diff --git a/imgconvert/imgconvert.pro b/imgconvert/imgconvert.pro index 5ae1d93..24b7fc0 100644 --- a/imgconvert/imgconvert.pro +++ b/imgconvert/imgconvert.pro @@ -28,7 +28,9 @@ QMAKE_CFLAGS += \ $$JOEY_FLAGS INCLUDEPATH += \ - $$JOEY_INCLUDES + $$JOEY_INCLUDES \ + /home/scott/source/lzsa/src \ + /home/scott/source/lzsa/src/libdivsufsort/include HEADERS += \ $$JOEY_HEADERS @@ -38,4 +40,7 @@ SOURCES += \ LIBS += \ $$JOEY_LIBS \ - $$SDL_IMAGE_LIBS + $$SDL_IMAGE_LIBS \ + -llz4 \ + -L/home/scott/source/lzsa \ + -llzsa diff --git a/imgconvert/main.c b/imgconvert/main.c index a2b73cd..3e5e500 100644 --- a/imgconvert/main.c +++ b/imgconvert/main.c @@ -4,7 +4,9 @@ #include #include #include +#include +#include "lib.h" #include "joey.h" @@ -24,6 +26,11 @@ void convertColor(char *filename, char *basename, bool showIt) { if (image == NULL) return; + if (!image->format->palette) { + fprintf(stderr, "Not a palettized image.\n"); + return; + } + colors = image->format->palette->ncolors; c = image->format->palette->colors; @@ -56,9 +63,57 @@ void convertColor(char *filename, char *basename, bool showIt) { } } + SDL_FreeSurface(image); + jlImgSave(img, basename); - SDL_FreeSurface(image); + // Experimental LZ4 compression + const size_t srcSize = (sizeof(jlColorT) * 16) + (sizeof(jlPixelPairT) * 32000); + const int maxSize = LZ4_compressBound(srcSize); + char *compressedData = malloc((size_t)maxSize); + if (!compressedData) { + fprintf(stderr, "Unable to allocate space for compressed data.\n"); + return; + } + const int compressedDataSize = LZ4_compress_default((char *)img->palette, compressedData, srcSize, maxSize); + if (compressedDataSize <= 0) { + fprintf(stderr, "Unable to compress data.\n"); + return; + } + char name[2048]; + FILE *out; + snprintf(name, 2048, "%s.imgz", basename); + out = fopen(name, "wb"); + if (!out) { + fprintf(stderr, "Unable to save compressed file: %s\n", name); + return; + } + fwrite(img, 4, 1, out); + fwrite(compressedData, compressedDataSize, 1, out); + fclose(out); + + // Experimental LZSA compression + const size_t srcSize2 = (sizeof(jlColorT) * 16) + (sizeof(jlPixelPairT) * 32000); + const int maxSize2 = lzsa_get_max_compressed_size_inmem(srcSize2); + unsigned char *compressedData2 = malloc((size_t)maxSize2); + if (!compressedData2) { + fprintf(stderr, "Unable to allocate space for compressed data.\n"); + return; + } + const int compressedDataSize2 = lzsa_compress_inmem((unsigned char *)img->palette, compressedData2, srcSize2, maxSize2, LZSA_FLAG_FAVOR_RATIO, 3, 1); + if (compressedDataSize2 <= 0) { + fprintf(stderr, "Unable to compress data.\n"); + return; + } + snprintf(name, 2048, "%s.imgz2", basename); + out = fopen(name, "wb"); + if (!out) { + fprintf(stderr, "Unable to save compressed file: %s\n", name); + return; + } + fwrite(img, 4, 1, out); + fwrite(compressedData2, compressedDataSize2, 1, out); + fclose(out); if (showIt) { jlImgDisplay(img); diff --git a/joeylib/src/jIIgs.c b/joeylib/src/jIIgs.c index c40802e..8c30133 100644 --- a/joeylib/src/jIIgs.c +++ b/joeylib/src/jIIgs.c @@ -232,50 +232,6 @@ void jlPaletteSetFromImg(jlImgT *img) { } -void jlSoundFree(jlSoundT *sound) { - //***TODO*** -} - - -bool jlSoundIsPlaying(jlSoundT *sound) { - //***TODO*** - return false; -} - - -bool _jlSoundLoad(jlSoundT **sound, char *filename) { - //***TODO*** - return false; -} - - -void jlSoundMidiContinue(void) { - //***TODO*** -} - - -bool jlSoundMidiIsPlaying(void) { - //***TODO*** - return false; -} - - -void jlSoundMidiPause(void) { - //***TODO*** -} - - -void jlSoundMidiPlay(char *name) { - (void)name; - //***TODO*** -} - - -void jlSoundMidiStop(void) { - //***TODO*** -} - - void jlSoundModContinue(void) { NTPContinueMusic(); } @@ -311,21 +267,6 @@ void jlSoundModStop(void) { } -void jlSoundPlay(jlSoundT *sound) { - //***TODO*** -} - - -void jlUtilIdle(void) { - // No need to pump the message loop on the IIgs -} - - -bool jlUtilMustExit(void) { - return false; -} - - void jlUtilShutdown(void) { // Clear the display. jlDrawColorSet(0); diff --git a/joeylib/src/jSDL2.c b/joeylib/src/jSDL2.c index e10d849..f1c41d6 100644 --- a/joeylib/src/jSDL2.c +++ b/joeylib/src/jSDL2.c @@ -244,100 +244,12 @@ void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, ji } -//***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) { - // startX = start tile for drawing - in pixels - // startY = start tile for drawing - in pixels - // width = tiles to draw horizontally - in tiles - // height = tiles to draw vertically - in tiles - // mapData = pointer to tile x/y pairs to draw - // stride = number of tile bytes to skip in the mapData for every horizontal line - // tiles = surface to fetch tile data from - jint16 x; - jint16 y; - byte tileX; - byte tileY; - juint16 offset = 0; - jint16 endX = width * 8 + startX; - jint16 endY = height * 8 + startY; - - for (y=startY; y= x1) { - dx = x2 - x1; - incX = 1; - } else { - dx = x1 - x2; - incX = -1; - } - - if (y2 >= y1) { - dy = y2 - y1; - incY = 1; - } else { - dy = y1 - y2; - incY = -1; - } - - x = x1; - y = y1; - - if (dx >= dy) { - dy <<= 1; - balance = dy - dx; - dx <<= 1; - while (x != x2) { - jlDrawPixelSet(x, y); - if (balance >= 0) { - y += incY; - balance -= dx; - } - balance += dy; - x += incX; - } - jlDrawPixelSet(x, y); - } else { - dx <<= 1; - balance = dx - dy; - dy <<= 1; - while (y != y2) { - jlDrawPixelSet(x, y); - if (balance >= 0) { - x += incX; - balance -= dy; - } - balance += dx; - y += incY; - } - jlDrawPixelSet(x, y); - } -} - - byte jlDrawPixelGet(jint16 x, jint16 y) { jlPixelPairT *target = (jlPixelPairT *)_jlDrawTargetActual; int p = x / 2 + y * 160; @@ -513,34 +425,6 @@ bool _jlSoundLoad(jlSoundT **sound, char *filename) { } -void jlSoundMidiContinue(void) { - //***TODO*** -} - - -bool jlSoundMidiIsPlaying(void) { - //***TODO*** - return false; -} - - - -void jlSoundMidiPause(void) { - //***TODO*** -} - - -void jlSoundMidiPlay(char *name) { - (void)name; - //***TODO*** -} - - -void jlSoundMidiStop(void) { - //***TODO*** -} - - void jlSoundModContinue(void) { Mix_ResumeMusic(); } @@ -677,17 +561,6 @@ bool jlUtilMustExit(void) { } -void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new) { - int x; - jlPixelPairT *b; - for (x=0; xl == old) b->l = new; - if (b->r == old) b->r = new; - } -} - - void jlUtilShutdown(void) { int x; diff --git a/joeylib/src/joey.c b/joeylib/src/joey.c index 4db943f..081aedd 100644 --- a/joeylib/src/joey.c +++ b/joeylib/src/joey.c @@ -179,27 +179,94 @@ void *_jlRealloc(void *pointer, size_t size) { #endif +#ifndef JL_HAS_DISPLAYBORDER void jlDisplayBorder(jlBorderColorsE color) { _jlBorderColor = (byte)color; } +#endif +#ifndef JL_HAS_DISPLAYPRESENT +void jlDisplayPresent(void) { + +} +#endif + + +#ifndef JL_HAS_DRAWBLIT8X8 +void jlDrawBlit8x8(jlSurfaceT source, jint16 sx, jint16 sy, jint16 tx, jint16 ty) { + (void)source; + (void)sx; + (void)sy; + (void)tx; + (void)ty; +} +#endif + + +#ifndef JL_HAS_DRAWBLIT8X8A +void jlDrawBlit8x8a(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty) { + (void)source; + (void)stencil; + (void)sx; + (void)sy; + (void)tx; + (void)ty; +} +#endif + + +#ifndef JL_HAS_DRAWBLITMAP +//***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) { + // startX = start tile for drawing - in pixels + // startY = start tile for drawing - in pixels + // width = tiles to draw horizontally - in tiles + // height = tiles to draw vertically - in tiles + // mapData = pointer to tile x/y pairs to draw + // stride = number of tile bytes to skip in the mapData for every horizontal line + // tiles = surface to fetch tile data from + jint16 x; + jint16 y; + byte tileX; + byte tileY; + juint16 offset = 0; + jint16 endX = width * 8 + startX; + jint16 endY = height * 8 + startY; + + for (y=startY; yStartX = startX; @@ -392,20 +474,136 @@ void _jlDrawFill(jint16 x, jint16 y, bool how) { jlFree(r); } } +#endif +#ifndef JL_HAS_DRAWFILL void jlDrawFill(jint16 x, jint16 y) { _jlDrawFillColor = jlDrawPixelGet(x, y); _jlDrawFill(x, y, true); } +#endif +#ifndef JL_HAS_DRAWFILLTO void jlDrawFillTo(jint16 x, jint16 y, byte color) { _jlDrawFillColor = color; _jlDrawFill(x, y, false); } +#endif +#ifndef JL_HAS_DRAWLINE +void jlDrawLine(jint16 x1, jint16 y1, jint16 x2, jint16 y2) { + jint16 x; + jint16 y; + jint16 dx; + jint16 dy; + jint16 incX; + jint16 incY; + jint16 balance; + + if (x2 >= x1) { + dx = x2 - x1; + incX = 1; + } else { + dx = x1 - x2; + incX = -1; + } + + if (y2 >= y1) { + dy = y2 - y1; + incY = 1; + } else { + dy = y1 - y2; + incY = -1; + } + + x = x1; + y = y1; + + if (dx >= dy) { + dy <<= 1; + balance = dy - dx; + dx <<= 1; + while (x != x2) { + jlDrawPixelSet(x, y); + if (balance >= 0) { + y += incY; + balance -= dx; + } + balance += dy; + x += incX; + } + jlDrawPixelSet(x, y); + } else { + dx <<= 1; + balance = dx - dy; + dy <<= 1; + while (y != y2) { + jlDrawPixelSet(x, y); + if (balance >= 0) { + x += incX; + balance -= dy; + } + balance += dx; + y += incY; + } + jlDrawPixelSet(x, y); + } +} +#endif + + +#ifndef JL_HAS_DRAWPIXELGIT +byte jlDrawPixelGet(jint16 x, jint16 y) { + (void)x; + (void)y; + return 0; +} +#endif + + +#ifndef JL_HAS_DRAWPIXELSET +void jlDrawPixelSet(jint16 x, jint16 y) { + (void)x; + (void)y; + +} +#endif + + +#ifndef JL_HAS_DRAWSURFACEGET +jlSurfaceT jlDrawSurfaceGet(void) { + return NULL; +} +#endif + + +#ifndef JL_HAS_DRAWSURFACESET +void jlDrawSurfaceSet(jlSurfaceT target) { + (void)target; +} +#endif + + +#ifndef JL_HAS_GETGAMEAXIS +jint16 jlGameGetAxis(byte which) { + (void)which; + return 0; +} +#endif + + +#ifndef JL_HAS_GETGAMEBUTTON +bool jlGameGetButton(byte which) { + (void)which; + return false; +} +#endif + + +#ifndef JL_HAS_IMGCOPY bool _jlImgCopy(jlImgT *source, jlImgT **target) { jlImgT *t = NULL; // Are we copying into a new image? @@ -420,15 +618,34 @@ bool _jlImgCopy(jlImgT *source, jlImgT **target) { memcpy(*target, source, sizeof(jlImgT)); return true; } +#endif +#ifndef JL_HAS_IMGCREATE +bool _jlImgCreate(jlImgT **img) { + (void)img; + return false; +} +#endif + + +#ifndef JL_HAS_IMGDISPLAY +void jlImgDisplay(jlImgT *img) { + (void)img; +} +#endif + + +#ifndef JL_HAS_IMGFREE void jlImgFree(jlImgT *img) { if (img != NULL) { jlFree(img); } } +#endif +#ifndef JL_HAS_IMGLOAD bool _jlImgLoad(jlImgT **img, char *filename) { bool result = false; jlImgT *s = NULL; @@ -456,8 +673,10 @@ bool _jlImgLoad(jlImgT **img, char *filename) { } return result; } +#endif +#ifndef JL_HAS_IMGSAVE bool jlImgSave(jlImgT *img, char *filename) { bool result = false; FILE *f; @@ -470,16 +689,34 @@ bool jlImgSave(jlImgT *img, char *filename) { } return result; } +#endif +#ifndef JL_HAS_KEYPRESSED +bool jlKeyPressed(void) { + return false; +} +#endif + + +#ifndef JL_HAS_KEYREAD +char jlKeyRead(void) { + return 0; +} +#endif + + +#ifndef JL_HAS_KEYWAITFORANY void jlKeyWaitForAny(void) { //***TODO*** I don't think this does what we think it does. while (!jlKeyPressed() && !jlUtilMustExit()) ; jlKeyRead(); while (jlKeyPressed() && !jlUtilMustExit()) ; } +#endif +#ifndef JL_HAS_PALETTEDEFAULT void jlPaletteDefault(void) { byte i; // Set palette. @@ -503,8 +740,138 @@ void jlPaletteDefault(void) { jlPaletteSet(i, _jlDefaultPalette[i].r, _jlDefaultPalette[i].g, _jlDefaultPalette[i].b); } } +#endif +#ifndef JL_HAS_PALETTESET +void jlPaletteSet(byte index, byte r, byte g, byte b) { + (void)index; + (void)r; + (void)g; + (void)b; + //***TODO*** Really need a matching "get" +} +#endif + + +#ifndef JL_HAS_PALETTESETFROMIMG +void jlPaletteSetFromImg(jlImgT *img) { + (void)img; +} +#endif + + +#ifndef JL_HAS_SOUNDFREE +void jlSoundFree(jlSoundT *sound) { + (void)sound; +} +#endif + + +#ifndef JL_HAS_SOUNDISPLAYING +bool jlSoundIsPlaying(jlSoundT *sound) { + (void)sound; + return false; +} +#endif + + +#ifndef JL_HAS_SOUNDLOAD +bool _jlSoundLoad(jlSoundT **sound, char *filename) { + (void)sound; + (void)filename; + return false; +} +#endif + + +#ifndef JL_HAS_SOUNDMIDICONTINUE +void jlSoundMidiContinue(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDMIDIISPLAYING +bool jlSoundMidiIsPlaying(void) { + return false; +} +#endif + + +#ifndef JL_HAS_SOUNDMIDIPAUSE +void jlSoundMidiPause(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDMIDIPLAY +void jlSoundMidiPlay(char *name) { + (void)name; +} +#endif + + +#ifndef JL_HAS_SOUNDMIDISTOP +void jlSoundMidiStop(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDMODCONTINUE +void jlSoundModContinue(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDMODISPLAYING +bool jlSoundModIsPlaying(void) { + return false; +} +#endif + + +#ifndef JL_HAS_SOUNDMODPAUSE +void jlSoundModPause(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDMODPLAY +void jlSoundModPlay(char *name) { + (void)name; +} +#endif + + +#ifndef JL_HAS_SOUNDMODSTOP +void jlSoundModStop(void) { + +} +#endif + + +#ifndef JL_HAS_SOUNDPLAY +void jlSoundPlay(jlSoundT *sound) { + (void)sound; +} +#endif + + +#ifndef JL_HAS_STNFREE +void jlStnFree(jlStnT *stn) { + if (stn != NULL) { + jlFree(stn); + } +} +#endif + + +#ifndef JL_HAS_STNLOAD bool _jlStnLoad(jlStnT **stn, char *filename) { bool result = false; jlStnT *s = NULL; @@ -532,14 +899,10 @@ bool _jlStnLoad(jlStnT **stn, char *filename) { } return result; } +#endif -void jlStnFree(jlStnT *stn) { - if (stn != NULL) { - jlFree(stn); - } -} - +#ifndef JL_HAS_UTILDIE __attribute__((__format__ (__printf__, 1, 0))) void jlUtilDie(const char *why, ...) { #ifdef JOEY_DEBUG @@ -575,8 +938,105 @@ void jlUtilDie(const char *why, ...) { #endif exit(0); } +#endif +#ifndef JL_HAS_UTILIDLE +void jlUtilIdle(void) { + +} +#endif + + +#ifndef JL_HAS_UTILINPUTREAD +bool jlUtilInputRead(byte *key) { + + static bool debounceController = false; + + *key = 0; + + // Keyboard + if (jlKeyPressed()) { + while (jlKeyPressed()) { + *key = jlKeyRead(); + } + switch (*key) { + // Up + case 'I': + case 'i': + case 'W': + case 'w': + case '8': + *key = JOEY_INPUT_UP; + break; + + // Left + case 'J': + case 'j': + case 'A': + case 'a': + case '4': + *key = JOEY_INPUT_LEFT; + break; + + // Right + case 'K': + case 'k': + case 'D': + case 'd': + case '6': + *key = JOEY_INPUT_RIGHT; + break; + + // Down + case 'M': + case 'm': + case 'S': + case 's': + case '2': + *key = JOEY_INPUT_DOWN; + break; + + // Primary + case 13: + *key = JOEY_INPUT_PRIMARY; + break; + + // Secondary + case 27: + *key = JOEY_INPUT_SECONDARY; + break; + } + + return true; + } + + // Joystick + if (jlGameGetAxis(0) < -50) *key = JOEY_INPUT_LEFT; + if (jlGameGetAxis(0) > 50) *key = JOEY_INPUT_RIGHT; + if (jlGameGetAxis(1) < -50) *key = JOEY_INPUT_UP; + if (jlGameGetAxis(1) > 50) *key = JOEY_INPUT_DOWN; + if (jlGameGetButton(0)) *key = JOEY_INPUT_PRIMARY; + if (jlGameGetButton(1)) *key = JOEY_INPUT_SECONDARY; + + // Debounce Joystick Input + if (debounceController) { + *key = 0; + return false; + } else { + if (*key != 0) { + debounceController = true; + return true; + } + } + debounceController = false; + + return false; +} +#endif + + +#ifndef JL_HAS_UTILMAKEPATHNAME char *jlUtilMakePathname(char *filename, char *extension) { char temp[2]; @@ -594,24 +1054,60 @@ char *jlUtilMakePathname(char *filename, char *extension) { return _jlTempString; } +#endif +#ifndef JL_HAS_UTILMUSTEXIT +bool jlUtilMustExit(void) { + return false; +} +#endif + + +#ifndef JL_HAS_UTILNIBBLESWAP +void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new) { + int x; + jlPixelPairT *b; + for (x=0; xl == old) b->l = new; + if (b->r == old) b->r = new; + } +} +#endif + + +#ifndef JL_HAS_UTILRANDOM juint16 jlUtilRandom(void) { _jlSeed = _jlSeed * 1103515245 + 12345; return _jlSeed / 65536; } +#endif +#ifndef JL_HAS_UTILRANDOMSEEDGET juint32 jlUtilRandomSeedGet(void) { return _jlSeed; } +#endif +#ifndef JL_HAS_UTILRANDOMSEEDSET void jlUtilRandomSeedSet(juint32 seed) { _jlSeed = seed; } +#endif +#ifndef JL_HAS_UTILSHUTDOWN +__attribute__((noreturn)) +void jlUtilShutdown(void) { + exit(0); +} +#endif + + +#ifndef JL_HAS_UTILSLEEP void jlUtilSleep(juint16 sixtieths) { juint16 t = jlUtilTimer(); juint16 d = 0; @@ -620,8 +1116,10 @@ void jlUtilSleep(juint16 sixtieths) { d = jlUtilTimeSpan(t, jlUtilTimer()); } } +#endif +#ifndef JL_HAS_UTILSTACKPOP void *_jlUtilStackPop(jlStackT **stack) { void *d = NULL; jlStackT *s; @@ -633,8 +1131,10 @@ void *_jlUtilStackPop(jlStackT **stack) { } return d; } +#endif +#ifndef JL_HAS_UTILSTACKPUSH void _jlUtilStackPush(jlStackT **stack, void *data) { jlStackT *s = NULL; s = (jlStackT *)jlMalloc(sizeof(jlStackT)); @@ -642,8 +1142,24 @@ void _jlUtilStackPush(jlStackT **stack, void *data) { s->data = data; *stack = s; } +#endif +#ifndef JL_HAS_UTILSTARTUP +void jlUtilStartup(char *appTitle) { + (void)appTitle; +} +#endif + + +#ifndef JL_HAS_UTILTIMER +juint16 jlUtilTimer(void) { + return 0; +} +#endif + + +#ifndef JL_HAS_UTILTIMESPAN juint16 jlUtilTimeSpan(juint16 past, juint16 current) { jint32 temp = current - past; if (temp < 0) { @@ -651,8 +1167,10 @@ juint16 jlUtilTimeSpan(juint16 past, juint16 current) { } return (juint16)temp; } +#endif +#ifndef JL_HAS_VECDISPLAY void jlVecDisplay(jlVecT *vec, jint16 ox, jint16 oy) { jint16 command; jint16 count; @@ -767,16 +1285,20 @@ void jlVecDisplay(jlVecT *vec, jint16 ox, jint16 oy) { } // switch } // while } +#endif +#ifndef JL_HAS_VECFREE void jlVecFree(jlVecT *vec) { if (vec != NULL) { jlFree(vec->data); jlFree(vec); } } +#endif +#ifndef JL_HAS_VECLOAD bool _jlVecLoad(jlVecT **vec, char *filename) { bool result = false; jlVecT *v = NULL; @@ -818,3 +1340,4 @@ bool _jlVecLoad(jlVecT **vec, char *filename) { } return result; } +#endif diff --git a/joeylib/src/joey.h b/joeylib/src/joey.h index a33d505..37e1d86 100644 --- a/joeylib/src/joey.h +++ b/joeylib/src/joey.h @@ -51,6 +51,14 @@ typedef unsigned char byte; #define JOEY_DISPLAY (byte *)NULL +#define JOEY_INPUT_NONE 0 +#define JOEY_INPUT_UP 1 +#define JOEY_INPUT_DOWN 2 +#define JOEY_INPUT_LEFT 3 +#define JOEY_INPUT_RIGHT 4 +#define JOEY_INPUT_PRIMARY 5 +#define JOEY_INPUT_SECONDARY 6 + // Determine platform and settings #ifdef __linux__ @@ -67,6 +75,37 @@ typedef unsigned short juint16; typedef int jint32; typedef unsigned int juint32; +#define JL_HAS_DISPLAYPRESENT +#define JL_HAS_DRAWBLIT8X8 +#define JL_HAS_DRAWBLIT8X8A +#define JL_HAS_DRAWCLEAR +#define JL_HAS_DRAWPIXELGET +#define JL_HAS_DRAWPIXELSET +#define JL_HAS_DRAWSURFACEGET +#define JL_HAS_DRAWSURFACESET +#define JL_HAS_GAMEGETAXIS +#define JL_HAS_GAMEGETBUTTON +#define JL_HAS_IMGCREATE +#define JL_HAS_IMGDISPLAY +#define JL_HAS_KEYPRESSED +#define JL_HAS_KEYREAD +#define JL_HAS_PALETTESET +#define JL_HAS_PALETTESETFROMIMG +#define JL_HAS_SOUNDFREE +#define JL_HAS_SOUNDISPLAYING +#define JL_HAS_SOUNDLOAD +#define JL_HAS_SOUNDMODCONTINUE +#define JL_HAS_SOUNDMODISPLAYING +#define JL_HAS_SOUNDMODPAUSE +#define JL_HAS_SOUNDMODPLAY +#define JL_HAS_SOUNDMODSTOP +#define JL_HAS_SOUNDPLAY +#define JL_HAS_UTILIDLE +#define JL_HAS_UTILMUSTEXIT +#define JL_HAS_UTILSHUTDOWN +#define JL_HAS_UTILSTARTUP +#define JL_HAS_UTILTIMER + #elif _WIN32 #define JOEY_WINDOWS @@ -78,6 +117,37 @@ typedef unsigned short juint16; typedef int jint32; typedef unsigned int juint32; +#define JL_HAS_DISPLAYPRESENT +#define JL_HAS_DRAWBLIT8X8 +#define JL_HAS_DRAWBLIT8X8A +#define JL_HAS_DRAWCLEAR +#define JL_HAS_DRAWPIXELGET +#define JL_HAS_DRAWPIXELSET +#define JL_HAS_DRAWSURFACEGET +#define JL_HAS_DRAWSURFACESET +#define JL_HAS_GAMEGETAXIS +#define JL_HAS_GAMEGETBUTTON +#define JL_HAS_IMGCREATE +#define JL_HAS_IMGDISPLAY +#define JL_HAS_KEYPRESSED +#define JL_HAS_KEYREAD +#define JL_HAS_PALETTESET +#define JL_HAS_PALETTESETFROMIMG +#define JL_HAS_SOUNDFREE +#define JL_HAS_SOUNDISPLAYING +#define JL_HAS_SOUNDLOAD +#define JL_HAS_SOUNDMODCONTINUE +#define JL_HAS_SOUNDMODISPLAYING +#define JL_HAS_SOUNDMODPAUSE +#define JL_HAS_SOUNDMODPLAY +#define JL_HAS_SOUNDMODSTOP +#define JL_HAS_SOUNDPLAY +#define JL_HAS_UTILIDLE +#define JL_HAS_UTILMUSTEXIT +#define JL_HAS_UTILSHUTDOWN +#define JL_HAS_UTILSTARTUP +#define JL_HAS_UTILTIMER + #elif __APPLE__ #define JOEY_MACOS @@ -89,6 +159,37 @@ typedef unsigned short juint16; typedef int jint32; typedef unsigned int juint32; +#define JL_HAS_DISPLAYPRESENT +#define JL_HAS_DRAWBLIT8X8 +#define JL_HAS_DRAWBLIT8X8A +#define JL_HAS_DRAWCLEAR +#define JL_HAS_DRAWPIXELGET +#define JL_HAS_DRAWPIXELSET +#define JL_HAS_DRAWSURFACEGET +#define JL_HAS_DRAWSURFACESET +#define JL_HAS_GAMEGETAXIS +#define JL_HAS_GAMEGETBUTTON +#define JL_HAS_IMGCREATE +#define JL_HAS_IMGDISPLAY +#define JL_HAS_KEYPRESSED +#define JL_HAS_KEYREAD +#define JL_HAS_PALETTESET +#define JL_HAS_PALETTESETFROMIMG +#define JL_HAS_SOUNDFREE +#define JL_HAS_SOUNDISPLAYING +#define JL_HAS_SOUNDLOAD +#define JL_HAS_SOUNDMODCONTINUE +#define JL_HAS_SOUNDMODISPLAYING +#define JL_HAS_SOUNDMODPAUSE +#define JL_HAS_SOUNDMODPLAY +#define JL_HAS_SOUNDMODSTOP +#define JL_HAS_SOUNDPLAY +#define JL_HAS_UTILIDLE +#define JL_HAS_UTILMUSTEXIT +#define JL_HAS_UTILSHUTDOWN +#define JL_HAS_UTILSTARTUP +#define JL_HAS_UTILTIMER + #elif __ORCAC__ #define JOEY_IIGS @@ -107,6 +208,35 @@ typedef unsigned long juint32; #pragma lint -1 #pragma debug 0 +#define JL_HAS_DISPLAYBORDER +#define JL_HAS_DISPLAYPRESENT +#define JL_HAS_DRAWBLIT8X8 +#define JL_HAS_DRAWBLIT8X8A +#define JL_HAS_DRAWBLITMAP +#define JL_HAS_DRAWPIXELGET +#define JL_HAS_DRAWPIXELSET +#define JL_HAS_DRAWLINE +#define JL_HAS_DRAWCLEAR +#define JL_HAS_DRAWSURFACEGET +#define JL_HAS_DRAWSURFACESET +#define JL_HAS_GAMEGETAXIS +#define JL_HAS_GAMEGETBUTTON +#define JL_HAS_IMGCREATE +#define JL_HAS_IMGDISPLAY +#define JL_HAS_KEYPRESSED +#define JL_HAS_KEYREAD +#define JL_HAS_PALETTESET +#define JL_HAS_PALETTESETFROMIMG +#define JL_HAS_SOUNDMODCONTINUE +#define JL_HAS_SOUNDMODISPLAYING +#define JL_HAS_SOUNDMODPAUSE +#define JL_HAS_SOUNDMODPLAY +#define JL_HAS_SOUNDMODSTOP +#define JL_HAS_UTILNIBBLESWAP +#define JL_HAS_UTILSHUTDOWN +#define JL_HAS_UTILSTARTUP +#define JL_HAS_UTILTIMER + #elif AMIGA #define JOEY_AMIGA @@ -302,6 +432,7 @@ bool _jlStnLoad(jlStnT **stn, char *filename); #define jlUtilByteSwap(twoBytes) ((juint16)((twoBytes) & 0xff) >> 8) | (juint16)((twoBytes) << 8) void jlUtilDie(const char *why, ...) __attribute__((noreturn)); void jlUtilIdle(void); +bool jlUtilInputRead(byte *key); #define jlUtilIsOdd(x) (((x & 1) == 1) ? true : false) char *jlUtilMakePathname(char *filename, char *extension); bool jlUtilMustExit(void); diff --git a/joeylib/src/test.c b/joeylib/src/test.c index 369203d..02fa93b 100644 --- a/joeylib/src/test.c +++ b/joeylib/src/test.c @@ -319,13 +319,14 @@ void musicTest(void) { void showStencil(void) { jlStnT *stencil = NULL; - jint16 y; - jint16 x; + juint16 y; + juint16 x; + juint16 temp; jint16 count; - juint16 index; + jint16 index; byte bit; - if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!"); + if (!jlStnLoad(stencil, "biff")) jlUtilDie("Unable to load biff.stn!"); jlDrawColorSet(0); jlDrawClear(); @@ -354,12 +355,12 @@ void showStencil(void) { jlDrawClear(); jlDrawColorSet(15); - // Draw stencil by pixel location - this fails on the IIgs + // Draw stencil by pixel location for (y=0; y<200; y++) { for (x=0; x<320; x++) { - index = (y * 320 + x); - count = 7 - (index % 8); - index /= 8; + temp = (y * 320 + x); + count = 7 - (temp % 8); + index = temp / 8; bit = stencil->pixels[index]; if (bit & (1 << count)) { jlDrawPixelSet(x, y); @@ -382,8 +383,8 @@ void stencilTest(void) { jint16 j; if (!jlImgLoad(kangaI, "kanga")) jlUtilDie("Unable to load kanga.img!"); - if (!jlImgLoad(biffI, "biff")) jlUtilDie("Unable to load biff.img!"); - if (!jlStnLoad(biffS, "biff")) jlUtilDie("Unable to load biff.stn!"); + if (!jlImgLoad(biffI, "biff")) jlUtilDie("Unable to load biff.img!"); + if (!jlStnLoad(biffS, "biff")) jlUtilDie("Unable to load biff.stn!"); jlImgDisplay(kangaI); @@ -391,12 +392,9 @@ void stencilTest(void) { while (!jlKeyPressed()) { // Draw Biff & grab background - for (x=0; x<319-32; x++) { + for (x=0; x<319-32; x+=2) { for (i=0; i<3; i++) { for (j=0; j<4; j++) { - jlDrawSurfaceSet(jlImgSurfaceGet(biffI)); - jlDrawBlit8x8(JOEY_DISPLAY, x + (j * 8), y + (i * 8), j * 8 + 32, i * 8 + 32); - jlDrawSurfaceSet(JOEY_DISPLAY); jlDrawBlit8x8a(jlImgSurfaceGet(biffI), biffS, j * 8, i * 8, x + (j * 8), y + (i * 8)); } } @@ -404,7 +402,7 @@ void stencilTest(void) { // Erase Biff for (i=0; i<3; i++) { for (j=0; j<4; j++) { - jlDrawBlit8x8(jlImgSurfaceGet(biffI), j * 8 + 32, i * 8 + 32, x + (j * 8), y + (i * 8)); + jlDrawBlit8x8(jlImgSurfaceGet(kangaI), x + (j * 8), y + (i * 8), x + (j * 8), y + (i * 8)); } } // Check for early quit @@ -447,8 +445,8 @@ int main(void) { //grid(); //lineTest(); //musicTest(); - //showStencil(); - stencilTest(); + showStencil(); + //stencilTest(); //timerTest(); jlUtilShutdown();