use streamline custom gfx engine for jiles

This commit is contained in:
Jeremy Penner 2019-07-23 22:39:56 -04:00
parent 0fef456dff
commit f7ec90f032
4 changed files with 81 additions and 7 deletions

BIN
game.exe

Binary file not shown.

BIN
game.prj

Binary file not shown.

View file

@ -14,16 +14,26 @@ REPL start-repl
intern input.jor intern input.jor
input.jor loadfile input.jor loadfile
: worldpos>tilepos 4 >> swap 4 >> swap ; var color
: tilepos>mapindex mapsize drop * + ; var spriteindex
8 spriteindex !
2 color !
: refresh
spriteindex @ drawfatsprite ;
: mousepos>sprpos 3 >> swap 3 >> swap ;
: tick : tick
MOUSEL clicked if MOUSEL clicked if
0xf5 mousepos worldpos>tilepos tilepos>mapindex map + b! color @ mousepos mousepos>sprpos spriteindex @ putpixel
then then
tick-debounce tick-debounce
; ;
: draw : draw ;
0 0 scroll
mousepos 4 draw-sprite mouseshow
draw-screen ; refresh

View file

@ -263,6 +263,66 @@ void f_glitch() {
} }
} }
/* JILES */
#define SCREEN_STRIDE 320
void f_mouseshow() {
setLogicalWidth(SCREEN_STRIDE >> 1);
mouse_show();
}
void f_drawfatsprite() {
int isprite = TOP().i;
unsigned int dst = 0;
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
int x, y, faty;
DROP(1);
setWriteMode(0);
for ( y = 0; y < 16; y ++ ) {
for ( x = 0; x < 16; x ++ ) {
int shift = (15 - x);
int b = (spr[y + 0] & (1 << shift)) >> shift;
int g = (spr[y + 16] & (1 << shift)) >> shift;
int r = (spr[y + 32] & (1 << shift)) >> shift;
int i = (spr[y + 48] & (1 << shift)) >> shift;
int colour = b | (g << 1) | (r << 2) | (i << 3);
int fill1 = (spr[y + 64] & (1 << shift)) ? 0xff : 0x55;
int fill2 = fill1 == 0xff ? 0xff : 0xaa;
setPlaneColor(colour);
for ( faty = 0; faty < 8; faty ++) {
VID[dst + x + (SCREEN_STRIDE * faty)] = (faty % 2) ? fill1 : fill2;
}
}
dst += (SCREEN_STRIDE * 8);
}
}
void f_putpixel() {
int isprite = TOP().i;
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
int x = ST2().i;
int y = ST1().i;
int color, shift, b, g, r, i, v;
DROP(3);
color = TOP().i;
DROP(1);
shift = (15 - x);
b = (color & 0x01);
g = (color & 0x02) >> 1;
r = (color & 0x04) >> 2;
i = (color & 0x08) >> 3;
v = ((color & 0x10) >> 4) ^ 1;
spr[y + 0] = (spr[y + 0] & ~(1 << shift)) | (b << shift);
spr[y + 16] = (spr[y + 16] & ~(1 << shift)) | (g << shift);
spr[y + 32] = (spr[y + 32] & ~(1 << shift)) | (r << shift);
spr[y + 48] = (spr[y + 48] & ~(1 << shift)) | (i << shift);
spr[y + 64] = (spr[y + 64] & ~(1 << shift)) | (v << shift);
}
/* INIT */
void game_f_init(char *exe, char *bootjor) { void game_f_init(char *exe, char *bootjor) {
f_init(exe); f_init(exe);
CDEF("seremit", f_seremit); CDEF("seremit", f_seremit);
@ -288,6 +348,10 @@ void game_f_init(char *exe, char *bootjor) {
CDEF("glitch", f_glitch); CDEF("glitch", f_glitch);
CDEF("unfuck", tile_init); CDEF("unfuck", tile_init);
CDEF("mouseshow", f_mouseshow);
CDEF("drawfatsprite", f_drawfatsprite);
CDEF("putpixel", f_putpixel);
f_loadjor(bootjor); f_loadjor(bootjor);
f_atexit = f_lookupcp("atexit"); f_atexit = f_lookupcp("atexit");