From cfd2764992ff3281b5b050f6d7b33012e0d05940 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 28 Feb 2021 11:41:28 -0800 Subject: [PATCH] Fixed issue in system device offset was wrong --- emulator.c | 5 +++-- examples/blank.usm | 4 ++-- examples/dev.console.usm | 2 +- examples/dev.ctrl.usm | 2 +- examples/dev.key.usm | 2 +- examples/dev.mouse.usm | 2 +- examples/dev.screen.usm | 21 ++++++++++++++++++++- examples/gui.picture.usm | 2 +- uxn.h | 2 +- 9 files changed, 31 insertions(+), 11 deletions(-) diff --git a/emulator.c b/emulator.c index 749a9eb..74cd912 100644 --- a/emulator.c +++ b/emulator.c @@ -181,6 +181,7 @@ loadtheme(Uint8 *addr) theme[2] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); r = *(addr + 1) & 0xf, g = *(addr + 3) & 0xf, b = *(addr + 5) & 0xf; theme[3] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); + screen.reqdraw = 1; } void @@ -371,7 +372,7 @@ sprite_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) Uint8 system_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) { - printf("system_poke\n"); + loadtheme(&m[0xfff8]); return b1; } @@ -442,7 +443,7 @@ main(int argc, char **argv) devkey = portuxn(&u, "key", ppnil, ppnil); devmouse = portuxn(&u, "mouse", ppnil, ppnil); - u.devices = 7; + u.devices = 15; /* pad to last device */ devsystem = portuxn(&u, "system", ppnil, system_poke); /* Write screen size to dev/screen */ diff --git a/examples/blank.usm b/examples/blank.usm index 56fbba1..ff75e50 100644 --- a/examples/blank.usm +++ b/examples/blank.usm @@ -21,5 +21,5 @@ |FF30 ;dev/ctrl Controller |FF50 ;dev/mouse Mouse -|FFF0 [ f2ac 35bb 2b53 ] ( palette ) -|FFFA .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) +|FFF8 [ f2ac 35bb 2b53 ] ( palette ) diff --git a/examples/dev.console.usm b/examples/dev.console.usm index 819b62d..50c8b57 100644 --- a/examples/dev.console.usm +++ b/examples/dev.console.usm @@ -25,5 +25,5 @@ RTS |FF00 ;dev/console Console -|FFF0 .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF8 [ f3f0 f30b f30a ] ( palette ) \ No newline at end of file diff --git a/examples/dev.ctrl.usm b/examples/dev.ctrl.usm index 4fb86f0..ec3dd30 100644 --- a/examples/dev.ctrl.usm +++ b/examples/dev.ctrl.usm @@ -75,5 +75,5 @@ RTS |FF20 ;dev/sprite Sprite |FF30 ;dev/ctrl Controller -|FFF0 .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF8 [ 0daf 02ff 035f ] ( palette ) diff --git a/examples/dev.key.usm b/examples/dev.key.usm index d055f1c..dfbbbe6 100644 --- a/examples/dev.key.usm +++ b/examples/dev.key.usm @@ -130,5 +130,5 @@ RTS |FF20 ;dev/sprite Sprite |FF40 ;dev/key Keyboard -|FFF0 .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF8 [ f0ff f00f f00f ] ( palette ) diff --git a/examples/dev.mouse.usm b/examples/dev.mouse.usm index 4b3e181..2a9bcd4 100644 --- a/examples/dev.mouse.usm +++ b/examples/dev.mouse.usm @@ -231,5 +231,5 @@ RTS |FF20 ;dev/sprite Sprite |FF50 ;dev/mouse Mouse -|FFF0 .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF8 [ 0f85 0fd5 0fb5 ] ( palette ) diff --git a/examples/dev.screen.usm b/examples/dev.screen.usm index 97579ff..44cea35 100644 --- a/examples/dev.screen.usm +++ b/examples/dev.screen.usm @@ -3,6 +3,7 @@ &Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } &Sprite { pad 8 x 2 y 2 addr 2 color 1 } +;timer 1 ;centerx 2 ;centery 2 ;i 2 ;j 1 |0100 @RESET @@ -47,7 +48,25 @@ BRK @icon [ 3c7e e7c3 c3e7 7e3c ] -|c000 @FRAME BRK +|c000 @FRAME + + ( update colors every 40 frames ) + ~timer #40 NEQ ,skip1 ROT JMP? POP2 + #0fac =fffa #f0bb =fffc #f053 =fff8 + @skip1 + ~timer #80 NEQ ,skip2 ROT JMP? POP2 + #00fc =fffc #f0bb =fff8 #f053 =fffa + @skip2 + ~timer #c0 NEQ ,skip3 ROT JMP? POP2 + #000f =fff8 #0f0f =fffa #ff00 =fffc + @skip3 + ~timer #00 NEQ ,skip4 ROT JMP? POP2 + #f0ac =fff8 #f0bb =fffa #f053 =fffc + @skip4 + ~timer #01 ADD =timer + +BRK + |d000 @ERROR BRK |FF10 ;dev/screen Screen diff --git a/examples/gui.picture.usm b/examples/gui.picture.usm index f98600f..98455cb 100644 --- a/examples/gui.picture.usm +++ b/examples/gui.picture.usm @@ -312,5 +312,5 @@ RTS |FF10 ;dev/screen Screen |FF20 ;dev/sprite Sprite -|FFF0 .RESET .FRAME .ERROR +|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF8 [ 0ffc 0f0b 0f03 ] ( palette ) diff --git a/uxn.h b/uxn.h index ea42a7f..c4f9e94 100644 --- a/uxn.h +++ b/uxn.h @@ -42,7 +42,7 @@ typedef struct { Uint16 counter, vreset, vframe, verror; Stack wst, rst; Memory ram; - Device dev[8]; + Device dev[16]; } Uxn; void setflag(Uint8 *status, char flag, int b);