From 7f8f254a745300c61f487273dec3597d46b8a2e7 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 14 Oct 2021 22:03:18 -0600 Subject: [PATCH] client is WORKING! move server data dir to somewhere in /opt --- server/config.h | 2 +- uxn-client/xrxs.tal | 209 +++++++++++++++++++++++++++++++++----------- 2 files changed, 157 insertions(+), 54 deletions(-) diff --git a/server/config.h b/server/config.h index e9e5dd9..5b47aa3 100644 --- a/server/config.h +++ b/server/config.h @@ -2,4 +2,4 @@ #define MAX_USERS 64 /* Path to cart/realm storage (must include trailing slash) */ -#define DATA_DIR "/home/nilix/src/9/xrxs/server/carts/" +#define DATA_DIR "/opt/xrxs/carts/" diff --git a/uxn-client/xrxs.tal b/uxn-client/xrxs.tal index 4ba266d..9444c7b 100644 --- a/uxn-client/xrxs.tal +++ b/uxn-client/xrxs.tal @@ -22,7 +22,7 @@ |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 ] +|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 ] |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 ] @@ -57,7 +57,7 @@ @sb-pos $1 @sb-step $1 -@cart $32 +@cart-len $1 ( program ) @@ -122,6 +122,11 @@ #ff .btn-state STZ GET-USABLE-HEIGHT .list-height STZ + ;carts-file .File/name DEO2 + #2000 .File/length DEO2 + ;list-buf .File/load DEO2 + .File/success DEI2 .list-len STZ2 + CENTER-X .logo-coords/x STZ2 CENTER-Y .logo-coords/y STZ2 @@ -171,10 +176,7 @@ BRK ;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 @@ -221,7 +223,12 @@ BRK ;draw-pointer JSR2 POP BRK - &state6 POP + &state6 + [ ;load-cmd + CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2 + CENTER-Y #0004 SUB + #02 ] ;draw-string JSR2 + POP BRK @clear-screen ( -> ) @@ -489,7 +496,20 @@ RTN ,&while JMP &end RTN - + + +@draw-cart-name ( -> ) + + ;get-entry-color JSR2 #0c NEQ ,&no-store-cart JCN + ;store-cart JSR2 + &no-store-cart + [ ;word + .Screen/x DEI2 + .Screen/y DEI2 + ;get-entry-color JSR2 ] ;draw-string JSR2 + ;finish-line JSR2 + +RTN @render-cart-list ( -> ) @@ -516,11 +536,7 @@ RTN #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 + ;draw-cart-name JSR2 #0040 .Screen/x DEO2 INC-Y &no-draw @@ -535,6 +551,18 @@ RTN RTN +@store-cart ( -> ) + + #20 #00 &while EQUk ,&end JCN + DUP TOS ;word ADD2 LDA + + SWP DUP TOS ;cart ADD2 + ROT STH STA + STHr + INC ,&while JMP &end POP2 + RTN +RTN + @get-entry-color ( -- colorByte ) .list-offset LDZ @@ -835,53 +863,127 @@ 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! ) + .state LDZ INC .state STZ + + ( 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 + ;slot-file ;load-rom JSR2 RTN +@load-rom ( filename* -- ) +( + Attempts to load the ROM from filename* and executes it. If the file exists + and has non-zero length, this function does not return, because the new ROM + is executing in its place. + + The screen and both stacks are cleared and all the device vectors are + written to zero as a convenience. All other device bytes are left + untouched, so they could introduce a device state to the next ROM that + it's not expecting. +) + + .File/name DEO2 + #0000 .File/offset-hs DEO2 + #0000 .File/offset-ls DEO2 + + ( return if file can't be found, or zero length ) + #0001 .File/length DEO2 + ;&tmp .File/load DEO2 + .File/success DEI2 ORA JMP JMP2r + + ( clear wst ) + #ab + &wst-loop + POP + .System/wst STH DEIr STHr ,&wst-loop JCN + + ( clear rst ) + LITr ab + &rst-loop + POPr + .System/rst DEI ,&rst-loop JCN + + ( clear screen ) + #01 .Screen/auto DEO + #0000 .Screen/y DEO2 + .Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2 + &screen-yloop + #0000 .Screen/x DEO2 + STH2kr + &screen-xloop-bg + #00 .Screen/sprite DEO + INC2 + ORAk ,&screen-xloop-bg JCN + POP2 + #0000 .Screen/x DEO2 + STH2kr + &screen-xloop-fg + #40 .Screen/sprite DEO + INC2 + ORAk ,&screen-xloop-fg JCN + POP2 + .Screen/y DEI2 #0008 ADD2 + DUP2 .Screen/y DEO2 + .Screen/height DEI2 LTH2 ,&screen-yloop JCN + POP2r + #00 .Screen/auto DEO + + ( reset device vectors ) + LIT2r 0000 #00 + &device-vector-loop + DUP2r STHk DEO2r + #10 ADD + DUP ,&device-vector-loop JCN + 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 (carry on) ) + DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) ) + OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) ) + OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) ) + OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) ) + OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 ) + STHkr ( first argument for ADD2 ) + .File/success ( argument for DEI2 ) + #0100 .File/load ( 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 + @capture-input ( -> ) ;no-instr .Mouse/vector DEO2 @@ -901,7 +1003,8 @@ RTN @title-loadCart "Select 20 "A 20 "Cartridge 00 @title-confirmCart "Load 20 "This 20 "Cartridge? 00 -@load-cmd "load 20 $32 +@load-cmd "load 20 +@cart $32 ( sprites ) @blank $16