(life.tal) Minor cleanup

This commit is contained in:
neauoire 2022-02-08 20:04:18 -08:00
parent db431f75fe
commit 5abb885eb5
1 changed files with 66 additions and 44 deletions

View File

@ -20,13 +20,15 @@
%RTN { JMP2r }
%SFL { #40 SFT SFT }
%WIDTH { #40 } %HEIGHT { #40 }
%WIDTH-MOD { #3f AND } %HEIGHT-MOD { #3f AND }
%WIDTH { #40 }
%HEIGHT { #40 }
%LENGTH { #0200 }
%WIDTH-MOD { #3f AND }
%HEIGHT-MOD { #3f AND }
%IN-RANGE { INCk SWP SUB2 GTH }
%BANK1 { #8000 } %BANK2 { #a000 }
%GET-SIZE { WIDTH TOS 8// 40** }
%GET-ITERATORS { SWP2k POP NIP }
%GET-ITER { OVR2 NIP OVR SWP }
@ -92,11 +94,7 @@ BRK
#03 AND #00 = #01 JCN [ BRK ]
( clear buffer )
BANK2 STH2k GET-SIZE ++ STH2r
&clear-loop
DUP2 #0000 SWP2 STA2
INC2 INC2 GTH2k ,&clear-loop JCN
POP2 POP2
BANK2 LENGTH ;mclr JSR2
( run grid )
#00 HEIGHT
@ -116,12 +114,7 @@ BRK
POP2
( move buffer )
BANK2 DUP2 GET-SIZE ++ SWP2
&copy-loop
DUP2 LDA2k
SWP2 #2000 -- STA2
INC2 INC2 GTH2k ,&copy-loop JCN
POP2 POP2
BANK2 BANK1 LENGTH ;mcpy JSR2
;draw-grid JSR2
@ -187,8 +180,6 @@ BRK
@on-control ( -> )
.Controller/key DEI #00 ! #01 JCN [ BRK ]
.Controller/key DEI #20 ! ,&no-toggle JCN
;on-frame
.Screen/vector DEI2 ;on-frame-paused == ,&swap JCN
@ -197,6 +188,11 @@ BRK
.Screen/vector DEO2
&no-toggle
.Controller/button DEI #08 ! ,&no-reset JCN
BANK1 #1000 ;mclr JSR2
BANK2 #1000 ;mclr JSR2
&no-reset
BRK
@draw-grid ( -- )
@ -210,10 +206,10 @@ BRK
HEIGHT #00
&ver
#00 OVR 2** .anchor/y LDZ2 ++ .Screen/y DEO2
DUP TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2
WIDTH #00
&hor
#00 OVR 2** .anchor/x LDZ2 ++ .Screen/x DEO2
DUP TOS 2** .anchor/x LDZ2 ++ .Screen/x DEO2
GET-ITER ,get-cell JSR INC .Screen/pixel DEO
INC GTHk ,&hor JCN
POP2
@ -272,21 +268,47 @@ RTN
@draw-short ( short* color -- )
;draw-char/color STA
SWP ,draw-byte JSR
STH
SWP STHkr ,draw-byte JSR
STHr
@draw-byte ( byte -- )
@draw-byte ( byte color -- )
DUP #04 SFT ,draw-char JSR
#0f AND
STH
DUP #04 SFT STHkr ,draw-hex JSR #0f AND
STHr
@draw-char ( char -- )
@draw-hex ( char color -- )
TOS 8** ;font-hex ++ .Screen/addr DEO2
[ LIT &color $1 ] .Screen/sprite DEO
SWP TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/sprite DEO
RTN
@mclr ( addr* len* -- )
OVR2 ++ SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ,&loop JCN
POP2 POP2
JMP2r
@mcpy ( src* dst* len* -- )
SWP2 STH2
OVR2 ++ SWP2
&loop
LDAk STH2kr STA INC2r
INC2 GTH2k ,&loop JCN
POP2 POP2
POP2r
JMP2r
( input )
@on-input ( -> )
,&main JSR
BRK