uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 7f3b8b3dea60959e31b5bb0bf609557ee05f70d0
parent 3d2f764914916c4b132c3a3c63302013b749aa25
Author: neauoire <aliceffekt@gmail.com>
Date:   Fri, 19 Feb 2021 11:48:40 -0800

Implemented color palette in memory

Diffstat:
MREADME.md | 1-
Memulator.c | 16++++++++++++++++
Mexamples/blank.usm | 1+
Mexamples/controller.usm | 1+
Mexamples/drag.usm | 1+
Mexamples/draw.usm | 1+
Mexamples/hello.usm | 1+
Mexamples/line.usm | 1+
Mexamples/mouse.usm | 1+
Mexamples/paint.usm | 14++++++++------
Mexamples/pixels.usm | 1+
Mexamples/screen.usm | 1+
Mexamples/sprite.usm | 1+
Mexamples/test.usm | 1+
14 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md @@ -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 diff --git a/emulator.c b/emulator.c @@ -173,6 +173,20 @@ error(char *msg, const char *err) } 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) { Uint8 i; @@ -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) { diff --git a/examples/blank.usm b/examples/blank.usm @@ -7,4 +7,5 @@ |c000 @FRAME BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/controller.usm b/examples/controller.usm @@ -61,4 +61,5 @@ BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/drag.usm b/examples/drag.usm @@ -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 diff --git a/examples/draw.usm b/examples/draw.usm @@ -92,4 +92,5 @@ RTS |c000 @FRAME BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/hello.usm b/examples/hello.usm @@ -94,4 +94,5 @@ BRK |c000 @FRAME |d000 @ERROR +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR \ No newline at end of file diff --git a/examples/line.usm b/examples/line.usm @@ -77,4 +77,5 @@ RTS |c000 @FRAME BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/mouse.usm b/examples/mouse.usm @@ -37,4 +37,5 @@ BRK RTS |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/paint.usm b/examples/paint.usm @@ -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 diff --git a/examples/pixels.usm b/examples/pixels.usm @@ -39,4 +39,5 @@ BRK RTS |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/screen.usm b/examples/screen.usm @@ -32,4 +32,5 @@ BRK RTS |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/sprite.usm b/examples/sprite.usm @@ -31,4 +31,5 @@ BRK |c000 @FRAME BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR diff --git a/examples/test.usm b/examples/test.usm @@ -55,4 +55,5 @@ BRK |d000 @ERROR BRK +|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |FFFA .RESET .FRAME .ERROR