Media support added! Probably has bugs.
This commit is contained in:
parent
0d16275af3
commit
e15a7d0df0
18 changed files with 2093 additions and 1904 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,2 +1,4 @@
|
||||||
*.sta filter=lfs diff=lfs merge=lfs -text
|
*.sta filter=lfs diff=lfs merge=lfs -text
|
||||||
*.z5 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
|
||||||
|
|
75
ansiterm.c
75
ansiterm.c
|
@ -13,38 +13,38 @@ segment "ansiterm";
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x;
|
byte x;
|
||||||
int y;
|
byte y;
|
||||||
} Vector2T;
|
} PositionT;
|
||||||
|
|
||||||
|
|
||||||
static int _columns = 40;
|
static byte _columns = 40;
|
||||||
static int _rows = 25;
|
static byte _rows = 25;
|
||||||
static int _xoff = 0;
|
static byte _xoff = 0;
|
||||||
static int _yoff = 0;
|
static byte _yoff = 0;
|
||||||
static bool _escFound = false;
|
static bool _escFound = false;
|
||||||
static bool _inEscape = false;
|
static bool _inEscape = false;
|
||||||
static bool _bold = false;
|
static bool _bold = false;
|
||||||
static bool _blink = false;
|
static bool _blink = false;
|
||||||
static bool _reverse = false;
|
static bool _reverse = false;
|
||||||
static bool _destructiveBS = false;
|
static bool _destructiveBS = false;
|
||||||
static int _foreground = 7;
|
static byte _foreground = 7;
|
||||||
static int _background = 0;
|
static byte _background = 0;
|
||||||
static int _fColor = 7;
|
static byte _fColor = 7;
|
||||||
static int _bColor = 0;
|
static byte _bColor = 0;
|
||||||
static int _number = 0;
|
static byte _number = 0;
|
||||||
static int _parameters[5];
|
static byte _parameters[5];
|
||||||
static int _parameterCount = 0;
|
static byte _parameterCount = 0;
|
||||||
|
static byte _hiddenLines = 0;
|
||||||
static jlStaT *_ansiFont = NULL;
|
static jlStaT *_ansiFont = NULL;
|
||||||
static Vector2T _cursorSave;
|
static PositionT _cursorSave;
|
||||||
static Vector2T _cursor;
|
static PositionT _cursor;
|
||||||
static Vector2T *_screenBuffer = NULL;
|
static PositionT *_screenBuffer = NULL;
|
||||||
|
|
||||||
|
|
||||||
void termDebug(const char *what, ...);
|
void termDebug(const char *what, ...);
|
||||||
bool termParseANSI(char c);
|
bool termParseANSI(char c);
|
||||||
void termRenderCharacterAtCursor(byte c);
|
void termRenderCharacterAtCursor(byte c);
|
||||||
void termRepaint(void);
|
|
||||||
void termResetSequence(void);
|
void termResetSequence(void);
|
||||||
void termScrollUp(void);
|
void termScrollUp(void);
|
||||||
void termUpdateColors(void);
|
void termUpdateColors(void);
|
||||||
|
@ -81,13 +81,18 @@ void termDestruciveBackspace(bool dbs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void termGetCursor(int *x, int *y) {
|
void termGetCursor(byte *x, byte *y) {
|
||||||
*x = _cursor.x;
|
*x = _cursor.x;
|
||||||
*y = _cursor.y;
|
*y = _cursor.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void termMoveCursor(int x, int y) {
|
void termHideTopLines(byte count) {
|
||||||
|
_hiddenLines = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void termMoveCursor(byte x, byte y) {
|
||||||
if (x < 1) {
|
if (x < 1) {
|
||||||
_cursor.x = 1;
|
_cursor.x = 1;
|
||||||
termDebug("Attempt to position cursor too far left: %d", x);
|
termDebug("Attempt to position cursor too far left: %d", x);
|
||||||
|
@ -114,13 +119,13 @@ void termMoveCursor(int x, int y) {
|
||||||
|
|
||||||
|
|
||||||
bool termParseANSI(char c) {
|
bool termParseANSI(char c) {
|
||||||
int x;
|
bool x;
|
||||||
int y;
|
bool y;
|
||||||
int oldX;
|
bool oldX;
|
||||||
int cx;
|
bool cx;
|
||||||
int p;
|
int p;
|
||||||
bool updateDisplay = false;
|
bool updateDisplay = false;
|
||||||
Vector2T cursor = _cursor;
|
PositionT cursor = _cursor;
|
||||||
|
|
||||||
// Find leading ESC character.
|
// Find leading ESC character.
|
||||||
if ((c == (char)27) && !_escFound && !_inEscape) {
|
if ((c == (char)27) && !_escFound && !_inEscape) {
|
||||||
|
@ -389,7 +394,7 @@ bool termParseANSI(char c) {
|
||||||
default:
|
default:
|
||||||
// Number?
|
// Number?
|
||||||
if ((c >= '0') && (c <= '9')) {
|
if ((c >= '0') && (c <= '9')) {
|
||||||
_number = _number * 10 + (c - '0');
|
_number = (byte)(_number * 10 + (c - '0'));
|
||||||
} else {
|
} else {
|
||||||
termDebug("Unknown sequence: %d", (int)c);
|
termDebug("Unknown sequence: %d", (int)c);
|
||||||
termResetSequence();
|
termResetSequence();
|
||||||
|
@ -489,23 +494,25 @@ void termPrintChar(char c) {
|
||||||
|
|
||||||
|
|
||||||
void termRenderCharacterAtCursor(byte c) {
|
void termRenderCharacterAtCursor(byte c) {
|
||||||
int r = (_reverse ? 7 : 0);
|
byte r = (_reverse ? 7 : 0);
|
||||||
int cx = c % 40;
|
byte cx = c % 40;
|
||||||
int cy = (c / 40) + r;
|
byte cy = (c / 40) + r;
|
||||||
int i = ((_cursor.y - 1) * _columns) + (_cursor.x - 1);
|
int i = ((_cursor.y - 1) * _columns) + (_cursor.x - 1);
|
||||||
_screenBuffer[i].x = cx;
|
_screenBuffer[i].x = cx;
|
||||||
_screenBuffer[i].y = cy;
|
_screenBuffer[i].y = cy;
|
||||||
|
if (_cursor.y > _hiddenLines) {
|
||||||
jlDrawBlit8x8(_ansiFont, cx, cy, _cursor.x - 1 + _xoff, _cursor.y - 1 + _yoff);
|
jlDrawBlit8x8(_ansiFont, cx, cy, _cursor.x - 1 + _xoff, _cursor.y - 1 + _yoff);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void termRepaint(void) {
|
void termRepaint(void) {
|
||||||
int i = 0;
|
int i = _hiddenLines * _columns;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
for (y=0; y<_rows; y++) {
|
for (y=_hiddenLines; y<_rows; y++) {
|
||||||
for (x=0; x<_columns; x++) {
|
for (x=0; x<_columns; x++) {
|
||||||
jlDrawBlit8x8(_ansiFont, _screenBuffer[i].x, _screenBuffer[i].y, x, y);
|
jlDrawBlit8x8(_ansiFont, _screenBuffer[i].x, _screenBuffer[i].y, x + _xoff, y + _yoff);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,7 +553,7 @@ void termScrollUp(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void termStart(jlStaT *font, int xoff, int yoff, int cols, int rows) {
|
void termStart(jlStaT *font, byte xoff, byte yoff, byte cols, byte rows) {
|
||||||
_ansiFont = font;
|
_ansiFont = font;
|
||||||
_xoff = xoff;
|
_xoff = xoff;
|
||||||
_yoff = yoff;
|
_yoff = yoff;
|
||||||
|
@ -556,7 +563,7 @@ void termStart(jlStaT *font, int xoff, int yoff, int cols, int rows) {
|
||||||
_cursorSave.y = 1;
|
_cursorSave.y = 1;
|
||||||
_cursor.x = 1;
|
_cursor.x = 1;
|
||||||
_cursor.y = 1;
|
_cursor.y = 1;
|
||||||
_screenBuffer = (Vector2T *)jlMalloc(sizeof(Vector2T) * (size_t)(_columns * _rows));
|
_screenBuffer = (PositionT *)jlMalloc(sizeof(PositionT) * (size_t)(_columns * _rows));
|
||||||
termClearScreen();
|
termClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,15 @@
|
||||||
|
|
||||||
void termClearScreen(void);
|
void termClearScreen(void);
|
||||||
void termDestruciveBackspace(bool dbs);
|
void termDestruciveBackspace(bool dbs);
|
||||||
void termGetCursor(int *x, int *y);
|
void termGetCursor(byte *x, byte *y);
|
||||||
void termMoveCursor(int x, int y);
|
void termHideTopLines(byte count);
|
||||||
|
void termMoveCursor(byte x, byte y);
|
||||||
void termPrint(char *string);
|
void termPrint(char *string);
|
||||||
void termPrintChar(char c);
|
void termPrintChar(char c);
|
||||||
|
void termRepaint(void);
|
||||||
void termRestoreCursor(void);
|
void termRestoreCursor(void);
|
||||||
void termSaveCursor(void);
|
void termSaveCursor(void);
|
||||||
void termStart(jlStaT *font, int xoff, int yoff, int cols, int rows);
|
void termStart(jlStaT *font, byte xoff, byte yoff, byte cols, byte rows);
|
||||||
void termStop(void);
|
void termStop(void);
|
||||||
|
|
||||||
#endif // _H_ANSITERM_
|
#endif // _H_ANSITERM_
|
||||||
|
|
21
fileio.c
21
fileio.c
|
@ -52,8 +52,8 @@ static FILE *rfp = NULL; /* Record file pointer */
|
||||||
static char gfpbuffer[BUFSIZ];
|
static char gfpbuffer[BUFSIZ];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
static char sfpbuffer[BUFSIZ];
|
//static char sfpbuffer[BUFSIZ];
|
||||||
static char rfpbuffer[BUFSIZ];
|
//static char rfpbuffer[BUFSIZ];
|
||||||
|
|
||||||
char save_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1] = "story.sav";
|
char save_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1] = "story.sav";
|
||||||
char script_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1] = "story.scr";
|
char script_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1] = "story.scr";
|
||||||
|
@ -123,7 +123,8 @@ void set_names( const char *storyname )
|
||||||
|
|
||||||
void open_story( const char *storyname )
|
void open_story( const char *storyname )
|
||||||
{
|
{
|
||||||
char *path, *p;
|
char *path = NULL;
|
||||||
|
char *p = NULL;
|
||||||
char tmp[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
char tmp[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
||||||
|
|
||||||
// if ( !STANDALONE_FLAG )
|
// if ( !STANDALONE_FLAG )
|
||||||
|
@ -297,7 +298,7 @@ void read_page( int page, void *buffer )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Read failed. Are we in the last page? */
|
/* Read failed. Are we in the last page? */
|
||||||
file_size = ( unsigned long ) h_file_size *story_scaler;
|
file_size = ( unsigned long )(h_file_size *story_scaler);
|
||||||
|
|
||||||
pages = ( unsigned int ) ( ( unsigned long ) file_size / PAGE_SIZE );
|
pages = ( unsigned int ) ( ( unsigned long ) file_size / PAGE_SIZE );
|
||||||
offset = ( unsigned int ) ( ( unsigned long ) file_size & PAGE_MASK );
|
offset = ( unsigned int ) ( ( unsigned long ) file_size & PAGE_MASK );
|
||||||
|
@ -401,7 +402,7 @@ void z_verify( void )
|
||||||
|
|
||||||
/* Calculate game file dimensions */
|
/* Calculate game file dimensions */
|
||||||
|
|
||||||
file_size = ( unsigned long ) h_file_size *story_scaler;
|
file_size = ( unsigned long )(h_file_size *story_scaler);
|
||||||
|
|
||||||
pages = ( unsigned int ) ( ( unsigned long ) file_size / PAGE_SIZE );
|
pages = ( unsigned int ) ( ( unsigned long ) file_size / PAGE_SIZE );
|
||||||
offset = ( unsigned int ) file_size & PAGE_MASK;
|
offset = ( unsigned int ) file_size & PAGE_MASK;
|
||||||
|
@ -410,7 +411,7 @@ void z_verify( void )
|
||||||
|
|
||||||
for ( i = 0; i <= pages; i++ )
|
for ( i = 0; i <= pages; i++ )
|
||||||
{
|
{
|
||||||
read_page( i, buffer );
|
read_page( (int)i, buffer );
|
||||||
start = ( i == 0 ) ? 64 : 0;
|
start = ( i == 0 ) ? 64 : 0;
|
||||||
end = ( i == pages ) ? offset : PAGE_SIZE;
|
end = ( i == pages ) ? offset : PAGE_SIZE;
|
||||||
for ( j = start; j < end; j++ )
|
for ( j = start; j < end; j++ )
|
||||||
|
@ -448,7 +449,7 @@ static void get_default_name( char *default_name, zword_t addr )
|
||||||
{
|
{
|
||||||
addr++;
|
addr++;
|
||||||
c = get_byte( addr );
|
c = get_byte( addr );
|
||||||
default_name[i] = c;
|
default_name[i] = (char)c;
|
||||||
}
|
}
|
||||||
default_name[i] = 0;
|
default_name[i] = 0;
|
||||||
|
|
||||||
|
@ -503,7 +504,7 @@ int z_save( int argc, zword_t table, zword_t bytes, zword_t name )
|
||||||
setbuf( afp, afpbuffer );
|
setbuf( afp, afpbuffer );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = fwrite( datap + table, bytes, 1, afp );
|
status = (int)fwrite( datap + table, bytes, 1, afp );
|
||||||
|
|
||||||
fclose( afp );
|
fclose( afp );
|
||||||
|
|
||||||
|
@ -591,7 +592,7 @@ int z_restore( int argc, zword_t table, zword_t bytes, zword_t name )
|
||||||
setbuf( afp, afpbuffer );
|
setbuf( afp, afpbuffer );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = fread( datap + table, bytes, 1, afp );
|
status = (int)fread( datap + table, bytes, 1, afp );
|
||||||
|
|
||||||
fclose( afp );
|
fclose( afp );
|
||||||
|
|
||||||
|
@ -1315,7 +1316,7 @@ int playback_line( int buflen, char *buffer, int *read_size )
|
||||||
{
|
{
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
}
|
}
|
||||||
*read_size = strlen( buffer );
|
*read_size = (int)strlen( buffer );
|
||||||
output_line( buffer );
|
output_line( buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
gamedata.dat
Normal file
3
gamedata.dat
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
IF Engine Test Game
|
||||||
|
output.z8
|
||||||
|
8x8thin.sta
|
BIN
gamedata.z5
BIN
gamedata.z5
Binary file not shown.
|
@ -45,7 +45,6 @@ INCLUDEPATH += \
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$JOEY_HEADERS \
|
$$JOEY_HEADERS \
|
||||||
ansiterm.h \
|
ansiterm.h \
|
||||||
jzip.h \
|
|
||||||
ztypes.h
|
ztypes.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|
9
input.c
9
input.c
|
@ -177,7 +177,7 @@ void z_sread_aread( int argc, zword_t * argv )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer = &cbuf[1];
|
buffer = &cbuf[1];
|
||||||
out_size = strlen( buffer );
|
out_size = (int)strlen( buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( out_size > in_size )
|
if ( out_size > in_size )
|
||||||
|
@ -318,7 +318,7 @@ static void tokenise_line( zword_t char_buf, zword_t token_buf, zword_t dictiona
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
slen = strlen( cbuf + 1 );
|
slen = (int)strlen( cbuf + 1 );
|
||||||
str_end = cbuf + 1 + slen;
|
str_end = cbuf + 1 + slen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ static void tokenise_line( zword_t char_buf, zword_t token_buf, zword_t dictiona
|
||||||
|
|
||||||
count = get_byte( dictionary++ );
|
count = get_byte( dictionary++ );
|
||||||
for ( i = 0; i < count; i++ )
|
for ( i = 0; i < count; i++ )
|
||||||
punctuation[i] = get_byte( dictionary++ );
|
punctuation[i] = (char)get_byte( dictionary++ );
|
||||||
punctuation[i] = '\0';
|
punctuation[i] = '\0';
|
||||||
entry_size = get_byte( dictionary++ );
|
entry_size = get_byte( dictionary++ );
|
||||||
dictionary_size = ( ZINT16 ) get_word( dictionary );
|
dictionary_size = ( ZINT16 ) get_word( dictionary );
|
||||||
|
@ -357,7 +357,7 @@ static void tokenise_line( zword_t char_buf, zword_t token_buf, zword_t dictiona
|
||||||
/* Skip to next token */
|
/* Skip to next token */
|
||||||
|
|
||||||
cp = next_token( cp, str_end, &token, &token_length, punctuation );
|
cp = next_token( cp, str_end, &token, &token_length, punctuation );
|
||||||
if ( token_length )
|
if ( token_length ) {
|
||||||
|
|
||||||
/* If still space in token buffer then store word */
|
/* If still space in token buffer then store word */
|
||||||
|
|
||||||
|
@ -392,6 +392,7 @@ static void tokenise_line( zword_t char_buf, zword_t token_buf, zword_t dictiona
|
||||||
output_line( token );
|
output_line( token );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
while ( token_length );
|
while ( token_length );
|
||||||
|
|
||||||
/* Store word count */
|
/* Store word count */
|
||||||
|
|
165
joeyio.c
165
joeyio.c
|
@ -3,12 +3,33 @@
|
||||||
#include "ztypes.h"
|
#include "ztypes.h"
|
||||||
|
|
||||||
|
|
||||||
static int _cursorIndex = 0;
|
#define DISPLAY_MIXED_SIZE 5
|
||||||
static int _cursorSize = 9;
|
#define COMMAND_BUFFER_SIZE 32
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DISPLAY_MODE_TEXT = 0,
|
||||||
|
DISPLAY_MODE_GRAPHICS,
|
||||||
|
DISPLAY_MODE_MIXED,
|
||||||
|
DISPLAY_MODE_LAST
|
||||||
|
} DModeT;
|
||||||
|
|
||||||
|
|
||||||
|
static jlVecT *_vectorImage = NULL;
|
||||||
|
static jlStaT *_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 unsigned int _cursorTime = 0;
|
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, 32 };
|
||||||
|
|
||||||
|
|
||||||
|
void set_next_display_mode(void);
|
||||||
|
|
||||||
|
|
||||||
void clear_line(void) {
|
void clear_line(void) {
|
||||||
termPrint("\33[K");
|
termPrint("\33[K");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +37,7 @@ void clear_line(void) {
|
||||||
|
|
||||||
void clear_screen(void) {
|
void clear_screen(void) {
|
||||||
termClearScreen();
|
termClearScreen();
|
||||||
termMoveCursor(1, screen_rows);
|
termMoveCursor(1, (byte)screen_rows);
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,17 +79,106 @@ void delete_status_window(void) {
|
||||||
|
|
||||||
|
|
||||||
void display_char(int c) {
|
void display_char(int c) {
|
||||||
|
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
|
||||||
|
// {M name} - Play Music "name"
|
||||||
|
// {S name} - Play Sound "name"
|
||||||
|
// {Q} - Quiet!
|
||||||
|
if (_inCommand) {
|
||||||
|
if ((char) c == '}') {
|
||||||
|
// Exit command mode.
|
||||||
|
if (_bufferCount > 0) {
|
||||||
|
// Did we get a command we understand?
|
||||||
|
command = (char)toupper(_buffer[0]);
|
||||||
|
_buffer[_bufferCount] = 0;
|
||||||
|
(void)strtok(_buffer, " ");
|
||||||
|
switch (command) {
|
||||||
|
case 'I':
|
||||||
|
token = strtok(NULL, " ");
|
||||||
|
if (jlVecLoad(_vectorImage, token)) {
|
||||||
|
x = y = 0;
|
||||||
|
token = strtok(NULL, " ");
|
||||||
|
if (token != NULL) {
|
||||||
|
x = atoi(token);
|
||||||
|
token = strtok(NULL, " ");
|
||||||
|
if (token != NULL) {
|
||||||
|
y = atoi(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Put user into GRAPHICS mode if they aren't.
|
||||||
|
_displayMode = DISPLAY_MODE_GRAPHICS - 1;
|
||||||
|
set_next_display_mode();
|
||||||
|
// Render the image.
|
||||||
|
jlVecDisplay(_vectorImage, x, y);
|
||||||
|
// Save it to the graphics page.
|
||||||
|
jlStaCreate(_graphicsPage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'M':
|
||||||
|
token = strtok(NULL, " ");
|
||||||
|
jlSoundMusicPlay(token);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'S':
|
||||||
|
token = strtok(NULL, " ");
|
||||||
|
if (jlSoundLoad(_soundEffect, token)) {
|
||||||
|
jlSoundPlay(_soundEffect);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Q':
|
||||||
|
jlSoundMusicStop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Exit command mode
|
||||||
|
_bufferCount = 0;
|
||||||
|
_inCommand = false;
|
||||||
|
} else {
|
||||||
|
if (_bufferCount < COMMAND_BUFFER_SIZE - 1) {
|
||||||
|
// Add character to command buffer.
|
||||||
|
_buffer[_bufferCount++] = (char)c;
|
||||||
|
} else {
|
||||||
|
// Overflowed buffer - exit command mode
|
||||||
|
_bufferCount = 0;
|
||||||
|
_inCommand = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((char)c == '{') {
|
||||||
|
// Switch to embedded command mode.
|
||||||
|
_inCommand = true;
|
||||||
|
} else {
|
||||||
|
// Display game text.
|
||||||
termPrintChar((char)c);
|
termPrintChar((char)c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_cursor_position(int *row, int *col) {
|
void get_cursor_position(int *row, int *col) {
|
||||||
termGetCursor(col, row);
|
byte x;
|
||||||
|
byte y;
|
||||||
|
termGetCursor(&x, &y);
|
||||||
|
*col = (int)x;
|
||||||
|
*row = (int)y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void initialize_screen(void) {
|
void initialize_screen(void) {
|
||||||
// Handled in main
|
// Also handled in main
|
||||||
|
|
||||||
|
// Create initial empty graphics image.
|
||||||
|
jlDrawColor(0);
|
||||||
|
jlDrawClear();
|
||||||
|
jlDrawColor(15);
|
||||||
|
jlDisplayPresent();
|
||||||
|
jlStaCreate(_graphicsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,8 +239,12 @@ int input_line(int buflen, char *buffer, int timeout, int *read_size) {
|
||||||
//***TODO*** Flash border or ding or something
|
//***TODO*** Flash border or ding or something
|
||||||
} else {
|
} else {
|
||||||
if (c == 13) {
|
if (c == 13) {
|
||||||
|
if (curr_char_pos == 0) {
|
||||||
|
set_next_display_mode();
|
||||||
|
} else {
|
||||||
scroll_line();
|
scroll_line();
|
||||||
return c;
|
return c;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer[curr_char_pos++] = (char)c;
|
buffer[curr_char_pos++] = (char)c;
|
||||||
if (*read_size < curr_char_pos) {
|
if (*read_size < curr_char_pos) {
|
||||||
|
@ -148,12 +262,15 @@ int input_line(int buflen, char *buffer, int timeout, int *read_size) {
|
||||||
|
|
||||||
|
|
||||||
void move_cursor(int row, int col) {
|
void move_cursor(int row, int col) {
|
||||||
termMoveCursor(col, row);
|
termMoveCursor((byte)col, (byte)row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reset_screen(void) {
|
void reset_screen(void) {
|
||||||
// Handled in main
|
// Also handled in main
|
||||||
|
jlStaFree(_graphicsPage);
|
||||||
|
jlVecFree(_vectorImage);
|
||||||
|
jlSoundFree(_soundEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,3 +314,37 @@ void set_attribute(int attribute) {
|
||||||
termPrint("\33[7m");
|
termPrint("\33[7m");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void set_next_display_mode(void) {
|
||||||
|
|
||||||
|
_displayMode++;
|
||||||
|
if (_displayMode >= DISPLAY_MODE_LAST) {
|
||||||
|
_displayMode = DISPLAY_MODE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (_displayMode) {
|
||||||
|
case DISPLAY_MODE_TEXT:
|
||||||
|
printf("Terminal now TEXT\n");
|
||||||
|
termHideTopLines(0);
|
||||||
|
termRepaint();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_MODE_GRAPHICS:
|
||||||
|
printf("Terminal now GRAPHICS\n");
|
||||||
|
termHideTopLines((byte)screen_rows);
|
||||||
|
jlStaDisplay(_graphicsPage);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_MODE_MIXED:
|
||||||
|
printf("Terminal now MIXED\n");
|
||||||
|
termHideTopLines((byte)screen_rows - DISPLAY_MIXED_SIZE);
|
||||||
|
jlStaDisplay(_graphicsPage);
|
||||||
|
termRepaint();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISPLAY_MODE_LAST:
|
||||||
|
// Won't happen. Silences a warning.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
37
jzip.h
37
jzip.h
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
/* $Id: jzip.h,v 1.5 2000/10/10 14:46:22 jholder Exp $
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
* see doc/License.txt for License Information
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* File name: $Id: jzip.h,v 1.5 2000/10/10 14:46:22 jholder Exp $
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
*
|
|
||||||
* Modification history:
|
|
||||||
* $Log: jzip.h,v $
|
|
||||||
* Revision 1.5 2000/10/10 14:46:22 jholder
|
|
||||||
* Fixed text wrap bug when printing array w/ \r chars in it
|
|
||||||
*
|
|
||||||
* Revision 1.4 2000/10/05 17:09:12 jholder
|
|
||||||
* removed old email address
|
|
||||||
*
|
|
||||||
* Revision 1.3 2000/10/04 23:07:57 jholder
|
|
||||||
* fixed redirect problem with isolatin1 range chars
|
|
||||||
*
|
|
||||||
* Revision 1.2 2000/09/18 15:31:44 jholder
|
|
||||||
* Updated release date for package release
|
|
||||||
*
|
|
||||||
* Revision 1.1.1.1 2000/05/10 14:21:34 jholder
|
|
||||||
*
|
|
||||||
* imported
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define JZIPVER "Jzip V2.1"
|
|
||||||
#define JZIPRELDATE "Tue, Oct 10 2000"
|
|
||||||
#define JZIPAUTHOR "John Holder (j-holder@home.com)"
|
|
||||||
#define JZIPURL "http://jzip.sourceforge.net/"
|
|
||||||
|
|
25
main.c
25
main.c
|
@ -1,5 +1,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#include "joey.h"
|
#include "joey.h"
|
||||||
|
@ -94,17 +95,34 @@ void process_arguments(char *game) {
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
|
FILE *in;
|
||||||
jlStaT *font = NULL;
|
jlStaT *font = NULL;
|
||||||
|
char name[40];
|
||||||
|
char game[40];
|
||||||
|
char text[40];
|
||||||
|
|
||||||
jlUtilStartup("IF Engine");
|
in = fopen("gamedata.dat", "rt");
|
||||||
jlStaLoad(font, "8x8thin.sta");
|
if (in != NULL) {
|
||||||
|
|
||||||
|
fgets(name, 40, in);
|
||||||
|
fgets(game, 40, in);
|
||||||
|
fgets(text, 40, in);
|
||||||
|
|
||||||
|
fclose(in);
|
||||||
|
|
||||||
|
name[strlen(name) - 1] = 0;
|
||||||
|
game[strlen(game) - 1] = 0;
|
||||||
|
text[strlen(text) - 1] = 0;
|
||||||
|
|
||||||
|
jlUtilStartup(name);
|
||||||
|
jlStaLoad(font, text);
|
||||||
|
|
||||||
termStart(font, 0, 0, 40, 25);
|
termStart(font, 0, 0, 40, 25);
|
||||||
termDestruciveBackspace(false);
|
termDestruciveBackspace(false);
|
||||||
termMoveCursor(1, 25);
|
termMoveCursor(1, 25);
|
||||||
termSaveCursor();
|
termSaveCursor();
|
||||||
|
|
||||||
process_arguments("gamedata.z5");
|
process_arguments(game);
|
||||||
configure(V1, V8);
|
configure(V1, V8);
|
||||||
initialize_screen();
|
initialize_screen();
|
||||||
load_cache();
|
load_cache();
|
||||||
|
@ -118,6 +136,7 @@ int main(void) {
|
||||||
termStop();
|
termStop();
|
||||||
|
|
||||||
jlStaFree(font);
|
jlStaFree(font);
|
||||||
|
}
|
||||||
|
|
||||||
jlUtilShutdown();
|
jlUtilShutdown();
|
||||||
}
|
}
|
||||||
|
|
0
nowhere.vec
Normal file
0
nowhere.vec
Normal file
29
nowhere.vec.source
Normal file
29
nowhere.vec.source
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# Reset Palette, Clear Screen to White, Draw in Black
|
||||||
|
# Hacky Border because we can't hit 319 yet.
|
||||||
|
R
|
||||||
|
C 0
|
||||||
|
E
|
||||||
|
C 15
|
||||||
|
S 0 0 255 199
|
||||||
|
C 0
|
||||||
|
|
||||||
|
# Horizon
|
||||||
|
L 0 87 255 87
|
||||||
|
|
||||||
|
# Sun
|
||||||
|
L 255 64 248 61 240 61 233 62 228 66 223 72 220 78 220 87
|
||||||
|
|
||||||
|
# Beach
|
||||||
|
L 0 101 87 124 126 128 148 133 160 136 168 141 172 146 171 149 169 153 169 158 176 164 188 168 205 171 227 174 255 174
|
||||||
|
|
||||||
|
# Fill Sun
|
||||||
|
C 12
|
||||||
|
F 242 74
|
||||||
|
|
||||||
|
# Fill Beach
|
||||||
|
C 14
|
||||||
|
F 105 161
|
||||||
|
|
||||||
|
# Fill Ocean
|
||||||
|
C 1
|
||||||
|
F 194 106
|
|
@ -468,7 +468,8 @@ void set_font( int font_type )
|
||||||
|
|
||||||
void set_colours( zword_t foreground, zword_t background )
|
void set_colours( zword_t foreground, zword_t background )
|
||||||
{
|
{
|
||||||
|
(void)foreground;
|
||||||
|
(void)background;
|
||||||
} /* set_colours */
|
} /* set_colours */
|
||||||
|
|
||||||
#endif /* !defined MSDOS && !defined OS2 && !defined AMIGA !defined HARD_COLORS && !defined ATARIST */
|
#endif /* !defined MSDOS && !defined OS2 && !defined AMIGA !defined HARD_COLORS && !defined ATARIST */
|
||||||
|
@ -519,6 +520,8 @@ void set_colours( zword_t foreground, zword_t background )
|
||||||
|
|
||||||
int codes_to_text( int c, char *s )
|
int codes_to_text( int c, char *s )
|
||||||
{
|
{
|
||||||
|
(void)c;
|
||||||
|
(void)s;
|
||||||
return 1;
|
return 1;
|
||||||
} /* codes_to_text */
|
} /* codes_to_text */
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ void z_get_prop( zword_t obj, zword_t prop )
|
||||||
{
|
{
|
||||||
prop_addr++;
|
prop_addr++;
|
||||||
/* Only load first property if it is a byte sized property */
|
/* Only load first property if it is a byte sized property */
|
||||||
if ( h_type <= V3 && !( value & 0xe0 ) || h_type >= V4 && !( value & 0xc0 ) )
|
if ( (h_type <= V3 && !( value & 0xe0 )) || (h_type >= V4 && !( value & 0xc0 )) )
|
||||||
{
|
{
|
||||||
bprop_val = get_byte( prop_addr );
|
bprop_val = get_byte( prop_addr );
|
||||||
wprop_val = bprop_val;
|
wprop_val = bprop_val;
|
||||||
|
@ -205,7 +205,7 @@ void z_put_prop( zword_t obj, zword_t prop, zword_t setvalue )
|
||||||
|
|
||||||
prop_addr++;
|
prop_addr++;
|
||||||
|
|
||||||
if ( h_type <= V3 && !( value & 0xe0 ) || h_type >= V4 && !( value & 0xc0 ) )
|
if ( (h_type <= V3 && !( value & 0xe0 )) || (h_type >= V4 && !( value & 0xc0 )) )
|
||||||
{
|
{
|
||||||
set_byte( prop_addr, ( zbyte_t ) setvalue );
|
set_byte( prop_addr, ( zbyte_t ) setvalue );
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,7 +413,7 @@ int restore_quetzal( FILE * sfp, FILE * gfp )
|
||||||
if ( !read_long( sfp, &tmpl ) )
|
if ( !read_long( sfp, &tmpl ) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
y = ( zword_t ) tmpl & 0x0F;
|
y = ( zword_t ) tmpl & 0x0F;
|
||||||
tmpw = y << VAR_SHIFT; /* number of variables */
|
tmpw = (zword_t)(y << VAR_SHIFT); /* number of variables */
|
||||||
/* read result variable */
|
/* read result variable */
|
||||||
if ( ( x = get_c( sfp ) ) == EOF )
|
if ( ( x = get_c( sfp ) ) == EOF )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -553,7 +553,7 @@ int restore_quetzal( FILE * sfp, FILE * gfp )
|
||||||
}
|
}
|
||||||
/* Fall thru (to default) if already got memory */
|
/* Fall thru (to default) if already got memory */
|
||||||
default:
|
default:
|
||||||
( void ) fseek( sfp, currlen, SEEK_CUR ); /* skip chunk */
|
( void ) fseek( sfp, (long)currlen, SEEK_CUR ); /* skip chunk */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( skip )
|
if ( skip )
|
||||||
|
|
9
text.c
9
text.c
|
@ -423,9 +423,9 @@ void encode_text( int len, const char *s, ZINT16 * buffer )
|
||||||
|
|
||||||
/* Pack codes into buffer */
|
/* Pack codes into buffer */
|
||||||
|
|
||||||
buffer[0] = ( ( ZINT16 ) codes[0] << 10 ) | ( ( ZINT16 ) codes[1] << 5 ) | ( ZINT16 ) codes[2];
|
buffer[0] = (short)(( ( ZINT16 ) codes[0] << 10 ) | ( ( ZINT16 ) codes[1] << 5 ) | ( ZINT16 ) codes[2]);
|
||||||
buffer[1] = ( ( ZINT16 ) codes[3] << 10 ) | ( ( ZINT16 ) codes[4] << 5 ) | ( ZINT16 ) codes[5];
|
buffer[1] = (short)(( ( ZINT16 ) codes[3] << 10 ) | ( ( ZINT16 ) codes[4] << 5 ) | ( ZINT16 ) codes[5]);
|
||||||
buffer[2] = ( ( ZINT16 ) codes[6] << 10 ) | ( ( ZINT16 ) codes[7] << 5 ) | ( ZINT16 ) codes[8];
|
buffer[2] = (short)(( ( ZINT16 ) codes[6] << 10 ) | ( ( ZINT16 ) codes[7] << 5 ) | ( ZINT16 ) codes[8]);
|
||||||
|
|
||||||
/* Terminate buffer at 6 or 9 codes depending on the version */
|
/* Terminate buffer at 6 or 9 codes depending on the version */
|
||||||
|
|
||||||
|
@ -687,7 +687,8 @@ void write_char( int c )
|
||||||
|
|
||||||
void z_set_text_style( zword_t mode )
|
void z_set_text_style( zword_t mode )
|
||||||
{
|
{
|
||||||
if ( mode >= MIN_ATTRIBUTE && mode <= MAX_ATTRIBUTE )
|
//if ( mode >= MIN_ATTRIBUTE && mode <= MAX_ATTRIBUTE )
|
||||||
|
if (mode <= MAX_ATTRIBUTE )
|
||||||
{
|
{
|
||||||
set_attribute( mode );
|
set_attribute( mode );
|
||||||
}
|
}
|
||||||
|
|
16
ztypes.h
16
ztypes.h
|
@ -34,8 +34,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(__ZTYPES_INCLUDED)
|
#if !defined(ZTYPES_INCLUDED)
|
||||||
#define __ZTYPES_INCLUDED
|
#define ZTYPES_INCLUDED
|
||||||
|
|
||||||
// IIgs stuff - everyone gets it
|
// IIgs stuff - everyone gets it
|
||||||
#include "joey.h"
|
#include "joey.h"
|
||||||
|
@ -74,8 +74,11 @@
|
||||||
#endif /* MSDOS */
|
#endif /* MSDOS */
|
||||||
|
|
||||||
/* Set Version of JZIP */
|
/* Set Version of JZIP */
|
||||||
|
#define JZIPVER "Jzip V2.1"
|
||||||
|
#define JZIPRELDATE "Tue, Oct 10 2000"
|
||||||
|
#define JZIPAUTHOR "John Holder (j-holder@home.com)"
|
||||||
|
#define JZIPURL "http://jzip.sourceforge.net/"
|
||||||
|
|
||||||
#include "jzip.h"
|
|
||||||
extern unsigned char JTERP;
|
extern unsigned char JTERP;
|
||||||
|
|
||||||
/* Configuration options */
|
/* Configuration options */
|
||||||
|
@ -456,6 +459,11 @@ zobjectv4_t;
|
||||||
|
|
||||||
/* External data */
|
/* External data */
|
||||||
|
|
||||||
|
extern char save_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
||||||
|
extern char script_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
||||||
|
extern char record_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
||||||
|
extern char auxilary_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1];
|
||||||
|
|
||||||
extern int GLOBALVER;
|
extern int GLOBALVER;
|
||||||
extern zbyte_t h_type;
|
extern zbyte_t h_type;
|
||||||
extern zbyte_t h_config;
|
extern zbyte_t h_config;
|
||||||
|
@ -796,4 +804,4 @@ void z_load( zword_t );
|
||||||
void z_pull( zword_t );
|
void z_pull( zword_t );
|
||||||
void z_push( zword_t );
|
void z_push( zword_t );
|
||||||
|
|
||||||
#endif /* !defined(__ZTYPES_INCLUDED) */
|
#endif /* !defined(ZTYPES_INCLUDED) */
|
||||||
|
|
Loading…
Add table
Reference in a new issue