diff --git a/gui/lander/lander.tal b/gui/lander/lander.tal index b9b2efc..a3ae59e 100644 --- a/gui/lander/lander.tal +++ b/gui/lander/lander.tal @@ -6,12 +6,15 @@ |30 @Audio0 &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 +|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |0000 @pos &x $2 &y $2 @force &x $2 &y $2 @angle $2 + @stage + &w $1 &h $1 &id $2 |0100 ( -> ) @@ -20,14 +23,19 @@ #0f0f .System/g DEO2 #0f0f .System/b DEO2 ( resize ) - #0200 .Screen/width DEO2 - #0160 .Screen/height DEO2 + #0260 .Screen/width DEO2 + #01a0 .Screen/height DEO2 ( vectors ) ;on-frame .Screen/vector DEO2 ;on-control .Controller/vector DEO2 + prng-init + ( get stage ) + .Screen/width DEI2 #03 SFT2 NIP .stage/w STZ + .Screen/height DEI2 #03 SFT2 NIP .stage/h STZ #0100 .pos/x STZ2 #00a0 .pos/y STZ2 + set-terrain redraw BRK @@ -40,16 +48,16 @@ BRK [ LIT &f $1 ] INCk ,&f STR #01 AND ?&no-read .Controller/button DEI - DUP #10 NEQ ?&no-u + DUP #10 AND #00 EQU ?&no-u .angle LDZ2 thruster &no-u - DUP #20 NEQ ?&no-d + DUP #20 AND #00 EQU ?&no-d #0010 .force/y STZ2 &no-d - DUP #40 NEQ ?&no-l + DUP #40 AND #00 EQU ?&no-l .angle LDZ2 #0001 SUB2 #001f AND2 .angle STZ2 &no-l - DUP #80 NEQ ?&no-r + DUP #80 AND #00 EQU ?&no-r .angle LDZ2 INC2 #001f AND2 .angle STZ2 &no-r POP @@ -58,6 +66,7 @@ BRK apply-force ( .force/y LDZ2 phex #0a18 DEO ) redraw + draw-stage BRK @@ -81,7 +90,6 @@ BRK DUP #80 AND #00 NEQ STH #ff00 STHr [ JMP SWP POP ] SWP reduce3 .force/y LDZ2 ADD2 .force/y STZ2 - #08 ;draw-lander/plume STA JMP2r @@ -115,6 +123,53 @@ JMP2r JMP2r &neg abs2 #05 SFT2 #0000 SWP2 SUB2 JMP2r +( +@|terrain ) + +@set-terrain ( -- ) + + .stage/w LDZ INC INC #00 + &loop + ( height/2 ) .stage/h LDZ #01 SFT + ( rand ) prng #0a SFT2 NIP ADD #01 SFT + ( v offset ) #10 ADD + ( store ) OVR #00 SWP ;terrain ADD2 STA + INC GTHk ,&loop JCN + POP2 + ( soften ) + #0800 + &loop-soften + soften + INC GTHk ?&loop-soften + POP2 + +JMP2r + +@soften ( -- ) + + .stage/w LDZ #00 + &loop2 + ( a ) #00 OVR ;terrain ADD2 LDA STH + ( b ) #00 OVR INC ;terrain ADD2 LDA STH + ( c ) #00 OVR INC INC ;terrain ADD2 LDA STH + #00 STHr #00 STHr ADD2 #00 STHr ADD2 #0003 DIV2 NIP + ( store ) OVR #00 SWP ;terrain ADD2 STA + INC GTHk ,&loop2 JCN + POP2 + +JMP2r + +@create-platform ( x -- height ) + + #01 SUB + #00 SWP ;terrain ADD2 DUP2 + ( average ) LDAk STH INC2 LDAk STH INC2 ADDr LDAk STH INC2 ADDr LDA STH ADDr + LITr 04 DIVr + ( flatten ) STHkr ROT ROT STAk INC2 STAk INC2 STAk INC2 STA + STHr + +JMP2r + ( @|drawing ) @@ -141,7 +196,7 @@ JMP2r [ LIT2r &plume $1 09 ] ADDr #0e08 get-pt #1208 get-pt #02 draw-line #0e08 get-pt #10 STHkr get-pt #02 draw-line - #1208 get-pt #10 STHr get-pt #02 draw-line + #1208 get-pt #10 STHr get-pt #02 draw-line ( face ) #26 .Screen/auto DEO ;face-icn .Screen/addr DEO2 @@ -152,17 +207,29 @@ JMP2r JMP2r +@draw-stage ( color -- ) + + ( x ) #0000 .Screen/x DEO2 + .stage/w LDZ #00 + &loop + STHk + ( a ) + #00 OVR #30 SFT2 + #00 STHr ;terrain ADD2 STH2k LDA #01 SUB #00 SWP #30 SFT2 + ( b ) + OVR2 #0008 ADD2 + STH2r INC2 LDA #01 SUB #00 SWP #30 SFT2 + #43 draw-line + INC GTHk ?&loop + POP2 + +JMP2r + @get-pt ( id rad -- x* y* ) #00 SWP STH2 .angle LDZ2 #001f AND2 NIP ADD -!get-point/force - -@get-point ( id -- x* y* ) - - [ LIT2r &radius $2 ] - &force #1f AND DUP ADD #00 SWP ;circle-tbl ADD2 LDA2 #00 SWP STH2kr MUL2 #04 SFT2 @@ -208,6 +275,33 @@ JMP2r JMP2r +( +@|prng ) + +@prng-init ( -- ) + + ( seed ) + #00 .DateTime/second DEI + #00 .DateTime/minute DEI #60 SFT2 EOR2 + #00 .DateTime/hour DEI #c0 SFT2 EOR2 ,prng/x STR2 + #00 .DateTime/hour DEI #04 SFT2 + #00 .DateTime/day DEI #10 SFT2 EOR2 + #00 .DateTime/month DEI #60 SFT2 EOR2 + .DateTime/year DEI2 #a0 SFT2 EOR2 ,prng/y STR2 + +JMP2r + +@prng ( -- number* ) + + LIT2 &x $2 + DUP2 #50 SFT2 EOR2 + DUP2 #03 SFT2 EOR2 + LIT2 &y $2 DUP2 ,&x STR2 + DUP2 #01 SFT2 EOR2 EOR2 + ,&y STR2k POP + +JMP2r + ( @|stdlib ) @@ -234,3 +328,5 @@ JMP2r 80ff 67fd 4ff6 38ea 25da 15c7 09b0 0298 0080 0267 094f 1538 2525 3815 4f09 6702 ] +@terrain +