From d21141cb06419c2eb0fd1b5129053bf8a3dbca4d Mon Sep 17 00:00:00 2001 From: nihilazo Date: Mon, 26 Apr 2021 13:22:10 +0100 Subject: [PATCH 1/2] stuff, but it's borked --- main.fs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/main.fs b/main.fs index 6d384a9..8f89eb2 100644 --- a/main.fs +++ b/main.fs @@ -58,6 +58,13 @@ variable screen \ variable screens contains the highest unlocked screen number. variable screens 0 screens ! +\ variable searchspeed is the speed of going metal detecting (per tick). When it reaches 1000, it's done. +variable searchspeed +10 searchspeed ! +\ variable searchprogress is the progress through metal detecting. It has an update flag. +create searchprogress 0 , 0 , +\ variable searching is true if metal detecting is in progress. + \ message contains a string message which is printed on the screen. \ because forth is weird, strings can be stored in variables but it's easier to just store them someplace else and then store that address and the string's length in the variable (this is what S" " does and what "type" expects) create message 0 , 0 , 0 , @@ -73,9 +80,9 @@ S" you feel like throwing some stuff into the pool." set-message : f+! ( addr -- ) ( F: r -- ) dup f@ f+ f! ; \ any-change? leaves a -1 on the stack if any value has changed, 0 otherwise -: any-change? ( -- flag ) membercost 1 changed? devices 2 changed? message 2 changed? or or ; +: any-change? ( -- flag ) membercost 1 changed? devices 2 changed? message 2 changed? searchprogress 1 changed? or or or ; \ clear-all clears the change flag on all values. -: clear-all membercost 1 cleared devices 2 cleared message 2 cleared ; +: clear-all membercost 1 cleared devices 2 cleared message 2 cleared searchprogress 1 cleared ; \ the word !0= tests if something is non-zero : !0= ( n -- flag ) 0= 0= ; \ the word f!0= tests if a floating thing is non-zero @@ -173,6 +180,8 @@ S" you feel like throwing some stuff into the pool." set-message 1 screens +! then page ; +\ the word metal-detect goes metal detecting! +: metal-detect ; \ TODO stub \ DEBUGGING STUFF \ the word debug-console is used for entering debug mode. @@ -213,7 +222,10 @@ S" you feel like throwing some stuff into the pool." set-message endcase ; \ the word garden-input contains the input cases specifically for the garden -: garden-input ; \ TODO stub +: garden-input + case + [char] m of metal-detect endof + endcase ; \ TODO stub \ the word handle-input handles input every time around the game loop. : handle-input @@ -256,16 +268,15 @@ S" you feel like throwing some stuff into the pool." set-message \ draw-tab draws a single tab for a screen : draw-tab ( i -- ) dup screen @ = if - ." >" bl - drop then draw-screen-name ; + ." >" bl then draw-screen-name ; -\ draw-tab-bar draws the tab bar. TODO make this into smaller words +\ draw-tab-bar draws the tab bar. TODO something here seems to be clobbering the stack : draw-tab-bar ( x y -- x y ) 2dup at-xy clear-line screens @ if \ 0 is false in forth, so if the number of screens is zero, don't draw the bar. screens @ 1+ 0 do - i dup draw-tab + i draw-tab loop inc-y draw-tab-keys draw-tab-devices From 9f0724e1bc765b7bc07c04c4af578c5aba411dbd Mon Sep 17 00:00:00 2001 From: nihilazo Date: Tue, 27 Apr 2021 13:55:21 +0100 Subject: [PATCH 2/2] fix bar issues --- main.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.fs b/main.fs index 8f89eb2..ab687f1 100644 --- a/main.fs +++ b/main.fs @@ -268,7 +268,7 @@ S" you feel like throwing some stuff into the pool." set-message \ draw-tab draws a single tab for a screen : draw-tab ( i -- ) dup screen @ = if - ." >" bl then draw-screen-name ; + ." >" else space then draw-screen-name ; \ draw-tab-bar draws the tab bar. TODO something here seems to be clobbering the stack : draw-tab-bar ( x y -- x y )