From e2524d43369fb8c0834d4c1bf2f9b6b2cfb57a0e Mon Sep 17 00:00:00 2001 From: neauoire Date: Fri, 27 Aug 2021 14:01:22 -0700 Subject: [PATCH] Started implementing create --- README.md | 6 +-- src/font.tal | 2 - src/main.tal | 126 +++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 101 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index e7601c0..10e69fb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ In Paradise, you are but a force acting upon places, objects, words — vessels. You must have the [Uxn](https://git.sr.ht/~rabbits/uxn/) assembler and emulator. -``` +```sh +cat src/main.tal src/font.tal > src/parade.tal uxnasm parade.tal parade.rom && uxnemu parade.rom ``` @@ -37,7 +38,6 @@ tcc parade.c -o parade - **note** this place is dark. - **program** create a sound - **use** the machine +- **learn** to become ## Save/Load - -To save a world, use `@save filename.txt`, to load `@load filename.txt`, to quit `@quit`. You can learn more about Parade [here](https://wiki.xxiivv.com/site/parade.html). diff --git a/src/font.tal b/src/font.tal index fc5eeec..4675600 100644 --- a/src/font.tal +++ b/src/font.tal @@ -1697,5 +1697,3 @@ 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 - -@world diff --git a/src/main.tal b/src/main.tal index 03444d2..5e960a9 100644 --- a/src/main.tal +++ b/src/main.tal @@ -2,6 +2,7 @@ TODO - Reflect vessel name in headerview - Blink cursor + - Theme ) %+ { ADD } %- { SUB } @@ -28,6 +29,10 @@ %BRK? { #01 JCN BRK } %SWP? { #01 JCN SWP } +%GET-NAME { 20** ;world/vessels ++ } ( id* -- addr* ) +%GET-MAKER { 20** ;world/vessels ++ #001c ++ LDA2 } ( id* -- addr* ) +%GET-PARENT { 20** ;world/vessels ++ #001e ++ LDA2 } ( id* -- addr* ) + %DEBUG { ;print-hex JSR2 #0a .Console/write DEO } %DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO } @@ -46,22 +51,14 @@ |0000 -@ghost - &vessel - +@ghost $2 @input-field $32 - @headerview - &x $2 - &y $2 - + &x $2 &y $2 @bodyview - &x $2 - &y $2 - + &x $2 &y $2 @inputview - &x $2 - &y $2 + &x $2 &y $2 ( program ) @@ -80,10 +77,9 @@ #0040 #0080 .bodyview/y STZ2 .bodyview/x STZ2 #0040 #00f0 .inputview/y STZ2 .inputview/x STZ2 - ( draw label ) - .bodyview/x LDZ2 .bodyview/y LDZ2 ;text-buffer #01 ;draw-uf2 JSR2 - .inputview/x LDZ2 #0010 -- .inputview/y LDZ2 ;prompt-txt #03 ;draw-uf2 JSR2 - .headerview/x LDZ2 .headerview/y LDZ2 ;headerview-txt #01 ;draw-uf3 JSR2 + ( select starting vessel ) + ;init-world JSR2 + ;redraw JSR2 BRK @@ -109,6 +105,42 @@ BRK BRK +@init-world ( -- ) + + ;&library-txt ;create-vessel JSR2 + ;&ghost-txt ;create-vessel JSR2 + ( select ghost ) #0001 .ghost STZ2 + ;&teapot-txt ;create-vessel JSR2 + +RTN + &library-txt "glittering 20 "snake $1 + &ghost-txt "ruby 20 "slipper $1 + &teapot-txt "teapot $1 + +@create-vessel ( name* -- ) + + ( get addr* ) + ;world/vessels [ ;world/length LDA2 20** ] ++ STH2k + + ( name ) + ;scpy JSR2 + ( makership ) + ( get maker ) .ghost LDZ2 + ( set maker ) STH2kr #001c ++ STA2 + ( parenting ) + ( get parent ) .ghost LDZ2 GET-PARENT + ( set parent ) STH2r #001e ++ STA2 + + ( debug ) + ;world/length LDA2 + DUP2 GET-NAME ;print-string JSR2 + DUP2 GET-MAKER DEBUG2 + GET-PARENT DEBUG2 + + ( incr length ) ;world/length LDA2 INC2 ;world/length STA2 + +RTN + ( Input ) @input-validate ( -- ) @@ -167,10 +199,11 @@ RTN @do ( input* -- ) &create ( input* -- ) - ;print-string JSR2 - ;you-said-txt ;text-buffer ;scpy JSR2 - ;input-field ;text-buffer ;scat JSR2 - #aa DEBUG + STH2k ;create-vessel JSR2 + ;you-created-the-txt ;text-buffer ;scpy JSR2 + STH2r ;text-buffer ;scat JSR2 + LIT '. ;text-buffer ;ccat JSR2 + ;input-validate/end JMP2 BRK @@ -233,7 +266,6 @@ RTN ;input-validate/end JMP2 BRK - &unknown ( input* -- ) POP2 #ee DEBUG ;input-validate/end JMP2 @@ -241,7 +273,22 @@ RTN RTN -( Generics ) +( Drawing ) + +@redraw ( -- ) + + ( header ) + ;you-are-the-txt ;text-buffer ;scpy JSR2 + .ghost LDZ2 STH2k GET-NAME ;text-buffer ;scat JSR2 + ;in-the-txt ;text-buffer ;scat JSR2 + STH2r GET-PARENT GET-NAME ;text-buffer ;scat JSR2 + .headerview/x LDZ2 .headerview/y LDZ2 ;text-buffer #01 ;draw-uf3 JSR2 + + + .bodyview/x LDZ2 .bodyview/y LDZ2 ;text-buffer #01 ;draw-uf2 JSR2 + .inputview/x LDZ2 #0010 -- .inputview/y LDZ2 ;prompt-txt #03 ;draw-uf2 JSR2 + +RTN @draw-uf2 ( x* y* text* color -- ) @@ -299,7 +346,7 @@ RTN &loop LDAk #0a !~ ,&no-linebreak JCN - ( move down ) STH OVR2 #0008 -- .Screen/x DEO2 STHr + ( move down ) STH OVR2 .Screen/x DEO2 STHr ( incr y ) .Screen/y DEI2 #0018 ++ .Screen/y DEO2 POP INC2 ,&loop JMP &no-linebreak STHkr ,&sprite JSR @@ -363,7 +410,7 @@ RTN &continue STHkr NEQ ,&loop JCN POPr - ( compare ) SWP2 SUB2 + ( compare ) SWP2 -- RTN @@ -409,10 +456,10 @@ RTN STH2 DUP2 &while - SWP2k SUB2 STH2kr ADD2 STH2 + SWP2k -- STH2kr ADD2 STH2 LDAk STH2r STA INC2 LDAk ,&while JCN - SWP2 SUB2 STH2r ADD2 + SWP2 -- STH2r ADD2 #00 ROT ROT STA RTN @@ -422,7 +469,7 @@ RTN #0001 -- DUP2 &while INC2 LDAk ,&while JCN - SWP2 SUB2 + SWP2 -- #0001 -- RTN @@ -460,6 +507,16 @@ RTN RTN &a $2 &b $2 +@ccat ( char dst* -- ) + + #0001 -- + &while + INC2 LDAk ,&while JCN + STH2k STA + #00 STH2r INC2 STA + +RTN + ( lookup table ) @actions @@ -478,11 +535,24 @@ RTN @word1 "foo $1 @word2 "bar $1 +( header text ) +@you-are-the-txt "You 20 "are 20 "the 20 $1 +@in-the-txt 0a "in 20 "the 20 $1 +@you-created-the-txt "You 20 "created 20 "the 20 $1 + @prompt-txt "> $1 -@you-said-txt "you 20 "said: 20 $1 @unknown-txt "Unknown 20 "command. $1 @headerview-txt "You 20 "are 20 "a 20 "ghost 0a 20 "in 20 "the 20 "library. $1 +( char id, name[NAMELEN], note[TEXTLEN], prog[TEXTLEN]; ) + +( NAME--------------------OWNRPRNT ) + +@world + &length $2 + &vessels ( 0x20 bytes per vessel ) + ( pad ) $100 + @text-buffer $100