still workinge

This commit is contained in:
~d6 2022-01-18 23:51:43 -05:00
parent ce675833cc
commit 9db3b38e46
1 changed files with 19 additions and 6 deletions

View File

@ -14,17 +14,20 @@
%EMIT { #18 DEO }
%SPACE { #20 EMIT }
%NEWLINE { #0a EMIT }
%ITERATIONS { #0100 }
%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }
%DEC { #01 SUB }
%DEC2 { #0001 SUB2 }
%NEGATE2 { #ffff MUL2 }
( TODO: once the dimensions are finalized inline constants )
%ROWS { #0027 } ( rows of cells )
%COLS { #003f } ( columns of cells )
%MAZEROWS { ROWS #0003 SUB2 #0002 DIV2 }
%MAZECOLS { COLS #0003 SUB2 #0002 DIV2 }
( %MAZEROWS { ROWS INC2 #0002 DIV2 }
%MAZECOLS { COLS INC2 #0002 DIV2 } )
%NORTH { COLS NEGATE2 }
%EAST { #0001 }
%SOUTH { COLS }
@ -38,6 +41,10 @@
%UNSEEN { LOAD #02 AND #00 EQU } ( cell* -> bool^ )
%PATH { ADD2 #0002 DIV2 } ( cell1* cell2* -> cell3* )
%DIGIT { #00 SWP ;digits ADD2 LDA EMIT }
%EMIT-BYTE { DUP #04 SFT DIGIT #0f AND DIGIT }
%EMIT-SHORT { SWP EMIT-BYTE EMIT-BYTE }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
@ -83,7 +90,6 @@
( intialize rng )
;init-rng JSR2
( #03 .tint STZ )
#03 .tint STZ
#00 .regenerate STZ
@ -150,10 +156,6 @@ BRK
&done
BRK
%DIGIT { #00 SWP ;digits ADD2 LDA EMIT }
%EMIT-BYTE { DUP #04 SFT DIGIT #0f AND DIGIT }
%EMIT-SHORT { SWP EMIT-BYTE EMIT-BYTE }
@try-move ( drow dcol -> )
.charx LDZ2 ADD2 SWP2 ( col+dcol row+drow )
.chary LDZ2 ADD2 SWP2 ( row+drow dcol )
@ -282,6 +284,15 @@ RTN
POP2 POP2
RTN
( a move is illegal if it changes both x and y. )
( that occurs when the player wraps around the border. )
@illegal-move ( cell* -> bool^ )
DUP2
COLS MOD2 ;focus LDA2 COLS MOD2 NEQ2 STH
ROWS DIV2 ;focus LDA2 ROWS DIV2 NEQ2 STHr
AND
RTN
@create-maze ( -> )
( create starting pt, must have even coords )
;random-short JSR2 MAZEROWS MOD2 INC2 #0002 MUL2 ( row* )
@ -297,8 +308,10 @@ RTN
DUP .directions ADD LDZ ( i^ d^ )
DUP #02 MUL .cell-offsets ADD LDZ2 ( i^ d^ off* )
DUP2 ;focus LDA2 ADD2 ADD2 ( i^ d^ cell2* )
DUP2 ;illegal-move JSR2 ,&notfound JCN
DUP2 UNSEEN ( i^ d^ cell2* unseen^ )
,&found JCN ( i^ d^ cell2* )
&notfound
POP2 POP INC ( j=i+1 )
DUP #04 LTH ( j^ j<4 )
,&search JCN ( j^ )