diff --git a/.gitattributes b/.gitattributes index dce9157..ab1b86c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -*.sta filter=lfs diff=lfs merge=lfs -text +*.img filter=lfs diff=lfs merge=lfs -text *.z5 filter=lfs diff=lfs merge=lfs -text *.z8 filter=lfs diff=lfs merge=lfs -text *.vec filter=lfs diff=lfs merge=lfs -text diff --git a/ansiterm.c b/ansiterm.c index d21cff6..9ddb135 100644 --- a/ansiterm.c +++ b/ansiterm.c @@ -37,7 +37,7 @@ static byte _number = 0; static byte _parameters[5]; static byte _parameterCount = 0; static byte _hiddenLines = 0; -static jlStaT *_ansiFont = NULL; +static jlImgT *_ansiFont = NULL; static PositionT _cursorSave; static PositionT _cursor; static PositionT *_screenBuffer = NULL; @@ -161,35 +161,35 @@ bool termParseANSI(char c) { // Cursor up. case 'A': y = _number; - termDebug("Moving cursor up %d", y); + //termDebug("Moving cursor up %d", y); termMoveCursor(cursor.x, cursor.y - y); termResetSequence(); break; // Cursor down. case 'B': y = _number; - termDebug("Moving cursor down %d", y); + //termDebug("Moving cursor down %d", y); termMoveCursor(cursor.x, cursor.y + y); termResetSequence(); break; // Cursor forward. case 'C': x = _number; - termDebug("Moving cursor right %d", x); + //termDebug("Moving cursor right %d", x); termMoveCursor(cursor.x + x, cursor.y); termResetSequence(); break; // Cursor backward. case 'D': x = _number; - termDebug("Moving cursor left %d", x); + //termDebug("Moving cursor left %d", x); termMoveCursor(cursor.x - x, cursor.y); termResetSequence(); break; // Cursor line down. case 'E': y = _number; - termDebug("Moving cursor down line %d", y); + //termDebug("Moving cursor down line %d", y); termMoveCursor(1, cursor.y + y); //***TODO*** This should allow scrolling termResetSequence(); @@ -197,14 +197,14 @@ bool termParseANSI(char c) { // Cursor line up. case 'F': y = _number; - termDebug("Moving cursor up line %d", y); + //termDebug("Moving cursor up line %d", y); termMoveCursor(1, cursor.y - y); termResetSequence(); break; // Cursor horizontal absolute. case 'G': x = _number; - termDebug("Moving cursor horizontally to %d", x); + //termDebug("Moving cursor horizontally to %d", x); termMoveCursor(x, cursor.y); termResetSequence(); break; @@ -215,14 +215,14 @@ bool termParseANSI(char c) { case 0: // Absolute position, Y. Kinda. Moves X to 1. y = _number; - termDebug("Moving cursor to 1x%d", y); + //termDebug("Moving cursor to 1x%d", y); termMoveCursor(1, y); break; case 1: // Absolute position. x = _number; y = _parameters[0]; - termDebug("Moving cursor to %dx%d", x, y); + //termDebug("Moving cursor to %dx%d", x, y); termMoveCursor(x, y); break; default: @@ -234,7 +234,7 @@ bool termParseANSI(char c) { // Clear display. case 'J': if ((_parameterCount == 0) && (_number == 2)) { - termDebug("Clear display"); + //termDebug("Clear display"); termClearScreen(); updateDisplay = true; termMoveCursor(1, 1); @@ -247,7 +247,7 @@ bool termParseANSI(char c) { case 'K': x = _number; if (x == 0) { - termDebug("Clear to end of line"); + //termDebug("Clear to end of line"); oldX = cursor.x; for (cx=cursor.x; cx<=_columns; cx++) { termMoveCursor(cx, cursor.y); @@ -311,7 +311,7 @@ bool termParseANSI(char c) { case 'm': _parameters[_parameterCount++] = _number; for (p=0; p<_parameterCount; p++) { - termDebug("Set attribute %d", _parameters[p]); + //termDebug("Set attribute %d", _parameters[p]); x = _parameters[p]; switch (x) { case 0: @@ -381,13 +381,13 @@ bool termParseANSI(char c) { break; // Cursor save. case 's': - termDebug("Saving cursor"); + //termDebug("Saving cursor"); _cursorSave = cursor; termResetSequence(); break; // Cursor restore. case 'u': - termDebug("Restoring cursor"); + //termDebug("Restoring cursor"); termMoveCursor(_cursorSave.x, _cursorSave.y); termResetSequence(); break; @@ -415,7 +415,7 @@ bool termParseANSI(char c) { cursor.x--; } else { if (cursor.y > 1) { - termDebug("Cursor wrapped off left"); + //termDebug("Cursor wrapped off left"); cursor.y--; cursor.x = _columns; } @@ -460,11 +460,11 @@ bool termParseANSI(char c) { } cursor.x++; if (cursor.x > _columns) { - termDebug("Cursor wrapped off right"); + //termDebug("Cursor wrapped off right"); cursor.x = 1; cursor.y++; if (cursor.y > _rows) { - termDebug("Cursor went off bottom"); + //termDebug("Cursor went off bottom"); cursor.y--; termScrollUp(); } @@ -502,7 +502,7 @@ void termRenderCharacterAtCursor(byte c) { _screenBuffer[i].x = cx; _screenBuffer[i].y = cy; if (_cursor.y > _hiddenLines) { - jlDrawBlit8x8(jlStaSurfaceGet(_ansiFont), cx, cy, (_cursor.x - 1 + _xoff) * 8, (_cursor.y - 1 + _yoff) * 8); + jlDrawBlit8x8(jlImgSurfaceGet(_ansiFont), cx, cy, (_cursor.x - 1 + _xoff) * 8, (_cursor.y - 1 + _yoff) * 8); } } @@ -513,7 +513,7 @@ void termRepaint(void) { int y; for (y=_hiddenLines; y<_rows; y++) { for (x=0; x<_columns; x++) { - jlDrawBlit8x8(jlStaSurfaceGet(_ansiFont), _screenBuffer[i].x, _screenBuffer[i].y, (jint16)(x + _xoff) * 8, (jint16)(y + _yoff) * 8); + jlDrawBlit8x8(jlImgSurfaceGet(_ansiFont), _screenBuffer[i].x, _screenBuffer[i].y, (jint16)(x + _xoff) * 8, (jint16)(y + _yoff) * 8); i++; } } @@ -554,7 +554,7 @@ void termScrollUp(void) { } -void termStart(jlStaT *font, byte xoff, byte yoff, byte cols, byte rows) { +void termStart(jlImgT *font, byte xoff, byte yoff, byte cols, byte rows) { _ansiFont = font; _xoff = xoff; _yoff = yoff; diff --git a/ansiterm.h b/ansiterm.h index 7db9d56..a4abdc0 100644 --- a/ansiterm.h +++ b/ansiterm.h @@ -13,7 +13,7 @@ void termPrintChar(char c); void termRepaint(void); void termRestoreCursor(void); void termSaveCursor(void); -void termStart(jlStaT *font, byte xoff, byte yoff, byte cols, byte rows); +void termStart(jlImgT *font, byte xoff, byte yoff, byte cols, byte rows); void termStop(void); #endif // _H_ANSITERM_ diff --git a/build-IIgs.sh b/build-IIgs.sh index 8e78780..4776afa 100755 --- a/build-IIgs.sh +++ b/build-IIgs.sh @@ -5,4 +5,6 @@ DATA=(thin.sta output.z8 gamedata.dat nowhere.vec) #SOURCE=(*.c *.h) SOURCE=() -. ${JOEY}/joeylib/joeylib/build-IIgs.helper.sh +. ${JOEY}/joeylib/scripts/build-IIgs.helper.sh + +buildIIgs $1 diff --git a/gamedata.dat b/gamedata.dat index b48d5be..0876682 100644 --- a/gamedata.dat +++ b/gamedata.dat @@ -1,3 +1,3 @@ IF Engine Test Game data/output.z8 -thin.sta +thin diff --git a/ifengine.pro b/ifengine.pro index d3af869..7c2ac5d 100644 --- a/ifengine.pro +++ b/ifengine.pro @@ -1,49 +1,15 @@ -TEMPLATE = app -CONFIG += console -CONFIG -= \ - app_bundle \ - qt - -DESTDIR = $$OUT_PWD/build - JOEY = /home/scott/joey +include($$JOEY/dist/joey.pri) -JOEY_INCLUDES = \ - $$JOEY/dist +#ZIP_FLAGS = \ +# -DANSI_COLOR \ +# -DUNIX \ +# -DSCREEN_WIDTH=40 \ +# -DSCREEN_HEIGHT=25 -JOEY_HEADERS = \ - $$JOEY/dist/joey.h - -JOEY_LIBS = \ - -L$$JOEY/dist/linux/x64 \ - -Wl,-rpath,$$JOEY/dist/linux/x64 \ - -Wl,--enable-new-dtags \ - -l:joeylib.a \ - -Wl,--no-undefined \ - -ldl \ - -lsndio \ - -lpthread \ - -lrt \ - -lm - -JOEY_FLAGS = \ - -pthread \ - -D_REENTRANT - -ZIP_FLAGS = \ - -DANSI_COLOR \ - -DUNIX \ - -DSCREEN_WIDTH=40 \ - -DSCREEN_HEIGHT=25 \ - -QMAKE_CFLAGS += \ - $$JOEY_FLAGS - -INCLUDEPATH += \ - $$JOEY_INCLUDES +#QMAKE_CFLAGS += $$ZIP_FLAGS HEADERS += \ - $$JOEY_HEADERS \ ansiterm.h \ ztypes.h @@ -65,11 +31,12 @@ SOURCES += \ screen.c \ text.c \ variable.c \ - joeyio.c + joeyio.c -LIBS += \ - $$JOEY_LIBS \ +OTHER_FILES += \ + build-IIgs.sh \ + postlink.sh \ + notes.txt \ + gamedata.dat -DISTFILES += \ - build-IIgs.sh \ - gamedata.dat +linux:QMAKE_POST_LINK = $$PWD/postlink.sh "$$PWD" "$$JOEY" diff --git a/joeyio.c b/joeyio.c index 0f51977..fb31679 100644 --- a/joeyio.c +++ b/joeyio.c @@ -19,17 +19,18 @@ typedef enum { } DModeT; +static jlImgT *_bitmap = NULL; static jlVecT *_vectorImage = NULL; -static jlStaT *_graphicsPage = NULL; +static jlImgT *_graphicsPage = NULL; static jlSoundT *_soundEffect = NULL; static DModeT _displayMode = DISPLAY_MODE_TEXT; static byte _bufferCount = 0; static char _buffer[COMMAND_BUFFER_SIZE]; static bool _inCommand = false; static byte _cursorIndex = 0; -static byte _cursorSize = 9; +static byte _cursorSize = 8; static unsigned int _cursorTime = 0; -static byte _cursor[] = { 32, 176, 177, 178, 219, 178, 177, 176, 32 }; +static byte _cursor[] = { 32, 176, 177, 178, 219, 178, 177, 176 }; void set_next_display_mode(void); @@ -74,22 +75,24 @@ void clear_text_window(void) { void create_status_window(void) { - printf("Create Status Window\n"); + //printf("Create Status Window\n"); } void delete_status_window(void) { - printf("Delete Status Window\n"); + //printf("Delete Status Window\n"); } void display_char(int c) { - char command; - char *token; - int x; - int y; + char command; + char *token; + int x; + int y; + // This also handles processing of embedded media commands: - // {I name x y} - Display Image "name" @ x, y + // {B name} - Display Bitmap + // {I name x y} - Display Vector Image "name" @ x, y // {M name} - Play Music "name" // {S name} - Play Sound "name" // {Q} - Quiet! @@ -102,6 +105,20 @@ void display_char(int c) { _buffer[_bufferCount] = 0; (void)strtok(_buffer, " "); switch (command) { + case 'B': + token = strtok(NULL, " "); + if (jlImgLoad(_bitmap, token)) { + // Put user into GRAPHICS mode if they aren't. + _displayMode = DISPLAY_MODE_GRAPHICS - 1; + set_next_display_mode(); + // Render the image. + jlImgDisplay(_bitmap); + // Save it to the graphics page. + jlImgCreate(_graphicsPage); + } + jlSoundMusicPlay(token); + break; + case 'I': token = strtok(NULL, " "); if (jlVecLoad(_vectorImage, token)) { @@ -120,7 +137,7 @@ void display_char(int c) { // Render the image. jlVecDisplay(_vectorImage, (jint16)x, (jint16)y); // Save it to the graphics page. - jlStaCreate(_graphicsPage); + jlImgCreate(_graphicsPage); } break; @@ -183,17 +200,19 @@ void initialize_screen(void) { jlDrawClear(); jlDrawColorSet(15); jlDisplayPresent(); - jlStaCreate(_graphicsPage); + jlImgCreate(_graphicsPage); } int input_character(int timeout) { - char k = 0; + char k = 0; + (void)timeout; // In 1/10ths of a second + if (!jlKeyPressed()) { while (!jlKeyPressed() && !jlUtilMustExit()) { // Animate cursor - if (_cursorTime != jlUtilTimer()) { + if (jlUtilTimeSpan(_cursorTime, jlUtilTimer()) > 3) { display_char(_cursor[_cursorIndex++]); display_char(8); if (_cursorIndex >= _cursorSize) { @@ -273,7 +292,8 @@ void move_cursor(int row, int col) { void reset_screen(void) { // Also handled in main - jlStaFree(_graphicsPage); + jlImgFree(_graphicsPage); + jlImgFree(_bitmap); jlVecFree(_vectorImage); jlSoundFree(_soundEffect); } @@ -330,21 +350,21 @@ void set_next_display_mode(void) { switch (_displayMode) { case DISPLAY_MODE_TEXT: - printf("Terminal now TEXT\n"); + //printf("Terminal now TEXT\n"); termHideTopLines(0); termRepaint(); break; case DISPLAY_MODE_GRAPHICS: - printf("Terminal now GRAPHICS\n"); + //printf("Terminal now GRAPHICS\n"); termHideTopLines((byte)screen_rows); - jlStaDisplay(_graphicsPage); + jlImgDisplay(_graphicsPage); break; case DISPLAY_MODE_MIXED: - printf("Terminal now MIXED\n"); + //printf("Terminal now MIXED\n"); termHideTopLines((byte)screen_rows - DISPLAY_MIXED_SIZE); - jlStaDisplay(_graphicsPage); + jlImgDisplay(_graphicsPage); termRepaint(); break; diff --git a/main.c b/main.c index 1ac8cd5..564bfa1 100644 --- a/main.c +++ b/main.c @@ -101,7 +101,7 @@ void process_arguments(char *game) { int main(void) { FILE *in; - jlStaT *font = NULL; + jlImgT *font = NULL; char name[40]; char game[40]; char text[40]; @@ -121,7 +121,7 @@ int main(void) { jlUtilStartup(name); - if (!jlStaLoad(font, text)) { + if (!jlImgLoad(font, text)) { jlUtilDie("Unable to load [%s] (%d)", text, strlen(text)); } @@ -142,7 +142,7 @@ int main(void) { reset_screen(); termStop(); - jlStaFree(font); + jlImgFree(font); jlUtilShutdown(); } diff --git a/postlink.sh b/postlink.sh new file mode 100755 index 0000000..0e3d0eb --- /dev/null +++ b/postlink.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +GAME=$1 +export JOEY=$2 + +mkdir -p data +cp -f "${GAME}"/gamedata.dat data/. +cp -f "${GAME}"/output.z8 data/. +cp -f "${GAME}"/*.vec data/. +cp -f "${GAME}"/*.img data/. diff --git a/thin.img b/thin.img new file mode 100644 index 0000000..73dfabf --- /dev/null +++ b/thin.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5f2312250edddaca7693c8445d47bdcb667573e5ea13a79e8b724ae37d91587 +size 32036 diff --git a/thin.sta b/thin.sta deleted file mode 100644 index 7884ce5..0000000 --- a/thin.sta +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:565eb32e85105126f7c0a1a0dcecc8a1fa5c46a81d072a8b650942c839152fb2 -size 32036