Implemented color palette in memory

This commit is contained in:
neauoire 2021-02-19 11:48:40 -08:00
parent 3d2f764914
commit 7f3b8b3dea
14 changed files with 35 additions and 7 deletions

View File

@ -106,7 +106,6 @@ A device that works like a NES controller, each button is a bit from a single by
### Misc TODOs ### Misc TODOs
- Defining theme colors in memory
- Includes - Includes
- Defines - Defines
- Lint, print unused labels - Lint, print unused labels

View File

@ -172,6 +172,20 @@ error(char *msg, const char *err)
return 0; 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 void
drawdebugger(Uint32 *dst, Uxn *u) drawdebugger(Uint32 *dst, Uxn *u)
{ {
@ -307,6 +321,7 @@ screenr(Device *d, Memory *m, Uint8 b)
case 2: return (HEIGHT >> 8) & 0xff; case 2: return (HEIGHT >> 8) & 0xff;
case 3: return HEIGHT & 0xff; case 3: return HEIGHT & 0xff;
} }
loadtheme(m->dat + 0xfff0);
(void)m; (void)m;
return d->mem[b]; return d->mem[b];
} }
@ -355,6 +370,7 @@ start(Uxn *u)
{ {
int ticknext = 0; int ticknext = 0;
evaluxn(u, u->vreset); evaluxn(u, u->vreset);
loadtheme(u->ram.dat + 0xfff0);
if(screen.reqdraw) if(screen.reqdraw)
redraw(pixels, u); redraw(pixels, u);
while(1) { while(1) {

View File

@ -7,4 +7,5 @@
|c000 @FRAME BRK |c000 @FRAME BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -61,4 +61,5 @@ BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -114,4 +114,5 @@ BRK
@eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ] @eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ]
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -92,4 +92,5 @@ RTS
|c000 @FRAME BRK |c000 @FRAME BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -94,4 +94,5 @@ BRK
|c000 @FRAME |c000 @FRAME
|d000 @ERROR |d000 @ERROR
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -77,4 +77,5 @@ RTS
|c000 @FRAME BRK |c000 @FRAME BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -37,4 +37,5 @@ BRK
RTS RTS
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -3,22 +3,23 @@
:dev/r fff8 ( std read port ) :dev/r fff8 ( std read port )
:dev/w fff9 ( std write 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 |0100 @RESET
#05 =dev/r ( set dev/read mouse ) #05 =dev/r ( set dev/read mouse )
#02 =dev/w ( set dev/write to sprite ) #02 =dev/w ( set dev/write to sprite )
#05 =color #05 =color ( select a default color )
,brush_large ,brush STR2 ( select a default brush )
,draw-interface JSR ,draw-interface JSR
,brush_large ,brush STR2
BRK BRK
|c000 @FRAME |c000 @FRAME
#02 =dev/w ( set dev/write to sprite )
( clear last cursor ) ( clear last cursor )
#10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR #10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR
( record mouse values ) ( record mouse values )
@ -58,7 +59,7 @@ BRK
~color ~brush ~mousex #0004 SUB2 ~mousey #0004 SUB2 ,draw-sprite JSR ~color ~brush ~mousex #0004 SUB2 ~mousey #0004 SUB2 ,draw-sprite JSR
@end-touch @end-touch
~mousex =lastx ~mousey =lasty ~mousex =lastx ~mousey =lasty ( update last post )
BRK BRK
@ -90,4 +91,5 @@ BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2af 35bb 2b5f ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -39,4 +39,5 @@ BRK
RTS RTS
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -32,4 +32,5 @@ BRK
RTS RTS
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -31,4 +31,5 @@ BRK
|c000 @FRAME BRK |c000 @FRAME BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR

View File

@ -55,4 +55,5 @@ BRK
|d000 @ERROR BRK |d000 @ERROR BRK
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR |FFFA .RESET .FRAME .ERROR