Jorth words for pausing the game & displaying text

This commit is contained in:
Jeremy Penner 2019-02-16 19:21:02 -05:00
parent 08e8926abb
commit ae1b5712ef
8 changed files with 60 additions and 27 deletions

Binary file not shown.

BIN
game.exe

Binary file not shown.

View file

@ -77,6 +77,37 @@ defentity player
: now! ( timer -- ) ticks swap ! ;
( F O O T E R )
var footer-y
0 footer-y !
: draw-footer footer-y @ split-screen ;
: text1 6 4 rot text ;
: text2 6 12 rot text ;
: clear s" " dup text1 text2 ;
var footer-timer
: move-footer-to ( ytarget -- )
footer-y @ swap ( from to -- )
footer-timer now!
begin
2dup 10 footer-timer lerp ( from to now -- )
dup footer-y !
over != ( from to -- )
while
suspend
repeat drop drop ;
: show-footer 24 move-footer-to ;
: hide-footer 0 move-footer-to ;
: say1 ( s -- ) clear text1 show-footer ^ENTER wait-key ;
: say2 ( s1 s2 -- ) clear text2 text1 show-footer ^ENTER wait-key ;
( T I C K )
: tick-player
0 ^LEFT key-down if 3 - W player entity.dir ! then
^RIGHT key-down if 3 + E player entity.dir ! then
@ -85,32 +116,30 @@ defentity player
^DOWN key-down if 3 + S player entity.dir ! then
player entity.y +! ;
var MODE-TRAVEL
var MODE-TEXT
var split-timer
var MODE-MOVE
var MODE-WAIT
: enter-mode-text
split-timer now!
MODE-TEXT @ ' tick redefine ;
( J O B )
: listen-for-jobs activate blah
begin receive
MODE-WAIT @ ' tick redefine
execute
hide-footer
MODE-MOVE @ ' tick redefine
again ;
: mode-travel
task const JOB
JOB listen-for-jobs
: hello-world s" Hello, world!" say1 s" How are you" s" today?" say2 ;
: mode-move
tick-player
^SPACE key-pressed if
enter-mode-text
' hello-world JOB send
then ;
' mode-travel MODE-TRAVEL !
: mode-text-hide
24 0 10 split-timer lerp dup split-screen
0 = if ' mode-travel ' tick redefine then ;
: mode-text-show
0 24 10 split-timer lerp split-screen
^SPACE key-pressed if
split-timer now!
' mode-text-hide ' tick redefine
then ;
' mode-text-show MODE-TEXT !
' mode-move MODE-MOVE !
' noop MODE-WAIT !
: draw-player
player entity.x @
@ -126,7 +155,8 @@ var split-timer
draw-player
50 50 0 draw-sprite
600 600 2 draw-sprite
draw-screen ;
draw-screen
draw-footer ;
MODE-TRAVEL @ ' tick redefine
MODE-MOVE @ ' tick redefine
' full-draw ' draw redefine

BIN
game.prj

Binary file not shown.

1
kbd.h
View file

@ -16,6 +16,7 @@ unsigned char kbd_wait();
#define keyIsDown(k) (keybuf[k] & KEY_SIGNAL)
#define keyWasPressed(k) ((keybuf[k] & 0x0f) == KEY_PRESSED)
#define consumeKey(k) (keybuf[k] = keyWasPressed(k) ? KEY_DOWN : keybuf[k])
#define keyWasReleased(k) ((keybuf[k] & 0x0f) == KEY_RELEASED)
#define K_ESC 1

View file

@ -115,7 +115,9 @@ void f_seremit() {
}
void f_keyWasPressed() {
TOP().i = keyWasPressed(TOP().i);
int k = TOP().i;
TOP().i = keyWasPressed(k);
consumeKey(k);
}
void f_keyIsDown() {
TOP().i = keyIsDown(TOP().i);
@ -136,7 +138,7 @@ void f_splitscreen() {
DROP(1);
}
void f_text() { // ( col y s -- )
void f_text() { // ( col line s -- )
text_draw(ST2().u + (ST1().u * PAGE_STRIDE), TOP().s);
DROP(3);
}

2
tiff.c
View file

@ -70,7 +70,7 @@ int tifLoadEGA(FILE *f, TifImageMeta_t meta, unsigned int vidOffset, int maxY, u
volatile unsigned char far *out = &VID[vidOffset];
unsigned char b, g, r, i;
if (meta.width > MAX_WIDTH || (meta.width % 16) != 0) {
if (meta.width > MAX_WIDTH || (meta.width % 8) != 0) {
return 0;
}
setWriteMode(0);

2
tiff.h
View file

@ -10,7 +10,7 @@ typedef struct {
unsigned long stripOffsets;
} TifImageMeta_t;
#define MAX_WIDTH 320
#define MAX_WIDTH 328
TifImageMeta_t tifLoadMeta(FILE *f);
int tifLoadEGA(FILE *f, TifImageMeta_t meta, unsigned int vidOffset, int maxY, unsigned int w);