Fixed DJGPP mouse pointer in 8 and 16 bit.

This commit is contained in:
Scott Duensing 2022-06-03 19:25:55 -05:00
parent 4d0b209adc
commit 4c7be223a9
6 changed files with 52 additions and 19 deletions

View file

@ -16,6 +16,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
BACKEND=DJGPP
#BACKEND=GRX
# General
CC = gcc
LD = gcc
@ -32,7 +35,7 @@ BINDIR = bin
## CHANGE THIS ##
# CFLAGS, LDFLAGS, CPPFLAGS, PREFIX can be overriden on CLI
CFLAGS := $(DEBUG) -DBACKEND_DJGPP
CFLAGS := $(DEBUG)
CFLAGS += -I$(SRCDIR)/shared -I$(SRCDIR)/client/src
CPPFLAGS :=
LDFLAGS :=
@ -40,11 +43,22 @@ LDLIBS :=
PREFIX :=
TARGET_ARCH :=
# GRX
#CFLAGS += -I$(SRCDIR)/installed/dos/include
#LDFLAGS := -L$(SRCDIR)/installed/dos/lib
#LDLIBS := -lgrx20 -ljpeg -lpng -lz
# DJGPP
ifeq ($(BACKEND),DJGPP)
$(info Building DJGPP Backend)
CFLAGS += -DBACKEND_DJGPP
TARGET = vesa
endif
# GRX
ifeq ($(BACKEND),GRX)
$(info Building GRX Backend)
CFLAGS += -DBACKEND_GRX
CFLAGS += -I$(SRCDIR)/installed/dos/include
LDFLAGS := -L$(SRCDIR)/installed/dos/lib
LDLIBS := -lgrx20 -ljpeg -lpng -lz
TARGET = grx
endif
# Compiler Flags
ALL_CFLAGS := $(CFLAGS)

View file

@ -33,4 +33,6 @@ source /opt/cross/djgpp/setenv
make -f Makefile.djgpp
rm bin/client
[[ -f bin/client ]] && rm bin/client
[[ -f bin/vesa ]] && rm bin/vesa
[[ -f bin/grx ]] && rm bin/grx

View file

@ -13,10 +13,10 @@ int main(int argc, char *argv[]) {
if (guiStartup(800, 600, 32) == SUCCESS) {
i = 1;
//for (i=1; i<4; i++) {
for (i=1; i<4; i++) {
sprintf(title, "Testing %d", i);
windowCreate(i * 50, i * 50, 300, 200, title, WIN_CLOSE | WIN_MAXIMIZE | WIN_MINIMIZE | WIN_RESIZE);
//}
}
guiRun();
guiShutdown();
}

View file

@ -176,13 +176,18 @@ static uint16_t vbeSelectModeNumber(uint16_t xRes, uint16_t yRes, uint8_t b
static VBESurfaceT *vbeSetMode(uint16_t vbeModeNumber);
static uint16_t vbeSetScanlineLength(uint16_t pixelLength);
static ColorT videoSurfacePixelGet8(SurfaceT *surface, int16_t x, int16_t y);
static ColorT videoSurfacePixelGet16(SurfaceT *surface, int16_t x, int16_t y);
static ColorT videoSurfacePixelGet32(SurfaceT *surface, int16_t x, int16_t y);
static void videoSurfacePixelSet8(uint16_t x, uint16_t y, ColorT color);
static void videoSurfacePixelSet16(uint16_t x, uint16_t y, ColorT color);
static void videoSurfacePixelSet32(uint16_t x, uint16_t y, ColorT color);
static void (*pmVBESetDisplayStart)(void);
void (*videoSurfacePixelSet)(uint16_t x, uint16_t y, ColorT color);
ColorT (*videoSurfacePixelGet)(SurfaceT *surface, int16_t x, int16_t y);
void (*videoSurfacePixelSet)(uint16_t x, uint16_t y, ColorT color);
void platformEventGet(EventT *event) {
@ -370,10 +375,10 @@ uint8_t platformStartup(int16_t width, int16_t height, int16_t depth) {
return FAIL;
}
if (_vbeSurface.bitsPerPixel == 8) videoSurfacePixelSet = videoSurfacePixelSet8;
if (_vbeSurface.bitsPerPixel == 16) videoSurfacePixelSet = videoSurfacePixelSet16;
if (_vbeSurface.bitsPerPixel == 15) videoSurfacePixelSet = videoSurfacePixelSet16;
if (_vbeSurface.bitsPerPixel == 32) videoSurfacePixelSet = videoSurfacePixelSet32;
if (_vbeSurface.bitsPerPixel == 8) { videoSurfacePixelSet = videoSurfacePixelSet8; videoSurfacePixelGet = videoSurfacePixelGet8; }
if (_vbeSurface.bitsPerPixel == 16) { videoSurfacePixelSet = videoSurfacePixelSet16; videoSurfacePixelGet = videoSurfacePixelGet16; }
if (_vbeSurface.bitsPerPixel == 15) { videoSurfacePixelSet = videoSurfacePixelSet16; videoSurfacePixelGet = videoSurfacePixelGet16; }
if (_vbeSurface.bitsPerPixel == 32) { videoSurfacePixelSet = videoSurfacePixelSet32; videoSurfacePixelGet = videoSurfacePixelGet32; }
__guiBaseColors = (ColorT *)malloc(sizeof(ColorT) * 16);
for (i=0; i<16; i++) {
@ -828,7 +833,7 @@ void videoSurfaceBlitWithTransparency(SurfaceT *target, int16_t targetX, int16_t
for (y1=0; y1<y2; y1++) {
for (x1=0; x1<x2; x1++) {
pixel = source->buffer.bits32[y1 * source->width + x1];
pixel = videoSurfacePixelGet(source, x1, y1);
if (transparent != pixel) {
videoSurfacePixelSet(targetX + x1, targetY + y1, pixel);
}
@ -970,7 +975,17 @@ void videoSurfaceLineV(int16_t x, int16_t y1, int16_t y2, ColorT c) {
}
ColorT videoSurfacePixelGet(SurfaceT *surface, int16_t x, int16_t y) {
static ColorT videoSurfacePixelGet8(SurfaceT *surface, int16_t x, int16_t y) {
return surface->buffer.bits8[y * surface->width + x];
}
static ColorT videoSurfacePixelGet16(SurfaceT *surface, int16_t x, int16_t y) {
return surface->buffer.bits16[y * surface->width + x];
}
static ColorT videoSurfacePixelGet32(SurfaceT *surface, int16_t x, int16_t y) {
return surface->buffer.bits32[y * surface->width + x];
}

View file

@ -47,7 +47,8 @@ typedef struct EventS {
#define KEY_ESC 27
extern void (*videoSurfacePixelSet)(uint16_t x, uint16_t y, ColorT color);
extern ColorT (*videoSurfacePixelGet)(SurfaceT *surface, int16_t x, int16_t y);
extern void (*videoSurfacePixelSet)(uint16_t x, uint16_t y, ColorT color);
void platformEventGet(EventT *event);
@ -65,7 +66,6 @@ SurfaceT *videoSurfaceGet(void);
int16_t videoSurfaceHeightGet(SurfaceT *surface);
void videoSurfaceLineH(int16_t x1, int16_t y1, int16_t x, ColorT c);
void videoSurfaceLineV(int16_t x, int16_t x2, int16_t y2, ColorT c);
ColorT videoSurfacePixelGet(SurfaceT *surface, int16_t x, int16_t y);
void videoSurfaceSet(SurfaceT *surface);
SurfaceT *videoSurfaceScreenGet(void);
int16_t videoSurfaceWidthGet(SurfaceT *surface);

View file

@ -26,10 +26,10 @@ void platformShutdown(void) {
}
void platformStartup(int16_t width, int16_t height, int16_t depth) {
uint8_t platformStartup(int16_t width, int16_t height, int16_t depth) {
// Set up graphics environment.
if (!GrSetMode(GR_width_height_bpp_graphics, width, height, depth)) {
//***TODO*** Die
return FAIL;
}
GrSetRGBcolorMode();
__guiBaseColors = GrAllocEgaColors(); // This does not need released.
@ -40,6 +40,8 @@ void platformStartup(int16_t width, int16_t height, int16_t depth) {
GrMouseSetCursorMode(GR_M_CUR_NORMAL);
// This is a total hack to prevent GRX from drawing the mouse pointer.
_GrMouseInfo.cursor = 0;
return SUCCESS;
}