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

View File

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

View File

@ -1,7 +1,5 @@
( dev/audio )
%MOD { DUP2 DIV MUL SUB }
@timer $1
@progress $1
@ -49,7 +47,7 @@ BRK
;dot .Screen/addr DEO2
#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

View File

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