uxn-utils/gui/soroban/soroban.tal

344 lines
7.7 KiB
Tal
Raw Normal View History

2023-03-17 23:50:51 -04:00
( uxnemu soroban.rom )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|10 @Console &vector $2 &read $1 &pad $5 &write $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
@cursor &x $2 &y $2
@rods $a $1
|0100 ( -> )
( meta )
;meta #f0 DEO2
( theme )
#e1cc .System/r DEO2
#e03b .System/g DEO2
#e009 .System/b DEO2
load-theme
( size )
#0148 .Screen/width DEO2
#0078 .Screen/height DEO2
( unlock )
;on-mouse .Mouse/vector DEO2
;on-console .Console/vector DEO2
redraw
BRK
(
@|vectors )
@on-console ( -> )
.Console/read DEI
DUP #20 GTH ?&no-lb
#00 ,&id STR POP BRK
&no-lb
LIT "0 SUB [ LIT &id $1 ] set-rod
,&id LDR INC ,&id STR
BRK
@on-mouse ( -> )
( clear last cursor )
#40 draw-cursor
( draw new cursor )
.Mouse/x DEI2 .cursor/x STZ2
.Mouse/y DEI2 .cursor/y STZ2
;cursor-icn .Screen/addr DEO2
#41 .Mouse/state DEI #00 NEQ ADD draw-cursor
( route )
.Mouse/x DEI2 #0008 SUB2 #0018 DIV2 NIP
.Mouse/y DEI2 #0008 SUB2 #03 SFT2 NIP
.Mouse/state DEI
DUP #01 EQU ?&on-mouse-touch
DUP #01 GTH ?&on-mouse-alt
POP POP2
BRK
&on-mouse-alt ( x y state -> )
POP2
#00 SWP set-rod
#00 .Mouse/state DEO
BRK
&on-mouse-touch ( x y state -> )
POP
( release ) #00 .Mouse/state DEO
DUP #03 LTH ?&on-touch-godama
#04 SUB #05 LTH ?&on-touch-ichidama-inc
#ff SWP mod-rod
BRK
&on-touch-godama ( x y -> )
POP
#05 SWP mod-rod
BRK
&on-touch-ichidama-inc ( x -> )
#01 SWP mod-rod
BRK
(
@|core )
@get-rod ( id -- value )
.rods ADD LDZ
JMP2r
@mod-rod ( mod id -- )
STHk get-rod ADD STHr
@set-rod ( value id -- )
STH
#0a DIVk MUL SUB
STHkr .rods ADD STZ
2023-03-17 23:57:08 -04:00
STHr
2023-03-17 23:50:51 -04:00
!draw-rod
(
@|drawing )
@redraw ( -- )
( frame )
#d5 .Screen/auto DEO
#0000 .Screen/x DEO2
#0000 .Screen/y DEO2
;frame-chr .Screen/addr DEO2
#81 .Screen/sprite DEO
.Screen/width DEI2 #0008 SUB2 .Screen/x DEO2
#0000 .Screen/y DEO2
;frame-chr .Screen/addr DEO2
#91 .Screen/sprite DEO
( bottom )
#01 .Screen/auto DEO
#0000 .Screen/x DEO2
;fill-icn .Screen/addr DEO2
.Screen/height DEI2 #0008 SUB2 .Screen/y DEO2
.Screen/width DEI2 #03 SFT2 NIP #00
&f
#03 .Screen/sprite DEO
INC GTHk ?&f
POP2
( rods )
#0d00
&l
DUP draw-rod
INC GTHk ?&l
POP2
JMP2r
@draw-rod ( id -- )
DUP .rods ADD LDZ SWP
( position )
#00 OVR #0018 MUL2 #0008 ADD2 .Screen/x DEO2
#0000 .Screen/y DEO2
( set special )
INC INC #03 DIVk MUL SUB #00 EQU ,&special STR
#26 .Screen/auto DEO
( top )
;rod-icn/top .Screen/addr DEO2
#81 .Screen/sprite DEO
#01 .Screen/sprite DEO
;rod-icn/rod .Screen/addr DEO2
#01 .Screen/sprite DEO
;rod-icn/rod .Screen/addr DEO2
#01 .Screen/sprite DEO
( middle )
[ LIT2 00 &special $1 ] #0030 MUL2 ;rod-icn/spacer ADD2
.Screen/addr DEO2
#81 .Screen/sprite DEO
( bottom )
#0800
&l
;rod-icn/rod .Screen/addr DEO2
#01 .Screen/sprite DEO
INC GTHk ?&l
POP2
;rod-icn/top .Screen/addr DEO2
#a1 .Screen/sprite DEO
( num )
#00 .Screen/auto DEO
.Screen/x DEI2k #0008 ADD2 ROT DEO2
.Screen/y DEI2k #0002 SUB2 ROT DEO2
#00 OVR #30 SFT2 ;num-icn ADD2 .Screen/addr DEO2
#0d .Screen/sprite DEO
.Screen/x DEI2k #0008 SUB2 ROT DEO2
.Screen/y DEI2k INC2 INC2 ROT DEO2
@draw-beads ( value -- )
STH
( godama )
#26 .Screen/auto DEO
#00 STHkr #04 GTH #0b MUL #0006 ADD2 .Screen/y DEO2
;bead-icn .Screen/addr DEO2
#85 .Screen/sprite DEOk DEO
( ichidama )
#0027 .Screen/y DEO2
#0400
&l
( red ichidama )
( first bead ) DUP #00 EQU
( 3rd rod ) ;draw-rod/special LDA AND
#00 SWP #0060 MUL2 ;bead-icn ADD2 .Screen/addr DEO2
( offset )
2023-03-17 23:57:08 -04:00
#00
2023-03-17 23:50:51 -04:00
OVR #05 DIVk MUL SUB
STHkr #05 DIVk MUL SUB
EQU #000c MUL2 STH2
.Screen/y DEI2k STH2r ADD2 ROT DEO2
( location )
#85 .Screen/sprite DEOk DEO
.Screen/y DEI2k #0003 SUB2 ROT DEO2
INC GTHk ?&l
POP2
POPr
JMP2r
@draw-cursor ( color -- )
#00 .Screen/auto DEO
.cursor/x LDZ2 .Screen/x DEO2
.cursor/y LDZ2 .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|utils )
@load-theme ( -- )
;&path .File/name DEO2
#0002 .File/length DEO2
;&r .File/read DEO2
;&g .File/read DEO2
;&b .File/read DEO2
.File/success DEI2 ORA #01 JCN JMP2r
LIT2 &r $2 .System/r DEO2
LIT2 &g $2 .System/g DEO2
LIT2 &b $2 .System/b DEO2
JMP2r
&path ".theme $1
(
@|etc )
@meta =&end =appicon &body
( name ) "Soroban $1
( version ) "Ver. 20 "1.01 $1
( details ) "Graphical 20 "Japanese 20 "Soroban $1
( author ) "Devine 20 "Lu 20 "Linvega 20 7f 20 "2022 $1
&end $1
(
@|spritesheet )
2023-03-17 23:57:08 -04:00
@cursor-icn [
80c0 e0f0 f8e0 1000 ]
@fill-icn [
ffff ffff ffff ffff ]
@bead-icn [
0000 0000 030f 3f7f 0000 0000 0003 0f3f 0018 3cff ffff ffff 0000 003c ffff ffff
0000 0000 c0f0 fcfe 0000 0000 00c0 f0fc 7f3f 0f03 0000 0000 3f0f 0300 0000 0000
2023-03-17 23:50:51 -04:00
ffff ffff ff3c 1800 ffff ffff 3c00 0000 fefc f0c0 0000 0000 fcf0 c000 0000 0000
( special )
2023-03-17 23:57:08 -04:00
0000 0000 030c 3040 0000 0000 0003 0f3f 1818 3cc3 0000 0000 0000 003c ffff ffff
0000 0000 c030 0c02 0000 0000 00c0 f0fc 4030 0c03 0000 0000 3f0f 0300 0000 0000
0000 0000 c33c 1818 ffff ffff 3c00 0000 020c 30c0 0000 0000 fcf0 c000 0000 0000 ]
2023-03-17 23:50:51 -04:00
2023-03-17 23:57:08 -04:00
@rod-icn [
2023-03-17 23:50:51 -04:00
&top
2023-03-17 23:57:08 -04:00
ffff ffff ffff 0000 ffff ffff ff00 0000 ffff ffff ffff 3c18 ffff ffff ff3c 1800
2023-03-17 23:50:51 -04:00
ffff ffff ffff 0000 ffff ffff ff00 0000
&rod
0000 0000 0000 0000 1818 1818 1818 1818 0000 0000 0000 0000
&spacer
2023-03-17 23:57:08 -04:00
00ff ffff ffff ff00 0000 ffff ffff 0000 3cff ffff ffff ff3c 003c ffff ffff 3c00
2023-03-17 23:50:51 -04:00
00ff ffff ffff ff00 0000 ffff ffff 0000
( marker )
2023-03-17 23:57:08 -04:00
00ff ffff ffff ff00 0000 ffff ffff 0000 3cff ffff ffff ff3c 183c ffe7 e7ff 3c18
00ff ffff ffff ff00 0000 ffff ffff 0000 ]
@frame-chr [
ffff ffff ffff fcfc ffff ffff fffc f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcff ffff ffff fffc f8fc ffff ffff fcf8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8
fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc ffff ffff ffff f8f8 fcff ffff ffff ]
@num-icn [
2023-03-17 23:50:51 -04:00
3c66 6e76 6666 3c00
1838 1818 1818 7e00
3c66 060c 1830 7e00
7e0c 180c 0666 3c00
0c1c 3c6c 7e0c 0c00
7e60 7c06 0666 3c00
3c60 607c 6666 3c00
7e06 0c18 3030 3000
3c66 663c 6666 3c00
2023-03-17 23:57:08 -04:00
3c66 663e 060c 3800 ]
@appicon [
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2023-03-17 23:50:51 -04:00
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2023-03-17 23:57:08 -04:00
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff 0000 0000 0000 0080 0000 0000 0000 0000
0000 0000 0000 0000 0101 0101 0101 0101 ff88 8888 889c be9c ff20 71fb 7120 2020
ff82 c2e2 c287 8f87 ff08 0808 081c be1c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000
0000 0000 0000 0000 0101 0101 0101 0101 88ff 889c be9c 889c 20ff 2070 f870 2123
827f 8282 8282 c7ef 08ff 081c 3e1c 089c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000
0000 0000 0000 0000 0101 0101 0101 0101 be9c 889c be9c 8888 2120 71fb 7120 71fb
c782 c7ef c782 c7ef 3e1c 089c 3e1c 089c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000
0000 0000 0000 0000 0101 0101 0101 0100 8888 9cbe 9c88 ffff 7120 71fb 7120 ffff
c782 c7ef c782 ffff 3e1c 0888 0808 ffff c0c0 c0c0 c0c0 c080 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ]