uxn/projects/software/launcher.tal

297 lines
6.4 KiB
Tal
Raw Normal View History

2021-11-06 16:21:14 +00:00
( launcher
TODO:
Theme setting
Window size setting
Play notes
)
2021-09-21 16:44:10 +00:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r }
%TOS { #00 SWP }
%BRK? { #01 JCN BRK }
%RTN? { #01 JCN RTN }
%DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO }
%DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO }
%HEX-CHAR { DUP #09 GTH #04 JCN #30 + RTN #57 + }
2021-09-21 16:44:10 +00:00
( devices )
2021-11-06 16:21:14 +00:00
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|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 &wheel $1 ]
2021-11-07 19:10:30 +00:00
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
2021-11-06 16:21:14 +00:00
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
2021-09-21 16:44:10 +00:00
( variables )
|0000
@input $30
@second $1
2021-09-21 17:45:56 +00:00
@pointer
&x $2 &y $2
2021-11-07 19:30:36 +00:00
@browser
2021-11-06 16:21:14 +00:00
&x $2 &y $2
2021-09-21 16:44:10 +00:00
( init )
|0100 ( -> )
( theme )
2021-11-06 16:21:14 +00:00
#f077 .System/r DEO2
#f00c .System/g DEO2
#f02a .System/b DEO2
2021-09-21 16:44:10 +00:00
( vectors )
;on-frame .Screen/vector DEO2
2021-09-21 16:44:10 +00:00
;on-button .Controller/vector DEO2
2021-09-21 17:45:56 +00:00
;on-mouse .Mouse/vector DEO2
2021-09-21 16:44:10 +00:00
2021-11-07 19:30:36 +00:00
( place )
#0080 .browser/x STZ2
#0010 .browser/y STZ2
( draw mascot )
#0010 #0010 #0060 #0060 ;mascot-icn #01 ;draw-icn JSR2
( load directory )
;dir/path .File/name DEO2
#1000 .File/length DEO2
;dir/data .File/load DEO2
;dir/data #07 ;draw-browser JSR2
2021-09-21 17:45:56 +00:00
( theme support )
;load-theme JSR2
2021-11-07 19:30:36 +00:00
2021-09-21 16:44:10 +00:00
BRK
@on-frame ( -> )
2021-11-07 19:30:36 +00:00
BRK
.DateTime/second DEI .second LDZ ! BRK?
.DateTime/second DEI .second STZ ;draw-time JSR2
BRK
2021-09-21 17:45:56 +00:00
@on-mouse ( -> )
;pointer-icn .Screen/addr DEO2
( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
( record pointer positions )
.Mouse/x DEI2 .pointer/x STZ2
.Mouse/y DEI2 .pointer/y STZ2
( draw new cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#41 .Mouse/state DEI #01 = + .Screen/sprite DEO
BRK
2021-09-21 16:44:10 +00:00
@on-button ( -> )
.Controller/key DEI BRK?
BRK
@redraw ( -- )
2021-11-07 19:30:36 +00:00
RTN
#0018 #0020 #0040 #0040 ;logo-icn #03 ;draw-icn JSR2
#0020 #0070 ;welcome-txt #01 ;draw-label JSR2
;draw-time JSR2
#0020 #00b0 ;prompt-txt #01 ;draw-label JSR2
#0020 #00c0 ;do-txt #03 ;draw-label JSR2
2021-11-07 19:30:36 +00:00
RTN
@draw-browser ( x* y* addr* color -- )
STH STH2
.browser/x LDZ2 .Screen/x DEO2
.browser/y LDZ2 .Screen/y DEO2
STH2r
&loop
LDAk #0a ! ,&no-lb JCN
#0080 .Screen/x DEO2
.Screen/y DEI2 #0010 ++ .Screen/y DEO2
,&skip JMP
&no-lb
( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
( top-draw ) STHkr .Screen/sprite DEO
( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( bottom-draw ) STHkr .Screen/sprite DEO
( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
&skip
INC2 LDAk ,&loop JCN
POP2 POPr
RTN
@draw-time ( -- )
.DateTime/day DEI
DUP #0f AND ;hex-char JSR2 ;&date-str #0009 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0008 ++ STA
.DateTime/month DEI
DUP #0f AND ;hex-char JSR2 ;&date-str #0006 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0005 ++ STA
.DateTime/year DEI2
DUP #0f AND ;hex-char JSR2 ;&date-str #0003 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0002 ++ STA
DUP #0f AND ;hex-char JSR2 ;&date-str INC2 STA
#04 SFT ;hex-char JSR2 ;&date-str STA
.DateTime/second DEI
DUP #0f AND ;hex-char JSR2 ;&time-str #0007 ++ STA
#04 SFT ;hex-char JSR2 ;&time-str #0006 ++ STA
.DateTime/minute DEI
DUP #0f AND ;hex-char JSR2 ;&time-str #0004 ++ STA
#04 SFT ;hex-char JSR2 ;&time-str #0003 ++ STA
.DateTime/hour DEI
DUP #0f AND ;hex-char JSR2 ;&time-str INC2 STA
#04 SFT ;hex-char JSR2 ;&time-str STA
#0020 #0080 ;&date-str #01 ;draw-label JSR2
#0080 #0080 ;&time-str #02 ;draw-label JSR2
RTN
&date-str "0000-00-00 $1
&time-str "00:00:00 $1
@hex-char ( hex -- char )
HEX-CHAR
2021-09-21 16:44:10 +00:00
RTN
2021-09-21 17:45:56 +00:00
@draw-cursor ( color -- )
STH
;cursor-icn .Screen/addr DEO2
STHkr .Screen/sprite DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
STHr .Screen/sprite DEO
RTN
@draw-icn ( x* y* width* height* addr* color -- )
( load ) STH .Screen/addr DEO2 ,&height STR2 ,&width STR2 ,&y STR2 ,&x STR2
,&height LDR2 #0000
&ver
( save ) DUP2 ,&y LDR2 ADD2 .Screen/y DEO2
,&width LDR2 #0000
&hor
( save ) DUP2 ,&x LDR2 ADD2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
#0008 ADD2 GTH2k ,&hor JCN
POP2 POP2
#0008 ADD2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN
&x $2 &y $2 &width $2 &height $2
2021-09-21 16:44:10 +00:00
@draw-label ( x* y* addr* color -- )
STH STH2
.Screen/y DEO2
.Screen/x DEO2
STH2r
&loop
2021-09-21 17:45:56 +00:00
( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
2021-09-21 16:44:10 +00:00
( top-draw ) STHkr .Screen/sprite DEO
( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( bottom-draw ) STHkr .Screen/sprite DEO
( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
INC2 LDAk ,&loop JCN
POP2 POPr
RTN
2021-09-21 17:45:56 +00:00
( theme )
@theme-txt ".theme $1
@load-theme ( -- )
;theme-txt .File/name DEO2
#0006 .File/length DEO2
2021-11-07 19:10:30 +00:00
#fffa .File/read DEO2
2021-09-21 17:45:56 +00:00
.File/success DEI2 #0006 !! ,&ignore JCN
#fffa LDA2 .System/r DEO2
#fffc LDA2 .System/g DEO2
#fffe LDA2 .System/b DEO2
&ignore
;redraw JSR2
RTN
( helpers )
2021-09-21 16:44:10 +00:00
@print-hex ( value* -- )
&short ( value* -- )
SWP ,&echo JSR
&byte ( value -- )
,&echo JSR
RTN
&echo ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 + RTN &above #09 - #60 + RTN
RTN
@welcome-txt
"Welcome 20 "to 20 "your 20 "UXN 20 "Ordinator $1
@today-txt
"Today 20 "is 20 "0000-00-00 ", 20 "the 20 "time 20 "is 20 "00:00:00 $1
2021-09-21 16:44:10 +00:00
@prompt-txt
"What 20 "shall 20 "we 20 "do? $1
2021-09-21 17:45:56 +00:00
@do-txt
"$: $1
2021-09-21 16:44:10 +00:00
@error-txt
"Sorry, 20 "ROM 20 "not 20 "found. $1
2021-09-21 17:45:56 +00:00
@pointer-icn
80c0 e0f0 f8e0 1000
@cursor-icn
2021-09-21 16:44:10 +00:00
ffff ffff ffff ffff
2021-09-21 17:45:56 +00:00
2021-11-06 16:21:14 +00:00
include projects/library/load-rom.tal
include projects/assets/logo05x05.tal
include projects/assets/mascot0cx0c.tal
include projects/assets/msx01x02.tal
2021-11-07 19:30:36 +00:00
@dir
&path ". $1
&data