diff --git a/Makefile.djgpp b/Makefile.djgpp
index cfd5b2c..a12ca2d 100644
--- a/Makefile.djgpp
+++ b/Makefile.djgpp
@@ -16,6 +16,9 @@
# along with this program. If not, see .
#
+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)
diff --git a/build.sh b/build.sh
index 3fe400f..7168b87 100755
--- a/build.sh
+++ b/build.sh
@@ -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
diff --git a/client/src/main.c b/client/src/main.c
index 61008a6..6413a77 100644
--- a/client/src/main.c
+++ b/client/src/main.c
@@ -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();
}
diff --git a/client/src/platform/djgpp.c b/client/src/platform/djgpp.c
index be49d91..9fdd083 100644
--- a/client/src/platform/djgpp.c
+++ b/client/src/platform/djgpp.c
@@ -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; y1buffer.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];
}
diff --git a/client/src/platform/djgpp.h b/client/src/platform/djgpp.h
index f6f4eb1..93cacf9 100644
--- a/client/src/platform/djgpp.h
+++ b/client/src/platform/djgpp.h
@@ -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);
diff --git a/client/src/platform/grx.c b/client/src/platform/grx.c
index c6bcf2a..de87580 100644
--- a/client/src/platform/grx.c
+++ b/client/src/platform/grx.c
@@ -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;
}