(m291) Progress

This commit is contained in:
Devine Lu Linvega 2024-08-25 15:58:25 -07:00
parent a057e3057e
commit b2b1b9259e
3 changed files with 368 additions and 109 deletions

View File

@ -8,7 +8,7 @@ ROM=bin/${ID}.rom
all: ${ROM}
lint:
@ ${LIN} ${ID}.tal
@ ${LIN} src/${ID}.tal
run: all
@ ${EMU} ${ROM}
clean:

View File

@ -349,7 +349,10 @@
0000 0000 0000 0000 0000 3333 0000 0000
0000 0000 0000 0000 0000 3030 0000 0000 ]
@mem &filepath $80 &dir $800
&folders $200
&roms $200
&misc $200
@buffer $200 &pos $2
@dir $2000

View File

@ -1,140 +1,396 @@
( mp3.tal )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2
|12 &read $1
|17 &type $1
|18 &write $1
|19 &error $1
|1c &addr $2
|1e &mode $1
|1f &exec $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &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
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|a0 @File &vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|100
|0000
@misc $1
@selection $1 &mod $1
@path $2 &null $80
@lines &folders $1 &roms $1 &misc $1
|0100
@on-reset ( -> )
( | theme )
#d2d2 DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
<draw-directory>
;meta #06 DEO2
#d20f .System/r DEO2
#d24f .System/g DEO2
#d204 .System/b DEO2
<load-theme>
#0100 .Screen/width DEO2
;dict/home-path set-path <refresh-dir>
;on-mouse .Mouse/vector DEO2
;on-control .Controller/vector DEO2
BRK
( | initialize buffer )
;buffer ;buffer/pos STA2
( | run mpg123 )
;on-console .Console/vector DEO2
;program .Console/addr DEO2
( cmd addr ) #03 .Console/mode DEO
( cmd mode ) #01 .Console/exec DEO
( exec ) ;cmd1 print ;cmd2 print BRK
@<draw-directory> ( -- )
( here ) { ". $1 }
@meta $1
( name ) "Menu(Porporo) 0a
( desc ) "File 20 "Browser 0a
( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
( date ) "9 20 "Dec 20 "2023 $1
( exts ) 00
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn <update-cursor>
.Mouse/y DEI2 <y-id>
.Mouse/state DEI DUP ?{ POP <select>
BRK }
#01 GTH .selection/mod STZ
<pick>
[ LIT2 00 -Mouse/state ] DEO
BRK
@<y-id> ( y* -- id )
#0003 SUB2
( | above )
DUP2 #8000 GTH2 ?&outside
( | spacer )
has-spacer #00 EQU ?{
DUP2 [ LIT2 00 -lines/folders ] LDZ #40 SFT2 SUB2 #0008 LTH2 ?&outside
DUP2 [ LIT2 00 -lines/folders ] LDZ #40 SFT2 GTH2 #00 SWP #30 SFT2 SUB2 }
#04 SFT2 NIP
( | below )
DUP count-lines LTH ?{ POP #ff JMP2r }
JMP2r
&outside ( y* -- id )
POP2 #ff JMP2r
@on-control ( -> )
( | mod )
[ LIT2 04 -Controller/button ] DEI AND #00 NEQ .selection/mod STZ
( | key )
.Controller/key DEI
( esc ) DUP #1b NEQ ?{ <escape> }
( tab ) DUP #09 NEQ ?{ <toggle-misc> }
( enter ) DUP #0d NEQ ?{ .selection LDZ <pick> }
POP
( | button )
.Controller/button DEI
( up ) DUP #10 NEQ ?{ #ff <move> }
( down ) DUP #20 NEQ ?{ #01 <move> }
( A ) DUP #01 NEQ ?{ .selection LDZ <pick> }
POP BRK
(
@|core )
@<refresh-dir> ( -- )
;path .File/name DEO2
#0800 .File/length DEO2
;mem/dir .File/read DEO2
( | clean )
[ LIT2 00 -lines/folders ] STZ
[ LIT2 00 -lines/roms ] STZ
[ LIT2 00 -lines/misc ] STZ
( | parse )
;mem/dir
&w ( -- )
DUP2 <parse-line>
lcap/ INC2 LDAk ?&w
POP2
( >> )
@fit-window ( -- )
#00 count-lines
( empty ) DUP #00 EQU ADD #40 SFT2
( no-folder spacer ) has-spacer #00 EQU ?{ #0008 ADD2 }
( padding ) #0016 ADD2 .Screen/height DEO2
!<redraw>
@<parse-line> ( line* -- )
#0005 ADD2 LDAk [ LIT ". ] EQU ?&hidden
is-folder ?&folder
is-rom ?&rom
;mem/misc [ LIT2 00 -lines/misc ] LDZ #40 SFT2 ADD2 <lcpy>
.lines/misc LDZ INC .lines/misc STZ
JMP2r
&folder ( line* -- )
;mem/folders [ LIT2 00 -lines/folders ] LDZ #40 SFT2 ADD2 <lcpy>
.lines/folders LDZ INC .lines/folders STZ
JMP2r
&rom ( line* -- )
;mem/roms [ LIT2 00 -lines/roms ] LDZ #40 SFT2 ADD2 <lcpy>
.lines/roms LDZ INC .lines/roms STZ
JMP2r
&hidden ( line* -- )
POP2 JMP2r
@<move> ( mod -- )
.selection LDZ ADD INCk ?{
POP count-lines #01 SUB !<select> }
count-lines DIVk MUL SUB
( >> )
@<select> ( id -- )
[ LIT &last ff ] NEQk ?{ POP2 JMP2r }
POP DUP ,&last STR
.selection STZ
!<redraw>
@<pick> ( alt id -- )
DUP .lines/folders LDZ LTH ?&folder
.lines/folders LDZ SUB DUP .lines/roms LDZ LTH ?&roms
.lines/roms LDZ SUB DUP .lines/misc LDZ LTH ?&misc
POP JMP2r
&roms ( id -- )
#00 SWP #40 SFT2 ;mem/roms ADD2 !<send-path>
&misc ( id -- )
#00 SWP #40 SFT2 ;mem/misc ADD2 !<send-file>
&folder ( id -- )
#00 SWP #40 SFT2 ;mem/folders ADD2 !<enter>
@<send-path> ( file* -- )
.selection/mod LDZ ?&special
[ LIT2 ff -Console/type ] DEO
;path <pstr>
<pstr>/
#0a18 DEO
!<exit>
&special ( file* -- )
[ LIT2 01 -Console/type ] DEO
;path <pstr>
<pstr>/
#0a18 DEO
JMP2r
@<send-file> ( file* -- )
[ LIT2 01 -Console/type ] DEO
.selection/mod LDZ ?&special
;path ;mem/filepath STH2k <scpy>
STH2kr scap/ <scpy>
STH2r .File/name DEO2
#2000 .File/length DEO2
;dir .File/read DEO2
;dir <pstr>
#0010 DUP2 .Screen/x DEO2
#0001 .File/length DEO2
&s ( -- )
;&b .File/read DEO2
[ LIT2 &b $1 18 ] DEO
.File/success-lb DEI ?&s
JMP2r
&special ( file* -- )
;path <pstr>
<pstr>/
#0a18 DEO
JMP2r
@<enter> ( folder* -- )
.selection/mod LDZ ?&special
push-path !<refresh-dir>
&special ( folder* -- )
;path <pstr>
<pstr>/
#0a18 DEO
JMP2r
@<leave> ( -- )
pop-path !<refresh-dir>
@<escape> ( -- )
;path/null LDA ?<leave>
( >> )
@<exit> ( -- )
#800f DEO
JMP2r
@<toggle-misc> ( -- )
[ LIT2 00 -misc ] LDZ EQU .misc STZ
!fit-window
@count-lines ( -- lines )
.lines/folders LDZ .lines/roms LDZ ADD
( ) [ LIT2 00 -misc ] LDZ EQU ?{ .lines/misc LDZ ADD }
JMP2r
@has-spacer ( -- f )
[ LIT2 00 -lines/folders ] LDZ NEQ
( ) [ LIT2 00 -lines/roms ] LDZ NEQ
( ) [ LIT2 00 -misc ] LDZ EQU ?{
[ LIT2 00 -lines/misc ] LDZ NEQ ORA }
AND JMP2r
@get-cat ( id -- color )
INC .lines/folders LDZ GTHk ?{ POP2 #03 JMP2r }
SUB .lines/roms LDZ GTH ?{ #02 JMP2r }
#01 JMP2r
@is-folder ( line* -- line* f )
DUP2 lcap/ #0001 SUB2 LDA [ LIT "/ ] EQU JMP2r
@is-rom ( line* -- line*f )
DUP2 lcap/ #0003 SUB2 ;dict/mp3-ext !scmp3
(
@|path )
@set-path ( path* -- )
;path !<scpy>
@push-path ( subpath* -- )
;path scap/ !<scpy>
@pop-path ( -- )
;path scap/ #0001 SUB2
&w ( -- )
;path/null LDA ?{ POP2 JMP2r }
#0001 SUB2 LDAk [ LIT "/ ] NEQ ?{
LITr 00 STH2
INC2r STAr
JMP2r }
!&w
(
@|drawing )
@<redraw> ( -- )
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
;dir <draw-uf2-line>
[ LIT2 80 -Screen/pixel ] DEO
( | highlight )
.selection LDZ <draw-highlight>
( | content )
#0004 .Screen/y DEO2
( | empty )
count-lines ?{
#0008 .Screen/x DEO2
;dict/empty #0f !<draw-uf2> }
( | folders )
;mem/folders .lines/folders LDZ #05 <draw-list>
[ LIT2 00 -lines/folders ] LDZ EQU ?{ <draw-spacer> }
;mem/roms .lines/roms LDZ #05 <draw-list>
[ LIT2 00 -misc ] LDZ EQU ?{
;mem/misc .lines/misc LDZ #0f <draw-list> }
JMP2r
@<draw-uf2-line> ( addr* -- )
[ LIT2 15 -Screen/auto ] DEO
&>while ( -- )
LDAk #20 SUB #00 SWP
( addr ) DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
( move ) ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
( draw ) [ LIT2 01 -Screen/sprite ] DEOk DEO
.Screen/x DEO2
INC2 LDAk #0a NEQ ?&>while
@<draw-spacer> ( -- )
#0000 .Screen/x DEO2
;dash-icn .Screen/addr DEO2
[ LIT2 f2 -Screen/auto ] DEO
[ LIT2 05 -Screen/sprite ] DEO
JMP2r
@<draw-uf2> ( text* -- )
@<draw-highlight> ( id -- )
( empty ) count-lines ?{ POP JMP2r }
;fill-icn .Screen/addr DEO2
[ LIT2 f2 -Screen/auto ] DEO
#0000 .Screen/x DEO2
STH
( lines ) #00 STHkr #40 SFT2
( | spacer )
has-spacer #00 EQU ?{
#00 STHkr INC .lines/folders LDZ GTH #30 SFT2 ADD2 }
( padding ) #0003 ADD2 .Screen/y DEO2
STHr get-cat .Screen/sprite DEOk DEO
JMP2r
@<draw-list> ( addr* length color -- )
,&color STR
DUP ?{ POP2 POP JMP2r }
#0008 .Screen/x DEO2
#00 SWP2 ,&t STR2
&l ( -- )
#00 OVR #40 SFT2 [ LIT2 &t $2 ] ADD2 [ LIT &color $1 ] <draw-uf2>
#0008 .Screen/x DEO2
.Screen/y DEI2k #0010 ADD2 ROT DEO2
INC GTHk ?&l
POP2 JMP2r
@<draw-uf2> ( addr* color -- )
,&color STR
[ LIT2 15 -Screen/auto ] DEO
&>while ( -- )
&w ( -- )
LDAk #1f GTH ?{ POP2 JMP2r }
LDAk #20 SUB #00 SWP
( addr ) DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
( move ) ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
( draw ) [ LIT2 01 -Screen/sprite ] DEOk DEO
( ) DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
( ) ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
( ) [ LIT &color 05 ] .Screen/sprite DEOk DEO
.Screen/x DEO2
INC2 LDAk ?&>while
POP2 JMP2r
INC2 !&w
@printerr ( s* -> )
LDAk ?{
#0a .Console/error DEO
POP2 JMP2r }
LDAk .Console/error DEO
INC2 !printerr
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
.Screen/addr DEO2
@print ( s* -> )
LDAk ?{ POP2 JMP2r }
LDAk .Console/write DEO
INC2 !print
@on-console ( -> )
.Console/type DEI #01 EQU ?{ BRK }
.Console/read DEI #0a EQU ?&newline
;buffer/pos LDA2k STH2k .Console/read DEI STH2r STA
INC2 SWP2 STA2
BRK
&newline #00 ;buffer/pos LDA2 STA
on-line ;buffer ;buffer/pos STA2
BRK
@on-line ( -> )
;buffer LDAk [ LIT "@ ] EQU ?{ POP2 JMP2r }
INC2k LDA [ LIT "F ] EQU ?on-frame
!printerr
@on-frame ( buf* -> )
POP2 JMP2r
@on-help ( buf* -> )
POP2r JMP2r
@on-id3 ( buf* -> )
POP2 JMP2r
@on-paused ( buf* -> )
POP2 JMP2r
@on-revision ( buf* -> )
POP2 JMP2r
@on-status ( buf* -> )
POP2 JMP2r
@on-tag ( buf* -> )
POP2 JMP2r
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|stdlib )
@<phex> ( short* -: )
SWP /b
&b ( byte -: )
DUP #04 SFT /c
&c ( byte -: )
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
@scap ( str* -- end* )
&w ( -- )
INC2 & LDAk ?&w
JMP2r
@<pstr> ( str* -: )
LDAk #18 DEO
INC2 & LDAk ?<pstr>
@scmp3 ( a* b* -- f )
STH2
LDAkr LDAk STHr NEQ ?{ INC2r INC2 }
LDA2r LDA2 STH2r EQU2 JMP2r
@lcap ( str* -- next-line* )
&w ( -- )
LDAk #0a EQU ?{
INC2 & LDAk ?&w }
JMP2r
@<lcpy> ( src* dst* -- )
STH2
&w ( -- )
LDAk #1f GTH ?{
POP2 #00 STH2r STA
JMP2r }
LDAk #00 STH2kr STA2
INC2r INC2 !&w
@<scpy> ( src* dst* -- )
STH2
&w ( -- )
LDAk #00 STH2kr STA2
INC2r INC2 LDAk ?&w
POP2 POP2r JMP2r
@<pstr> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 & LDAk ?&w
POP2 JMP2r
(
@|theme )
@<load-theme> ( -- )
;&path .File/name DEO2
#0002 .File/length DEO2
[ LIT2 -System/debug -System/r ]
&l ( -- )
;&buf .File/read DEO2
[ LIT2 00 -File/success-lb ] DEI EQU ?{
[ LIT2r &buf $2 ] STHk DEO2r
INC INC NEQk ?&l }
POP2 JMP2r
&path ".theme $1
(
@|assets )
@program "mpg123 20 "-R 00
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@cmd1 "loadpaused 20 "always_wrong.mp3 0a 00
@fill-icn [ ffff ffff ffff ffff ]
@cmd2 "pause 0a 00
@dash-icn [ 0000 00aa 0000 0000 ]
@dict &home-path "./ $1
&mp3-ext "mp3 $1
&empty "(empty) $1
~src/assets.tal