From eb6236b389157fb5b80d73dd99f893af5413d08c Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 13 Oct 2021 00:24:54 -0600 Subject: [PATCH] add load-cart function --- uxn-client/xrxs.tal | 59 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/uxn-client/xrxs.tal b/uxn-client/xrxs.tal index 185645f..4ba266d 100644 --- a/uxn-client/xrxs.tal +++ b/uxn-client/xrxs.tal @@ -58,7 +58,6 @@ @sb-step $1 @cart $32 -@realm $32 ( program ) @@ -223,7 +222,6 @@ BRK POP BRK &state6 POP - BRK @clear-screen ( -> ) @@ -725,7 +723,7 @@ BRK ( A on yes ) .btn-state LDZ #01 NEQ ,&a-on-no JCN ;capture-input JSR2 - #06 .state STZ + ;load-cart JSR2 BRK &a-on-no .btn-state LDZ #00 NEQ ,&no-action JCN @@ -774,7 +772,7 @@ BRK BRK &state-load ;capture-input JSR2 - #06 .state STZ + ;load-cart JSR2 &no-click BRK @@ -836,6 +834,54 @@ RTN RTN +@load-cart ( -> ) + &lines #00 + &chars #00 + + .list-len LDZ2 #0000 &while EQU2k ,&end JCN + ( find the cartridge that matches our select-index ) + DUP ;list-buf ADD2 LDA + #0a NEQ ,&no-newline JCN + ,&lines LDR INC ,&lines STR + &no-newline + ,&lines LDR .select-index LDZ NEQ ,&while JCN + DUP2 + ( store characters for this cartridge ) + #20 #00 &getchar EQU2k ,&end-getchar JCN + STHk SWP2 ;list-buf ADD2 LDA + DUP #00 EQU ,&name-copied JCN + SWP .cart ADD STZ + ,&chars LDR INC ,&chars STR + STHr + INC ,&getchar JMP &end-getchar POP2 + INC ,&while JMP &end POP2 POP2 RTN + + ( append the null byte and clear the stacks ) + &name-copied + #00 .cart ,&chars LDR INC ADD STZ + POPr POP2 POP2 POP2 + + ( append the cartridge name to the load command ) + ;load-cmd #0005 ADD2 + ,&chars LDR #00 &compose-cmd EQUk ,&compose-done JCN + TOS SWP2 ADD2k ROT2 TOB + DUP STH .cart ADD LDZ + TOS SWP2 STA POP + ROT STHr + INC ,&compose-cmd JMP &compose-done POP2 POP2 + + ( send it! ) + #0020 .File/length DEO2 + #0001 .File/offset-ls DEO2 + ;ctl-file .File/name DEO2 + ;load-cmd .File/save DEO2 + + #0000 .File/offset-ls DEO2 + ;slot-file .File/name DEO2 + LIT 0000 .File/load DEO2 + LIT 0100 JMP2 +RTN + @capture-input ( -> ) ;no-instr .Mouse/vector DEO2 @@ -849,9 +895,14 @@ RTN @spritesheet "xrxs.chr 00 @fontsheet "zz.chr 00 @carts-file "n/carts 00 +@slot-file "n/slot 00 +@ctl-file "n/ctl 00 + @title-loadCart "Select 20 "A 20 "Cartridge 00 @title-confirmCart "Load 20 "This 20 "Cartridge? 00 +@load-cmd "load 20 $32 + ( sprites ) @blank $16 @uxn-logo $256