StringCmp → CompareBytes; CompareLong → CompareBytesLong

hStringCmpString[1/2] → h[EnemyMon/PartyMon1]Speed
This commit is contained in:
Rangi 2018-07-23 00:25:53 -04:00
parent a1806d6e81
commit 4f0c9cecf9
10 changed files with 72 additions and 72 deletions

View File

@ -530,7 +530,7 @@ DetermineMoveOrder:
ld de, wBattleMonSpeed ld de, wBattleMonSpeed
ld hl, wEnemyMonSpeed ld hl, wEnemyMonSpeed
ld c, 2 ld c, 2
call StringCmp call CompareBytes
jr z, .speed_tie jr z, .speed_tie
jp nc, .player_first jp nc, .player_first
jp .enemy_first jp .enemy_first
@ -3715,19 +3715,19 @@ TryToRunAwayFromBattle:
inc a inc a
ld [wNumFleeAttempts], a ld [wNumFleeAttempts], a
ld a, [hli] ld a, [hli]
ld [hStringCmpString2 + 0], a ld [hPartyMon1Speed + 0], a
ld a, [hl] ld a, [hl]
ld [hStringCmpString2 + 1], a ld [hPartyMon1Speed + 1], a
ld a, [de] ld a, [de]
inc de inc de
ld [hStringCmpString1 + 0], a ld [hEnemyMonSpeed + 0], a
ld a, [de] ld a, [de]
ld [hStringCmpString1 + 1], a ld [hEnemyMonSpeed + 1], a
call Call_LoadTempTileMapToTileMap call Call_LoadTempTileMapToTileMap
ld de, hStringCmpString2 ld de, hPartyMon1Speed
ld hl, hStringCmpString1 ld hl, hEnemyMonSpeed
ld c, $2 ld c, 2
call StringCmp call CompareBytes
jr nc, .can_escape jr nc, .can_escape
xor a xor a
@ -3739,9 +3739,9 @@ TryToRunAwayFromBattle:
ld [hDividend + 0], a ld [hDividend + 0], a
ld a, [hProduct + 3] ld a, [hProduct + 3]
ld [hDividend + 1], a ld [hDividend + 1], a
ld a, [hStringCmpString1 + 0] ld a, [hEnemyMonSpeed + 0]
ld b, a ld b, a
ld a, [hStringCmpString1 + 1] ld a, [hEnemyMonSpeed + 1]
srl b srl b
rr a rr a
srl b srl b
@ -8712,7 +8712,7 @@ AddLastMobileBattleToLinkRecord:
push de push de
ld bc, 12 ld bc, 12
ld de, wStringBuffer1 ld de, wStringBuffer1
call CompareLong call CompareBytesLong
pop de pop de
pop hl pop hl
jr c, .done jr c, .done
@ -8821,7 +8821,7 @@ AddLastMobileBattleToLinkRecord:
pop hl pop hl
push bc push bc
ld c, 3 ld c, 3
call StringCmp call CompareBytes
pop bc pop bc
jr z, .equal jr z, .equal
jr nc, .done2 jr nc, .done2

View File

@ -6154,7 +6154,7 @@ BattleCommand_Heal:
push de push de
push bc push bc
ld c, 2 ld c, 2
call StringCmp call CompareBytes
pop bc pop bc
pop de pop de
pop hl pop hl
@ -6573,7 +6573,7 @@ BattleCommand_TimeBasedHealContinue:
; Don't bother healing if HP is already full. ; Don't bother healing if HP is already full.
push bc push bc
call StringCmp call CompareBytes
pop bc pop bc
jr z, .Full jr z, .Full

View File

@ -13,7 +13,7 @@ BattleCommand_FalseSwipe:
ld c, 2 ld c, 2
push hl push hl
push de push de
call StringCmp call CompareBytes
pop de pop de
pop hl pop hl
jr c, .done jr c, .done

View File

@ -171,7 +171,7 @@ DetermineContestWinners:
ld de, wBugContestTempScore ld de, wBugContestTempScore
ld hl, wBugContestFirstPlaceScore ld hl, wBugContestFirstPlaceScore
ld c, 2 ld c, 2
call StringCmp call CompareBytes
jr c, .not_first_place jr c, .not_first_place
ld hl, wBugContestSecondPlaceWinnerID ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID
@ -189,7 +189,7 @@ DetermineContestWinners:
ld de, wBugContestTempScore ld de, wBugContestTempScore
ld hl, wBugContestSecondPlaceScore ld hl, wBugContestSecondPlaceScore
ld c, 2 ld c, 2
call StringCmp call CompareBytes
jr c, .not_second_place jr c, .not_second_place
ld hl, wBugContestSecondPlaceWinnerID ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID
@ -203,7 +203,7 @@ DetermineContestWinners:
ld de, wBugContestTempScore ld de, wBugContestTempScore
ld hl, wBugContestThirdPlaceScore ld hl, wBugContestThirdPlaceScore
ld c, 2 ld c, 2
call StringCmp call CompareBytes
jr c, .done jr c, .done
ld hl, wBugContestThirdPlaceWinnerID ld hl, wBugContestThirdPlaceWinnerID
call CopyTempContestant call CopyTempContestant

View File

@ -36,7 +36,7 @@ CheckMagikarpLength:
ld hl, wMagikarpLength ld hl, wMagikarpLength
ld de, wBestMagikarpLengthFeet ld de, wBestMagikarpLengthFeet
ld c, 2 ld c, 2
call StringCmp call CompareBytes
jr nc, .not_long_enough jr nc, .not_long_enough
; NEW RECORD!!! Let's save that. ; NEW RECORD!!! Let's save that.

View File

@ -99,7 +99,7 @@ EvolveAfterBattle_MasterLoop:
ld de, wTempMonAttack ld de, wTempMonAttack
ld hl, wTempMonDefense ld hl, wTempMonDefense
ld c, 2 ld c, 2
call StringCmp call CompareBytes
ld a, ATK_EQ_DEF ld a, ATK_EQ_DEF
jr z, .got_tyrogue_evo jr z, .got_tyrogue_evo
ld a, ATK_LT_DEF ld a, ATK_LT_DEF

View File

@ -162,55 +162,8 @@ CallPointerAt::
rst Bankswitch rst Bankswitch
ret ret
QueueScript:: INCLUDE "home/queue_script.asm"
; Push pointer hl in the current bank to wQueuedScriptBank. INCLUDE "home/compare.asm"
ld a, [hROMBank]
FarQueueScript::
; Push pointer a:hl to wQueuedScriptBank.
ld [wQueuedScriptBank], a
ld a, l
ld [wQueuedScriptAddr], a
ld a, h
ld [wQueuedScriptAddr + 1], a
ret
StringCmp::
; Compare c bytes at de and hl.
; Return z if they all match.
.loop
ld a, [de]
cp [hl]
ret nz
inc de
inc hl
dec c
jr nz, .loop
ret
CompareLong::
; Compare bc bytes at de and hl.
; Return carry if they all match.
ld a, [de]
cp [hl]
jr nz, .Diff
inc de
inc hl
dec bc
ld a, b
or c
jr nz, CompareLong
scf
ret
.Diff:
and a
ret
INCLUDE "home/tilemap.asm" INCLUDE "home/tilemap.asm"
INCLUDE "home/hp_pals.asm" INCLUDE "home/hp_pals.asm"

35
home/compare.asm Normal file
View File

@ -0,0 +1,35 @@
CompareBytes::
; Compare c bytes at de and hl.
; Return z if they all match.
.loop
ld a, [de]
cp [hl]
ret nz
inc de
inc hl
dec c
jr nz, .loop
ret
CompareBytesLong::
; Compare bc bytes at de and hl.
; Return carry if they all match.
.loop
ld a, [de]
cp [hl]
jr nz, .diff
inc de
inc hl
dec bc
ld a, b
or c
jr nz, .loop
scf
ret
.diff:
and a
ret

12
home/queue_script.asm Normal file
View File

@ -0,0 +1,12 @@
QueueScript::
; Push pointer hl in the current bank to wQueuedScriptBank.
ld a, [hROMBank]
FarQueueScript::
; Push pointer a:hl to wQueuedScriptBank.
ld [wQueuedScriptBank], a
ld a, l
ld [wQueuedScriptAddr], a
ld a, h
ld [wQueuedScriptAddr + 1], a
ret

View File

@ -48,8 +48,8 @@ hConnectedMapWidth EQU $ffb0
hPastLeadingZeroes EQU $ffb3 hPastLeadingZeroes EQU $ffb3
hStringCmpString1 EQU $ffb1 hEnemyMonSpeed EQU $ffb1
hStringCmpString2 EQU $ffb5 hPartyMon1Speed EQU $ffb5
hDividend EQU $ffb3 ; length in b register, before 'call Divide' (max 4 bytes) hDividend EQU $ffb3 ; length in b register, before 'call Divide' (max 4 bytes)
hDivisor EQU $ffb7 ; 1 byte long hDivisor EQU $ffb7 ; 1 byte long