Renamed byte/bool/true/false/new to make C++ based tools happy.

This commit is contained in:
Scott Duensing 2021-04-19 19:20:07 -05:00
parent 379ba1318a
commit 9a897ec8ef
6 changed files with 214 additions and 194 deletions

View file

@ -29,8 +29,6 @@
#include <sound.h> #include <sound.h>
#include <MIDISynth.h> #include <MIDISynth.h>
#include <Orca.h> #include <Orca.h>
#undef false
#undef true
#include "joey.h" #include "joey.h"
@ -76,17 +74,17 @@ extern pascal void NTPContinueMusic(void) inline(0x14DE, dispatcher);
char _jlKeyCheck(char key); char _jlKeyCheck(char key);
static byte *KEYBOARD = (byte *)0x00C000L; static jbyte *KEYBOARD = (jbyte *)0x00C000L;
static byte *KEYSTROBE = (byte *)0x00C010L; static jbyte *KEYSTROBE = (jbyte *)0x00C010L;
static byte *BUTTON0 = (byte *)0x00C061L; static jbyte *BUTTON0 = (jbyte *)0x00C061L;
static byte *BUTTON1 = (byte *)0x00C062L; static jbyte *BUTTON1 = (jbyte *)0x00C062L;
static jlPixelPairT *SHRPIXELS = (jlPixelPairT *)0x012000L; // Shadow of 0xE12000 static jlPixelPairT *SHRPIXELS = (jlPixelPairT *)0x012000L; // Shadow of 0xE12000
static byte *SHRSCB = (byte *)0x019D00L; // Shadow of 0xE19D00 static jbyte *SHRSCB = (jbyte *)0x019D00L; // Shadow of 0xE19D00
static jlColorT *SHRCOLORS = (jlColorT *)0x019E00L; // Shadow of 0xE19E00 static jlColorT *SHRCOLORS = (jlColorT *)0x019E00L; // Shadow of 0xE19E00
static byte *BORDER = (byte *)0xE0C034L; static jbyte *BORDER = (jbyte *)0xE0C034L;
static byte _jlBorderSaved; static jbyte _jlBorderSaved;
static jint16 _jlHertz; static jint16 _jlHertz;
@ -129,7 +127,7 @@ void jlDrawSurfaceSet(jlSurfaceT target) {
} }
int jlGameGetAxis(byte which) { int jlGameGetAxis(jbyte which) {
jint16 r; jint16 r;
if (which == 0) { if (which == 0) {
@ -142,20 +140,20 @@ int jlGameGetAxis(byte which) {
} }
bool jlGameGetButton(byte which) { jbool jlGameGetButton(jbyte which) {
if (which > 0) return (bool)(*BUTTON1 > 127); if (which > 0) return (jbool)(*BUTTON1 > 127);
return (bool)(*BUTTON0 > 127); return (jbool)(*BUTTON0 > 127);
} }
bool _jlImgCreate(jlImgT **img) { jbool _jlImgCreate(jlImgT **img) {
jlImgT *t = NULL; jlImgT *t = NULL;
// Are we loading into a new image? // Are we loading into a new image?
if (*img == NULL) { if (*img == NULL) {
t = (jlImgT *)jlMalloc(sizeof(jlImgT)); t = (jlImgT *)jlMalloc(sizeof(jlImgT));
if (t == NULL) { if (t == NULL) {
return false; return jfalse;
} }
*img = t; *img = t;
} }
@ -167,7 +165,7 @@ bool _jlImgCreate(jlImgT **img) {
memcpy(t->palette, SHRCOLORS, sizeof(t->palette)); memcpy(t->palette, SHRCOLORS, sizeof(t->palette));
memcpy(t->pixels, SHRPIXELS, sizeof(t->pixels)); memcpy(t->pixels, SHRPIXELS, sizeof(t->pixels));
*img = t; *img = t;
return true; return jtrue;
} }
@ -200,11 +198,11 @@ char _jlKeyCheck(char key) {
} }
bool jlKeyPressed(void) { jbool jlKeyPressed(void) {
bool result = false; jbool result = jfalse;
// On other platforms we should call jlIdle() here. // On other platforms we should call jlIdle() here.
if ((*KEYBOARD & 0x80) != 0) { if ((*KEYBOARD & 0x80) != 0) {
result = (_jlKeyCheck(*KEYBOARD & 0x7F) != 0); result = (_jlKeyCheck(*KEYBOARD & 0x7F) != 0) ? jtrue : jfalse;
} }
return result; return result;
} }
@ -220,7 +218,7 @@ char jlKeyRead(void) {
} }
void jlPaletteSet(byte index, byte r, byte g, byte b) { void jlPaletteSet(jbyte index, jbyte r, jbyte g, jbyte b) {
SHRCOLORS[index].r = r; SHRCOLORS[index].r = r;
SHRCOLORS[index].g = g; SHRCOLORS[index].g = g;
SHRCOLORS[index].b = b; SHRCOLORS[index].b = b;
@ -237,8 +235,8 @@ void jlSoundModContinue(void) {
} }
bool jlSoundModIsPlaying(void) { jbool jlSoundModIsPlaying(void) {
return (NTPGetPlayingMusic() != 0xFFFF); return (NTPGetPlayingMusic() != 0xFFFF) ? jtrue : jfalse;
} }
@ -256,7 +254,7 @@ void jlSoundModPlay(char *name) {
JOEY_CHECK_TOOL_ERROR("NTPStartup") JOEY_CHECK_TOOL_ERROR("NTPStartup")
NTPLoadOneMusic((Pointer)&file); NTPLoadOneMusic((Pointer)&file);
JOEY_CHECK_TOOL_ERROR("NTPLoadOneMusic") JOEY_CHECK_TOOL_ERROR("NTPLoadOneMusic")
NTPPlayMusic(false); NTPPlayMusic(jfalse);
JOEY_CHECK_TOOL_ERROR("NTPPlayMusic") JOEY_CHECK_TOOL_ERROR("NTPPlayMusic")
} }

View file

@ -124,7 +124,7 @@ void jlDrawClear(void) {
} }
byte jlDrawPixelGet(jint16 x, jint16 y) { jbyte jlDrawPixelGet(jint16 x, jint16 y) {
jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual; jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual;
int p = x / 2 + y * 160; int p = x / 2 + y * 160;
return (jlUtilIsOdd(x) ? target[p].l : target[p].r); return (jlUtilIsOdd(x) ? target[p].l : target[p].r);
@ -153,14 +153,14 @@ void jlDrawSurfaceSet(jlSurfaceT target) {
} }
bool _jlImgCreate(jlImgT **img) { jbool _jlImgCreate(jlImgT **img) {
jlImgT *t = NULL; jlImgT *t = NULL;
// Are we loading into a new image? // Are we loading into a new image?
if (*img == NULL) { if (*img == NULL) {
t = (jlImgT *)jlMalloc(sizeof(jlImgT)); t = (jlImgT *)jlMalloc(sizeof(jlImgT));
if (t == NULL) { if (t == NULL) {
return false; return jfalse;
} }
*img = t; *img = t;
} }
@ -175,7 +175,7 @@ bool _jlImgCreate(jlImgT **img) {
memcpy(t->pixels, _jlBackingStore->pixels, sizeof(t->pixels)); memcpy(t->pixels, _jlBackingStore->pixels, sizeof(t->pixels));
} }
*img = t; *img = t;
return true; return jtrue;
} }
@ -185,7 +185,7 @@ void jlImgDisplay(jlImgT *img) {
} }
void jlPaletteSet(byte index, byte r, byte g, byte b) { void jlPaletteSet(jbyte index, jbyte r, jbyte g, jbyte b) {
_jlBackingStore->palette[index].r = r; _jlBackingStore->palette[index].r = r;
_jlBackingStore->palette[index].g = g; _jlBackingStore->palette[index].g = g;
_jlBackingStore->palette[index].b = b; _jlBackingStore->palette[index].b = b;

View file

@ -40,7 +40,7 @@ static SDL_Window *_jlWindow = NULL;
static SDL_Renderer *_jlRenderer = NULL; static SDL_Renderer *_jlRenderer = NULL;
static SDL_Texture *_jlTexture = NULL; // Video card representation in ARGB static SDL_Texture *_jlTexture = NULL; // Video card representation in ARGB
static SDL_PixelFormat *_jlPixelFormat = NULL; // Pixel format of _jlTexture static SDL_PixelFormat *_jlPixelFormat = NULL; // Pixel format of _jlTexture
static bool _jlIsRunning = true; static jbool _jlIsRunning = jtrue;
static jint16 _jlNumKeysDown = 0; static jint16 _jlNumKeysDown = 0;
static char _jlLastKey = 0; static char _jlLastKey = 0;
static Mix_Music *_jlMusicHandle = NULL; static Mix_Music *_jlMusicHandle = NULL;
@ -159,7 +159,7 @@ void jlDisplayPresent(void) {
} }
jint16 jlGameGetAxis(byte which) { jint16 jlGameGetAxis(jbyte which) {
SDL_GameControllerAxis axis; SDL_GameControllerAxis axis;
short int unscaled; short int unscaled;
short int max = SHRT_MIN; short int max = SHRT_MIN;
@ -191,10 +191,10 @@ jint16 jlGameGetAxis(byte which) {
} }
bool jlGameGetButton(byte which) { jbool jlGameGetButton(jbyte which) {
SDL_GameControllerButton button; SDL_GameControllerButton button;
int x; int x;
bool pressed = false; jbool pressed = jfalse;
jlUtilIdle(); jlUtilIdle();
@ -206,7 +206,7 @@ bool jlGameGetButton(byte which) {
for (x=0; x<_jlControllerCount; x++) { for (x=0; x<_jlControllerCount; x++) {
if (SDL_GameControllerGetButton(_jlControllers[x], button)) { if (SDL_GameControllerGetButton(_jlControllers[x], button)) {
pressed = true; pressed = jtrue;
break; break;
} }
} }
@ -215,7 +215,7 @@ bool jlGameGetButton(byte which) {
} }
bool jlKeyPressed(void) { jbool jlKeyPressed(void) {
jlUtilIdle(); jlUtilIdle();
return (_jlNumKeysDown > 0); return (_jlNumKeysDown > 0);
} }
@ -237,13 +237,13 @@ void jlSoundFree(jlSoundT *sound) {
} }
bool jlSoundIsPlaying(jlSoundT *sound) { jbool jlSoundIsPlaying(jlSoundT *sound) {
return (Mix_Playing(sound->channel) > 0); return (Mix_Playing(sound->channel) > 0);
} }
bool _jlSoundLoad(jlSoundT **sound, char *filename) { jbool _jlSoundLoad(jlSoundT **sound, char *filename) {
bool result = false; jbool result = jfalse;
Mix_Chunk *sample; Mix_Chunk *sample;
sample = Mix_LoadWAV(jlUtilMakePathname(filename, "ogg")); sample = Mix_LoadWAV(jlUtilMakePathname(filename, "ogg"));
if (sample) { if (sample) {
@ -254,7 +254,7 @@ bool _jlSoundLoad(jlSoundT **sound, char *filename) {
if (t != NULL) { if (t != NULL) {
t->data = (void *)sample; t->data = (void *)sample;
*sound = t; *sound = t;
result = true; result = jtrue;
} }
} }
return result; return result;
@ -266,8 +266,8 @@ void jlSoundModContinue(void) {
} }
bool jlSoundModIsPlaying(void) { jbool jlSoundModIsPlaying(void) {
return (bool)Mix_PlayingMusic(); return (jbool)Mix_PlayingMusic();
} }
@ -381,7 +381,7 @@ void jlUtilIdle(void) {
break; break;
case SDL_QUIT: case SDL_QUIT:
_jlIsRunning = false; _jlIsRunning = jfalse;
break; break;
} }
} }
@ -392,7 +392,7 @@ void jlUtilIdle(void) {
} }
bool jlUtilMustExit(void) { jbool jlUtilMustExit(void) {
return !_jlIsRunning; return !_jlIsRunning;
} }

View file

@ -62,30 +62,30 @@ typedef struct {
jint16 EndX; jint16 EndX;
jint16 Y; jint16 Y;
signed char Dir; // 'signed' needs to be specified for ORCA/C signed char Dir; // 'signed' needs to be specified for ORCA/C
bool ScanLeft; jbool ScanLeft;
bool ScanRight; jbool ScanRight;
bool padding; // Aligns structure on x86 jbool padding; // Aligns structure on x86
} _jlScanDataT; } _jlScanDataT;
jlSurfaceT _jlDrawTarget = JOEY_DISPLAY; jlSurfaceT _jlDrawTarget = JOEY_DISPLAY;
jlSurfaceT _jlDrawTargetActual = NULL; jlSurfaceT _jlDrawTargetActual = NULL;
byte _jlDrawColor = 15; // Color in lower nibble only jbyte _jlDrawColor = 15; // Color in lower nibble only
byte _jlDrawColorNibbles = (15 << 4) + 15; // Color in both nibbles jbyte _jlDrawColorNibbles = (15 << 4) + 15; // Color in both nibbles
byte _jlBorderColor = 0; jbyte _jlBorderColor = 0;
char _jlTempString[1024]; // Used internally for pathname operations char _jlTempString[1024]; // Used internally for pathname operations
static jlColorT _jlDefaultPalette[16]; static jlColorT _jlDefaultPalette[16];
static jlStackT *_jlFillStackTop = NULL; static jlStackT *_jlFillStackTop = NULL;
static byte _jlDrawFillColor = 0; static jbyte _jlDrawFillColor = 0;
static juint32 _jlSeed = 0; static juint32 _jlSeed = 0;
void _jlDrawCircleClipped(jint16 x0, jint16 y0, jint16 radius); void _jlDrawCircleClipped(jint16 x0, jint16 y0, jint16 radius);
void _jlDrawFill(jint16 x, jint16 y, bool how); void _jlDrawFill(jint16 x, jint16 y, jbool how);
void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart, jint16 ignoreEnd, char dir, bool isNextInDir, bool how); void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart, jint16 ignoreEnd, char dir, jbool isNextInDir, jbool how);
_jlScanDataT *_jlDrawFillNewSegment(jint16 startX, jint16 endX, jint16 y, signed char dir, bool scanLeft, bool scanRight); _jlScanDataT *_jlDrawFillNewSegment(jint16 startX, jint16 endX, jint16 y, signed char dir, jbool scanLeft, jbool scanRight);
#ifdef JOEY_DEBUG #ifdef JOEY_DEBUG
@ -98,7 +98,7 @@ static long _jlTotalAllocations = 0;
static long _jlTotalFrees = 0; static long _jlTotalFrees = 0;
static long _jlHighWaterMark = 0; static long _jlHighWaterMark = 0;
static long _jlBlocksNeeded = 0; static long _jlBlocksNeeded = 0;
static bool _jlMemoryStarted = false; static jbool _jlMemoryStarted = jfalse;
void _jlFree(void **pointer) { void _jlFree(void **pointer) {
jint16 i; jint16 i;
@ -125,7 +125,7 @@ void *_jlMalloc(size_t size, jint16 line, char *file) {
if (!_jlMemoryStarted) { if (!_jlMemoryStarted) {
memset(_jlMemoryBlocks, 0, sizeof(_jlMemoryBlocks)); memset(_jlMemoryBlocks, 0, sizeof(_jlMemoryBlocks));
_jlMemoryStarted = true; _jlMemoryStarted = jtrue;
} }
_jlTotalAllocations++; _jlTotalAllocations++;
@ -182,7 +182,7 @@ void *_jlRealloc(void *pointer, size_t size) {
#ifndef JL_HAS_DISPLAYBORDER #ifndef JL_HAS_DISPLAYBORDER
void jlDisplayBorder(jlBorderColorsE color) { void jlDisplayBorder(jlBorderColorsE color) {
_jlBorderColor = (byte)color; _jlBorderColor = (jbyte)color;
} }
#endif #endif
@ -219,7 +219,7 @@ void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, ji
#ifndef JL_HAS_DRAWBLITMAP #ifndef JL_HAS_DRAWBLITMAP
//***FIX*** This no longer does what we want since blitting source addresses are now in pixels. Fix! //***FIX*** This no longer does what we want since blitting source addresses are now in pixels. Fix!
void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlSurfaceT source) { void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, jbyte *mapData, juint16 stride, jlSurfaceT source) {
// startX = start tile for drawing - in pixels // startX = start tile for drawing - in pixels
// startY = start tile for drawing - in pixels // startY = start tile for drawing - in pixels
// width = tiles to draw horizontally - in tiles // width = tiles to draw horizontally - in tiles
@ -229,8 +229,8 @@ void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, by
// tiles = surface to fetch tile data from // tiles = surface to fetch tile data from
jint16 x; jint16 x;
jint16 y; jint16 y;
byte tileX; jbyte tileX;
byte tileY; jbyte tileY;
juint16 offset = 0; juint16 offset = 0;
jint16 endX = width * 8 + startX; jint16 endX = width * 8 + startX;
jint16 endY = height * 8 + startY; jint16 endY = height * 8 + startY;
@ -346,16 +346,16 @@ void jlDrawClear(void) {
#ifndef JL_HAS_DRAWCOLORGET #ifndef JL_HAS_DRAWCOLORGET
byte jlDrawColorGet(void) { jbyte jlDrawColorGet(void) {
return _jlDrawColor; return _jlDrawColor;
} }
#endif #endif
#ifndef JL_HAS_DRAWCOLORSET #ifndef JL_HAS_DRAWCOLORSET
void jlDrawColorSet(byte index) { void jlDrawColorSet(jbyte index) {
_jlDrawColor = index; _jlDrawColor = index;
_jlDrawColorNibbles = (byte)((index << 4) + index); _jlDrawColorNibbles = (jbyte)((index << 4) + index);
} }
#endif #endif
@ -393,7 +393,7 @@ void jlDrawEllipse(jint16 x0, jint16 y0, jint16 x1, jint16 y1) {
#if !defined(JL_HAS_DRAWFILL) && !defined(JL_HASDRAWFILLTO) #if !defined(JL_HAS_DRAWFILL) && !defined(JL_HASDRAWFILLTO)
_jlScanDataT *_jlDrawFillNewSegment(jint16 startX, jint16 endX, jint16 y, signed char dir, bool scanLeft, bool scanRight) { _jlScanDataT *_jlDrawFillNewSegment(jint16 startX, jint16 endX, jint16 y, signed char dir, jbool scanLeft, jbool scanRight) {
_jlScanDataT *s = (_jlScanDataT *)jlMalloc(sizeof(_jlScanDataT)); _jlScanDataT *s = (_jlScanDataT *)jlMalloc(sizeof(_jlScanDataT));
s->StartX = startX; s->StartX = startX;
s->EndX = endX; s->EndX = endX;
@ -405,7 +405,7 @@ _jlScanDataT *_jlDrawFillNewSegment(jint16 startX, jint16 endX, jint16 y, signed
} }
void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart, jint16 ignoreEnd, char dir, bool isNextInDir, bool how) { void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart, jint16 ignoreEnd, char dir, jbool isNextInDir, jbool how) {
jint16 regionStart = -1; jint16 regionStart = -1;
jint16 x; jint16 x;
@ -416,7 +416,7 @@ void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart
jlDrawPixelSet(x, y); jlDrawPixelSet(x, y);
if (regionStart < 0) regionStart = x; if (regionStart < 0) regionStart = x;
} else if (regionStart >= 0) { } else if (regionStart >= 0) {
jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, false)); jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, jfalse));
regionStart = -1; regionStart = -1;
} }
} else { } else {
@ -425,20 +425,20 @@ void _jlDrawFillAddLine(jint16 startX, jint16 endX, jint16 y, jint16 ignoreStart
jlDrawPixelSet(x, y); jlDrawPixelSet(x, y);
if (regionStart < 0) regionStart = x; if (regionStart < 0) regionStart = x;
} else if (regionStart >= 0) { } else if (regionStart >= 0) {
jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, false)); jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, jfalse));
regionStart = -1; regionStart = -1;
} }
} }
if (!isNextInDir && x < ignoreEnd && x >= ignoreStart) x = ignoreEnd-1; if (!isNextInDir && x < ignoreEnd && x >= ignoreStart) x = ignoreEnd-1;
} }
if (regionStart >= 0) { if (regionStart >= 0) {
jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, true)); jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(regionStart, x, y, dir, regionStart == startX, jtrue));
} }
} }
// Stole this from http://www.adammil.net/blog/v126_A_More_Efficient_Flood_Fill.html // Stole this from http://www.adammil.net/blog/v126_A_More_Efficient_Flood_Fill.html
void _jlDrawFill(jint16 x, jint16 y, bool how) { void _jlDrawFill(jint16 x, jint16 y, jbool how) {
jint16 height = 200; jint16 height = 200;
jint16 width = 320; jint16 width = 320;
_jlScanDataT *r; _jlScanDataT *r;
@ -450,7 +450,7 @@ void _jlDrawFill(jint16 x, jint16 y, bool how) {
jlDrawPixelSet(x, y); jlDrawPixelSet(x, y);
jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(x, x+1, y, 0, true, true)); jlUtilStackPush(_jlFillStackTop, _jlDrawFillNewSegment(x, x+1, y, 0, jtrue, jtrue));
while ((r = jlUtilStackPop(_jlFillStackTop)) != NULL) { while ((r = jlUtilStackPop(_jlFillStackTop)) != NULL) {
startX = r->StartX; startX = r->StartX;
endX = r->EndX; endX = r->EndX;
@ -481,15 +481,15 @@ void _jlDrawFill(jint16 x, jint16 y, bool how) {
#ifndef JL_HAS_DRAWFILL #ifndef JL_HAS_DRAWFILL
void jlDrawFill(jint16 x, jint16 y) { void jlDrawFill(jint16 x, jint16 y) {
_jlDrawFillColor = jlDrawPixelGet(x, y); _jlDrawFillColor = jlDrawPixelGet(x, y);
_jlDrawFill(x, y, true); _jlDrawFill(x, y, jtrue);
} }
#endif #endif
#ifndef JL_HAS_DRAWFILLTO #ifndef JL_HAS_DRAWFILLTO
void jlDrawFillTo(jint16 x, jint16 y, byte color) { void jlDrawFillTo(jint16 x, jint16 y, jbyte color) {
_jlDrawFillColor = color; _jlDrawFillColor = color;
_jlDrawFill(x, y, false); _jlDrawFill(x, y, jfalse);
} }
#endif #endif
@ -557,7 +557,7 @@ void jlDrawLine(jint16 x1, jint16 y1, jint16 x2, jint16 y2) {
#ifndef JL_HAS_DRAWPIXELGET #ifndef JL_HAS_DRAWPIXELGET
byte jlDrawPixelGet(jint16 x, jint16 y) { jbyte jlDrawPixelGet(jint16 x, jint16 y) {
(void)x; (void)x;
(void)y; (void)y;
return 0; return 0;
@ -589,7 +589,7 @@ void jlDrawSurfaceSet(jlSurfaceT target) {
#ifndef JL_HAS_GAMEGETAXIS #ifndef JL_HAS_GAMEGETAXIS
jint16 jlGameGetAxis(byte which) { jint16 jlGameGetAxis(jbyte which) {
(void)which; (void)which;
return 0; return 0;
} }
@ -597,35 +597,34 @@ jint16 jlGameGetAxis(byte which) {
#ifndef JL_HAS_GAMEGETBUTTON #ifndef JL_HAS_GAMEGETBUTTON
bool jlGameGetButton(byte which) { jbool jlGameGetButton(jbyte which) {
(void)which; (void)which;
return false; return jfalse;
} }
#endif #endif
#ifndef JL_HAS_IMGCOPY #ifndef JL_HAS_IMGCOPY
bool _jlImgCopy(jlImgT *source, jlImgT **target) { jbool _jlImgCopy(jlImgT *source, jlImgT **target) {
jlImgT *t = NULL; jlImgT *t = NULL;
// Are we copying into a new image? // Are we copying into a new image?
if (*target == NULL) { if (*target == NULL) {
t = (jlImgT *)jlMalloc(sizeof(jlImgT)); t = (jlImgT *)jlMalloc(sizeof(jlImgT));
if (t == NULL) { if (t == NULL) {
return false; return jfalse;
} }
*target = t; *target = t;
} }
t = (jlImgT *)*target;
memcpy(*target, source, sizeof(jlImgT)); memcpy(*target, source, sizeof(jlImgT));
return true; return jtrue;
} }
#endif #endif
#ifndef JL_HAS_IMGCREATE #ifndef JL_HAS_IMGCREATE
bool _jlImgCreate(jlImgT **img) { jbool _jlImgCreate(jlImgT **img) {
(void)img; (void)img;
return false; return jfalse;
} }
#endif #endif
@ -647,8 +646,8 @@ void jlImgFree(jlImgT *img) {
#ifndef JL_HAS_IMGLOAD #ifndef JL_HAS_IMGLOAD
bool _jlImgLoad(jlImgT **img, char *filename) { jbool _jlImgLoad(jlImgT **img, char *filename) {
bool result = false; jbool result = jfalse;
jlImgT *s = NULL; jlImgT *s = NULL;
FILE *f = NULL; FILE *f = NULL;
@ -662,12 +661,16 @@ bool _jlImgLoad(jlImgT **img, char *filename) {
} }
s = (jlImgT *)*img; s = (jlImgT *)*img;
// Load into it. // Load into it.
#ifdef JOEY_TOOLS
f = fopen(filename, "rb");
#else
f = fopen(jlUtilMakePathname(filename, "img"), "rb"); f = fopen(jlUtilMakePathname(filename, "img"), "rb");
#endif
if (f != NULL) { if (f != NULL) {
if (fread(s, sizeof(jlImgT), 1, f) > 0) { if (fread(s, sizeof(jlImgT), 1, f) > 0) {
// Is this a valid image file? // Is this a valid image file?
if ((s->id[0] == 'I') && (s->id[1] == 'M') && (s->id[2] == 'G') && (s->version <= 0)) { if ((s->id[0] == 'I') && (s->id[1] == 'M') && (s->id[2] == 'G') && (s->version <= 0)) {
result = true; result = jtrue;
} }
} }
fclose(f); fclose(f);
@ -678,14 +681,18 @@ bool _jlImgLoad(jlImgT **img, char *filename) {
#ifndef JL_HAS_IMGSAVE #ifndef JL_HAS_IMGSAVE
bool jlImgSave(jlImgT *img, char *filename) { jbool jlImgSave(jlImgT *img, char *filename) {
bool result = false; jbool result = jfalse;
FILE *f; FILE *f;
#ifdef JOEY_TOOLS
f = fopen(filename, "wb");
#else
f = fopen(jlUtilMakePathname(filename, "img"), "wb"); f = fopen(jlUtilMakePathname(filename, "img"), "wb");
#endif
if (f != NULL) { if (f != NULL) {
if (fwrite(img, sizeof(jlImgT), 1, f) > 0) { if (fwrite(img, sizeof(jlImgT), 1, f) > 0) {
result = true; result = jtrue;
} }
} }
return result; return result;
@ -694,8 +701,8 @@ bool jlImgSave(jlImgT *img, char *filename) {
#ifndef JL_HAS_KEYPRESSED #ifndef JL_HAS_KEYPRESSED
bool jlKeyPressed(void) { jbool jlKeyPressed(void) {
return false; return jfalse;
} }
#endif #endif
@ -719,7 +726,7 @@ void jlKeyWaitForAny(void) {
#ifndef JL_HAS_PALETTEDEFAULT #ifndef JL_HAS_PALETTEDEFAULT
void jlPaletteDefault(void) { void jlPaletteDefault(void) {
byte i; jbyte i;
// Set palette. // Set palette.
_jlDefaultPalette[ 0].r = 0; _jlDefaultPalette[ 0].g = 0; _jlDefaultPalette[ 0].b = 0; // 000000 Black _jlDefaultPalette[ 0].r = 0; _jlDefaultPalette[ 0].g = 0; _jlDefaultPalette[ 0].b = 0; // 000000 Black
_jlDefaultPalette[ 1].r = 0; _jlDefaultPalette[ 1].g = 0; _jlDefaultPalette[ 1].b = 10; // 0000AA Blue _jlDefaultPalette[ 1].r = 0; _jlDefaultPalette[ 1].g = 0; _jlDefaultPalette[ 1].b = 10; // 0000AA Blue
@ -745,7 +752,7 @@ void jlPaletteDefault(void) {
#ifndef JL_HAS_PALETTESET #ifndef JL_HAS_PALETTESET
void jlPaletteSet(byte index, byte r, byte g, byte b) { void jlPaletteSet(jbyte index, jbyte r, jbyte g, jbyte b) {
(void)index; (void)index;
(void)r; (void)r;
(void)g; (void)g;
@ -770,18 +777,18 @@ void jlSoundFree(jlSoundT *sound) {
#ifndef JL_HAS_SOUNDISPLAYING #ifndef JL_HAS_SOUNDISPLAYING
bool jlSoundIsPlaying(jlSoundT *sound) { jbool jlSoundIsPlaying(jlSoundT *sound) {
(void)sound; (void)sound;
return false; return jfalse;
} }
#endif #endif
#ifndef JL_HAS_SOUNDLOAD #ifndef JL_HAS_SOUNDLOAD
bool _jlSoundLoad(jlSoundT **sound, char *filename) { jbool _jlSoundLoad(jlSoundT **sound, char *filename) {
(void)sound; (void)sound;
(void)filename; (void)filename;
return false; return jfalse;
} }
#endif #endif
@ -794,8 +801,8 @@ void jlSoundMidiContinue(void) {
#ifndef JL_HAS_SOUNDMIDIISPLAYING #ifndef JL_HAS_SOUNDMIDIISPLAYING
bool jlSoundMidiIsPlaying(void) { jbool jlSoundMidiIsPlaying(void) {
return false; return jfalse;
} }
#endif #endif
@ -829,8 +836,8 @@ void jlSoundModContinue(void) {
#ifndef JL_HAS_SOUNDMODISPLAYING #ifndef JL_HAS_SOUNDMODISPLAYING
bool jlSoundModIsPlaying(void) { jbool jlSoundModIsPlaying(void) {
return false; return jfalse;
} }
#endif #endif
@ -873,8 +880,8 @@ void jlStnFree(jlStnT *stn) {
#ifndef JL_HAS_STNLOAD #ifndef JL_HAS_STNLOAD
bool _jlStnLoad(jlStnT **stn, char *filename) { jbool _jlStnLoad(jlStnT **stn, char *filename) {
bool result = false; jbool result = jfalse;
jlStnT *s = NULL; jlStnT *s = NULL;
FILE *f = NULL; FILE *f = NULL;
@ -888,12 +895,16 @@ bool _jlStnLoad(jlStnT **stn, char *filename) {
} }
s = (jlStnT *)*stn; s = (jlStnT *)*stn;
// Load into it. // Load into it.
#ifdef JOEY_TOOLS
f = fopen(filename, "rb");
#else
f = fopen(jlUtilMakePathname(filename, "stn"), "rb"); f = fopen(jlUtilMakePathname(filename, "stn"), "rb");
#endif
if (f != NULL) { if (f != NULL) {
if (fread(s, sizeof(jlStnT), 1, f) > 0) { if (fread(s, sizeof(jlStnT), 1, f) > 0) {
// Is this a valid stencil file? // Is this a valid stencil file?
if ((s->id[0] == 'S') && (s->id[1] == 'T') && (s->id[2] == 'N') && (s->version <= 0)) { if ((s->id[0] == 'S') && (s->id[1] == 'T') && (s->id[2] == 'N') && (s->version <= 0)) {
result = true; result = jtrue;
} }
} }
fclose(f); fclose(f);
@ -950,9 +961,9 @@ void jlUtilIdle(void) {
#ifndef JL_HAS_UTILINPUTREAD #ifndef JL_HAS_UTILINPUTREAD
bool jlUtilInputRead(byte *key) { jbool jlUtilInputRead(jbyte *key) {
static bool debounceController = false; static jbool debounceController = jfalse;
*key = 0; *key = 0;
@ -1009,7 +1020,7 @@ bool jlUtilInputRead(byte *key) {
break; break;
} }
return true; return jtrue;
} }
// Joystick // Joystick
@ -1023,16 +1034,16 @@ bool jlUtilInputRead(byte *key) {
// Debounce Joystick Input // Debounce Joystick Input
if (debounceController) { if (debounceController) {
*key = 0; *key = 0;
return false; return jfalse;
} else { } else {
if (*key != 0) { if (*key != 0) {
debounceController = true; debounceController = jtrue;
return true; return jtrue;
} }
} }
debounceController = false; debounceController = jfalse;
return false; return jfalse;
} }
#endif #endif
@ -1059,20 +1070,20 @@ char *jlUtilMakePathname(char *filename, char *extension) {
#ifndef JL_HAS_UTILMUSTEXIT #ifndef JL_HAS_UTILMUSTEXIT
bool jlUtilMustExit(void) { jbool jlUtilMustExit(void) {
return false; return jfalse;
} }
#endif #endif
#ifndef JL_HAS_UTILNIBBLESWAP #ifndef JL_HAS_UTILNIBBLESWAP
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new) { void jlUtilNibbleSwap(jbyte *mem, jint16 count, jbyte oldValue, jbyte newValue) {
int x; int x;
jlPixelPairT *b; jlPixelPairT *b;
for (x=0; x<count; x++) { for (x=0; x<count; x++) {
b = (jlPixelPairT *)&mem[x]; b = (jlPixelPairT *)&mem[x];
if (b->l == old) b->l = new; if (b->l == oldValue) b->l = newValue;
if (b->r == old) b->r = new; if (b->r == oldValue) b->r = newValue;
} }
} }
#endif #endif
@ -1180,7 +1191,7 @@ void jlVecDisplay(jlVecT *vec, jint16 ox, jint16 oy) {
case COMMAND_COLOR: case COMMAND_COLOR:
x1 = vec->data[p++]; x1 = vec->data[p++];
jlDrawColorSet((byte)x1); jlDrawColorSet((jbyte)x1);
break; break;
case COMMAND_CLEAR: case COMMAND_CLEAR:
@ -1229,7 +1240,7 @@ void jlVecDisplay(jlVecT *vec, jint16 ox, jint16 oy) {
y1 = vec->data[p++]; y1 = vec->data[p++];
x2 = vec->data[p++]; x2 = vec->data[p++];
y2 = vec->data[p++]; y2 = vec->data[p++];
jlPaletteSet((byte)x1,(byte)y1, (byte)x2, (byte)y2); jlPaletteSet((jbyte)x1,(jbyte)y1, (jbyte)x2, (jbyte)y2);
} }
break; break;
@ -1270,7 +1281,7 @@ void jlVecDisplay(jlVecT *vec, jint16 ox, jint16 oy) {
x1 = x1 + (jint16)(vec->data[p++] << 8); x1 = x1 + (jint16)(vec->data[p++] << 8);
y1 = oy + vec->data[p++]; y1 = oy + vec->data[p++];
x2 =vec->data[p++]; x2 =vec->data[p++];
jlDrawFillTo(x1, y1, (byte)x2); jlDrawFillTo(x1, y1, (jbyte)x2);
} }
break; break;
@ -1292,8 +1303,8 @@ void jlVecFree(jlVecT *vec) {
#ifndef JL_HAS_VECLOAD #ifndef JL_HAS_VECLOAD
bool _jlVecLoad(jlVecT **vec, char *filename) { jbool _jlVecLoad(jlVecT **vec, char *filename) {
bool result = false; jbool result = jfalse;
jlVecT *v = NULL; jlVecT *v = NULL;
FILE *f = NULL; FILE *f = NULL;
long size; long size;
@ -1309,22 +1320,26 @@ bool _jlVecLoad(jlVecT **vec, char *filename) {
*vec = v; *vec = v;
v = (jlVecT *)*vec; v = (jlVecT *)*vec;
// Load into it. // Load into it.
#ifdef JOEY_TOOLS
f = fopen(filename, "rb");
#else
f = fopen(jlUtilMakePathname(filename, "vec"), "rb"); f = fopen(jlUtilMakePathname(filename, "vec"), "rb");
#endif
if (f != NULL) { if (f != NULL) {
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
size = ftell(f); size = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
v->length = (juint16)((unsigned long)size - (sizeof(char) * 3) + (sizeof(byte))); v->length = (juint16)((unsigned long)size - (sizeof(char) * 3) + (sizeof(jbyte)));
// Load header. // Load header.
v->id[0] = (char)fgetc(f); v->id[0] = (char)fgetc(f);
v->id[1] = (char)fgetc(f); v->id[1] = (char)fgetc(f);
v->id[2] = (char)fgetc(f); v->id[2] = (char)fgetc(f);
v->version = (byte)fgetc(f); v->version = (jbyte)fgetc(f);
// Is this a valid image file? // Is this a valid image file?
if ((v->id[0] == 'V') && (v->id[1] == 'E') && (v->id[2] == 'C') && (v->version <= 0)) { if ((v->id[0] == 'V') && (v->id[1] == 'E') && (v->id[2] == 'C') && (v->version <= 0)) {
v->data = (byte *)jlMalloc(sizeof(byte) * v->length); v->data = (jbyte *)jlMalloc(sizeof(jbyte) * v->length);
if (fread(v->data, sizeof(byte), v->length, f) > 0) { if (fread(v->data, sizeof(jbyte), v->length, f) > 0) {
result = true; result = jtrue;
} else { } else {
jlFree(v->data); jlFree(v->data);
} }

View file

@ -22,6 +22,11 @@
#ifndef H_JOEY_ #ifndef H_JOEY_
#define H_JOEY_ #define H_JOEY_
#ifdef __cplusplus
extern "C" {
#endif
#define JOEY_DEBUG #define JOEY_DEBUG
@ -29,14 +34,12 @@
#include <limits.h> #include <limits.h>
#ifndef bool typedef unsigned char jbool;
typedef unsigned char bool; #define jtrue 1
#define true 1 #define jfalse 0
#define false 0
#endif
typedef unsigned char byte; typedef unsigned char jbyte;
#define JINT16_MIN -32768 #define JINT16_MIN -32768
@ -49,7 +52,7 @@ typedef unsigned char byte;
#define JUINT32_MIN 0 #define JUINT32_MIN 0
#define JUINT32_MAX 4294967295 #define JUINT32_MAX 4294967295
#define JOEY_DISPLAY (byte *)NULL #define JOEY_DISPLAY (jbyte *)NULL
#define JOEY_INPUT_NONE 0 #define JOEY_INPUT_NONE 0
#define JOEY_INPUT_UP 1 #define JOEY_INPUT_UP 1
@ -256,14 +259,14 @@ typedef unsigned long juint32;
#endif #endif
typedef byte *jlSurfaceT; typedef jbyte *jlSurfaceT;
extern jlSurfaceT _jlDrawTarget; extern jlSurfaceT _jlDrawTarget;
extern jlSurfaceT _jlDrawTargetActual; extern jlSurfaceT _jlDrawTargetActual;
extern byte _jlDrawColor; extern jbyte _jlDrawColor;
extern byte _jlDrawColorNibbles; extern jbyte _jlDrawColorNibbles;
extern byte _jlBorderColor; extern jbyte _jlBorderColor;
extern char _jlTempString[1024]; extern char _jlTempString[1024];
@ -288,15 +291,15 @@ enum _jlBorderColorsE {
typedef enum _jlBorderColorsE jlBorderColorsE; typedef enum _jlBorderColorsE jlBorderColorsE;
typedef struct { typedef struct {
byte b : 4; jbyte b : 4;
byte g : 4; jbyte g : 4;
byte r : 4; jbyte r : 4;
byte reserved : 4; jbyte reserved : 4;
} jlColorT; } jlColorT;
typedef struct { typedef struct {
byte l : 4; jbyte l : 4;
byte r : 4; jbyte r : 4;
} jlPixelPairT; } jlPixelPairT;
typedef struct { typedef struct {
@ -306,15 +309,15 @@ typedef struct {
typedef struct { typedef struct {
char id[3]; char id[3];
byte version; jbyte version;
jlColorT palette[16]; // 4 bits reserved, 4 bits red, 4 green, 4 blue jlColorT palette[16]; // 4 bits reserved, 4 bits red, 4 green, 4 blue
jlPixelPairT pixels[32000]; // 320x200, 4 bits per pixel jlPixelPairT pixels[32000]; // 320x200, 4 bits per pixel
} jlImgT; } jlImgT;
typedef struct { typedef struct {
char id[3]; char id[3];
byte version; jbyte version;
byte pixels[8000]; // 320x200, 1 bit per pixel stencil buffer jbyte pixels[8000]; // 320x200, 1 bit per pixel stencil buffer
} jlStnT; } jlStnT;
typedef struct _jlStackS { typedef struct _jlStackS {
@ -324,9 +327,9 @@ typedef struct _jlStackS {
typedef struct { typedef struct {
char id[3]; char id[3];
byte version; jbyte version;
juint16 length; juint16 length;
byte *data; jbyte *data;
} jlVecT; } jlVecT;
@ -364,56 +367,56 @@ void jlDisplayPresent(void);
void jlDrawBlit8x8(jlSurfaceT source, jint16 sx, jint16 sy, jint16 tx, jint16 ty); void jlDrawBlit8x8(jlSurfaceT source, jint16 sx, jint16 sy, jint16 tx, jint16 ty);
void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty); void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty);
void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlSurfaceT source); void jlDrawBlitMap(jint16 startX, jint16 startY, jint16 width, jint16 height, jbyte *mapData, juint16 stride, jlSurfaceT source);
void jlDrawBox(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawBox(jint16 x1, jint16 y1, jint16 x2, jint16 y2);
void jlDrawBoxFilled(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawBoxFilled(jint16 x1, jint16 y1, jint16 x2, jint16 y2);
void jlDrawCircle(jint16 x, jint16 y, jint16 radius); void jlDrawCircle(jint16 x, jint16 y, jint16 radius);
void jlDrawClear(void); void jlDrawClear(void);
byte jlDrawColorGet(void); jbyte jlDrawColorGet(void);
void jlDrawColorSet(byte index); void jlDrawColorSet(jbyte index);
void jlDrawEllipse(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawEllipse(jint16 x1, jint16 y1, jint16 x2, jint16 y2);
void jlDrawFill(jint16 x, jint16 y); void jlDrawFill(jint16 x, jint16 y);
void jlDrawFillTo(jint16 x, jint16 y, byte color); void jlDrawFillTo(jint16 x, jint16 y, jbyte color);
void jlDrawLine(jint16 x1, jint16 y1, jint16 x2, jint16 y2); void jlDrawLine(jint16 x1, jint16 y1, jint16 x2, jint16 y2);
byte jlDrawPixelGet(jint16 x, jint16 y); jbyte jlDrawPixelGet(jint16 x, jint16 y);
void jlDrawPixelSet(jint16 x, jint16 y); void jlDrawPixelSet(jint16 x, jint16 y);
jlSurfaceT jlDrawSurfaceGet(void); jlSurfaceT jlDrawSurfaceGet(void);
void jlDrawSurfaceSet(jlSurfaceT target); void jlDrawSurfaceSet(jlSurfaceT target);
jint16 jlGameGetAxis(byte which); jint16 jlGameGetAxis(jbyte which);
bool jlGameGetButton(byte which); jbool jlGameGetButton(jbyte which);
#define jlImgCopy(source, target) _jlImgCopy(source, (jlImgT **)&(target)) // Syntatic Sugar #define jlImgCopy(source, target) _jlImgCopy(source, (jlImgT **)&(target)) // Syntatic Sugar
bool _jlImgCopy(jlImgT *source, jlImgT **target); jbool _jlImgCopy(jlImgT *source, jlImgT **target);
#define jlImgCreate(img) _jlImgCreate((jlImgT **)&(img)) // Syntatic Sugar #define jlImgCreate(img) _jlImgCreate((jlImgT **)&(img)) // Syntatic Sugar
bool _jlImgCreate(jlImgT **img); jbool _jlImgCreate(jlImgT **img);
void jlImgDisplay(jlImgT *img); void jlImgDisplay(jlImgT *img);
void jlImgFree(jlImgT *img); void jlImgFree(jlImgT *img);
#define jlImgLoad(img, filename) _jlImgLoad((jlImgT **)&(img), filename) // Syntatic Sugar #define jlImgLoad(img, filename) _jlImgLoad((jlImgT **)&(img), filename) // Syntatic Sugar
bool _jlImgLoad(jlImgT **img, char *filename); jbool _jlImgLoad(jlImgT **img, char *filename);
bool jlImgSave(jlImgT *img, char *filename); jbool jlImgSave(jlImgT *img, char *filename);
#define jlImgSurfaceGet(img) ((jlSurfaceT)img->pixels) #define jlImgSurfaceGet(img) ((jlSurfaceT)img->pixels)
bool jlKeyPressed(void); jbool jlKeyPressed(void);
char jlKeyRead(void); char jlKeyRead(void);
void jlKeyWaitForAny(void); void jlKeyWaitForAny(void);
void jlPaletteDefault(void); //***TODO*** Treat palettes like we do "surfaces" - allow changing STAs or display void jlPaletteDefault(void); //***TODO*** Treat palettes like we do "surfaces" - allow changing STAs or display
void jlPaletteSet(byte index, byte r, byte g, byte b); //***TODO*** Really need a matching "get" void jlPaletteSet(jbyte index, jbyte r, jbyte g, jbyte b); //***TODO*** Really need a matching "get"
void jlPaletteSetFromImg(jlImgT *img); void jlPaletteSetFromImg(jlImgT *img);
void jlSoundFree(jlSoundT *sound); void jlSoundFree(jlSoundT *sound);
bool jlSoundIsPlaying(jlSoundT *sound); jbool jlSoundIsPlaying(jlSoundT *sound);
#define jlSoundLoad(sound, filename) _jlSoundLoad((jlSoundT **)&(sound), filename) // Syntatic Sugar #define jlSoundLoad(sound, filename) _jlSoundLoad((jlSoundT **)&(sound), filename) // Syntatic Sugar
bool _jlSoundLoad(jlSoundT **sound, char *filename); jbool _jlSoundLoad(jlSoundT **sound, char *filename);
void jlSoundMidiContinue(void); void jlSoundMidiContinue(void);
bool jlSoundMidiIsPlaying(void); jbool jlSoundMidiIsPlaying(void);
void jlSoundMidiPause(void); void jlSoundMidiPause(void);
void jlSoundMidiPlay(char *name); void jlSoundMidiPlay(char *name);
void jlSoundMidiStop(void); void jlSoundMidiStop(void);
void jlSoundModContinue(void); void jlSoundModContinue(void);
bool jlSoundModIsPlaying(void); jbool jlSoundModIsPlaying(void);
void jlSoundModPause(void); void jlSoundModPause(void);
void jlSoundModPlay(char *name); void jlSoundModPlay(char *name);
void jlSoundModStop(void); void jlSoundModStop(void);
@ -421,16 +424,16 @@ void jlSoundPlay(jlSoundT *sound);
void jlStnFree(jlStnT *stn); void jlStnFree(jlStnT *stn);
#define jlStnLoad(stn, filename) _jlStnLoad((jlStnT **)&(stn), filename) // Syntatic Sugar #define jlStnLoad(stn, filename) _jlStnLoad((jlStnT **)&(stn), filename) // Syntatic Sugar
bool _jlStnLoad(jlStnT **stn, char *filename); jbool _jlStnLoad(jlStnT **stn, char *filename);
#define jlUtilByteSwap(twoBytes) ((juint16)((twoBytes) & 0xff) >> 8) | (juint16)((twoBytes) << 8) #define jlUtilByteSwap(twoBytes) ((juint16)((twoBytes) & 0xff) >> 8) | (juint16)((twoBytes) << 8)
void jlUtilDie(const char *why, ...) __attribute__((noreturn)); void jlUtilDie(const char *why, ...) __attribute__((noreturn));
void jlUtilIdle(void); void jlUtilIdle(void);
bool jlUtilInputRead(byte *key); jbool jlUtilInputRead(jbyte *key);
#define jlUtilIsOdd(x) (((x & 1) == 1) ? true : false) #define jlUtilIsOdd(x) (((x & 1) == 1) ? jtrue : jfalse)
char *jlUtilMakePathname(char *filename, char *extension); char *jlUtilMakePathname(char *filename, char *extension);
bool jlUtilMustExit(void); jbool jlUtilMustExit(void);
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new); void jlUtilNibbleSwap(jbyte *mem, jint16 count, jbyte oldValue, jbyte newValue);
juint16 jlUtilRandom(void); juint16 jlUtilRandom(void);
juint32 jlUtilRandomSeedGet(void); juint32 jlUtilRandomSeedGet(void);
void jlUtilRandomSeedSet(juint32 seed); void jlUtilRandomSeedSet(juint32 seed);
@ -446,7 +449,7 @@ void jlUtilTitleSet(char *title);
void jlVecDisplay(jlVecT *vec, jint16 x, jint16 y); void jlVecDisplay(jlVecT *vec, jint16 x, jint16 y);
void jlVecFree(jlVecT *vec); void jlVecFree(jlVecT *vec);
#define jlVecLoad(vec, filename) _jlVecLoad((jlVecT **)&(vec), filename) // Syntatic Sugar #define jlVecLoad(vec, filename) _jlVecLoad((jlVecT **)&(vec), filename) // Syntatic Sugar
bool _jlVecLoad(jlVecT **vec, char *filename); jbool _jlVecLoad(jlVecT **vec, char *filename);
// Must be provided by application // Must be provided by application
@ -470,18 +473,18 @@ void joeyMain(void);
#ifdef JOEY_IIGS #ifdef JOEY_IIGS
// Inlined functions - asm code // Inlined functions - asm code
extern void asmB88(jlSurfaceT target, jlSurfaceT source, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2); extern void asmB88(jlSurfaceT target, jlSurfaceT source, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2);
extern void asmB88a(jlSurfaceT target, jlSurfaceT source, byte *stencil, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2); extern void asmB88a(jlSurfaceT target, jlSurfaceT source, jbyte *stencil, jint16 cx1, jint16 cy1, jint16 cx2, jint16 cy2);
extern void asmDrawBM(jlSurfaceT target, jint16 startX, jint16 startY, jint16 width, jint16 height, byte *mapData, juint16 stride, jlSurfaceT source); extern void asmDrawBM(jlSurfaceT target, jint16 startX, jint16 startY, jint16 width, jint16 height, jbyte *mapData, juint16 stride, jlSurfaceT source);
extern void asmDrawLine(jlSurfaceT target, jint16 color, jint16 x1, jint16 y1, jint16 x2, jint16 y2); extern void asmDrawLine(jlSurfaceT target, jint16 color, jint16 x1, jint16 y1, jint16 x2, jint16 y2);
extern jint16 asmGetPoint(jlSurfaceT target, jint16 x, jint16 y); extern jint16 asmGetPoint(jlSurfaceT target, jint16 x, jint16 y);
extern juint16 asmGetVbl(void); extern juint16 asmGetVbl(void);
extern void asmNSwap(byte *mem, jint16 count, jint16 old, jint16 new); extern void asmNSwap(jbyte *mem, jint16 count, jint16 old, jint16 new);
extern void asmPoint(jlSurfaceT target, jint16 color, jint16 x, jint16 y); extern void asmPoint(jlSurfaceT target, jint16 color, jint16 x, jint16 y);
// Inlined functions // Inlined functions
#define jlDrawBlit8x8(source, cx1, cy1, cx2, cy2) asmB88(_jlDrawTargetActual, source, cx1, cy1, cx2, cy2) #define jlDrawBlit8x8(source, cx1, cy1, cx2, cy2) asmB88(_jlDrawTargetActual, source, cx1, cy1, cx2, cy2)
#define jlDrawBlit8x8a(source, stencil, cx1, cy1, cx2, cy2) asmB88a(_jlDrawTargetActual, source, (byte *)stencil->pixels, cx1, cy1, cx2, cy2) #define jlDrawBlit8x8a(source, stencil, cx1, cy1, cx2, cy2) asmB88a(_jlDrawTargetActual, source, (jbyte *)stencil->pixels, cx1, cy1, cx2, cy2)
#define jlDrawBlitMap(startX, startY, width, height, mapData, stride, source) asmDrawBM(_jlDrawTargetActual, startX, startY, width, height, (byte *)mapData, stride, source) #define jlDrawBlitMap(startX, startY, width, height, mapData, stride, source) asmDrawBM(_jlDrawTargetActual, startX, startY, width, height, (jbyte *)mapData, stride, source)
#define jlDrawPixelGet(x, y) asmGetPoint(_jlDrawTargetActual, x, y) #define jlDrawPixelGet(x, y) asmGetPoint(_jlDrawTargetActual, x, y)
#define jlDrawPixelSet(x, y) asmPoint(_jlDrawTargetActual, _jlDrawColorNibbles, x, y) #define jlDrawPixelSet(x, y) asmPoint(_jlDrawTargetActual, _jlDrawColorNibbles, x, y)
#define jlDrawLine(x1, y1, x2, y2) asmDrawLine(_jlDrawTargetActual, _jlDrawColor, x1, y1, x2, y2) #define jlDrawLine(x1, y1, x2, y2) asmDrawLine(_jlDrawTargetActual, _jlDrawColor, x1, y1, x2, y2)
@ -494,4 +497,8 @@ void _jlDebugBorder(jlBorderColorsE color);
#endif // JOEY_IIGS #endif // JOEY_IIGS
#ifdef __cplusplus
}
#endif
#endif // H_JOEY_ #endif // H_JOEY_

View file

@ -43,7 +43,7 @@ void help(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, j
int mo; // Mask offset int mo; // Mask offset
int x; int x;
int y; int y;
byte b; // Mask bit index jbyte b; // Mask bit index
printf("\n"); printf("\n");
@ -221,7 +221,7 @@ void lineTest(void) {
y = 17; y = 17;
fontPrint(font, NULL, 1, y++, "Drawing %s ", what); fontPrint(font, NULL, 1, y++, "Drawing %s ", what);
jlDrawColorSet((byte)color); jlDrawColorSet((jbyte)color);
if (phase < 2) { if (phase < 2) {
jlDrawLine(x2, y2, 319-x2, 199-y2); jlDrawLine(x2, y2, 319-x2, 199-y2);
} else { } else {
@ -271,7 +271,7 @@ void lineTest(void) {
jlDisplayPresent(); jlDisplayPresent();
jlDrawColorSet((byte)0); jlDrawColorSet((jbyte)0);
if (op < 2) { if (op < 2) {
jlDrawLine(ox, oy, 319-ox, 199-oy); jlDrawLine(ox, oy, 319-ox, 199-oy);
} else { } else {
@ -323,7 +323,7 @@ void showStencil(void) {
juint16 temp; juint16 temp;
jint16 count; jint16 count;
jint16 index; jint16 index;
byte bit; jbyte bit;
if (!jlStnLoad(stencil, "biff")) jlUtilDie("Unable to load biff.stn!"); if (!jlStnLoad(stencil, "biff")) jlUtilDie("Unable to load biff.stn!");