From c5862961398e83d58ed9c19aab33ad581f7ec895 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 2 Sep 2021 11:03:18 -0600 Subject: [PATCH] trying to list cartridges, fixed an errant MAX_USERS where it wasn't welcome --- server/universe.h | 2 +- uxn-client/build.sh | 5 +++ uxn-client/cart_select_notes.md | 18 ++++++++ uxn-client/n/carts | 6 +++ uxn-client/xrxs.tal | 76 +++++++++++++++++++++++++++------ 5 files changed, 93 insertions(+), 14 deletions(-) create mode 100755 uxn-client/build.sh create mode 100644 uxn-client/cart_select_notes.md create mode 100644 uxn-client/n/carts diff --git a/server/universe.h b/server/universe.h index 6952973..2bee2da 100644 --- a/server/universe.h +++ b/server/universe.h @@ -4,7 +4,7 @@ typedef struct Atom Atom; struct Atom { char name[16]; - char value[MAX_USERS]; + char value[64]; Atom* next; }; diff --git a/uxn-client/build.sh b/uxn-client/build.sh new file mode 100755 index 0000000..e12f17c --- /dev/null +++ b/uxn-client/build.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +rm xrxs.rom 2>/dev/null +uxnasm xrxs.tal xrxs.rom +uxnemu xrxs.rom \ No newline at end of file diff --git a/uxn-client/cart_select_notes.md b/uxn-client/cart_select_notes.md new file mode 100644 index 0000000..fe90ff2 --- /dev/null +++ b/uxn-client/cart_select_notes.md @@ -0,0 +1,18 @@ +# how to render lists + +1. start at top of list area +2. seek until ;list-offset \n have been read +3. drawstr until \n (if y index is hihglihgt index, draw highlighted) +4. increment y and reset x +5. if y > height/8 - 80, break + +# how to highlight list elements + +1. if .Mouse/x > 64 && < width - 64 && .Mouse/y > 40 && < height - 40 +2. index = ((.Mouse/y - 40)/8) + ;list-offset + +# on click + +1. take highlight index +2. seek listbuf until as many \n have been read +3. read until next \n into loadcmdbuf + len(load ) diff --git a/uxn-client/n/carts b/uxn-client/n/carts new file mode 100644 index 0000000..48acf85 --- /dev/null +++ b/uxn-client/n/carts @@ -0,0 +1,6 @@ +nasu +dexe +noodle +orca +left + diff --git a/uxn-client/xrxs.tal b/uxn-client/xrxs.tal index 8db5f7c..ee8d73e 100644 --- a/uxn-client/xrxs.tal +++ b/uxn-client/xrxs.tal @@ -29,7 +29,7 @@ |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 $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] +|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 ) @@ -45,6 +45,9 @@ &y $2 ] +@list-offset $1 +@list-elem $32 + @cart $32 @realm $32 @@ -58,20 +61,23 @@ #02cd .System/g DEO2 #02cb .System/b DEO2 + ( load uxn and xrxs logos from main spritesheet ) ;spritesheet .File/name DEO2 #0100 .File/length DEO2 - #0000 .File/offset DEO2 + #0000 .File/offset-ls DEO2 ;uxnlogo .File/load DEO2 - #0200 .File/offset DEO2 + #0200 .File/offset-ls DEO2 ;xrxslogo .File/load DEO2 + ( load zz font ) ;fontsheet .File/name DEO2 - #0000 .File/offset DEO2 + #0000 .File/offset-ls DEO2 #0300 .File/length DEO2 ;font .File/load DEO2 + ( initialize state ) #00 .ticker STZ #00 .state STZ #20 .anim-speed STZ @@ -126,11 +132,14 @@ BRK ;draw-xrxs-logo-xr JSR2 ;draw-xrxs-logo-xs JSR2 .logo-coords/x LDZ2 #0020 GTH2 ,&keep-state JCN + ;cartlist .File/name DEO2 + #2000 .File/length DEO2 + ;listbuf .File/load DEO2 #01 ADD .state STZ BRK &keep-state POP BRK - ( render the logo and window decorations ) + ( render the cartridge list interface ) &state4 DUP #04 NEQ ,&state5 JCN ;draw-gray-borders JSR2 ;draw-bl-scanlines JSR2 @@ -144,6 +153,7 @@ BRK CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2 #0010 #02 ] ;draw-string JSR2 + ;render-cart-list JSR2 ;draw-pointer JSR2 POP BRK @@ -359,17 +369,27 @@ RTN .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 - .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 - #0001 ADD2 - LDAk #00 NEQ ,&loop JCN - POP2 - POPr + &loop + LDAk DUP #00 NEQ #20 MUL SUB TOS 8** ;font ADD2 .Screen/addr DEO2 + STHkr .Screen/sprite DEO + .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + #0001 ADD2 + LDAk #00 NEQ ,&loop JCN + POP2 + POPr RTN +@draw-char ( char x y color -- ) + + STH ( save color ) + .Screen/y DEO2 ( set y ) + .Screen/x DEO2 ( set x ) + + #20 MUL SUB TOS 8** ;font ADD2 .Screen/addr DEO2 + STHr .Screen/sprite DEO +RTN + @strlen ( addr -- len ) DUP2 @@ -379,6 +399,33 @@ RTN RTN +@render-cart-list ( -> ) + + #0040 .Screen/x DEO2 + #0028 .Screen/y DEO2 + + &lines $1 + ,&lines #00 STZ + + #2000 #0000 &while EQU2k ,&end JCN + DUP2 ;listbuf ADD2 LDA ( get a character from the list ) + DUP #00 NEQ ,&terminate JCN + DUP #0a NEQk ,&no-inc-line JCN + [ ( char ) + .Screen/x DEI2 + .Screen/y DEI2 + #02 ] ;draw-char JSR2 + ,&lines LDR INC ,&lines STR + INC-Y + #0040 .Screen/x DEO2 + &no-inc-line INC-X + OVR EQU ,&no-store-char JCN + OVR2 ;list-elem ADD2k OVR2 NIP2 NIP STZk + &no-store-char + INC2 ,&while JMP &end POP2 POP2 RTN + &terminate POP2 POP2 POP2 +RTN + ( constants ) @spritesheet "xrxs.chr 00 @fontsheet "zz.chr 00 @@ -392,3 +439,6 @@ RTN @pointer_icn [ 80c0 e0f0 f8e0 1000 ] @font $768 +( big data ) +@listbuf $8192 +