small story edits, first stab at tile/sprite editor "jiles"

This commit is contained in:
Jeremy Penner 2019-07-19 22:29:32 -04:00
parent d4dca89ef9
commit 0fef456dff
12 changed files with 98 additions and 14 deletions

BIN
game.exe

Binary file not shown.

View file

@ -33,6 +33,7 @@ var player.prevdir
2 const DRIVING
4 const NOCLIP
8 const ISMARY
16 const ISJEANNE
: player.driving? player.state DRIVING f@ ;
@ -45,7 +46,10 @@ var player.prevdir
: {player}
player.driving? if {car-drive}
else player.state ISMARY f@ if {pmary} else {ppete} then
else
player.state ISMARY f@ if {pmary}
else player.state ISJEANNE f@ if {pjeanne}
else {ppete} then then
then ;
: player.canmove? ( x y -- )
@ -170,7 +174,7 @@ var glitchlevel
MODE-MOVE @ ' tick redefine
' full-draw ' draw redefine
:| player yield
ISMARY player.state f@ if p_jeanne yield then
player.state ISMARY f@ if p_jeanne yield then
CHUCK-FOLLOW flag@ if p_chuck yield then
done |; ' party redefine

BIN
game.prj

Binary file not shown.

BIN
goth.chr

Binary file not shown.

29
jiles.jor Executable file
View file

@ -0,0 +1,29 @@
: blah ' seremit task-emit ! ;
blah
s" game.log" open seekend fdeactivate const LOGFILE
: emit-log ' fputc LOGFILE withfp ;
: atexit LOGFILE factivate close ;
: start-repl activate blah ' emit-log task-echo !
s" .:: J O R T H ( jean forth) ::." type cr
begin receive loadstring s" ok" type cr again ;
task const REPL
REPL start-repl
intern input.jor
input.jor loadfile
: worldpos>tilepos 4 >> swap 4 >> swap ;
: tilepos>mapindex mapsize drop * + ;
: tick
MOUSEL clicked if
0xf5 mousepos worldpos>tilepos tilepos>mapindex map + b!
then
tick-debounce
;
: draw
0 0 scroll
mousepos 4 draw-sprite
draw-screen ;

BIN
litt.chr

Binary file not shown.

View file

@ -1,16 +1,18 @@
( T R A I L 1 )
39 71 N ' {car} defentity car
( 39 71 N ' {car} defentity car
car :touch
move-player 1 player.state DRIVING f!
;entity
)
:noname
0 player.state DRIVING f!
:| player.driving? not if car yield then
( :| player.driving? not if car yield then
done |; ' entities redefine
)
:|
touch-begin S leaving? dup
@ -26,4 +28,6 @@ touch-next 3 56 2= dup
touch-last |; ' player-touch redefine
s" trail1.map" load-map
1 player.state ISMARY f!
; ' onload redefine

BIN
sans.chr

Binary file not shown.

View file

@ -263,7 +263,7 @@ void f_glitch() {
}
}
void game_f_init(char *exe) {
void game_f_init(char *exe, char *bootjor) {
f_init(exe);
CDEF("seremit", f_seremit);
CDEF("key-pressed", f_keyWasPressed);
@ -288,7 +288,7 @@ void game_f_init(char *exe) {
CDEF("glitch", f_glitch);
CDEF("unfuck", tile_init);
f_loadjor("gameboot.jor");
f_loadjor(bootjor);
f_atexit = f_lookupcp("atexit");
atexit(f_cleanup);
@ -329,13 +329,13 @@ void do_repl(char *exe) {
int main(int argc, char *argv[]) {
cell tick, draw;
char *bootjor = "gameboot.jor";
if (argc > 1) {
do_repl(argv[0]);
return 0;
bootjor = argv[1];
}
ser_init(SER_COM2, BAUD_19200, SER_8N1);
game_init();
game_f_init(argv[0]);
game_f_init(argv[0], bootjor);
tick = f_lookupcp("tick");
draw = f_lookupcp("draw");

55
tiles.c
View file

@ -32,6 +32,16 @@ void blitTile(unsigned int offsetFrom, unsigned int offsetTo) {
}
}
void blitSolidBlock(unsigned int offsetTo, unsigned char color) {
int y;
setPlaneColor(color);
for (y = 0; y < 16; y ++) {
VID[offsetTo] = 0xff;
VID[offsetTo + 1] = 0xff;
offsetTo += PAGE_STRIDE;
}
}
void blit32x32(unsigned int offsetFrom, unsigned int offsetTo) {
int y;
for (y = 0; y < 32; y ++) {
@ -74,8 +84,27 @@ int prepareBuffer(int pageX, int pageY) {
unsigned char ibuffer = screen.nextBuffer;
screen.nextBuffer = nextBufferIndex(ibuffer);
*dirty = ibuffer;
for (i = 0; i < BUF_WSIZE; i ++) {
screen.buffer[ibuffer][i] = (&screen.memTiles[tile * BUF_WSIZE])[i];
if ((tile & 0xf0) == 0xf0) {
unsigned int val = (tile & 0x01) ? 0xffff : 0x0000;
for (i = 0; i < 16; i ++) {
screen.buffer[ibuffer][i] = val;
}
val = (tile & 0x02) ? 0xffff : 0x0000;
for (i = 16; i < 32; i ++) {
screen.buffer[ibuffer][i] = val;
}
val = (tile & 0x04) ? 0xffff : 0x0000;
for (i = 32; i < 48; i ++) {
screen.buffer[ibuffer][i] = val;
}
val = (tile & 0x08) ? 0xffff : 0x0000;
for (i = 48; i < 64; i ++) {
screen.buffer[ibuffer][i] = val;
}
} else {
for (i = 0; i < BUF_WSIZE; i ++) {
screen.buffer[ibuffer][i] = (&screen.memTiles[tile * BUF_WSIZE])[i];
}
}
screen.bufferOffset[ibuffer] = screen.pageOffset[screen.currentPage]
+ (pageX << 1) + (pageY * PAGE_STRIDE * 16);
@ -183,9 +212,10 @@ void drawScreen() {
for (y = startY; y < startY + PAGE_TILES_H; y ++) {
for (x = startX; x < startX + PAGE_TILES_W; x ++) {
if (dirty[di++] == D_BGTILE) {
blitTile(
screen.tilesOffset + (screen.map[x + (y * screen.w)] << 5),
drawOffset);
char tile = screen.map[x + (y * screen.w)];
if ((tile & 0xf0) != 0xf0) {
blitTile(screen.tilesOffset + (tile << 5), drawOffset);
}
}
drawOffset += 2;
}
@ -204,6 +234,21 @@ void drawScreen() {
}
}
setAllPlanes();
di = 0;
drawOffset = screen.pageOffset[screen.currentPage];
for (y = startY; y < startY + PAGE_TILES_H; y ++) {
for (x = startX; x < startX + PAGE_TILES_W; x ++) {
if (dirty[di++] == D_BGTILE) {
char tile = screen.map[x + (y * screen.w)];
if ((tile & 0xf0) == 0xf0) {
blitSolidBlock(drawOffset, tile & 0x0f);
}
}
drawOffset += 2;
}
drawOffset += PAGE_STRIDE * 15;
}
setDisplayOffset(scrollOffset);
setHorizontalPan(screen.scrollX & 0x07);

View file

@ -43,8 +43,10 @@ CHUCK-GONE flag@ if
then
touch-next 3 56 2= dup
if
1 glitchlevel !
pete say" This is where I buried it."
say" All those years ago."
0 glitchlevel !
then
touch-last |; ' player-touch redefine

BIN
trip.chr

Binary file not shown.