Optimized some MOD operations

This commit is contained in:
Andrew Alderwick 2021-05-15 09:44:20 +01:00
parent e442342664
commit 72dd7d5a87
4 changed files with 14 additions and 13 deletions

View File

@ -13,6 +13,7 @@
%DECR { SWP #01 - SWP } %DECR { SWP #01 - SWP }
%TOS { #00 SWP } %TOB { SWP POP } %TOS { #00 SWP } %TOB { SWP POP }
%RTN { JMP2r } %MOD { DUP2 / * - } %RTN { JMP2r } %MOD { DUP2 / * - }
%MOD8 { #07 AND } %MOD2 { #01 AND }
%SFL { #40 SFT SFT } %SFL { #40 SFT SFT }
%WIDTH { #40 } %HEIGHT { #40 } %WIDTH { #40 } %HEIGHT { #40 }
@ -72,7 +73,7 @@ BRK
( incr frame ) .world/frame LDZ #01 + [ DUP ] .world/frame STZ ( incr frame ) .world/frame LDZ #01 + [ DUP ] .world/frame STZ
( reset count ) #0000 .world/count STZ2 ( reset count ) #0000 .world/count STZ2
#02 MOD #00 = #01 JCN [ BRK ] MOD2 #00 = #01 JCN [ BRK ]
( clear buffer ) ( clear buffer )
BANK2 DUP2 GET-SIZE ++ BANK2 DUP2 GET-SIZE ++
@ -173,7 +174,7 @@ RTN
@set-cell ( x y -- ) @set-cell ( x y -- )
DUP2 ,get-index JSR STH2 DUP2 ,get-index JSR STH2
POP #08 MOD #01 SWP SFL POP MOD8 #01 SWP SFL
LDAkr STHr SWP ORA LDAkr STHr SWP ORA
STH2r STA STH2r STA
@ -183,7 +184,7 @@ RTN
DUP2 ,get-index JSR LDA DUP2 ,get-index JSR LDA
SWP POP SWP SWP POP SWP
#08 MOD MOD8
SFT #01 AND SFT #01 AND
RTN RTN
@ -245,7 +246,7 @@ RTN
.world/count LDZ2 #0001 ADD2 .world/count STZ2 .world/count LDZ2 #0001 ADD2 .world/count STZ2
( save in buffer ) ( save in buffer )
STH2 STH2
DUP2 POP #08 MOD #01 SWP SFL DUP2 POP MOD8 #01 SWP SFL
LDAkr STHr SWP ORA LDAkr STHr SWP ORA
STH2r STA STH2r STA

View File

@ -4,7 +4,7 @@
%8+ { #0008 ADD2 } %8- { #0008 SUB2 } %8+ { #0008 ADD2 } %8- { #0008 SUB2 }
%8* { #0008 MUL2 } %8/ { #0008 DIV2 } %8* { #0008 MUL2 } %8/ { #0008 DIV2 }
%++ { #0001 ADD2 } %++ { #0001 ADD2 }
%MOD { DUP2 DIV MUL SUB } %MOD8 { #07 AND }
%TRACK { ;track/ch1 #00 .track/active LDZ #0020 MUL2 ADD2 } %TRACK { ;track/ch1 #00 .track/active LDZ #0020 MUL2 ADD2 }
( variables ) ( variables )
@ -79,7 +79,7 @@ BRK
;move-head JSR2 ;move-head JSR2
;draw-vu JSR2 ;draw-vu JSR2
.head/pos LDZ #08 MOD ,&skip JCN .head/pos LDZ MOD8 ,&skip JCN
;bang JSR2 ;bang JSR2
&skip &skip

View File

@ -1,7 +1,5 @@
( dev/audio ) ( dev/audio )
%MOD { DUP2 DIV MUL SUB }
@timer $1 @timer $1
@progress $1 @progress $1
@ -49,7 +47,7 @@ BRK
;dot .Screen/addr DEO2 ;dot .Screen/addr DEO2
#21 .Screen/color DEO #21 .Screen/color DEO
( incr ) .progress LDZ #01 ADD #20 MOD .progress STZ ( incr ) .progress LDZ #01 ADD #1f AND .progress STZ
#00 .timer STZ #00 .timer STZ

View File

@ -16,6 +16,8 @@
%8+ { #0008 ADD2 } %8+ { #0008 ADD2 }
%8* { #0008 MUL2 } %8/ { #0008 DIV2 } %8* { #0008 MUL2 } %8/ { #0008 DIV2 }
%MOD { DUP2 DIV MUL SUB } %MOD { DUP2 DIV MUL SUB }
%MOD8 { #07 AND }
%MOD2 { #01 AND }
%DATA-CELLS { #2000 } %DATA-CELLS { #2000 }
%DATA-LOCKS { #3000 } %DATA-LOCKS { #3000 }
@ -195,8 +197,8 @@ RTN
DUP #2e NEQ ,&no-bar JCN DUP #2e NEQ ,&no-bar JCN
( check if x,y is grid ) ( check if x,y is grid )
POP POP
DUP2 #08 MOD #00 EQU SWP #08 MOD #00 EQU #0101 NEQ2 ,&no-marker8 JCN POP2 ;marker8_icn RTN &no-marker8 DUP2 MOD8 #00 EQU SWP MOD8 #00 EQU #0101 NEQ2 ,&no-marker8 JCN POP2 ;marker8_icn RTN &no-marker8
DUP2 #02 MOD #00 EQU SWP #02 MOD #00 EQU #0101 NEQ2 ,&no-marker4 JCN POP2 ;marker4_icn RTN &no-marker4 DUP2 MOD2 #00 EQU SWP MOD2 #00 EQU #0101 NEQ2 ,&no-marker4 JCN POP2 ;marker4_icn RTN &no-marker4
POP2 ;font RTN POP2 ;font RTN
&no-bar &no-bar
STH POP2 STHr STH POP2 STHr
@ -236,7 +238,7 @@ RTN
POP POP
++ ++
#30 .timer/frame LDZ #08 MOD ADD SET-CELL #30 .timer/frame LDZ MOD8 ADD SET-CELL
RTN RTN
@ -517,7 +519,7 @@ RTN
#0040 .Screen/x DEO2 #0040 .Screen/x DEO2
;beat_icn .Screen/addr DEO2 ;beat_icn .Screen/addr DEO2
#21 .timer/frame LDZ #08 MOD #00 EQU #02 MUL ADD .Screen/color DEO #21 .timer/frame LDZ MOD8 #00 EQU #02 MUL ADD .Screen/color DEO
( Speed ) ( Speed )
#0050 .Screen/x DEO2 #0050 .Screen/x DEO2