From 35c9e14773122c348781da13e51261e701f2e7b7 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 22 Feb 2024 15:03:36 -0800 Subject: [PATCH] Use better loader --- src/assets.tal | 68 ++++++++++++++++++++++++++++++++++++++++++++++--- src/desktop.tal | 5 +++- src/potato.tal | 10 +++----- 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/assets.tal b/src/assets.tal index 36bd233..466ba2a 100644 --- a/src/assets.tal +++ b/src/assets.tal @@ -35,6 +35,70 @@ "Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1 "Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1 &no-metadata "Metadata 20 "Missing $1 + &oversize-rom "File 20 "Too 20 "Large $1 + +( +@|launcher ) + +@load-rom ( filename* -- ) + .File/name DEO2 + ( clear wst/rst ) + #0000 .System/wst DEO2 + ( clear screen ) + #0000 DUP2 .Screen/x DEO2 .Screen/y DEO2 + [ LIT2 80 -Screen/pixel ] DEO + [ LIT2 c0 -Screen/pixel ] DEO + ( reset device vectors ) + [ LIT2r 0000 ] + #00 + &device-vector-loop + DUP2r STHk DEO2r + #10 ADD + DUP ?&device-vector-loop + POP POP2r + ( copy the zero-page-loader into f0-ff ) + ;&zero-page-loader LITr f0 + ©-loop + LDAk STHkr STZ + INC2 INCr + STHkr ,©-loop JCN + POP2 ( leave 00 on return stack ) + + ( prepare the stack for the zero-page-loader ) + ( the more we prepare here in advance, the less we'll have to overwrite ) + STHkr #00fe ( arguments for STZ2 at ff ) + STHkr ( argument for JMP at fe ) + DUPk #fcfe ( arguments for STZ2 at fd and JMP ) + OVR2 #fafe ( arguments for STZ2 at fd and JMP ) + OVR2 #f8fe ( arguments for STZ2 at fd and JMP ) + OVR2 #f6fe ( arguments for STZ2 at fd and JMP ) + OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 ) + STHkr ( first argument for ADD2 ) + .File/success ( argument for DEI2 ) + #0100 .File/read ( arguments for DEO2 ) + #ff00 .File/length DEO2 + #00f0 JMP2 + + &zero-page-loader + ( f0 ) DEO2 + ( f1 ) DEI2 + ( f2 ) ADD2 + ( f3 ) &loop DUPr + ( f4 ) STH2k + ( f5 ) STAr + ( f6 ) INC2 + ( f7 ) NEQ2k + ( f8 ) ,&loop + ( f9 ) + ( fa ) JCN + ( fb ) POPr + ( fc ) POP2 + ( fd ) STZ2 ( deletes f4-fd through looping ) + ( fe ) JMP + ( ff ) STZ2 ( deletes fe-ff ) + + &tmp $1 + ( icn ) @@ -363,10 +427,6 @@ c060 3018 0c06 0300 3c0c 0c0c 0c0c 3c00 ( @|blobs ) -@loader-rom - 8000 8000 0711 0106 20ff f702 a001 00af - 80ac 37a0 ffd5 80a2 36ef 38af 8000 6f15 - 21aa 20ff f622 226f 2c00 @notes 30 32 34 35 37 39 3b 3c diff --git a/src/desktop.tal b/src/desktop.tal index 4998662..c26bb1e 100644 --- a/src/desktop.tal +++ b/src/desktop.tal @@ -1,3 +1,5 @@ + + @size-desktop-start @@ -173,7 +175,8 @@ ;app-option/target STA2 DUP2 ;app-option/action STA2 ;app-option #1807 #0000 DUP2 add-win !center-win -( TODO ) $10 + ( TODO ) $10 + @add-win ( name* app* h w y* x* -- ) .length LDZ #0f LTH ?{ ( limit ) POP2 POP2 POP2 POP2 POP2 JMP2r } diff --git a/src/potato.tal b/src/potato.tal index a38c455..19ecaa7 100644 --- a/src/potato.tal +++ b/src/potato.tal @@ -1,6 +1,6 @@ ( a potato. ) -|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 +|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 &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 |30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 @@ -251,15 +251,13 @@ ( x ) .Screen/width DEI2 #00c0 SUB2 !add-win @open-rom ( file* -- ) + LDAk LIT "? EQU ?&err ;load-rom-callback/src STA2 ;load-rom-callback ! + &err #0005 ADD2 ;dict/oversize-rom SWP2 !add-err @load-rom-callback ( file* -- ) - [ LIT2 &src $2 ] #0005 ADD2 make-src .File/name DEO2 - #fe00 .File/length DEO2 - ;loader-rom #ffd6 #0029 - - POP2r #ffd6 JMP2 + [ LIT2 &src $2 ] #0005 ADD2 make-src !load-rom ( @|animation ) -- 2.45.2