Updated to latest JoeyLib API. Added {B} command to display bitmaps.
This commit is contained in:
parent
be75c40812
commit
e4f974496e
11 changed files with 97 additions and 98 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -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
|
||||
|
|
42
ansiterm.c
42
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;
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
IF Engine Test Game
|
||||
data/output.z8
|
||||
thin.sta
|
||||
thin
|
||||
|
|
57
ifengine.pro
57
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
|
||||
|
||||
|
@ -67,9 +33,10 @@ SOURCES += \
|
|||
variable.c \
|
||||
joeyio.c
|
||||
|
||||
LIBS += \
|
||||
$$JOEY_LIBS \
|
||||
|
||||
DISTFILES += \
|
||||
OTHER_FILES += \
|
||||
build-IIgs.sh \
|
||||
postlink.sh \
|
||||
notes.txt \
|
||||
gamedata.dat
|
||||
|
||||
linux:QMAKE_POST_LINK = $$PWD/postlink.sh "$$PWD" "$$JOEY"
|
||||
|
|
50
joeyio.c
50
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,12 +75,12 @@ 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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,8 +89,10 @@ void display_char(int c) {
|
|||
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;
|
||||
|
||||
(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;
|
||||
|
||||
|
|
6
main.c
6
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();
|
||||
}
|
||||
|
||||
|
|
10
postlink.sh
Executable file
10
postlink.sh
Executable file
|
@ -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/.
|
BIN
thin.img
(Stored with Git LFS)
Normal file
BIN
thin.img
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
thin.sta
(Stored with Git LFS)
BIN
thin.sta
(Stored with Git LFS)
Binary file not shown.
Loading…
Add table
Reference in a new issue