758 lines
18 KiB
Tal
758 lines
18 KiB
Tal
( utility macros )
|
|
|
|
%INC-X { .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 } ( -- )
|
|
%INC-Y { .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 } ( -- )
|
|
|
|
%CENTER-X { .Screen/width DEI2 #01 SFT2 }
|
|
%CENTER-Y { .Screen/height DEI2 #01 SFT2 }
|
|
|
|
%MOD { DIVk MUL SUB }
|
|
%MOD2 { DIV2k MUL2 SUB2 }
|
|
|
|
%2** { #10 SFT2 } %2// { #01 SFT2 }
|
|
%8** { #30 SFT2 } %8// { #03 SFT2 }
|
|
%TOS { #00 SWP } %TOB { SWP POP }
|
|
|
|
%NEXT-TILE { DUP2 #0010 ADD2 }
|
|
%GET-USABLE-HEIGHT { .Screen/height DEI2 #0050 #03 SFT2 SWP POP }
|
|
|
|
%RTN { JMP2r }
|
|
|
|
( devices )
|
|
|
|
|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 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|
|
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|
|
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|
|
|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|
|
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|
|
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
|
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|
|
|a0 @File [ &vector $2 &success $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ]
|
|
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|
|
|
|
( variables )
|
|
|
|
|0000
|
|
|
|
@state $1
|
|
@ticker $1
|
|
@anim-speed $1
|
|
|
|
@logo-coords [
|
|
&x $2
|
|
&y $2
|
|
]
|
|
|
|
@list-len $2
|
|
@list-offset $1
|
|
@list-elem-offset $1
|
|
@list-top $1
|
|
@list-height $1
|
|
@select-index $1
|
|
@ncarts $1
|
|
@btn-state $1
|
|
|
|
@cart $32
|
|
@realm $32
|
|
|
|
( program )
|
|
|
|
|0100
|
|
@init ( -> )
|
|
|
|
( steppewnolf-dark theme )
|
|
#02c1 .System/r DEO2
|
|
#02cd .System/g DEO2
|
|
#02cb .System/b DEO2
|
|
|
|
( load individual sprites from the main sheet )
|
|
;spritesheet .File/name DEO2
|
|
#0100 .File/length DEO2
|
|
|
|
#0000 .File/offset-ls DEO2
|
|
;uxn-logo .File/load DEO2
|
|
|
|
#0200 .File/offset-ls DEO2
|
|
;xrxs-logo .File/load DEO2
|
|
|
|
#00c0 .File/length DEO2
|
|
#0400 .File/offset-ls DEO2
|
|
;yes-btn .File/load DEO2
|
|
|
|
#04c0 .File/offset-ls DEO2
|
|
;yes-btn-active .File/load DEO2
|
|
|
|
#0600 .File/offset-ls DEO2
|
|
;no-btn .File/load DEO2
|
|
|
|
#06c0 .File/offset-ls DEO2
|
|
;no-btn-active .File/load DEO2
|
|
|
|
( load zz font )
|
|
;fontsheet .File/name DEO2
|
|
#0000 .File/offset-ls DEO2
|
|
#0300 .File/length DEO2
|
|
;font .File/load DEO2
|
|
|
|
( initialize state )
|
|
#00 .ticker STZ
|
|
#00 .state STZ
|
|
#00 .select-index STZ
|
|
#20 .anim-speed STZ
|
|
#ff .btn-state STZ
|
|
GET-USABLE-HEIGHT .list-height STZ
|
|
|
|
CENTER-X .logo-coords/x STZ2
|
|
CENTER-Y .logo-coords/y STZ2
|
|
|
|
;on-frame .Screen/vector DEO2
|
|
|
|
BRK
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
|
.ticker LDZ #01 ADD
|
|
DUP .anim-speed LDZ EQU ,&next-render JCN
|
|
.ticker STZ
|
|
BRK
|
|
|
|
&next-render
|
|
POP #00 .ticker STZ
|
|
.state LDZ
|
|
|
|
( draw uxn logo )
|
|
DUP #00 NEQ ,&state1 JCN
|
|
;draw-uxn-logo JSR2
|
|
INC .state STZ
|
|
BRK
|
|
|
|
( draw first syllable of xrxs logo )
|
|
&state1 DUP #01 NEQ ,&state2 JCN
|
|
;draw-xrxs-logo-xr JSR2
|
|
INC .state STZ
|
|
BRK
|
|
|
|
( draw second syllable of xrxs logo )
|
|
&state2 DUP #02 NEQ ,&state3 JCN
|
|
;draw-xrxs-logo-xs JSR2
|
|
|
|
INC .state STZ
|
|
BRK
|
|
|
|
( clear screen )
|
|
&state3
|
|
;clear-screen JSR2
|
|
|
|
( move shove logo into top-left corner )
|
|
DUP #03 NEQ ,&state4 JCN
|
|
#04 .anim-speed STZ
|
|
;scoot-logos JSR2
|
|
;draw-uxn-logo JSR2
|
|
;draw-xrxs-logo-xr JSR2
|
|
;draw-xrxs-logo-xs JSR2
|
|
.logo-coords/x LDZ2 #0020 GTH2 ,&keep-state JCN
|
|
;carts-file .File/name DEO2
|
|
#2000 .File/length DEO2
|
|
;list-buf .File/load DEO2
|
|
.File/success DEI2 .list-len STZ2
|
|
INC .state STZ
|
|
;get-select-idx-by-mouse .Mouse/vector DEO2
|
|
;get-select-idx-by-key .Controller/vector DEO2 BRK
|
|
&keep-state POP
|
|
BRK
|
|
|
|
( render the cartridge list interface )
|
|
&state4 DUP #04 NEQ ,&state5 JCN
|
|
;draw-gray-borders JSR2
|
|
;draw-bl-scanlines JSR2
|
|
;draw-tl-scanlines JSR2
|
|
;draw-tr-scanlines JSR2
|
|
;draw-br-scanlines JSR2
|
|
;draw-uxn-logo JSR2
|
|
;draw-xrxs-logo-xr JSR2
|
|
;draw-xrxs-logo-xs JSR2
|
|
[ ;title-loadCart
|
|
CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2
|
|
#0010
|
|
#02 ] ;draw-string JSR2
|
|
;render-cart-list JSR2
|
|
;draw-pointer JSR2
|
|
POP
|
|
BRK
|
|
|
|
( confirm the selected cartridge )
|
|
&state5 DUP #05 NEQ ,&state6 JCN
|
|
;draw-gray-borders JSR2
|
|
;draw-bl-scanlines JSR2
|
|
;draw-tl-scanlines JSR2
|
|
;draw-tr-scanlines JSR2
|
|
;draw-br-scanlines JSR2
|
|
;draw-uxn-logo JSR2
|
|
;draw-xrxs-logo-xr JSR2
|
|
;draw-xrxs-logo-xs JSR2
|
|
[ ;title-confirmCart
|
|
CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2
|
|
#0010
|
|
#02 ] ;draw-string JSR2
|
|
;render-cart-list JSR2
|
|
;draw-confirm-buttons JSR2
|
|
;draw-pointer JSR2
|
|
POP
|
|
BRK
|
|
&state6 POP
|
|
BRK
|
|
|
|
@clear-screen ( -> )
|
|
|
|
.Screen/width DEI2 #0000 &whilex EQU2k ,&endx JCN
|
|
DUP2 ,&x STR2
|
|
.Screen/height DEI2 #0000 &whiley EQU2k ,&endy JCN
|
|
DUP2 ,&y STR2
|
|
,&x LDR2 .Screen/x DEO2
|
|
,&y LDR2 .Screen/y DEO2
|
|
;blank .Screen/addr DEO2
|
|
#10 .Screen/sprite DEO
|
|
#40 .Screen/sprite DEO
|
|
#0008 ADD2 ,&whiley JMP &endy POP2 POP2
|
|
#0008 ADD2 ,&whilex JMP &endx POP2 POP2
|
|
|
|
RTN
|
|
&x $2
|
|
&y $2
|
|
|
|
@scoot-logos ( -> )
|
|
.logo-coords/x LDZ2 #0021 LTH2 ,&no-scoot-x JCN
|
|
.logo-coords/x LDZ2 #01 SFT2
|
|
.logo-coords/x STZ2
|
|
&no-scoot-x
|
|
|
|
.logo-coords/y LDZ2 #0021 LTH2 ,&no-scoot-y JCN
|
|
.logo-coords/y LDZ2 #01 SFT2
|
|
.logo-coords/y STZ2
|
|
&no-scoot-y
|
|
RTN
|
|
|
|
@draw-uxn-logo ( -> )
|
|
|
|
.logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
|
|
.logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
|
|
|
|
#0100 #0000 &while EQU2k ,&end JCN
|
|
DUP2 ;uxn-logo ADD2 .Screen/addr DEO2
|
|
#c1 .Screen/sprite DEO INC-X
|
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
|
.logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
|
|
INC-Y
|
|
&no-inc-y
|
|
#0010 ADD2 ,&while JMP &end POP2 POP2
|
|
|
|
RTN
|
|
|
|
@draw-xrxs-logo-xr ( -> )
|
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
.logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
|
|
|
|
#0080 #0000 &while EQU2k ,&end JCN
|
|
DUP2 ;xrxs-logo ADD2 .Screen/addr DEO2
|
|
#c1 .Screen/sprite DEO INC-X
|
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
INC-Y
|
|
&no-inc-y
|
|
#0010 ADD2 ,&while JMP &end POP2 POP2
|
|
|
|
RTN
|
|
|
|
@draw-xrxs-logo-xs ( -> )
|
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
.logo-coords/y LDZ2 .Screen/y DEO2
|
|
|
|
#0100 #0080 &while EQU2k ,&end JCN
|
|
DUP2 ;xrxs-logo ADD2 .Screen/addr DEO2
|
|
#c1 .Screen/sprite DEO INC-X
|
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
INC-Y
|
|
&no-inc-y
|
|
#0010 ADD2 ,&while JMP &end POP2 POP2
|
|
|
|
RTN
|
|
|
|
@draw-gray-borders ( -> )
|
|
|
|
;blank .Screen/addr DEO2
|
|
#0028 #0000 &whilemtop EQU2k ,&endmtop JCN
|
|
DUP2 .Screen/y DEO2
|
|
.Screen/width DEI2 #0000 &whiletop EQU2k ,&endtop JCN
|
|
DUP2 .Screen/x DEO2
|
|
#84 .Screen/sprite DEO
|
|
#0008 ADD2 ,&whiletop JMP &endtop POP2 POP2
|
|
#0008 ADD2 ,&whilemtop JMP &endmtop POP2 POP2
|
|
|
|
#0040 #0000 &whilemleft EQU2k ,&endmleft JCN
|
|
DUP2 .Screen/x DEO2
|
|
.Screen/height DEI2 #0028 SUB2 #0028 &whileleft EQU2k ,&endleft JCN
|
|
DUP2 .Screen/y DEO2
|
|
#84 .Screen/sprite DEO
|
|
#0008 ADD2 ,&whileleft JMP &endleft POP2 POP2
|
|
#0008 ADD2 ,&whilemleft JMP &endmleft POP2 POP2
|
|
|
|
.Screen/width DEI2 DUP2 #0040 SUB2 &whilemright EQU2k ,&endmright JCN
|
|
DUP2 .Screen/x DEO2
|
|
.Screen/height DEI2 #0028 SUB2 #0028 &whileright EQU2k ,&endright JCN
|
|
DUP2 .Screen/y DEO2
|
|
#84 .Screen/sprite DEO
|
|
#0008 ADD2 ,&whileright JMP &endright POP2 POP2
|
|
#0008 ADD2 ,&whilemright JMP &endmright POP2 POP2
|
|
|
|
.Screen/height DEI2 DUP2 #0028 SUB2 &whilembottom EQU2k ,&endmbottom JCN
|
|
DUP2 .Screen/y DEO2
|
|
.Screen/width DEI2 #0000 &whilebottom EQU2k ,&endbottom JCN
|
|
DUP2 .Screen/x DEO2
|
|
#84 .Screen/sprite DEO
|
|
#0008 ADD2 ,&whilebottom JMP &endbottom POP2 POP2
|
|
#0008 ADD2 ,&whilembottom JMP &endmbottom POP2 POP2
|
|
RTN
|
|
|
|
|
|
( come up with a more elegant way to draw these )
|
|
|
|
@draw-bl-scanlines ( -> )
|
|
CENTER-Y ,&y STR2
|
|
#0008 ,&x STR2
|
|
|
|
&whileld
|
|
,&y LDR2 CENTER-Y SUB2 #04 SFT2 DUP2 ADD2 #0008 ADD2 ,&x STR2
|
|
.Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endld JCN
|
|
&dlscan #0040 ,&x LDR2 EQU2 ,&enddlscan JCN
|
|
,&x LDR2 .Screen/x DEO2
|
|
,&y LDR2 .Screen/y DEO2
|
|
#03 .Screen/pixel DEO
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&dlscan JMP &enddlscan
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whileld JMP &endld
|
|
RTN
|
|
&x $2
|
|
&y $2
|
|
|
|
@draw-tl-scanlines
|
|
#0028 ,&y STR2
|
|
#0008 ,&x STR2
|
|
|
|
&whilelu
|
|
CENTER-Y ,&y LDR2 SUB2 #04 SFT2 DUP2 ADD2 #0008 ADD2 ,&x STR2
|
|
CENTER-Y ,&y LDR2 LTH2 ,&endlu JCN
|
|
&ulscan #0040 ,&x LDR2 EQU2 ,&endulscan JCN
|
|
,&x LDR2 .Screen/x DEO2
|
|
,&y LDR2 .Screen/y DEO2
|
|
#03 .Screen/pixel DEO
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&ulscan JMP &endulscan
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whilelu JMP &endlu
|
|
|
|
RTN
|
|
&x $2
|
|
&y $2
|
|
|
|
@draw-br-scanlines ( -> )
|
|
CENTER-Y ,&y STR2
|
|
.Screen/width DEI2 #0008 SUB2 ,&x STR2
|
|
|
|
&whilerd
|
|
.Screen/width DEI2 #0040 SUB2 ,&x STR2
|
|
.Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endrd JCN
|
|
&drscan .Screen/width DEI2 #0008 SUB2 ,&y LDR2 CENTER-Y SUB2 #04 SFT2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&enddrscan JCN
|
|
,&x LDR2 .Screen/x DEO2
|
|
,&y LDR2 .Screen/y DEO2
|
|
#03 .Screen/pixel DEO
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&drscan JMP &enddrscan
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whilerd JMP &endrd
|
|
RTN
|
|
&x $2
|
|
&y $2
|
|
|
|
@draw-tr-scanlines
|
|
#0028 ,&y STR2
|
|
.Screen/width DEI2 #0008 SUB2 ,&x STR2
|
|
|
|
&whileru
|
|
.Screen/width DEI2 #0040 SUB2 ,&x STR2
|
|
CENTER-Y ,&y LDR2 LTH2 ,&endru JCN
|
|
&urscan .Screen/width DEI2 #0008 SUB2 CENTER-Y ,&y LDR2 SUB2 #04 SFT2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&endurscan JCN
|
|
,&x LDR2 .Screen/x DEO2
|
|
,&y LDR2 .Screen/y DEO2
|
|
#03 .Screen/pixel DEO
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&urscan JMP &endurscan
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whileru JMP &endru
|
|
|
|
RTN
|
|
&x $2
|
|
&y $2
|
|
|
|
|
|
@draw-pointer ( -> )
|
|
|
|
;cursor .Screen/addr DEO2
|
|
|
|
.Mouse/x DEI2 .Screen/x DEO2
|
|
.Mouse/y DEI2 .Screen/y DEO2
|
|
|
|
#4a .Screen/sprite DEO
|
|
|
|
RTN
|
|
|
|
@draw-string ( addr x y color -- )
|
|
|
|
STH ( save color )
|
|
.Screen/y DEO2 ( set y )
|
|
.Screen/x DEO2 ( set x )
|
|
|
|
( now the string address is at the top of the stack )
|
|
&loop
|
|
LDAk DUP #00 NEQ #20 MUL SUB TOS 8** ;font ADD2 .Screen/addr DEO2
|
|
STHkr .Screen/sprite DEO
|
|
INC-X
|
|
INC2
|
|
LDAk #00 NEQ ,&loop JCN
|
|
POP2
|
|
POPr
|
|
|
|
RTN
|
|
|
|
@strlen ( addr -- len )
|
|
|
|
DUP2
|
|
&loop
|
|
INC2 LDAk ,&loop JCN
|
|
SWP2 SUB2
|
|
|
|
RTN
|
|
|
|
@store-char ( char -- char )
|
|
|
|
#00 .list-elem-offset LDZ ;word ADD2 STA
|
|
.list-elem-offset LDZ INC .list-elem-offset STZ
|
|
|
|
RTN
|
|
|
|
@shouldnt-draw-word ( -- flag )
|
|
|
|
.list-offset LDZ .list-top LDZ LTH
|
|
#00 .list-offset LDZ #00 .list-top LDZ #00 .list-height LDZ ADD2 LTH2
|
|
ORA #01 NEQ
|
|
|
|
RTN
|
|
|
|
@finish-line ( -> )
|
|
|
|
;get-entry-color JSR2 #02 EQU ,&end JCN
|
|
|
|
&while
|
|
.Screen/x DEI2
|
|
.Screen/width DEI2 #0040 SUB2
|
|
|
|
EQU2 ,&end JCN
|
|
#0c .Screen/sprite DEO
|
|
INC-X
|
|
|
|
,&while JMP &end
|
|
|
|
RTN
|
|
|
|
|
|
|
|
@render-cart-list ( -> )
|
|
|
|
#0040 .Screen/x DEO2
|
|
#0028 .Screen/y DEO2
|
|
|
|
#00 .list-offset STZ
|
|
.list-len LDZ2 #0000 &while EQU2k ,&end JCN
|
|
( get a character from the list )
|
|
DUP2 ;list-buf ADD2 LDA
|
|
|
|
( if null byte, terminate loop )
|
|
DUP #00 EQU ,&end JCN
|
|
|
|
( if not newline, store the character and increment the offsets )
|
|
DUP #0a EQU ,&inc-line JCN
|
|
;store-char JSR2
|
|
,&continue JMP ( continue looping )
|
|
|
|
( if newline, print the word, increment x, reset y )
|
|
( clear the word and word offsets, increment the buffer offset )
|
|
&inc-line
|
|
#00 .list-elem-offset LDZ ;word ADD2 STA
|
|
( if the word isn't in the scroll window, don't draw it )
|
|
;shouldnt-draw-word JSR2 ,&no-draw JCN
|
|
[ ;word
|
|
.Screen/x DEI2
|
|
.Screen/y DEI2
|
|
;get-entry-color JSR2 ] ;draw-string JSR2
|
|
;finish-line JSR2
|
|
#0040 .Screen/x DEO2
|
|
INC-Y
|
|
&no-draw
|
|
.list-offset LDZ INC .list-offset STZ
|
|
|
|
#20 #00 &word_clr EQUk ,&end-clr JCN
|
|
#00 OVR SWP DUP ROT ;word ADD2 STA
|
|
INC ,&word_clr JMP &end-clr POP2
|
|
#00 .list-elem-offset STZ
|
|
&continue INC2 ,&while JMP
|
|
&end .list-offset LDZ #01 SUB .ncarts STZ POP2 POP2
|
|
RTN
|
|
|
|
@get-entry-color ( -- colorByte )
|
|
|
|
.list-offset LDZ
|
|
.select-index LDZ
|
|
|
|
NEQ ,&normal JCN
|
|
|
|
( selected )
|
|
#0c RTN
|
|
&normal
|
|
#02
|
|
RTN
|
|
|
|
@get-select-idx-by-mouse ( -> )
|
|
|
|
.Mouse/x DEI2 #0040 LTH2 ,&done JCN
|
|
.Mouse/x DEI2 .Screen/width DEI2 #0040 SUB2 GTH2 ,&done JCN
|
|
|
|
.Mouse/y DEI2 #0028 LTH2 ,&done JCN
|
|
.Mouse/y DEI2 .Screen/height DEI2 #0028 SUB2 GTH2 ,&done JCN
|
|
|
|
.Mouse/y DEI2 #0028 SUB2 8// TOB .list-top LDZ ADD .select-index STZ
|
|
|
|
.Mouse/state DEI #00 EQU ,&no-click JCN
|
|
.select-index LDZ .ncarts GTH ,&no-click JCN
|
|
.state LDZ INC .state STZ
|
|
;set-button-state-by-key .Controller/vector DEO2
|
|
;set-button-state-by-mouse .Mouse/vector DEO2
|
|
&no-click
|
|
BRK
|
|
|
|
&done
|
|
#ff .select-index STZ
|
|
BRK
|
|
|
|
@get-select-idx-by-key ( -> )
|
|
|
|
.Controller/button DEI
|
|
|
|
DUP #10 NEQ ,&no-up JCN
|
|
.select-index LDZ
|
|
DUP .list-top LDZ NEQ ,&no-scroll-up JCN
|
|
.list-top LDZ #01 SUB .list-top STZ
|
|
&no-scroll-up
|
|
DUP #00 EQU ,&no-dec JCN
|
|
#01 SUB .select-index STZ
|
|
,&no-up JMP
|
|
&no-dec
|
|
POP
|
|
&no-up
|
|
|
|
DUP #20 NEQ ,&no-down JCN
|
|
.select-index LDZ
|
|
DUP .list-top LDZ .list-height LDZ ADD NEQ ,&no-scroll-down JCN
|
|
.list-top LDZ INC .list-top STZ
|
|
&no-scroll-down
|
|
DUP .ncarts LDZ EQU ,&no-inc JCN
|
|
INC .select-index STZ
|
|
,&no-down JMP
|
|
&no-inc
|
|
POP
|
|
&no-down
|
|
|
|
DUP #01 NEQ ,&no-a-btn JCN
|
|
.state LDZ INC .state STZ
|
|
;set-button-state-by-key .Controller/vector DEO2
|
|
;set-button-state-by-mouse .Mouse/vector DEO2
|
|
&no-a-btn
|
|
POP
|
|
BRK
|
|
|
|
@set-button-state-by-key ( -> )
|
|
|
|
.btn-state LDZ #ff EQU ,&from-null JCN
|
|
.btn-state LDZ #00 EQU ,&from-no JCN
|
|
|
|
( from yes )
|
|
.Controller/button DEI #80 NEQ ,&check-action JCN
|
|
#00 .btn-state STZ
|
|
BRK
|
|
|
|
&from-no
|
|
.Controller/button DEI #40 NEQ ,&check-action JCN
|
|
#01 .btn-state STZ
|
|
BRK
|
|
|
|
&from-null
|
|
( in from left )
|
|
.Controller/button DEI #80 NEQ ,&in-from-right JCN
|
|
#01 .btn-state STZ
|
|
BRK
|
|
&in-from-right
|
|
.Controller/button DEI #40 NEQ ,&check-action JCN
|
|
#00 .btn-state STZ
|
|
BRK
|
|
|
|
&check-action
|
|
.Controller/button DEI #00 EQU ,&no-action JCN
|
|
( check A button )
|
|
.Controller/button DEI #01 NEQ ,&check-b-button JCN
|
|
( A on yes )
|
|
.btn-state LDZ #01 NEQ ,&a-on-no JCN
|
|
;capture-input JSR2
|
|
#06 .state STZ
|
|
BRK
|
|
&a-on-no
|
|
.btn-state LDZ #00 NEQ ,&no-action JCN
|
|
;get-select-idx-by-mouse .Mouse/vector DEO2
|
|
;get-select-idx-by-key .Controller/vector DEO2
|
|
#04 .state STZ
|
|
BRK
|
|
|
|
&check-b-button
|
|
.Controller/button DEI #02 NEQ ,&no-action
|
|
;get-select-idx-by-mouse .Mouse/vector DEO2
|
|
;get-select-idx-by-key .Controller/vector DEO2
|
|
#04 .state STZ
|
|
&no-action
|
|
BRK
|
|
|
|
@set-button-state-by-mouse ( -> )
|
|
|
|
( if not in the vertical range of the buttons, quit early )
|
|
.Mouse/y DEI2 .Screen/height DEI2 #001c SUB2 LTH2 ,¬-no JCN
|
|
.Mouse/y DEI2 .Screen/height DEI2 #000c SUB2 GTH2 ,¬-no JCN
|
|
|
|
|
|
.Mouse/x DEI2 CENTER-X #0030 SUB2 LTH2 ,¬-yes JCN
|
|
.Mouse/x DEI2 CENTER-X GTH2 ,¬-yes JCN
|
|
#01 .btn-state STZ
|
|
,&check-click JMP
|
|
|
|
¬-yes
|
|
|
|
.Mouse/x DEI2 CENTER-X LTH2 ,¬-no JCN
|
|
.Mouse/x DEI2 CENTER-X #0030 ADD2 GTH2 ,¬-no JCN
|
|
#00 .btn-state STZ
|
|
,&check-click JMP
|
|
|
|
¬-no
|
|
#ff .btn-state STZ BRK
|
|
|
|
&check-click
|
|
.Mouse/state DEI #00 EQU ,&no-click JCN
|
|
.btn-state LDZ #00 NEQ ,&state-load JCN
|
|
;get-select-idx-by-mouse .Mouse/vector DEO2
|
|
;get-select-idx-by-key .Controller/vector DEO2
|
|
#04 .state STZ
|
|
BRK
|
|
&state-load
|
|
;capture-input JSR2
|
|
#06 .state STZ
|
|
&no-click
|
|
|
|
BRK
|
|
|
|
@button-color ( bit -- sprite )
|
|
|
|
,&get-color-yes JCN
|
|
|
|
( get color no )
|
|
.btn-state LDZ #ff EQU ,&no-inactive JCN
|
|
.btn-state LDZ #01 EQU ,&no-inactive JCN
|
|
( active )
|
|
;no-btn-active RTN
|
|
|
|
&no-inactive
|
|
;no-btn RTN
|
|
|
|
|
|
&get-color-yes
|
|
.btn-state LDZ #ff EQU ,&yes-inactive JCN
|
|
.btn-state LDZ #00 EQU ,&yes-inactive JCN
|
|
( active )
|
|
;yes-btn-active RTN
|
|
|
|
&yes-inactive
|
|
;yes-btn
|
|
|
|
RTN
|
|
|
|
@draw-confirm-buttons ( -> )
|
|
|
|
( yes )
|
|
.Screen/height DEI2 #001c SUB2 .Screen/y DEO2
|
|
CENTER-X #0030 SUB2 .Screen/x DEO2
|
|
|
|
#00c0 #0000 &while-yes EQU2k ,&end-yes JCN
|
|
DUP2 [ #01 ;button-color JSR2 ] ADD2 .Screen/addr DEO2
|
|
#81 .Screen/sprite DEO INC-X
|
|
|
|
NEXT-TILE #0060 NEQ2 ,&no-inc-y JCN
|
|
CENTER-X #0030 SUB2 .Screen/x DEO2
|
|
INC-Y
|
|
&no-inc-y
|
|
#0010 ADD2 ,&while-yes JMP &end-yes POP2 POP2
|
|
|
|
( no )
|
|
.Screen/height DEI2 #001c SUB2 .Screen/y DEO2
|
|
CENTER-X .Screen/x DEO2
|
|
|
|
#00c0 #0000 &while-no EQU2k ,&end-no JCN
|
|
DUP2 [ #00 ;button-color JSR2 ] ADD2 .Screen/addr DEO2
|
|
#81 .Screen/sprite DEO INC-X
|
|
|
|
NEXT-TILE #0060 NEQ2 ,&no-inc-y-no JCN
|
|
CENTER-X .Screen/x DEO2
|
|
INC-Y
|
|
&no-inc-y-no
|
|
#0010 ADD2 ,&while-no JMP &end-no POP2 POP2
|
|
|
|
RTN
|
|
|
|
@capture-input ( -> )
|
|
|
|
;no-instr .Mouse/vector DEO2
|
|
;no-instr .Controller/vector DEO2
|
|
|
|
RTN
|
|
|
|
@no-instr BRK
|
|
|
|
( constants )
|
|
@spritesheet "xrxs.chr 00
|
|
@fontsheet "zz.chr 00
|
|
@carts-file "n/carts 00
|
|
@title-loadCart "Select 20 "A 20 "Cartridge 00
|
|
@title-confirmCart "Load 20 "This 20 "Cartridge? 00
|
|
|
|
( sprites )
|
|
@blank $16
|
|
@uxn-logo $256
|
|
@xrxs-logo $256
|
|
@yes-btn $192
|
|
@no-btn $192
|
|
@yes-btn-active $192
|
|
@no-btn-active $192
|
|
@cursor [ 80c0 e0f0 f8e0 1000 ]
|
|
@font $768
|
|
|
|
( big data )
|
|
@word [ #0000 #0000 #0000 #0000
|
|
#0000 #0000 #0000 #0000
|
|
#0000 #0000 #0000 #0000
|
|
#0000 #0000 #0000 #0000 ]
|
|
@list-buf $8192
|
|
|