Fixed issue in system device offset was wrong

This commit is contained in:
neauoire 2021-02-28 11:41:28 -08:00
parent 2ea562948d
commit cfd2764992
9 changed files with 31 additions and 11 deletions

View File

@ -181,6 +181,7 @@ loadtheme(Uint8 *addr)
theme[2] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); 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; 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)); theme[3] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4));
screen.reqdraw = 1;
} }
void void
@ -371,7 +372,7 @@ sprite_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
Uint8 Uint8
system_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) system_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
{ {
printf("system_poke\n"); loadtheme(&m[0xfff8]);
return b1; return b1;
} }
@ -442,7 +443,7 @@ main(int argc, char **argv)
devkey = portuxn(&u, "key", ppnil, ppnil); devkey = portuxn(&u, "key", ppnil, ppnil);
devmouse = portuxn(&u, "mouse", 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); devsystem = portuxn(&u, "system", ppnil, system_poke);
/* Write screen size to dev/screen */ /* Write screen size to dev/screen */

View File

@ -21,5 +21,5 @@
|FF30 ;dev/ctrl Controller |FF30 ;dev/ctrl Controller
|FF50 ;dev/mouse Mouse |FF50 ;dev/mouse Mouse
|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFFA .RESET .FRAME .ERROR |FFF8 [ f2ac 35bb 2b53 ] ( palette )

View File

@ -25,5 +25,5 @@ RTS
|FF00 ;dev/console Console |FF00 ;dev/console Console
|FFF0 .RESET .FRAME .ERROR |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ f3f0 f30b f30a ] ( palette ) |FFF8 [ f3f0 f30b f30a ] ( palette )

View File

@ -75,5 +75,5 @@ RTS
|FF20 ;dev/sprite Sprite |FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller |FF30 ;dev/ctrl Controller
|FFF0 .RESET .FRAME .ERROR |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0daf 02ff 035f ] ( palette ) |FFF8 [ 0daf 02ff 035f ] ( palette )

View File

@ -130,5 +130,5 @@ RTS
|FF20 ;dev/sprite Sprite |FF20 ;dev/sprite Sprite
|FF40 ;dev/key Keyboard |FF40 ;dev/key Keyboard
|FFF0 .RESET .FRAME .ERROR |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ f0ff f00f f00f ] ( palette ) |FFF8 [ f0ff f00f f00f ] ( palette )

View File

@ -231,5 +231,5 @@ RTS
|FF20 ;dev/sprite Sprite |FF20 ;dev/sprite Sprite
|FF50 ;dev/mouse Mouse |FF50 ;dev/mouse Mouse
|FFF0 .RESET .FRAME .ERROR |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0f85 0fd5 0fb5 ] ( palette ) |FFF8 [ 0f85 0fd5 0fb5 ] ( palette )

View File

@ -3,6 +3,7 @@
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } &Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
&Sprite { pad 8 x 2 y 2 addr 2 color 1 } &Sprite { pad 8 x 2 y 2 addr 2 color 1 }
;timer 1
;centerx 2 ;centery 2 ;i 2 ;j 1 ;centerx 2 ;centery 2 ;i 2 ;j 1
|0100 @RESET |0100 @RESET
@ -47,7 +48,25 @@ BRK
@icon [ 3c7e e7c3 c3e7 7e3c ] @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 |d000 @ERROR BRK
|FF10 ;dev/screen Screen |FF10 ;dev/screen Screen

View File

@ -312,5 +312,5 @@ RTS
|FF10 ;dev/screen Screen |FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite |FF20 ;dev/sprite Sprite
|FFF0 .RESET .FRAME .ERROR |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0ffc 0f0b 0f03 ] ( palette ) |FFF8 [ 0ffc 0f0b 0f03 ] ( palette )

2
uxn.h
View File

@ -42,7 +42,7 @@ typedef struct {
Uint16 counter, vreset, vframe, verror; Uint16 counter, vreset, vframe, verror;
Stack wst, rst; Stack wst, rst;
Memory ram; Memory ram;
Device dev[8]; Device dev[16];
} Uxn; } Uxn;
void setflag(Uint8 *status, char flag, int b); void setflag(Uint8 *status, char flag, int b);