(romviz) Improved drawing

This commit is contained in:
Devine Lu Linvega 2023-04-05 10:53:53 -07:00
parent f81510d216
commit b99cdbb95f
1 changed files with 58 additions and 17 deletions

View File

@ -3,6 +3,8 @@
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000 ( -> )
@ -24,27 +26,40 @@ BRK
@on-ready ( -> )
( theme ) [
#014e .System/r DEO2
#07d1 .System/g DEO2
#0bf1 .System/b DEO2 ]
#f41e .System/r DEO2
#fa71 .System/g DEO2
#f4b1 .System/b DEO2 ]
( resize )
#0200
#0240
DUP2 .Screen/width DEO2
.Screen/height DEO2
draw-memory
( test )
#f000 #0100
&l
STH2k MULk STH2r draw-byte
INC2 GTH2k ?&l
POP2 POP2
;on-mouse .Mouse/vector DEO2
BRK
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn update-cursor
.Mouse/state DEI ?&on-mouse-down
BRK
&on-mouse-down ( -> )
( TODO: )
BRK
(
@|drawing )
@draw-memory ( -- )
;src .File/name DEO2
#0001 .File/length DEO2
;pixel-icn .Screen/addr DEO2
LIT2r 0000
&stream
;&buf .File/read DEO2
@ -55,6 +70,23 @@ BRK
JMP2r
@update-cursor ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
#40 draw-cursor
.Mouse/x DEI2 ,draw-cursor/x STR2
.Mouse/y DEI2 ,draw-cursor/y STR2
.Screen/addr DEO2
@draw-cursor ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|stdlib )
@ -62,15 +94,15 @@ JMP2r
addr-pos .Screen/y DEO2 .Screen/x DEO2
DUP #00 NEQ ?&no-null
.Screen/pixel DEO JMP2r
.Screen/sprite DEO JMP2r
&no-null
DUP #20 GTH ?&no-low
POP #01 .Screen/pixel DEO JMP2r
POP #05 .Screen/sprite DEO JMP2r
&no-low
#80 GTH ?&no-ascii
#02 .Screen/pixel DEO JMP2r
#0a .Screen/sprite DEO JMP2r
&no-ascii
#03 .Screen/pixel DEO
#0f .Screen/sprite DEO
JMP2r
@ -79,9 +111,10 @@ JMP2r
STH2k
( pixel x ) #000f AND2
( block x ) STH2kr #48 SFT2 ADD2 #00ff AND2
#10 SFT2 #0020 ADD2
( pixel y ) STHk2r #04 SFT2 #000f AND2
( block y ) STH2kr #4c SFT2 ADD2
POP2r
( block y ) STH2r #4c SFT2 ADD2
#10 SFT2 #0020 ADD2
JMP2r
@ -92,3 +125,11 @@ JMP2r
@pstr ( str* -- ) &w LDAk #18 DEO INC2 LDAk ?&w POP2 JMP2r
@phex ( short* -- ) SWP phex/b &b DUP #04 SFT phex/c &c #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
(
@|assets )
@pixel-icn [
c0c0 0000 0000 0000 ]
@cursor-icn [
80c0 e0f0 f8e0 1000 ]