Bigger footer, portrait support, coloured text
This commit is contained in:
parent
20e7089b84
commit
114d1ff804
16
defs.jor
16
defs.jor
|
@ -10,15 +10,23 @@ s" jorth.log" open seekend deactivate const LOGFILE
|
|||
|
||||
: noop ;
|
||||
|
||||
' cells @ const docolon ( get the colon execution token )
|
||||
: :noname here docolon , ] ;
|
||||
' cells @ const $DOCOLON ( get the colon execution token )
|
||||
: :noname here $DOCOLON , ] ;
|
||||
|
||||
: :| inline| :noname ; immediate
|
||||
: :| inline| $DOCOLON , ; immediate
|
||||
: |; ' ret , |inline ; immediate
|
||||
|
||||
: defer word new-word docolon , ' noop , ' ret , ;
|
||||
: defer word new-word $DOCOLON , ' noop , ' ret , ;
|
||||
: redefine ( cp cpdeferred ) cell + ! ;
|
||||
|
||||
: create word new-word $DOCREATE , 0 , ;
|
||||
|
||||
: finishcreate ( ipfirst -- )
|
||||
( set cell after codepointer to first instruction of does> )
|
||||
latest codepointer cell + ! ;
|
||||
|
||||
: does> here 4 cells + lit ' finishcreate , ' ret , ] ; immediate
|
||||
|
||||
: +towards ( from to -- from+-1 )
|
||||
over > if 1 + else 1 - then ;
|
||||
|
||||
|
|
15
egamap.h
Executable file
15
egamap.h
Executable file
|
@ -0,0 +1,15 @@
|
|||
#include "tiles.h"
|
||||
|
||||
#define NUM_TILES 128
|
||||
#define NUM_PORTRAITS 16
|
||||
|
||||
#define SIZE_FOOTER (PAGE_STRIDE * 48)
|
||||
#define SIZE_PAGE (PAGE_STRIDE * (PAGE_TILES_H << 4))
|
||||
#define SIZE_TILES (NUM_TILES << 5)
|
||||
#define SIZE_PORTRAITS (NUM_PORTRAITS << 7)
|
||||
|
||||
#define OFF_FOOTER 0
|
||||
#define OFF_PAGE1 (OFF_FOOTER + SIZE_FOOTER)
|
||||
#define OFF_PAGE2 (OFF_PAGE1 + SIZE_PAGE)
|
||||
#define OFF_TILES (OFF_PAGE2 + SIZE_PAGE)
|
||||
#define OFF_PORTRAITS (OFF_TILES + SIZE_TILES)
|
BIN
footer.tif
BIN
footer.tif
Binary file not shown.
51
game.jor
51
game.jor
|
@ -90,9 +90,35 @@ var footer-y
|
|||
|
||||
: draw-footer footer-y @ split-screen ;
|
||||
|
||||
: text1 6 4 <rot text ;
|
||||
: text2 6 12 <rot text ;
|
||||
: clear s" " dup text1 text2 ;
|
||||
0 const BLACK
|
||||
1 const BLUE
|
||||
2 const GREEN
|
||||
3 const CYAN
|
||||
4 const RED
|
||||
5 const MAGENTA
|
||||
6 const BROWN
|
||||
7 const LGRAY
|
||||
8 const DGRAY
|
||||
9 const LBLUE
|
||||
10 const LGREEN
|
||||
11 const LCYAN
|
||||
12 const PINK
|
||||
13 const LMAGENTA
|
||||
14 const YELLOW
|
||||
15 const WHITE
|
||||
|
||||
var text-color
|
||||
WHITE text-color !
|
||||
|
||||
: texty 7 swap <rot text-color @ text ;
|
||||
: text0 10 texty ;
|
||||
: text1 20 texty ;
|
||||
: text2 30 texty ;
|
||||
: clear
|
||||
text-color @
|
||||
WHITE text-color !
|
||||
s" " dup dup text0 text1 text2
|
||||
text-color ! ;
|
||||
|
||||
: move-to ( target speed p -- )
|
||||
dup r> @ >rot ticks ( from to duration start )
|
||||
|
@ -103,11 +129,20 @@ var footer-y
|
|||
>rot suspend
|
||||
repeat rdrop drop drop drop drop ;
|
||||
|
||||
: show-footer 24 10 footer-y move-to ;
|
||||
: show-footer 48 10 footer-y move-to ;
|
||||
: hide-footer 0 10 footer-y move-to ;
|
||||
|
||||
: say1 ( s -- ) clear text1 show-footer ^ENTER wait-key ;
|
||||
: say2 ( s1 s2 -- ) clear text2 text1 show-footer ^ENTER wait-key ;
|
||||
: footer-wait show-footer ^ENTER wait-key ;
|
||||
: say1 ( s -- ) clear text1 footer-wait ;
|
||||
: say2 ( s1 s2 -- ) clear text1 text0 footer-wait ;
|
||||
: say3 ( s1 s2 s3 -- ) clear text2 text1 text0 footer-wait ;
|
||||
|
||||
: character ( iportrait color ) create , ,
|
||||
does> dup @ text-color ! cell + @ draw-portrait ;
|
||||
|
||||
0 GREEN character pete
|
||||
1 MAGENTA character mary
|
||||
2 BROWN character chuck
|
||||
|
||||
( M O U S E )
|
||||
|
||||
|
@ -162,8 +197,8 @@ var tileselect
|
|||
factivate ;
|
||||
|
||||
: load-map ( filename -- )
|
||||
fdeactivate swap open tell .
|
||||
fget tell . fget tell . cr .s
|
||||
fdeactivate swap open
|
||||
fget fget
|
||||
2dup * map fread
|
||||
mapsize!
|
||||
factivate ;
|
||||
|
|
13
jorth.c
13
jorth.c
|
@ -324,7 +324,7 @@ void f_fgetc() {
|
|||
void f_fget() {
|
||||
if (ACTIVE_FILE) {
|
||||
int result = 0;
|
||||
int err = fread(&result, 2, 1, ACTIVE_FILE);
|
||||
fread(&result, 2, 1, ACTIVE_FILE);
|
||||
PUSHU(result);
|
||||
} else {
|
||||
PUSHU(0); // no way to signal EOF
|
||||
|
@ -413,9 +413,7 @@ void f_create() { // name --
|
|||
|
||||
void f_cdef() { // func name --
|
||||
f_create();
|
||||
HERE->p = TOP().p;
|
||||
HERE ++;
|
||||
DROP(1);
|
||||
f_comma();
|
||||
}
|
||||
|
||||
void f_docolon();
|
||||
|
@ -719,6 +717,12 @@ void f_var() {
|
|||
f_comma();
|
||||
}
|
||||
|
||||
void f_docreate() {
|
||||
PUSHCP(W.p + 2);
|
||||
RPUSH(IP);
|
||||
IP = *(W.p + 1);
|
||||
}
|
||||
|
||||
void f_bz_() {
|
||||
if (!TOP().u) {
|
||||
IP.p = IP.p->p; // branch
|
||||
|
@ -946,6 +950,7 @@ void f_init() {
|
|||
CDEF("stacksize", f_stacksize);
|
||||
CDEF("rstacksize", f_rstacksize);
|
||||
CDEF("task-user-size", f_taskusersize);
|
||||
PCONST("$DOCREATE", f_docreate);
|
||||
|
||||
PUSHS("boot.jor");
|
||||
f_open();
|
||||
|
|
5
jorth.h
5
jorth.h
|
@ -7,7 +7,6 @@
|
|||
void f_init();
|
||||
|
||||
void f_cdef();
|
||||
#define CDEF(name, def) PUSHP(def); PUSHS(name); f_cdef()
|
||||
void f_immediate();
|
||||
|
||||
void f_loadfile(char *filename);
|
||||
|
@ -64,5 +63,9 @@ void f_comma();
|
|||
void f_bcomma();
|
||||
void f_create(); // name --
|
||||
void f_cdef(); // func name --
|
||||
void f_doconst();
|
||||
void f_compileword();
|
||||
|
||||
#define CDEF(name, def) PUSHP(def); PUSHS(name); f_cdef()
|
||||
#define ICONST(name, v) CDEF(name, f_doconst); PUSHI(v); f_comma()
|
||||
#define PCONST(name, p) CDEF(name, f_doconst); PUSHP(p); f_comma()
|
||||
|
|
BIN
portrait.tif
Executable file
BIN
portrait.tif
Executable file
Binary file not shown.
26
testbed.c
26
testbed.c
|
@ -10,6 +10,7 @@
|
|||
#include "serial.h"
|
||||
#include "timer.h"
|
||||
#include "jorth.h"
|
||||
#include "egamap.h"
|
||||
|
||||
/*** T E X T ***/
|
||||
char far *font = NULL;
|
||||
|
@ -49,9 +50,7 @@ void text_draw(unsigned int vidOffset, unsigned char *s) {
|
|||
|
||||
/*** S C R A T C H ***/
|
||||
|
||||
#define NUM_TILES 128
|
||||
#define NUM_SPRITES 64
|
||||
#define OFF_TILES 0x5000
|
||||
#define TILE_STRIDE 64
|
||||
#define SPRITE_STRIDE 80
|
||||
unsigned int tiles[NUM_TILES * TILE_STRIDE];
|
||||
|
@ -88,7 +87,7 @@ void game_init() {
|
|||
|
||||
f = fopen("FOOTER.TIF", "rb");
|
||||
meta = tifLoadMeta(f);
|
||||
tifLoadEGA(f, meta, 0, 24, 336);
|
||||
tifLoadEGA(f, meta, 0, 48, 336);
|
||||
fclose(f);
|
||||
|
||||
f = fopen("TILES.TIF", "rb");
|
||||
|
@ -102,6 +101,11 @@ void game_init() {
|
|||
tifLoad(f, meta, sprites, NUM_SPRITES * 16, 16, 5);
|
||||
fclose(f);
|
||||
|
||||
f = fopen("PORTRAIT.TIF", "rb");
|
||||
meta = tifLoadMeta(f);
|
||||
tifLoadEGA(f, meta, OFF_PORTRAITS, NUM_PORTRAITS * 32, 32);
|
||||
fclose(f);
|
||||
|
||||
loadTiles(OFF_TILES, tiles);
|
||||
loadMap(map, 100, 100);
|
||||
scroll(0, 0);
|
||||
|
@ -144,7 +148,11 @@ void f_splitscreen() {
|
|||
DROP(1);
|
||||
}
|
||||
|
||||
void f_text() { // ( col line s -- )
|
||||
|
||||
void f_text() { // ( col line s color -- )
|
||||
setWriteMode(0);
|
||||
setPlaneColor(TOP().u);
|
||||
DROP(1);
|
||||
text_draw(ST2().u + (ST1().u * PAGE_STRIDE), TOP().s);
|
||||
DROP(3);
|
||||
}
|
||||
|
@ -171,12 +179,20 @@ void f_mousebuttons() {
|
|||
PUSHI(MOUSE.buttons);
|
||||
}
|
||||
|
||||
void f_drawportrait() {
|
||||
setAllPlanes();
|
||||
setWriteMode(1);
|
||||
blit32x32(OFF_PORTRAITS + (TOP().u << 7), (PAGE_STRIDE << 3) + 1);
|
||||
DROP(1);
|
||||
}
|
||||
|
||||
void game_f_init() {
|
||||
f_init();
|
||||
CDEF("seremit", f_seremit);
|
||||
CDEF("key-pressed", f_keyWasPressed);
|
||||
CDEF("key-down", f_keyIsDown);
|
||||
CDEF("draw-sprite", f_drawSprite);
|
||||
CDEF("draw-portrait", f_drawportrait);
|
||||
CDEF("scroll", f_scroll);
|
||||
CDEF("scrollpos", f_scrollpos);
|
||||
CDEF("draw-screen", drawScreen);
|
||||
|
@ -188,7 +204,7 @@ void game_f_init() {
|
|||
CDEF("mapsize!", f_mapsize_set);
|
||||
CDEF("mousepos", f_mousepos);
|
||||
CDEF("mousebuttons", f_mousebuttons);
|
||||
|
||||
CDEF("unfuck", tile_init);
|
||||
f_loadfile("game.jor");
|
||||
}
|
||||
|
||||
|
|
14
tiles.c
14
tiles.c
|
@ -3,6 +3,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "video.h"
|
||||
#include "tiles.h"
|
||||
#include "egamap.h"
|
||||
|
||||
/*** T I L E S ***/
|
||||
|
||||
|
@ -31,13 +32,24 @@ void blitTile(unsigned int offsetFrom, unsigned int offsetTo) {
|
|||
}
|
||||
}
|
||||
|
||||
void blit32x32(unsigned int offsetFrom, unsigned int offsetTo) {
|
||||
int y;
|
||||
for (y = 0; y < 32; y ++) {
|
||||
VID[offsetTo] = VID[offsetFrom ++];
|
||||
VID[offsetTo + 1] = VID[offsetFrom ++];
|
||||
VID[offsetTo + 2] = VID[offsetFrom ++];
|
||||
VID[offsetTo + 3] = VID[offsetFrom ++];
|
||||
offsetTo += PAGE_STRIDE;
|
||||
}
|
||||
}
|
||||
|
||||
#define D_NOTHING 0x80
|
||||
#define D_BGTILE 0x81
|
||||
#define isBufIndex(d) (!((d) & 0x80))
|
||||
|
||||
#define nextBufferIndex(i) ((i + 1) % NUM_BUFFERS)
|
||||
|
||||
TiledScreen_t screen = { 0, 0, 0, 0, { 0x0600, 0x2B00 }, 0, 0, NULL, NULL,
|
||||
TiledScreen_t screen = { 0, 0, 0, 0, { OFF_PAGE1, OFF_PAGE2 }, 0, 0, NULL, NULL,
|
||||
0, 0, 0, 0, 0 };
|
||||
|
||||
void loadTiles(unsigned int tilesOffset, unsigned int *memTiles) {
|
||||
|
|
8
tiles.h
8
tiles.h
|
@ -1,4 +1,6 @@
|
|||
/*** T I L E S ***/
|
||||
#ifndef __TILES_H__
|
||||
#define __TILES_H__
|
||||
|
||||
void tile_init();
|
||||
|
||||
|
@ -8,6 +10,8 @@ void drawSprite(unsigned int *sprite, int x, int y);
|
|||
void scroll(int newX, int newY);
|
||||
void drawScreen();
|
||||
|
||||
void blit32x32(unsigned int offsetFrom, unsigned int offsetTo);
|
||||
|
||||
#define PAGE_TILES_W 21
|
||||
#define PAGE_TILES_H 14
|
||||
#define PAGE_TILES_COUNT (PAGE_TILES_H * PAGE_TILES_W)
|
||||
|
@ -34,4 +38,6 @@ typedef struct {
|
|||
unsigned char firstBuffer;
|
||||
} TiledScreen_t;
|
||||
|
||||
extern TiledScreen_t screen;
|
||||
extern TiledScreen_t screen;
|
||||
|
||||
#endif
|
3
video.h
3
video.h
|
@ -15,7 +15,8 @@
|
|||
#define PLANE_R 0x02
|
||||
#define PLANE_I 0x03
|
||||
#define setPlane(p) outport(REG_TS, 2 | (0x100 << p))
|
||||
#define setAllPlanes() outport(REG_TS, 0x0f02)
|
||||
#define setPlaneColor(c) outport(REG_TS, 2 | (c << 8))
|
||||
#define setAllPlanes() setPlaneColor(0x0f)
|
||||
|
||||
#define setWriteMode(m) outport(REG_GDC, 0x05 | m << 8)
|
||||
|
||||
|
|
Loading…
Reference in a new issue