Fixed issue with emulator colors

This commit is contained in:
neauoire 2021-03-30 12:21:00 -07:00
parent 0b1d8efb86
commit d4783214a4
3 changed files with 98 additions and 53 deletions

View File

@ -21,12 +21,12 @@
@RESET @RESET
RTN BRK
@FRAME @FRAME
RTN BRK
@ERROR @ERROR
RTN BRK

View File

@ -45,9 +45,10 @@
;pt1 { x 2 y 2 } ;pt1 { x 2 y 2 }
;pt2 { x 2 y 2 } ( paint-rect ) ;pt2 { x 2 y 2 } ( paint-rect )
;px { x 1 y 1 } ;px { x 1 y 1 }
;document { state 1 edit 1 } ;document { state 1 edit 1 presentation 1 }
;path { length 1 name 20 } ;path { length 1 name 20 }
;timer { byte 1 } ;timer { byte 1 }
;theme { r0 2 g0 2 b0 2 r1 2 g1 2 b1 2 }
( devices ) ( devices )
@ -68,7 +69,10 @@
@RESET ( -- ) @RESET ( -- )
( theme ) ( theme )
#e0fd =System.r #30fd =System.g #30fd =System.b #e0cd =theme.r0 #30fd =theme.g0 #30fd =theme.b0 ( normal mode )
#00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode )
~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
( default canvas ) ( default canvas )
#002a =canvas.w #001a =canvas.h #002a =canvas.w #001a =canvas.h
@ -233,22 +237,26 @@ BRK
( background interface ) ( background interface )
~Mouse.y STEP8 ~Screen.height #0010 SUB2 NEQ2 ^$no-touch-background JNZ ~Mouse.y STEP8 ~Screen.height #0010 SUB2 NEQ2 ^$no-touch-background JNZ
~Mouse.x ~Screen.width #0020 SUB2 SUB2 8/ ~Mouse.x ~Screen.width #0028 SUB2 SUB2 8/ SWP POP
DUP2 #0000 NEQ2 ^$no-clear-button JNZ DUP #00 NEQ ^$no-eye-button JNZ
,clear JSR2 ,present JSR2
( release ) #00 =Mouse.state
$no-eye-button
DUP #01 NEQ ^$no-rename-button JNZ
,rename JSR2
#01 =document.edit #01 =document.edit
( release ) #00 =Mouse.state ( release ) #00 =Mouse.state
$no-clear-button $no-rename-button
DUP2 #0001 NEQ2 ^$no-load-button JNZ DUP #02 NEQ ^$no-load-button JNZ
,path.name ,load-file JSR2 ,path.name ,load-file JSR2
,draw-canvas JSR2 ,draw-canvas JSR2
( release ) #00 =Mouse.state ( release ) #00 =Mouse.state
$no-load-button $no-load-button
DUP2 #0002 NEQ2 ^$no-save-button JNZ DUP #03 NEQ ^$no-save-button JNZ
,path.name ,save-file JSR2 ,path.name ,save-file JSR2
( release ) #00 =Mouse.state ( release ) #00 =Mouse.state
$no-save-button $no-save-button
POP2 POP
$no-touch-background $no-touch-background
( jump label ) ( jump label )
@ -348,12 +356,15 @@ BRK
RTN RTN
@clear ( -- ) @rename
( new label )
,untitled_txt ,path.name ,strcpy JSR2 ,untitled_txt ,path.name ,strcpy JSR2
#00 =path.length #00 =path.length
( erase data )
RTN
@clear ( -- )
,data FILESIZE ,data ADD2 ,data FILESIZE ,data ADD2
$loop $loop
( write ) OVR2 #00 ROT ROT POK2 ( write ) OVR2 #00 ROT ROT POK2
@ -364,6 +375,29 @@ RTN
RTN RTN
@present
~document.presentation #00 EQU =document.presentation
~document.presentation
DUP #00 NEQ ^$skip0 JNZ
~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
$skip0
DUP #01 NEQ ^$skip1 JNZ
~theme.r1 =System.r ~theme.g1 =System.g ~theme.b1 =System.b
$skip1
POP
~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ++ ~toolpane.y2 ++ #00 ,fill-rect JSR2
~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ++ ~pattpane.y2 ++ #00 ,fill-rect JSR2
~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ++ ~sizepane.y2 ++ #00 ,fill-rect JSR2
~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ++ ~viewpane.y2 ++ #00 ,fill-rect JSR2
( clear panes )
,redraw JSR2
RTN
@load-file ( path -- ) @load-file ( path -- )
=File.name FILESIZE =File.length ,data =File.load =File.name FILESIZE =File.length ,data =File.load
@ -647,6 +681,8 @@ RTN
@draw-toolpane ( -- ) @draw-toolpane ( -- )
~document.presentation #00 EQU ^$skip JNZ RTN $skip
( frame ) ( frame )
~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2 ~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2
~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2 ~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2
@ -669,6 +705,8 @@ RTN
@draw-pattpane ( -- ) @draw-pattpane ( -- )
~document.presentation #00 EQU ^$skip JNZ RTN $skip
( frame ) ( frame )
~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2 ~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2
~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2 ~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2
@ -685,6 +723,8 @@ RTN
@draw-sizepane ( -- ) @draw-sizepane ( -- )
~document.presentation #00 EQU ^$skip JNZ RTN $skip
( frame ) ( frame )
~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2 ~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2
~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2 ~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2
@ -701,6 +741,8 @@ RTN
@draw-viewpane ( -- ) @draw-viewpane ( -- )
~document.presentation #00 EQU ^$skip JNZ RTN $skip
( frame ) ( frame )
~viewpane.x1 -- ~viewpane.y1 -- ~viewpane.x2 ~viewpane.y2 #00 ,line-rect JSR2 ~viewpane.x1 -- ~viewpane.y1 -- ~viewpane.x2 ~viewpane.y2 #00 ,line-rect JSR2
~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ~viewpane.y2 #01 ,line-rect JSR2 ~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ~viewpane.y2 #01 ,line-rect JSR2
@ -727,10 +769,11 @@ RTN
@draw-background @draw-background
( draw hor line ) ( draw hor line )
#0000 ~Screen.width ~Screen.height #0002 DIV2 ,line-horizontal-dotted JSR2 #0000 ~Screen.width ~Screen.height #0002 DIV2 ~document.presentation #00 EQU ,line-horizontal-dotted JSR2
( draw ver line ) ( draw ver line )
~Screen.width #0002 DIV2 #0000 ~Screen.height ,line-vertical-dotted JSR2 ~Screen.width #0002 DIV2 #0000 ~Screen.height ~document.presentation #00 EQU ,line-vertical-dotted JSR2
~document.presentation #01 EQU ,$skip-size JNZ2
( draw size ) ( draw size )
#0010 =Sprite.y #0010 =Sprite.y
( draw width ) ( draw width )
@ -743,25 +786,27 @@ RTN
( draw ) #01 =Sprite.color ( draw ) #01 =Sprite.color
~Sprite.x 8+ =Sprite.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Sprite.addr ~Sprite.x 8+ =Sprite.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #01 =Sprite.color ( draw ) #01 =Sprite.color
$skip-size
( draw save/load/guides icons ) ( draw save/load/guides icons )
~Screen.height #0010 SUB2 =Sprite.y ~Screen.height #0010 SUB2 =Sprite.y
~Screen.width #0020 SUB2 =Sprite.x ~Screen.width #0028 SUB2 =Sprite.x
( TODO: Presentation mode button ,eye #00 ~document.presentation #08 MUL ADD2 =Sprite.addr
,guides_icn =Sprite.addr #03 =Sprite.color
#01 =Sprite.color
~Sprite.x 8+ =Sprite.x ~Sprite.x 8+ =Sprite.x
)
,filestate_icn =Sprite.addr ,filestate_icn =Sprite.addr
#01 =Sprite.color #03 =Sprite.color
~Sprite.x 8+ =Sprite.x ~Sprite.x 8+ =Sprite.x
,load_icn =Sprite.addr ,load_icn =Sprite.addr
#01 =Sprite.color #03 =Sprite.color
~Sprite.x 8+ =Sprite.x ~Sprite.x 8+ =Sprite.x
,save_icn =Sprite.addr ,save_icn =Sprite.addr
#01 =Sprite.color #03 =Sprite.color
( filename )
~document.presentation #01 EQU ^$skip-path JNZ
#0008 =Sprite.x #0008 =Sprite.x
,path.name #01 ,draw-label JSR2 ,path.name #01 ,draw-label JSR2
$skip-path
RTN RTN
@ -811,22 +856,22 @@ RTN
RTN RTN
@line-horizontal-dotted ( x0 x1 y -- ) @line-horizontal-dotted ( x0 x1 y color -- )
=Screen.y OVR2 =Screen.x =color =Screen.y OVR2 =Screen.x
$draw-hor $draw-hor
( draw ) #01 =Screen.color ( draw ) ~color =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor JNZ OVR2 OVR2 LTH2 ^$draw-hor JNZ
POP2 POP2 POP2 POP2
RTN RTN
@line-vertical-dotted ( x y0 y1 -- ) @line-vertical-dotted ( x y0 y1 color -- )
STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y =color STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y
$draw-ver $draw-ver
( draw ) #01 =Screen.color ( draw ) ~color =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver JNZ OVR2 OVR2 LTH2 ^$draw-ver JNZ
POP2 POP2 POP2 POP2
@ -898,8 +943,8 @@ RTN
[ 4040 4070 f8f8 f870 ] [ 4040 4070 f8f8 f870 ]
@eye @eye
[ 0000 0082 4438 0000 ] ( open ) [ 0038 4492 2810 0000 ] ( open )
[ 0038 4492 2810 0000 ] ( closed ) [ 0000 0082 4438 0000 ] ( closed )
@load_icn [ feaa d6aa d4aa f400 ] @load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ] @save_icn [ fe82 8282 848a f400 ]

View File

@ -154,7 +154,7 @@ loadtheme(Uint8 *addr)
r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f,
g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f,
b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
theme[i] = (r << 20) + (g << 12) + (b << 4); theme[i] = (r << 20) + (r << 16) + (g << 12) + (g << 8) + (b << 4) + b;
} }
screen.reqdraw = 1; screen.reqdraw = 1;
} }
@ -444,6 +444,7 @@ Uint8
system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
{ {
Uint8 *m = u->ram.dat; Uint8 *m = u->ram.dat;
m[PAGE_DEVICE + 0x00f0 + b0] = b1;
loadtheme(&m[PAGE_DEVICE + 0x00f8]); loadtheme(&m[PAGE_DEVICE + 0x00f8]);
(void)ptr; (void)ptr;
(void)b0; (void)b0;
@ -466,7 +467,6 @@ start(Uxn *u)
{ {
int ticknext = 0; int ticknext = 0;
evaluxn(u, PAGE_VECTORS); evaluxn(u, PAGE_VECTORS);
loadtheme(u->ram.dat + PAGE_DEVICE + 0x00f8);
if(screen.reqdraw) if(screen.reqdraw)
redraw(pixels, u); redraw(pixels, u);
while(1) { while(1) {