Optimized a few examples

This commit is contained in:
Devine Lu Linvega 2022-08-14 12:17:44 -07:00
parent f348d24606
commit 79e085088a
5 changed files with 31 additions and 41 deletions

View File

@ -44,30 +44,6 @@ BRK
BRK BRK
@clear-ball ( -- )
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
#76 .Screen/auto DEO
#0800
&loop-bg
#40 .Screen/sprite DEO
INC GTHk ,&loop-bg JCN
POP2
JMP2r
@move-ball ( -- )
,clear-ball JSR
.ball/vx LDZ2k STH2k ROT STZ2
.ball/x LDZ2k STH2r ADD2 ,check-flip-vx JSR ROT STZ2
.ball/vy LDZ2k INC2 STH2k ROT STZ2
.ball/y LDZ2k STH2r ADD2 ,check-flip-vy JSR ROT STZ2
,draw-ball JSR
JMP2r
@check-flip-vx ( x -- x ) @check-flip-vx ( x -- x )
( left ) DUP2 #0010 LTH2 ,&flip JCN ( left ) DUP2 #0010 LTH2 ,&flip JCN
@ -85,6 +61,23 @@ JMP2r
JMP2r JMP2r
@move-ball ( -- )
( clear )
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
#76 .Screen/auto DEO
#0800
&loop-bg
#40 .Screen/sprite DEO
INC GTHk ,&loop-bg JCN
POP2
.ball/vx LDZ2k STH2k ROT STZ2
.ball/x LDZ2k STH2r ADD2 ,check-flip-vx JSR ROT STZ2
.ball/vy LDZ2k INC2 STH2k ROT STZ2
.ball/y LDZ2k STH2r ADD2 ,check-flip-vy JSR ROT STZ2
@draw-ball ( -- ) @draw-ball ( -- )
( shadow ) ( shadow )

View File

@ -90,9 +90,6 @@ JMP2r
[ .center/x LDZ2 #0008 ADD2 ] [ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 ADD2 ] [ .center/y LDZ2 #0018 ADD2 ]
.DateTime/second DEI #0a ;mod JSR2 .DateTime/second DEI #0a ;mod JSR2
;draw-number JSR2
JMP2r
@draw-number ( x* y* n -- ) @draw-number ( x* y* n -- )

View File

@ -110,9 +110,9 @@ BRK
( top ) ( top )
[ LDA2k ] #05 SFT2 .Screen/x DEO2 [ LDA2k ] #05 SFT2 .Screen/x DEO2
[ INC2 INC2 LDA2 ] #05 SFT2 .Screen/y DEO2 [ INC2 INC2 LDA2 ] #05 SFT2 .Screen/y DEO2
#85 ,draw-sprite JSR #85 ,draw-sprite ( .. )
JMP2r JMP
@draw-sprite ( color -- ) @draw-sprite ( color -- )

View File

@ -31,11 +31,11 @@
;on-mouse .Mouse/vector DEO2 ;on-mouse .Mouse/vector DEO2
;on-control .Controller/vector DEO2 ;on-control .Controller/vector DEO2
( glider ) ( glider )
#07 #03 ;set-cell JSR2 #0703 ;set-cell JSR2
#07 #04 ;set-cell JSR2 #0704 ;set-cell JSR2
#05 #04 ;set-cell JSR2 #0504 ;set-cell JSR2
#07 #05 ;set-cell JSR2 #0705 ;set-cell JSR2
#06 #05 ;set-cell JSR2 #0605 ;set-cell JSR2
( center ) ( center )
.Screen/width DEI2 #01 SFT2 #0040 SUB2 .Screen/width DEI2 #01 SFT2 #0040 SUB2
DUP2 .anchor/x STZ2 DUP2 .anchor/x STZ2
@ -118,9 +118,9 @@ BRK
( move buffer ) ( move buffer )
;bank2 ;bank1 #1000 ;mcpy JSR2 ;bank2 ;bank1 #1000 ;mcpy JSR2
( draw ) ( draw )
;draw-grid JSR2 ;draw-grid ( .. )
JMP2r JMP2
@run-cell ( x y -- ) @run-cell ( x y -- )
@ -130,13 +130,13 @@ JMP2r
#00 EQU ,&dead JCN #00 EQU ,&dead JCN
DUP #02 LTH ,&dies JCN DUP #02 LTH ,&dies JCN
DUP #03 GTH ,&dies JCN DUP #03 GTH ,&dies JCN
POP ;&save JSR2 JMP2r POP ;&save JMP2
&dies POP POP2 JMP2r &dies POP POP2 JMP2r
&dead &dead
DUP #03 EQU ,&birth JCN POP POP2 JMP2r DUP #03 EQU ,&birth JCN POP POP2 JMP2r
&birth POP ;&save JSR2 &birth POP ;&save ( .. )
JMP2r JMP2
&save ( x y -- ) &save ( x y -- )
STH2 #01 STH2r ,get-index JSR [ #1000 ADD2 ] STA STH2 #01 STH2r ,get-index JSR [ #1000 ADD2 ] STA
.world/count LDZ2 INC2 .world/count STZ2 .world/count LDZ2 INC2 .world/count STZ2

View File

@ -54,9 +54,9 @@ BRK
#81 .Screen/sprite DEO #81 .Screen/sprite DEO
( eye/tail ) ( eye/tail )
#00 ,draw-eye JSR #00 ,draw-eye JSR
#00 ;draw-tail JSR2 #00 ;draw-tail ( .. )
JMP2r JMP2
@on-mouse ( -> ) @on-mouse ( -> )