fix graphical artifacts, add eyedropper

This commit is contained in:
Jeremy Penner 2019-07-25 22:32:31 -04:00
parent f7ec90f032
commit 0c1a4c0539
5 changed files with 59 additions and 15 deletions

BIN
game.exe

Binary file not shown.

BIN
game.prj

Binary file not shown.

View file

@ -22,13 +22,19 @@ var spriteindex
: refresh
spriteindex @ drawfatsprite ;
mousehide spriteindex @ drawfatsprite mouseshow ;
: mousepos>sprpos 3 >> swap 3 >> swap ;
: mousexys mousepos mousepos>sprpos spriteindex @ ;
: tick
MOUSEL clicked if
color @ mousepos mousepos>sprpos spriteindex @ putpixel
MOUSEL mousedown if
mousexys getpixel color @ != if
color @ mousexys putpixel
refresh
then
then
MOUSER clicked if
mousexys getpixel color !
then
tick-debounce
;

View file

@ -264,31 +264,53 @@ void f_glitch() {
}
/* JILES */
#define SCREEN_STRIDE 320
#define SCREEN_STRIDE 40
void f_mousehide() {
mouse_hide();
}
void f_mouseshow() {
setLogicalWidth(SCREEN_STRIDE >> 1);
mouse_show();
}
int getpixel(int x, int y, unsigned int far *spr) {
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;
return b | (g << 1) | (r << 2) | (i << 3);
}
void f_drawfatsprite() {
int isprite = TOP().i;
unsigned int dst = 0;
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
int x, y, faty;
int x, y, faty, resetEnabled;
DROP(1);
setWriteMode(0);
setAllPlanes();
setResetEnabled(0x0f);
resetEnabled = 1;
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 color = getpixel(x, y, spr);
int fill1 = color & 0x10 ? 0xff : 0x55;
int fill2 = fill1 == 0xff ? 0xff : 0xaa;
setPlaneColor(colour);
if (color >= 0x0f) {
if (resetEnabled) {
setResetEnabled(0);
resetEnabled = 0;
}
} else {
if (!resetEnabled) {
setResetEnabled(0x0f);
resetEnabled = 1;
}
setResetMask(color);
}
for ( faty = 0; faty < 8; faty ++) {
VID[dst + x + (SCREEN_STRIDE * faty)] = (faty % 2) ? fill1 : fill2;
}
@ -322,6 +344,16 @@ void f_putpixel() {
spr[y + 64] = (spr[y + 64] & ~(1 << shift)) | (v << shift);
}
void f_getpixel() {
int isprite = TOP().i;
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
int x = ST2().i;
int y = ST1().i;
DROP(2);
TOP().i = getpixel(x, y, spr);
}
/* INIT */
void game_f_init(char *exe, char *bootjor) {
f_init(exe);
@ -349,8 +381,10 @@ void game_f_init(char *exe, char *bootjor) {
CDEF("unfuck", tile_init);
CDEF("mouseshow", f_mouseshow);
CDEF("mousehide", f_mousehide);
CDEF("drawfatsprite", f_drawfatsprite);
CDEF("putpixel", f_putpixel);
CDEF("getpixel", f_getpixel);
f_loadjor(bootjor);

View file

@ -18,7 +18,11 @@
#define setPlaneColor(c) outport(REG_TS, 2 | (c << 8))
#define setAllPlanes() setPlaneColor(0x0f)
#define setWriteMode(m) outport(REG_GDC, 0x05 | m << 8)
#define setWriteMode(m) outport(REG_GDC, 0x05 | (m << 8))
#define setBitMask(m) outport(REG_GDC, 0x08 | (m << 8))
#define setResetEnabled(m) outport(REG_GDC, 0x01 | (m << 8))
#define setResetMask(m) outport(REG_GDC, m << 8)
#define VID ((volatile char far *)MK_FP(0xa000, 0))
#define WVID ((volatile int far *)MK_FP(0xa000, 0))