Implemented color palette in memory
This commit is contained in:
parent
3d2f764914
commit
7f3b8b3dea
|
@ -106,7 +106,6 @@ A device that works like a NES controller, each button is a bit from a single by
|
|||
|
||||
### Misc TODOs
|
||||
|
||||
- Defining theme colors in memory
|
||||
- Includes
|
||||
- Defines
|
||||
- Lint, print unused labels
|
||||
|
|
16
emulator.c
16
emulator.c
|
@ -172,6 +172,20 @@ error(char *msg, const char *err)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
loadtheme(Uint8 *addr)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
r = *(addr + 0) >> 4 & 0xf, g = *(addr + 2) >> 4 & 0xf, b = *(addr + 4) >> 4 & 0xf;
|
||||
theme[0] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4));
|
||||
r = *(addr + 0) & 0xf, g = *(addr + 2) & 0xf, b = *(addr + 4) & 0xf;
|
||||
theme[1] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4));
|
||||
r = *(addr + 1) >> 4 & 0xf, g = *(addr + 3) >> 4 & 0xf, b = *(addr + 5) >> 4 & 0xf;
|
||||
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));
|
||||
}
|
||||
|
||||
void
|
||||
drawdebugger(Uint32 *dst, Uxn *u)
|
||||
{
|
||||
|
@ -307,6 +321,7 @@ screenr(Device *d, Memory *m, Uint8 b)
|
|||
case 2: return (HEIGHT >> 8) & 0xff;
|
||||
case 3: return HEIGHT & 0xff;
|
||||
}
|
||||
loadtheme(m->dat + 0xfff0);
|
||||
(void)m;
|
||||
return d->mem[b];
|
||||
}
|
||||
|
@ -355,6 +370,7 @@ start(Uxn *u)
|
|||
{
|
||||
int ticknext = 0;
|
||||
evaluxn(u, u->vreset);
|
||||
loadtheme(u->ram.dat + 0xfff0);
|
||||
if(screen.reqdraw)
|
||||
redraw(pixels, u);
|
||||
while(1) {
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -61,4 +61,5 @@ BRK
|
|||
|
||||
|d000 @ERROR BRK
|
||||
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -114,4 +114,5 @@ BRK
|
|||
@eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ]
|
||||
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -92,4 +92,5 @@ RTS
|
|||
|
||||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -94,4 +94,5 @@ BRK
|
|||
|c000 @FRAME
|
||||
|d000 @ERROR
|
||||
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
|
@ -77,4 +77,5 @@ RTS
|
|||
|
||||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -37,4 +37,5 @@ BRK
|
|||
RTS
|
||||
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -3,22 +3,23 @@
|
|||
:dev/r fff8 ( std read port )
|
||||
:dev/w fff9 ( std write port )
|
||||
|
||||
;mousex 2 ;mousey 2 ;lastx 2 ;lasty 2 ;color 1 ;mode 1 ;state 1 ;brush 2
|
||||
;mousex 2 ;mousey 2 ;lastx 2 ;lasty 2
|
||||
;state 1 ;color 1 ;brush 2
|
||||
|
||||
|0100 @RESET
|
||||
|
||||
#05 =dev/r ( set dev/read mouse )
|
||||
#02 =dev/w ( set dev/write to sprite )
|
||||
|
||||
#05 =color
|
||||
,draw-interface JSR
|
||||
,brush_large ,brush STR2
|
||||
#05 =color ( select a default color )
|
||||
,brush_large ,brush STR2 ( select a default brush )
|
||||
|
||||
,draw-interface JSR
|
||||
|
||||
BRK
|
||||
|
||||
|c000 @FRAME
|
||||
|
||||
#02 =dev/w ( set dev/write to sprite )
|
||||
( clear last cursor )
|
||||
#10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR
|
||||
( record mouse values )
|
||||
|
@ -58,7 +59,7 @@ BRK
|
|||
~color ~brush ~mousex #0004 SUB2 ~mousey #0004 SUB2 ,draw-sprite JSR
|
||||
@end-touch
|
||||
|
||||
~mousex =lastx ~mousey =lasty
|
||||
~mousex =lastx ~mousey =lasty ( update last post )
|
||||
|
||||
BRK
|
||||
|
||||
|
@ -90,4 +91,5 @@ BRK
|
|||
|
||||
|d000 @ERROR BRK
|
||||
|
||||
|FFF0 [ f2af 35bb 2b5f ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -39,4 +39,5 @@ BRK
|
|||
RTS
|
||||
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -32,4 +32,5 @@ BRK
|
|||
RTS
|
||||
|
||||
|d000 @ERROR BRK
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -31,4 +31,5 @@ BRK
|
|||
|c000 @FRAME BRK
|
||||
|d000 @ERROR BRK
|
||||
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
|
@ -55,4 +55,5 @@ BRK
|
|||
|
||||
|d000 @ERROR BRK
|
||||
|
||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
Loading…
Reference in New Issue