Optimizations: sla a -> add a, a

This commit is contained in:
Randy Thiemann 2023-11-13 03:09:57 +01:00
parent 304a5f739b
commit 932666b5bb
8 changed files with 4996 additions and 4996 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -103,7 +103,7 @@ BlitField::
REPT 7 REPT 7
; Wait until start of drawing, then insert nops. ; Wait until start of drawing, then insert nops.
: ldh a, [rSTAT] : ldh a, [rSTAT]
or a, ~STATF_LCD or a, $FF - STATF_LCD
inc a inc a
jr nz, :- jr nz, :-
REPT 40 REPT 40
@ -160,7 +160,7 @@ BigBlitField::
REPT 7 REPT 7
; Wait until start of drawing, then insert nops. ; Wait until start of drawing, then insert nops.
: ldh a, [rSTAT] : ldh a, [rSTAT]
or a, ~STATF_LCD or a, $FF - STATF_LCD
inc a inc a
jr nz, :- jr nz, :-
REPT 40 REPT 40
@ -310,10 +310,10 @@ FromShadowField:
; corresponding to that piece's zero rotation. ; corresponding to that piece's zero rotation.
SetPieceData: SetPieceData:
ldh a, [hCurrentPiece] ldh a, [hCurrentPiece]
sla a add a, a
sla a add a, a
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld b, 0 ld b, 0
@ -336,8 +336,8 @@ SetPieceData:
; The rotation state is a further offset of 4 bytes. ; The rotation state is a further offset of 4 bytes.
SetPieceDataOffset: SetPieceDataOffset:
ldh a, [hCurrentPieceRotationState] ldh a, [hCurrentPieceRotationState]
sla a add a, a
sla a add a, a
ldh [hPieceDataOffset], a ldh [hPieceDataOffset], a
ret ret
@ -989,8 +989,8 @@ FieldProcess::
ldh a, [hPieceDataBase+1] ldh a, [hPieceDataBase+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1070,8 +1070,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1110,8 +1110,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1159,8 +1159,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1221,8 +1221,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1266,8 +1266,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -1312,8 +1312,8 @@ FieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -2559,10 +2559,10 @@ BigFromShadowField:
; corresponding to that piece's zero rotation. ; corresponding to that piece's zero rotation.
BigSetPieceData: BigSetPieceData:
ldh a, [hCurrentPiece] ldh a, [hCurrentPiece]
sla a add a, a
sla a add a, a
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld b, 0 ld b, 0
@ -2585,8 +2585,8 @@ BigSetPieceData:
; The rotation state is a further offset of 4 bytes. ; The rotation state is a further offset of 4 bytes.
BigSetPieceDataOffset: BigSetPieceDataOffset:
ldh a, [hCurrentPieceRotationState] ldh a, [hCurrentPieceRotationState]
sla a add a, a
sla a add a, a
ldh [hPieceDataOffset], a ldh [hPieceDataOffset], a
ret ret
@ -3238,8 +3238,8 @@ BigFieldProcess::
ldh a, [hPieceDataBase+1] ldh a, [hPieceDataBase+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3319,8 +3319,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3359,8 +3359,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3408,8 +3408,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3469,8 +3469,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3514,8 +3514,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a
@ -3560,8 +3560,8 @@ BigFieldProcess::
ldh a, [hPieceDataBaseFast+1] ldh a, [hPieceDataBaseFast+1]
ld h, a ld h, a
ldh a, [hWantRotation] ldh a, [hWantRotation]
sla a add a, a
sla a add a, a
push bc push bc
ld c, a ld c, a
xor a, a xor a, a

View File

@ -824,9 +824,9 @@ GetSection::
; Multiply by 10, which is equal to multiply by 8 + multiply by 2 ; Multiply by 10, which is equal to multiply by 8 + multiply by 2
ld b, a ld b, a
sla b sla b
sla a add a, a
sla a add a, a
sla a add a, a
add a, b add a, b
; Add hundreds. ; Add hundreds.
@ -854,9 +854,9 @@ GetAdjustedSection::
; Multiply by 10, which is equal to multiply by 8 + multiply by 2 ; Multiply by 10, which is equal to multiply by 8 + multiply by 2
ld b, a ld b, a
sla b sla b
sla a add a, a
sla a add a, a
sla a add a, a
add a, b add a, b
; Add hundreds. ; Add hundreds.

View File

@ -296,7 +296,7 @@ ApplyNext::
ldh a, [hUpcomingPiece1] ldh a, [hUpcomingPiece1]
ld [wSPRQueue1A+3], a ld [wSPRQueue1A+3], a
ld [wSPRQueue1B+3], a ld [wSPRQueue1B+3], a
sla a add a, a
add a, TILE_PIECE_SMALL_0 add a, TILE_PIECE_SMALL_0
ld [wSPRQueue1A+2], a ld [wSPRQueue1A+2], a
inc a inc a
@ -305,7 +305,7 @@ ApplyNext::
ldh a, [hUpcomingPiece2] ldh a, [hUpcomingPiece2]
ld [wSPRQueue2A+3], a ld [wSPRQueue2A+3], a
ld [wSPRQueue2B+3], a ld [wSPRQueue2B+3], a
sla a add a, a
add a, TILE_PIECE_SMALL_0 add a, TILE_PIECE_SMALL_0
ld [wSPRQueue2A+2], a ld [wSPRQueue2A+2], a
inc a inc a

View File

@ -636,8 +636,8 @@ TitleVBlankHandlerB:
; RNG mode. ; RNG mode.
ld b, 0 ld b, 0
ld a, [wRNGModeState] ld a, [wRNGModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sRNGMode ld hl, sRNGMode
add hl, bc add hl, bc
@ -650,8 +650,8 @@ TitleVBlankHandlerB:
; ROT mode. ; ROT mode.
ld b, 0 ld b, 0
ld a, [wRotModeState] ld a, [wRotModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sROTMode ld hl, sROTMode
add hl, bc add hl, bc
@ -664,8 +664,8 @@ TitleVBlankHandlerB:
; DROP mode. ; DROP mode.
ld b, 0 ld b, 0
ld a, [wDropModeState] ld a, [wDropModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sDROPMode ld hl, sDROPMode
add hl, bc add hl, bc
@ -678,8 +678,8 @@ TitleVBlankHandlerB:
; CURVE mode. ; CURVE mode.
ld b, 0 ld b, 0
ld a, [wSpeedCurveState] ld a, [wSpeedCurveState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sCURVEMode ld hl, sCURVEMode
add hl, bc add hl, bc
@ -698,8 +698,8 @@ TitleVBlankHandlerB:
xor a, a xor a, a
ld b, a ld b, a
ld a, [wAlways20GState] ld a, [wAlways20GState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sHIGMode ld hl, sHIGMode
add hl, bc add hl, bc
@ -785,8 +785,8 @@ TitleVBlankHandlerB:
; RNG mode. ; RNG mode.
ld b, 0 ld b, 0
ld a, [wRNGModeState] ld a, [wRNGModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sRNGMode ld hl, sRNGMode
add hl, bc add hl, bc
@ -799,8 +799,8 @@ TitleVBlankHandlerB:
; ROT mode. ; ROT mode.
ld b, 0 ld b, 0
ld a, [wRotModeState] ld a, [wRotModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sROTMode ld hl, sROTMode
add hl, bc add hl, bc
@ -813,8 +813,8 @@ TitleVBlankHandlerB:
; DROP mode. ; DROP mode.
ld b, 0 ld b, 0
ld a, [wDropModeState] ld a, [wDropModeState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sDROPMode ld hl, sDROPMode
add hl, bc add hl, bc
@ -827,8 +827,8 @@ TitleVBlankHandlerB:
; CURVE mode. ; CURVE mode.
ld b, 0 ld b, 0
ld a, [wSpeedCurveState] ld a, [wSpeedCurveState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sCURVEMode ld hl, sCURVEMode
add hl, bc add hl, bc
@ -847,8 +847,8 @@ TitleVBlankHandlerB:
xor a, a xor a, a
ld b, a ld b, a
ld a, [wAlways20GState] ld a, [wAlways20GState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sHIGMode ld hl, sHIGMode
add hl, bc add hl, bc
@ -867,8 +867,8 @@ TitleVBlankHandlerB:
.buttons .buttons
ld b, 0 ld b, 0
ld a, [wSwapABState] ld a, [wSwapABState]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sBUTTONSMode ld hl, sBUTTONSMode
add hl, bc add hl, bc
@ -881,8 +881,8 @@ TitleVBlankHandlerB:
.filter .filter
ld b, 0 ld b, 0
ldh a, [hFilterMode] ldh a, [hFilterMode]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sFilterMode ld hl, sFilterMode
add hl, bc add hl, bc
@ -1661,8 +1661,8 @@ RenderScores:
; Draw the mode. ; Draw the mode.
: ld b, 0 : ld b, 0
ld a, [wSelected] ld a, [wSelected]
sla a add a, a
sla a add a, a
ld c, a ld c, a
ld hl, sCURVEMode ld hl, sCURVEMode
add hl, bc add hl, bc