summaryrefslogtreecommitdiff
path: root/main.asm
diff options
context:
space:
mode:
Diffstat (limited to 'main.asm')
-rw-r--r--main.asm11271
1 files changed, 957 insertions, 10314 deletions
diff --git a/main.asm b/main.asm
index d499745ca..cbbfba98c 100644
--- a/main.asm
+++ b/main.asm
@@ -1,9 +1,7 @@
INCLUDE "includes.asm"
-
SECTION "bank1", ROMX, BANK[$1]
-
PlaceWaitingText:: ; 4000
hlcoord 3, 10
ld b, 1
@@ -45,9 +43,9 @@ LoadPushOAM:: ; 4031
; 403f
PushOAM: ; 403f
- ld a, Sprites >> 8
+ ld a, Sprites / $100
ld [rDMA], a
- ld a, $28
+ ld a, 40
.loop
dec a
jr nz, .loop
@@ -55,7 +53,6 @@ PushOAM: ; 403f
PushOAMEnd
; 4049
-
INCLUDE "engine/map_objects.asm"
INCLUDE "engine/intro_menu.asm"
@@ -92,8 +89,8 @@ Function6473: ; 6473
ld a, VBGMap1 / $100
call Function64b9
call Function2e20
- callba Function49409
- callba Function96a4
+ callba LoadOW_BGPal7
+ callba ApplyPals
ld a, $1
ld [hCGBPalUpdate], a
xor a
@@ -149,12 +146,12 @@ Function64db: ; 64db
ld [rSVBK], a
ld a, $60
- ld hl, w6_d000
- lb bc, 4, 0
+ ld hl, wDecompressScratch
+ ld bc, wBackupAttrMap - wDecompressScratch
call ByteFill
- ld a, w6_d000 / $100
+ ld a, wDecompressScratch / $100
ld [rHDMA1], a
- ld a, w6_d000 % $100
+ ld a, wDecompressScratch % $100
ld [rHDMA2], a
ld a, (VBGMap0 % $8000) / $100
ld [rHDMA3], a
@@ -169,264 +166,7 @@ Function64db: ; 64db
ret
; 6508
-LearnMove: ; 6508
- call LoadTileMapToTempTileMap
- ld a, [CurPartyMon]
- ld hl, PartyMonNicknames
- call GetNick
- ld hl, StringBuffer1
- ld de, wd050_MonNick
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
-.loop
- ld hl, PartyMon1Moves
- ld bc, PARTYMON_STRUCT_LENGTH
- ld a, [CurPartyMon]
- call AddNTimes
- ld d, h
- ld e, l
- ld b, NUM_MOVES
-; Get the first empty move slot. This routine also serves to
-; determine whether the Pokemon learning the moves already has
-; all four slots occupied, in which case one would need to be
-; deleted.
-.next
- ld a, [hl]
- and a
- jr z, .learn
- inc hl
- dec b
- jr nz, .next
-; If we're here, we enter the routine for forgetting a move
-; to make room for the new move we're trying to learn.
- push de
- call ForgetMove
- pop de
- jp c, .cancel
-
- push hl
- push de
- ld [wd265], a
-
- ld b, a
- ld a, [wBattleMode]
- and a
- jr z, .not_disabled
- ld a, [DisabledMove]
- cp b
- jr nz, .not_disabled
- xor a
- ld [DisabledMove], a
- ld [PlayerDisableCount], a
-.not_disabled
-
- call GetMoveName
- ld hl, UnknownText_0x6684 ; 1, 2 and…
- call PrintText
- pop de
- pop hl
-
-.learn
- ld a, [wd262]
- ld [hl], a
- ld bc, MON_PP - MON_MOVES
- add hl, bc
-
- push hl
- push de
- dec a
- ld hl, Moves + MOVE_PP
- ld bc, MOVE_LENGTH
- call AddNTimes
- ld a, BANK(Moves)
- call GetFarByte
- pop de
- pop hl
-
- ld [hl], a
-
- ld a, [wBattleMode]
- and a
- jp z, .learned
-
- ld a, [CurPartyMon]
- ld b, a
- ld a, [CurBattleMon]
- cp b
- jp nz, .learned
-
- ld a, [PlayerSubStatus5]
- bit SUBSTATUS_TRANSFORMED, a
- jp nz, .learned
-
- ld h, d
- ld l, e
- ld de, BattleMonMoves
- ld bc, NUM_MOVES
- call CopyBytes
- ld bc, PartyMon1PP - (PartyMon1Moves + NUM_MOVES)
- add hl, bc
- ld de, BattleMonPP
- ld bc, NUM_MOVES
- call CopyBytes
- jp .learned
-
-.cancel
- ld hl, UnknownText_0x6675 ; Stop learning <MOVE>?
- call PrintText
- call YesNoBox
- jp c, .loop
-
- ld hl, UnknownText_0x667a ; <MON> did not learn <MOVE>.
- call PrintText
- ld b, 0
- ret
-
-.learned
- ld hl, UnknownText_0x666b ; <MON> learned <MOVE>!
- call PrintText
- ld b, 1
- ret
-; 65d3
-
-ForgetMove: ; 65d3
- push hl
- ld hl, UnknownText_0x667f
- call PrintText
- call YesNoBox
- pop hl
- ret c
- ld bc, -NUM_MOVES
- add hl, bc
- push hl
- ld de, wListMoves_MoveIndicesBuffer
- ld bc, NUM_MOVES
- call CopyBytes
- pop hl
-.loop
- push hl
- ld hl, UnknownText_0x6670
- call PrintText
- hlcoord 5, 2
- ld b, NUM_MOVES * 2
- ld c, MOVE_NAME_LENGTH
- call TextBox
- hlcoord 5 + 2, 2 + 2
- ld a, SCREEN_WIDTH * 2
- ld [Buffer1], a
- predef ListMoves
- ; wMenuData3
- ld a, $4
- ld [wcfa1], a
- ld a, $6
- ld [wcfa2], a
- ld a, [wd0eb]
- inc a
- ld [wcfa3], a
- ld a, $1
- ld [wcfa4], a
- ld [MenuSelection2], a
- ld [wcfaa], a
- ld a, $3
- ld [wcfa8], a
- ld a, $20
- ld [wcfa5], a
- xor a
- ld [wcfa6], a
- ld a, $20
- ld [wcfa7], a
- call Function1bc9
- push af
- call Call_LoadTempTileMapToTileMap
- pop af
- pop hl
- bit 1, a
- jr nz, .cancel
- push hl
- ld a, [MenuSelection2]
- dec a
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [hl]
- push af
- push bc
- call IsHMMove
- pop bc
- pop de
- ld a, d
- jr c, .hmmove
- pop hl
- add hl, bc
- and a
- ret
-
-.hmmove
- ld hl, UnknownText_0x669a
- call PrintText
- pop hl
- jr .loop
-
-.cancel
- scf
- ret
-; 666b
-
-UnknownText_0x666b: ; 666b
-; <MON> learned <MOVE>!
- text_jump UnknownText_0x1c5660
- db "@"
-; 6670
-
-UnknownText_0x6670: ; 6670
-; Which move should be forgotten?
- text_jump UnknownText_0x1c5678
- db "@"
-; 6675
-
-UnknownText_0x6675: ; 6675
-; Stop learning <MOVE>?
- text_jump UnknownText_0x1c5699
- db "@"
-; 667a
-
-UnknownText_0x667a: ; 667a
-; <MON> did not learn <MOVE>.
- text_jump UnknownText_0x1c56af
- db "@"
-; 667f
-
-UnknownText_0x667f: ; 667f
-; <MON> is trying to learn <MOVE>. But <MON> can't learn more than
-; four moves. Delete an older move to make room for <MOVE>?
- text_jump UnknownText_0x1c56c9
- db "@"
-; 6684
-
-UnknownText_0x6684: ; 6684
- text_jump UnknownText_0x1c5740 ; 1, 2 and…
- start_asm
- push de
- ld de, SFX_SWITCH_POKEMON
- call PlaySFX
- pop de
- ld hl, UnknownText_0x6695
- ret
-; 6695
-
-UnknownText_0x6695: ; 6695
-; Poof! <MON> forgot <MOVE>. And…
- text_jump UnknownText_0x1c574e
- db "@"
-; 669a
-
-UnknownText_0x669a: ; 669a
-; HM moves can't be forgotten now.
- text_jump UnknownText_0x1c5772
- db "@"
-; 669f
-
+INCLUDE "engine/learn.asm"
CheckNickErrors:: ; 669f
; error-check monster nick before use
@@ -494,793 +234,23 @@ CheckNickErrors:: ; 669f
.textcommands ; 66cf
; table defining which characters are actually text commands
; format:
- ; ≥ <
- db $00, $05
- db $14, $19
- db $1d, $26
- db $35, $3a
- db $3f, $40
- db $49, $5d
- db $5e, $7f
- db $ff ; end
+ ; ≥ <
+ db "<START>", $04 + 1
+ db "<PLAY_G>", $18 + 1
+ db $1d, "%" + 1
+ db $35, "<GREEN>" + 1
+ db "<ENEMY>", "<ENEMY>" + 1
+ db $49, "<TM>" + 1
+ db "<ROCKET>", "┘" + 1
+ db -1 ; end
; 66de
-
-_Multiply:: ; 66de
-
-; hMultiplier is one byte.
- ld a, 8
- ld b, a
-
- xor a
- ld [hMultiplicand - 1], a
- ld [hMathBuffer + 1], a
- ld [hMathBuffer + 2], a
- ld [hMathBuffer + 3], a
- ld [hMathBuffer + 4], a
-
-
-.loop
- ld a, [hMultiplier]
- srl a
- ld [hMultiplier], a
- jr nc, .next
-
- ld a, [hMathBuffer + 4]
- ld c, a
- ld a, [hMultiplicand + 2]
- add c
- ld [hMathBuffer + 4], a
-
- ld a, [hMathBuffer + 3]
- ld c, a
- ld a, [hMultiplicand + 1]
- adc c
- ld [hMathBuffer + 3], a
-
- ld a, [hMathBuffer + 2]
- ld c, a
- ld a, [hMultiplicand + 0]
- adc c
- ld [hMathBuffer + 2], a
-
- ld a, [hMathBuffer + 1]
- ld c, a
- ld a, [hMultiplicand - 1]
- adc c
- ld [hMathBuffer + 1], a
-
-.next
- dec b
- jr z, .done
-
-
-; hMultiplicand <<= 1
-
- ld a, [hMultiplicand + 2]
- add a
- ld [hMultiplicand + 2], a
-
- ld a, [hMultiplicand + 1]
- rla
- ld [hMultiplicand + 1], a
-
- ld a, [hMultiplicand + 0]
- rla
- ld [hMultiplicand + 0], a
-
- ld a, [hMultiplicand - 1]
- rla
- ld [hMultiplicand - 1], a
-
- jr .loop
-
-
-.done
- ld a, [hMathBuffer + 4]
- ld [hProduct + 3], a
-
- ld a, [hMathBuffer + 3]
- ld [hProduct + 2], a
-
- ld a, [hMathBuffer + 2]
- ld [hProduct + 1], a
-
- ld a, [hMathBuffer + 1]
- ld [hProduct + 0], a
-
- ret
-; 673e
-
-
-_Divide:: ; 673e
- xor a
- ld [hMathBuffer + 0], a
- ld [hMathBuffer + 1], a
- ld [hMathBuffer + 2], a
- ld [hMathBuffer + 3], a
- ld [hMathBuffer + 4], a
-
- ld a, 9
- ld e, a
-
-.loop
- ld a, [hMathBuffer + 0]
- ld c, a
- ld a, [hDividend + 1]
- sub c
- ld d, a
-
- ld a, [hDivisor]
- ld c, a
- ld a, [hDividend + 0]
- sbc c
- jr c, .asm_6767
-
- ld [hDividend + 0], a
-
- ld a, d
- ld [hDividend + 1], a
-
- ld a, [hMathBuffer + 4]
- inc a
- ld [hMathBuffer + 4], a
-
- jr .loop
-
-.asm_6767
- ld a, b
- cp 1
- jr z, .done
-
- ld a, [hMathBuffer + 4]
- add a
- ld [hMathBuffer + 4], a
-
- ld a, [hMathBuffer + 3]
- rla
- ld [hMathBuffer + 3], a
-
- ld a, [hMathBuffer + 2]
- rla
- ld [hMathBuffer + 2], a
-
- ld a, [hMathBuffer + 1]
- rla
- ld [hMathBuffer + 1], a
-
- dec e
- jr nz, .asm_6798
-
- ld e, 8
- ld a, [hMathBuffer + 0]
- ld [hDivisor], a
- xor a
- ld [hMathBuffer + 0], a
-
- ld a, [hDividend + 1]
- ld [hDividend + 0], a
-
- ld a, [hDividend + 2]
- ld [hDividend + 1], a
-
- ld a, [hDividend + 3]
- ld [hDividend + 2], a
-
-.asm_6798
- ld a, e
- cp 1
- jr nz, .asm_679e
- dec b
-
-.asm_679e
- ld a, [hDivisor]
- srl a
- ld [hDivisor], a
-
- ld a, [hMathBuffer + 0]
- rr a
- ld [hMathBuffer + 0], a
-
- jr .loop
-
-.done
- ld a, [hDividend + 1]
- ld [hDivisor], a
-
- ld a, [hMathBuffer + 4]
- ld [hDividend + 3], a
-
- ld a, [hMathBuffer + 3]
- ld [hDividend + 2], a
-
- ld a, [hMathBuffer + 2]
- ld [hDividend + 1], a
-
- ld a, [hMathBuffer + 1]
- ld [hDividend + 0], a
-
- ret
-; 67c1
-
+INCLUDE "engine/math.asm"
ItemAttributes: ; 67c1
INCLUDE "items/item_attributes.asm"
; 6ec1
-
-
-Function6ec1: ; 6ec1
-
- ld hl, OBJECT_PALETTE
- add hl, bc
- bit 5, [hl]
- jr z, .not_bit_5
-
- ld hl, OBJECT_FLAGS1
- add hl, bc
- bit 4, [hl] ; lost
- push hl
- push bc
- call Function6f2c
- pop bc
- pop hl
- ret c
- jr .resume
-
-.not_bit_5
- ld hl, OBJECT_FLAGS1
- add hl, bc
- bit 4, [hl]
- jr nz, .resume
- push hl
- push bc
- call Function6f07
- pop bc
- pop hl
- ret c
-
-.resume
- bit 6, [hl]
- jr nz, .bit_6
-
- push hl
- push bc
- call WillPersonBumpIntoSomeoneElse
- pop bc
- pop hl
- ret c
-
-.bit_6
- bit 5, [hl]
- jr nz, .bit_5
- push hl
- call HasPersonReachedMovementLimit
- pop hl
- ret c
-
- push hl
- call IsPersonMovingOffEdgeOfScreen
- pop hl
- ret c
-
-.bit_5
- and a
- ret
-; 6f07
-
-
-Function6f07: ; 6f07
- call Function6f5f
- ret c
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld d, [hl]
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld e, [hl]
- ld hl, OBJECT_PALETTE
- add hl, bc
- bit 7, [hl]
- jp nz, Function6fa1
- ld hl, OBJECT_NEXT_TILE
- add hl, bc
- ld a, [hl]
- ld d, a
- call GetTileCollision
- and a
- jr z, Function6f3e
- scf
- ret
-; 6f2c
-
-Function6f2c: ; 6f2c
- call Function6f5f
- ret c
- ld hl, OBJECT_NEXT_TILE
- add hl, bc
- ld a, [hl]
- call GetTileCollision
- cp $1
- jr z, Function6f3e
- scf
- ret
-; 6f3e
-
-Function6f3e: ; 6f3e
- ld hl, OBJECT_NEXT_TILE
- add hl, bc
- ld a, [hl]
- call Function6f7f
- ret nc
- push af
- ld hl, OBJECT_DIRECTION_WALKING
- add hl, bc
- ld a, [hl]
- and 3
- ld e, a
- ld d, 0
- ld hl, .data_6f5b
- add hl, de
- pop af
- and [hl]
- ret z
- scf
- ret
-; 6f5b
-
-.data_6f5b
- db 1 << DOWN, 1 << UP, 1 << RIGHT, 1 << LEFT
-; 6f5f
-
-Function6f5f: ; 6f5f
- ld hl, OBJECT_STANDING_TILE
- add hl, bc
- ld a, [hl]
- call Function6f7f
- ret nc
- push af
- ld hl, OBJECT_DIRECTION_WALKING
- add hl, bc
- and 3
- ld e, a
- ld d, 0
- ld hl, .data_6f7b
- add hl, de
- pop af
- and [hl]
- ret z
- scf
- ret
-; 6f7b
-
-.data_6f7b
- db 1 << UP, 1 << DOWN, 1 << LEFT, 1 << RIGHT
-; 6f7f
-
-Function6f7f: ; 6f7f
- ld d, a
- and $f0
- cp $b0
- jr z, .done
- cp $c0
- jr z, .done
- xor a
- ret
-
-.done
- ld a, d
- and 7
- ld e, a
- ld d, 0
- ld hl, .data_6f99
- add hl, de
- ld a, [hl]
- scf
- ret
-; 6f99
-
-.data_6f99
- db 8, 4, 1, 2
- db 10, 6, 9, 5
-; 6fa1
-
-Function6fa1: ; 6fa1
- ld hl, OBJECT_DIRECTION_WALKING
- add hl, bc
- ld a, [hl]
- and 3
- jr z, .asm_6fb2
- dec a
- jr z, .asm_6fb7
- dec a
- jr z, .asm_6fbb
- jr .asm_6fbf
-
-.asm_6fb2
- inc e
- push de
- inc d
- jr .asm_6fc2
-
-.asm_6fb7
- push de
- inc d
- jr .asm_6fc2
-
-.asm_6fbb
- push de
- inc e
- jr .asm_6fc2
-
-.asm_6fbf
- inc d
- push de
- inc e
-
-.asm_6fc2
- call GetCoordTile
- call GetTileCollision
- pop de
- and a
- jr nz, .asm_6fd7
- call GetCoordTile
- call GetTileCollision
- and a
- jr nz, .asm_6fd7
- xor a
- ret
-
-.asm_6fd7
- scf
- ret
-; 6fd9
-
-
-
-CheckFacingObject:: ; 6fd9
-
- call GetFacingTileCoord
-
-; Double the distance for counter tiles.
- call CheckCounterTile
- jr nz, .asm_6ff1
-
- ld a, [PlayerNextMapX]
- sub d
- cpl
- inc a
- add d
- ld d, a
-
- ld a, [PlayerNextMapY]
- sub e
- cpl
- inc a
- add e
- ld e, a
-
-.asm_6ff1
- ld bc, ObjectStructs ; redundant
- ld a, 0
- ld [hMapObjectIndexBuffer], a
- call IsNPCAtCoord
- ret nc
- ld hl, OBJECT_DIRECTION_WALKING
- add hl, bc
- ld a, [hl]
- cp STANDING
- jr z, .standing
- xor a
- ret
-
-.standing
- scf
- ret
-; 7009
-
-
-WillPersonBumpIntoSomeoneElse: ; 7009
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld d, [hl]
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld e, [hl]
- jr IsNPCAtCoord
-; 7015
-
-Function7015: ; unreferenced
- ld a, [hMapObjectIndexBuffer]
- call GetObjectStruct
- call .CheckWillBeFacingNPC
- call IsNPCAtCoord
- ret
-
-.CheckWillBeFacingNPC: ; 7021
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld d, [hl]
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld e, [hl]
- call GetSpriteDirection
- and a
- jr z, .down
- cp OW_UP
- jr z, .up
- cp OW_LEFT
- jr z, .left
- inc d
- ret
-
-.down
- inc e
- ret
-
-.up
- dec e
- ret
-
-.left
- dec d
- ret
-; 7041
-
-IsNPCAtCoord: ; 7041
- ld bc, ObjectStructs
- xor a
-.loop
- ld [hObjectStructIndexBuffer], a
- call GetObjectSprite
- jr z, .next
-
- ld hl, OBJECT_FLAGS1
- add hl, bc
- bit 7, [hl]
- jr nz, .next
-
- ld hl, OBJECT_PALETTE
- add hl, bc
- bit 7, [hl]
- jr z, .got
-
- call Function7171
- jr nc, .ok
- jr .ok2
-
-.got
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .ok
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .ok
-
-.ok2
- ld a, [hMapObjectIndexBuffer]
- ld l, a
- ld a, [hObjectStructIndexBuffer]
- cp l
- jr nz, .setcarry
-
-.ok
- ld hl, OBJECT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .next
- ld hl, OBJECT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .next
- ld a, [hMapObjectIndexBuffer]
- ld l, a
- ld a, [hObjectStructIndexBuffer]
- cp l
- jr nz, .setcarry
-
-.next
- ld hl, OBJECT_STRUCT_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- ld a, [hObjectStructIndexBuffer]
- inc a
- cp NUM_OBJECT_STRUCTS
- jr nz, .loop
- and a
- ret
-
-.setcarry
- scf
- ret
-; 70a4
-
-HasPersonReachedMovementLimit: ; 70a4
- ld hl, OBJECT_RADIUS
- add hl, bc
- ld a, [hl]
- and a
- jr z, .nope
- and $f
- jr z, .check_y
- ld e, a
- ld d, a
- ld hl, OBJECT_INIT_X
- add hl, bc
- ld a, [hl]
- sub d
- ld d, a
- ld a, [hl]
- add e
- ld e, a
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr z, .yes
- cp e
- jr z, .yes
-
-.check_y
- ld hl, OBJECT_RADIUS
- add hl, bc
- ld a, [hl]
- swap a
- and $f
- jr z, .nope
- ld e, a
- ld d, a
- ld hl, OBJECT_INIT_Y
- add hl, bc
- ld a, [hl]
- sub d
- ld d, a
- ld a, [hl]
- add e
- ld e, a
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp d
- jr z, .yes
- cp e
- jr z, .yes
-
-.nope
- xor a
- ret
-
-.yes
- scf
- ret
-; 70ed
-
-IsPersonMovingOffEdgeOfScreen: ; 70ed
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [XCoord]
- cp [hl]
- jr z, .check_y
- jr nc, .yes
- add $9
- cp [hl]
- jr c, .yes
-
-.check_y
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [YCoord]
- cp [hl]
- jr z, .nope
- jr nc, .yes
- add $8
- cp [hl]
- jr c, .yes
-
-.nope
- and a
- ret
-
-.yes
- scf
- ret
-; 7113
-
-Function7113: ; unreferenced
- ld a, [PlayerNextMapX]
- ld d, a
- ld a, [PlayerNextMapY]
- ld e, a
- ld bc, ObjectStructs
- xor a
-.loop
- ld [hObjectStructIndexBuffer], a
- call GetObjectSprite
- jr z, .next
- ld hl, OBJECT_MOVEMENTTYPE
- add hl, bc
- ld a, [hl]
- cp SPRITEMOVEDATA_SNORLAX
- jr nz, .not_snorlax
- call Function7171
- jr c, .yes
- jr .next
-
-.not_snorlax
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .check_current_coords
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .check_current_coords
- ld a, [hObjectStructIndexBuffer]
- cp $0
- jr z, .next
- jr .yes
-
-.check_current_coords
- ld hl, OBJECT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .next
- ld hl, OBJECT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .next
- jr .yes
-
-.next
- ld hl, OBJECT_STRUCT_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- ld a, [hObjectStructIndexBuffer]
- inc a
- cp NUM_OBJECT_STRUCTS
- jr nz, .loop
- xor a
- ret
-
-.yes
- scf
- ret
-; 7171
-
-
-Function7171: ; 7171
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, d
- sub [hl]
- jr c, .nope
- cp $2
- jr nc, .nope
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, e
- sub [hl]
- jr c, .nope
- cp $2
- jr nc, .nope
- scf
- ret
-
-.nope
- and a
- ret
-; 718d
+INCLUDE "engine/npc_movement.asm"
GetFirstPokemonHappiness: ; 718d
ld hl, PartyMon1Happiness
@@ -1316,7 +286,6 @@ CheckFirstMonIsEgg: ; 71ac
jp CopyPokemonName_Buffer1_Buffer3
; 71c2
-
ChangeHappiness: ; 71c2
; Perform happiness action c on CurPartyMon
@@ -1382,7 +351,7 @@ endr
ret z
ld a, [CurPartyMon]
ld b, a
- ld a, [wd0d8]
+ ld a, [wPartyMenuCursor]
cp b
ret nz
ld a, [de]
@@ -1412,7 +381,6 @@ endr
db +10, +6, +4 ; Gained a level in the place where it was caught
; 725a
-
StepHappiness:: ; 725a
; Raise the party's happiness by 1 point every other step cycle.
@@ -1449,53 +417,52 @@ StepHappiness:: ; 725a
ret
; 7282
-
DaycareStep:: ; 7282
ld a, [wDaycareMan]
bit 0, a
- jr z, .asm_72a4
+ jr z, .daycare_lady
ld a, [wBreedMon1Level] ; level
cp 100
- jr nc, .asm_72a4
+ jr nc, .daycare_lady
ld hl, wBreedMon1Exp + 2 ; exp
inc [hl]
- jr nz, .asm_72a4
+ jr nz, .daycare_lady
dec hl
inc [hl]
- jr nz, .asm_72a4
+ jr nz, .daycare_lady
dec hl
inc [hl]
ld a, [hl]
- cp $50
- jr c, .asm_72a4
- ld a, $50
+ cp 5242880 / $10000
+ jr c, .daycare_lady
+ ld a, 5242880 / $10000
ld [hl], a
-.asm_72a4
+.daycare_lady
ld a, [wDaycareLady]
bit 0, a
- jr z, .asm_72c6
+ jr z, .check_egg
ld a, [wBreedMon2Level] ; level
cp 100
- jr nc, .asm_72c6
+ jr nc, .check_egg
ld hl, wBreedMon2Exp + 2 ; exp
inc [hl]
- jr nz, .asm_72c6
+ jr nz, .check_egg
dec hl
inc [hl]
- jr nz, .asm_72c6
+ jr nz, .check_egg
dec hl
inc [hl]
ld a, [hl]
- cp $50
- jr c, .asm_72c6
- ld a, $50
+ cp 5242880 / $10000
+ jr c, .check_egg
+ ld a, 5242880 / $10000
ld [hl], a
-.asm_72c6
+.check_egg
ld hl, wDaycareMan
bit 5, [hl] ; egg
ret z
@@ -1505,22 +472,22 @@ DaycareStep:: ; 7282
call Random
ld [hl], a
- callab Function16e1d
+ callab CheckBreedmonCompatibility
ld a, [wd265]
- cp $e6
- ld b, $50
- jr nc, .asm_72f8
+ cp 230
+ ld b, -1 + 32 percent
+ jr nc, .okay
ld a, [wd265]
- cp $aa
- ld b, $28
- jr nc, .asm_72f8
+ cp 170
+ ld b, 16 percent
+ jr nc, .okay
ld a, [wd265]
- cp $6e
- ld b, $1e
- jr nc, .asm_72f8
- ld b, $a
+ cp 110
+ ld b, 12 percent
+ jr nc, .okay
+ ld b, 4 percent
-.asm_72f8
+.okay
call Random
cp b
ret nc
@@ -1530,7 +497,6 @@ DaycareStep:: ; 7282
ret
; 7305
-
SpecialGiveShuckle: ; 7305
; Adding to the party.
@@ -1604,7 +570,6 @@ SpecialShuckleNick:
db "SHUCKIE@"
; 737e
-
SpecialReturnShuckle: ; 737e
callba SelectMonFromParty
jr c, .refused
@@ -1655,9 +620,8 @@ SpecialReturnShuckle: ; 737e
jr nc, .HappyToStayWithYou
xor a ; take from pc
ld [wPokemonWithdrawDepositParameter], a
- callab Functione039
+ callab RemoveMonFromPartyOrBox
ld a, $2
-
.HappyToStayWithYou
ld [ScriptVar], a
ret
@@ -1777,10 +741,9 @@ Predef1: ; 747a
ret
; 747b
-
SECTION "bank2", ROMX, BANK[$2]
-Function8000: ; 8000
+BlankScreen: ; 8000
call DisableSpriteUpdates
xor a
ld [hBGMapMode], a
@@ -1794,7 +757,7 @@ Function8000: ; 8000
ld bc, AttrMapEnd - AttrMap
ld a, $7
call ByteFill
- call Function3200
+ call WaitBGMap2
call SetPalettes
ret
; 8029
@@ -1869,7 +832,6 @@ PlayerSpawn_ConvertCoords: ; 808f
ret
; 80a1
-
WritePersonXY:: ; 80a1
ld a, b
call CheckObjectVisibility
@@ -1917,7 +879,6 @@ RefreshPlayerCoords: ; 80b8
ret
; 80e7
-
CopyObjectStruct:: ; 80e7
call CheckObjectMask
and a
@@ -2213,7 +1174,6 @@ Function823e: ; 823e
ret
; 8286
-
CopyTempObjectToObjectStruct: ; 8286
ld a, [wTempObjectCopyMapObjectIndex]
ld hl, OBJECT_MAP_OBJECT_INDEX
@@ -2415,7 +1375,6 @@ Special_SurfStartStep: ; 8379
slow_step_right
; 839e
-
FollowNotExact:: ; 839e
push bc
ld a, c
@@ -2683,24 +1642,24 @@ _Sine:: ; 84d9
cp %100000
jr nc, .negative
- call Function84ef
+ call .ApplySineWave
ld a, h
ret
.negative
and %011111
- call Function84ef
+ call .ApplySineWave
ld a, h
xor -1
inc a
ret
; 84ef
-Function84ef: ; 84ef
+.ApplySineWave: ; 84ef
ld e, a
ld a, d
ld d, 0
- ld hl, SineWave
+ ld hl, .sinewave
rept 2
add hl, de
endr
@@ -2722,19 +1681,16 @@ endr
ret
; 850b
-SineWave: ; 850b
+.sinewave: ; 850b
; A $20-word table representing a sine wave.
; 90 degrees is index $10 at a base amplitude of $100.
sine_wave $100
; 854b
-
INCLUDE "engine/predef.asm"
-
INCLUDE "engine/color.asm"
-
SECTION "bank3", ROMX, BANK[$3]
CheckTime:: ; c000
@@ -2759,10 +1715,8 @@ TimeOfDayTable: ; c012
db -1
; c01b
-
INCLUDE "engine/specials.asm"
-
_PrintNum:: ; c4c7
; Print c digits of the b-byte value from de to hl.
; Allows 2 to 7 digits. For 1-digit numbers, add
@@ -3067,7 +2021,6 @@ _PrintNum:: ; c4c7
ret
; c658
-
HealParty: ; c658
xor a
ld [CurPartyMon], a
@@ -3125,7 +2078,8 @@ endr
ret
; c699
-DrawPartyMenuHPBar: ; c699
+ComputeHPBarPixels: ; c699
+; bc * (6 * 8) / de
ld a, b
or c
jr z, .zero
@@ -3136,12 +2090,14 @@ DrawPartyMenuHPBar: ; c699
ld [hMultiplicand + 1], a
ld a, c
ld [hMultiplicand + 2], a
- ld a, $30
+ ld a, 6 * 8
ld [hMultiplier], a
call Multiply
+ ; We need de to be under 256 because hDivisor is only 1 byte.
ld a, d
and a
jr z, .divide
+ ; divide de and hProduct by 4
srl d
rr e
srl d
@@ -3156,22 +2112,21 @@ DrawPartyMenuHPBar: ; c699
ld [hDividend + 3], a
ld a, b
ld [hDividend + 2], a
-
.divide
ld a, e
ld [hDivisor], a
- ld b, $4
+ ld b, 4
call Divide
ld a, [hQuotient + 2]
ld e, a
pop hl
and a
ret nz
- ld e, $1
+ ld e, 1
ret
.zero
- ld e, $0
+ ld e, 0
ret
; c6e0
@@ -3182,7 +2137,6 @@ AnimateHPBar: ; c6e0
ret
; c6ea
-
ClearBuffer1: ; c6ea
xor a
ld hl, Buffer1
@@ -3206,7 +2160,6 @@ FieldMoveJumptable: ; c6f5
ret
; c706
-
GetPartyNick: ; c706
; write CurPartyMon nickname to StringBuffer1-3
ld hl, PartyMonNicknames
@@ -3222,7 +2175,6 @@ GetPartyNick: ; c706
ret
; c721
-
CheckEngineFlag: ; c721
; Check engine flag de
; Return carry if flag is not set
@@ -3243,20 +2195,19 @@ CheckBadge: ; c731
; Display "Badge required" text and return carry if the badge is not owned
call CheckEngineFlag
ret nc
- ld hl, BadgeRequiredText
+ ld hl, .BadgeRequiredText
call MenuTextBoxBackup ; push text to queue
scf
ret
; c73d
-BadgeRequiredText: ; c73d
+.BadgeRequiredText: ; c73d
; Sorry! A new BADGE
; is required.
text_jump _BadgeRequiredText
db "@"
; c742
-
CheckPartyMove: ; c742
; Check if a monster in your party has move d.
@@ -3302,14 +2253,14 @@ CheckPartyMove: ; c742
ret
; c779
-
FieldMoveFailed: ; c779
- ld hl, UnknownText_0xc780
+ ld hl, .CantUseHere
call MenuTextBoxBackup
ret
; c780
-UnknownText_0xc780: ; 0xc780
+.CantUseHere: ; 0xc780
+ ; Can't use that here.
text_jump UnknownText_0x1c05c8
db "@"
; 0xc785
@@ -3321,16 +2272,15 @@ CutFunction: ; c785
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c796
-
.Jumptable: ; c796 (3:4796)
- dw .CheckAble
- dw .DoCut
- dw .FailCut
-
+ jumptable_start
+ jumptable .CheckAble
+ jumptable .DoCut
+ jumptable .FailCut
.CheckAble: ; c79c (3:479c)
ld de, ENGINE_HIVEBADGE
@@ -3340,9 +2290,11 @@ CutFunction: ; c785
jr c, .nothingtocut
ld a, $1
ret
+
.nohivebadge
ld a, $80
ret
+
.nothingtocut
ld a, $2
ret
@@ -3354,45 +2306,51 @@ CutFunction: ; c785
ret
.FailCut: ; c7bb (3:47bb)
- ld hl, UnknownText_0xc7c9
+ ld hl, Text_NothingToCut
call MenuTextBoxBackup
ld a, $80
ret
-UnknownText_0xc7c4: ; 0xc7c4
+Text_UsedCut: ; 0xc7c4
; used CUT!
text_jump UnknownText_0x1c05dd
db "@"
; 0xc7c9
-UnknownText_0xc7c9: ; 0xc7c9
+Text_NothingToCut: ; 0xc7c9
; There's nothing to CUT here.
text_jump UnknownText_0x1c05ec
db "@"
; 0xc7ce
CheckMapForSomethingToCut: ; c7ce
+ ; Does the collision data of the facing tile permit cutting?
call GetFacingTileCoord
ld c, a
push de
callba CheckCutCollision
pop de
jr nc, .fail
+ ; Get the location of the current block in OverworldMap.
call GetBlockLocation
ld c, [hl]
+ ; See if that block contains something that can be cut.
push hl
ld hl, CutTreeBlockPointers
call CheckOverworldTileArrays
pop hl
jr nc, .fail
+ ; Back up the OverworldMap address to Buffer3
ld a, l
- ld [wd1ec], a
+ ld [Buffer3], a
ld a, h
- ld [wd1ed], a
+ ld [Buffer4], a
+ ; Back up the replacement tile to Buffer5
ld a, b
- ld [wd1ee], a
+ ld [Buffer5], a
+ ; Back up the animation index to Buffer6
ld a, c
- ld [wd1ef], a
+ ld [Buffer6], a
xor a
ret
@@ -3407,26 +2365,26 @@ Script_CutFromMenu: ; c7fe
Script_Cut: ; 0xc802
callasm GetPartyNick
- writetext UnknownText_0xc7c4
+ writetext Text_UsedCut
reloadmappart
callasm CutDownTreeOrGrass
- loadmovesprites
+ closetext
end
; 0xc810
CutDownTreeOrGrass: ; c810
- ld hl, wd1ec
+ ld hl, Buffer3 ; OverworldMapTile
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wd1ee]
+ ld a, [Buffer5] ; ReplacementTile
ld [hl], a
xor a
ld [hBGMapMode], a
call OverworldTextModeSwitch
call UpdateSprites
call DelayFrame
- ld a, [wd1ef]
+ ld a, [Buffer6] ; Animation type
ld e, a
callba OWCutAnimation
call BufferScreen
@@ -3438,22 +2396,32 @@ CutDownTreeOrGrass: ; c810
; c840
CheckOverworldTileArrays: ; c840
+ ; Input: c contains the tile you're facing
+ ; Output: Replacement tile in b and effect on wild encounters in c, plus carry set.
+ ; Carry is not set if the facing tile cannot be replaced, or if the tileset
+ ; does not contain a tile you can replace.
+
+ ; Dictionary lookup for pointer to tile replacement table
push bc
ld a, [wTileset]
ld de, 3
call IsInArray
pop bc
jr nc, .nope
+ ; Load the pointer
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
+ ; Look up the tile you're facing
ld de, 3
ld a, c
call IsInArray
jr nc, .nope
+ ; Load the replacement to b
inc hl
ld b, [hl]
+ ; Load the animation type parameter to c
inc hl
ld c, [hl]
scf
@@ -3466,16 +2434,16 @@ CheckOverworldTileArrays: ; c840
CutTreeBlockPointers: ; c862
; Which tileset are we in?
- dbw TILESET_JOHTO_1, .one
- dbw TILESET_JOHTO_2, .two
- dbw TILESET_KANTO, .three
- dbw TILESET_PARK, .twentyfive
- dbw TILESET_ILEX_FOREST, .thirtyone
+ dbw TILESET_JOHTO_1, .johto1
+ dbw TILESET_JOHTO_2, .johto2
+ dbw TILESET_KANTO, .kanto
+ dbw TILESET_PARK, .park
+ dbw TILESET_ILEX_FOREST, .ilex
db -1
; c872
-.one: ; Johto OW
-; Which meta tile are we facing, which should we replace it with, and does it affect encounters?
+.johto1: ; Johto OW
+; Which meta tile are we facing, which should we replace it with, and which animation?
db $03, $02, $01 ; grass
db $5b, $3c, $00 ; tree
db $5f, $3d, $00 ; tree
@@ -3484,12 +2452,12 @@ CutTreeBlockPointers: ; c862
db -1
; c882
-.two: ; Goldenrod area
+.johto2: ; Goldenrod area
db $03, $02, $01 ; grass
db -1
; c886
-.three: ; Kanto OW
+.kanto: ; Kanto OW
db $0b, $0a, $01 ; grass
db $32, $6d, $00 ; tree
db $33, $6c, $00 ; tree
@@ -3499,35 +2467,35 @@ CutTreeBlockPointers: ; c862
db -1
; c899
-.twentyfive: ; National Park
+.park: ; National Park
db $13, $03, $01 ; grass
db $03, $04, $01 ; grass
db -1
; c8a0
-.thirtyone: ; Ilex Forest
+.ilex: ; Ilex Forest
db $0f, $17, $00
db -1
; c8a4
WhirlpoolBlockPointers: ; c8a4
- dbw TILESET_JOHTO_1, .one
+ dbw TILESET_JOHTO_1, .johto
db -1
; c8a8
-.one: ; c8a8
+.johto: ; c8a8
db $07, $36, $00
db -1
; c8ac
-Functionc8ac: ; c8ac
- call Functionc8b5
+OWFlash: ; c8ac
+ call .CheckUseFlash
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c8b5
-Functionc8b5: ; c8b5
+.CheckUseFlash: ; c8b5
; Flash
ld de, ENGINE_ZEPHYRBADGE
callba CheckBadge
@@ -3536,10 +2504,9 @@ Functionc8b5: ; c8b5
callba SpecialAerodactylChamber
pop hl
jr c, .useflash
- ld a, [wd847]
- cp -1
+ ld a, [wTimeOfDayPalset]
+ cp %11111111 ; 3, 3, 3, 3
jr nz, .notadarkcave
-
.useflash
call UseFlash
ld a, $81
@@ -3565,7 +2532,7 @@ Script_UseFlash: ; 0xc8e6
special UpdateTimePals
writetext UnknownText_0xc8f3
callasm BlindingFlash
- loadmovesprites
+ closetext
end
; 0xc8f3
@@ -3576,11 +2543,11 @@ UnknownText_0xc8f3: ; 0xc8f3
ld de, SFX_FLASH
call PlaySFX
call WaitSFX
- ld hl, UnknownText_0xc908
+ ld hl, .BlankText
ret
; c908
-UnknownText_0xc908: ; 0xc908
+.BlankText: ; 0xc908
db "@"
; 0xc909
@@ -3591,18 +2558,16 @@ SurfFunction: ; c909
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c91a
-
.Jumptable: ; c91a (3:491a)
dw .TrySurf
dw .DoSurf
dw .FailSurf
dw .AlreadySurfing
-
.TrySurf: ; c922 (3:4922)
ld de, ENGINE_FOGBADGE
call CheckBadge
@@ -3662,8 +2627,8 @@ SurfFromMenuScript: ; c983
UsedSurfScript: ; c986
writetext UsedSurfText ; "used SURF!"
+ waitbutton
closetext
- loadmovesprites
callasm Functionc9a2 ; empty function
@@ -3698,7 +2663,6 @@ AlreadySurfingText: ; c9b3
db "@"
; c9b8
-
GetSurfType: ; c9b8
; Surfing on Pikachu uses an alternate sprite.
; This is done by using a separate movement type.
@@ -3717,7 +2681,6 @@ GetSurfType: ; c9b8
ret
; c9cb
-
CheckDirection: ; c9cb
; Return carry if a tile permission prevents you
; from moving in the direction you're facing.
@@ -3750,7 +2713,6 @@ CheckDirection: ; c9cb
db FACE_RIGHT
; c9e7
-
TrySurfOW:: ; c9e7
; Checking a tile in the overworld.
; Return carry if surfing is allowed.
@@ -3800,13 +2762,12 @@ TrySurfOW:: ; c9e7
ret
; ca2c
-
AskSurfScript: ; ca2c
- loadfont
+ opentext
writetext AskSurfText
yesorno
iftrue UsedSurfScript
- loadmovesprites
+ closetext
end
; ca36
@@ -3815,25 +2776,23 @@ AskSurfText: ; ca36
db "@" ; Want to SURF?
; ca3b
-
FlyFunction: ; ca3b
call ClearBuffer1
-.asm_ca3e
- ld hl, .data_ca4c
+.loop
+ ld hl, .Jumptable
call FieldMoveJumptable
- jr nc, .asm_ca3e
+ jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; ca4c
-.data_ca4c
+.Jumptable
dw .TryFly
dw .DoFly
dw .FailFly
; ca52
-
.TryFly: ; ca52
; Fly
ld de, ENGINE_STORMBADGE
@@ -3893,13 +2852,13 @@ FlyFunction: ; ca3b
reloadmappart
callasm HideSprites
special UpdateTimePals
- callasm Function8caed
+ callasm FlyFromAnim
farscall Script_AbortBugContest
special WarpToSpawnPoint
callasm DelayLoadingNewSprites
writecode VAR_MOVEMENT, PLAYER_NORMAL
newloadmap MAPSETUP_FLY
- callasm Function8cb33
+ callasm FlyToAnim
special WaitSFX
callasm .ReturnFromFly
end
@@ -3909,14 +2868,14 @@ FlyFunction: ; ca3b
callba Function561d
call DelayFrame
call ReplaceKrisSprite
- callba Function106594
+ callba LoadOverworldFont
ret
; cade
Functioncade: ; cade
call AttemptToWaterfall
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cae7
@@ -3962,8 +2921,8 @@ Script_WaterfallFromMenu: ; 0xcb1c
Script_UsedWaterfall: ; 0xcb20
callasm GetPartyNick
writetext UnknownText_0xcb51
+ waitbutton
closetext
- loadmovesprites
playsound SFX_BUBBLEBEAM
.loop
applymovement PLAYER, WaterfallStep
@@ -4027,11 +2986,11 @@ UnknownText_0xcb81: ; 0xcb81
; 0xcb86
Script_AskWaterfall: ; 0xcb86
- loadfont
+ opentext
writetext UnknownText_0xcb90
yesorno
iftrue Script_UsedWaterfall
- loadmovesprites
+ closetext
end
; 0xcb90
@@ -4040,7 +2999,6 @@ UnknownText_0xcb90: ; 0xcb90
db "@"
; 0xcb95
-
EscapeRopeFunction: ; cb95
call ClearBuffer1
ld a, $1
@@ -4057,7 +3015,7 @@ dig_incave
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cbb2
@@ -4069,16 +3027,16 @@ dig_incave
.CheckCanDig: ; cbb8
call GetMapPermission
- cp $4
+ cp CAVE
jr z, .incave
- cp $7
+ cp DUNGEON
jr z, .incave
.fail
ld a, $2
ret
.incave
- ld hl, wdca9
+ ld hl, wDigWarp
ld a, [hli]
and a
jr z, .fail
@@ -4093,8 +3051,8 @@ dig_incave
; cbd8
.DoDig: ; cbd8
- ld hl, wdca9
- ld de, wd146
+ ld hl, wDigWarp
+ ld de, wNextWarp
ld bc, 3
call CopyBytes
call GetPartyNick
@@ -4159,8 +3117,8 @@ UsedDigScript: ; 0xcc35
writetext UnknownText_0xcc1c
UsedDigOrEscapeRopeScript: ; 0xcc3c
+ waitbutton
closetext
- loadmovesprites
playsound SFX_WARP_TO
applymovement PLAYER, .DigOut
farscall Script_AbortBugContest
@@ -4191,7 +3149,7 @@ TeleportFunction: ; cc61
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cc72
@@ -4208,9 +3166,9 @@ TeleportFunction: ; cc61
jr .nope
.CheckIfSpawnPoint
- ld a, [wdcb2]
+ ld a, [wLastSpawnMapGroup]
ld d, a
- ld a, [wdcb3]
+ ld a, [wLastSpawnMapNumber]
ld e, a
callba IsSpawnPoint
jr nc, .nope
@@ -4257,7 +3215,7 @@ Script_UsedTeleport: ; 0xccbb
writetext UnknownText_0xccb1
pause 60
reloadmappart
- loadmovesprites
+ closetext
playsound SFX_WARP_TO
applymovement PLAYER, .TeleportFrom
farscall Script_AbortBugContest
@@ -4282,7 +3240,7 @@ Script_UsedTeleport: ; 0xccbb
StrengthFunction: ; cce5
call .TryStrength
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; ccee
@@ -4331,7 +3289,7 @@ Functioncd1d: ; cd1d
ld hl, PartySpecies
add hl, de
ld a, [hl]
- ld [wd1ef], a
+ ld [Buffer6], a
call GetPartyNick
ret
; cd29
@@ -4343,11 +3301,11 @@ Script_StrengthFromMenu: ; 0xcd29
Script_UsedStrength: ; 0xcd2d
callasm Functioncd12
writetext UnknownText_0xcd41
- copybytetovar wd1ef
+ copybytetovar Buffer6
cry 0
pause 3
writetext UnknownText_0xcd46
- loadmovesprites
+ closetext
end
; 0xcd41
@@ -4377,11 +3335,11 @@ AskStrengthScript:
; 0xcd5f
.AskStrength: ; 0xcd5f
- loadfont
+ opentext
writetext UnknownText_0xcd69
yesorno
iftrue Script_UsedStrength
- loadmovesprites
+ closetext
end
; 0xcd69
@@ -4439,7 +3397,7 @@ WhirlpoolFunction: ; cd9d
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cdae
@@ -4501,13 +3459,13 @@ TryWhirlpoolMenu: ; cdde
pop hl
jr nc, .failed
ld a, l
- ld [wd1ec], a
+ ld [Buffer3], a
ld a, h
- ld [wd1ed], a
+ ld [Buffer4], a
ld a, b
- ld [wd1ee], a
+ ld [Buffer5], a
ld a, c
- ld [wd1ef], a
+ ld [Buffer6], a
xor a
ret
@@ -4525,21 +3483,21 @@ Script_UsedWhirlpool: ; 0xce0f
writetext UnknownText_0xcdd9
reloadmappart
callasm DisappearWhirlpool
- loadmovesprites
+ closetext
end
; 0xce1d
DisappearWhirlpool: ; ce1d
- ld hl, wd1ec
+ ld hl, Buffer3
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wd1ee]
+ ld a, [Buffer5]
ld [hl], a
xor a
ld [hBGMapMode], a
call OverworldTextModeSwitch
- ld a, [wd1ef]
+ ld a, [Buffer6]
ld e, a
callba PlayWhirlpoolSound
call BufferScreen
@@ -4580,11 +3538,11 @@ UnknownText_0xce69: ; 0xce69
; 0xce6e
Script_AskWhirlpoolOW: ; 0xce6e
- loadfont
+ opentext
writetext UnknownText_0xce78
yesorno
iftrue Script_UsedWhirlpool
- loadmovesprites
+ closetext
end
; 0xce78
@@ -4593,11 +3551,10 @@ UnknownText_0xce78: ; 0xce78
db "@"
; 0xce7d
-
HeadbuttFunction: ; ce7d
call TryHeadbuttFromMenu
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; ce86
@@ -4642,16 +3599,16 @@ HeadbuttScript: ; 0xceab
callasm TreeMonEncounter
iffalse .no_battle
- loadmovesprites
- battlecheck
+ closetext
+ randomwildmon
startbattle
returnafterbattle
end
.no_battle
writetext UnknownText_0xcea2
+ waitbutton
closetext
- loadmovesprites
end
; 0xcec9
@@ -4672,11 +3629,11 @@ TryHeadbuttOW:: ; cec9
; cedc
AskHeadbuttScript: ; 0xcedc
- loadfont
+ opentext
writetext UnknownText_0xcee6
yesorno
iftrue HeadbuttScript
- loadmovesprites
+ closetext
end
; 0xcee6
@@ -4686,11 +3643,10 @@ UnknownText_0xcee6: ; 0xcee6
db "@"
; 0xceeb
-
RockSmashFunction: ; ceeb
call TryRockSmashFromMenu
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cef4
@@ -4742,7 +3698,7 @@ RockSmashFromMenuScript: ; 0xcf2e
RockSmashScript: ; cf32
callasm GetPartyNick
writetext UnknownText_0xcf58
- loadmovesprites
+ closetext
special WaitSFX
playsound SFX_STRENGTH
earthquake 84
@@ -4752,7 +3708,7 @@ RockSmashScript: ; cf32
callasm RockMonEncounter
copybytetovar TempWildMonSpecies
iffalse .done
- battlecheck
+ randomwildmon
startbattle
returnafterbattle
.done
@@ -4772,11 +3728,11 @@ AskRockSmashScript: ; 0xcf5d
callasm HasRockSmash
if_equal 1, .no
- loadfont
+ opentext
writetext UnknownText_0xcf77
yesorno
iftrue RockSmashScript
- loadmovesprites
+ closetext
end
.no
jumptext UnknownText_0xcf72
@@ -4808,7 +3764,6 @@ HasRockSmash: ; cf7c
ld [ScriptVar], a
ret
-
FishFunction: ; cf8e
ld a, e
push af
@@ -4820,7 +3775,7 @@ FishFunction: ; cf8e
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cfa5
@@ -4882,7 +3837,7 @@ FishFunction: ; cf8e
.FishGotSomething: ; cff4
ld a, $1
- ld [wd1ef], a
+ ld [Buffer6], a
ld hl, Script_GotABite
call QueueScript
ld a, $81
@@ -4891,7 +3846,7 @@ FishFunction: ; cf8e
.FishNoBite: ; d002
ld a, $2
- ld [wd1ef], a
+ ld [Buffer6], a
ld hl, Script_NotEvenANibble
call QueueScript
ld a, $81
@@ -4900,7 +3855,7 @@ FishFunction: ; cf8e
.FailFish: ; d010
ld a, $0
- ld [wd1ef], a
+ ld [Buffer6], a
ld hl, Script_NotEvenANibble2
call QueueScript
ld a, $81
@@ -4920,7 +3875,7 @@ Script_NotEvenANibble2: ; 0xd027
Script_NotEvenANibble_FallThrough: ; 0xd02d
loademote EMOTE_SHADOW
callasm PutTheRodAway
- loadmovesprites
+ closetext
end
; 0xd035
@@ -4940,8 +3895,8 @@ Script_GotABite: ; 0xd035
applymovement PLAYER, .Movement_RestoreRod
writetext UnknownText_0xd0a4
callasm PutTheRodAway
- loadmovesprites
- battlecheck
+ closetext
+ randomwildmon
startbattle
returnafterbattle
end
@@ -5033,7 +3988,7 @@ UnknownText_0xd0ae: ; unused
BikeFunction: ; d0b3
call .TryBike
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; d0bc
@@ -5090,7 +4045,7 @@ BikeFunction: ; d0b3
; d119
.CheckIfRegistered: ; d119
- ld a, [wd0ef]
+ ld a, [wUsingItemWithSelect]
and a
ret z
ld h, d
@@ -5125,15 +4080,15 @@ Script_GetOnBike: ; 0xd13e
special UpdateTimePals
writecode VAR_MOVEMENT, PLAYER_BIKE
writetext UnknownText_0xd17c
+ waitbutton
closetext
- loadmovesprites
special ReplaceKrisSprite
end
; 0xd14e
Script_GetOnBike_Register: ; 0xd14e
writecode VAR_MOVEMENT, PLAYER_BIKE
- loadmovesprites
+ closetext
special ReplaceKrisSprite
end
; 0xd156
@@ -5147,10 +4102,10 @@ Script_GetOffBike: ; 0xd158
special UpdateTimePals
writecode VAR_MOVEMENT, PLAYER_NORMAL
writetext UnknownText_0xd181
- closetext
+ waitbutton
FinishGettingOffBike:
- loadmovesprites
+ closetext
special ReplaceKrisSprite
special PlayMapMusic
end
@@ -5163,8 +4118,8 @@ Script_GetOffBike_Register: ; 0xd16b
UnknownScript_0xd171: ; 0xd171
writetext UnknownText_0xd177
+ waitbutton
closetext
- loadmovesprites
end
; 0xd177
@@ -5186,7 +4141,6 @@ UnknownText_0xd181: ; 0xd181
db "@"
; 0xd186
-
TryCutOW:: ; d186
ld d, CUT
call CheckPartyMove
@@ -5211,14 +4165,14 @@ TryCutOW:: ; d186
; d1a9
AskCutScript: ; 0xd1a9
- loadfont
+ opentext
writetext UnknownText_0xd1c8
yesorno
iffalse .script_d1b8
callasm .CheckMap
iftrue Script_Cut
.script_d1b8
- loadmovesprites
+ closetext
end
; 0xd1ba
@@ -5227,7 +4181,7 @@ AskCutScript: ; 0xd1a9
ld [ScriptVar], a
call CheckMapForSomethingToCut
ret c
- ld a, 1
+ ld a, TRUE
ld [ScriptVar], a
ret
; d1c8
@@ -5246,7 +4200,6 @@ UnknownText_0xd1d0: ; 0xd1d0
db "@"
; 0xd1d5
-
_ReceiveItem:: ; d1d5
call DoesHLEqualNumItems
jp nz, PutItemInPocket
@@ -5293,7 +4246,6 @@ _ReceiveItem:: ; d1d5
jp ReceiveTMHM
; d20d
-
_TossItem:: ; d20d
call DoesHLEqualNumItems
jr nz, .remove
@@ -5504,7 +4456,7 @@ RemoveItemFromPocket: ; d2ff
ld e, l
ld a, [hli]
ld c, a
- ld a, [ItemCountBuffer]
+ ld a, [CurItemQuantity]
cp c
jr nc, .ok ; memory
ld c, a
@@ -5677,8 +4629,6 @@ CheckKeyItems: ; d3b1
ret
; d3c4
-
-
ReceiveTMHM: ; d3c4
dec c
ld b, 0
@@ -5737,8 +4687,6 @@ CheckTMHM: ; d3fb
ret
; d407
-
-
GetTMHMNumber:: ; d407
; Return the number of a TM/HM by item id c.
@@ -5760,7 +4708,6 @@ GetTMHMNumber:: ; d407
ret
; d417
-
GetNumberedTMHM: ; d417
; Return the item id of a TM/HM by number c.
@@ -5783,7 +4730,6 @@ GetNumberedTMHM: ; d417
ret
; d427
-
_CheckTossableItem:: ; d427
; Return 1 in wItemAttributeParamBuffer and carry if CurItem can't be removed from the bag.
ld a, ITEMATTR_PERMISSIONS
@@ -5866,7 +4812,6 @@ ItemAttr_ReturnCarry: ; d47f
ret
; d486
-
GetItemPrice: ; d486
; Return the price of CurItem in de.
push hl
@@ -5882,27 +4827,29 @@ GetItemPrice: ; d486
ret
; d497
-
Functiond497:: ; d497 (3:5497)
ld a, [wPlayerStepFlags]
and a
ret z
bit 7, a
- jr nz, .asm_d4a9
+ jr nz, .update_overworld_map
bit 6, a
- jr nz, .asm_d4b3
+ jr nz, .update_player_coords
bit 5, a
- jr nz, .asm_d4b8
+ jr nz, .finish
ret
-.asm_d4a9
+
+.update_overworld_map
ld a, $4
ld [wd13f], a
- call Functiond536
- jr .asm_d4b8
-.asm_d4b3
- call Functiond511
- jr .asm_d4b8
-.asm_d4b8
+ call UpdateOverworldMap
+ jr .finish
+
+.update_player_coords
+ call UpdatePlayerCoords
+ jr .finish
+
+.finish
call Functiond4e5
ld a, [wPlayerStepVectorX]
ld d, a
@@ -5936,23 +4883,23 @@ Functiond4e5: ; d4e5 (3:54e5)
ret z
dec [hl]
ld a, [hl]
- ld hl, Jumptable_d4f2
+ ld hl, .Jumptable
rst JumpTable
ret
-Jumptable_d4f2: ; d4f2 (3:54f2)
- dw GetMovementPermissions
- dw BufferScreen
- dw .mobile
- dw .fail2
- dw .fail1
- dw .fail1
- dw .fail1
- dw .fail1
- dw .fail1
- dw .fail1
- dw .fail1
-
+.Jumptable: ; d4f2 (3:54f2)
+ jumptable_start
+ jumptable GetMovementPermissions
+ jumptable BufferScreen
+ jumptable .mobile
+ jumptable .fail2
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
.fail1: ; d508 (3:5508)
ret
@@ -5964,71 +4911,74 @@ Jumptable_d4f2: ; d4f2 (3:54f2)
.fail2: ; d510 (3:5510)
ret
-Functiond511: ; d511 (3:5511)
+UpdatePlayerCoords: ; d511 (3:5511)
ld a, [wPlayerStepDirection]
and a
- jr nz, .asm_d51c
+ jr nz, .check_step_down
ld hl, YCoord
inc [hl]
ret
-.asm_d51c
- cp $1
- jr nz, .asm_d525
+
+.check_step_down
+ cp UP
+ jr nz, .check_step_left
ld hl, YCoord
dec [hl]
ret
-.asm_d525
- cp $2
- jr nz, .asm_d52e
+
+.check_step_left
+ cp LEFT
+ jr nz, .check_step_right
ld hl, XCoord
dec [hl]
ret
-.asm_d52e
- cp $3
+
+.check_step_right
+ cp RIGHT
ret nz
ld hl, XCoord
inc [hl]
ret
-Functiond536: ; d536 (3:5536)
+UpdateOverworldMap: ; d536 (3:5536)
ld a, [wPlayerStepDirection]
and a
- jr z, .asm_d549
- cp $1
- jr z, .asm_d553
- cp $2
- jr z, .asm_d55d
- cp $3
- jr z, .asm_d567
+ jr z, .step_down
+ cp UP
+ jr z, .step_up
+ cp LEFT
+ jr z, .step_left
+ cp RIGHT
+ jr z, .step_right
ret
-.asm_d549
- call Functiond571
+.step_down
+ call .ScrollOverworldMapDown
call LoadMapPart
call ScrollMapUp
ret
-.asm_d553
- call Functiond5a2
+.step_up
+ call .ScrollOverworldMapUp
call LoadMapPart
call ScrollMapDown
ret
-.asm_d55d
- call Functiond5d5
+.step_left
+ call .ScrollOverworldMapLeft
call LoadMapPart
- call ScrollMapLeft
+ call ScrollMapRight
ret
-.asm_d567
- call Functiond5fe
+.step_right
+ call .ScrollOverworldMapRight
call LoadMapPart
- call ScrollMapRight
+ call ScrollMapLeft
ret
-Functiond571: ; d571 (3:5571)
+.ScrollOverworldMapDown: ; d571 (3:5571)
ld a, [wBGMapAnchor]
- add $40
+ add 2 * BG_MAP_WIDTH
ld [wBGMapAnchor], a
jr nc, .not_overflowed
ld a, [wBGMapAnchor + 1]
@@ -6037,29 +4987,29 @@ Functiond571: ; d571 (3:5571)
or VBGMap0 / $100
ld [wBGMapAnchor + 1], a
.not_overflowed
- ld hl, wd196
+ ld hl, wMetatileStandingY
inc [hl]
ld a, [hl]
- cp $2 ; was 1
- jr nz, .skip
- ld [hl], $0
- call Functiond595
-.skip
+ cp 2 ; was 1
+ jr nz, .done_down
+ ld [hl], 0
+ call .Add6ToOverworldMapAnchor
+.done_down
ret
-Functiond595: ; d595 (3:5595)
- ld hl, wd194
+.Add6ToOverworldMapAnchor: ; d595 (3:5595)
+ ld hl, wOverworldMapAnchor
ld a, [MapWidth]
- add $6
+ add 6
add [hl]
ld [hli], a
ret nc
inc [hl]
ret
-Functiond5a2: ; d5a2 (3:55a2)
+.ScrollOverworldMapUp: ; d5a2 (3:55a2)
ld a, [wBGMapAnchor]
- sub $40
+ sub 2 * BG_MAP_WIDTH
ld [wBGMapAnchor], a
jr nc, .not_underflowed
ld a, [wBGMapAnchor + 1]
@@ -6068,20 +5018,20 @@ Functiond5a2: ; d5a2 (3:55a2)
or VBGMap0 / $100
ld [wBGMapAnchor + 1], a
.not_underflowed
- ld hl, wd196
+ ld hl, wMetatileStandingY
dec [hl]
ld a, [hl]
- cp $ff ; was 0
- jr nz, .skip
+ cp -1 ; was 0
+ jr nz, .done_up
ld [hl], $1
- call Functiond5c6
-.skip
+ call .Sub6FromOverworldMapAnchor
+.done_up
ret
-Functiond5c6: ; d5c6 (3:55c6)
- ld hl, wd194
+.Sub6FromOverworldMapAnchor: ; d5c6 (3:55c6)
+ ld hl, wOverworldMapAnchor
ld a, [MapWidth]
- add $6
+ add 6
ld b, a
ld a, [hl]
sub b
@@ -6090,7 +5040,7 @@ Functiond5c6: ; d5c6 (3:55c6)
dec [hl]
ret
-Functiond5d5: ; d5d5 (3:55d5)
+.ScrollOverworldMapLeft: ; d5d5 (3:55d5)
ld a, [wBGMapAnchor]
ld e, a
and $e0
@@ -6100,26 +5050,26 @@ Functiond5d5: ; d5d5 (3:55d5)
and $1f
or d
ld [wBGMapAnchor], a
- ld hl, wd197
+ ld hl, wMetatileStandingX
dec [hl]
ld a, [hl]
- cp $ff
- jr nz, .asm_d5f3
- ld [hl], $1
- call Functiond5f4
-.asm_d5f3
+ cp -1
+ jr nz, .done_left
+ ld [hl], 1
+ call .DecrementwOverworldMapAnchor
+.done_left
ret
-Functiond5f4: ; d5f4 (3:55f4)
- ld hl, wd194
+.DecrementwOverworldMapAnchor: ; d5f4 (3:55f4)
+ ld hl, wOverworldMapAnchor
ld a, [hl]
- sub $1
+ sub 1
ld [hli], a
ret nc
dec [hl]
ret
-Functiond5fe: ; d5fe (3:55fe)
+.ScrollOverworldMapRight: ; d5fe (3:55fe)
ld a, [wBGMapAnchor]
ld e, a
and $e0
@@ -6129,459 +5079,26 @@ Functiond5fe: ; d5fe (3:55fe)
and $1f
or d
ld [wBGMapAnchor], a
- ld hl, wd197
+ ld hl, wMetatileStandingX
inc [hl]
ld a, [hl]
- cp $2
- jr nz, .asm_d61c
- ld [hl], $0
- call .Incrementwd194
-.asm_d61c
+ cp 2
+ jr nz, .done_right
+ ld [hl], 0
+ call .IncrementwOverworldMapAnchor
+.done_right
ret
-.Incrementwd194: ; d61d (3:561d)
- ld hl, wd194
+.IncrementwOverworldMapAnchor: ; d61d (3:561d)
+ ld hl, wOverworldMapAnchor
ld a, [hl]
- add $1
+ add 1
ld [hli], a
ret nc
inc [hl]
ret
-_AnimateHPBar: ; d627
- call Functiond65f
- jr c, .do_player
- call Functiond670
-.enemy_loop
- push bc
- push hl
- call Functiond6e2
- pop hl
- pop bc
- push af
- push bc
- push hl
- call Functiond730
- call Functiond7c9
- pop hl
- pop bc
- pop af
- jr nc, .enemy_loop
- ret
-
-.do_player
- call Functiond670
-.player_loop
- push bc
- push hl
- call Functiond6f5
- pop hl
- pop bc
- ret c
- push af
- push bc
- push hl
- call Functiond749
- call Functiond7c9
- pop hl
- pop bc
- pop af
- jr nc, .player_loop
- ret
-; d65f
-
-Functiond65f: ; d65f
- ld a, [Buffer2]
- and a
- jr nz, .player
- ld a, [Buffer1]
- cp $30
- jr nc, .player
- and a
- ret
-
-.player
- scf
- ret
-; d670
-
-Functiond670: ; d670
- push hl
- ld hl, Buffer1
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- ld c, a
- ld a, [hli]
- ld b, a
- pop hl
- call DrawPartyMenuHPBar
- ld a, e
- ld [wd1f1], a
- ld a, [wd1ee]
- ld c, a
- ld a, [wd1ef]
- ld b, a
- ld a, [Buffer1]
- ld e, a
- ld a, [Buffer2]
- ld d, a
- call DrawPartyMenuHPBar
- ld a, e
- ld [wd1f2], a
- push hl
- ld hl, wd1ec
- ld a, [hli]
- ld c, a
- ld a, [hli]
- ld b, a
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- pop hl
- ld a, e
- sub c
- ld e, a
- ld a, d
- sbc b
- ld d, a
- jr c, .asm_d6c1
- ld a, [wd1ec]
- ld [wd1f5], a
- ld a, [wd1ee]
- ld [wd1f6], a
- ld bc, 1
- jr .asm_d6d9
-
-.asm_d6c1
- ld a, [wd1ec]
- ld [wd1f6], a
- ld a, [wd1ee]
- ld [wd1f5], a
- ld a, e
- xor $ff
- inc a
- ld e, a
- ld a, d
- xor $ff
- ld d, a
- ld bc, rIE
-
-.asm_d6d9
- ld a, d
- ld [wd1f3], a
- ld a, e
- ld [wd1f4], a
- ret
-; d6e2
-
-Functiond6e2: ; d6e2
- ld hl, wd1f1
- ld a, [wd1f2]
- cp [hl]
- jr nz, .asm_d6ed
- scf
- ret
-
-.asm_d6ed
- ld a, c
- add [hl]
- ld [hl], a
- call Functiond839
- and a
- ret
-; d6f5
-
-Functiond6f5: ; d6f5
-.asm_d6f5
- ld hl, wd1ec
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, e
- cp [hl]
- jr nz, .asm_d707
- inc hl
- ld a, d
- cp [hl]
- jr nz, .asm_d707
- scf
- ret
-
-.asm_d707
- ld l, e
- ld h, d
- add hl, bc
- ld a, l
- ld [wd1ec], a
- ld a, h
- ld [wd1ed], a
- push hl
- push de
- push bc
- ld hl, Buffer1
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- ld c, a
- ld a, [hli]
- ld b, a
- call DrawPartyMenuHPBar
- pop bc
- pop de
- pop hl
- ld a, e
- ld hl, wd1f1
- cp [hl]
- jr z, .asm_d6f5
- ld [hl], a
- and a
- ret
-; d730
-
-Functiond730: ; d730
- call Functiond784
- ld d, $6
- ld a, [wd10a]
- and $1
- ld b, a
- ld a, [wd1f1]
- ld e, a
- ld c, a
- push de
- call Functiond771
- pop de
- call Functiond7b4
- ret
-; d749
-
-Functiond749: ; d749
- call Functiond784
- ld a, [wd1ec]
- ld c, a
- ld a, [wd1ed]
- ld b, a
- ld a, [Buffer1]
- ld e, a
- ld a, [Buffer2]
- ld d, a
- call DrawPartyMenuHPBar
- ld c, e
- ld d, $6
- ld a, [wd10a]
- and $1
- ld b, a
- push de
- call Functiond771
- pop de
- call Functiond7b4
- ret
-; d771
-
-Functiond771: ; d771
- ld a, [wd10a]
- cp $2
- jr nz, .asm_d780
- ld a, $28
- add l
- ld l, a
- ld a, $0
- adc h
- ld h, a
-
-.asm_d780
- call DrawBattleHPBar
- ret
-; d784
-
-Functiond784: ; d784
- ld a, [wd10a]
- and a
- ret z
- cp $1
- jr z, .load_15
- ld de, $16
- jr .loaded_de
-
-.load_15
- ld de, $15
-
-.loaded_de
- push hl
- add hl, de
- ld a, " "
-rept 2
- ld [hli], a
-endr
- ld [hld], a
- dec hl
- ld a, [wd1ec]
- ld [StringBuffer2 + 1], a
- ld a, [wd1ed]
- ld [StringBuffer2], a
- ld de, StringBuffer2
- lb bc, 2, 3
- call PrintNum
- pop hl
- ret
-; d7b4
-
-Functiond7b4: ; d7b4
- ld a, [hCGB]
- and a
- ret z
- ld hl, wd1f0
- call SetHPPal
- ld a, [wd1f0]
- ld c, a
- callba Function8c43
- ret
-; d7c9
-
-Functiond7c9: ; d7c9
- ld a, [hCGB]
- and a
- jr nz, .cgb
- call DelayFrame
- call DelayFrame
- ret
-
-.cgb
- ld a, [wd10a]
- and a
- jr z, .load_0
- cp $1
- jr z, .load_1
- ld a, [CurPartyMon]
- cp $3
- jr nc, .c_is_1
- ld c, $0
- jr .c_is_0
-
-.c_is_1
- ld c, $1
-
-.c_is_0
- push af
- cp $2
- jr z, .skip_delay
- cp $5
- jr z, .skip_delay
- ld a, $2
- ld [hBGMapMode], a
- ld a, c
- ld [hBGMapThird], a
- call DelayFrame
-
-.skip_delay
- ld a, $1
- ld [hBGMapMode], a
- ld a, c
- ld [hBGMapThird], a
- call DelayFrame
- pop af
- cp $2
- jr z, .two_frames
- cp $5
- jr z, .two_frames
- ret
-
-.two_frames
- inc c
- ld a, $2
- ld [hBGMapMode], a
- ld a, c
- ld [hBGMapThird], a
- call DelayFrame
- ld a, $1
- ld [hBGMapMode], a
- ld a, c
- ld [hBGMapThird], a
- call DelayFrame
- ret
-
-.load_0
- ld c, $0
- jr .finish
-
-.load_1
- ld c, $1
-
-.finish
- call DelayFrame
- ld a, c
- ld [hBGMapThird], a
- call DelayFrame
- ret
-; d839
-
-Functiond839: ; d839
- ld a, [Buffer1]
- ld c, a
- ld b, $0
- ld hl, 0
- ld a, [wd1f1]
- cp $30
- jr nc, .coppy_buffer
- and a
- jr z, .return_zero
- call AddNTimes
- ld b, $0
-.loop
- ld a, l
- sub $30
- ld l, a
- ld a, h
- sbc $0
- ld h, a
- jr c, .done
- inc b
- jr .loop
-
-.done
- push bc
- ld bc, $80
- add hl, bc
- pop bc
- ld a, l
- sub $30
- ld l, a
- ld a, h
- sbc $0
- ld h, a
- jr c, .no_carry
- inc b
-
-.no_carry
- ld a, [wd1f5]
- cp b
- jr nc, .finish
- ld a, [wd1f6]
- cp b
- jr c, .finish
- ld a, b
-
-.finish
- ld [wd1ec], a
- ret
-
-.return_zero
- xor a
- ld [wd1ec], a
- ret
-
-.coppy_buffer
- ld a, [Buffer1]
- ld [wd1ec], a
- ret
-; d88c
-
+INCLUDE "engine/anim_hp_bar.asm"
TryAddMonToParty: ; d88c
; Check if to copy wild Pkmn or generate new Pkmn
@@ -6723,13 +5240,13 @@ endr
ld d, a
callab CalcExpAtLevel
pop de
- ld a, [hMultiplicand]
+ ld a, [hProduct + 1]
ld [de], a
inc de
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [de], a
inc de
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [de], a
inc de
xor a
@@ -6809,12 +5326,12 @@ endr
add hl, bc
ld a, $1
ld c, a
- ld b, $0
+ ld b, FALSE
call CalcPkmnStatC
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [de], a
inc de
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [de], a
inc de
jr .next2
@@ -6906,7 +5423,6 @@ endr
ret
; da6d
-
FillPP: ; da6d
push bc
ld b, NUM_MOVES
@@ -7012,17 +5528,16 @@ AddTempmonToParty: ; da96
call AddNTimes
predef GetUnownLetter
callab UpdateUnownDex
- ld a, [wdef4]
+ ld a, [wFirstUnownSeen]
and a
jr nz, .done
ld a, [UnownLetter]
- ld [wdef4], a
+ ld [wFirstUnownSeen], a
.done
and a
ret
-
SentGetPkmnIntoFromBox: ; db3f
; Sents/Gets Pkmn into/from Box depending on Parameter
; wPokemonWithdrawDepositParameter == 0: get Pkmn into Party
@@ -7201,7 +5716,7 @@ SentGetPkmnIntoFromBox: ; db3f
add hl, bc
ld d, h
ld e, l
- ld hl, MON_EXP + 2
+ ld hl, MON_STAT_EXP - 1
add hl, bc
push bc
@@ -7245,7 +5760,6 @@ endr
dec a
ld b, a
call Functiondcb6
-
.CloseSRAM_And_ClearCarryFlag
call CloseSRAM
and a
@@ -7258,7 +5772,6 @@ CloseSRAM_And_SetCarryFlag: ; dcb1
ret
; dcb6
-
Functiondcb6: ; dcb6
ld a, b
ld hl, sBoxMons
@@ -7283,7 +5796,7 @@ Functiondcb6: ; dcb6
pop hl
pop de
- ld a, [MenuSelection2]
+ ld a, [wMenuCursorY]
push af
ld a, [MonType]
push af
@@ -7292,11 +5805,11 @@ Functiondcb6: ; dcb6
ld a, [hli]
and a
jr z, .asm_dd18
- ld [TempMonMoves+0], a
+ ld [TempMonMoves], a
ld a, BOXMON
ld [MonType], a
ld a, b
- ld [MenuSelection2], a
+ ld [wMenuCursorY], a
push bc
push hl
push de
@@ -7320,11 +5833,10 @@ Functiondcb6: ; dcb6
pop af
ld [MonType], a
pop af
- ld [MenuSelection2], a
+ ld [wMenuCursorY], a
ret
; dd21
-
Functiondd21: ; dd21
ld a, [wBreedMon1Species]
ld [CurPartySpecies], a
@@ -7470,7 +5982,7 @@ Functionde2a: ; de2a
call Functionde44
xor a
ld [wPokemonWithdrawDepositParameter], a
- jp Functione039
+ jp RemoveMonFromPartyOrBox
; de37
Functionde37: ; de37
@@ -7478,7 +5990,7 @@ Functionde37: ; de37
call Functionde44
xor a
ld [wPokemonWithdrawDepositParameter], a
- jp Functione039
+ jp RemoveMonFromPartyOrBox
; de44
Functionde44: ; de44
@@ -7497,7 +6009,6 @@ Functionde44: ; de44
ld bc, BOXMON_STRUCT_LENGTH
jp CopyBytes
-
SentPkmnIntoBox: ; de6e
; Sents the Pkmn into one of Bills Boxes
; the data comes mainly from 'EnemyMon:'
@@ -7506,14 +6017,14 @@ SentPkmnIntoBox: ; de6e
ld de, sBoxCount
ld a, [de]
cp MONS_PER_BOX
- jp nc, Functiondf42
+ jp nc, .full
inc a
ld [de], a
ld a, [CurPartySpecies]
ld [CurSpecies], a
ld c, a
-.asm_de85
+.loop
inc de
ld a, [de]
ld b, a
@@ -7521,7 +6032,7 @@ SentPkmnIntoBox: ; de6e
ld c, b
ld [de], a
inc a
- jr nz, .asm_de85
+ jr nz, .loop
call GetBaseData
call ShiftBoxMon
@@ -7557,33 +6068,33 @@ SentPkmnIntoBox: ; de6e
ld d, a
callab CalcExpAtLevel
pop de
- ld a, [hMultiplicand]
+ ld a, [hProduct + 1]
ld [de], a
inc de
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [de], a
inc de
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [de], a
inc de
; Set all 5 Experience Values to 0
xor a
- ld b, 2*5
-.asm_dee5
+ ld b, 2 * 5
+.loop2
ld [de], a
inc de
dec b
- jr nz, .asm_dee5
+ jr nz, .loop2
ld hl, EnemyMonDVs
ld b, 2 + NUM_MOVES ; DVs and PP ; EnemyMonHappiness - EnemyMonDVs
-.asm_deef
+.loop3
ld a, [hli]
ld [de], a
inc de
dec b
- jr nz, .asm_deef
+ jr nz, .loop3
ld a, BASE_HAPPINESS
ld [de], a
@@ -7602,12 +6113,12 @@ SentPkmnIntoBox: ; de6e
call SetSeenAndCaughtMon
ld a, [CurPartySpecies]
cp UNOWN
- jr nz, .asm_df20
+ jr nz, .not_unown
ld hl, sBoxMon1DVs
predef GetUnownLetter
callab UpdateUnownDex
-.asm_df20
+.not_unown
ld hl, sBoxMon1Moves
ld de, TempMonMoves
ld bc, NUM_MOVES
@@ -7626,8 +6137,7 @@ SentPkmnIntoBox: ; de6e
ret
; df42
-
-Functiondf42: ; df42
+.full: ; df42
call CloseSRAM
and a
ret
@@ -7636,16 +6146,16 @@ Functiondf42: ; df42
ShiftBoxMon: ; df47
ld hl, sBoxMonOT
ld bc, NAME_LENGTH
- call .asm_df5f
+ call .shift
ld hl, sBoxMonNicknames
ld bc, PKMN_NAME_LENGTH
- call .asm_df5f
+ call .shift
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
-.asm_df5f
+.shift
ld a, [sBoxCount]
cp 2
ret c
@@ -7762,11 +6272,11 @@ GiveEgg:: ; df8c
call AddNTimes
ld a, [wc2cc]
bit 1, a
- ld a, $1
- jr nz, .asm_e022
+ ld a, 1
+ jr nz, .got_init_happiness
ld a, [BaseEggSteps]
-.asm_e022
+.got_init_happiness
ld [hl], a
ld a, [PartyCount]
dec a
@@ -7784,7 +6294,7 @@ String_Egg: ; e035
db "EGG@"
; e039
-Functione039: ; e039
+RemoveMonFromPartyOrBox: ; e039
ld hl, PartyCount
ld a, [wPokemonWithdrawDepositParameter]
@@ -7806,30 +6316,33 @@ Functione039: ; e039
ld e, l
ld d, h
inc de
-.asm_e057
+.loop
ld a, [de]
inc de
ld [hli], a
inc a
- jr nz, .asm_e057
+ jr nz, .loop
ld hl, PartyMonOT
ld d, PARTY_LENGTH - 1
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e06d
+ jr z, .party
ld hl, sBoxMonOT
ld d, MONS_PER_BOX - 1
-.asm_e06d
+.party
+ ; If this is the last mon in our party (box),
+ ; shift all the other mons up to close the gap.
ld a, [CurPartyMon]
call SkipNames
ld a, [CurPartyMon]
cp d
- jr nz, .asm_e07e
- ld [hl], $ff
- jp .asm_60f0
+ jr nz, .delete_inside
+ ld [hl], -1
+ jp .finish
-.asm_e07e
+.delete_inside
+ ; Shift the OT names
ld d, h
ld e, l
ld bc, PKMN_NAME_LENGTH
@@ -7837,46 +6350,44 @@ Functione039: ; e039
ld bc, PartyMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e090
+ jr z, .party2
ld bc, sBoxMonNicknames
-.asm_e090
+.party2
call CopyDataUntil
-
+ ; Shift the struct
ld hl, PartyMons
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0a5
+ jr z, .party4
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
-
-.asm_e0a5
+.party4
ld a, [CurPartyMon]
call AddNTimes
ld d, h
ld e, l
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0bc
+ jr z, .party5
ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
ld bc, sBoxMonOT
- jr .asm_e0c3
+ jr .copy
-.asm_e0bc
+.party5
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
ld bc, PartyMonOT
-
-.asm_e0c3
+.copy
call CopyDataUntil
+ ; Shift the nicknames
ld hl, PartyMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0d2
+ jr z, .party6
ld hl, sBoxMonNicknames
-
-.asm_e0d2
+.party6
ld bc, PKMN_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
@@ -7887,25 +6398,27 @@ Functione039: ; e039
ld bc, PartyMonNicknamesEnd
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0ed
+ jr z, .party7
ld bc, sBoxMonNicknamesEnd
-
-.asm_e0ed
+.party7
call CopyDataUntil
-
-.asm_60f0
+ ; Mail time!
+.finish
ld a, [wPokemonWithdrawDepositParameter]
and a
jp nz, CloseSRAM
ld a, [wLinkMode]
and a
ret nz
+ ; Shift mail
ld a, BANK(sPartyMail)
call GetSRAMBank
+ ; If this is the last mon in our party, no need to shift mail.
ld hl, PartyCount
ld a, [CurPartyMon]
cp [hl]
- jr z, .asm_e131
+ jr z, .close_sram
+ ; Shift our mail messages up.
ld hl, sPartyMail
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
@@ -7914,7 +6427,7 @@ Functione039: ; e039
pop de
ld a, [CurPartyMon]
ld b, a
-.asm_e11a
+.loop2
push bc
push hl
ld bc, MAIL_STRUCT_LENGTH
@@ -7928,13 +6441,12 @@ Functione039: ; e039
inc b
ld a, [PartyCount]
cp b
- jr nz, .asm_e11a
-
-.asm_e131
+ jr nz, .loop2
+.close_sram
jp CloseSRAM
; e134
-Functione134: ; e134
+ComputeNPCTrademonStats: ; e134
ld a, MON_LEVEL
call GetPartyParamLocation
ld a, [hl]
@@ -7949,7 +6461,7 @@ Functione134: ; e134
ld d, h
ld e, l
push de
- ld a, MON_EXP + 2
+ ld a, MON_STAT_EXP - 1
call GetPartyParamLocation
ld b, $1
call CalcPkmnStats
@@ -7966,8 +6478,9 @@ Functione134: ; e134
CalcPkmnStats: ; e167
; Calculates all 6 Stats of a Pkmn
-; b = 0 or 1
+; b: Take into account stat EXP if TRUE
; 'c' counts from 1-6 and points with 'BaseStats' to the base value
+; hl is the path to the Stat EXP
; results in $ffb5 and $ffb6 are saved in [de]
ld c, $0
@@ -8200,7 +6713,7 @@ GivePoke:: ; e277
ld e, l
pop bc
ld a, b
- ld b, $0
+ ld b, 0
push bc
push de
push af
@@ -8220,15 +6733,15 @@ GivePoke:: ; e277
ld [TempEnemyMonSpecies], a
callab LoadEnemyMon
call SentPkmnIntoBox
- jp nc, Functione3d4
- ld a, $2
+ jp nc, .FailedToGiveMon
+ ld a, BOXMON
ld [MonType], a
xor a
ld [CurPartyMon], a
- ld de, wd050
+ ld de, wMonOrItemNameBuffer
pop bc
ld a, b
- ld b, $1
+ ld b, 1
push bc
push de
push af
@@ -8244,12 +6757,12 @@ GivePoke:: ; e277
ld [TempEnemyMonSpecies], a
call GetPokemonName
ld hl, StringBuffer1
- ld de, wd050
+ ld de, wMonOrItemNameBuffer
ld bc, PKMN_NAME_LENGTH
call CopyBytes
pop af
and a
- jp z, .asm_e390
+ jp z, .wildmon
pop de
pop bc
pop hl
@@ -8271,7 +6784,7 @@ endr
and a
push de
push bc
- jr nz, .asm_e35e
+ jr nz, .send_to_box
push hl
ld a, [CurPartyMon]
@@ -8303,7 +6816,7 @@ endr
callba SetGiftPartyMonCaughtData
jr .skip_nickname
-.asm_e35e
+.send_to_box
ld a, BANK(sBoxMonOT)
call GetSRAMBank
ld de, sBoxMonOT
@@ -8327,21 +6840,20 @@ endr
callba SetGiftBoxMonCaughtData
jr .skip_nickname
-.asm_e390
+.wildmon
pop de
pop bc
push bc
push de
ld a, b
and a
- jr z, .asm_e3a0
+ jr z, .party
callba SetBoxMonCaughtData
- jr .asm_e3a6
+ jr .set_caught_data
-.asm_e3a0
+.party
callba SetCaughtData
-
-.asm_e3a6
+.set_caught_data
callba GiveANickname_YesNo
pop de
jr c, .skip_nickname
@@ -8357,7 +6869,7 @@ endr
call PrintText
ld a, BANK(sBoxMonNicknames)
call GetSRAMBank
- ld hl, wd050
+ ld hl, wMonOrItemNameBuffer
ld de, sBoxMonNicknames
ld bc, PKMN_NAME_LENGTH
call CopyBytes
@@ -8366,14 +6878,13 @@ endr
ret
; e3d4
-Functione3d4: ; e3d4
+.FailedToGiveMon: ; e3d4
pop bc
pop de
ld b, $2
ret
; e3d9
-
TextJump_WasSentToBillsPC: ; 0xe3d9
; was sent to BILL's PC.
text_jump Text_WasSentToBillsPC
@@ -8444,7 +6955,7 @@ _BillsPC: ; e3fd
; 0xe43f
.LogOut: ; e43f (3:643f)
- call ReturnToCallingMenu
+ call CloseSubmenu
ret
.UseBillsPC: ; e443 (3:6443)
@@ -8455,7 +6966,7 @@ _BillsPC: ; e3fd
ld [wMenuCursorBuffer], a
call SetPalettes
xor a
- ld [wcf76], a
+ ld [wWhichIndexSet], a
ld [hBGMapMode], a
call DoNthMenu
jr c, .cancel
@@ -8484,7 +6995,7 @@ _BillsPC: ; e3fd
db $80 ; flags
db 0 ; items
dw .items
- dw Function1f79
+ dw PlaceMenuStrings
dw .strings
; 0xe47f
@@ -8589,7 +7100,6 @@ Functione512: ; unused
db "@"
; 0xe538
-
CheckCurPartyMonFainted: ; e538
ld hl, PartyMon1HP
ld de, PARTYMON_STRUCT_LENGTH
@@ -8620,7 +7130,6 @@ CheckCurPartyMonFainted: ; e538
ret
; e559
-
BillsPC_WithdrawMenu: ; e559 (3:6559)
call LoadStandardMenuDataHeader
callba _WithdrawPKMN
@@ -8672,7 +7181,7 @@ ClearPCItemScreen: ; e58b
hlcoord 0,12
lb bc, 4, 18
call TextBox
- call Function3200
+ call WaitBGMap2
call SetPalettes ; load regular palettes?
ret
; 0xe5bb
@@ -8840,7 +7349,6 @@ Functione6b3: ; e6b3
ret
; e6ce
-
BugContest_SetCaughtContestMon: ; e6ce
ld a, [wContestMon]
and a
@@ -8883,10 +7391,8 @@ BugContest_SetCaughtContestMon: ; e6ce
db "@"
; 0xe722
-
INCLUDE "items/item_effects.asm"
-
GetPokeBallWobble: ; f971 (3:7971)
; Returns whether a Poke Ball will wobble in the catch animation.
; Whether a Pokemon is caught is determined beforehand.
@@ -8908,7 +7414,7 @@ GetPokeBallWobble: ; f971 (3:7971)
cp 3 + 1
jr z, .finished
- ld a, [wc64e]
+ ld a, [wWildMon]
and a
ld c, 0 ; next
jr nz, .done
@@ -8933,7 +7439,7 @@ GetPokeBallWobble: ; f971 (3:7971)
jr .done
.finished
- ld a, [wc64e]
+ ld a, [wWildMon]
and a
ld c, 1 ; caught
jr nz, .done
@@ -8977,36 +7483,34 @@ WobbleChances: ; f9ba
db 255, 255
; f9ea
-
KnowsMove: ; f9ea
ld a, MON_MOVES
call GetPartyParamLocation
- ld a, [wd262]
+ ld a, [wPutativeTMHMMove]
ld b, a
ld c, NUM_MOVES
-.asm_f9f5
+.loop
ld a, [hli]
cp b
- jr z, .asm_f9fe
+ jr z, .knows_move
dec c
- jr nz, .asm_f9f5
+ jr nz, .loop
and a
ret
-.asm_f9fe
- ld hl, UnknownText_0xfa06
+.knows_move
+ ld hl, .Text_knows
call PrintText
scf
ret
; fa06
-UnknownText_0xfa06: ; 0xfa06
+.Text_knows: ; 0xfa06
; knows @ .
text_jump UnknownText_0x1c5ea8
db "@"
; 0xfa0b
-
SECTION "bank4", ROMX, BANK[$4]
INCLUDE "engine/pack.asm"
@@ -9044,7 +7548,7 @@ Special_GiveParkBalls: ; 135db
BugCatchingContestBattleScript:: ; 0x135eb
writecode VAR_BATTLETYPE, BATTLETYPE_CONTEST
- battlecheck
+ randomwildmon
startbattle
returnafterbattle
copybytetovar wParkBallsRemaining
@@ -9054,40 +7558,40 @@ BugCatchingContestBattleScript:: ; 0x135eb
BugCatchingContestOverScript:: ; 0x135f8
playsound SFX_ELEVATOR_END
- loadfont
- writetext UnknownText_0x1360f
- closetext
+ opentext
+ writetext BugCatchingContestText_BeeepTimesUp
+ waitbutton
jump BugCatchingContestReturnToGateScript
; 0x13603
BugCatchingContestOutOfBallsScript: ; 0x13603
playsound SFX_ELEVATOR_END
- loadfont
- writetext UnknownText_0x13614
- closetext
+ opentext
+ writetext BugCatchingContestText_ContestIsOver
+ waitbutton
BugCatchingContestReturnToGateScript: ; 0x1360b
- loadmovesprites
+ closetext
jumpstd bugcontestresultswarp
; 0x1360f
-UnknownText_0x1360f: ; 0x1360f
+BugCatchingContestText_BeeepTimesUp: ; 0x1360f
; ANNOUNCER: BEEEP! Time's up!
text_jump UnknownText_0x1bd2ca
db "@"
; 0x13614
-UnknownText_0x13614: ; 0x13614
+BugCatchingContestText_ContestIsOver: ; 0x13614
; ANNOUNCER: The Contest is over!
text_jump UnknownText_0x1bd2e7
db "@"
; 0x13619
RepelWoreOffScript:: ; 0x13619
- loadfont
+ opentext
writetext .text
+ waitbutton
closetext
- loadmovesprites
end
; 0x13620
@@ -9097,8 +7601,8 @@ RepelWoreOffScript:: ; 0x13619
db "@"
; 0x13625
-SignpostItemScript:: ; 0x13625
- loadfont
+HiddenItemScript:: ; 0x13625
+ opentext
copybytetovar EngineBuffer3
itemtotext 0, 0
writetext .found_text
@@ -9111,12 +7615,12 @@ SignpostItemScript:: ; 0x13625
; 0x1363e
.bag_full: ; 0x1363e
- keeptextopen
+ buttonsound
writetext .no_room_text
- closetext
+ waitbutton
.finish: ; 13643
- loadmovesprites
+ closetext
end
; 0x13645
@@ -9141,7 +7645,6 @@ SetMemEvent: ; 1364f
call EventFlagAction
ret
-
CheckFacingTileForStd:: ; 1365b
; Checks to see if the tile you're facing has a std script associated with it. If so, executes the script and returns carry.
ld a, c
@@ -9177,7 +7680,7 @@ CheckFacingTileForStd:: ; 1365b
dbw $97, tv
dbw $9d, window
dbw $9f, incenseburner
- db $ff ; end
+ db -1 ; end
; 1369a
Script_JumpStdFromRAM: ; 0x1369a
@@ -9252,375 +7755,35 @@ root set root+1
endr
; 13d96
-
SECTION "bank5", ROMX, BANK[$5]
-
-StopRTC: ; Unreferenced???
- ld a, SRAM_ENABLE
- ld [MBC3SRamEnable], a
- call LatchClock
- ld a, RTC_DH
- ld [MBC3SRamBank], a
- ld a, [MBC3RTC]
- set 6, a ; halt
- ld [MBC3RTC], a
- call CloseSRAM
- ret
-; 14019
-
-StartRTC: ; 14019
- ld a, SRAM_ENABLE
- ld [MBC3SRamEnable], a
- call LatchClock
- ld a, RTC_DH
- ld [MBC3SRamBank], a
- ld a, [MBC3RTC]
- res 6, a ; halt
- ld [MBC3RTC], a
- call CloseSRAM
- ret
-; 14032
-
-
-GetTimeOfDay:: ; 14032
-; get time of day based on the current hour
- ld a, [hHours] ; hour
- ld hl, TimesOfDay
-
-.check
-; if we're within the given time period,
-; get the corresponding time of day
- cp [hl]
- jr c, .match
-; else, get the next entry
-rept 2
- inc hl
-endr
-; try again
- jr .check
-
-.match
-; get time of day
- inc hl
- ld a, [hl]
- ld [TimeOfDay], a
- ret
-; 14044
-
-TimesOfDay: ; 14044
-; hours for the time of day
-; 04-09 morn | 10-17 day | 18-03 nite
- db 04, NITE
- db 10, MORN
- db 18, DAY
- db 24, NITE
- db -1, MORN
-; 1404e
-
-Unknown_1404e: ; Unreferenced
- db 20, 2
- db 40, 0
- db 60, 1
- db -1, 0
-; 14056
-
-
-StageRTCTimeForSave: ; 14056
- call UpdateTime
- ld hl, wRTC
- ld a, [CurDay]
- ld [hli], a
- ld a, [hHours]
- ld [hli], a
- ld a, [hMinutes]
- ld [hli], a
- ld a, [hSeconds]
- ld [hli], a
- ret
-; 1406a
-
-SaveRTC: ; 1406a
- ld a, $a
- ld [MBC3SRamEnable], a
- call LatchClock
- ld hl, MBC3RTC
- ld a, $c
- ld [MBC3SRamBank], a
- res 7, [hl]
- ld a, BANK(sRTCStatusFlags)
- ld [MBC3SRamBank], a
- xor a
- ld [sRTCStatusFlags], a
- call CloseSRAM
- ret
-; 14089
-
-
-
-StartClock:: ; 14089
- call GetClock
- call Function1409b
- call FixDays
- jr nc, .skip_set
- ; bit 5: Day count exceeds 139
- ; bit 6: Day count exceeds 255
- call RecordRTCStatus ; set flag on sRTCStatusFlags
-
-.skip_set
- call StartRTC
- ret
-; 1409b
-
-Function1409b: ; 1409b
- ld hl, hRTCDayHi
- bit 7, [hl]
- jr nz, .set_bit_7
- bit 6, [hl]
- jr nz, .set_bit_7
- xor a
- ret
-
-.set_bit_7
- ; Day count exceeds 16383
- ld a, %10000000
- call RecordRTCStatus ; set bit 7 on sRTCStatusFlags
- ret
-; 140ae
-
-Function140ae: ; 140ae
- call CheckRTCStatus
- ld c, a
- and %11000000 ; Day count exceeded 255 or 16383
- jr nz, .time_overflow
-
- ld a, c
- and %00100000 ; Day count exceeded 139
- jr z, .dont_update
-
- call UpdateTime
- ld a, [wRTC + 0]
- ld b, a
- ld a, [CurDay]
- cp b
- jr c, .dont_update
-
-.time_overflow
- callba ClearDailyTimers
- callba Function170923
-; mobile
- ld a, $5
- call GetSRAMBank
- ld a, [$aa8c]
- inc a
- ld [$aa8c], a
- ld a, [$b2fa]
- inc a
- ld [$b2fa], a
- call CloseSRAM
- ret
-
-.dont_update
- xor a
- ret
-; 140ed
-
-
-
-Function140ed:: ; 140ed
- call GetClock
- call FixDays
- ld hl, hRTCSeconds
- ld de, StartSecond
-
- ld a, [StringBuffer2 + 3]
- sub [hl]
- dec hl
- jr nc, .okay_secs
- add 60
-.okay_secs
- ld [de], a
- dec de
-
- ld a, [StringBuffer2 + 2]
- sbc [hl]
- dec hl
- jr nc, .okay_mins
- add 60
-.okay_mins
- ld [de], a
- dec de
-
- ld a, [StringBuffer2 + 1]
- sbc [hl]
- dec hl
- jr nc, .okay_hrs
- add 24
-.okay_hrs
- ld [de], a
- dec de
-
- ld a, [StringBuffer2]
- sbc [hl]
- dec hl
- jr nc, .okay_days
- add 140
- ld c, 7
- call SimpleDivide
-
-.okay_days
- ld [de], a
- ret
-; 1412a
-
+INCLUDE "engine/rtc.asm"
INCLUDE "engine/overworld.asm"
-
-Function1499a:: ; 1499a
- ld a, [PlayerNextTile]
- cp $60
- jr z, .warp
- cp $68
- jr z, .warp
- and $f0
- cp $70
- jr z, .warp
- and a
- ret
-
-.warp
- scf
- ret
-; 149af
-
-Function149af:: ; 149af
- ld a, [PlayerNextTile]
- cp $70
- jr z, .not_warp
- cp $76
- jr z, .not_warp
- cp $78
- jr z, .not_warp
- cp $7e
- jr z, .not_warp
- scf
- ret
-
-.not_warp
- xor a
- ret
-; 149c6
-
-CheckWarpCollision: ; 149c6
- ld de, 1
- ld hl, .blocks
- ld a, [PlayerNextTile]
- call IsInArray
- ret
-; 149d3
-
-.blocks: ; 149d3
- db $71 ; door
- db $79
- db $7a ; stairs
- db $73
- db $7b ; cave entrance
- db $74
- db $7c ; warp pad
- db $75
- db $7d
- db -1
-; 149dd
-
-CheckGrassCollision:: ; 149dd
- ld a, [PlayerNextTile]
- ld hl, .blocks
- ld de, 1
- call IsInArray
- ret
-; 149ea
-
-.blocks: ; 149ea
- db $08
- db $18 ; tall grass
- db $14 ; tall grass
- db $28
- db $29
- db $48
- db $49
- db $4a
- db $4b
- db $4c
- db -1
-; 149f5
-
-CheckCutCollision: ; 149f5
- ld a, c
- ld hl, .blocks
- ld de, 1
- call IsInArray
- ret
-; 14a00
-
-.blocks: ; 14a00
- db $12 ; cut tree
- db $1a ; cut tree
- db $10 ; tall grass
- db $18 ; tall grass
- db $14 ; tall grass
- db $1c ; tall grass
- db -1
-; 14a07
-
-Function14a07:: ; 14a07
- ld a, [PlayerNextTile]
- ld de, $1f
- cp $71 ; door
- ret z
- ld de, $13
- cp $7c ; warp pad
- ret z
- ld de, $23
- ret
-; 14a1a
-
+INCLUDE "engine/tile_events.asm"
INCLUDE "engine/save.asm"
-
INCLUDE "engine/spawn_points.asm"
-
INCLUDE "engine/map_setup.asm"
-
INCLUDE "engine/pokecenter_pc.asm"
-
INCLUDE "engine/mart.asm"
-
INCLUDE "engine/money.asm"
-
INCLUDE "items/marts.asm"
-
INCLUDE "event/mom.asm"
-
INCLUDE "event/daycare.asm"
-
INCLUDE "event/photo.asm"
-
INCLUDE "engine/breeding/egg.asm"
SECTION "Tileset Data 1", ROMX, BANK[TILESETS_1]
INCLUDE "tilesets/data_1.asm"
-
SECTION "Roofs", ROMX, BANK[ROOFS]
INCLUDE "tilesets/roofs.asm"
-
SECTION "Tileset Data 2", ROMX, BANK[TILESETS_2]
INCLUDE "tilesets/data_2.asm"
-
-
SECTION "bank8", ROMX, BANK[$8]
INCLUDE "engine/clock_reset.asm"
@@ -9629,7 +7792,6 @@ SECTION "Tileset Data 3", ROMX, BANK[TILESETS_3]
INCLUDE "tilesets/data_3.asm"
-
SECTION "bank9", ROMX, BANK[$9]
StringBufferPointers:: ; 24000
@@ -9644,263 +7806,6 @@ StringBufferPointers:: ; 24000
INCLUDE "engine/menu.asm"
-_BackUpTiles:: ; 24374
- ld a, [rSVBK]
- push af
- ld a, $7
- ld [rSVBK], a
-
- ld hl, wcf71
- ld e, [hl]
- inc hl
- ld d, [hl]
- push de
-
- ld b, $10
- ld hl, wMenuFlags
-.loop
- ld a, [hli]
- ld [de], a
- dec de
- dec b
- jr nz, .loop
-
-; If bit 6 or 7 of the menu flags is set, set bit 0 of the address
-; at 7:[wcf71], and draw the menu using the coordinates from the header.
-; Otherwise, reset bit 0 of 7:[wcf71].
- ld a, [wMenuFlags]
- bit 6, a
- jr nz, .bit_6
- bit 7, a
- jr z, .not_bit_7
-
-.bit_6
- ld hl, wcf71
- ld a, [hli]
- ld h, [hl]
- ld l, a
- set 0, [hl]
- call MenuBoxCoord2Tile
- call .copy
- call MenuBoxCoord2Attr
- call .copy
- jr .done
-
-.not_bit_7
- pop hl ; last-pushed register was de
- push hl
- ld a, [hld]
- ld l, [hl]
- ld h, a
- res 0, [hl]
-
-.done
- pop hl
- call .ret ; empty function
- ld a, h
- ld [de], a
- dec de
- ld a, l
- ld [de], a
- dec de
- ld hl, wcf71
- ld [hl], e
- inc hl
- ld [hl], d
-
- pop af
- ld [rSVBK], a
- ld hl, wcf78
- inc [hl]
- ret
-; 243cd
-
-.copy: ; 243cd
- call GetMenuBoxDims
- inc b
- inc c
- call .ret ; empty function
-
-.row
- push bc
- push hl
-
-.col
- ld a, [hli]
- ld [de], a
- dec de
- dec c
- jr nz, .col
-
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .row
-
- ret
-; 243e7
-
-.ret: ; 243e7
- ret
-; 243e8
-
-Function243e8:: ; 243e8
- xor a
- ld [hBGMapMode], a
-
- ld a, [rSVBK]
- push af
- ld a, $7
- ld [rSVBK], a
-
- call Function1c7e
- ld a, l
- or h
- jp z, Function2445d
- ld a, l
- ld [wcf71], a
- ld a, h
- ld [wcf72], a
- call Function1c47
- ld a, [wMenuFlags]
- bit 0, a
- jr z, .next
- ld d, h
- ld e, l
- call RestoreTileBackup
-
-.next
- call Function1c7e
- ld a, h
- or l
- jr z, .done
- call Function1c47
-
-.done
- pop af
- ld [rSVBK], a
- ld hl, wcf78
- dec [hl]
- ret
-; 24423
-
-
-Function24423: ; 24423
- ld a, [VramState]
- bit 0, a
- ret z
- xor a
- call GetSRAMBank
- hlcoord 0, 0
- ld de, sScratch
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- call CopyBytes
- call CloseSRAM
- call OverworldTextModeSwitch
- xor a
- call GetSRAMBank
- ld hl, sScratch
- decoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-.asm_2444c
- ld a, [hl]
- cp $61
- jr c, .asm_24452
- ld [de], a
-
-.asm_24452
- inc hl
- inc de
- dec bc
- ld a, c
- or b
- jr nz, .asm_2444c
- call CloseSRAM
- ret
-; 2445d
-
-Function2445d: ; 2445d
- ld hl, UnknownText_0x24468
- call PrintText
- call WaitBGMap
-.asm_24466
- jr .asm_24466
-; 24468
-
-UnknownText_0x24468: ; 24468
- text_jump UnknownText_0x1c46b7
- db "@"
-; 2446d
-
-Function2446d:: ; 2446d
- ld a, [wMenuData2Flags]
- ld b, a
- ld hl, wcfa1
- ld a, [wMenuBorderTopCoord]
- inc a
- bit 6, b
- jr nz, .asm_2447d
- inc a
-
-.asm_2447d
- ld [hli], a
- ld a, [wMenuBorderLeftCoord]
- inc a
- ld [hli], a
- ld a, [wMenuData2Items]
- ld [hli], a
- ld a, $1
- ld [hli], a
- ld [hl], $0
- bit 5, b
- jr z, .asm_24492
- set 5, [hl]
-
-.asm_24492
- ld a, [wMenuFlags]
- bit 4, a
- jr z, .asm_2449b
- set 6, [hl]
-
-.asm_2449b
- inc hl
- xor a
- ld [hli], a
- ld a, $20
- ld [hli], a
- ld a, $1
- bit 0, b
- jr nz, .asm_244a9
- add $2
-
-.asm_244a9
- ld [hli], a
- ld a, [wMenuCursorBuffer]
- and a
- jr z, .asm_244b7
- ld c, a
- ld a, [wMenuData2Items]
- cp c
- jr nc, .asm_244b9
-
-.asm_244b7
- ld c, $1
-
-.asm_244b9
- ld [hl], c
- inc hl
- ld a, $1
- ld [hli], a
- xor a
-rept 3
- ld [hli], a
-endr
- ret
-; 244c3
-
-
UpdateItemDescription: ; 0x244c3
ld a, [MenuSelection]
ld [CurSpecies], a
@@ -9917,7 +7822,7 @@ UpdateItemDescription: ; 0x244c3
; 0x244e3
Pokepic:: ; 244e3
- ld hl, MenuDataHeader_0x24547
+ ld hl, PokepicMenuDataHeader
call CopyMenuDataHeader
call MenuBox
call UpdateSprites
@@ -9946,8 +7851,8 @@ Pokepic:: ; 244e3
ret
; 24528
-PokepicYesOrNo:: ; 24528
- ld hl, MenuDataHeader_0x24547
+ClosePokepic:: ; 24528
+ ld hl, PokepicMenuDataHeader
call CopyMenuDataHeader
call ClearMenuBoxInterior
call WaitBGMap
@@ -9961,7 +7866,7 @@ PokepicYesOrNo:: ; 24528
ret
; 24547
-MenuDataHeader_0x24547: ; 0x24547
+PokepicMenuDataHeader: ; 0x24547
db $40 ; flags
db 04, 06 ; start coords
db 13, 14 ; end coords
@@ -10040,822 +7945,8 @@ GetObjectTimeMask: ; 245a7 (9:45a7)
xor a
ret
-
-Function245af:: ; 245af
- xor a
- ld [wcf73], a
- ld [hBGMapMode], a
- inc a
- ld [hInMenu], a
- call ClearObjectStructsa
- call Function24764
- call Function247dd
- call Function245f1
- call ApplyTilemap
- xor a
- ld [hBGMapMode], a
- ret
-; 245cb
-
-Function245cb:: ; 245cb
-.loop
- call MenuJoyAction
- jp c, .exit
- call z, .zero
- jr .loop
-; 245d6
-
-.exit: ; 245d6
- call Function1ff8
- ld [wcf73], a
- ld a, 0
- ld [hInMenu], a
- ret
-; 245e1
-
-.zero: ; 245e1
- call Function245f1
- ld a, 1
- ld [hBGMapMode], a
- ld c, 3
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- ret
-; 245f1
-
-Function245f1: ; 245f1
- xor a
- ld [hBGMapMode], a
- ld hl, Options
- ld a, [hl]
- push af
- set NO_TEXT_SCROLL, [hl]
- call Function247f0
- call Function2488b
- call Function248b8
- pop af
- ld [Options], a
- ret
-; 24609
-
-MenuJoyAction: ; 24609
-.loop
- call Function1bd3
- ld a, [hJoyLast]
- and D_PAD
- ld b, a
- ld a, [hJoyPressed]
- and BUTTONS
- or b
- bit 0, a ; A
- jp nz, .a_button
- bit 1, a ; B
- jp nz, .b_button
- bit 2, a ; Select
- jp nz, .select
- bit 3, a ; Start
- jp nz, .start
- bit 4, a ; Right
- jp nz, .d_right
- bit 5, a ; Left
- jp nz, .d_left
- bit 6, a ; Up
- jp nz, .d_up
- bit 7, a ; Down
- jp nz, .d_down
- jr .loop
-; 24640
-
-.unreferenced: ; unreferenced
- ld a, -1
- and a
- ret
-; 24644
-
-
-.a_button: ; 24644
- call Function1bee
- ld a, [MenuSelection2]
- dec a
- call Function248d5
- ld a, [MenuSelection]
- ld [CurItem], a
- ld a, [wcf75]
- ld [wItemQuantityBuffer], a
- call Function246fc
- dec a
- ld [wcf77], a
- ld [wd107], a
- ld a, [MenuSelection]
- cp -1
- jr z, .b_button
- ld a, A_BUTTON
- scf
- ret
-; 2466f
-
-.b_button: ; 2466f
- ld a, B_BUTTON
- scf
- ret
-; 24673
-
-.select: ; 24673
- ld a, [wMenuData2Flags]
- bit 7, a
- jp z, xor_a_dec_a
- ld a, [MenuSelection2]
- dec a
- call Function248d5
- ld a, [MenuSelection]
- cp -1
- jp z, xor_a_dec_a
- call Function246fc
- dec a
- ld [wcf77], a
- ld a, SELECT
- scf
- ret
-; 24695
-
-.start: ; 24695
- ld a, [wMenuData2Flags]
- bit 6, a
- jp z, xor_a_dec_a
- ld a, START
- scf
- ret
-; 246a1
-
-.d_left: ; 246a1
- ld hl, wcfa6
- bit 7, [hl]
- jp z, xor_a_dec_a
- ld a, [wMenuData2Flags]
- bit 3, a
- jp z, xor_a_dec_a
- ld a, D_LEFT
- scf
- ret
-; 246b5
-
-.d_right: ; 246b5
- ld hl, wcfa6
- bit 7, [hl]
- jp z, xor_a_dec_a
- ld a, [wMenuData2Flags]
- bit 2, a
- jp z, xor_a_dec_a
- ld a, D_RIGHT
- scf
- ret
-; 246c9
-
-.d_up: ; 246c9
- ld hl, wcfa6
- bit 7, [hl]
- jp z, xor_a
- ld hl, wMenuScrollPosition
- ld a, [hl]
- and a
- jr z, .xor_dec_up
- dec [hl]
- jp xor_a
-
-.xor_dec_up
- jp xor_a_dec_a
-; 246df
-
-.d_down: ; 246df
- ld hl, wcfa6
- bit 7, [hl]
- jp z, xor_a
- ld hl, wMenuScrollPosition
- ld a, [wMenuData2Items]
- add [hl]
- ld b, a
- ld a, [wd144]
- cp b
- jr c, .xor_dec_down
- inc [hl]
- jp xor_a
-
-.xor_dec_down
- jp xor_a_dec_a
-; 246fc
-
-Function246fc: ; 246fc
- ld a, [wMenuScrollPosition]
- ld c, a
- ld a, [MenuSelection2]
- add c
- ld c, a
- ret
-; 24706
-
-Function24706: ; 24706 (9:4706)
- call MenuBoxCoord2Tile
- ld de, SCREEN_WIDTH
- add hl, de
- ld de, 2 * SCREEN_WIDTH
- ld a, [wMenuData2Items]
-.asm_24713
- ld [hl], " "
- add hl, de
- dec a
- jr nz, .asm_24713
- ret
-
-ClearObjectStructsa: ; 2471a
-; Get the value of (wcf95):(wcf96,wcf97) and store it in wd144.
- ld hl, wcf96
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wcf95]
- call GetFarByte
- ld [wd144], a
-; if ([wd144] + 1) < [wMenuData2Items] + [wMenuScrollPosition]: [wMenuScrollPosition] = max(([wd144] + 1) - [wMenuData2Items], 0)
- ld a, [wMenuData2Items]
- ld c, a
- ld a, [wMenuScrollPosition]
- add c
- ld c, a
- ld a, [wd144]
- inc a
- cp c
- jr nc, .skip
- ld a, [wMenuData2Items]
- ld c, a
- ld a, [wd144]
- inc a
- sub c
- jr nc, .store
- xor a
-
-.store
- ld [wMenuScrollPosition], a
-
-.skip
- ld a, [wMenuScrollPosition]
- ld c, a
- ld a, [wMenuCursorBuffer]
- add c
- ld b, a
- ld a, [wd144]
- inc a
- cp b
- jr c, .asm_2475a
- jr nc, .asm_24763
-
-.asm_2475a
- xor a
- ld [wMenuScrollPosition], a
- ld a, $1
- ld [wMenuCursorBuffer], a
-
-.asm_24763
- ret
-; 24764
-
-Function24764: ; 24764
- ld a, [wMenuData2Flags]
- ld c, a
- ld a, [wd144]
- ld b, a
- ld a, [wMenuBorderTopCoord]
- add $1
- ld [wcfa1], a
- ld a, [wMenuBorderLeftCoord]
- add $0
- ld [wcfa2], a
- ld a, [wMenuData2Items]
- cp b
- jr c, .asm_24786
- jr z, .asm_24786
- ld a, b
- inc a
-
-.asm_24786
- ld [wcfa3], a
- ld a, $1
- ld [wcfa4], a
- ld a, $8c
- bit 2, c
- jr z, .asm_24796
- set 0, a
-
-.asm_24796
- bit 3, c
- jr z, .asm_2479c
- set 1, a
-
-.asm_2479c
- ld [wcfa5], a
- xor a
- ld [wcfa6], a
- ld a, $20
- ld [wcfa7], a
- ld a, $c3
- bit 7, c
- jr z, .asm_247b0
- add $4
-
-.asm_247b0
- bit 6, c
- jr z, .asm_247b6
- add $8
-
-.asm_247b6
- ld [wcfa8], a
- ld a, [wcfa3]
- ld b, a
- ld a, [wMenuCursorBuffer]
- and a
- jr z, .asm_247c8
- cp b
- jr z, .asm_247ca
- jr c, .asm_247ca
-
-.asm_247c8
- ld a, $1
-
-.asm_247ca
- ld [MenuSelection2], a
- ld a, $1
- ld [wcfaa], a
- xor a
- ld [wcfac], a
- ld [wcfad], a
- ld [wcfab], a
- ret
-; 247dd
-
-Function247dd: ; 247dd
- ld a, [wd144]
- ld c, a
- ld a, [wd0e3]
- and a
- jr z, .asm_247ef
- dec a
- cp c
- jr c, .asm_247ef
- xor a
- ld [wd0e3], a
-
-.asm_247ef
- ret
-; 247f0
-
-Function247f0: ; 247f0
- call ClearWholeMenuBox
- ld a, [wMenuData2Flags]
- bit 4, a
- jr z, .asm_2480d
- ld a, [wMenuScrollPosition]
- and a
- jr z, .asm_2480d
- ld a, [wMenuBorderTopCoord]
- ld b, a
- ld a, [wMenuBorderRightCoord]
- ld c, a
- call Coord2Tile
- ld [hl], $61
-
-.asm_2480d
- call MenuBoxCoord2Tile
- ld bc, $15
- add hl, bc
- ld a, [wMenuData2Items]
- ld b, a
- ld c, $0
-.asm_2481a
- ld a, [wMenuScrollPosition]
- add c
- ld [wcf77], a
- ld a, c
- call Function248d5
- ld a, [MenuSelection]
- cp $ff
- jr z, .asm_24851
- push bc
- push hl
- call Function2486e
- pop hl
- ld bc, $28
- add hl, bc
- pop bc
- inc c
- ld a, c
- cp b
- jr nz, .asm_2481a
- ld a, [wMenuData2Flags]
- bit 4, a
- jr z, .asm_24850
- ld a, [wMenuBorderBottomCoord]
- ld b, a
- ld a, [wMenuBorderRightCoord]
- ld c, a
- call Coord2Tile
- ld [hl], $ee
-
-.asm_24850
- ret
-
-.asm_24851
- ld a, [wMenuData2Flags]
- bit 0, a
- jr nz, .asm_24866
- ld de, .string_2485f
- call PlaceString
- ret
-
-.string_2485f
- db "CANCEL@"
-
-.asm_24866
- ld d, h
- ld e, l
- ld hl, wcf98
- jp CallPointerAt
-; 2486e
-
-Function2486e: ; 2486e
- push hl
- ld d, h
- ld e, l
- ld hl, wcf98
- call CallPointerAt
- pop hl
- ld a, [wcf93]
- and a
- jr z, .asm_2488a
- ld e, a
- ld d, $0
- add hl, de
- ld d, h
- ld e, l
- ld hl, wcf9b
- call CallPointerAt
-
-.asm_2488a
- ret
-; 2488b
-
-Function2488b: ; 2488b
- ld a, [wd0e3]
- and a
- jr z, .asm_248b7
- ld b, a
- ld a, [wMenuScrollPosition]
- cp b
- jr nc, .asm_248b7
- ld c, a
- ld a, [wMenuData2Items]
- add c
- cp b
- jr c, .asm_248b7
- ld a, b
- sub c
- dec a
- add a
- add $1
- ld c, a
- ld a, [wMenuBorderTopCoord]
- add c
- ld b, a
- ld a, [wMenuBorderLeftCoord]
- add $0
- ld c, a
- call Coord2Tile
- ld [hl], $ec
-
-.asm_248b7
- ret
-; 248b8
-
-Function248b8: ; 248b8
- ld a, [wMenuData2Flags]
- bit 5, a
- ret z
- bit 1, a
- jr z, .asm_248c7
- ld a, [wd0e3]
- and a
- ret nz
-
-.asm_248c7
- ld a, [MenuSelection2]
- dec a
- call Function248d5
- ld hl, wcf9e
- call CallPointerAt
- ret
-; 248d5
-
-Function248d5: ; 248d5
- push de
- push hl
- ld e, a
- ld a, [wMenuScrollPosition]
- add e
- ld e, a
- ld d, $0
- ld hl, wcf96
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- ld a, [wcf94]
- cp $1
- jr z, .asm_248f2
- cp $2
- jr z, .asm_248f1
-
-.asm_248f1
- add hl, de
-
-.asm_248f2
- add hl, de
- ld a, [wcf95]
- call GetFarByte
- ld [MenuSelection], a
- ld [CurItem], a
- inc hl
- ld a, [wcf95]
- call GetFarByte
- ld [wcf75], a
- pop hl
- pop de
- ret
-; 2490c
-
-
-Function2490c: ; 2490c (9:490c)
- ld a, [wd0e3]
- and a
- jr z, .asm_2493d
- ld b, a
- ld a, [wcf77]
- inc a
- cp b
- jr z, .asm_24945
- ld a, [wcf77]
- call Function24a5c
- ld a, [hl]
- cp $ff
- ret z
- ld a, [wd0e3]
- dec a
- ld [wd0e3], a
- call Function249a7
- jp c, Function249d1
- ld a, [wcf77]
- ld c, a
- ld a, [wd0e3]
- cp c
- jr c, .asm_2497a
- jr .asm_2494a
-.asm_2493d
- ld a, [wcf77]
- inc a
- ld [wd0e3], a
- ret
-.asm_24945
- xor a
- ld [wd0e3], a
- ret
-.asm_2494a
- ld a, [wd0e3]
- call Function24a40
- ld a, [wcf77]
- ld d, a
- ld a, [wd0e3]
- ld e, a
- call Function24a6c
- push bc
- ld a, [wd0e3]
- call Function24a5c
- dec hl
- push hl
- call Function24a80
- add hl, bc
- ld d, h
- ld e, l
- pop hl
- pop bc
- call Function24aab
- ld a, [wcf77]
- call Function24a4d
- xor a
- ld [wd0e3], a
- ret
-.asm_2497a
- ld a, [wd0e3]
- call Function24a40
- ld a, [wcf77]
- ld d, a
- ld a, [wd0e3]
- ld e, a
- call Function24a6c
- push bc
- ld a, [wd0e3]
- call Function24a5c
- ld d, h
- ld e, l
- call Function24a80
- add hl, bc
- pop bc
- call CopyBytes
- ld a, [wcf77]
- call Function24a4d
- xor a
- ld [wd0e3], a
- ret
-
-Function249a7: ; 249a7 (9:49a7)
- ld a, [wd0e3]
- call Function24a5c
- ld d, h
- ld e, l
- ld a, [wcf77]
- call Function24a5c
- ld a, [de]
- cp [hl]
- jr nz, .asm_249cd
- ld a, [wcf77]
- call Function24a97
- cp $63
- jr z, .asm_249cd
- ld a, [wd0e3]
- call Function24a97
- cp $63
- jr nz, .asm_249cf
-.asm_249cd
- and a
- ret
-.asm_249cf
- scf
- ret
-
-Function249d1: ; 249d1 (9:49d1)
- ld a, [wd0e3]
- call Function24a5c
- inc hl
- push hl
- ld a, [wcf77]
- call Function24a5c
- inc hl
- ld a, [hl]
- pop hl
- add [hl]
- cp $64
- jr c, .asm_24a01
- sub $63
- push af
- ld a, [wcf77]
- call Function24a5c
- inc hl
- ld [hl], $63
- ld a, [wd0e3]
- call Function24a5c
- inc hl
- pop af
- ld [hl], a
- xor a
- ld [wd0e3], a
- ret
-.asm_24a01
- push af
- ld a, [wcf77]
- call Function24a5c
- inc hl
- pop af
- ld [hl], a
- ld hl, wcf96
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wd0e3]
- cp [hl]
- jr nz, .asm_24a25
- dec [hl]
- ld a, [wd0e3]
- call Function24a5c
- ld [hl], $ff
- xor a
- ld [wd0e3], a
- ret
-.asm_24a25
- dec [hl]
- call Function24a80
- push bc
- ld a, [wd0e3]
- call Function24a5c
- pop bc
- push hl
- add hl, bc
- pop de
-.asm_24a34
- ld a, [hli]
- ld [de], a
- inc de
- cp $ff
- jr nz, .asm_24a34
- xor a
- ld [wd0e3], a
- ret
-
-Function24a40: ; 24a40 (9:4a40)
- call Function24a5c
- ld de, wd002
- call Function24a80
- call CopyBytes
- ret
-
-Function24a4d: ; 24a4d (9:4a4d)
- call Function24a5c
- ld d, h
- ld e, l
- ld hl, wd002
- call Function24a80
- call CopyBytes
- ret
-
-Function24a5c: ; 24a5c (9:4a5c)
- push af
- call Function24a80
- ld hl, wcf96
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- pop af
- call AddNTimes
- ret
-
-Function24a6c: ; 24a6c (9:4a6c)
- push hl
- call Function24a80
- ld a, d
- sub e
- jr nc, .asm_24a76
- dec a
- cpl
-.asm_24a76
- ld hl, 0
- call AddNTimes
- ld b, h
- ld c, l
- pop hl
- ret
-
-Function24a80: ; 24a80 (9:4a80)
- push hl
- ld a, [wcf94]
- ld c, a
- ld b, 0
- ld hl, Unknown_24a91
-rept 2
- add hl, bc
-endr
- ld c, [hl]
- inc hl
- ld b, [hl]
- pop hl
- ret
-; 24a91 (9:4a91)
-
-Unknown_24a91: ; 24a91
- dw 0, 1, 2
-; 24a97
-
-Function24a97: ; 24a97 (9:4a97)
- push af
- call Function24a80
- ld a, c
- cp $2
- jr nz, .asm_24aa7
- pop af
- call Function24a5c
- inc hl
- ld a, [hl]
- ret
-.asm_24aa7
- pop af
- ld a, $1
- ret
-
-Function24aab: ; 24aab (9:4aab)
- ld a, [hld]
- ld [de], a
- dec de
- dec bc
- ld a, b
- or c
- jr nz, Function24aab
- ret
+INCLUDE "engine/scrolling_menu.asm"
+INCLUDE "engine/switch_items.asm"
PlaceMenuItemName: ; 0x24ab4
push de
@@ -10880,7 +7971,7 @@ PlaceMenuItemQuantity: ; 0x24ac3
add hl, de
ld [hl], "×"
inc hl
- ld de, wcf75
+ ld de, MenuSelectionQuantity
lb bc, 1, 2
call PrintNum
@@ -10888,25 +7979,25 @@ PlaceMenuItemQuantity: ; 0x24ac3
ret
; 0x24ae8
-PlaceMoneyTopRightOW: ; 24ae8
+PlaceMoneyTopRight: ; 24ae8
ld hl, MenuDataHeader_0x24b15
call CopyMenuDataHeader
- jr Function24b01
+ jr PlaceMoneyDataHeader
-PlaceMoneyBottomLeftOW: ; 24af0
+PlaceMoneyBottomLeft: ; 24af0
ld hl, MenuDataHeader_0x24b1d
call CopyMenuDataHeader
- jr Function24b01
+ jr PlaceMoneyDataHeader
-PlaceMoneyTopRightMenu: ; 24af8
+PlaceMoneyAtTopLeftOfTextbox: ; 24af8
ld hl, MenuDataHeader_0x24b15
- ld de, $b
- call Function1e2e
+ lb de, 0, 11
+ call OffsetMenuDataHeader
-Function24b01: ; 24b01
+PlaceMoneyDataHeader: ; 24b01
call MenuBox
call MenuBoxCoord2Tile
- ld de, $15
+ ld de, SCREEN_WIDTH + 1
add hl, de
ld de, Money
lb bc, PRINTNUM_MONEY | 3, 6
@@ -11079,7 +8170,6 @@ String24c5e: ; 24c5e
db "LEVEL@"
; 24c64
-
FindApricornsInBag: ; 24c64
; Checks the bag for Apricorns.
ld hl, Buffer1
@@ -11139,719 +8229,9 @@ endr
db -1
; 24caf
-
-MonMenuOptionStrings: ; 24caf
- db "STATS@"
- db "SWITCH@"
- db "ITEM@"
- db "CANCEL@"
- db "MOVE@"
- db "MAIL@"
- db "ERROR!@"
-; 24cd9
-
-MonMenuOptions: ; 24cd9
-
-; Moves
- db MONMENU_FIELD_MOVE, MONMENU_CUT, CUT
- db MONMENU_FIELD_MOVE, MONMENU_FLY, FLY
- db MONMENU_FIELD_MOVE, MONMENU_SURF, SURF
- db MONMENU_FIELD_MOVE, MONMENU_STRENGTH, STRENGTH
- db MONMENU_FIELD_MOVE, MONMENU_FLASH, FLASH
- db MONMENU_FIELD_MOVE, MONMENU_WATERFALL, WATERFALL
- db MONMENU_FIELD_MOVE, MONMENU_WHIRLPOOL, WHIRLPOOL
- db MONMENU_FIELD_MOVE, MONMENU_DIG, DIG
- db MONMENU_FIELD_MOVE, MONMENU_TELEPORT, TELEPORT
- db MONMENU_FIELD_MOVE, MONMENU_SOFTBOILED, SOFTBOILED
- db MONMENU_FIELD_MOVE, MONMENU_HEADBUTT, HEADBUTT
- db MONMENU_FIELD_MOVE, MONMENU_ROCKSMASH, ROCK_SMASH
- db MONMENU_FIELD_MOVE, MONMENU_MILKDRINK, MILK_DRINK
- db MONMENU_FIELD_MOVE, MONMENU_SWEETSCENT, SWEET_SCENT
-
-; Options
- db MONMENU_MENUOPTION, MONMENU_STATS, 1 ; STATS
- db MONMENU_MENUOPTION, MONMENU_SWITCH, 2 ; SWITCH
- db MONMENU_MENUOPTION, MONMENU_ITEM, 3 ; ITEM
- db MONMENU_MENUOPTION, MONMENU_CANCEL, 4 ; CANCEL
- db MONMENU_MENUOPTION, MONMENU_MOVE, 5 ; MOVE
- db MONMENU_MENUOPTION, MONMENU_MAIL, 6 ; MAIL
- db MONMENU_MENUOPTION, MONMENU_ERROR, 7 ; ERROR!
-
- db -1
-; 24d19
-
-MonSubmenu: ; 24d19
- xor a
- ld [hBGMapMode], a
- call GetMonSubmenuItems
- callba Function8ea4a
- ld hl, .MenuDataHeader
- call LoadMenuDataHeader
- call .GetTopCoord
- call PopulateMonMenu
-
- ld a, 1
- ld [hBGMapMode], a
- call MonMenuLoop
- ld [MenuSelection], a
-
- call ExitMenu
- ret
-; 24d3f
-
-.MenuDataHeader: ; 24d3f
- db $40 ; tile backup
- db 00, 06 ; start coords
- db 17, 19 ; end coords
- dw 0
- db 1 ; default option
-; 24d47
-
-.GetTopCoord: ; 24d47
-; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1)
- ld a, [Buffer1]
- inc a
- add a
- ld b, a
- ld a, [wMenuBorderBottomCoord]
- sub b
- inc a
- ld [wMenuBorderTopCoord], a
- call MenuBox
- ret
-; 24d59
-
-MonMenuLoop: ; 24d59
-.loop
- ld a, $a0 ; flags
- ld [wMenuData2Flags], a
- ld a, [Buffer1] ; items
- ld [wMenuData2Items], a
- call Function1c10
- ld hl, wcfa5
- set 6, [hl]
- call Function1bc9
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- ld a, [hJoyPressed]
- bit 0, a ; A
- jr nz, .select
- bit 1, a ; B
- jr nz, .cancel
- jr .loop
-
-.cancel
- ld a, MONMENU_CANCEL ; CANCEL
- ret
-
-.select
- ld a, [MenuSelection2]
- dec a
- ld c, a
- ld b, 0
- ld hl, Buffer2
- add hl, bc
- ld a, [hl]
- ret
-; 24d91
-
-PopulateMonMenu: ; 24d91
- call MenuBoxCoord2Tile
- ld bc, $2a ; 42
- add hl, bc
- ld de, Buffer2
-.loop
- ld a, [de]
- inc de
- cp -1
- ret z
- push de
- push hl
- call GetMonMenuString
- pop hl
- call PlaceString
- ld bc, $28 ; 40
- add hl, bc
- pop de
- jr .loop
-; 24db0
-
-GetMonMenuString: ; 24db0
- ld hl, MonMenuOptions + 1
- ld de, 3
- call IsInArray
- dec hl
- ld a, [hli]
- cp 1
- jr z, .NotMove
- inc hl
- ld a, [hl]
- ld [wd265], a
- call GetMoveName
- ret
-
-.NotMove
- inc hl
- ld a, [hl]
- dec a
- ld hl, MonMenuOptionStrings
- call GetNthString
- ld d, h
- ld e, l
- ret
-; 24dd4
-
-GetMonSubmenuItems: ; 24dd4
- call ResetMonSubmenu
- ld a, [CurPartySpecies]
- cp EGG
- jr z, .egg
- ld a, [wLinkMode]
- and a
- jr nz, .skip_moves
- ld a, MON_MOVES
- call GetPartyParamLocation
- ld d, h
- ld e, l
- ld c, NUM_MOVES
-.loop
- push bc
- push de
- ld a, [de]
- and a
- jr z, .next
- push hl
- call IsFieldMove
- pop hl
- jr nc, .next
- call AddMonMenuItem
-
-.next
- pop de
- inc de
- pop bc
- dec c
- jr nz, .loop
-
-.skip_moves
- ld a, MONMENU_STATS
- call AddMonMenuItem
- ld a, MONMENU_SWITCH
- call AddMonMenuItem
- ld a, MONMENU_MOVE
- call AddMonMenuItem
- ld a, [wLinkMode]
- and a
- jr nz, .skip2
- push hl
- ld a, MON_ITEM
- call GetPartyParamLocation
- ld d, [hl]
- callba ItemIsMail
- pop hl
- ld a, MONMENU_MAIL
- jr c, .ok
- ld a, MONMENU_ITEM
-
-.ok
- call AddMonMenuItem
-
-.skip2
- ld a, [Buffer1]
- cp NUM_MON_SUBMENU_ITEMS
- jr z, .ok2
- ld a, MONMENU_CANCEL
- call AddMonMenuItem
-
-.ok2
- call TerminateMonSubmenu
- ret
-
-.egg
- ld a, MONMENU_STATS
- call AddMonMenuItem
- ld a, MONMENU_SWITCH
- call AddMonMenuItem
- ld a, MONMENU_CANCEL
- call AddMonMenuItem
- call TerminateMonSubmenu
- ret
-; 24e52
-
-IsFieldMove: ; 24e52
- ld b, a
- ld hl, MonMenuOptions
-.next
- ld a, [hli]
- cp -1
- jr z, .nope
- cp MONMENU_MENUOPTION
- jr z, .nope
- ld d, [hl]
- inc hl
- ld a, [hli]
- cp b
- jr nz, .next
- ld a, d
- scf
-
-.nope
- ret
-; 24e68
-
-ResetMonSubmenu: ; 24e68
- xor a
- ld [Buffer1], a
- ld hl, Buffer2
- ld bc, NUM_MON_SUBMENU_ITEMS + 1
- call ByteFill
- ret
-; 24e76
-
-TerminateMonSubmenu: ; 24e76
- ld a, [Buffer1]
- ld e, a
- ld d, $0
- ld hl, Buffer2
- add hl, de
- ld [hl], -1
- ret
-; 24e83
-
-AddMonMenuItem: ; 24e83
- push hl
- push de
- push af
- ld a, [Buffer1]
- ld e, a
- inc a
- ld [Buffer1], a
- ld d, $0
- ld hl, Buffer2
- add hl, de
- pop af
- ld [hl], a
- pop de
- pop hl
- ret
-; 24e99
-
-Function24e99: ; 24e99
-; BattleMonMenu
- ld hl, MenuDataHeader_0x24ed4
- call CopyMenuDataHeader
- xor a
- ld [hBGMapMode], a
- call MenuBox
- call UpdateSprites
- call Function1c89
- call WaitBGMap
- call CopyMenuData2
- ld a, [wMenuData2Flags]
- bit 7, a
- jr z, .asm_24ed0
- call Function1c10
- ld hl, wcfa5
- set 6, [hl]
- call Function1bc9
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- ld a, [hJoyPressed]
- bit 1, a
- jr z, .asm_24ed2
- ret z
-
-.asm_24ed0
- scf
- ret
-
-.asm_24ed2
- and a
- ret
-; 24ed4
-
-MenuDataHeader_0x24ed4: ; 24ed4
- db $00 ; flags
- db 11, 11 ; start coords
- db 17, 19 ; end coords
- dw MenuData2_0x24edc
- db 1 ; default option
-; 24edc
-
-MenuData2_0x24edc: ; 24edc
- db $c0 ; flags
- db 3 ; items
- db "SWITCH@"
- db "STATS@"
- db "CANCEL@"
-; 24ef2
-
-
-LoadBattleMenu: ; 24ef2
- ld hl, BattleMenuDataHeader
- call LoadMenuDataHeader
- ld a, [wd0d2]
- ld [wMenuCursorBuffer], a
- call Function2039
- ld a, [wMenuCursorBuffer]
- ld [wd0d2], a
- call ExitMenu
- ret
-; 24f0b
-
-
-SafariBattleMenu: ; 24f0b
-; untranslated
- ld hl, MenuDataHeader_0x24f4e
- call LoadMenuDataHeader
- jr Function24f19
-; 24f13
-
-ContestBattleMenu: ; 24f13
- ld hl, MenuDataHeader_0x24f89
- call LoadMenuDataHeader
-; 24f19
-
-Function24f19: ; 24f19
- ld a, [wd0d2]
- ld [wMenuCursorBuffer], a
- call InterpretMenu
- ld a, [wMenuCursorBuffer]
- ld [wd0d2], a
- call ExitMenu
- ret
-; 24f2c
-
-
-BattleMenuDataHeader: ; 24f2c
- db $40 ; flags
- db 12, 08 ; start coords
- db 17, 19 ; end coords
- dw MenuData_0x24f34
- db 1 ; default option
-; 24f34
-
-MenuData_0x24f34: ; 0x24f34
- db $81 ; flags
- dn 2, 2 ; rows, columns
- db 6 ; spacing
- dba Strings24f3d
- dbw BANK(MenuData_0x24f34), 0
-; 0x24f3d
-
-Strings24f3d: ; 0x24f3d
- db "FIGHT@"
- db "<PKMN>@"
- db "PACK@"
- db "RUN@"
-; 24f4e
-
-
-MenuDataHeader_0x24f4e: ; 24f4e
- db $40 ; flags
- db 12, 00 ; start coords
- db 17, 19 ; end coords
- dw MenuData_0x24f56
- db 1 ; default option
-; 24f56
-
-MenuData_0x24f56: ; 24f56
- db $81 ; flags
- dn 2, 2 ; rows, columns
- db 11 ; spacing
- dba Strings24f5f
- dba Function24f7c
-; 24f5f
-
-Strings24f5f: ; 24f5f
- db "サファりボール× @" ; "SAFARI BALL× @"
- db "エサをなげる@" ; "THROW BAIT"
- db "いしをなげる@" ; "THROW ROCK"
- db "にげる@" ; "RUN"
-; 24f7c
-
-Function24f7c: ; 24f7c
- hlcoord 17, 13
- ld de, wSafariBallsRemaining
- lb bc, PRINTNUM_LEADINGZEROS | 1, 2
- call PrintNum
- ret
-; 24f89
-
-
-MenuDataHeader_0x24f89: ; 24f89
- db $40 ; flags
- db 12, 02 ; start coords
- db 17, 19 ; end coords
- dw MenuData_0x24f91
- db 1 ; default option
-; 24f91
-
-MenuData_0x24f91: ; 24f91
- db $81 ; flags
- dn 2, 2 ; rows, columns
- db 12 ; spacing
- dba Strings24f9a
- dba Function24fb2
-; 24f9a
-
-Strings24f9a: ; 24f9a
- db "FIGHT@"
- db "<PKMN>", "@"
- db "PARKBALL× @"
- db "RUN@"
-; 24fb2
-
-Function24fb2: ; 24fb2
- hlcoord 13, 16
- ld de, wParkBallsRemaining
- lb bc, PRINTNUM_LEADINGZEROS | 1, 2
- call PrintNum
- ret
-; 24fbf
-
-
-Function24fbf: ; 24fbf
- ld hl, MenuDataHeader_0x250ed
- call LoadMenuDataHeader
- call Function24ff9
- ret
-; 24fc9
-
-
-Function24fc9: ; 24fc9
- callba GetItemPrice
-Function24fcf: ; 24fcf
- ld a, d
- ld [Buffer1], a
- ld a, e
- ld [Buffer2], a
- ld hl, MenuDataHeader_0x250f5
- call LoadMenuDataHeader
- call Function24ff9
- ret
-; 24fe1
-
-Function24fe1: ; 24fe1
- callba GetItemPrice
- ld a, d
- ld [Buffer1], a
- ld a, e
- ld [Buffer2], a
- ld hl, MenuDataHeader_0x250fd
- call LoadMenuDataHeader
- call Function24ff9
- ret
-; 24ff9
-
-Function24ff9: ; 24ff9
- ld a, $1
- ld [wItemQuantityChangeBuffer], a
-.loop
- call Function25072 ; update display
- call Function2500e ; joy action
- jr nc, .loop
- cp -1
- jr nz, .nope
- scf
- ret
-
-.nope
- and a
- ret
-; 2500e
-
-Function2500e: ; 2500e
- call Function354b ; get joypad
- bit B_BUTTON_F, c
- jr nz, .b
- bit A_BUTTON_F, c
- jr nz, .a
- bit D_DOWN_F, c
- jr nz, .down
- bit D_UP_F, c
- jr nz, .up
- bit D_LEFT_F, c
- jr nz, .left
- bit D_RIGHT_F, c
- jr nz, .right
- and a
- ret
-
-.b
- ld a, -1
- scf
- ret
-
-.a
- ld a, 0
- scf
- ret
-
-.down
- ld hl, wItemQuantityChangeBuffer
- dec [hl]
- jr nz, .finish_down
- ld a, [wItemQuantityBuffer]
- ld [hl], a
-
-.finish_down
- and a
- ret
-
-.up
- ld hl, wItemQuantityChangeBuffer
- inc [hl]
- ld a, [wItemQuantityBuffer]
- cp [hl]
- jr nc, .finish_up
- ld [hl], $1
-
-.finish_up
- and a
- ret
-
-.left
- ld a, [wItemQuantityChangeBuffer]
- sub $a
- jr c, .load_1
- jr z, .load_1
- jr .finish_left
-
-.load_1
- ld a, $1
-
-.finish_left
- ld [wItemQuantityChangeBuffer], a
- and a
- ret
-
-.right
- ld a, [wItemQuantityChangeBuffer]
- add $a
- ld b, a
- ld a, [wItemQuantityBuffer]
- cp b
- jr nc, .finish_right
- ld b, a
-
-.finish_right
- ld a, b
- ld [wItemQuantityChangeBuffer], a
- and a
- ret
-; 25072
-
-Function25072: ; 25072
- call MenuBox
- call MenuBoxCoord2Tile
- ld de, $15
- add hl, de
- ld [hl], $f1
- inc hl
- ld de, wItemQuantityChangeBuffer
- lb bc, PRINTNUM_LEADINGZEROS | 1, 2
- call PrintNum
- ld a, [wMenuData2Pointer]
- ld e, a
- ld a, [wMenuData2Pointer + 1]
- ld d, a
- ld a, [wMenuDataBank]
- call FarCall_de
- ret
-; 25097
-
-
-Function25097: ; 25097
- ret
-; 25098
-
-Function25098: ; 25098
- call Function250a9
- call Function250d1
- ret
-; 2509f
-
-Function2509f: ; 2509f
- call Function250a9
- call Function250c1
- call Function250d1
- ret
-; 250a9
-
-Function250a9: ; 250a9
- xor a
- ld [hMultiplicand + 0], a
- ld a, [Buffer1]
- ld [hMultiplicand + 1], a
- ld a, [Buffer2]
- ld [hMultiplicand + 2], a
- ld a, [wItemQuantityChangeBuffer]
- ld [hMultiplier], a
- push hl
- call Multiply
- pop hl
- ret
-; 250c1
-
-Function250c1: ; 250c1
- push hl
- ld hl, hMultiplicand
- ld a, [hl]
- srl a
- ld [hli], a
- ld a, [hl]
- rra
- ld [hli], a
- ld a, [hl]
- rra
- ld [hl], a
- pop hl
- ret
-; 250d1
-
-Function250d1: ; 250d1
- push hl
- ld hl, hMoneyTemp
- ld a, [hMultiplicand]
- ld [hli], a
- ld a, [$ffb5]
- ld [hli], a
- ld a, [$ffb6]
- ld [hl], a
- pop hl
- inc hl
- ld de, hMoneyTemp
- lb bc, PRINTNUM_MONEY | 3, 6
- call PrintNum
- call WaitBGMap
- ret
-; 250ed
-
-MenuDataHeader_0x250ed: ; 0x250ed
- db $40 ; flags
- db 09, 15 ; start coords
- db 11, 19 ; end coords
- dw Function25097
- db 0 ; default option
-; 0x250f5
-
-MenuDataHeader_0x250f5: ; 0x250f5
- db $40 ; flags
- db 15, 07 ; start coords
- db 17, 19 ; end coords
- dw Function25098
- db -1 ; default option
-; 0x250fd
-
-MenuDataHeader_0x250fd: ; 0x250fd
- db $40 ; flags
- db 15, 07 ; start coords
- db 17, 19 ; end coords
- dw Function2509f
- db 0 ; default option
-; 0x25105
-
+INCLUDE "engine/mon_menu.asm"
+INCLUDE "battle/menu.asm"
+INCLUDE "engine/buy_sell_toss.asm"
INCLUDE "engine/trainer_card.asm"
ProfOaksPC: ; 0x265d3
@@ -11878,7 +8258,7 @@ ProfOaksPCBoot ; 0x265ee
ret
; 0x26601
-Function26601: ; 0x26601
+ProfOaksPCRating: ; 0x26601
call Rate
push de
ld de, MUSIC_NONE
@@ -11902,7 +8282,7 @@ Rate: ; 0x26616
ld [wd003], a
; print appropriate rating
- call ClearOakRatingBuffers
+ call .UpdateRatingBuffers
ld hl, OakPCText3
call PrintText
call JoyWaitAorB
@@ -11915,17 +8295,17 @@ Rate: ; 0x26616
ret
; 0x26647
-ClearOakRatingBuffers: ; 0x26647
+.UpdateRatingBuffers: ; 0x26647
ld hl, StringBuffer3
ld de, wd002
- call ClearOakRatingBuffer
+ call .UpdateRatingBuffer
ld hl, StringBuffer4
ld de, wd003
- call ClearOakRatingBuffer
+ call .UpdateRatingBuffer
ret
; 0x2665a
-ClearOakRatingBuffer: ; 0x2665a
+.UpdateRatingBuffer: ; 0x2665a
push hl
ld a, "@"
ld bc, ITEM_NAME_LENGTH
@@ -11962,85 +8342,31 @@ endr
; 0x2667f
OakRatings: ; 0x2667f
-; db count (if number caught ≤ this number, then this entry is used)
-; dw sound effect
-; dw text pointer
-
- db 9
- dw SFX_DEX_FANFARE_LESS_THAN_20
- dw OakRating01
-
- db 19
- dw SFX_DEX_FANFARE_LESS_THAN_20
- dw OakRating02
-
- db 34
- dw SFX_DEX_FANFARE_20_49
- dw OakRating03
-
- db 49
- dw SFX_DEX_FANFARE_20_49
- dw OakRating04
-
- db 64
- dw SFX_DEX_FANFARE_50_79
- dw OakRating05
-
- db 79
- dw SFX_DEX_FANFARE_50_79
- dw OakRating06
-
- db 94
- dw SFX_DEX_FANFARE_80_109
- dw OakRating07
-
- db 109
- dw SFX_DEX_FANFARE_80_109
- dw OakRating08
-
- db 124
- dw SFX_CAUGHT_MON
- dw OakRating09
-
- db 139
- dw SFX_CAUGHT_MON
- dw OakRating10
-
- db 154
- dw SFX_DEX_FANFARE_140_169
- dw OakRating11
-
- db 169
- dw SFX_DEX_FANFARE_140_169
- dw OakRating12
-
- db 184
- dw SFX_DEX_FANFARE_170_199
- dw OakRating13
-
- db 199
- dw SFX_DEX_FANFARE_170_199
- dw OakRating14
-
- db 214
- dw SFX_DEX_FANFARE_200_229
- dw OakRating15
-
- db 229
- dw SFX_DEX_FANFARE_200_229
- dw OakRating16
-
- db 239
- dw SFX_DEX_FANFARE_230_PLUS
- dw OakRating17
-
- db 248
- dw SFX_DEX_FANFARE_230_PLUS
- dw OakRating18
+oakrating: MACRO
+ db \1
+ dw \2, \3
+endm
- db 255
- dw SFX_DEX_FANFARE_230_PLUS
- dw OakRating19
+; if you caught at most this many, play this sound, load this text
+ oakrating 9, SFX_DEX_FANFARE_LESS_THAN_20, OakRating01
+ oakrating 19, SFX_DEX_FANFARE_LESS_THAN_20, OakRating02
+ oakrating 34, SFX_DEX_FANFARE_20_49, OakRating03
+ oakrating 49, SFX_DEX_FANFARE_20_49, OakRating04
+ oakrating 64, SFX_DEX_FANFARE_50_79, OakRating05
+ oakrating 79, SFX_DEX_FANFARE_50_79, OakRating06
+ oakrating 94, SFX_DEX_FANFARE_80_109, OakRating07
+ oakrating 109, SFX_DEX_FANFARE_80_109, OakRating08
+ oakrating 124, SFX_CAUGHT_MON, OakRating09
+ oakrating 139, SFX_CAUGHT_MON, OakRating10
+ oakrating 154, SFX_DEX_FANFARE_140_169, OakRating11
+ oakrating 169, SFX_DEX_FANFARE_140_169, OakRating12
+ oakrating 184, SFX_DEX_FANFARE_170_199, OakRating13
+ oakrating 199, SFX_DEX_FANFARE_170_199, OakRating14
+ oakrating 214, SFX_DEX_FANFARE_200_229, OakRating15
+ oakrating 229, SFX_DEX_FANFARE_200_229, OakRating16
+ oakrating 239, SFX_DEX_FANFARE_230_PLUS, OakRating17
+ oakrating 248, SFX_DEX_FANFARE_230_PLUS, OakRating18
+ oakrating 255, SFX_DEX_FANFARE_230_PLUS, OakRating19
OakPCText1: ; 0x266de
text_jump _OakPCText1
@@ -12147,7 +8473,6 @@ PadCoords_de: ; 27092
ret
; 2709e
-
LevelUpHappinessMod: ; 2709e
ld a, [CurPartyMon]
ld hl, PartyMon1CaughtLocation
@@ -12183,7 +8508,6 @@ _ReturnToBattle_UseBall: ; 2715c
.gettutorialbackpic
callba GetTrainerBackpic
-
.continue
callba GetMonFrontpic
callba _LoadBattleFontsHPBar
@@ -12284,12 +8608,11 @@ MoveEffects: ; 2732e
INCLUDE "battle/moves/move_effects.asm"
Function27a28: ; 27a28
- call Function2500e
+ call BuySellToss_InterpretJoypad
ld b, a
ret
; 27a2d
-
SECTION "bankA", ROMX, BANK[$A]
INCLUDE "engine/link.asm"
@@ -12476,7 +8799,6 @@ DetermineLinkBattleResult: ; 2b930
ret
; 2ba1a
-
ChrisBackpic: ; 2ba1a
INCBIN "gfx/misc/player.6x6.2bpp.lz"
; 2bbaa
@@ -12485,1387 +8807,25 @@ DudeBackpic: ; 2bbaa
INCBIN "gfx/misc/dude.6x6.2bpp.lz"
; 2bcea
-
SECTION "bankB", ROMX, BANK[$B]
-Function2c000: ; 2c000
- ld a, $e4
- ld [rOBP0], a
- call Function2c165
- call Function2c01c
- ld a, [wBattleMode]
- dec a
- ret z
- jp Function2c03a
-; 2c012
-
-
-
-Function2c012: ; 2c012
- ld a, $e4
- ld [rOBP0], a
- call Function2c165
- jp Function2c03a
-; 2c01c
-
-Function2c01c: ; 2c01c
- call Function2c0ad
- ld hl, PartyMon1HP
- ld de, PartyCount
- call Function2c059
- ld a, $60
- ld hl, wcfc4
- ld [hli], a
- ld [hl], a
- ld a, $8
- ld [wd003], a
- ld hl, Sprites
- jp Function2c143
-; 2c03a
-
-
-
-Function2c03a: ; 2c03a
- call Function2c0c5
- ld hl, OTPartyMon1HP
- ld de, OTPartyCount
- call Function2c059
- ld hl, wcfc4
- ld a, $48
- ld [hli], a
- ld [hl], $20
- ld a, $f8
- ld [wd003], a
- ld hl, Sprites + $18
- jp Function2c143
-; 2c059
-
-
-Function2c059: ; 2c059
- ld a, [de]
- push af
- ld de, Buffer1
- ld c, $6
- ld a, $34
-.asm_2c062
- ld [de], a
- inc de
- dec c
- jr nz, .asm_2c062
- pop af
- ld de, Buffer1
-.asm_2c06b
- push af
- call Function2c075
- inc de
- pop af
- dec a
- jr nz, .asm_2c06b
- ret
-; 2c075
-
-Function2c075: ; 2c075
- ld a, [hli]
- and a
- jr nz, .asm_2c07f
- ld a, [hl]
- and a
- ld b, $33
- jr z, .asm_2c08b
-
-.asm_2c07f
-rept 3
- dec hl
-endr
- ld a, [hl]
- and a
- ld b, $32
- jr nz, .asm_2c08e
- dec b
- jr .asm_2c08e
-
-.asm_2c08b
-rept 3
- dec hl
-endr
-
-.asm_2c08e
- ld a, b
- ld [de], a
- ld bc, $32
- add hl, bc
- ret
-; 2c095
-
-DrawPlayerExpBar: ; 2c095
- ld hl, .data_2c0a9
- ld de, wd004
- ld bc, 4
- call CopyBytes
- hlcoord 18, 10
- ld de, -1
- jr Function2c0f1
-
-.data_2c0a9
- db $73
- db $77
- db $6f
- db $76
-; 2c0ad
-
-Function2c0ad: ; 2c0ad
- ld hl, .data_2c0c1
- ld de, wd004
- ld bc, 4
- call CopyBytes
- hlcoord 18, 10
- ld de, -1
- jr Function2c0f1
-
-.data_2c0c1
- db $73, $5c, $6f, $76
-; 2c0c5
-
-Function2c0c5: ; 2c0c5
- ld hl, .data_2c0ed
- ld de, wd004
- ld bc, 4
- call CopyBytes
- hlcoord 1, 2
- ld de, 1
- call Function2c0f1
- ld a, [wBattleMode]
- dec a
- ret nz
- ld a, [TempEnemyMonSpecies]
- dec a
- call CheckCaughtMon
- ret z
- hlcoord 1, 1
- ld [hl], $5d
- ret
-
-.data_2c0ed
- db $6d
- db $74
- db $78
- db $76
-; 2c0f1
-
-Function2c0f1: ; 2c0f1
- ld a, [wd004]
- ld [hl], a
- ld bc, SCREEN_WIDTH
- add hl, bc
- ld a, [StartFlypoint]
- ld [hl], a
- ld b, $8
-.asm_2c0ff
- add hl, de
- ld a, [MovementBuffer]
- ld [hl], a
- dec b
- jr nz, .asm_2c0ff
- add hl, de
- ld a, [EndFlypoint]
- ld [hl], a
- ret
-; 2c10d
-
-
-Function2c10d: ; 2c10d
- call Function2c165
- ld hl, PartyMon1HP
- ld de, PartyCount
- call Function2c059
- ld hl, wcfc4
- ld a, $50
- ld [hli], a
- ld [hl], $40
- ld a, $8
- ld [wd003], a
- ld hl, Sprites
- call Function2c143
- ld hl, OTPartyMon1HP
- ld de, OTPartyCount
- call Function2c059
- ld hl, wcfc4
- ld a, "@"
- ld [hli], a
- ld [hl], $68
- ld hl, Sprites + $18
- jp Function2c143
-; 2c143
-
-Function2c143: ; 2c143
- ld de, Buffer1
- ld c, $6
-.loop
- ld a, [wcfc5]
- ld [hli], a
- ld a, [wcfc4]
- ld [hli], a
- ld a, [de]
- ld [hli], a
- ld a, $3
- ld [hli], a
- ld a, [wcfc4]
- ld b, a
- ld a, [wd003]
- add b
- ld [wcfc4], a
- inc de
- dec c
- jr nz, .loop
- ret
-; 2c165
-
-Function2c165: ; 2c165
- ld de, GFX_2c172
- ld hl, VTiles0 tile $31
- lb bc, BANK(GFX_2c172), 4
- call Get2bpp_2
- ret
-; 2c172
-
-GFX_2c172: ; 2c172
-INCBIN "gfx/battle/balls.2bpp"
-; 2c1b2
-
-_ShowLinkBattleParticipants: ; 2c1b2
- call ClearBGPalettes
- call LoadFontsExtra
- hlcoord 2, 3
- ld b, 9
- ld c, 14
- call TextBox
- hlcoord 4, 5
- ld de, PlayerName
- call PlaceString
- hlcoord 4, 10
- ld de, OTPlayerName
- call PlaceString
- hlcoord 9, 8
- ld a, $69
- ld [hli], a
- ld [hl], $6a
- callba Function2c10d ; no need to callba
- ld b, SCGB_08
- call GetSGBLayout
- call SetPalettes
- ld a, $e4
- ld [rOBP0], a
- ret
-; 2c1ef
-
+INCLUDE "battle/trainer_huds.asm"
TrainerClassNames:: ; 2c1ef
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "RIVAL@"
- db "#MON PROF.@"
- db "ELITE FOUR@"
- db "<PKMN> TRAINER@"
- db "ELITE FOUR@"
- db "ELITE FOUR@"
- db "ELITE FOUR@"
- db "CHAMPION@"
- db "LEADER@"
- db "LEADER@"
- db "LEADER@"
- db "SCIENTIST@"
- db "LEADER@"
- db "YOUNGSTER@"
- db "SCHOOLBOY@"
- db "BIRD KEEPER@"
- db "LASS@"
- db "LEADER@"
- db "COOLTRAINER@"
- db "COOLTRAINER@"
- db "BEAUTY@"
- db "#MANIAC@"
- db "ROCKET@"
- db "GENTLEMAN@"
- db "SKIER@"
- db "TEACHER@"
- db "LEADER@"
- db "BUG CATCHER@"
- db "FISHER@"
- db "SWIMMER♂@"
- db "SWIMMER♀@"
- db "SAILOR@"
- db "SUPER NERD@"
- db "RIVAL@"
- db "GUITARIST@"
- db "HIKER@"
- db "BIKER@"
- db "LEADER@"
- db "BURGLAR@"
- db "FIREBREATHER@"
- db "JUGGLER@"
- db "BLACKBELT@"
- db "ROCKET@"
- db "PSYCHIC@"
- db "PICNICKER@"
- db "CAMPER@"
- db "ROCKET@"
- db "SAGE@"
- db "MEDIUM@"
- db "BOARDER@"
- db "#FAN@"
- db "KIMONO GIRL@"
- db "TWINS@"
- db "#FAN@"
- db "<PKMN> TRAINER@"
- db "LEADER@"
- db "OFFICER@"
- db "ROCKET@"
- db "MYSTICALMAN@"
-
-
-
-AI_Redundant: ; 2c41a
-; Check if move effect c will fail because it's already been used.
-; Return z if the move is a good choice.
-; Return nz if the move is a bad choice.
- ld a, c
- ld de, 3
- ld hl, .Moves
- call IsInArray
- jp nc, .NotRedundant
- inc hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-
-.Moves: ; 2c42c
- dbw EFFECT_DREAM_EATER, .DreamEater
- dbw EFFECT_HEAL, .Heal
- dbw EFFECT_LIGHT_SCREEN, .LightScreen
- dbw EFFECT_MIST, .Mist
- dbw EFFECT_FOCUS_ENERGY, .FocusEnergy
- dbw EFFECT_CONFUSE, .Confuse
- dbw EFFECT_TRANSFORM, .Transform
- dbw EFFECT_REFLECT, .Reflect
- dbw EFFECT_SUBSTITUTE, .Substitute
- dbw EFFECT_LEECH_SEED, .LeechSeed
- dbw EFFECT_DISABLE, .Disable
- dbw EFFECT_ENCORE, .Encore
- dbw EFFECT_SNORE, .Snore
- dbw EFFECT_SLEEP_TALK, .SleepTalk
- dbw EFFECT_MEAN_LOOK, .MeanLook
- dbw EFFECT_NIGHTMARE, .Nightmare
- dbw EFFECT_SPIKES, .Spikes
- dbw EFFECT_FORESIGHT, .Foresight
- dbw EFFECT_PERISH_SONG, .PerishSong
- dbw EFFECT_SANDSTORM, .Sandstorm
- dbw EFFECT_ATTRACT, .Attract
- dbw EFFECT_SAFEGUARD, .Safeguard
- dbw EFFECT_RAIN_DANCE, .RainDance
- dbw EFFECT_SUNNY_DAY, .SunnyDay
- dbw EFFECT_TELEPORT, .Teleport
- dbw EFFECT_MORNING_SUN, .MorningSun
- dbw EFFECT_SYNTHESIS, .Synthesis
- dbw EFFECT_MOONLIGHT, .Moonlight
- dbw EFFECT_SWAGGER, .Swagger
- dbw EFFECT_FUTURE_SIGHT, .FutureSight
- db -1
-
-.LightScreen: ; 2c487
- ld a, [EnemyScreens]
- bit SCREENS_LIGHT_SCREEN, a
- ret
-
-.Mist: ; 2c48d
- ld a, [EnemySubStatus4]
- bit SUBSTATUS_MIST, a
- ret
-
-.FocusEnergy: ; 2c493
- ld a, [EnemySubStatus4]
- bit SUBSTATUS_FOCUS_ENERGY, a
- ret
-
-.Confuse: ; 2c499
- ld a, [PlayerSubStatus3]
- bit SUBSTATUS_CONFUSED, a
- ret nz
- ld a, [PlayerScreens]
- bit SCREENS_SAFEGUARD, a
- ret
-
-.Transform: ; 2c4a5
- ld a, [EnemySubStatus5]
- bit SUBSTATUS_TRANSFORMED, a
- ret
-
-.Reflect: ; 2c4ab
- ld a, [EnemyScreens]
- bit SCREENS_REFLECT, a
- ret
-
-.Substitute: ; 2c4b1
- ld a, [EnemySubStatus4]
- bit SUBSTATUS_SUBSTITUTE, a
- ret
-
-.LeechSeed: ; 2c4b7
- ld a, [PlayerSubStatus4]
- bit SUBSTATUS_LEECH_SEED, a
- ret
-
-.Disable: ; 2c4bd
- ld a, [PlayerDisableCount]
- and a
- ret
-
-.Encore: ; 2c4c2
- ld a, [PlayerSubStatus5]
- bit SUBSTATUS_ENCORED, a
- ret
-
-.Snore:
-.SleepTalk: ; 2c4c8
- ld a, [EnemyMonStatus]
- and SLP
- jr z, .Redundant
- jr .NotRedundant
-
-.MeanLook: ; 2c4d1
- ld a, [EnemySubStatus5]
- bit SUBSTATUS_CANT_RUN, a
- ret
-
-.Nightmare: ; 2c4d7
- ld a, [BattleMonStatus]
- and a
- jr z, .Redundant
- ld a, [PlayerSubStatus1]
- bit SUBSTATUS_NIGHTMARE, a
- ret
-
-.Spikes: ; 2c4e3
- ld a, [PlayerScreens]
- bit SCREENS_SPIKES, a
- ret
-
-.Foresight: ; 2c4e9
- ld a, [PlayerSubStatus1]
- bit SUBSTATUS_IDENTIFIED, a
- ret
-
-.PerishSong: ; 2c4ef
- ld a, [PlayerSubStatus1]
- bit SUBSTATUS_PERISH, a
- ret
-
-.Sandstorm: ; 2c4f5
- ld a, [Weather]
- cp WEATHER_SANDSTORM
- jr z, .Redundant
- jr .NotRedundant
-
-.Attract: ; 2c4fe
- callba CheckOppositeGender
- jr c, .Redundant
- ld a, [PlayerSubStatus1]
- bit SUBSTATUS_IN_LOVE, a
- ret
-
-.Safeguard: ; 2c50c
- ld a, [EnemyScreens]
- bit SCREENS_SAFEGUARD, a
- ret
-
-.RainDance: ; 2c512
- ld a, [Weather]
- cp WEATHER_RAIN
- jr z, .Redundant
- jr .NotRedundant
-
-.SunnyDay: ; 2c51b
- ld a, [Weather]
- cp WEATHER_SUN
- jr z, .Redundant
- jr .NotRedundant
-
-.DreamEater: ; 2c524
- ld a, [BattleMonStatus]
- and SLP
- jr z, .Redundant
- jr .NotRedundant
-
-.Swagger: ; 2c52d
- ld a, [PlayerSubStatus3]
- bit SUBSTATUS_CONFUSED, a
- ret
-
-.FutureSight: ; 2c533
- ld a, [EnemyScreens]
- bit 5, a
- ret
-
-.Heal:
-.MorningSun:
-.Synthesis:
-.Moonlight: ; 2c539
- callba AICheckEnemyMaxHP
- jr nc, .NotRedundant
-
-.Teleport:
-.Redundant: ; 2c541
- ld a, 1
- and a
- ret
-
-.NotRedundant: ; 2c545
- xor a
- ret
+INCLUDE "text/trainer_class_names.asm"
+INCLUDE "battle/ai/redundant.asm"
INCLUDE "event/move_deleter.asm"
+INCLUDE "engine/mysterygift2.asm"
-Function2c642: ; 2c642 (b:4642)
- ld de, OverworldMap
- ld a, $1
- ld [de], a
- inc de
- ld a, BANK(sGameData)
- call GetSRAMBank
- ld hl, sPlayerData + PlayerID - wPlayerData
- ld a, [hli]
- ld [de], a
- ld b, a
- inc de
- ld a, [hl]
- ld [de], a
- ld c, a
- inc de
- push bc
- ld hl, sPlayerData + PlayerName - wPlayerData
- ld bc, NAME_LENGTH
- call CopyBytes
- push de
- ld hl, sPokemonData + PokedexCaught - wPokemonData
- ld b, (NUM_POKEMON + 7) / 8
- call CountSetBits
- pop de
- pop bc
- ld a, [wd265]
- ld [de], a
- inc de
- call CloseSRAM
- call Random
- and $1
- ld [de], a
- inc de
- call Function2c6ac
- ld [de], a
- inc de
- ld a, c
- ld c, b
- ld b, a
- call Function2c6ac
- ld [de], a
- inc de
- ld a, BANK(sBackupMysteryGiftItem)
- call GetSRAMBank
- ld a, [sBackupMysteryGiftItem]
- ld [de], a
- inc de
- ld a, [sBackupMysteryGiftItem + 1]
- ld [de], a
- ld a, $14
- ld [wca00], a
- call CloseSRAM
- ld hl, OverworldMap
- ld de, wc950
- ld bc, SCREEN_WIDTH
- jp CopyBytes
-
-Function2c6ac: ; 2c6ac (b:46ac)
- push de
- call Random
- cp $19 ; 10 percent
- jr c, .tenpercent
- call Random
- and $7
- ld d, a
- rl d
- ld e, $80
-.loop
- rlc e
- dec a
- jr nz, .loop
- ld a, e
- and c
- jr z, .skip
- ld a, $1
-.skip
- add d
- jr .done
-
-.tenpercent
- call Random
- cp $32 ; 20 percent
- jr c, .twopercent
- call Random
- and $3
- ld d, a
- rl d
- ld e, $80
-.loop2
- rlc e
- dec a
- jr nz, .loop2
- ld a, e
- and b
- jr z, .skip2
- ld a, $1
-.skip2
- add d
- add $10
- jr .done
-
-.twopercent
- call Random
- cp $32 ; 50 ; 20 percent
- jr c, .pointfourpercent
- ld a, b
- swap a
- and $7
- add $18
- jr .done
-
-.pointfourpercent
- ld a, b
- and $80
- ld a, $20
- jr z, .done
- ld a, $21
-
-.done
- pop de
- ret
-
-MysteryGiftGetItemHeldEffect: ; 2c708 (b:4708)
- ld a, c
- cp $25 ; 37
- jr nc, Function2c722
- ld hl, Unknown_2c725
- ld b, 0
- add hl, bc
- ld c, [hl]
- ret
-
-MysteryGiftGetDecoration: ; 2c715 (b:4715)
- ld a, c
- cp $25 ; 37
- jr nc, Function2c722
- ld hl, Unknown_2c74a
- ld b, 0
- add hl, bc
- ld c, [hl]
- ret
-
-Function2c722: ; 2c722 (b:4722)
- ld c, DECO_POLKADOT_BED ; GREAT_BALL
- ret
-; 2c725 (b:4725)
-
-Unknown_2c725: ; 2c725
-; May or may not be items.
- db BERRY
- db PRZCUREBERRY
- db MINT_BERRY
- db ICE_BERRY
- db BURNT_BERRY
- db PSNCUREBERRY
- db GUARD_SPEC
- db X_DEFEND
- db X_ATTACK
- db BITTER_BERRY
- db DIRE_HIT
- db X_SPECIAL
- db X_ACCURACY
- db EON_MAIL
- db MORPH_MAIL
- db MUSIC_MAIL
- db MIRACLEBERRY
- db GOLD_BERRY
- db REVIVE
- db GREAT_BALL
- db SUPER_REPEL
- db MAX_REPEL
- db ELIXER
- db ETHER
- db WATER_STONE
- db FIRE_STONE
- db LEAF_STONE
- db THUNDERSTONE
- db MAX_ETHER
- db MAX_ELIXER
- db MAX_REVIVE
- db SCOPE_LENS
- db HP_UP
- db PP_UP
- db RARE_CANDY
- db BLUESKY_MAIL
- db MIRAGE_MAIL
-; 2c74a
-
-Unknown_2c74a: ; 2c74a
-; May or may not be items.
- db DECO_SNES
- db DECO_BIG_SNORLAX_DOLL
- db DECO_BIG_ONIX_DOLL
- db DECO_BIG_LAPRAS_DOLL
- db DECO_DOLLS
- db DECO_PIKACHU_DOLL
- db DECO_SURF_PIKACHU_DOLL
- db DECO_CLEFAIRY_DOLL
- db DECO_JIGGLYPUFF_DOLL
- db DECO_BULBASAUR_DOLL
- db DECO_TROPICPLANT
- db DECO_JUMBOPLANT
- db DECO_TOWN_MAP
- db DECO_CHARMANDER_DOLL
- db DECO_POLIWAG_DOLL
- db DECO_DIGLETT_DOLL
- db DECO_BLUE_CARPET
- db DECO_YELLOW_CARPET
- db DECO_POSTERS
- db DECO_PIKACHU_POSTER
- db DECO_N64
- db DECO_BIG_DOLLS
- db DECO_BEDS
- db DECO_FEATHERY_BED
- db DECO_POLKADOT_BED
- db DECO_PIKACHU_BED
- db DECO_CARPETS
- db DECO_RED_CARPET
- db DECO_GREEN_CARPET
- db DECO_CLEFAIRY_POSTER
- db DECO_ODDISH_DOLL
- db DECO_MAGNAPLANT
- db DECO_GENGAR_DOLL
- db DECO_CONSOLES
- db DECO_PINK_BED
- db DECO_SQUIRTLE_DOLL
- db DECO_STARMIE_DOLL
-; 2c76f
-
-Function2c76f: ; 2c76f (b:476f)
- ld a, $1
- ld [hInMenu], a
- call Function2c8d3
- ld a, $0
- ld [hInMenu], a
- ret nc
- call Function1bee
- call WaitBGMap
- ld a, [CurItem]
- dec a
- ld [wd107], a
- ld hl, TMsHMs
- ld c, a
- ld b, $0
- add hl, bc
- ld a, [hl]
- ld [wItemQuantityBuffer], a
- call Function2c798
- scf
- ret
-
-Function2c798: ; 2c798 (b:4798)
- ld a, [CurItem]
- ld c, a
- callab GetNumberedTMHM
- ld a, c
- ld [CurItem], a
- ret
-
-ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7)
- ld a, [CurItem]
- ld c, a
- callab GetTMHMNumber
- ld a, c
- ld [wCurTMHM], a
- ret
-
-GetTMHMItemMove: ; 2c7b6 (b:47b6)
- call ConvertCurItemIntoCurTMHM
- predef GetTMHMMove
- ret
-
-Function2c7bf: ; 2c7bf (b:47bf)
- ld hl, Options
- ld a, [hl]
- push af
- res 4, [hl]
- ld a, [CurItem]
- cp TM01
- jr c, .NotTMHM
- call GetTMHMItemMove
- ld a, [wCurTMHM]
- ld [wd262], a
- call GetMoveName
- call CopyName1
- ld hl, UnknownText_0x2c8bf ; Booted up a TM
- ld a, [CurItem]
- cp HM01
- jr c, .TM
- ld hl, UnknownText_0x2c8c4 ; Booted up an HM
-.TM
- call PrintText
- ld hl, UnknownText_0x2c8c9
- call PrintText
- call YesNoBox
-.NotTMHM
- pop bc
- ld a, b
- ld [Options], a
- ret
-
-
-Function2c7fb: ; 2c7fb
- ld hl, StringBuffer2
- ld de, wd066
- ld bc, $c
- call CopyBytes
- call ClearBGPalettes
-
-Function2c80a: ; 2c80a
- callba LoadPartyMenuGFX
- callba InitPartyMenuWithCancel
- callba InitPartyMenuGFX
- ld a, $3
- ld [PartyMenuActionText], a
-.loopback
- callba WritePartyMenuTilemap
- callba PrintPartyMenuText
- call WaitBGMap
- call SetPalettes
- call DelayFrame
- callba PartyMenuSelect
- push af
- ld a, [CurPartySpecies]
- cp EGG
- pop bc ; now contains the former contents of af
- jr z, .egg
- push bc
- ld hl, wd066
- ld de, StringBuffer2
- ld bc, $c
- call CopyBytes
- pop af ; now contains the original contents of af
- ret
-
-.egg
- push hl
- push de
- push bc
- push af
- ld de, SFX_WRONG
- call PlaySFX
- call WaitSFX
- pop af
- pop bc
- pop de
- pop hl
- jr .loopback
-; 2c867
-
-Function2c867: ; 2c867
- predef CanLearnTMHMMove
-
- push bc
- ld a, [CurPartyMon]
- ld hl, PartyMonNicknames
- call GetNick
- pop bc
-
- ld a, c
- and a
- jr nz, .compatible
- push de
- ld de, SFX_WRONG
- call PlaySFX
- pop de
- ld hl, UnknownText_0x2c8ce
- call PrintText
- jr .nope
-
-.compatible
- callab KnowsMove
- jr c, .nope
-
- predef LearnMove
- ld a, b
- and a
- jr z, .nope
-
- callba MobileFn_106049
- ld a, [CurItem]
- call IsHM
- ret c
-
- ld c, HAPPINESS_LEARNMOVE
- callab ChangeHappiness
- call Function2cb0c
- jr .asm_2c8bd
-
-.nope
- and a
- ret
-
-.asm_2c8b8
- ld a, $2
- ld [wd0ec], a
-
-.asm_2c8bd
- scf
- ret
-; 2c8bf (b:48bf)
-
-UnknownText_0x2c8bf: ; 0x2c8bf
- ; Booted up a TM.
- text_jump UnknownText_0x1c0373
- db "@"
-; 0x2c8c4
-
-UnknownText_0x2c8c4: ; 0x2c8c4
- ; Booted up an HM.
- text_jump UnknownText_0x1c0384
- db "@"
-; 0x2c8c9
-
-UnknownText_0x2c8c9: ; 0x2c8c9
- ; It contained @ . Teach @ to a #MON?
- text_jump UnknownText_0x1c0396
- db "@"
-; 0x2c8ce
-
-UnknownText_0x2c8ce: ; 0x2c8ce
- ; is not compatible with @ . It can't learn @ .
- text_jump UnknownText_0x1c03c2
- db "@"
-; 0x2c8d3
-
-Function2c8d3: ; 2c8d3 (b:48d3)
- xor a
- ld [hBGMapMode], a
- call Function2c9e2
- ld a, $2
- ld [wcfa1], a
- ld a, $7
- ld [wcfa2], a
- ld a, $1
- ld [wcfa4], a
- ld a, $5
- sub d
- inc a
- cp $6
- jr nz, .asm_2c8f1
- dec a
-.asm_2c8f1
- ld [wcfa3], a
- ld a, $c
- ld [wcfa5], a
- xor a
- ld [wcfa6], a
- ld a, $20
- ld [wcfa7], a
- ld a, $f3
- ld [wcfa8], a
- ld a, [wTMHMPocketCursor]
- inc a
- ld [MenuSelection2], a
- ld a, $1
- ld [wcfaa], a
- jr Function2c946
-
-Function2c915: ; 2c915 (b:4915)
- call Function2c9e2
- call Function1bc9
- ld b, a
- ld a, [MenuSelection2]
- dec a
- ld [wTMHMPocketCursor], a
- xor a
- ld [hBGMapMode], a
- ld a, [wcfa6]
- bit 7, a
- jp nz, Function2c9b1
- ld a, b
- ld [wcf73], a
- bit 0, a
- jp nz, Function2c974
- bit 1, a
- jp nz, Function2c9a5
- bit 4, a
- jp nz, Function2c9af
- bit 5, a
- jp nz, Function2c9af
-
-Function2c946: ; 2c946 (b:4946)
- call Function2c98a
- jp nc, Function2c9af
- hlcoord 0, 12
- ld b, $4
- ld c, $12
- call TextBox
- ld a, [CurItem]
- cp $3a
- jr nc, Function2c915
- ld [wd265], a
- predef GetTMHMMove
- ld a, [wd265]
- ld [CurSpecies], a
- hlcoord 1, 14
- call PrintMoveDesc
- jp Function2c915
-
-Function2c974: ; 2c974 (b:4974)
- call Function2cad6
- call Function2cb2a
- ld a, [MenuSelection2]
- dec a
- ld b, a
- ld a, [wTMHMPocketScrollPosition]
- add b
- ld b, a
- ld a, [wd265]
- cp b
- jr z, asm_2c9a8
-
-Function2c98a: ; 2c98a (b:498a)
- call Function2cab5
- ld a, [MenuSelection2]
- ld b, a
-.asm_2c991
- inc c
- ld a, c
- cp $3a
- jr nc, .asm_2c99f
- ld a, [hli]
- and a
- jr z, .asm_2c991
- dec b
- jr nz, .asm_2c991
- ld a, c
-.asm_2c99f
- ld [CurItem], a
- cp $ff
- ret
-
-Function2c9a5: ; 2c9a5 (b:49a5)
- call Function2cad6
-
-asm_2c9a8: ; 2c9a8 (b:49a8)
- ld a, $2
- ld [wcf73], a
- and a
- ret
-
-Function2c9af: ; 2c9af (b:49af)
- and a
- ret
-
-Function2c9b1: ; 2c9b1 (b:49b1)
- ld a, b
- bit 7, a
- jr nz, .skip
- ld hl, wTMHMPocketScrollPosition
- ld a, [hl]
- and a
- jp z, Function2c915
- dec [hl]
- call Function2c9e2
- jp Function2c946
-
-.skip
- call Function2cab5
- ld b, $5
-.loop
- inc c
- ld a, c
- cp NUM_TMS + NUM_HMS + 1
- jp nc, Function2c915
- ld a, [hli]
- and a
- jr z, .loop
- dec b
- jr nz, .loop
- ld hl, wTMHMPocketScrollPosition
- inc [hl]
- call Function2c9e2
- jp Function2c946
-
-Function2c9e2: ; 2c9e2 (b:49e2)
- ld a, [BattleType]
- cp BATTLETYPE_TUTORIAL
- jp z, Function2caca
-
- hlcoord 5, 2
- lb bc, 10, 15
- ld a, " "
- call ClearBox
- call Function2cab5
- ld d, $5
-.loop2
- inc c
- ld a, c
- cp NUM_TMS + NUM_HMS + 1
- jr nc, .NotTMHM
- ld a, [hli]
- and a
- jr z, .loop2
- ld b, a
- ld a, c
- ld [wd265], a
- push hl
- push de
- push bc
- call Function2ca86
- push hl
- ld a, [wd265]
- cp NUM_TMS + 1
- jr nc, .HM
- ld de, wd265
- lb bc, PRINTNUM_LEADINGZEROS | 1, 2
- call PrintNum
- jr .okay
-
-.HM
- push af
- sub NUM_TMS
- ld [wd265], a
- ld [hl], "H"
- inc hl
- ld de, wd265
- lb bc, PRINTNUM_RIGHTALIGN | 1, 2
- call PrintNum
- pop af
- ld [wd265], a
-.okay
- predef GetTMHMMove
- ld a, [wd265]
- ld [wd262], a
- call GetMoveName
- pop hl
- ld bc, $3
- add hl, bc
- push hl
- call PlaceString
- pop hl
- pop bc
- ld a, c
- push bc
- cp NUM_TMS + 1
- jr nc, .hm2
- ld bc, $1d
- add hl, bc
- ld [hl], $f1
- inc hl
- ld a, "0" ; why are we doing this?
- pop bc
- push bc
- ld a, b
- ld [wd265], a
- ld de, wd265
- lb bc, 1, 2
- call PrintNum
-.hm2
- pop bc
- pop de
- pop hl
- dec d
- jr nz, .loop2
- jr .done
-
-.NotTMHM
- call Function2ca86
-rept 3
- inc hl
-endr
- push de
- ld de, String_2caae
- call PlaceString
- pop de
-.done
- ret
-
-Function2ca86: ; 2ca86 (b:4a86)
- hlcoord 5, 0
- ld bc, $28
- ld a, 6
- sub d
- ld e, a
-.loop
- add hl, bc
- dec e
- jr nz, .loop
- ret
-; 2ca95 (b:4a95)
-
-Function2ca95: ; 2ca95
- pop hl
- ld bc, 3
- add hl, bc
- predef GetTMHMMove
- ld a, [wd265]
- ld [wd262], a
- call GetMoveName
- push hl
- call PlaceString
- pop hl
- ret
-; 2caae
-
-String_2caae: ; 2caae
- db "CANCEL@"
-; 2cab5
-
-Function2cab5: ; 2cab5 (b:4ab5)
- ld hl, TMsHMs
- ld a, [wTMHMPocketScrollPosition]
- ld b, a
- inc b
- ld c, 0
-.loop
- inc c
- ld a, [hli]
- and a
- jr z, .loop
- dec b
- jr nz, .loop
- dec hl
- dec c
- ret
-
-Function2caca: ; 2caca (b:4aca)
- hlcoord 9, 3
- push de
- ld de, String_2caae
- call PlaceString
- pop de
- ret
-
-Function2cad6: ; 2cad6 (b:4ad6)
- push de
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- pop de
- ret
-; 2cadf (b:4adf)
-
-Function2cadf: ; 2cadf
- call ConvertCurItemIntoCurTMHM
- call Function2cafa
- ld hl, UnknownText_0x2caf0
- jr nc, .asm_2caed
- ld hl, UnknownText_0x2caf5
-
-.asm_2caed
- jp PrintText
-; 2caf0
-
-UnknownText_0x2caf0: ; 0x2caf0
- ; You have no room for any more @ S.
- text_jump UnknownText_0x1c03fa
- db "@"
-; 0x2caf5
-
-UnknownText_0x2caf5: ; 0x2caf5
- ; You received @ !
- text_jump UnknownText_0x1c0421
- db "@"
-; 0x2cafa
-
-Function2cafa: ; 2cafa
- ld a, [wd265]
- dec a
- ld hl, TMsHMs
- ld b, 0
- ld c, a
- add hl, bc
- ld a, [hl]
- inc a
- cp NUM_TMS * 2
- ret nc
- ld [hl], a
- ret
-; 2cb0c
-
-Function2cb0c: ; 2cb0c (b:4b0c)
- call ConvertCurItemIntoCurTMHM
- ld a, [wd265]
- dec a
- ld hl, TMsHMs
- ld b, 0
- ld c, a
- add hl, bc
- ld a, [hl]
- and a
- ret z
- dec a
- ld [hl], a
- ret nz
- ld a, [wTMHMPocketScrollPosition]
- and a
- ret z
- dec a
- ld [wTMHMPocketScrollPosition], a
- ret
-
-Function2cb2a: ; 2cb2a (b:4b2a)
- ld b, $0
- ld c, $39
- ld hl, TMsHMs
-.asm_2cb31
- ld a, [hli]
- and a
- jr z, .asm_2cb36
- inc b
-.asm_2cb36
- dec c
- jr nz, .asm_2cb31
- ld a, b
- ld [wd265], a
- ret
-
-
-PrintMoveDesc: ; 2cb3e
- push hl
- ld hl, MoveDescriptions
- ld a, [CurSpecies]
- dec a
- ld c, a
- ld b, 0
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld e, a
- ld d, [hl]
- pop hl
- jp PlaceString
-; 2cb52
+INCLUDE "engine/tmhm2.asm"
MoveDescriptions:: ; 2cb52
INCLUDE "battle/moves/move_descriptions.asm"
; 2ed44
-
Function2ed44: ; 2ed44
call ConvertBerriesToBerryJuice
ld hl, PartyMon1PokerusStatus
@@ -14035,7 +8995,6 @@ ShowLinkBattleParticipants: ; 2ee18
ret
; 2ee2f
-
FindFirstAliveMon: ; 2ee2f
xor a
ld [hMapAnims], a
@@ -14071,7 +9030,6 @@ FindFirstAliveMon: ; 2ee2f
ret
; 2ee6c
-
PlayBattleMusic: ; 2ee6c
push hl
@@ -14174,13 +9132,12 @@ PlayBattleMusic: ; 2ee6c
ret
; 2ef18
-
ClearBattleRAM: ; 2ef18
xor a
- ld [wd0ec], a
+ ld [wPlayerAction], a
ld [wBattleResult], a
- ld hl, wd0d8
+ ld hl, wPartyMenuCursor
rept 3
ld [hli], a
endr
@@ -14217,26 +9174,25 @@ endr
callab ResetEnemyStatLevels
- call ResetTextRelatedRAM
+ call ClearWindowData
ld hl, hBGMapAddress
xor a
ld [hli], a
- ld [hl], $98
+ ld [hl], VBGMap0 / $100
ret
; 2ef6e
-
FillBox: ; 2ef6e
-; Fill wc2c6-aligned box width b height c
+; Fill wBoxAlignment-aligned box width b height c
; with iterating tile starting from hFillBox at hl.
; Predef $13
- ld de, 20
+ ld de, SCREEN_WIDTH
- ld a, [wc2c6]
+ ld a, [wBoxAlignment]
and a
- jr nz, .left
+ jr nz, .right
ld a, [hFillBox]
.x1
@@ -14257,7 +9213,7 @@ FillBox: ; 2ef6e
jr nz, .x1
ret
-.left
+.right
; Right-aligned.
push bc
ld b, 0
@@ -14285,25 +9241,21 @@ FillBox: ; 2ef6e
ret
; 2ef9f
-
SECTION "Tileset Data 4", ROMX, BANK[TILESETS_4]
INCLUDE "tilesets/data_4.asm"
-
-SECTION "bankD", ROMX, BANK[$D]
+SECTION "Effect Commands", ROMX, BANK[$D]
INCLUDE "battle/effect_commands.asm"
-
-SECTION "bankE", ROMX, BANK[$E]
+SECTION "Enemy Trainers", ROMX, BANK[$E]
INCLUDE "battle/ai/items.asm"
AIScoring: ; 38591
INCLUDE "battle/ai/scoring.asm"
-
GetTrainerClassName: ; 3952d
ld hl, RivalName
ld a, c
@@ -14326,8 +9278,8 @@ GetTrainerClassName: ; 3952d
ret
; 39550
-Function39550: ; 39550
- ld hl, wd26b
+GetOTName: ; 39550
+ ld hl, OTPlayerName
ld a, [wLinkMode]
and a
jr nz, .ok
@@ -14352,13 +9304,13 @@ Function39550: ; 39550
ret
; 3957b
-Function3957b: ; 3957b
+GetTrainerAttributes: ; 3957b
ld a, [TrainerClass]
ld c, a
- call Function39550
+ call GetOTName
ld a, [TrainerClass]
dec a
- ld hl, TrainerClassAttributes
+ ld hl, TrainerClassAttributes + TRNATTR_ITEM1
ld bc, NUM_TRAINER_ATTRIBUTES
call AddNTimes
ld de, wEnemyTrainerItem1
@@ -14374,491 +9326,22 @@ Function3957b: ; 3957b
INCLUDE "trainers/attributes.asm"
-
-ReadTrainerParty: ; 39771
- ld a, [InBattleTowerBattle]
- bit 0, a
- ret nz
-
- ld a, [wLinkMode]
- and a
- ret nz
-
- ld hl, OTPartyCount
- xor a
- ld [hli], a
- dec a
- ld [hl], a
-
- ld hl, OTPartyMons
- ld bc, OTPartyMonsEnd - OTPartyMons
- xor a
- call ByteFill
-
- ld a, [OtherTrainerClass]
- cp CAL
- jr nz, .not_cal2
- ld a, [OtherTrainerID]
- cp CAL2
- jr z, .cal2
- ld a, [OtherTrainerClass]
-.not_cal2
-
- dec a
- ld c, a
- ld b, 0
- ld hl, TrainerGroups
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- ld a, [OtherTrainerID]
- ld b, a
-.skip_trainer
- dec b
- jr z, .got_trainer
-.loop
- ld a, [hli]
- cp $ff
- jr nz, .loop
- jr .skip_trainer
-.got_trainer
-
-.skip_name
- ld a, [hli]
- cp "@"
- jr nz, .skip_name
-
- ld a, [hli]
- ld c, a
- ld b, 0
- ld d, h
- ld e, l
- ld hl, TrainerTypes
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld bc, .done
- push bc
- jp [hl]
-
-.done
- jp ComputeTrainerReward
-
-.cal2
- ld a, BANK(sMysteryGiftTrainer)
- call GetSRAMBank
- ld de, sMysteryGiftTrainer
- call TrainerType2
- call CloseSRAM
- jr .done
-; 397e3
-
-TrainerTypes: ; 397e3
- dw TrainerType1 ; level, species
- dw TrainerType2 ; level, species, moves
- dw TrainerType3 ; level, species, item
- dw TrainerType4 ; level, species, item, moves
-; 397eb
-
-TrainerType1: ; 397eb
-; normal (level, species)
- ld h, d
- ld l, e
-.loop
- ld a, [hli]
- cp $ff
- ret z
-
- ld [CurPartyLevel], a
- ld a, [hli]
- ld [CurPartySpecies], a
- ld a, OTPARTYMON
- ld [MonType], a
- push hl
- predef TryAddMonToParty
- pop hl
- jr .loop
-; 39806
-
-TrainerType2: ; 39806
-; moves
- ld h, d
- ld l, e
-.loop
- ld a, [hli]
- cp $ff
- ret z
-
- ld [CurPartyLevel], a
- ld a, [hli]
- ld [CurPartySpecies], a
- ld a, OTPARTYMON
- ld [MonType], a
-
- push hl
- predef TryAddMonToParty
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1Moves
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- pop hl
-
- ld b, NUM_MOVES
-.copy_moves
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .copy_moves
-
- push hl
-
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- ld hl, MON_PP
- add hl, de
- push hl
- ld hl, MON_MOVES
- add hl, de
- pop de
-
- ld b, NUM_MOVES
-.copy_pp
- ld a, [hli]
- and a
- jr z, .copied_pp
-
- push hl
- push bc
- dec a
- ld hl, Moves + MOVE_PP
- ld bc, MOVE_LENGTH
- call AddNTimes
- ld a, BANK(Moves)
- call GetFarByte
- pop bc
- pop hl
-
- ld [de], a
- inc de
- dec b
- jr nz, .copy_pp
-.copied_pp
-
- pop hl
- jr .loop
-; 39871
-
-TrainerType3: ; 39871
-; item
- ld h, d
- ld l, e
-.loop
- ld a, [hli]
- cp $ff
- ret z
-
- ld [CurPartyLevel], a
- ld a, [hli]
- ld [CurPartySpecies], a
- ld a, OTPARTYMON
- ld [MonType], a
- push hl
- predef TryAddMonToParty
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- pop hl
- ld a, [hli]
- ld [de], a
- jr .loop
-; 3989d (e:589d)
-
-TrainerType4: ; 3989d
-; item + moves
- ld h, d
- ld l, e
-.loop
- ld a, [hli]
- cp $ff
- ret z
-
- ld [CurPartyLevel], a
- ld a, [hli]
- ld [CurPartySpecies], a
-
- ld a, OTPARTYMON
- ld [MonType], a
-
- push hl
- predef TryAddMonToParty
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- pop hl
-
- ld a, [hli]
- ld [de], a
-
- push hl
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1Moves
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- pop hl
-
- ld b, NUM_MOVES
-.copy_moves
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .copy_moves
-
- push hl
-
- ld a, [OTPartyCount]
- dec a
- ld hl, OTPartyMon1
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- ld hl, MON_PP
- add hl, de
-
- push hl
- ld hl, MON_MOVES
- add hl, de
- pop de
-
- ld b, NUM_MOVES
-.copy_pp
- ld a, [hli]
- and a
- jr z, .copied_pp
-
- push hl
- push bc
- dec a
- ld hl, Moves + MOVE_PP
- ld bc, MOVE_LENGTH
- call AddNTimes
- ld a, BANK(Moves)
- call GetFarByte
- pop bc
- pop hl
-
- ld [de], a
- inc de
- dec b
- jr nz, .copy_pp
-.copied_pp
-
- pop hl
- jr .loop
-; 3991b
-
-ComputeTrainerReward: ; 3991b (e:591b)
- ld hl, hProduct
- xor a
-rept 3
- ld [hli], a
-endr
- ld a, [wEnemyTrainerBaseReward]
- ld [hli], a
- ld a, [CurPartyLevel]
- ld [hl], a
- call Multiply
- ld hl, wBattleReward
- xor a
- ld [hli], a
- ld a, [hProduct + 2]
- ld [hli], a
- ld a, [hProduct + 3]
- ld [hl], a
- ret
-
-
-Battle_GetTrainerName:: ; 39939
- ld a, [InBattleTowerBattle]
- bit 0, a
- ld hl, wd26b
- jp nz, CopyTrainerName
-
- ld a, [OtherTrainerID]
- ld b, a
- ld a, [OtherTrainerClass]
- ld c, a
-
-GetTrainerName:: ; 3994c
- ld a, c
- cp CAL
- jr nz, .not_cal2
-
- ld a, BANK(sMysteryGiftTrainerHouseFlag)
- call GetSRAMBank
- ld a, [sMysteryGiftTrainerHouseFlag]
- and a
- call CloseSRAM
- jr z, .not_cal2
-
- ld a, BANK(sMysteryGiftPartnerName)
- call GetSRAMBank
- ld hl, sMysteryGiftPartnerName
- call CopyTrainerName
- jp CloseSRAM
-
-.not_cal2
- dec c
- push bc
- ld b, 0
- ld hl, TrainerGroups
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- pop bc
-
-.loop
- dec b
- jr z, CopyTrainerName
-
-.skip
- ld a, [hli]
- cp $ff
- jr nz, .skip
- jr .loop
-
-CopyTrainerName: ; 39984
- ld de, StringBuffer1
- push de
- ld bc, NAME_LENGTH
- call CopyBytes
- pop de
- ret
-; 39990
-
-Function39990: ; 39990
-; This function is useless.
- ld de, StringBuffer1
- push de
- ld bc, NAME_LENGTH
- pop de
- ret
-; 39999
+INCLUDE "trainers/read_party.asm"
INCLUDE "trainers/trainer_pointers.asm"
INCLUDE "trainers/trainers.asm"
-
-SECTION "bankF", ROMX, BANK[$F]
+SECTION "Battle Core", ROMX, BANK[$F]
INCLUDE "battle/core.asm"
INCLUDE "battle/effect_command_pointers.asm"
-
SECTION "bank10", ROMX, BANK[$10]
-
INCLUDE "engine/pokedex.asm"
-
-Function41a7f: ; 41a7f
- xor a
- ld [hBGMapMode], a
- callba Function1de247
- call Function41af7
- call DisableLCD
- call LoadStandardFont
- call LoadFontsExtra
- call Function414b7
- call Function4147b
- ld a, [wd265]
- ld [CurPartySpecies], a
- call Function407fd
- call Function40ba0
- hlcoord 0, 17
- ld [hl], $3b
- inc hl
- ld bc, $13
- ld a, " "
- call ByteFill
- callba Function4424d
- call EnableLCD
- call WaitBGMap
- call GetBaseData
- ld de, VTiles2
- predef GetFrontpic
- ld a, $4
- call Function41423
- ld a, [CurPartySpecies]
- call PlayCry
- ret
-; 41ad7
-
-
-Function41ad7: ; 41ad7 (10:5ad7)
- ld a, $3
- ld [hBGMapMode], a
- ld c, 4
- call DelayFrames
- ret
-
-Function41ae1: ; 41ae1 (10:5ae1)
- ld a, $4
- ld [hBGMapMode], a
- ld c, 4
- call DelayFrames
- ret
-
-Function41aeb: ; 41aeb (10:5aeb)
- ld a, [hCGB]
- and a
- jr z, .asm_41af3
- call Function41ae1
-.asm_41af3
- call Function41ad7
- ret
-
-
-Function41af7: ; 41af7
- xor a
- ld [hBGMapMode], a
- ret
-; 41afb
-
-
INCLUDE "battle/moves/moves.asm"
INCLUDE "engine/evolve.asm"
@@ -14867,233 +9350,10 @@ SECTION "bank11", ROMX, BANK[$11]
INCLUDE "engine/fruit_trees.asm"
+INCLUDE "battle/ai/move.asm"
-AIChooseMove: ; 440ce
-; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
-; Pick the move with the lowest score.
-
-; Wildmons attack at random.
- ld a, [wBattleMode]
- dec a
- ret z
-
- ld a, [wLinkMode]
- and a
- ret nz
-
-; No use picking a move if there's no choice.
- callba CheckSubstatus_RechargeChargedRampageBideRollout
- ret nz
-
-
-; The default score is 20. Unusable moves are given a score of 80.
- ld a, 20
- ld hl, Buffer1
-rept 3
- ld [hli], a
-endr
- ld [hl], a
-
-; Don't pick disabled moves.
- ld a, [EnemyDisabledMove]
- and a
- jr z, .CheckPP
-
- ld hl, EnemyMonMoves
- ld c, 0
-.CheckDisabledMove
- cp [hl]
- jr z, .ScoreDisabledMove
- inc c
- inc hl
- jr .CheckDisabledMove
-.ScoreDisabledMove
- ld hl, Buffer1
- ld b, 0
- add hl, bc
- ld [hl], 80
-
-; Don't pick moves with 0 PP.
-.CheckPP
- ld hl, Buffer1 - 1
- ld de, EnemyMonPP
- ld b, 0
-.CheckMovePP
- inc b
- ld a, b
- cp EnemyMonMovesEnd - EnemyMonMoves + 1
- jr z, .ApplyLayers
- inc hl
- ld a, [de]
- inc de
- and $3f
- jr nz, .CheckMovePP
- ld [hl], 80
- jr .CheckMovePP
-
-
-; Apply AI scoring layers depending on the trainer class.
-.ApplyLayers
- ld hl, TrainerClassAttributes + 3
-
- ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner)
- ; so we have always the same AI, regardless of the loaded class of trainer
- ld a, [InBattleTowerBattle]
- bit 0, a
- jr nz, .battle_tower_skip
-
- ld a, [TrainerClass]
- dec a
- ld bc, 7 ; Trainer2AI - Trainer1AI
- call AddNTimes
-
-.battle_tower_skip
- lb bc, CHECK_FLAG, 0
- push bc
- push hl
-
-.CheckLayer
- pop hl
- pop bc
-
- ld a, c
- cp 16 ; up to 16 scoring layers
- jr z, .DecrementScores
-
- push bc
- ld d, BANK(TrainerClassAttributes)
- predef FlagPredef
- ld d, c
- pop bc
-
- inc c
- push bc
- push hl
-
- ld a, d
- and a
- jr z, .CheckLayer
-
- ld hl, AIScoringPointers
- dec c
- ld b, 0
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, BANK(AIScoring)
- call FarCall_hl
-
- jr .CheckLayer
-
-; Decrement the scores of all moves one by one until one reaches 0.
-.DecrementScores
- ld hl, Buffer1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves
-
-.DecrementNextScore
- ; If the enemy has no moves, this will infinite.
- ld a, [de]
- inc de
- and a
- jr z, .DecrementScores
-
- ; We are done whenever a score reaches 0
- dec [hl]
- jr z, .PickLowestScoreMoves
-
- ; If we just decremented the fourth move's score, go back to the first move
- inc hl
- dec c
- jr z, .DecrementScores
-
- jr .DecrementNextScore
-
-; In order to avoid bias towards the moves located first in memory, increment the scores
-; that were decremented one more time than the rest (in case there was a tie).
-; This means that the minimum score will be 1.
-.PickLowestScoreMoves
- ld a, c
-
-.move_loop
- inc [hl]
- dec hl
- inc a
- cp NUM_MOVES + 1
- jr nz, .move_loop
-
- ld hl, Buffer1
- ld de, EnemyMonMoves
- ld c, NUM_MOVES
-
-; Give a score of 0 to a blank move
-.loop2
- ld a, [de]
- and a
- jr nz, .skip_load
- ld [hl], a
-
-; Disregard the move if its score is not 1
-.skip_load
- ld a, [hl]
- dec a
- jr z, .keep
- xor a
- ld [hli], a
- jr .after_toss
-
-.keep
- ld a, [de]
- ld [hli], a
-.after_toss
- inc de
- dec c
- jr nz, .loop2
-
-; Randomly choose one of the moves with a score of 1
-.ChooseMove
- ld hl, Buffer1
- call Random
- and 3
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [hl]
- and a
- jr z, .ChooseMove
-
- ld [CurEnemyMove], a
- ld a, c
- ld [CurEnemyMoveNum], a
- ret
-; 441af
-
-
-AIScoringPointers: ; 441af
- dw AI_Basic
- dw AI_Setup
- dw AI_Types
- dw AI_Offensive
- dw AI_Smart
- dw AI_Opportunist
- dw AI_Aggressive
- dw AI_Cautious
- dw AI_Status
- dw AI_Risky
- dw AI_None
- dw AI_None
- dw AI_None
- dw AI_None
- dw AI_None
- dw AI_None
-; 441cf
-
-
-Function441cf: ; 441cf
- ld hl, Unknown_441fc
+AnimateDexSearchSlowpoke: ; 441cf
+ ld hl, .FrameIDs
ld b, 25
.loop
ld a, [hli]
@@ -15101,53 +9361,53 @@ Function441cf: ; 441cf
; Wrap around
cp $fe
jr nz, .ok
- ld hl, Unknown_441fc
+ ld hl, .FrameIDs
ld a, [hli]
.ok
- ld [wc7db], a
+ ld [wDexSearchSlowpokeFrame], a
ld a, [hli]
ld c, a
push bc
push hl
- call Function44207
+ call DoDexSearchSlowpokeFrame
pop hl
pop bc
call DelayFrames
dec b
jr nz, .loop
xor a
- ld [wc7db], a
- call Function44207
+ ld [wDexSearchSlowpokeFrame], a
+ call DoDexSearchSlowpokeFrame
ld c, 32
call DelayFrames
ret
; 441fc
-Unknown_441fc: ; 441fc
+.FrameIDs: ; 441fc
+ ; frame ID, duration
db 0, 7
db 1, 7
db 2, 7
db 3, 7
db 4, 7
- db $fe
+ db -2
; 44207
-
-Function44207: ; 44207
- ld a, [wc7db]
- ld hl, Unknown_44228
+DoDexSearchSlowpokeFrame: ; 44207
+ ld a, [wDexSearchSlowpokeFrame]
+ ld hl, .SpriteData
ld de, Sprites
-.asm_44210
+.loop
ld a, [hli]
- cp $ff
+ cp -1
ret z
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
- ld a, [wc7db]
+ ld a, [wDexSearchSlowpokeFrame]
ld b, a
add a
add b
@@ -15158,50 +9418,53 @@ Function44207: ; 44207
ld a, [hli]
ld [de], a
inc de
- jr .asm_44210
+ jr .loop
; 44228
-Unknown_44228: ; 44228
- db $58, $48, $00, $00
- db $58, $50, $01, $00
- db $58, $58, $02, $00
- db $60, $48, $10, $00
- db $60, $50, $11, $00
- db $60, $58, $12, $00
- db $68, $48, $20, $00
- db $68, $50, $21, $00
- db $68, $58, $22, $00
- db $ff
+.SpriteData: ; 44228
+ dsprite 11, 0, 9, 0, $00, $00
+ dsprite 11, 0, 10, 0, $01, $00
+ dsprite 11, 0, 11, 0, $02, $00
+ dsprite 12, 0, 9, 0, $10, $00
+ dsprite 12, 0, 10, 0, $11, $00
+ dsprite 12, 0, 11, 0, $12, $00
+ dsprite 13, 0, 9, 0, $20, $00
+ dsprite 13, 0, 10, 0, $21, $00
+ dsprite 13, 0, 11, 0, $22, $00
+ db -1
; 4424d
-Function4424d: ; 4424d
+DisplayDexEntry: ; 4424d
call GetPokemonName
hlcoord 9, 3
- call PlaceString
+ call PlaceString ; mon species
ld a, [wd265]
ld b, a
- call Function44333
+ call GetDexEntryPointer
ld a, b
push af
hlcoord 9, 5
- call FarString
+ call FarString ; dex species
ld h, b
ld l, c
push de
+; Print dex number
hlcoord 2, 8
- ld a, $5c
+ ld a, $5c ; No
ld [hli], a
- ld a, $5d
+ ld a, $5d ; .
ld [hli], a
ld de, wd265
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
+; Check to see if we caught it. Get out of here if we haven't.
ld a, [wd265]
dec a
call CheckCaughtMon
pop hl
pop bc
ret z
+; Get the height of the Pokemon.
ld a, [CurPartySpecies]
ld [CurSpecies], a
inc hl
@@ -15217,7 +9480,7 @@ rept 2
endr
ld a, d
or e
- jr z, .asm_442b0
+ jr z, .skip_height
push hl
push de
ld hl, [sp+$0]
@@ -15227,11 +9490,11 @@ endr
lb bc, 2, 36
call PrintNum
hlcoord 14, 7
- ld [hl], "<ROCKET>"
+ ld [hl], $5e ; ft symbol
pop af
pop hl
-.asm_442b0
+.skip_height
pop af
push af
inc hl
@@ -15242,32 +9505,34 @@ endr
ld e, h
ld a, e
or d
- jr z, .skip
+ jr z, .skip_weight
push de
ld hl, [sp+$0]
ld d, h
ld e, l
hlcoord 11, 9
- lb bc, 2, 69
+ lb bc, 2, PRINTNUM_RIGHTALIGN | 5
call PrintNum
pop de
-.skip
+.skip_weight
+; Page 1
lb bc, 5, SCREEN_WIDTH - 2
hlcoord 2, 11
call ClearBox
hlcoord 1, 10
- ld bc, $13
- ld a, $61
+ ld bc, SCREEN_WIDTH - 1
+ ld a, $61 ; horizontal divider
call ByteFill
+ ; page number
hlcoord 1, 9
- ld [hl], "<CONT>"
+ ld [hl], $55
inc hl
- ld [hl], "<CONT>"
+ ld [hl], $55
hlcoord 1, 10
- ld [hl], "<......>"
+ ld [hl], $56 ; P.
inc hl
- ld [hl], "<DONE>"
+ ld [hl], $57 ; 1
pop de
inc de
pop af
@@ -15278,23 +9543,26 @@ endr
ld a, [wPokedexStatus]
or a
ret z
+
+; Page 2
push bc
push de
lb bc, 5, SCREEN_WIDTH - 2
hlcoord 2, 11
call ClearBox
hlcoord 1, 10
- ld bc, $13
+ ld bc, SCREEN_WIDTH - 1
ld a, $61
call ByteFill
+ ; page number
hlcoord 1, 9
- ld [hl], "<CONT>"
+ ld [hl], $55
inc hl
- ld [hl], "<CONT>"
+ ld [hl], $55
hlcoord 1, 10
- ld [hl], "<......>"
+ ld [hl], $56 ; P.
inc hl
- ld [hl], "<PROMPT>"
+ ld [hl], $58 ; 2
pop de
inc de
pop af
@@ -15307,7 +9575,8 @@ String_44331: ; 44331
db "#@"
; 44333
-Function44333: ; 44333
+GetDexEntryPointer: ; 44333
+; return dex entry pointer b:de
push hl
ld hl, PokedexDataPointerTable
ld a, b
@@ -15324,7 +9593,7 @@ endr
rlca
rlca
and $3
- ld hl, PokedexEntryBanks
+ ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
@@ -15334,7 +9603,7 @@ endr
ret
; 44351
-PokedexEntryBanks: ; 44351
+.PokedexEntryBanks: ; 44351
GLOBAL PokedexEntries1
GLOBAL PokedexEntries2
@@ -15347,22 +9616,26 @@ GLOBAL PokedexEntries4
db BANK(PokedexEntries4)
; 44355
-Function44355: ; 44355
- call Function44333
+GetDexEntryPagePointer: ; 44355
+ call GetDexEntryPointer ; b:de
push hl
ld h, d
ld l, e
+; skip species name
.loop1
ld a, b
call GetFarByte
inc hl
cp "@"
jr nz, .loop1
+; skip height and weight
rept 4
inc hl
endr
+; if c != 1: skip entry
dec c
jr z, .done
+; skip entry
.loop2
ld a, b
call GetFarByte
@@ -15377,130 +9650,14 @@ endr
ret
; 44378
-
PokedexDataPointerTable: ; 0x44378
INCLUDE "data/pokedex/entry_pointers.asm"
INCLUDE "engine/mail.asm"
-SECTION "bank12", ROMX, BANK[$12]
-
-Function48000: ; 48000
- ld a, $1
- ld [wd474], a
- xor a
- ld [wd473], a
- ld [PlayerGender], a
- ld [wd475], a
- ld [wd476], a
- ld [wd477], a
- ld [wd478], a
- ld [wd002], a
- ld [wd003], a
- ; could have done "ld a, [wd479] \ and %11111100", saved four operations
- ld a, [wd479]
- res 0, a
- ld [wd479], a
- ld a, [wd479]
- res 1, a
- ld [wd479], a
- ret
-; 4802f
-
-INCLUDE "misc/mobile_12.asm"
-
-InitGender: ; 48dcb (12:4dcb)
- call Function48e14
- call Function48e47
- call Function48e64
- call Function3200
- call SetPalettes
- ld hl, TextJump_AreYouABoyOrAreYouAGirl
- call PrintText
- ld hl, .MenuDataHeader
- call LoadMenuDataHeader
- call Function3200
- call InterpretMenu2
- call WriteBackup
- ld a, [MenuSelection2]
- dec a
- ld [PlayerGender], a
- ld c, 10
- call DelayFrames
- ret
-; 48dfc (12:4dfc)
-
-.MenuDataHeader: ; 0x48dfc
- db $40 ; flags
- db 04, 06 ; start coords
- db 09, 12 ; end coords
- dw .MenuData2
- db 1 ; default option
-; 0x48e04
-
-.MenuData2: ; 0x48e04
- db $a1 ; flags
- db 2 ; items
- db "Boy@"
- db "Girl@"
-; 0x48e0f
-
-TextJump_AreYouABoyOrAreYouAGirl: ; 0x48e0f
- ; Are you a boy? Or are you a girl?
- text_jump Text_AreYouABoyOrAreYouAGirl
- db "@"
-; 0x48e14
-
-Function48e14: ; 48e14 (12:4e14)
- ld a, $10
- ld [MusicFade], a
- ld a, $0
- ld [MusicFadeIDLo], a
- ld a, $0
- ld [MusicFadeIDHi], a
- ld c, 8
- call DelayFrames
- call ClearBGPalettes
- call Function48000
- call LoadFontsExtra
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- ld a, $0
- call ByteFill
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- xor a
- call ByteFill
- ret
-
-Function48e47: ; 48e47 (12:4e47)
- ld hl, Palette_48e5c
- ld de, UnknBGPals
- ld bc, $8
- ld a, $5
- call FarCopyWRAM
- callba Function96a4
- ret
-; 48e5c (12:4e5c)
-
-Palette_48e5c: ; 48e5c
- RGB 31, 31, 31
- RGB 09, 30, 31
- RGB 01, 11, 31
- RGB 00, 00, 00
-; 48e64
-
-Function48e64: ; 48e64 (12:4e64)
- ld de, GFX_48e71
- ld hl, VTiles2 tile $00
- lb bc, BANK(GFX_48e71), 1
- call Get2bpp
- ret
-; 48e71 (12:4e71)
-
-GFX_48e71: ; 48e71
-INCBIN "gfx/unknown/048e71.2bpp"
+SECTION "Crystal Unique", ROMX, BANK[$12]
+INCLUDE "engine/init_gender.asm"
DrawKrisPackGFX: ; 48e81
ld hl, PackFGFXPointers
@@ -15517,10 +9674,10 @@ endr
; 48e93
PackFGFXPointers: ; 48e93
- dw PackFGFX + $f0 * 1
- dw PackFGFX + $f0 * 3
- dw PackFGFX + $f0 * 0
- dw PackFGFX + $f0 * 2
+ dw PackFGFX + (15 tiles) * 1
+ dw PackFGFX + (15 tiles) * 3
+ dw PackFGFX + (15 tiles) * 0
+ dw PackFGFX + (15 tiles) * 2
; 48e9b
PackFGFX: ; 48e9b
@@ -15532,59 +9689,57 @@ Special_MoveTutor: ; 4925b
call ClearBGPalettes
call ClearScreen
call DelayFrame
- ld b, SCGB_14
+ ld b, SCGB_PACKPALS
call GetSGBLayout
xor a
ld [wItemAttributeParamBuffer], a
- call Function492a5
+ call .GetMoveTutorMove
ld [wd265], a
- ld [wd262], a
+ ld [wPutativeTMHMMove], a
call GetMoveName
call CopyName1
- callba Function2c7fb
- jr c, .asm_4929c
- jr .asm_49291
-
-.asm_49289
- callba Function2c80a
- jr c, .asm_4929c
+ callba ChooseMonToLearnTMHM
+ jr c, .cancel
+ jr .enter_loop
-.asm_49291
- call Function492b9
- jr nc, .asm_49289
+.loop
+ callba ChooseMonToLearnTMHM_NoRefresh
+ jr c, .cancel
+.enter_loop
+ call CheckCanLearnMoveTutorMove
+ jr nc, .loop
xor a
ld [ScriptVar], a
- jr .asm_492a1
+ jr .quit
-.asm_4929c
- ld a, $ff
+.cancel
+ ld a, -1
ld [ScriptVar], a
-
-.asm_492a1
- call ReturnToCallingMenu
+.quit
+ call CloseSubmenu
ret
; 492a5
-Function492a5: ; 492a5
+.GetMoveTutorMove: ; 492a5
ld a, [ScriptVar]
- cp $1
- jr z, .asm_492b3
- cp $2
- jr z, .asm_492b6
+ cp 1
+ jr z, .flamethrower
+ cp 2
+ jr z, .thunderbolt
ld a, ICE_BEAM
ret
-.asm_492b3
+.flamethrower
ld a, FLAMETHROWER
ret
-.asm_492b6
+.thunderbolt
ld a, THUNDERBOLT
ret
; 492b9
-Function492b9: ; 492b9
- ld hl, MenuDataHeader_0x4930a
+CheckCanLearnMoveTutorMove: ; 492b9
+ ld hl, .MenuDataHeader
call LoadMenuDataHeader
predef CanLearnTMHMMove
@@ -15602,12 +9757,12 @@ Function492b9: ; 492b9
ld de, SFX_WRONG
call PlaySFX
pop de
- ld a, BANK(UnknownText_0x2c8ce)
- ld hl, UnknownText_0x2c8ce
+ ld a, BANK(Text_TMHMNotCompatible)
+ ld hl, Text_TMHMNotCompatible
call FarPrintText
jr .didnt_learn
-.can_learn
+.can_learn
callab KnowsMove
jr c, .didnt_learn
@@ -15631,627 +9786,13 @@ Function492b9: ; 492b9
ret
; 4930a
-MenuDataHeader_0x4930a: ; 0x4930a
+.MenuDataHeader: ; 0x4930a
db $40 ; flags
db 12, 00 ; start coords
db 17, 19 ; end coords
; 4930f
-Function4930f: ; 4930f (mobile)
- ld a, b
- cp SCGB_RAM
- jr nz, .not_ram
- ld a, [SGBPredef]
-.not_ram
- push af
- callba Function9673
- pop af
- ld l, a
- ld h, 0
- add hl, hl
- ld de, .jumptable
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, .done
- push de
- jp [hl]
-.done
- ret
-; 49330 (12:5330)
-
-.jumptable: ; 49330
- dw Function4936e
- dw Function4942f
- dw Function49706
-; 49336
-
-Function49336: ; 49336
-.asm_49336
- push bc
- push hl
-.asm_49338
- ld [hli], a
- dec c
- jr nz, .asm_49338
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .asm_49336
- ret
-; 49346
-
-
-Function49346: ; 49346 (12:5346)
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- xor a
- call ByteFill
- ret
-
-Function49351: ; 49351 (12:5351)
- ld de, UnknBGPals
- ld hl, Palette_493e1
- ld bc, $28
- ld a, $5 ; BANK(UnknBGPals)
- call FarCopyWRAM
- ld de, UnknBGPals + $38
- ld hl, Palette_49418
- ld bc, $8
- ld a, $5 ; BANK(UnknBGPals)
- call FarCopyWRAM
- ret
-
-Function4936e: ; 4936e (12:536e)
- call Function49351
- call Function49346
- call Function49384
- callba Function96b3
- callba Function96a4
- ret
-
-Function49384: ; 49384 (12:5384)
- hlcoord 0, 0, AttrMap
- lb bc, 4, 1
- ld a, $1
- call Function49336
- lb bc, 2, 1
- ld a, $2
- call Function49336
- lb bc, 6, 1
- ld a, $3
- call Function49336
- hlcoord 1, 0, AttrMap
- ld a, $1
- lb bc, 3, 18
- call Function49336
- lb bc, 2, 18
- ld a, $2
- call Function49336
- lb bc, 12, 18
- ld a, $3
- call Function49336
- hlcoord 19, 0, AttrMap
- lb bc, 4, 1
- ld a, $1
- call Function49336
- lb bc, 2, 1
- ld a, $2
- call Function49336
- lb bc, 6, 1
- ld a, $3
- call Function49336
- hlcoord 0, 12, AttrMap
- ld bc, 6 * SCREEN_WIDTH
- ld a, $7
- call ByteFill
- ret
-; 493e1 (12:53e1)
-
-Palette_493e1: ; 493e1
- RGB 03, 07, 09
- RGB 26, 31, 00
- RGB 20, 16, 03
- RGB 31, 31, 31
-
- RGB 13, 24, 29
- RGB 11, 16, 30
- RGB 07, 11, 22
- RGB 05, 06, 18
-
- RGB 31, 31, 31
- RGB 20, 26, 31
- RGB 13, 24, 29
- RGB 11, 16, 30
-
- RGB 31, 31, 31
- RGB 20, 26, 31
- RGB 00, 00, 00
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 20, 16, 08
- RGB 31, 00, 00
- RGB 00, 00, 00
-; 49409
-
-
-Function49409:: ; 49409
- ld hl, Palette_49418
- ld de, UnknBGPals + 8 * 7
- ld bc, 8
- ld a, $5
- call FarCopyWRAM
- ret
-; 49418
-
-Palette_49418: ; 49418
- RGB 31, 31, 31
- RGB 08, 19, 28
- RGB 05, 05, 16
- RGB 00, 00, 00
-; 49420
-
-Function49420:: ; 49420 (12:5420)
- ld hl, MansionPalette4
- ld de, UnknBGPals + $30
- ld bc, $8
- ld a, $5 ; BANK(UnknBGPals)
- call FarCopyWRAM
- ret
-; 4942f (12:542f)
-
-Function4942f: ; 4942f
- call Function49351
- ld de, UnknBGPals + $38
- ld hl, Palette_49478
- ld bc, $8
- ld a, $5 ; BANK(UnknBGPals)
- call FarCopyWRAM
- call Function49346
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- xor a
- call ByteFill
- hlcoord 0, 14, AttrMap
- ld bc, 4 * SCREEN_WIDTH
- ld a, $7
- call ByteFill
- ld a, [wd002]
- bit 6, a
- jr z, .asm_49464
- call Function49480
- jr .asm_49467
-
-.asm_49464
- call Function49496
-
-.asm_49467
- callba Function96b3
- callba Function96a4
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; 49478
-
-Palette_49478: ; 49478
- RGB 31, 31, 31
- RGB 26, 31, 00
- RGB 20, 16, 03
- RGB 00, 00, 00
-; 49480
-
-Function49480: ; 49480
- hlcoord 0, 0, AttrMap
- lb bc, 4, SCREEN_WIDTH
- ld a, $7
- call Function49336
- hlcoord 0, 2, AttrMap
- ld a, $4
- ld [hl], a
- hlcoord 19, 2, AttrMap
- ld [hl], a
- ret
-; 49496
-
-Function49496: ; 49496
- hlcoord 0, 0, AttrMap
- lb bc, 2, SCREEN_WIDTH
- ld a, $7
- call Function49336
- hlcoord 0, 1, AttrMap
- ld a, $4
- ld [hl], a
- hlcoord 19, 1, AttrMap
- ld [hl], a
- ret
-; 494ac
-
-LoadSpecialMapPalette: ; 494ac
- ld a, [wTileset]
- cp TILESET_POKECOM_CENTER
- jr z, .pokecom_2f
- cp TILESET_BATTLE_TOWER
- jr z, .battle_tower
- cp TILESET_ICE_PATH
- jr z, .ice_path
- cp TILESET_HOUSE_1
- jr z, .house
- cp TILESET_RADIO_TOWER
- jr z, .radio_tower
- cp TILESET_CELADON_MANSION
- jr z, .mansion_mobile
- jr .do_nothing
-
-.pokecom_2f
- call LoadPokeComPalette
- scf
- ret
-
-.battle_tower
- call LoadBattleTowerPalette
- scf
- ret
-
-.ice_path
- ld a, [wPermission] ; permission
- and 7
- cp 3 ; Hall of Fame
- jr z, .do_nothing
- call LoadIcePathPalette
- scf
- ret
-
-.house
- call LoadHousePalette
- scf
- ret
-
-.radio_tower
- call LoadRadioTowerPalette
- scf
- ret
-
-.mansion_mobile
- call LoadMansionPalette
- scf
- ret
-
-.do_nothing
- and a
- ret
-; 494f2
-
-LoadPokeComPalette: ; 494f2
- ld a, $5
- ld de, UnknBGPals
- ld hl, PokeComPalette
- ld bc, 8 palettes
- call FarCopyWRAM
- ret
-; 49501
-
-PokeComPalette: ; 49501
-INCLUDE "tilesets/pokecom.pal"
-; 49541
-
-LoadBattleTowerPalette: ; 49541
- ld a, $5
- ld de, UnknBGPals
- ld hl, BattleTowerPalette
- ld bc, 8 palettes
- call FarCopyWRAM
- ret
-; 49550
-
-BattleTowerPalette: ; 49550
-INCLUDE "tilesets/battle_tower.pal"
-; 49590
-
-LoadIcePathPalette: ; 49590
- ld a, $5
- ld de, UnknBGPals
- ld hl, IcePathPalette
- ld bc, 8 palettes
- call FarCopyWRAM
- ret
-; 4959f
-
-IcePathPalette: ; 4959f
-INCLUDE "tilesets/ice_path.pal"
-; 495df
-
-LoadHousePalette: ; 495df
- ld a, $5
- ld de, UnknBGPals
- ld hl, HousePalette
- ld bc, 8 palettes
- call FarCopyWRAM
- ret
-; 495ee
-
-HousePalette: ; 495ee
-INCLUDE "tilesets/house.pal"
-; 4962e
-
-LoadRadioTowerPalette: ; 4962e
- ld a, $5
- ld de, UnknBGPals
- ld hl, RadioTowerPalette
- ld bc, 8 palettes
- call FarCopyWRAM
- ret
-; 4963d
-
-RadioTowerPalette: ; 4963d
-INCLUDE "tilesets/radio_tower.pal"
-; 4967d
-
-MansionPalette1: ; 4967d
- RGB 30, 28, 26
- RGB 19, 19, 19
- RGB 13, 13, 13
- RGB 07, 07, 07
-
- RGB 30, 28, 26
- RGB 31, 19, 24
- RGB 30, 10, 06
- RGB 07, 07, 07
-
- RGB 18, 24, 09
- RGB 15, 20, 01
- RGB 09, 13, 00
- RGB 07, 07, 07
-
- RGB 30, 28, 26
- RGB 15, 16, 31
- RGB 09, 09, 31
- RGB 07, 07, 07
-
- RGB 30, 28, 26
- RGB 31, 31, 07
- RGB 31, 16, 01
- RGB 07, 07, 07
-
- RGB 26, 24, 17
- RGB 21, 17, 07
- RGB 16, 13, 03
- RGB 07, 07, 07
-
-MansionPalette3: ; 496ad
- RGB 30, 28, 26
- RGB 17, 19, 31
- RGB 14, 16, 31
- RGB 07, 07, 07
-
- RGB 31, 31, 16
- RGB 31, 31, 16
- RGB 14, 09, 00
- RGB 00, 00, 00
-; 496bd
-
-MansionPalette4: ; 496bd
- RGB 05, 05, 16
- RGB 08, 19, 28
- RGB 00, 00, 00
- RGB 31, 31, 31
-; 496c5
-
-LoadMansionPalette: ; 496c5
- ld a, $5
- ld de, UnknBGPals
- ld hl, MansionPalette1
- ld bc, 8 palettes
- call FarCopyWRAM
- ld a, $5
- ld de, UnknBGPals + 4 palettes
- ld hl, MansionPalette2
- ld bc, 1 palettes
- call FarCopyWRAM
- ld a, $5
- ld de, UnknBGPals + 3 palettes
- ld hl, MansionPalette3
- ld bc, 1 palettes
- call FarCopyWRAM
- ld a, $5
- ld de, UnknBGPals + 6 palettes
- ld hl, MansionPalette4
- ld bc, 1 palettes
- call FarCopyWRAM
- ret
-; 496fe
-
-MansionPalette2: ; 496fe
- RGB 25, 24, 23
- RGB 20, 19, 19
- RGB 14, 16, 31
- RGB 07, 07, 07
-; 49706
-
-Function49706: ; 49706
- ld hl, Palette_49732
- ld de, UnknBGPals
- ld bc, 1 palettes
- ld a, $5
- call FarCopyWRAM
- callba Function96a4
- call Function49346
- callba Function96b3
- ld hl, Palette_4973a
- ld de, UnknOBPals
- ld bc, 1 palettes
- ld a, $5
- call FarCopyWRAM
- ret
-; 49732
-
-Palette_49732: ; 49732
- RGB 31, 31, 31
- RGB 23, 16, 07
- RGB 23, 07, 07
- RGB 03, 07, 20
-; 4973a
-
-Palette_4973a: ; 4973a
- RGB 00, 00, 00
- RGB 07, 05, 31
- RGB 14, 18, 31
- RGB 31, 31, 31
-; 49742
-
-Function49742: ; 49742
- ld hl, Palette_49757
- ld de, UnknBGPals
- ld bc, $40
- ld a, $5
- call FarCopyWRAM
- callba Function96a4
- ret
-; 49757
-
-Palette_49757: ; 49757
- RGB 31, 31, 63
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-
- RGB 31, 31, 63
- RGB 00, 00, 00
- RGB 00, 00, 00
- RGB 00, 00, 00
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 31, 00, 00
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 30, 16, 26
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 16, 16, 16
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 31, 12, 12
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 07, 08, 31
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 21, 00, 21
- RGB 29, 28, 09
- RGB 31, 31, 31
-; 49797
-
-Function49797: ; 49797
- hlcoord 0, 0, AttrMap
- lb bc, 16, 2
- ld a, $4
- call Function49336
- ld a, $3
- ldcoord_a 0, 1, AttrMap
- ldcoord_a 0, 14, AttrMap
- hlcoord 2, 0, AttrMap
- lb bc, 8, 18
- ld a, $5
- call Function49336
- hlcoord 2, 8, AttrMap
- lb bc, 8, 18
- ld a, $6
- call Function49336
- hlcoord 0, 16, AttrMap
- lb bc, 2, SCREEN_WIDTH
- ld a, $4
- call Function49336
- ld a, $3
- lb bc, 6, 1
- hlcoord 6, 1, AttrMap
- call Function49336
- ld a, $3
- lb bc, 6, 1
- hlcoord 17, 1, AttrMap
- call Function49336
- ld a, $3
- lb bc, 6, 1
- hlcoord 6, 9, AttrMap
- call Function49336
- ld a, $3
- lb bc, 6, 1
- hlcoord 17, 9, AttrMap
- call Function49336
- ld a, $2
- hlcoord 2, 16, AttrMap
- ld [hli], a
- ld a, $7
-rept 3
- ld [hli], a
-endr
- ld a, $2
- ld [hl], a
- hlcoord 2, 17, AttrMap
- ld a, $3
- ld bc, 6
- call ByteFill
- ret
-; 49811
-
-Function49811: ; 49811
- ld hl, Palette_49826
- ld de, UnknBGPals + $10
- ld bc, $30
- ld a, $5
- call FarCopyWRAM
- callba Function96a4
- ret
-; 49826
-
-Palette_49826: ; 49826
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 31, 00, 00
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 15, 23, 30
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 16, 16, 16
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 25, 07, 04
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 03, 22, 08
- RGB 31, 31, 31
-
- RGB 04, 02, 15
- RGB 07, 09, 31
- RGB 29, 28, 09
- RGB 31, 31, 31
-; 49856
-
-Function49856: ; 49856
- call Function49797
- ret
-; 4985a
+INCLUDE "predef/crystal.asm"
Unknown_4985a: ; unreferenced
db $ab, $03, $57, $24, $ac, $0e, $13, $32
@@ -16265,1223 +9806,10 @@ Unknown_4985a: ; unreferenced
INCLUDE "event/celebi.asm"
INCLUDE "engine/main_menu.asm"
-
-SpecialBeastsCheck: ; 0x4a6e8
-; Check if the player owns all three legendary beasts.
-; They must exist in either party or PC, and have the player's OT and ID.
-; Return the result in ScriptVar.
-
- ld a, RAIKOU
- ld [ScriptVar], a
- call CheckOwnMonAnywhere
- jr nc, .notexist
-
- ld a, ENTEI
- ld [ScriptVar], a
- call CheckOwnMonAnywhere
- jr nc, .notexist
-
- ld a, SUICUNE
- ld [ScriptVar], a
- call CheckOwnMonAnywhere
- jr nc, .notexist
-
- ; they exist
- ld a, 1
- ld [ScriptVar], a
- ret
-
-.notexist
- xor a
- ld [ScriptVar], a
- ret
-
-
-SpecialMonCheck: ; 0x4a711
-; Check if the player owns any monsters of the species in ScriptVar.
-; Return the result in ScriptVar.
-
- call CheckOwnMonAnywhere
- jr c, .exists
-
- ; doesn't exist
- xor a
- ld [ScriptVar], a
- ret
-
-.exists
- ld a, 1
- ld [ScriptVar], a
- ret
-
-
-CheckOwnMonAnywhere: ; 0x4a721
-; Check if the player owns any monsters of the species in ScriptVar.
-; It must exist in either party or PC, and have the player's OT and ID.
-
- ; If there are no monsters in the party,
- ; the player must not own any yet.
- ld a, [PartyCount]
- and a
- ret z
-
- ld d, a
- ld e, 0
- ld hl, PartyMon1Species
- ld bc, PartyMonOT
-
- ; Run CheckOwnMon on each Pokémon in the party.
-.partymon
- call CheckOwnMon
- ret c ; found!
-
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call UpdateOTPointer
- dec d
- jr nz, .partymon
-
- ; Run CheckOwnMon on each Pokémon in the PC.
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld a, [sBoxCount]
- and a
- jr z, .boxes
-
- ld d, a
- ld hl, sBoxMon1Species
- ld bc, sBoxMonOT
-.openboxmon
- call CheckOwnMon
- jr nc, .loop
-
- ; found!
- call CloseSRAM
- ret
-
-.loop
- push bc
- ld bc, BOXMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call UpdateOTPointer
- dec d
- jr nz, .openboxmon
-
- ; Run CheckOwnMon on each monster in the other 13 PC boxes.
-.boxes
- call CloseSRAM
-
- ld c, 0
-.box
- ; Don't search the current box again.
- ld a, [wCurBox]
- and $f
- cp c
- jr z, .loopbox
-
- ; Load the box.
- ld hl, BoxAddressTable1
- ld b, 0
-rept 3
- add hl, bc
-endr
- ld a, [hli]
- call GetSRAMBank
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- ; Number of monsters in the box
- ld a, [hl]
- and a
- jr z, .loopbox
-
- push bc
-
- push hl
- ld de, sBoxMons - sBoxCount
- add hl, de
- ld d, h
- ld e, l
- pop hl
- push de
- ld de, sBoxMonOT - sBoxCount
- add hl, de
- ld b, h
- ld c, l
- pop hl
-
- ld d, a
-
-.boxmon
- call CheckOwnMon
- jr nc, .loopboxmon
-
- ; found!
- pop bc
- call CloseSRAM
- ret
-
-.loopboxmon
- push bc
- ld bc, BOXMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call UpdateOTPointer
- dec d
- jr nz, .boxmon
- pop bc
-
-.loopbox
- inc c
- ld a, c
- cp NUM_BOXES
- jr c, .box
-
- ; not found
- call CloseSRAM
- and a
- ret
-
-
-CheckOwnMon: ; 0x4a7ba
-; Check if a Pokémon belongs to the player and is of a specific species.
-
-; inputs:
-; hl, pointer to PartyMonNSpecies
-; bc, pointer to PartyMonNOT
-; ScriptVar should contain the species we're looking for
-
-; outputs:
-; sets carry if monster matches species, ID, and OT name.
-
- push bc
- push hl
- push de
- ld d, b
- ld e, c
-
-; check species
- ld a, [ScriptVar] ; species we're looking for
- ld b, [hl] ; species we have
- cp b
- jr nz, .notfound ; species doesn't match
-
-; check ID number
- ld bc, MON_ID
- add hl, bc ; now hl points to ID number
- ld a, [PlayerID]
- cp [hl]
- jr nz, .notfound ; ID doesn't match
- inc hl
- ld a, [PlayerID + 1]
- cp [hl]
- jr nz, .notfound ; ID doesn't match
-
-; check OT
-; This only checks five characters, which is fine for the Japanese version,
-; but in the English version the player name is 7 characters, so this is wrong.
-
- ld hl, PlayerName
-
- rept 4
- ld a, [de]
- cp [hl]
- jr nz, .notfound
- cp "@"
- jr z, .found ; reached end of string
- inc hl
- inc de
- endr
-
- ld a, [de]
- cp [hl]
- jr z, .found
-
-.notfound
- pop de
- pop hl
- pop bc
- and a
- ret
-
-.found
- pop de
- pop hl
- pop bc
- scf
- ret
-; 0x4a810
-
-BoxAddressTable1: ; 4a810
- dba sBox1
- dba sBox2
- dba sBox3
- dba sBox4
- dba sBox5
- dba sBox6
- dba sBox7
- dba sBox8
- dba sBox9
- dba sBox10
- dba sBox11
- dba sBox12
- dba sBox13
- dba sBox14
-; 4a83a
-
-UpdateOTPointer: ; 0x4a83a
- push hl
- ld hl, NAME_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- pop hl
- ret
-; 0x4a843
-
-
-MobileCheckOwnMonAnywhere: ; 4a843
-; Like CheckOwnMonAnywhere, but only check for species.
-; OT/ID don't matter.
-
- ld a, [PartyCount]
- and a
- ret z
-
- ld d, a
- ld e, 0
- ld hl, PartyMon1Species
- ld bc, PartyMonOT
-.asm_4a851
- call Function4a8dc
- ret c
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call Function4a91e
- dec d
- jr nz, .asm_4a851
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld a, [sBoxCount]
- and a
- jr z, .asm_4a888
- ld d, a
- ld hl, sBoxMon1Species
- ld bc, sBoxMonOT
-.asm_4a873
- call Function4a8dc
- jr nc, .asm_4a87c
- call CloseSRAM
- ret
-
-.asm_4a87c
- push bc
- ld bc, BOXMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call Function4a91e
- dec d
- jr nz, .asm_4a873
-
-.asm_4a888
- call CloseSRAM
- ld c, 0
-.asm_4a88d
- ld a, [wCurBox]
- and $f
- cp c
- jr z, .asm_4a8d1
- ld hl, BoxAddressTable2
- ld b, 0
-rept 3
- add hl, bc
-endr
- ld a, [hli]
- call GetSRAMBank
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [hl]
- and a
- jr z, .asm_4a8d1
- push bc
- push hl
- ld de, sBoxMons - sBoxCount
- add hl, de
- ld d, h
- ld e, l
- pop hl
- push de
- ld de, sBoxMonOT - sBoxCount
- add hl, de
- ld b, h
- ld c, l
- pop hl
- ld d, a
-.asm_4a8ba
- call Function4a8dc
- jr nc, .asm_4a8c4
- pop bc
- call CloseSRAM
- ret
-
-.asm_4a8c4
- push bc
- ld bc, BOXMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- call Function4a91e
- dec d
- jr nz, .asm_4a8ba
- pop bc
-
-.asm_4a8d1
- inc c
- ld a, c
- cp NUM_BOXES
- jr c, .asm_4a88d
- call CloseSRAM
- and a
- ret
-; 4a8dc
-
-Function4a8dc: ; 4a8dc
- push bc
- push hl
- push de
- ld d, b
- ld e, c
- ld a, [ScriptVar]
- ld b, [hl]
- cp b
- jr nz, .no_match
- jr .match
-
-.no_match
- pop de
- pop hl
- pop bc
- and a
- ret
-
-.match
- pop de
- pop hl
- pop bc
- scf
- ret
-; 4a8f4
-
-BoxAddressTable2: ; 4a8f4
- dba sBox1
- dba sBox2
- dba sBox3
- dba sBox4
- dba sBox5
- dba sBox6
- dba sBox7
- dba sBox8
- dba sBox9
- dba sBox10
- dba sBox11
- dba sBox12
- dba sBox13
- dba sBox14
-; 4a91e
-
-Function4a91e: ; 4a91e
- push hl
- ld hl, NAME_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- pop hl
- ret
-; 4a927
-
-
-FindItemInPCOrBag: ; 4a927
- ld a, [ScriptVar]
- ld [CurItem], a
- ld hl, PCItems
- call CheckItem
- jr c, .found
-
- ld a, [ScriptVar]
- ld [CurItem], a
- ld hl, NumItems
- call CheckItem
- jr c, .found
-
- xor a
- ld [ScriptVar], a
- ret
-
-.found
- ld a, 1
- ld [ScriptVar], a
- ret
-; 4a94e
-
-Function4a94e: ; 4a94e
- call FadeToMenu
- ld a, -1
- ld hl, wd002
- ld bc, 3
- call ByteFill
- xor a
- ld [wd018], a
- ld [wd019], a
- ld b, SCGB_14
- call GetSGBLayout
- call SetPalettes
- call Function4aa22
- jr c, .asm_4a985
- jr z, .asm_4a9a1
- jr .asm_4a97b
-
-.asm_4a974
- call Function4aa25
- jr c, .asm_4a985
- jr z, .asm_4a9a1
-
-.asm_4a97b
- call Function4ac58
- ld hl, wd019
- res 1, [hl]
- jr .asm_4a974
-
-.asm_4a985
- ld a, [wd018]
- and a
- jr nz, .asm_4a990
- call Function4aba8
- jr c, .asm_4a974
-
-.asm_4a990
- call ReturnToCallingMenu
- ld hl, wd002
- ld a, -1
- ld bc, 3
- call ByteFill
- scf
- jr .asm_4a9af
-
-.asm_4a9a1
- call Function4a9c3
- jr c, .asm_4a9b0
- call Function4a9d7
- jr c, .asm_4a974
- call ReturnToCallingMenu
- and a
-
-.asm_4a9af
- ret
-
-.asm_4a9b0
- ld de, SFX_WRONG
- call PlaySFX
- ld hl, UnknownText_0x4a9be
- call PrintText
- jr .asm_4a974
-; 4a9be
-
-UnknownText_0x4a9be: ; 0x4a9be
- ; Pick three #MON for battle.
- text_jump UnknownText_0x1c51d7
- db "@"
-; 0x4a9c3
-
-Function4a9c3: ; 4a9c3
- ld hl, wd002
- ld a, $ff
- cp [hl]
- jr z, .asm_4a9d5
- inc hl
- cp [hl]
- jr z, .asm_4a9d5
- inc hl
- cp [hl]
- jr z, .asm_4a9d5
- and a
- ret
-
-.asm_4a9d5
- scf
- ret
-; 4a9d7
-
-Function4a9d7: ; 4a9d7
- ld a, [wd002]
- ld hl, PartyMonNicknames
- call GetNick
- ld h, d
- ld l, e
- ld de, EndFlypoint
- ld bc, 6
- call CopyBytes
- ld a, [wd003]
- ld hl, PartyMonNicknames
- call GetNick
- ld h, d
- ld l, e
- ld de, wd00c
- ld bc, 6
- call CopyBytes
- ld a, [wd004]
- ld hl, PartyMonNicknames
- call GetNick
- ld h, d
- ld l, e
- ld de, wd012
- ld bc, 6
- call CopyBytes
- ld hl, UnknownText_0x4aa1d
- call PrintText
- call YesNoBox
- ret
-; 4aa1d
-
-UnknownText_0x4aa1d: ; 0x4aa1d
- ; , @ and @ . Use these three?
- text_jump UnknownText_0x1c51f4
- db "@"
-; 0x4aa22
-
-Function4aa22: ; 4aa22
- call ClearBGPalettes
-
-Function4aa25: ; 4aa25
- callba LoadPartyMenuGFX
- callba InitPartyMenuWithCancel
- call Function4aad3
-
-Function4aa34: ; 4aa34
- ld a, $9
- ld [PartyMenuActionText], a
- callba WritePartyMenuTilemap
- xor a
- ld [PartyMenuActionText], a
- callba PrintPartyMenuText
- call Function4aab6
- call WaitBGMap
- call SetPalettes
- call DelayFrame
- call Function4ab1a
- jr z, .asm_4aa66
- push af
- call Function4aafb
- jr c, .asm_4aa67
- call Function4ab06
- jr c, .asm_4aa67
- pop af
-
-.asm_4aa66
- ret
-
-.asm_4aa67
- ld hl, wd019
- set 1, [hl]
- pop af
- ret
-; 4aa6e
-
-Function4aa6e: ; 4aa6e
- pop af
- ld de, SFX_WRONG
- call PlaySFX
- call WaitSFX
- jr Function4aa34
-; 4aa7a
-
-Function4aa7a: ; 4aa7a
- ld hl, wd002
- ld d, $3
-.loop
- ld e, PARTY_LENGTH
- ld a, [hli]
- push de
- push hl
- cp -1
- jr z, .done
- ld hl, wSpriteAnimationStructs
- inc a
- ld d, a
-.inner_loop
- ld a, [hl]
- and a
- jr z, .next
- cp d
- jr z, .same_as_d
- jr .next
-
- ld a, $3
- jr .proceed
-
-.same_as_d
- ld a, $2
-
-.proceed
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], a
- pop hl
-
-.next
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .inner_loop
- pop hl
- pop de
- dec d
- jr nz, .loop
- jr .finished
-
-.done
- pop hl
- pop de
-
-.finished
- ret
-; 4aab6
-
-Function4aab6: ; 4aab6
- ld hl, wd002
- ld d, $3
-.loop
- ld a, [hli]
- cp -1
- jr z, .done
- push de
- push hl
- hlcoord 0, 1
- ld bc, $28
- call AddNTimes
- ld [hl], $ec
- pop hl
- pop de
- dec d
- jr nz, .loop
-
-.done
- ret
-; 4aad3
-
-Function4aad3: ; 4aad3
- ld hl, PartyCount
- ld a, [hli]
- and a
- ret z ; Nothing in your party
-
- ld c, a
- xor a
- ld [hObjectStructIndexBuffer], a
-.loop
- push bc
- push hl
- ld e, 0
- callba Function8e83f
- ld a, [hObjectStructIndexBuffer]
- inc a
- ld [hObjectStructIndexBuffer], a
- pop hl
- pop bc
- dec c
- jr nz, .loop
-
- call Function4aa7a
- callba Function8cf69
- ret
-; 4aafb
-
-Function4aafb: ; 4aafb
- ld a, [CurPartySpecies]
- cp EGG
- jr z, .egg
- and a
- ret
-
-.egg
- scf
- ret
-; 4ab06
-
-Function4ab06: ; 4ab06
- ld a, [CurPartyMon]
- ld bc, PARTYMON_STRUCT_LENGTH
- ld hl, PartyMon1HP
- call AddNTimes
- ld a, [hli]
- ld b, a
- ld a, [hl]
- or b
- jr nz, .NotFainted
- scf
-
-.NotFainted
- ret
-; 4ab1a
-
-Function4ab1a: ; 4ab1a
-.asm_4ab1a
- ld a, $fb
- ld [wcfa8], a
- ld a, $26
- ld [wcfa7], a
- ld a, $2
- ld [wcfa4], a
- call Function4adf7
- call Function1bc9
- call Function4abc3
- jr c, .asm_4ab1a
- push af
- call Function4ab99
- call nc, Function1bee
- pop af
- bit 1, a
- jr nz, .asm_4ab6d
- ld a, [PartyCount]
- inc a
- ld b, a
- ld a, [MenuSelection2]
- ld [wd0d8], a
- cp b
- jr z, .asm_4ab7e
- ld a, [MenuSelection2]
- dec a
- ld [CurPartyMon], a
- ld c, a
- ld b, $0
- ld hl, PartySpecies
- add hl, bc
- ld a, [hl]
- ld [CurPartySpecies], a
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- call WaitSFX
- ld a, $1
- and a
- ret
-
-.asm_4ab6d
- ld a, [MenuSelection2]
- ld [wd0d8], a
-.asm_4ab73
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- call WaitSFX
- scf
- ret
-
-.asm_4ab7e
- ld a, $1
- ld [wd018], a
- ld a, [wcfaa]
- cp $2
- jr z, .asm_4ab73
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- call WaitSFX
- xor a
- ld [wd018], a
- and a
- ret
-; 4ab99
-
-Function4ab99: ; 4ab99
- bit 1, a
- jr z, .asm_4aba6
- ld a, [wd002]
- cp $ff
- jr z, .asm_4aba6
- scf
- ret
-
-.asm_4aba6
- and a
- ret
-; 4aba8
-
-Function4aba8: ; 4aba8
- ld hl, wd004
- ld a, [hl]
- cp $ff
- jr nz, .asm_4abbe
- dec hl
- ld a, [hl]
- cp $ff
- jr nz, .asm_4abbe
- dec hl
- ld a, [hl]
- cp $ff
- jr nz, .asm_4abbe
- and a
- ret
-
-.asm_4abbe
- ld a, $ff
- ld [hl], a
- scf
- ret
-; 4abc3
-
-Function4abc3: ; 4abc3
- bit 3, a
- jr z, .asm_4abd5
- ld a, [PartyCount]
- inc a
- ld [MenuSelection2], a
- ld a, $1
- ld [wcfaa], a
- jr .asm_4ac29
-
-.asm_4abd5
- bit 6, a
- jr z, .asm_4abeb
- ld a, [MenuSelection2]
- ld [MenuSelection2], a
- and a
- jr nz, .asm_4ac29
- ld a, [PartyCount]
- inc a
- ld [MenuSelection2], a
- jr .asm_4ac29
-
-.asm_4abeb
- bit 7, a
- jr z, .asm_4ac08
- ld a, [MenuSelection2]
- ld [MenuSelection2], a
- ld a, [PartyCount]
-rept 2
- inc a
-endr
- ld b, a
- ld a, [MenuSelection2]
- cp b
- jr nz, .asm_4ac29
- ld a, $1
- ld [MenuSelection2], a
- jr .asm_4ac29
-
-.asm_4ac08
- bit 4, a
- jr nz, .asm_4ac10
- bit 5, a
- jr z, .asm_4ac56
-
-.asm_4ac10
- ld a, [MenuSelection2]
- ld b, a
- ld a, [PartyCount]
- inc a
- cp b
- jr nz, .asm_4ac29
- ld a, [wcfaa]
- cp $1
- jr z, .asm_4ac26
- ld a, $1
- jr .asm_4ac29
-
-.asm_4ac26
- ld [wcfaa], a
-
-.asm_4ac29
- hlcoord 0, 1
- lb bc, 13, 1
- call ClearBox
- call Function4aab6
- ld a, [PartyCount]
- hlcoord 6, 1
-.asm_4ac3b
- ld bc, $28
- add hl, bc
- dec a
- jr nz, .asm_4ac3b
- ld [hl], $7f
- ld a, [MenuSelection2]
- ld b, a
- ld a, [PartyCount]
- inc a
- cp b
- jr z, .asm_4ac54
- ld a, $1
- ld [wcfaa], a
-
-.asm_4ac54
- scf
- ret
-
-.asm_4ac56
- and a
- ret
-; 4ac58
-
-Function4ac58: ; 4ac58
- lb bc, 2, 18
- hlcoord 1, 15
- call ClearBox
- callba Function8ea4a
- ld hl, MenuDataHeader_0x4aca2
- call LoadMenuDataHeader
- ld hl, wd019
- bit 1, [hl]
- jr z, .asm_4ac89
- hlcoord 11, 13
- ld b, $3
- ld c, $7
- call TextBox
- hlcoord 13, 14
- ld de, String_4ada7
- call PlaceString
- jr .asm_4ac96
-
-.asm_4ac89
- hlcoord 11, 9
- ld b, $7
- ld c, $7
- call TextBox
- call Function4ad68
-
-.asm_4ac96
- ld a, $1
- ld [hBGMapMode], a
- call Function4acaa
- call ExitMenu
- and a
- ret
-; 4aca2
-
-MenuDataHeader_0x4aca2: ; 0x4aca2
- db $40 ; flags
- db 09, 11 ; start coords
- db 17, 19 ; end coords
- dw NULL
- db 1 ; default option
-; 0x4acaa
-
-Function4acaa: ; 4acaa
-.asm_4acaa
- ld a, $a0
- ld [wMenuData2Flags], a
- ld a, [wd019]
- bit 1, a
- jr z, .asm_4acc2
- ld a, $2
- ld [wMenuData2Items], a
- ld a, $c
- ld [wMenuBorderTopCoord], a
- jr .asm_4accc
-
-.asm_4acc2
- ld a, $4
- ld [wMenuData2Items], a
- ld a, $8
- ld [wMenuBorderTopCoord], a
-
-.asm_4accc
- ld a, $b
- ld [wMenuBorderLeftCoord], a
- ld a, $1
- ld [wMenuCursorBuffer], a
- call Function1c10
- ld hl, wcfa5
- set 6, [hl]
- call Function1bc9
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- ld a, [hJoyPressed]
- bit 0, a
- jr nz, .asm_4acf4
- bit 1, a
- jr nz, .asm_4acf3
- jr .asm_4acaa
-
-.asm_4acf3
- ret
-
-.asm_4acf4
- ld a, [wd019]
- bit 1, a
- jr nz, .asm_4ad0e
- ld a, [MenuSelection2]
- cp $1
- jr z, Function4ad17
- cp $2
- jp z, Function4ad56
- cp $3
- jp z, Function4ad60
- jr .asm_4acf3
-
-.asm_4ad0e
- ld a, [MenuSelection2]
- cp $1
- jr z, Function4ad56
- jr .asm_4acf3
-
-Function4ad17: ; 4ad17
- call Function4adb2
- jr z, .asm_4ad4a
- ld hl, wd002
- ld a, $ff
- cp [hl]
- jr z, .asm_4ad39
- inc hl
- cp [hl]
- jr z, .asm_4ad39
- inc hl
- cp [hl]
- jr z, .asm_4ad39
- ld de, SFX_WRONG
- call WaitPlaySFX
- ld hl, UnknownText_0x4ad51
- call PrintText
- ret
-
-.asm_4ad39
- ld a, [CurPartyMon]
- ld [hl], a
- call Function4a9c3
- ret c
- ld a, [wd019]
- set 0, a
- ld [wd019], a
- ret
-
-.asm_4ad4a
- ld a, $ff
- ld [hl], a
- call Function4adc2
- ret
-
-UnknownText_0x4ad51: ; 0x4ad51
- ; Only three #MON may enter.
- text_jump UnknownText_0x1c521c
- db "@"
-; 0x4ad56
-
-Function4ad56: ; 4ad56
- callba OpenPartyStats
- call Function3200
- ret
-; 4ad60
-
-Function4ad60: ; 4ad60
- callba ManagePokemonMoves
- ret
-; 4ad67
-
-Function4ad67: ; 4ad67
- ret
-; 4ad68
-
-Function4ad68: ; 4ad68
- hlcoord 13, 12
- ld de, String_4ad88
- call PlaceString
- call Function4adb2
- jr c, .asm_4ad7e
- hlcoord 13, 10
- ld de, String_4ada0
- jr .asm_4ad84
-
-.asm_4ad7e
- hlcoord 13, 10
- ld de, String_4ad9a
-
-.asm_4ad84
- call PlaceString
- ret
-; 4ad88
-
-String_4ad88: ; 4ad88
- db "つよさをみる"
- next "つかえるわざ"
- next "もどる@"
-; 4ad9a
-
-String_4ad9a: ; 4ad9a
- db "さんかする@"
-; 4ada0
-
-String_4ada0: ; 4ada0
- db "さんかしない@"
-; 4ada7
-
-String_4ada7: ; 4ada7
- db "つよさをみる"
- next "もどる@" ; BACK
-; 4adb2
-
-Function4adb2: ; 4adb2
- ld hl, wd002
- ld a, [CurPartyMon]
- cp [hl]
- ret z
- inc hl
- cp [hl]
- ret z
- inc hl
- cp [hl]
- ret z
- scf
- ret
-; 4adc2
-
-Function4adc2: ; 4adc2
- ld a, [wd002]
- cp $ff
- jr nz, .skip
- ld a, [wd003]
- cp $ff
- jr nz, .skip2
- ld a, [wd004]
- ld [wd002], a
- ld a, $ff
- ld [wd004], a
- jr .skip
-
-.skip2
- ld [wd002], a
- ld a, $ff
- ld [wd003], a
-
-.skip
- ld a, [wd003]
- cp $ff
- ret nz
- ld b, a
- ld a, [wd004]
- ld [wd003], a
- ld a, b
- ld [wd004], a
- ret
-; 4adf7
-
-Function4adf7: ; 4adf7
- ld a, [wd019]
- bit 0, a
- ret z
- ld a, [PartyCount]
- inc a
- ld [MenuSelection2], a
- ld a, $1
- ld [wcfaa], a
- ld a, [wd019]
- res 0, a
- ld [wd019], a
- ret
-; 4ae12
+INCLUDE "misc/mobile_menu.asm"
+INCLUDE "engine/search.asm"
+INCLUDE "misc/mobile_12_2.asm"
+; mobile battle selection
AskRememberPassword: ; 4ae12
call .DoMenu
@@ -17508,15 +9836,15 @@ AskRememberPassword: ; 4ae12
ld [wMenuBorderTopCoord], a
add $4
ld [wMenuBorderBottomCoord], a
- call BackUpTiles
- call InterpretMenu2
+ call PushWindow
+ call VerticalMenu
push af
ld c, 15
call DelayFrames
call Buena_ExitMenu
pop af
jr c, .refused
- ld a, [MenuSelection2]
+ ld a, [wMenuCursorY]
cp $2
jr z, .refused
and a
@@ -17524,7 +9852,7 @@ AskRememberPassword: ; 4ae12
.refused
ld a, $2
- ld [MenuSelection2], a
+ ld [wMenuCursorY], a
scf
ret
; 4ae5e
@@ -17545,13 +9873,12 @@ Buena_ExitMenu: ; 4ae5e
ret
; 4ae78
-
SECTION "bank13", ROMX, BANK[$13]
SwapTextboxPalettes:: ; 4c000
hlcoord 0, 0
decoord 0, 0, AttrMap
- ld b, $12
+ ld b, SCREEN_HEIGHT
.loop
push bc
ld c, SCREEN_WIDTH
@@ -17637,10 +9964,8 @@ ScrollBGMapPalettes:: ; 4c03f
ret
; 4c075
-
INCLUDE "tilesets/palette_maps.asm"
-
TileCollisionTable:: ; 4ce1f
; 00 land
; 01 water
@@ -17707,7 +10032,6 @@ EmptyAllSRAMBanks: ; 4cf1f
ret
; 4cf45
-
SaveMenu_LoadEDTile: ; 4cf45 (13:4f45)
ld a, [hCGB]
and a
@@ -17731,11 +10055,11 @@ SaveMenu_LoadEDTile: ; 4cf45 (13:4f45)
ld a, 1 ; BANK(VBGMap2)
ld [rVBK], a
hlcoord 0, 0, AttrMap
- call Function4cf80
+ call .LoadEDTile
ld a, 0 ; BANK(VBGMap0)
ld [rVBK], a
hlcoord 0, 0
- call Function4cf80
+ call .LoadEDTile
.WaitLY2
ld a, [rLY]
cp $60
@@ -17748,7 +10072,7 @@ SaveMenu_LoadEDTile: ; 4cf45 (13:4f45)
ld [hBGMapMode], a
ret
-Function4cf80: ; 4cf80 (13:4f80)
+.LoadEDTile: ; 4cf80 (13:4f80)
ld [hSPBuffer], sp ; $ffd9
ld sp, hl
ld a, [hBGMapAddress + 1]
@@ -17786,7 +10110,6 @@ endr
ld sp, hl
ret
-
CheckSave:: ; 4cffe
ld a, BANK(s1_a008)
call GetSRAMBank
@@ -17809,27 +10132,25 @@ CheckSave:: ; 4cffe
ret
; 4d01e
-
INCLUDE "engine/map_triggers.asm"
-
-Function4d15b:: ; 4d15b
- ld hl, wc608
- ld a, [wd196]
+_LoadMapPart:: ; 4d15b
+ ld hl, wMisc
+ ld a, [wMetatileStandingY]
and a
- jr z, .skip
- ld bc, $30
+ jr z, .top_row
+ ld bc, WMISC_WIDTH * 2
add hl, bc
-.skip
- ld a, [wd197]
+.top_row
+ ld a, [wMetatileStandingX]
and a
- jr z, .next_dw
+ jr z, .left_column
rept 2
inc hl
endr
-.next_dw
+.left_column
decoord 0, 0
ld b, SCREEN_HEIGHT
.loop
@@ -17942,39 +10263,38 @@ Shrink2Pic: ; 4d2d9
INCBIN "gfx/shrink2.2bpp.lz"
; 4d319
-Function4d319: ; 4d319
- ld a, [MenuSelection2]
+LinkMonStatsScreen: ; 4d319
+ ld a, [wMenuCursorY]
dec a
ld [CurPartyMon], a
call LowVolume
predef StatsScreenInit
ld a, [CurPartyMon]
inc a
- ld [MenuSelection2], a
+ ld [wMenuCursorY], a
call ClearScreen
call ClearBGPalettes
call MaxVolume
- callba Function28ef8
+ callba LoadTradeScreenBorder
callba Function4d354
- callba Function16d673
+ callba InitTradeSpeciesList
callba Function28eff
- call Function3200
+ call WaitBGMap2
ret
; 4d354
Function4d354: ; 4d354
call WaitBGMap
- call Function3200
+ call WaitBGMap2
ret
; 4d35b
-
-Function4d35b: ; 4d35b
+LinkTextbox2: ; 4d35b
ld h, d
ld l, e
push bc
push hl
- call Function4d37e
+ call .PlaceBorder
pop hl
pop bc
ld de, AttrMap - TileMap
@@ -18002,12 +10322,12 @@ endr
ret
; 4d37e
-Function4d37e: ; 4d37e
+.PlaceBorder: ; 4d37e
push hl
ld a, $76
ld [hli], a
inc a
- call Function4d3ab
+ call .PlaceRow
inc a
ld [hl], a
pop hl
@@ -18018,7 +10338,7 @@ Function4d37e: ; 4d37e
ld a, "┌"
ld [hli], a
ld a, " "
- call Function4d3ab
+ call .PlaceRow
ld [hl], "─"
pop hl
ld de, SCREEN_WIDTH
@@ -18028,22 +10348,22 @@ Function4d37e: ; 4d37e
ld a, "┐"
ld [hli], a
ld a, "│"
- call Function4d3ab
+ call .PlaceRow
ld [hl], "└"
ret
; 4d3ab
-Function4d3ab: ; 4d3ab
+.PlaceRow: ; 4d3ab
ld d, c
-.loop
+.row_loop
ld [hli], a
dec d
- jr nz, .loop
+ jr nz, .row_loop
ret
; 4d3b1
_ResetClock: ; 4d3b1
- callba Function8000
+ callba BlankScreen
ld b, SCGB_08
call GetSGBLayout
call LoadStandardFont
@@ -18054,9 +10374,9 @@ _ResetClock: ; 4d3b1
call PrintText
ld hl, .NoYes_MenuDataHeader
call CopyMenuDataHeader
- call InterpretMenu2
+ call VerticalMenu
ret c
- ld a, [MenuSelection2]
+ ld a, [wMenuCursorY]
cp $1
ret z
call ClockResetPassword
@@ -18318,42 +10638,42 @@ ClockResetPassword: ; 4d41e
ret
; 4d54c
-Function4d54c: ; 4d54c
- callba Function8000
+_DeleteSaveData: ; 4d54c
+ callba BlankScreen
ld b, SCGB_08
call GetSGBLayout
call LoadStandardFont
call LoadFontsExtra
ld de, MUSIC_MAIN_MENU
call PlayMusic
- ld hl, UnknownText_0x4d580
+ ld hl, .Text_ClearAllSaveData
call PrintText
- ld hl, MenuDataHeader_0x4d585
+ ld hl, .NoYesMenuDataHeader
call CopyMenuDataHeader
- call InterpretMenu2
+ call VerticalMenu
ret c
- ld a, [MenuSelection2]
+ ld a, [wMenuCursorY]
cp $1
ret z
callba EmptyAllSRAMBanks
ret
; 4d580
-UnknownText_0x4d580: ; 0x4d580
+.Text_ClearAllSaveData: ; 0x4d580
; Clear all save data?
text_jump UnknownText_0x1c564a
db "@"
; 0x4d585
-MenuDataHeader_0x4d585: ; 0x4d585
+.NoYesMenuDataHeader: ; 0x4d585
db $00 ; flags
db 07, 14 ; start coords
db 11, 19 ; end coords
- dw MenuData2_0x4d58d
+ dw .MenuData2
db 1 ; default option
; 0x4d58d
-MenuData2_0x4d58d: ; 0x4d58d
+.MenuData2: ; 0x4d58d
db $c0 ; flags
db 2 ; items
db "NO@"
@@ -18363,7 +10683,6 @@ MenuData2_0x4d58d: ; 0x4d58d
Tilesets::
INCLUDE "tilesets/tileset_headers.asm"
-
FlagPredef: ; 4d7c1
; Perform action b on flag c in flag array hl.
; If checking a flag, check flag array d:hl unless d is 0.
@@ -18436,9 +10755,9 @@ FlagPredef: ; 4d7c1
ret
; 4d7fd
-Function4d7fd: ; 4d7fd
- ld a, [wc702]
- ld hl, wEnemyTrappingMove
+GetTrademonFrontpic: ; 4d7fd
+ ld a, [wOTTrademonSpecies]
+ ld hl, wOTTrademonDVs
ld de, VTiles2
push de
push af
@@ -18452,23 +10771,23 @@ Function4d7fd: ; 4d7fd
ret
; 4d81e
-Function4d81e: ; 4d81e
- ld a, [wc702]
+AnimateTrademonFrontpic: ; 4d81e
+ ld a, [wOTTrademonSpecies]
call IsAPokemon
ret c
callba Function29549
- ld a, [wc702]
+ ld a, [wOTTrademonSpecies]
ld [CurPartySpecies], a
- ld a, [wEnemyTrappingMove]
+ ld a, [wOTTrademonDVs]
ld [TempMonDVs], a
- ld a, [wPlayerWrapCount]
+ ld a, [wOTTrademonDVs + 1]
ld [TempMonDVs + 1], a
ld b, SCGB_1A
call GetSGBLayout
- ld a, $e4
+ ld a, %11100100 ; 3,2,1,0
call DmgToCgbBGPals
- callba Function294c0
- ld a, [wc702]
+ callba TradeAnim_ShowGetmonFrontpic
+ ld a, [wOTTrademonSpecies]
ld [CurPartySpecies], a
hlcoord 7, 2
ld d, $0
@@ -18780,7 +11099,7 @@ CheckPartyFullAfterContest: ; 4d9e5
ld [wd265], a
call GetPokemonName
ld hl, StringBuffer1
- ld de, wd050
+ ld de, wMonOrItemNameBuffer
ld bc, PKMN_NAME_LENGTH
call CopyBytes
call GiveANickname_YesNo
@@ -18790,7 +11109,7 @@ CheckPartyFullAfterContest: ; 4d9e5
ld [CurPartyMon], a
xor a
ld [MonType], a
- ld de, wd050
+ ld de, wMonOrItemNameBuffer
callab InitNickname
.Party_SkipNickname
@@ -18800,7 +11119,7 @@ CheckPartyFullAfterContest: ; 4d9e5
call SkipNames
ld d, h
ld e, l
- ld hl, wd050
+ ld hl, wMonOrItemNameBuffer
call CopyBytes
ld a, [PartyCount]
dec a
@@ -18836,11 +11155,11 @@ CheckPartyFullAfterContest: ; 4d9e5
xor a
ld [CurPartyMon], a
ld hl, wContestMon
- ld de, wd018_Mon
+ ld de, wBufferMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
ld hl, PlayerName
- ld de, wd00d_MonOT
+ ld de, wBufferMonOT
ld bc, NAME_LENGTH
call CopyBytes
callab Function51322
@@ -18852,9 +11171,9 @@ CheckPartyFullAfterContest: ; 4d9e5
jr c, .Box_SkipNickname
ld a, BOXMON
ld [MonType], a
- ld de, wd050_MonNick
+ ld de, wMonOrItemNameBuffer
callab InitNickname
- ld hl, wd050_MonNick
+ ld hl, wMonOrItemNameBuffer
.Box_SkipNickname
ld a, BANK(sBoxMonNicknames)
@@ -18893,7 +11212,6 @@ CheckPartyFullAfterContest: ; 4d9e5
ret
; 4db3b
-
GiveANickname_YesNo: ; 4db3b
ld hl, TextJump_GiveANickname
call PrintText
@@ -18906,7 +11224,6 @@ TextJump_GiveANickname: ; 0x4db44
db "@"
; 0x4db49
-
SetCaughtData: ; 4db49
ld a, [PartyCount]
dec a
@@ -18983,7 +11300,6 @@ SetGiftMonCaughtData: ; 4dbaf
ret
; 4dbb8
-
SetEggMonCaughtData: ; 4dbb8 (13:5bb8)
ld a, [CurPartyMon]
ld hl, PartyMon1CaughtLevel
@@ -19140,7 +11456,6 @@ RetroactivelyIgnoreEggs: ; 4dc67
jr .loop
; 4dc7b
-
INCLUDE "engine/stats_screen.asm"
CatchTutorial:: ; 4e554
@@ -19200,26 +11515,26 @@ endr
ret
.LoadDudeData: ; 4e5b7 (13:65b7)
- ld hl, OTPartyMon1
- ld [hl], BULBASAUR
+ ld hl, wDudeNumItems
+ ld [hl], 1
inc hl
ld [hl], POTION
inc hl
- ld [hl], POUND
+ ld [hl], 1
inc hl
- ld [hl], $ff
- ld hl, OTPartyMon1Exp + 2
- ld [hl], $0
+ ld [hl], -1
+ ld hl, wDudeNumKeyItems
+ ld [hl], 0
inc hl
- ld [hl], $ff
- ld hl, OTPartyMon1CaughtGender
- ld a, $1
+ ld [hl], -1
+ ld hl, wDudeNumBalls
+ ld a, 1
ld [hli], a
- ld a, $5
+ ld a, POKE_BALL ; 5
rept 2
ld [hli], a
endr
- ld [hl], $ff
+ ld [hl], -1
ret
; 4e5da (13:65da)
@@ -19233,6 +11548,90 @@ endr
INCLUDE "engine/evolution_animation.asm"
+Function4e881: ; 4e881
+ call ClearBGPalettes
+ call ClearTileMap
+ call ClearSprites
+ call DisableLCD
+ call LoadStandardFont
+ call LoadFontsBattleExtra
+ hlbgcoord 0, 0
+ ld bc, VBGMap1 - VBGMap0
+ ld a, " "
+ call ByteFill
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ xor a
+ call ByteFill
+ xor a
+ ld [hSCY], a
+ ld [hSCX], a
+ call EnableLCD
+ ld hl, .SavingRecordDontTurnOff
+ call PrintText
+ call WaitBGMap2
+ call SetPalettes
+ ret
+; 4e8bd
+
+.SavingRecordDontTurnOff: ; 0x4e8bd
+ ; SAVING RECORD… DON'T TURN OFF!
+ text_jump UnknownText_0x1bd39e
+ db "@"
+; 0x4e8c2
+
+Function4e8c2: ; 4e8c2
+ call ClearBGPalettes
+ call ClearTileMap
+ call ClearSprites
+ call DisableLCD
+ call LoadStandardFont
+ call LoadFontsBattleExtra
+ hlbgcoord 0, 0
+ ld bc, VBGMap1 - VBGMap0
+ ld a, " "
+ call ByteFill
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ xor a
+ call ByteFill
+ ld hl, wd000 ; UnknBGPals
+ ld c, 4 * $10
+.load_white_palettes
+ ld a, (palred 31 + palgreen 31 + palblue 31) % $100
+ ld [hli], a
+ ld a, (palred 31 + palgreen 31 + palblue 31) / $100
+ ld [hli], a
+ dec c
+ jr nz, .load_white_palettes
+ xor a
+ ld [hSCY], a
+ ld [hSCX], a
+ call EnableLCD
+ call WaitBGMap2
+ call SetPalettes
+ ret
+; 4e906
+
+Function4e906: ; 4e906
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ ld hl, wDecompressScratch
+ ld bc, wBackupAttrMap - wDecompressScratch
+ ld a, " "
+ call ByteFill
+ hlbgcoord 0, 0
+ ld de, wDecompressScratch
+ ld b, $0
+ ld c, $40
+ call Request2bpp
+ pop af
+ ld [rSVBK], a
+ ret
+; 4e929
+
Function4e929: ; mobile function
ld h, b
ld l, c
@@ -19323,10 +11722,8 @@ FemaleTrainers: ; 4e976
FemaleTrainersEnd:
; 4e980
-
INCLUDE "battle/sliding_intro.asm"
-
Function4ea0a: ; 4ea0a
ld a, c
push af
@@ -19359,8 +11756,6 @@ Function4ea0a: ; 4ea0a
ret
; 4ea44
-
-
CheckBattleScene: ; 4ea44
; Return carry if battle scene is turned off.
@@ -19410,12 +11805,10 @@ CheckBattleScene: ; 4ea44
ret
; 4ea82
-
INCLUDE "misc/gbc_only.asm"
INCLUDE "event/poke_seer.asm"
-
SECTION "bank14", ROMX, BANK[$14]
INCLUDE "engine/party_menu.asm"
@@ -19461,18 +11854,14 @@ CopyPkmnToTempMon: ; 5084a
ret
; 5088b
-
-Function5088b: ; 5088b
- ld bc, wd018_Mon
- jr Function50893
+CalcwBufferMonStats: ; 5088b
+ ld bc, wBufferMon
+ jr _TempMonStatsCalculation
; 50890
-Function50890: ; 50890
+CalcTempmonStats: ; 50890
ld bc, TempMon
- ; fallthrough
-; 50893
-
-Function50893: ; 50893
+_TempMonStatsCalculation: ; 50893
ld hl, MON_LEVEL
add hl, bc
ld a, [hl]
@@ -19481,7 +11870,7 @@ Function50893: ; 50893
add hl, bc
ld d, h
ld e, l
- ld hl, MON_EXP + 2
+ ld hl, MON_STAT_EXP - 1
add hl, bc
push bc
ld b, $1
@@ -19493,14 +11882,14 @@ Function50893: ; 50893
ld e, l
ld a, [CurPartySpecies]
cp EGG
- jr nz, .asm_508c1
+ jr nz, .not_egg
xor a
ld [de], a
inc de
ld [de], a
- jr .asm_508cd
+ jr .zero_status
-.asm_508c1
+.not_egg
push bc
ld hl, MON_MAXHP
add hl, bc
@@ -19508,7 +11897,7 @@ Function50893: ; 50893
call CopyBytes
pop bc
-.asm_508cd
+.zero_status
ld hl, MON_STATUS
add hl, bc
xor a
@@ -19562,10 +11951,8 @@ GetPkmnSpecies: ; 508d5
ret
; 5090d
-
INCLUDE "text/types.asm"
-
Function50a28: ; 50a28
ld hl, Strings50a42
ld a, [TrainerClass]
@@ -19662,7 +12049,6 @@ Strings50a42: ; 50a42
.CooltrainerF db "エりート♀@"
; 50b0a
-
DrawPlayerHP: ; 50b0a
ld a, $1
jr DrawHP
@@ -19707,7 +12093,7 @@ DrawHP: ; 50b10
ld c, e
.asm_50b41
- predef DrawPartyMenuHPBar
+ predef ComputeHPBarPixels
ld a, 6
ld d, a
ld c, a
@@ -19747,7 +12133,6 @@ DrawHP: ; 50b10
ret
; 50b7b
-
PrintTempMonStats: ; 50b7b
; Print TempMon's stats at hl, with spacing bc.
push bc
@@ -19790,7 +12175,6 @@ PrintTempMonStats: ; 50b7b
next "@"
; 50bdd
-
GetGender: ; 50bdd
; Return the gender of a given monster (CurPartyMon/CurOTMon/CurWildMon).
; When calling this function, a should be set to an appropriate MonType value.
@@ -19803,7 +12187,6 @@ GetGender: ; 50bdd
; This is determined by comparing the Attack and Speed DVs
; with the species' gender ratio.
-
; Figure out what type of monster struct we're looking at.
; 0: PartyMon
@@ -19833,7 +12216,6 @@ GetGender: ; 50bdd
ld hl, EnemyMonDVs
jr .DVs
-
; Get our place in the party/box.
.PartyMon
@@ -19841,7 +12223,6 @@ GetGender: ; 50bdd
ld a, [CurPartyMon]
call AddNTimes
-
.DVs
; sBoxMon data is read directly from SRAM.
@@ -19868,7 +12249,6 @@ GetGender: ; 50bdd
cp BOXMON
call z, CloseSRAM
-
; We need the gender ratio to do anything with this.
push bc
ld a, [CurPartySpecies]
@@ -19881,7 +12261,6 @@ GetGender: ; 50bdd
ld a, BANK(BaseData)
call GetFarByte
-
; The higher the ratio, the more likely the monster is to be female.
cp $ff
@@ -19911,27 +12290,27 @@ GetGender: ; 50bdd
ret
; 50c50
-Function50c50: ; 50c50
- ld a, [wd0eb]
+ListMovePP: ; 50c50
+ ld a, [wNumMoves]
inc a
ld c, a
- ld a, $4
+ ld a, NUM_MOVES
sub c
ld b, a
push hl
ld a, [Buffer1]
ld e, a
ld d, $0
- ld a, $3e
- call Function50cc9
+ ld a, $3e ; P
+ call .load_loop
ld a, b
and a
- jr z, .asm_50c6f
+ jr z, .skip
ld c, a
- ld a, $e3
- call Function50cc9
+ ld a, "-"
+ call .load_loop
-.asm_50c6f
+.skip
pop hl
rept 3
inc hl
@@ -19940,14 +12319,14 @@ endr
ld e, l
ld hl, TempMonMoves
ld b, 0
-.asm_50c7a
+.loop
ld a, [hli]
and a
- jr z, .asm_50cc8
+ jr z, .done
push bc
push hl
push de
- ld hl, MenuSelection2
+ ld hl, wMenuCursorY
ld a, [hl]
push af
ld [hl], b
@@ -19970,7 +12349,7 @@ endr
ld de, StringBuffer1 + 4
lb bc, 1, 2
call PrintNum
- ld a, $f3
+ ld a, "/"
ld [hli], a
ld de, wd265
lb bc, 1, 2
@@ -19987,19 +12366,18 @@ endr
inc b
ld a, b
cp NUM_MOVES
- jr nz, .asm_50c7a
+ jr nz, .loop
-.asm_50cc8
+.done
ret
; 50cc9
-Function50cc9: ; 50cc9
-.asm_50cc9
+.load_loop: ; 50cc9
ld [hli], a
ld [hld], a
add hl, de
dec c
- jr nz, .asm_50cc9
+ jr nz, .load_loop
ret
; 50cd0
@@ -20044,7 +12422,6 @@ Function50cdb: ; unreferenced predef
ret
; 50d0a
-
PlaceStatusString: ; 50d0a
push de
rept 2
@@ -20140,7 +12517,7 @@ ListMoves: ; 50d6f
call PlaceString
pop bc
ld a, b
- ld [wd0eb], a
+ ld [wNumMoves], a
inc b
pop hl
push bc
@@ -20230,7 +12607,6 @@ Function50db9: ; 50db9
ret
; 50e1b
-
CalcLevel: ; 50e1b
ld a, [TempMonSpecies]
ld [CurSpecies], a
@@ -20264,8 +12640,6 @@ CalcLevel: ; 50e1b
ret
; 50e47
-
-
CalcExpAtLevel: ; 50e47
; (a/b)*n**3 + c*n**2 + d*n - e
ld a, [BaseGrowthRate]
@@ -20422,15 +12796,15 @@ ENDM
_SwitchPartyMons:
ld a, [wd0e3]
dec a
- ld [wd1ec], a
+ ld [Buffer3], a
ld b, a
- ld a, [MenuSelection2]
+ ld a, [wMenuCursorY]
dec a
ld [Buffer2], a ; wd1eb (aliases: MovementType)
cp b
jr z, .skip
call .SwapMonAndMail
- ld a, [wd1ec]
+ ld a, [Buffer3]
call .ClearSprite
ld a, [Buffer2] ; wd1eb (aliases: MovementType)
call .ClearSprite
@@ -20616,7 +12990,6 @@ GetUnownLetter: ; 51040
ret
; 51077
-
GetFrontpic: ; 51077
ld a, [CurPartySpecies]
ld [CurSpecies], a
@@ -20657,15 +13030,15 @@ _GetFrontpic: ; 510a5
ld a, $6
ld [rSVBK], a
ld a, b
- ld de, w6_d000 + $800
+ ld de, wDecompressScratch + $800
call FarDecompress
pop bc
- ld hl, w6_d000
- ld de, w6_d000 + $800
+ ld hl, wDecompressScratch
+ ld de, wDecompressScratch + $800
call Function512ab
pop hl
push hl
- ld de, w6_d000
+ ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
@@ -20708,7 +13081,7 @@ Function51103: ; 51103
ld a, $1
ld [rVBK], a
push hl
- ld de, w6_d000
+ ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
@@ -20739,7 +13112,7 @@ Function51103: ; 51103
call Function5114f
pop bc
pop hl
- ld de, w6_d000
+ ld de, wDecompressScratch
ld a, [hROMBank]
ld b, a
call Get2bpp
@@ -20749,7 +13122,7 @@ Function51103: ; 51103
; 5114f
Function5114f: ; 5114f
- ld hl, w6_d000
+ ld hl, wDecompressScratch
swap c
ld a, c
and $f
@@ -20758,12 +13131,12 @@ Function5114f: ; 5114f
and $f0
ld c, a
push bc
- call Function512f2
+ call LoadFrontpic
pop bc
.asm_51161
push bc
ld c, $0
- call Function512f2
+ call LoadFrontpic
pop bc
dec b
jr nz, .asm_51161
@@ -20808,14 +13181,14 @@ GetBackpic: ; 5116c
inc hl
ld a, d
call GetFarHalfword
- ld de, w6_d000
+ ld de, wDecompressScratch
pop af
call FarDecompress
- ld hl, w6_d000
+ ld hl, wDecompressScratch
ld c, 6 * 6
- call Function5127c
+ call FixBackpicAlignment
pop hl
- ld de, w6_d000
+ ld de, wDecompressScratch
ld a, [hROMBank]
ld b, a
call Get2bpp
@@ -20824,7 +13197,6 @@ GetBackpic: ; 5116c
ret
; 511c5
-
FixPicBank: ; 511c5
; This is a thing for some reason.
push hl
@@ -20886,7 +13258,6 @@ Function511ec: ; 511ec
ret
; 0x5120d
-
GetTrainerPic: ; 5120d
ld a, [TrainerClass]
and a
@@ -20914,10 +13285,10 @@ GetTrainerPic: ; 5120d
ld a, BANK(TrainerPicPointers)
call GetFarHalfword
pop af
- ld de, w6_d000
+ ld de, wDecompressScratch
call FarDecompress
pop hl
- ld de, w6_d000
+ ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
@@ -20930,8 +13301,6 @@ GetTrainerPic: ; 5120d
ret
; 5125d
-
-
DecompressPredef: ; 5125d
; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de.
@@ -20943,10 +13312,10 @@ DecompressPredef: ; 5125d
push de
push bc
ld a, b
- ld de, w6_d000
+ ld de, wDecompressScratch
call FarDecompress
pop bc
- ld de, w6_d000
+ ld de, wDecompressScratch
pop hl
ld a, [hROMBank]
ld b, a
@@ -20957,13 +13326,12 @@ DecompressPredef: ; 5125d
ret
; 5127c
-
-Function5127c: ; 5127c
+FixBackpicAlignment: ; 5127c
push de
push bc
- ld a, [wc2c6]
+ ld a, [wBoxAlignment]
and a
- jr z, .asm_512a8
+ jr z, .keep_dims
ld a, c
cp 7 * 7
ld de, 7 * 7 tiles
@@ -20989,7 +13357,7 @@ Function5127c: ; 5127c
or d
jr nz, .got_dims
-.asm_512a8
+.keep_dims
pop bc
pop de
ret
@@ -21002,39 +13370,39 @@ Function512ab: ; 512ab
cp 5
jr z, .five
-.seven
+.seven_loop
ld c, $70
- call Function512f2
+ call LoadFrontpic
dec b
- jr nz, .seven
+ jr nz, .seven_loop
ret
.six
ld c, $70
xor a
call .Fill
-.asm_512c3
+.six_loop
ld c, $10
xor a
call .Fill
ld c, $60
- call Function512f2
+ call LoadFrontpic
dec b
- jr nz, .asm_512c3
+ jr nz, .six_loop
ret
.five
ld c, $70
xor a
call .Fill
-.asm_512d8
+.five_loop
ld c, $20
xor a
call .Fill
ld c, $50
- call Function512f2
+ call LoadFrontpic
dec b
- jr nz, .asm_512d8
+ jr nz, .five_loop
ld c, $70
xor a
call .Fill
@@ -21047,21 +13415,21 @@ Function512ab: ; 512ab
ret
; 512f2
-Function512f2: ; 512f2
- ld a, [wc2c6]
+LoadFrontpic: ; 512f2
+ ld a, [wBoxAlignment]
and a
- jr nz, .asm_512ff
-.asm_512f8
+ jr nz, .x_flip
+.left_loop
ld a, [de]
inc de
ld [hli], a
dec c
- jr nz, .asm_512f8
+ jr nz, .left_loop
ret
-.asm_512ff
+.x_flip
push bc
-.asm_51300
+.right_loop
ld a, [de]
inc de
ld b, a
@@ -21072,7 +13440,7 @@ Function512f2: ; 512f2
endr
ld [hli], a
dec c
- jr nz, .asm_51300
+ jr nz, .right_loop
pop bc
ret
; 51322
@@ -21087,27 +13455,27 @@ Function51322: ; 51322
ld [wd265], a
ld hl, sBoxMonNicknames
ld bc, PKMN_NAME_LENGTH
- ld de, wd002
+ ld de, wBufferMonNick
call Function513e0
ld a, [sBoxCount]
dec a
ld [wd265], a
ld hl, sBoxMonOT
ld bc, NAME_LENGTH
- ld de, wd00d
+ ld de, wBufferMonOT
call Function513e0
ld a, [sBoxCount]
dec a
ld [wd265], a
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
- ld de, wd018_Mon
+ ld de, wBufferMon
call Function513e0
- ld hl, wd018_MonMoves
+ ld hl, wBufferMonMoves
ld de, TempMonMoves
ld bc, NUM_MOVES
call CopyBytes
- ld hl, wd018_MonPP
+ ld hl, wBufferMonPP
ld de, TempMonPP
ld bc, NUM_MOVES
call CopyBytes
@@ -21125,21 +13493,21 @@ Function5138b: ; 5138b
ld [wd265], a
ld hl, PartyMonNicknames
ld bc, PKMN_NAME_LENGTH
- ld de, wd002
+ ld de, wBufferMonNick
call Function513e0
ld a, [PartyCount]
dec a
ld [wd265], a
ld hl, PartyMonOT
ld bc, NAME_LENGTH
- ld de, wd00d
+ ld de, wBufferMonOT
call Function513e0
ld a, [PartyCount]
dec a
ld [wd265], a
ld hl, PartyMons
ld bc, PARTYMON_STRUCT_LENGTH
- ld de, wd018_Mon
+ ld de, wBufferMon
call Function513e0
ret
; 513cb
@@ -21241,16 +13609,12 @@ UnknownEggPic:: ; 53d9c
INCBIN "gfx/misc/unknown_egg.5x5.2bpp.lz"
; 53e2e
-
SECTION "bank19", ROMX, BANK[$19]
INCLUDE "text/phone/extra.asm"
-
-
SECTION "bank20", ROMX, BANK[$20]
-
DoPlayerMovement:: ; 80000
call GetMovementInput
@@ -21265,7 +13629,6 @@ DoPlayerMovement:: ; 80000
ret
; 80017
-
GetMovementInput: ; 80017
ld a, [hJoyDown]
@@ -21287,7 +13650,6 @@ GetMovementInput: ; 80017
ret
; 8002d
-
GetPlayerMovement: ; 8002d
ld a, [PlayerState]
@@ -21371,7 +13733,6 @@ GetPlayerMovement: ; 8002d
ret
; 800b7
-
CheckTileMovement: ; 800b7
; Tiles such as waterfalls and warps move the player
; in a given direction, overriding input.
@@ -21487,7 +13848,6 @@ CheckTileMovement: ; 800b7
ret
; 80147
-
CheckTurning: ; 80147
; If the player is turning, change direction first. This also lets
; the player change facing without moving by tapping a direction.
@@ -21518,7 +13878,6 @@ CheckTurning: ; 80147
ret
; 8016b
-
TryStep: ; 8016b
; Surfing actually calls TrySurfStep directly instead of passing through here.
@@ -21585,7 +13944,6 @@ TryStep: ; 8016b
ret
; 801c0
-
TrySurfStep: ; 801c0
call CheckWaterPermissions
@@ -21622,7 +13980,6 @@ TrySurfStep: ; 801c0
ret
; 801f3
-
TryJumpLedge: ; 801f3
ld a, [PlayerNextTile]
ld e, a
@@ -21663,7 +14020,6 @@ TryJumpLedge: ; 801f3
db FACE_UP | FACE_LEFT
; 80226
-
CheckEdgeWarp: ; 80226
; Bug: Since no case is made for STANDING here, it will check
@@ -21709,7 +14065,6 @@ CheckEdgeWarp: ; 80226
db $70, $78, $76, $7e
; 8025f
-
DoStep: ; 8025f
ld e, a
ld d, 0
@@ -21790,7 +14145,6 @@ endr
db $80 + movement_turn_head_right
; 802b3
-
StandInPlace: ; 802b3
ld a, 0
ld [wd04e], a
@@ -21800,7 +14154,6 @@ StandInPlace: ; 802b3
ret
; 802bf
-
WalkInPlace: ; 802bf
ld a, 0
ld [wd04e], a
@@ -21810,7 +14163,6 @@ WalkInPlace: ; 802bf
ret
; 802cb
-
CheckForcedMovementInput: ; 802cb
; When sliding on ice, input is forced to remain in the same direction.
@@ -21836,7 +14188,6 @@ CheckForcedMovementInput: ; 802cb
db D_DOWN, D_UP, D_LEFT, D_RIGHT
; 802ec
-
GetMovementAction: ; 802ec
; Poll player input and update movement info.
@@ -21896,7 +14247,6 @@ GetMovementAction: ; 802ec
dw TileDown
; 80341
-
IsNPCInFront: ; 80341
; Returns 0 if there is an NPC in front that you can't move
; Returns 1 if there is no NPC in front
@@ -21935,7 +14285,6 @@ IsNPCInFront: ; 80341
ret
; 8036f
-
Function8036f: ; 8036f
ld hl, BikeFlags
@@ -21974,7 +14323,6 @@ Function8036f: ; 8036f
ret
; 8039e
-
CheckLandPermissions: ; 8039e
; Return 0 if walking onto land and tile permissions allow it.
; Otherwise, return carry.
@@ -22019,7 +14367,6 @@ CheckWaterPermissions: ; 803b4
ret
; 803ca
-
CheckRiding: ; 803ca
ld a, [PlayerState]
@@ -22029,7 +14376,6 @@ CheckRiding: ; 803ca
ret
; 803d3
-
CheckWalkable: ; 803d3
; Return 0 if tile a is land. Otherwise, return carry.
@@ -22040,7 +14386,6 @@ CheckWalkable: ; 803d3
ret
; 803da
-
CheckSurfable: ; 803da
; Return 0 if tile a is water, or 1 if land.
; Otherwise, return carry.
@@ -22069,7 +14414,6 @@ CheckSurfable: ; 803da
ret
; 803ee
-
PlayBump: ; 803ee
call CheckSFX
@@ -22079,7 +14423,6 @@ PlayBump: ; 803ee
ret
; 803f9
-
WaterToLandSprite: ; 803f9
push bc
ld a, PLAYER_NORMAL
@@ -22089,7 +14432,6 @@ WaterToLandSprite: ; 803f9
ret
; 80404
-
CheckStandingOnIce:: ; 80404
ld a, [wd04e]
cp 0
@@ -22112,7 +14454,6 @@ CheckStandingOnIce:: ; 80404
ret
; 80422
-
Function80422:: ; 80422
ld hl, wc2de
ld a, movement_step_sleep_1
@@ -22125,8 +14466,6 @@ Function80422:: ; 80422
ret
; 80430
-
-
INCLUDE "engine/engine_flags.asm"
; 80648
@@ -22216,8 +14555,8 @@ ShowPlayerNamingChoices: ; 88297
ld hl, KrisNameMenuHeader
.GotGender
call LoadMenuDataHeader
- call InterpretMenu2
- ld a, [MenuSelection2]
+ call VerticalMenu
+ ld a, [wMenuCursorY]
dec a
call CopyNameFromMenu
call WriteBackup
@@ -22331,7 +14670,6 @@ CardGFX: ; 887c5
INCBIN "gfx/misc/trainer_card.2bpp"
; 88825
-
GetPlayerBackpic: ; 88825
ld a, [PlayerGender]
bit 0, a
@@ -22378,17 +14716,15 @@ Function88840: ; 88840
ret
; 88874
-
-
DrawIntroPlayerPic: ; 88874
; Draw the player pic at (6,4).
; Get class
- ld e, 0
+ ld e, CHRIS
ld a, [PlayerGender]
bit 0, a
jr z, .GotClass
- ld e, 1
+ ld e, KRIS
.GotClass
ld a, e
ld [TrainerClass], a
@@ -22414,7 +14750,6 @@ DrawIntroPlayerPic: ; 88874
ret
; 888a9
-
ChrisPic: ; 888a9
INCBIN "gfx/misc/chris.7x7.2bpp"
; 88bb9
@@ -22423,7 +14758,6 @@ KrisPic: ; 88bb9
INCBIN "gfx/misc/kris.7x7.2bpp"
; 88ec9
-
GetKrisBackpic: ; 88ec9
; Kris's backpic is uncompressed.
ld de, KrisBackpic
@@ -22437,7 +14771,6 @@ KrisBackpic: ; 88ed6
INCBIN "gfx/misc/kris_back.6x6.2bpp"
; 89116
-
String_89116:
db "-----@"
; 8911c
@@ -22449,7 +14782,6 @@ INCLUDE "event/dratini.asm"
INCLUDE "event/battle_tower.asm"
INCLUDE "misc/mobile_22_2.asm"
-
SECTION "bank23", ROMX, BANK[$23]
Predef35: ; 8c000
@@ -22457,7 +14789,6 @@ Predef36:
ret
; 8c001
-
INCLUDE "engine/timeofdaypals.asm"
INCLUDE "engine/battle_start.asm"
@@ -22471,153 +14802,6 @@ Function8c7c9: ; unreferenced
; 8c7d4
INCLUDE "event/field_moves.asm"
-
-Function8caed: ; 8caed
- call DelayFrame
- ld a, [VramState]
- push af
- xor a
- ld [VramState], a
- call Function8cb9b
- depixel 10, 10, 4, 0
- ld a, SPRITE_ANIM_INDEX_0A
- call _InitSpriteAnimStruct
- ld hl, $3
- add hl, bc
- ld [hl], $84
- ld hl, $2
- add hl, bc
- ld [hl], $16
- ld a, $80
- ld [wcf64], a
-.asm_8cb14
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_8cb2e
- ld a, $0
- ld [wc3b5], a
- callab Function8cf7a
- call Function8cbc8
- call DelayFrame
- jr .asm_8cb14
-.asm_8cb2e
- pop af
- ld [VramState], a
- ret
-; 8cb33
-
-Function8cb33: ; 8cb33
- call DelayFrame
- ld a, [VramState]
- push af
- xor a
- ld [VramState], a
- call Function8cb9b
- depixel 31, 10, 4, 0
- ld a, SPRITE_ANIM_INDEX_0A
- call _InitSpriteAnimStruct
- ld hl, $3
- add hl, bc
- ld [hl], $84
- ld hl, $2
- add hl, bc
- ld [hl], $18
- ld hl, $f
- add hl, bc
- ld [hl], $58
- ld a, $40
- ld [wcf64], a
-.asm_8cb60
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_8cb7a
- ld a, $0
- ld [wc3b5], a
- callab Function8cf7a
- call Function8cbc8
- call DelayFrame
- jr .asm_8cb60
-.asm_8cb7a
- pop af
- ld [VramState], a
- call Function8cb82
- ret
-
-Function8cb82: ; 8cb82 (23:4b82)
- ld hl, Sprites + 2
- xor a
- ld c, $4
-.asm_8cb88
- ld [hli], a
-rept 3
- inc hl
-endr
- inc a
- dec c
- jr nz, .asm_8cb88
- ld hl, Sprites + $10
- ld bc, $90
- xor a
- call ByteFill
- ret
-
-Function8cb9b: ; 8cb9b (23:4b9b)
- callab Function8cf53
- ld de, CutGrassGFX
- ld hl, VTiles1 tile $00
- lb bc, BANK(CutGrassGFX), 4
- call Request2bpp
- ld a, [CurPartyMon]
- ld hl, PartySpecies
- ld e, a
- ld d, 0
- add hl, de
- ld a, [hl]
- ld [wd265], a
- ld e, $84
- callba Function8e9bc
- xor a
- ld [wJumptableIndex], a
- ret
-
-Function8cbc8: ; 8cbc8 (23:4bc8)
- call Function8cbe6
- ld hl, wcf64
- ld a, [hl]
- and a
- jr z, .asm_8cbe0
- dec [hl]
- cp $40
- ret c
- and $7
- ret nz
- ld de, SFX_FLY
- call PlaySFX
- ret
-.asm_8cbe0
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-Function8cbe6: ; 8cbe6 (23:4be6)
- ld hl, wcf65
- ld a, [hl]
- inc [hl]
- and $7
- ret nz
- ld a, [hl]
- and $18
- sla a
- add $40
- ld d, a
- ld e, $0
- ld a, SPRITE_ANIM_INDEX_18 ; fly land
- call _InitSpriteAnimStruct
- ld hl, $3
- add hl, bc
- ld [hl], $80
- ret
-
INCLUDE "event/magnet_train.asm"
Function8cf4f: ; 8cf4f
@@ -22625,9 +14809,9 @@ Function8cf4f: ; 8cf4f
ret
; 8cf53
-
INCLUDE "engine/sprites.asm"
+INCLUDE "engine/mon_icons.asm"
SECTION "bank24", ROMX, BANK[$24]
@@ -22638,13 +14822,11 @@ INCLUDE "engine/pokegear.asm"
INCLUDE "data/wild/fish.asm"
INCLUDE "engine/slot_machine.asm"
-
SECTION "Phone Engine", ROMX, BANK[$28]
INCLUDE "engine/more_phone_scripts.asm"
INCLUDE "engine/buena_phone_scripts.asm"
-
SECTION "Phone Text", ROMX, BANK[$29]
INCLUDE "text/phone/anthony_overworld.asm"
@@ -22669,7 +14851,6 @@ SECTION "Tileset Data 5", ROMX, BANK[TILESETS_5]
INCLUDE "tilesets/data_5.asm"
-
SECTION "bank2E", ROMX, BANK[$2E]
INCLUDE "engine/events_3.asm"
@@ -22686,16 +14867,16 @@ INCLUDE "engine/phone_scripts.asm"
TalkToTrainerScript:: ; 0xbe66a
faceplayer
- trainerstatus CHECK_FLAG
+ trainerflagaction CHECK_FLAG
iftrue AlreadyBeatenTrainerScript
- loadtrainerdata
- playrammusic
+ loadmemtrainer
+ encountermusic
jump StartBattleWithMapTrainerScript
; 0xbe675
SeenByTrainerScript:: ; 0xbe675
- loadtrainerdata
- playrammusic
+ loadmemtrainer
+ encountermusic
showemote EMOTE_SHOCK, LAST_TALKED, 30
callasm TrainerWalkToPlayer
applymovement2 MovementBuffer
@@ -22705,22 +14886,20 @@ SeenByTrainerScript:: ; 0xbe675
; 0xbe68a
StartBattleWithMapTrainerScript: ; 0xbe68a
- loadfont
+ opentext
trainertext $0
+ waitbutton
closetext
- loadmovesprites
- loadtrainerdata
+ loadmemtrainer
startbattle
returnafterbattle
- trainerstatus SET_FLAG
+ trainerflagaction SET_FLAG
loadvar wRunningTrainerBattleScript, -1
AlreadyBeatenTrainerScript:
scripttalkafter
; 0xbe699
-
-
SECTION "bank30", ROMX, BANK[$30]
INCLUDE "gfx/overworld/sprites_1.asm"
@@ -22729,54 +14908,53 @@ SECTION "bank31", ROMX, BANK[$31]
INCLUDE "gfx/overworld/sprites_2.asm"
-
SECTION "bank32", ROMX, BANK[$32]
INCLUDE "battle/bg_effects.asm"
INCLUDE "battle/anims.asm"
-Functioncbcdd: ; cbcdd
- call Functioncbce5
+LoadPoisonBGPals: ; cbcdd
+ call .LoadPals
ld a, [hCGB]
and a
ret nz
ret
; cbce5
-Functioncbce5: ; cbce5
+.LoadPals: ; cbce5
ld a, [hCGB]
and a
- jr nz, .asm_cbd06
+ jr nz, .cgb
ld a, [TimeOfDayPal]
and $3
cp $3
ld a, $0
- jr z, .asm_cbcf7
+ jr z, .convert_pals
ld a, $aa
-.asm_cbcf7
+.convert_pals
call DmgToCgbBGPals
ld c, 4
call DelayFrames
callba _UpdateTimePals
ret
-.asm_cbd06
+.cgb
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
ld hl, BGPals
ld c, $20
-.asm_cbd12
+.loop
; RGB 31, 21, 28
- ld a, $bc
+ ld a, (palred 31 + palgreen 21 + palblue 28) % $100
ld [hli], a
- ld a, $7e
+ ld a, (palred 31 + palgreen 21 + palblue 28) / $100
ld [hli], a
dec c
- jr nz, .asm_cbd12
+ jr nz, .loop
pop af
ld [rSVBK], a
ld a, $1
@@ -22791,7 +14969,6 @@ TheEndGFX:: ; cbd2e
INCBIN "gfx/credits/theend.2bpp"
; cbe2e
-
SECTION "bank33", ROMX, BANK[$33]
DisplayCaughtContestMonStats: ; cc000
@@ -22908,12 +15085,10 @@ Predef39: ; cc0d5
ret
; cc0d6
-
INCLUDE "battle/anim_commands.asm"
INCLUDE "battle/anim_objects.asm"
-
SECTION "Pic Animations 1", ROMX, BANK[$34]
INCLUDE "gfx/pics/animation.asm"
@@ -22954,45 +15129,41 @@ INCLUDE "gfx/pics/bitmasks.asm"
INCLUDE "gfx/pics/unown_bitmask_pointers.asm"
INCLUDE "gfx/pics/unown_bitmasks.asm"
-
SECTION "Pic Animations 2", ROMX, BANK[$35]
INCLUDE "gfx/pics/frame_pointers.asm"
INCLUDE "gfx/pics/kanto_frames.asm"
-
SECTION "bank36", ROMX, BANK[$36]
FontInversed: INCBIN "gfx/misc/font_inversed.1bpp"
-
SECTION "Pic Animations 3", ROMX, BANK[$36]
INCLUDE "gfx/pics/johto_frames.asm"
INCLUDE "gfx/pics/unown_frame_pointers.asm"
INCLUDE "gfx/pics/unown_frames.asm"
-
SECTION "Tileset Data 6", ROMX, BANK[TILESETS_6]
INCLUDE "tilesets/data_6.asm"
-
SECTION "bank38", ROMX, BANK[$38]
Functione0000: ; e0000
+; something to do with Unown printer
push de
xor a
call GetSRAMBank
ld hl, sScratch
ld bc, 0
-.asm_e000b
+.loop
push bc
push hl
push bc
ld de, wd002
- call Functione004e
- call Functione0057
+ call .Copy
+ call .Decompress
ld hl, Unknown_e008b
pop bc
rept 2
@@ -23002,7 +15173,7 @@ endr
ld e, a
ld d, [hl]
ld hl, wd012
- call Functione004e
+ call .Copy
pop hl
ld bc, $10
add hl, bc
@@ -23010,10 +15181,11 @@ endr
inc c
ld a, c
cp $31
- jr c, .asm_e000b
+ jr c, .loop
+
ld hl, OverworldMap
ld de, sScratch
- ld bc, $310
+ ld bc, $31 tiles
call CopyBytes
pop hl
ld de, sScratch
@@ -23025,80 +15197,88 @@ endr
ret
; e004e
-Functione004e: ; e004e
+.Copy: ; e004e
ld c, $10
-.asm_e0050
+.loop_copy
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_e0050
+ jr nz, .loop_copy
ret
; e0057
-Functione0057: ; e0057
+.Decompress: ; e0057
ld hl, wd012
- ld e, $80
- ld d, $8
-.asm_e005e
+ ld e, %10000000
+ ld d, 8
+.loop_decompress
push hl
ld hl, wd002
- call Functione0078
+ call .CountSetBit
pop hl
ld a, b
ld [hli], a
push hl
ld hl, wd003
- call Functione0078
+ call .CountSetBit
pop hl
ld a, b
ld [hli], a
srl e
dec d
- jr nz, .asm_e005e
+ jr nz, .loop_decompress
ret
; e0078
-Functione0078: ; e0078
- ld b, $0
- ld c, $8
-.asm_e007c
+.CountSetBit: ; e0078
+ ld b, 0
+ ld c, 8
+.loop_count
ld a, [hli]
and e
- jr z, .asm_e0083
+ jr z, .clear
scf
- jr .asm_e0084
+ jr .apply
-.asm_e0083
+.clear
and a
-.asm_e0084
+.apply
rr b
inc hl
dec c
- jr nz, .asm_e007c
+ jr nz, .loop_count
ret
; e008b
+overworldmaptile EQUS "dw OverworldMap + $10 *"
+overworldmaprect: MACRO
+y = 0
+rept \1
+x = \1 * (\2 +- 1) + y
+rept \2
+ overworldmaptile x
+x = x +- \2
+endr
+y = y + 1
+endr
+endm
+
Unknown_e008b: ; e008b
- dw wcaa0, wca30, wc9c0, wc950, wc8e0, wc870, wc800
- dw wcab0, wca40, wc9d0, wc960, wc8f0, wc880, wc810
- dw wcac0, wca50, wc9e0, wc970, wc900, wc890, wc820
- dw wcad0, wca60, wc9f0, wc980, wc910, wc8a0, wc830
- dw wcae0, wca70, wca00, wc990, wc920, wc8b0, wc840
- dw wcaf0, wca80, wca10, wc9a0, wc930, wc8c0, wc850
- dw wcb00, wca90, wca20, wc9b0, wc940, wc8d0, wc860
+ overworldmaprect 7, 7
; e00ed
Unknown_e00ed:
; Graphics for an unused Game Corner
; game were meant to be here.
-Functione00ed: ; e00ed (38:40ed)
+ret_e00ed: ; e00ed (38:40ed)
ret
; e00ee (38:40ee)
INCLUDE "engine/card_flip.asm"
+INCLUDE "engine/unown_puzzle.asm"
INCLUDE "engine/dummy_game.asm"
INCLUDE "engine/billspc.asm"
@@ -23115,127 +15295,7 @@ SECTION "bank3E", ROMX, BANK[$3E]
INCLUDE "gfx/font.asm"
INCLUDE "engine/time_capsule/conversion.asm"
-
-UpdateUnownDex: ; fba18
- ld a, [UnownLetter]
- ld c, a
- ld b, 26
- ld hl, UnownDex
-.loop
- ld a, [hli]
- and a
- jr z, .done
- cp c
- ret z
- dec b
- jr nz, .loop
- ret
-
-.done
- dec hl
- ld [hl], c
- ret
-; fba2e
-
-
-Functionfba2e: ; fba2e (3e:7a2e)
- hlcoord 4, 15
- ld bc, 12
- ld a, " "
- call ByteFill
- ld a, [wc7dd]
- ld e, a
- ld d, 0
- ld hl, UnownDex
- add hl, de
- ld a, [hl]
- ld e, a
- ld d, 0
- ld hl, UnownWords
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld e, a
- ld d, [hl]
- hlcoord 4, 15
-.asm_fba52
- ld a, [de]
- cp $ff
- ret z
- inc de
- ld [hli], a
- jr .asm_fba52
-; fba5a (3e:7a5a)
-
-UnownWords: ; fba5a
- dw UnownWord1
- dw UnownWord1
- dw UnownWord2
- dw UnownWord3
- dw UnownWord4
- dw UnownWord5
- dw UnownWord6
- dw UnownWord7
- dw UnownWord8
- dw UnownWord9
- dw UnownWord10
- dw UnownWord11
- dw UnownWord12
- dw UnownWord13
- dw UnownWord14
- dw UnownWord15
- dw UnownWord16
- dw UnownWord17
- dw UnownWord18
- dw UnownWord19
- dw UnownWord20
- dw UnownWord21
- dw UnownWord22
- dw UnownWord23
- dw UnownWord24
- dw UnownWord25
- dw UnownWord26
-; fba90
-
-unownword: macro
-x = 1
- rept STRLEN(\1)
- db STRSUB(\1, x, 1) - $40
-x = x + 1
- endr
- db -1
-endm
-
-
-UnownWord1: unownword "ANGRY"
-UnownWord2: unownword "BEAR"
-UnownWord3: unownword "CHASE"
-UnownWord4: unownword "DIRECT"
-UnownWord5: unownword "ENGAGE"
-UnownWord6: unownword "FIND"
-UnownWord7: unownword "GIVE"
-UnownWord8: unownword "HELP"
-UnownWord9: unownword "INCREASE"
-UnownWord10: unownword "JOIN"
-UnownWord11: unownword "KEEP"
-UnownWord12: unownword "LAUGH"
-UnownWord13: unownword "MAKE"
-UnownWord14: unownword "NUZZLE"
-UnownWord15: unownword "OBSERVE"
-UnownWord16: unownword "PERFORM"
-UnownWord17: unownword "QUICKEN"
-UnownWord18: unownword "REASSURE"
-UnownWord19: unownword "SEARCH"
-UnownWord20: unownword "TELL"
-UnownWord21: unownword "UNDO"
-UnownWord22: unownword "VANISH"
-UnownWord23: unownword "WANT"
-UnownWord24: unownword "XXXXX"
-UnownWord25: unownword "YIELD"
-UnownWord26: unownword "ZOOM"
-; fbb32
-
+INCLUDE "engine/unowndex.asm"
INCLUDE "event/magikarp.asm"
INCLUDE "battle/hidden_power.asm"
@@ -23250,1054 +15310,15 @@ INCLUDE "engine/npctrade.asm"
INCLUDE "event/mom_phone.asm"
-INCLUDE "misc/mobile_40.asm"
+SECTION "bank40", ROMX, BANK[$40]
+INCLUDE "misc/mobile_40.asm"
SECTION "bank41", ROMX, BANK[$41]
-Function104000:: ; 104000
- ld hl, Function104006
- jp Function104177
-; 104006
-
-Function104006: ; 104006
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- decoord 0, 0
- ld hl, w6_d000
- call Function10425f
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function10419d
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function10419d
- ret
-; 10402d
-
-Function10402d:: ; 10402d
- ld hl, Function104033
- jp Function104177
-; 104033
-
-Function104033: ; 104033
- decoord 0, 0
- ld hl, w6_d000
- call Function10425f
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function10419d
- ret
-; 104047
-
-Function104047: ; 104047
- ld hl, Function10404d
- jp Function104177
-; 10404d
-
-Function10404d: ; 10404d
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function10419d
- ret
-; 104061
-
-ReloadMapPart:: ; 104061
- ld hl, Function104067
- jp Function104177
-; 104067
-
-Function104067: ; 104067
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- decoord 0, 0
- ld hl, w6_d000
- call Function10425f
- call DelayFrame
- di
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function1041ad
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function1041ad
- pop af
- ld [rVBK], a
- ei
- ret
-
-Function104099: ; 104099
- ld hl, ReloadMapPart ; useless
- ld hl, Function1040a2
- jp Function104177
-; 1040a2
-
-Function1040a2: ; 1040a2
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- decoord 0, 0
- ld hl, w6_d000
- call Function10425f
- call DelayFrame
- di
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function1041c1
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function1041c1
- pop af
- ld [rVBK], a
- ei
- ret
-; 1040d4
-
-Function1040d4: ; 1040d4
- ld hl, Function1040da
- jp Function104177
-; 1040da
-
-Function1040da: ; 1040da
- ld a, $1
- ld [rVBK], a
- ld a, $3
- ld [rSVBK], a
- ld de, w3_d800
- ld a, [hBGMapAddress + 1]
- ld [rHDMA1], a
- ld a, [hBGMapAddress]
- ld [rHDMA2], a
- ld a, d
- ld [rHDMA3], a
- ld a, e
- ld [rHDMA4], a
- ld a, $23
- ld [hDMATransfer], a
- call Function1041a4
- ret
-; 1040fb
-
-Function1040fb: ; 1040fb
- ld hl, Function104101
- jp Function104177
-; 104101
-
-Function104101: ; 104101
- ld a, $1
- ld [rVBK], a
- ld a, $3
- ld [rSVBK], a
- ld hl, w3_d800
- call Function10419d
- ret
-; 104110
-
-Function104110:: ; 104110
- ld hl, Function104116
- jp Function104177
-; 104116
-
-Function104116: ; 104116
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- decoord 0, 0
- ld hl, w6_d000
- call Function10425f
- call DelayFrame
- di
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function1041b7
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function1041b7
- pop af
- ld [rVBK], a
- ei
- ret
-; 104148
-
-Function104148: ; 104148 (41:4148)
- ld hl, Function10414e
- jp Function104177
-; 10414e (41:414e)
-
-Function10414e: ; 10414e
- decoord 0, 0, AttrMap
- ld hl, w6_d400
- call Function104263
- ld c, $ff
- decoord 0, 0
- ld hl, w6_d000
- call Function104265
- ld a, $1
- ld [rVBK], a
- ld hl, w6_d400
- call Function1041ad
- ld a, $0
- ld [rVBK], a
- ld hl, w6_d000
- call Function1041ad
- ret
-; 104177
-
-Function104177: ; 104177
- ld a, [hBGMapMode]
- push af
- ld a, [hMapAnims]
- push af
- xor a
- ld [hBGMapMode], a
- ld [hMapAnims], a
- ld a, [rSVBK]
- push af
- ld a, 6
- ld [rSVBK], a
- ld a, [rVBK]
- push af
- call Function10419c
- pop af
- ld [rVBK], a
- pop af
- ld [rSVBK], a
- pop af
- ld [hMapAnims], a
- pop af
- ld [hBGMapMode], a
- ret
-; 10419c
-
-Function10419c: ; 10419c
- jp [hl]
-; 10419d
-
-
-Function10419d: ; 10419d (41:419d)
- call Function10424e
- ld a, $23
- ld [hDMATransfer], a
-
-Function1041a4: ; 104a14
-.asm_1041a4
- call DelayFrame
- ld a, [hDMATransfer]
- and a
- jr nz, .asm_1041a4
- ret
-
-Function1041ad: ; 1041ad (41:41ad)
- ld a, [hBGMapAddress + 1]
- ld d, a
- ld a, [hBGMapAddress]
- ld e, a
- ld c, $24
- jr Function104209
-
-Function1041b7: ; 1041b7 (41:41b7)
- ld a, [hBGMapAddress + 1]
- ld d, a
- ld a, [hBGMapAddress]
- ld e, a
- ld c, $24
- jr asm_104205
-; 1041c1 (41:41c1)
-
-Function1041c1: ; 1041c1
- ld a, [hBGMapAddress + 1]
- ld d, a
- ld a, [hBGMapAddress]
- ld e, a
- ld c, $24
- ld a, h
- ld [rHDMA1], a
- ld a, l
- and $f0
- ld [rHDMA2], a
- ld a, d
- and $1f
- ld [rHDMA3], a
- ld a, e
- and $f0
- ld [rHDMA4], a
- ld a, c
- dec c
- or $80
- ld b, a
- ld a, $7f
- sub c
- ld d, a
-.loop1
- ld a, [rLY]
- cp d
- jr nc, .loop1
-.loop2
- ld a, [rSTAT]
- and $3
- jr z, .loop2
- ld a, b
- ld [rHDMA5], a
- ld a, [rLY]
- inc c
- ld hl, rLY
-.loop3
- cp [hl]
- jr z, .loop3
- ld a, [hl]
- dec c
- jr nz, .loop3
- ld hl, rHDMA5
- res 7, [hl]
- ret
-; 104205
-
-asm_104205:
- ld b, $7b
- jr asm_10420b
-
-
-Function104209:
-; LY magic
- ld b, $7f
-asm_10420b:
- ld a, h
- ld [rHDMA1], a
- ld a, l
- and $f0 ; high nybble
- ld [rHDMA2], a
- ld a, d
- and $1f ; lower 5 bits
- ld [rHDMA3], a
- ld a, e
- and $f0 ; high nybble
- ld [rHDMA4], a
- ld a, c
- dec c
- or $80 ; set 7, a
- ld e, a
- ld a, b
- sub c
- ld d, a
-.ly_loop
- ld a, [rLY]
- cp d
- jr nc, .ly_loop
-
- di
-.rstat_loop_1
- ld a, [rSTAT]
- and $3
- jr nz, .rstat_loop_1
-.rstat_loop_2
- ld a, [rSTAT]
- and $3
- jr z, .rstat_loop_2
- ld a, e
- ld [rHDMA5], a
- ld a, [rLY]
- inc c
- ld hl, rLY
-.final_ly_loop
- cp [hl]
- jr z, .final_ly_loop
- ld a, [hl]
- dec c
- jr nz, .final_ly_loop
- ld hl, rHDMA5
- res 7, [hl]
- ei
-
- ret
-; 10424e
+INCLUDE "misc/gfx_41.asm"
-
-Function10424e: ; 10424e (41:424e)
- ld a, h
- ld [rHDMA1], a
- ld a, l
- ld [rHDMA2], a
- ld a, [hBGMapAddress + 1]
- and $1f
- ld [rHDMA3], a
- ld a, [hBGMapAddress]
- ld [rHDMA4], a
- ret
-
-Function10425f: ; 10425f (41:425f)
- ld c, $7f
- jr Function104265
-
-Function104263: ; 104263 (41:4263)
- ld c, $0
-
-Function104265: ; 104265 (41:4265)
-; back up the value of c to hMapObjectIndexBuffer
- ld a, [hMapObjectIndexBuffer]
- push af
- ld a, c
- ld [hMapObjectIndexBuffer], a
-
-; for each row on the screen
- ld c, SCREEN_HEIGHT
-.loop1
-; for each tile in the row
- ld b, SCREEN_WIDTH
-.loop2
-; copy from de to hl
- ld a, [de]
- inc de
- ld [hli], a
- dec b
- jr nz, .loop2
-
-; load the original value of c into hl 12 times
- ld a, [hMapObjectIndexBuffer]
- ld b, 12
-.loop3
- ld [hli], a
- dec b
- jr nz, .loop3
-
- dec c
- jr nz, .loop1
-
-; restore the original value of hMapObjectIndexBuffer
- pop af
- ld [hMapObjectIndexBuffer], a
- ret
-
-
-_Get2bpp:: ; 104284
- ; 2bpp when [rLCDC] & $80
- ; switch to WRAM bank 6
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
-
- push bc
- push hl
-
- ; Copy c tiles of the 2bpp from b:de to w6_d000
- ld a, b ; bank
- ld l, c ; number of tiles
- ld h, $0
-rept 4
- add hl, hl ; multiply by 16 (16 bytes of a 2bpp = 8 x 8 tile)
-endr
- ld b, h
- ld c, l
- ld h, d ; address
- ld l, e
- ld de, w6_d000
- call FarCopyBytes
-
- pop hl
- pop bc
-
- push bc
- call DelayFrame
- pop bc
-
- ld d, h
- ld e, l
- ld hl, w6_d000
- call Function104209
-
- ; restore the previous bank
- pop af
- ld [rSVBK], a
- ret
-; 1042b2
-
-_Get1bpp:: ; 1042b2
- ; 1bpp when [rLCDC] & $80
-.loop
- ld a, c
- cp $10
- jp c, .bankswitch
- jp z, .bankswitch
- push bc
- push hl
- push de
- ld c, $10
- call .bankswitch
- pop de
- ld hl, $80
- add hl, de
- ld d, h
- ld e, l
- pop hl
- lb bc, 1, 0
- add hl, bc
- pop bc
- ld a, c
- sub $10
- ld c, a
- jr .loop
-; 1042d6
-
-.bankswitch: ; 1042d6
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
-
- push bc
- push hl
-
- ld a, b
- ld l, c
- ld h, $0
-rept 3
- add hl, hl ; multiply by 8
-endr
- ld c, l
- ld b, h
- ld h, d
- ld l, e
- ld de, w6_d000
- call FarCopyBytesDouble_DoubleBankSwitch
-
- pop hl
- pop bc
-
- push bc
- call DelayFrame
- pop bc
-
- ld d, h
- ld e, l
- ld hl, w6_d000
- call Function104209
-
- pop af
- ld [rSVBK], a
- ret
-; 104303
-
-Function104303: ; 104303
- ld hl, Function104309
- jp Function104177
-; 104309
-
-Function104309:
- ld hl, w6_d000
- decoord 0, 0
- call Function10433a
- ld hl, w6_d000 + $80
- decoord 0, 0, AttrMap
- call Function10433a
- ld a, $1
- ld [rVBK], a
- ld c, $8
- ld hl, w6_d000 + $80
- debgcoord 0, 0, VBGMap1
- call Function104209
- ld a, $0
- ld [rVBK], a
- ld c, $8
- ld hl, w6_d000
- debgcoord 0, 0, VBGMap1
- call Function104209
- ret
-
-Function10433a: ; 10433a (41:433a)
- ld b, 4
-.outer_loop
- ld c, 20
-.inner_loop
- ld a, [de]
- ld [hli], a
- inc de
- dec c
- jr nz, .inner_loop
- ld a, l
- add $20 - 20
- ld l, a
- ld a, h
- adc $0
- ld h, a
- dec b
- jr nz, .outer_loop
- ret
-; 104350
-
-ShockEmote: INCBIN "gfx/emotes/shock.2bpp"
-QuestionEmote: INCBIN "gfx/emotes/question.2bpp"
-HappyEmote: INCBIN "gfx/emotes/happy.2bpp"
-SadEmote: INCBIN "gfx/emotes/sad.2bpp"
-HeartEmote: INCBIN "gfx/emotes/heart.2bpp"
-BoltEmote: INCBIN "gfx/emotes/bolt.2bpp"
-SleepEmote: INCBIN "gfx/emotes/sleep.2bpp"
-FishEmote: INCBIN "gfx/emotes/fish.2bpp"
-JumpShadowGFX: INCBIN "gfx/misc/shadow.2bpp"
-FishingRodGFX2: INCBIN "gfx/misc/fishing2.2bpp"
-BoulderDustGFX: INCBIN "gfx/misc/boulderdust.2bpp"
-FishingRodGFX4: INCBIN "gfx/misc/fishing4.2bpp"
-
-
-RunCallback_05_03: ; 1045b0
- call Clearwc7e8
- call ResetMapBufferEventFlags
- call ResetFlashIfOutOfCave
- call GetCurrentMapTrigger
- call ResetBikeFlags
- ld a, $5
- call RunMapCallback
-
-RunCallback_03: ; 1045c4
- callba ClearCmdQueue
- ld a, $3
- call RunMapCallback
- call GetMapHeaderTimeOfDayNybble
- ld [wc2d0], a
- ret
-
-
-EnterMapConnection: ; 1045d6
-; Return carry if a connection has been entered.
- ld a, [wPlayerStepDirection]
- and a
- jp z, EnterSouthConnection
- cp 1
- jp z, EnterNorthConnection
- cp 2
- jp z, EnterWestConnection
- cp 3
- jp z, EnterEastConnection
- ret
-; 1045ed
-
-
-EnterWestConnection: ; 1045ed
- ld a, [WestConnectedMapGroup]
- ld [MapGroup], a
- ld a, [WestConnectedMapNumber]
- ld [MapNumber], a
- ld a, [WestConnectionStripXOffset]
- ld [XCoord], a
- ld a, [WestConnectionStripYOffset]
- ld hl, YCoord
- add [hl]
- ld [hl], a
- ld c, a
- ld hl, WestConnectionWindow
- ld a, [hli]
- ld h, [hl]
- ld l, a
- srl c
- jr z, .skip_to_load
- ld a, [WestConnectedMapWidth]
- add 6
- ld e, a
- ld d, 0
-
-.loop
- add hl, de
- dec c
- jr nz, .loop
-
-.skip_to_load
- ld a, l
- ld [wd194], a
- ld a, h
- ld [wd194 + 1], a
- jp EnteredConnection
-; 104629
-
-
-EnterEastConnection: ; 104629
- ld a, [EastConnectedMapGroup]
- ld [MapGroup], a
- ld a, [EastConnectedMapNumber]
- ld [MapNumber], a
- ld a, [EastConnectionStripXOffset]
- ld [XCoord], a
- ld a, [EastConnectionStripYOffset]
- ld hl, YCoord
- add [hl]
- ld [hl], a
- ld c, a
- ld hl, EastConnectionWindow
- ld a, [hli]
- ld h, [hl]
- ld l, a
- srl c
- jr z, .skip_to_load
- ld a, [EastConnectedMapWidth]
- add 6
- ld e, a
- ld d, 0
-
-.loop
- add hl, de
- dec c
- jr nz, .loop
-
-.skip_to_load
- ld a, l
- ld [wd194], a
- ld a, h
- ld [wd194 + 1], a
- jp EnteredConnection
-; 104665
-
-
-EnterNorthConnection: ; 104665
- ld a, [NorthConnectedMapGroup]
- ld [MapGroup], a
- ld a, [NorthConnectedMapNumber]
- ld [MapNumber], a
- ld a, [NorthConnectionStripYOffset]
- ld [YCoord], a
- ld a, [NorthConnectionStripXOffset]
- ld hl, XCoord
- add [hl]
- ld [hl], a
- ld c, a
- ld hl, NorthConnectionWindow
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld b, 0
- srl c
- add hl, bc
- ld a, l
- ld [wd194], a
- ld a, h
- ld [wd194 + 1], a
- jp EnteredConnection
-; 104696
-
-
-EnterSouthConnection: ; 104696
- ld a, [SouthConnectedMapGroup]
- ld [MapGroup], a
- ld a, [SouthConnectedMapNumber]
- ld [MapNumber], a
- ld a, [SouthConnectionStripYOffset]
- ld [YCoord], a
- ld a, [SouthConnectionStripXOffset]
- ld hl, XCoord
- add [hl]
- ld [hl], a
- ld c, a
- ld hl, SouthConnectionWindow
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld b, 0
- srl c
- add hl, bc
- ld a, l
- ld [wd194], a
- ld a, h
- ld [wd194 + 1], a
- ; fallthrough
-; 1046c4
-
-EnteredConnection: ; 1046c4
- scf
- ret
-; 1046c6
-
-LoadWarpData: ; 1046c6
- call Function1046df
- call Function104718
- ld a, [wd146]
- ld [WarpNumber], a
- ld a, [wd147]
- ld [MapGroup], a
- ld a, [wd148]
- ld [MapNumber], a
- ret
-
-Function1046df: ; 1046df (41:46df)
- call GetMapPermission
- call CheckOutdoorMap
- ret nz
- ld a, [wd147]
- ld b, a
- ld a, [wd148]
- ld c, a
- call GetAnyMapPermission
- call CheckIndoorMap
- ret nz
- ld a, [wd14a]
- cp $f
- jr nz, .asm_104705
- ld a, [wd14b]
- cp $a
- ret z
- cp $c
- ret z
-.asm_104705
- ld a, [wd149]
- ld [wdca9], a
- ld a, [wd14a]
- ld [wdcaa], a
- ld a, [wd14b]
- ld [wdcab], a
- ret
-
-Function104718: ; 104718 (41:4718)
- call GetMapPermission
- call CheckOutdoorMap
- ret nz
- ld a, [wd147]
- ld b, a
- ld a, [wd148]
- ld c, a
- call GetAnyMapPermission
- call CheckIndoorMap
- ret nz
- ld a, [wd147]
- ld b, a
- ld a, [wd148]
- ld c, a
- call GetAnyMapTileset
- ld a, c
- cp $7
- jr z, .asm_104743
- cp $15
- jr z, .asm_104743
- ret
-.asm_104743
- ld a, [wd14a]
- ld [wdcb2], a
- ld a, [wd14b]
- ld [wdcb3], a
- ret
-
-LoadMapTimeOfDay: ; 104750
- ld hl, VramState
- res 6, [hl]
- ld a, $1
- ld [wSpriteUpdatesEnabled], a
- callba Function8c0e5
- callba Function8c001
- call OverworldTextModeSwitch
- call Function104770
- call Function1047a3
- ret
-
-Function104770: ; 104770 (41:4770)
- ld a, VBGMap0 / $100
- ld [wBGMapAnchor + 1], a
- xor a
- ld [wBGMapAnchor], a
- ld [hSCY], a
- ld [hSCX], a
- callba Function5958
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
- xor a
- lb bc, 4, 0
- hlbgcoord 0, 0
- call ByteFill
- pop af
- ld [rVBK], a
- ld a, $60
- lb bc, 4, 0
- hlbgcoord 0, 0
- call ByteFill
- ret
-
-Function1047a3: ; 1047a3 (41:47a3)
- decoord 0, 0
- call .copy
- ld a, [hCGB]
- and a
- ret z
-
- decoord 0, 0, AttrMap
- ld a, $1
- ld [rVBK], a
-.copy:
- hlbgcoord 0, 0
- ld c, SCREEN_WIDTH
- ld b, SCREEN_HEIGHT
-.row
- push bc
-.column
- ld a, [de]
- inc de
- ld [hli], a
- dec c
- jr nz, .column
- ld bc, $20 - SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .row
- ld a, $0
- ld [rVBK], a
- ret
-
-LoadGraphics: ; 1047cf
- call LoadTilesetHeader
- call LoadTileset
- xor a
- ld [hMapAnims], a
- xor a
- ld [hTileAnimFrame], a
- callba RefreshSprites
- call LoadFontsExtra
- callba Function106594
- ret
-
-LoadMapPalettes: ; 1047eb
- ld b, SCGB_09
- jp GetSGBLayout
-; 1047f0
-
-RefreshMapSprites: ; 1047f0
- call ClearSprites
- callba ReturnFromMapSetupScript
- call GetMovementPermissions
- callba Function579d
- callba CheckReplaceKrisSprite
- ld hl, wPlayerSpriteSetupFlags
- bit 6, [hl]
- jr nz, .skip
- ld hl, VramState
- set 0, [hl]
- call Function2e31
-.skip
- ld a, [wPlayerSpriteSetupFlags]
- and $1c
- ld [wPlayerSpriteSetupFlags], a
- ret
-
-CheckMovingOffEdgeOfMap:: ; 104820 (41:4820)
- ld a, [wPlayerStepDirection]
- cp STANDING
- ret z
- and a ; DOWN
- jr z, .down
- cp UP
- jr z, .up
- cp LEFT
- jr z, .left
- cp RIGHT
- jr z, .right
- and a
- ret
-
-.down
- ld a, [PlayerNextMapY]
- sub 4
- ld b, a
- ld a, [MapHeight]
- add a
- cp b
- jr z, .ok
- and a
- ret
-
-.up
- ld a, [PlayerNextMapY]
- sub 4
- cp -1
- jr z, .ok
- and a
- ret
-
-.left
- ld a, [PlayerNextMapX]
- sub $4
- cp -1
- jr z, .ok
- and a
- ret
-
-.right
- ld a, [PlayerNextMapX]
- sub 4
- ld b, a
- ld a, [MapWidth]
- add a
- cp b
- jr z, .ok
- and a
- ret
-
-.ok
- scf
- ret
-
-
-GetCoordOfUpperLeftCorner:: ; 10486d
- ld hl, OverworldMap
- ld a, [XCoord]
- bit 0, a
- jr nz, .increment_then_halve1
- srl a
- add $1
- jr .resume
-
-.increment_then_halve1
- add $1
- srl a
-
-.resume
- ld c, a
- ld b, $0
- add hl, bc
- ld a, [MapWidth]
- add $6
- ld c, a
- ld b, $0
- ld a, [YCoord]
- bit 0, a
- jr nz, .increment_then_halve2
- srl a
- add $1
- jr .resume2
-
-.increment_then_halve2
- add $1
- srl a
-
-.resume2
- call AddNTimes
- ld a, l
- ld [wd194], a
- ld a, h
- ld [wd194 + 1], a
- ld a, [YCoord]
- and $1
- ld [wd196], a
- ld a, [XCoord]
- and $1
- ld [wd197], a
- ret
-; 1048ba
+INCLUDE "engine/warp_connection.asm"
INCLUDE "engine/mysterygift.asm"
@@ -24305,8 +15326,9 @@ INCLUDE "battle/used_move_text.asm"
INCLUDE "misc/mobile_41.asm"
-INCLUDE "misc/mobile_42.asm"
+SECTION "bank42", ROMX, BANK[$42]
+INCLUDE "misc/mobile_42.asm"
SECTION "Intro Logo", ROMX, BANK[$42]
@@ -24314,13 +15336,10 @@ IntroLogoGFX: ; 109407
INCBIN "gfx/intro/logo.2bpp.lz"
; 109847
-
INCLUDE "misc/unused_title.asm"
-
INCLUDE "engine/title.asm"
-
INCLUDE "misc/mobile_45.asm"
INCLUDE "misc/mobile_46.asm"
@@ -24331,6 +15350,7 @@ INCLUDE "misc/battle_tower_47.asm"
SECTION "bank5B", ROMX, BANK[$5B]
INCLUDE "misc/mobile_5b.asm"
+INCLUDE "engine/link_trade.asm"
SECTION "bank5C", ROMX, BANK[$5C]
@@ -24340,7 +15360,6 @@ SECTION "bank5D", ROMX, BANK[$5D]
INCLUDE "text/phone/extra3.asm"
-
SECTION "bank5E", ROMX, BANK[$5E]
_UpdateBattleHUDs:
@@ -24354,10 +15373,8 @@ _UpdateBattleHUDs:
ret
; 17801f (5e:401f)
-
INCLUDE "misc/mobile_5f.asm"
-
SECTION "Common Text 1", ROMX, BANK[$6C]
INCLUDE "text/stdtext.asm"
@@ -24380,7 +15397,6 @@ INCLUDE "text/phone/bill.asm"
INCLUDE "text/phone/elm.asm"
INCLUDE "text/phone/trainers1.asm"
-
SECTION "bank72", ROMX, BANK[$72]
ItemNames::
@@ -24393,375 +15409,17 @@ INCLUDE "battle/move_names.asm"
INCLUDE "engine/landmarks.asm"
-
SECTION "bank75", ROMX, BANK[$75]
-
SECTION "bank76", ROMX, BANK[$76]
-
SECTION "bank77", ROMX, BANK[$77]
UnownFont: ; 1dc000
INCBIN "gfx/misc/unown_font.2bpp"
; 1dc1b0
-Function1dc1b0: ; 1dc1b0
- hlcoord 0, 0
- ld de, wca90
- ld bc, 17 * SCREEN_WIDTH
- call CopyBytes
- ld hl, wcab5
- ld a, $62
- ld [hli], a
- inc a
- ld [hl], a
- ld hl, wcac9
- ld a, $64
- ld [hli], a
- inc a
- ld [hl], a
- ld hl, wcb45
- ld a, " "
- ld [hli], a
- ld [hl], a
- ld hl, wcb59
- ld a, $61
- ld [hli], a
- ld [hl], a
- ld hl, wcb6e
- lb bc, 5, 18
- call ClearBox
- ld a, [wd265]
- dec a
- call CheckCaughtMon
- push af
- ld a, [wd265]
- ld b, a
- ld c, $1
- callba Function44355
- pop af
- ld a, b
- ld hl, wcb6d
- call nz, FarString
- ld hl, wcaa3
- ld [hl], $35
- ld de, SCREEN_WIDTH
- add hl, de
- ld b, $f
-.asm_1dc20a
- ld [hl], $37
- add hl, de
- dec b
- jr nz, .asm_1dc20a
- ld [hl], $3a
- ret
-; 1dc213
-
-Function1dc213: ; 1dc213
- ld hl, wca90
- ld bc, $a0
- ld a, " "
- call ByteFill
- ld hl, wca90
- ld a, $36
- ld b, $6
- call Function1dc26a
- ld hl, wcaa3
- ld a, $37
- ld b, $6
- call Function1dc26a
- ld hl, wcb08
- ld [hl], $38
- inc hl
- ld a, $39
- ld bc, SCREEN_HEIGHT
- call ByteFill
- ld [hl], $3a
- ld hl, wcb1c
- ld bc, SCREEN_WIDTH
- ld a, $32
- call ByteFill
- ld a, [wd265]
- dec a
- call CheckCaughtMon
- push af
- ld a, [wd265]
- ld b, a
- ld c, $2
- callba Function44355
- pop af
- ld hl, wcaa5
- ld a, b
- call nz, FarString
- ret
-; 1dc26a
-
-Function1dc26a: ; 1dc26a
- push de
- ld de, SCREEN_WIDTH
-.asm_1dc26e
- ld [hl], a
- add hl, de
- dec b
- jr nz, .asm_1dc26e
- pop de
- ret
-; 1dc275
-
-GBPrinterStrings:
-String_1dc275: db "@"
-String_1dc276: next " CHECKING LINK...@"
-String_1dc289: next " TRANSMITTING...@"
-String_1dc29c: next " PRINTING...@"
-String_1dc2ad:
- db " Printer Error 1"
- next ""
- next "Check the Game Boy"
- next "Printer Manual."
- db "@"
-String_1dc2e2:
- db " Printer Error 2"
- next ""
- next "Check the Game Boy"
- next "Printer Manual."
- db "@"
-String_1dc317:
- db " Printer Error 3"
- next ""
- next "Check the Game Boy"
- next "Printer Manual."
- db "@"
-String_1dc34c:
- db " Printer Error 4"
- next ""
- next "Check the Game Boy"
- next "Printer Manual."
- db "@"
-; 1dc381
-
-Function1dc381: ; 1dc381
- call ClearBGPalettes
- call ClearTileMap
- call ClearSprites
- xor a
- ld [hBGMapMode], a
- call LoadFontsBattleExtra
-
- ld de, MobileHPIcon
- ld hl, VTiles2 tile $71
- lb bc, BANK(MobileHPIcon), 1
- call Request1bpp
-
- ld de, MobileLvIcon
- ld hl, VTiles2 tile $6e
- lb bc, BANK(MobileLvIcon), 1
- call Request1bpp
-
- ld de, ShinyIcon
- ld hl, VTiles2 tile $3f
- lb bc, BANK(ShinyIcon), 1
- call Get2bpp
-
- xor a
- ld [MonType], a
- callba CopyPkmnToTempMon
- hlcoord 0, 7
- ld b, 9
- ld c, 18
- call TextBox
- hlcoord 8, 2
- ld a, [TempMonLevel]
- call Function383d
- hlcoord 12, 2
- ld [hl], "◀" ; Filled left triangle
- inc hl
- ld de, TempMonMaxHP
- lb bc, 2, 3
- call PrintNum
- ld a, [CurPartySpecies]
- ld [wd265], a
- ld [CurSpecies], a
- ld hl, PartyMonNicknames
- call Function1dc50e
- hlcoord 8, 4
- call PlaceString
- hlcoord 9, 6
- ld [hl], "/"
- call GetPokemonName
- hlcoord 10, 6
- call PlaceString
- hlcoord 8, 0
- ld [hl], "№"
- inc hl
- ld [hl], "."
- inc hl
- ld de, wd265
- lb bc, PRINTNUM_LEADINGZEROS | 1, 3
- call PrintNum
- hlcoord 1, 9
- ld de, String1dc550
- call PlaceString
- ld hl, PartyMonOT
- call Function1dc50e
- hlcoord 4, 9
- call PlaceString
- hlcoord 1, 11
- ld de, String1dc559
- call PlaceString
- hlcoord 4, 11
- ld de, TempMonID
- lb bc, PRINTNUM_LEADINGZEROS | 2, 5
- call PrintNum
- hlcoord 1, 14
- ld de, String1dc554
- call PlaceString
- hlcoord 7, 14
- ld a, [TempMonMoves + 0]
- call Function1dc51a
- call Function1dc52c
- ld hl, TempMonDVs
- predef GetUnownLetter
- ld hl, wc2c6
- xor a
- ld [hl], a
- ld a, [CurPartySpecies]
- cp UNOWN
- jr z, .asm_1dc469
- inc [hl]
-
-.asm_1dc469
- hlcoord 0, 0
- call _PrepMonFrontpic
- call WaitBGMap
- ld b, SCGB_03
- call GetSGBLayout
- call SetPalettes
- ret
-; 1dc47b
-
-Function1dc47b: ; 1dc47b
- call ClearBGPalettes
- call ClearTileMap
- call ClearSprites
- xor a
- ld [hBGMapMode], a
- call LoadFontsBattleExtra
- xor a
- ld [MonType], a
- callba CopyPkmnToTempMon
- hlcoord 0, 0
- ld b, 15
- ld c, 18
- call TextBox
- ld bc, SCREEN_WIDTH
- decoord 0, 0
- hlcoord 0, 1
- call CopyBytes
- hlcoord 7, 0
- ld a, [TempMonMoves + 1]
- call Function1dc51a
- hlcoord 7, 2
- ld a, [TempMonMoves + 2]
- call Function1dc51a
- hlcoord 7, 4
- ld a, [TempMonMoves + 3]
- call Function1dc51a
- hlcoord 7, 7
- ld de, String1dc55d
- call PlaceString
- hlcoord 16, 7
- ld de, TempMonAttack
- call .PrintTempMonStats
- hlcoord 16, 9
- ld de, TempMonDefense
- call .PrintTempMonStats
- hlcoord 16, 11
- ld de, TempMonSpclAtk
- call .PrintTempMonStats
- hlcoord 16, 13
- ld de, TempMonSpclDef
- call .PrintTempMonStats
- hlcoord 16, 15
- ld de, TempMonSpeed
- call .PrintTempMonStats
- call WaitBGMap
- ld b, SCGB_03
- call GetSGBLayout
- call SetPalettes
- ret
-; 1dc507
-
-.PrintTempMonStats: ; 1dc507
- lb bc, 2, 3
- call PrintNum
- ret
-; 1dc50e
-
-Function1dc50e: ; 1dc50e
- ld bc, NAME_LENGTH
- ld a, [CurPartyMon]
- call AddNTimes
- ld e, l
- ld d, h
- ret
-; 1dc51a
-
-Function1dc51a: ; 1dc51a
- and a
- jr z, .no_move
-
- ld [wd265], a
- call GetMoveName
- jr .got_string
-
-.no_move
- ld de, String1dc584
-
-.got_string
- call PlaceString
- ret
-; 1dc52c
-
-Function1dc52c: ; 1dc52c
- callba GetGender
- ld a, " "
- jr c, .got_gender
- ld a, "♂"
- jr nz, .got_gender
- ld a, "♀"
-
-.got_gender
- hlcoord 17, 2
- ld [hl], a
- ld bc, TempMonDVs
- callba CheckShininess
- ret nc
- hlcoord 18, 2
- ld [hl], "<SHINY>"
- ret
-; 1dc550
-
-String1dc550: ; 1dc550
- db "OT/@"
-
-String1dc554: ; 1dc554
- db "MOVE@"
-
-String1dc559: ; 1dc559
- db "<ID>№.@"
-
-String1dc55d: ; 1dc55d
- db "ATTACK"
- next "DEFENSE"
- next "SPCL.ATK"
- next "SPCL.DEF"
- next "SPEED"
- db "@"
-
-String1dc584: ; 1dc584
- db "------------@"
-; 1dc591
+INCLUDE "misc/printer_77.asm"
MobileHPIcon: ; 1dc591
INCBIN "gfx/mobile/hp.1bpp"
@@ -24769,14 +15427,10 @@ INCBIN "gfx/mobile/hp.1bpp"
MobileLvIcon: ; 1dc599
INCBIN "gfx/mobile/lv.1bpp"
-
-
SECTION "Tileset Data 7", ROMX, BANK[TILESETS_7]
INCLUDE "tilesets/data_7.asm"
-
-
SECTION "bank77_2", ROMX, BANK[$77]
Function1dd6a9: ; 1dd6a9
@@ -24846,11 +15500,9 @@ String_AM: db "AM@" ; 1dd6fc
String_PM: db "PM@" ; 1dd6ff
; 1dd702
-
INCLUDE "engine/diploma.asm"
-
-Function1ddf1c: ; 1ddf1c
+LoadSGBPokedexGFX: ; 1ddf1c
ld hl, LZ_1ddf33
ld de, VTiles2 tile $31
call Decompress
@@ -24866,21 +15518,21 @@ Function1ddf26: ; 1ddf26 (77:5f26)
; 1ddf33 (77:5f33)
LZ_1ddf33: ; 1ddf33
-INCBIN "gfx/unknown/1ddf33.2bpp.lz"
+INCBIN "gfx/pokedex/sgb.2bpp.lz"
; 1de0d7
-Function1de0d7: ; 1de0d7
- ld hl, LZ_1de0e1
+LoadQuestionMarkPic: ; 1de0d7
+ ld hl, .QuestionMarkLZ
ld de, sScratch
call Decompress
ret
; 1de0e1
-LZ_1de0e1: ; 1de0e1
-INCBIN "gfx/unknown/1de0e1.2bpp.lz"
+.QuestionMarkLZ: ; 1de0e1
+INCBIN "gfx/pics/questionmark/front.2bpp.lz"
; 1de171
-Function1de171: ; 1de171 (77:6171)
+DrawPokedexListWindow: ; 1de171 (77:6171)
ld a, $32
hlcoord 0, 17
ld bc, 12
@@ -24890,46 +15542,49 @@ Function1de171: ; 1de171 (77:6171)
call ClearBox
ld a, $34
hlcoord 0, 0
- ld bc, $b
+ ld bc, 11
call ByteFill
ld a, $39
hlcoord 0, 16
- ld bc, $b
+ ld bc, 11
call ByteFill
hlcoord 5, 0
ld [hl], $3f
hlcoord 5, 16
ld [hl], $40
- ld a, [wc7d4]
- cp $1
- jr z, .asm_1de1bf
+ ld a, [wCurrentDexMode]
+ cp DEXMODE_OLD
+ jr z, .OldMode
+; scroll bar
hlcoord 11, 0
ld [hl], $50
ld a, $51
hlcoord 11, 1
ld b, SCREEN_HEIGHT - 3
- call Function1de27f
+ call Bank77_FillColumn
ld [hl], $52
- jr .asm_1de1d0
-.asm_1de1bf
+ jr .Done
+
+.OldMode
+; no scroll bar
hlcoord 11, 0
ld [hl], $66
ld a, $67
hlcoord 11, 1
ld b, SCREEN_HEIGHT - 3
- call Function1de27f
+ call Bank77_FillColumn
ld [hl], $68
-.asm_1de1d0
+.Done
ret
-Function1de1d1: ; 1de1d1 (77:61d1)
+DrawPokedexSearchResultsWindow: ; 1de1d1 (77:61d1)
ld a, $34
hlcoord 0, 0
- ld bc, $b
+ ld bc, 11
call ByteFill
ld a, $39
hlcoord 0, 10
- ld bc, $b
+ ld bc, 11
call ByteFill
hlcoord 5, 0
ld [hl], $3f
@@ -24940,35 +15595,36 @@ Function1de1d1: ; 1de1d1 (77:61d1)
ld a, $67
hlcoord 11, 1
ld b, SCREEN_HEIGHT / 2
- call Function1de27f
+ call Bank77_FillColumn
ld [hl], $68
ld a, $34
hlcoord 0, 11
- ld bc, $b
+ ld bc, 11
call ByteFill
ld a, $39
hlcoord 0, 17
- ld bc, $b
+ ld bc, 11
call ByteFill
hlcoord 11, 11
ld [hl], $66
ld a, $67
hlcoord 11, 12
ld b, 5
- call Function1de27f
+ call Bank77_FillColumn
ld [hl], $68
hlcoord 0, 12
lb bc, 5, 11
call ClearBox
- ld de, String_1de23c
+ ld de, .esults_D
hlcoord 0, 12
call PlaceString
ret
; 1de23c (77:623c)
-String_1de23c: ; 1de23c
-; At a glance, this is less coherent in the Japanese charset.
+.esults_D: ; 1de23c
+; (SEARCH R)
db "ESULTS<NEXT>"
+; (### FOUN)
next "D!@"
; 1de247
@@ -24987,16 +15643,16 @@ Function1de247: ; 1de247
ld [hl], $66
hlcoord 19, 1
ld a, $67
- ld b, SCREEN_HEIGHT - 3
- call Function1de27f
+ ld b, 15
+ call Bank77_FillColumn
ld [hl], $68
hlcoord 19, 17
ld [hl], $3c
xor a
ld b, SCREEN_HEIGHT
hlcoord 19, 0, AttrMap
- call Function1de27f
- call Function3200
+ call Bank77_FillColumn
+ call WaitBGMap2
pop hl
ld a, l
ld [hBGMapAddress], a
@@ -25005,7 +15661,7 @@ Function1de247: ; 1de247
ret
; 1de27f
-Function1de27f: ; 1de27f
+Bank77_FillColumn: ; 1de27f
push de
ld de, SCREEN_WIDTH
.loop
@@ -25017,8 +15673,6 @@ Function1de27f: ; 1de27f
ret
; 1de28a
-
-
_DudeAutoInput_A:: ; 1de28a
ld hl, DudeAutoInput_A
jr _DudeAutoInput
@@ -25040,7 +15694,6 @@ _DudeAutoInput: ; 1de299
ret
; 1de29f
-
DudeAutoInputs:
DudeAutoInput_A: ; 1de29f
@@ -25071,7 +15724,6 @@ DudeAutoInput_DownA: ; 1de2af
db NO_INPUT, $ff ; end
; 1de2c5
-
Function1de2c5: ; 1de2c5
ld hl, StringBuffer1
.loop
@@ -25233,28 +15885,22 @@ LeggiPostaInglese:
ret
; 1df238
-
SECTION "Tileset Data 8", ROMX, BANK[TILESETS_8]
INCLUDE "tilesets/data_8.asm"
-
SECTION "bank79", ROMX, BANK[$79]
-
SECTION "bank7A", ROMX, BANK[$7A]
-
SECTION "bank7B", ROMX, BANK[$7B]
INCLUDE "text/battle_tower.asm"
-
SECTION "bank7C", ROMX, BANK[$7C]
INCLUDE "data/battle_tower_2.asm"
-
SECTION "bank7D", ROMX, BANK[$7D]
db $cc, $6b, $1e ; XXX
@@ -25301,16 +15947,13 @@ Function1f5d9f: ; 1f5d9f
Unknown_1f5db4:
INCBIN "unknown/1f5db4.bin"
-
SECTION "bank7E", ROMX, BANK[$7E]
INCLUDE "data/battle_tower.asm"
INCLUDE "data/odd_eggs.asm"
-
SECTION "bank7F", ROMX, BANK[$7F]
-
SECTION "stadium2", ROMX[$8000-$220], BANK[$7F]
IF DEF(CRYSTAL11)