Use more assertions to ensure correct code and data

This commit is contained in:
Rangi
2020-10-26 22:24:38 -04:00
parent 9dcdad5e60
commit c85ba78b77
16 changed files with 50 additions and 17 deletions

View File

@@ -7781,7 +7781,8 @@ HandleSafariAngerEatingStatus: ; unreferenced
jr .finish
.angry
dec hl ; wSafariMonAngerCount
dec hl
assert wSafariMonEating - 1 == wSafariMonAngerCount
ld a, [hl]
and a
ret z

View File

@@ -245,7 +245,8 @@ BattleAnim_ClearOAM:
ld c, NUM_SPRITE_OAM_STRUCTS
.loop
ld a, [hl]
and $ff ^ (PALETTE_MASK | VRAM_BANK_1) ; PAL_BATTLE_OB_ENEMY (0)
and $ff ^ (PALETTE_MASK | VRAM_BANK_1) ; zeros out the palette bits
assert PAL_BATTLE_OB_ENEMY == 0
ld [hli], a
rept SPRITEOAMSTRUCT_LENGTH - 1
inc hl

View File

@@ -68,7 +68,8 @@ ContestJudging_ThirdPlaceScoreText:
LoadContestantName:
; If a = 1, get your name.
dec a ; BUG_CONTEST_PLAYER
assert BUG_CONTEST_PLAYER == 1
dec a
jr z, .player
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a

View File

@@ -208,7 +208,8 @@ GetMonBackpic:
push de
; These are assumed to be at the same address in their respective banks.
ld hl, PokemonPicPointers ; UnownPicPointers
assert PokemonPicPointers == UnownPicPointers
ld hl, PokemonPicPointers
ld a, b
ld d, BANK(PokemonPicPointers)
cp UNOWN

View File

@@ -273,7 +273,8 @@ SetFacingBoulderDust:
and 2
ld a, FACING_BOULDER_DUST_1
jr z, .ok
inc a ; FACING_BOULDER_DUST_2
inc a
assert FACING_BOULDER_DUST_1 + 1 == FACING_BOULDER_DUST_2
.ok
ld [hl], a
ret

View File

@@ -175,7 +175,8 @@ EnterMapWarp:
; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps.
; Dig and Escape Rope should not take you to them.
ld a, [wPrevMapGroup]
cp GROUP_MOUNT_MOON_SQUARE ; aka GROUP_TIN_TOWER_ROOF
cp GROUP_MOUNT_MOON_SQUARE
assert GROUP_MOUNT_MOON_SQUARE == GROUP_TIN_TOWER_ROOF
jr nz, .not_mt_moon_or_tin_tower
ld a, [wPrevMapNumber]
cp MAP_MOUNT_MOON_SQUARE

View File

@@ -334,6 +334,7 @@ OaksPKMNTalk8:
; so no need for a retry loop
call Random
maskbits NUM_OAKS_POKEMON_TALK_ADVERBS
assert_power_of_2 NUM_OAKS_POKEMON_TALK_ADVERBS
ld e, a
ld d, 0
ld hl, .Adverbs
@@ -433,6 +434,7 @@ OaksPKMNTalk9:
; so no need for a retry loop
call Random
maskbits NUM_OAKS_POKEMON_TALK_ADJECTIVES
assert_power_of_2 NUM_OAKS_POKEMON_TALK_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives
@@ -1130,6 +1132,7 @@ PeoplePlaces5:
; so no need for a retry loop
call Random
maskbits NUM_PNP_PEOPLE_ADJECTIVES
assert_power_of_2 NUM_PNP_PEOPLE_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives
@@ -1263,6 +1266,7 @@ PeoplePlaces7:
; so no need for a retry loop
call Random
maskbits NUM_PNP_PLACES_ADJECTIVES
assert_power_of_2 NUM_PNP_PLACES_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives