Optimized gui examples

This commit is contained in:
neauoire 2021-08-18 11:14:29 -07:00
parent c324881b90
commit e3f181579b
5 changed files with 67 additions and 82 deletions

View File

@ -63,7 +63,6 @@ You can also use the emulator without graphics by using `uxncli`. You can find a
``` ```
cc src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli cc src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
``` ```
### I/O ### I/O

View File

@ -1,11 +1,7 @@
( GUI Hover ) ( GUI Hover )
%+ { ADD } %- { SUB }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r } %RTN { JMP2r }
%GTS2 { #8000 ++ SWP2 #8000 ++ << } %GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
( devices ) ( devices )
@ -28,7 +24,11 @@
|0100 |0100
( theme ) #0f0f .System/r DEO2 #0fff .System/g DEO2 #0ff0 .System/b DEO2 ( theme )
#0f0f .System/r DEO2
#0fff .System/g DEO2
#0ff0 .System/b DEO2
( vectors ) ;on-mouse .Mouse/vector DEO2 ( vectors ) ;on-mouse .Mouse/vector DEO2
#0020 #0030 #0060 #0060 .r1/y2 STZ2 .r1/x2 STZ2 .r1/y1 STZ2 .r1/x1 STZ2 #0020 #0030 #0060 #0060 .r1/y2 STZ2 .r1/x2 STZ2 .r1/y1 STZ2 .r1/x1 STZ2
@ -62,27 +62,20 @@
&draw3 &draw3
.r3/x1 LDZ2 .r3/y1 LDZ2 .r3/x2 LDZ2 .r3/y2 LDZ2 .color LDZ ;line-rect JSR2 .r3/x1 LDZ2 .r3/y1 LDZ2 .r3/x2 LDZ2 .r3/y2 LDZ2 .color LDZ ;line-rect JSR2
;draw-cursor JSR2
BRK
@draw-cursor ( -- )
( clear last cursor ) ( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2 .pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2 .pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO #40 .Screen/sprite DEO
( record pointer positions ) ( record pointer positions )
.Mouse/x DEI2 .pointer/x STZ2 .Mouse/y DEI2 .pointer/y STZ2 .Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
.pointer/sprite LDZ2 .Screen/addr DEO2
( draw new cursor ) ( draw new cursor )
.pointer/sprite LDZ2 .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#41 .Screen/sprite DEO #41 .Screen/sprite DEO
RTN BRK
@within-rect ( x* y* rect -- flag ) @within-rect ( x* y* rect -- flag )

View File

@ -20,13 +20,10 @@
|0100 |0100
( theme ) #0f0f .System/r DEO2 #0fff .System/g DEO2 #0ff0 .System/b DEO2 ( theme )
#0f0f .System/r DEO2
;draw JSR2 #0fff .System/g DEO2
#0ff0 .System/b DEO2
BRK
@draw ( -- )
( find screen center ) ( find screen center )
.Screen/width DEI2 2// .center/x STZ2 .Screen/width DEI2 2// .center/x STZ2

View File

@ -1,7 +1,7 @@
( GUI Picture ) ( GUI Picture )
%RTN { JMP2r } %RTN { JMP2r }
%8+ { #0008 ADD2 } %LOAD-IMAGE { .File/length DEO2 .File/name DEO2 ;image .File/load DEO2 }
( devices ) ( devices )
@ -13,97 +13,93 @@
|0000 |0000
@color [ &byte $1 ] @position
@position [ &x $2 &y $2 ] &x $2 &y $2
@size [ &width $2 &height $2 ] @size
&width $2 &height $2
( program ) ( program )
|0100 |0100
( theme ) #f07a .System/r DEO2 #f02a .System/g DEO2 #f02a .System/b DEO2 ( theme )
#072f .System/r DEO2
#072f .System/g DEO2
#072f .System/b DEO2
( background ) ;checker_icn #02 ;cover-pattern JSR2 ( background ) ;checker-icn #02 ;cover-pattern JSR2
( load ) ;icn1_path .File/name DEO2 #1800 .File/length DEO2 ;image .File/load DEO2
( draw ) #0008 #0008 #0100 #00c0 #07 ;image ;draw-icn JSR2
( load ) ;icn2_path .File/name DEO2 #0800 .File/length DEO2 ;image .File/load DEO2
( draw ) #0010 #0078 #0080 #0080 #07 ;image ;draw-icn JSR2
( load ) ;chr1_path .File/name DEO2 #4000 .File/length DEO2 ;image .File/load DEO2
( draw ) #00a8 #0010 #0100 #0100 #8f ;image ;draw-chr JSR2
( load ) ;chr2_path .File/name DEO2 #0900 .File/length DEO2 ;image .File/load DEO2
( draw ) #0088 #0088 #0060 #0060 #81 ;image ;draw-chr JSR2
( load ) ;icn1-path #1800 LOAD-IMAGE
( draw ) #0008 #0008 #0100 #00c0 ;image #01 ;draw-icn JSR2
( load ) ;icn2-path #0800 LOAD-IMAGE
( draw ) #0010 #00a8 #0080 #0080 ;image #03 ;draw-icn JSR2
( load ) ;chr1-path #4000 LOAD-IMAGE
( draw ) #00e8 #0080 #0100 #0080 ;image #81 ;draw-chr JSR2
( load ) ;chr2-path #0900 LOAD-IMAGE
( draw ) #0068 #0098 #0060 #0060 ;image #85 ;draw-chr JSR2
BRK BRK
@draw-icn ( x y width height color addr -- ) @draw-icn ( x* y* width* height* addr* color -- )
( load ) .Screen/addr DEO2 .color STZ .size/height STZ2 .size/width STZ2 .position/y STZ2 .position/x STZ2 ( load ) STH .Screen/addr DEO2 .size/height STZ2 .size/width STZ2 .position/y STZ2 .position/x STZ2
#0000 .size/height LDZ2 .size/height LDZ2 #0000
&ver &ver
( save ) OVR2 .position/y LDZ2 ADD2 .Screen/y DEO2 ( save ) DUP2 .position/y LDZ2 ADD2 .Screen/y DEO2
#0000 .size/width LDZ2 .size/width LDZ2 #0000
&hor &hor
( save ) OVR2 .position/x LDZ2 ADD2 .Screen/x DEO2 ( save ) DUP2 .position/x LDZ2 ADD2 .Screen/x DEO2
( draw ) .color LDZ .Screen/sprite DEO ( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 ( incr ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&hor JCN
LTH2k ,&hor JCN
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&ver JCN
LTH2k ,&ver JCN
POP2 POP2 POP2 POP2
POPr
RTN RTN
@draw-chr ( x y width height color addr -- ) @draw-chr ( x* y* width* height* addr* color -- )
( load ) .Screen/addr DEO2 .color STZ .size/height STZ2 .size/width STZ2 .position/y STZ2 .position/x STZ2 ( load ) STH .Screen/addr DEO2 .size/height STZ2 .size/width STZ2 .position/y STZ2 .position/x STZ2
#0000 .size/height LDZ2 .size/height LDZ2 #0000
&ver &ver
( save ) OVR2 .position/y LDZ2 ADD2 .Screen/y DEO2 ( save ) DUP2 .position/y LDZ2 ADD2 .Screen/y DEO2
#0000 .size/width LDZ2 .size/width LDZ2 #0000
&hor &hor
( save ) OVR2 .position/x LDZ2 ADD2 .Screen/x DEO2 ( save ) DUP2 .position/x LDZ2 ADD2 .Screen/x DEO2
( draw ) .color LDZ .Screen/sprite DEO ( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2 ( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&hor JCN
LTH2k ,&hor JCN
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&ver JCN
LTH2k ,&ver JCN
POP2 POP2 POP2 POP2
POPr
RTN RTN
@cover-pattern ( addr* color -- ) @cover-pattern ( addr* color -- )
( load ) .color/byte STZ .Screen/addr DEO2 ( load ) STH .Screen/addr DEO2
#0000 .Screen/height DEI2 .Screen/height DEI2 #0000
&ver &ver
( save ) OVR2 .Screen/y DEO2 ( save ) DUP2 .Screen/y DEO2
#0000 .Screen/width DEI2 .Screen/width DEI2 #0000
&hor &hor
( save ) OVR2 .Screen/x DEO2 ( save ) DUP2 .Screen/x DEO2
( draw ) .color LDZ .Screen/sprite DEO ( draw ) STHkr .Screen/sprite DEO
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&hor JCN
LTH2k ,&hor JCN
POP2 POP2 POP2 POP2
( incr ) SWP2 8+ SWP2 #0008 ADD2 GTH2k ,&ver JCN
LTH2k ,&ver JCN
POP2 POP2 POP2 POP2
POPr
RTN RTN
@checker_icn [ f0f0 f0f0 0f0f 0f0f ] @checker-icn f0f0 f0f0 0f0f 0f0f
@icn1-path "projects/pictures/ergo100x0c0.bit 00
@icn1_path [ "projects/pictures/ergo100x0c0.bit 00 ] @icn2-path "projects/pictures/dafu80x80.bit 00
@icn2_path [ "projects/pictures/dafu80x80.bit 00 ] @chr1-path "projects/pictures/pc98.chr 00
@chr1_path [ "projects/pictures/zerotwo2020.chr 00 ] @chr2-path "projects/pictures/felix0cx0c.chr 00
@chr2_path [ "projects/pictures/felix0cx0c.chr 00 ]
@image [ ] @image [ ]