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