summaryrefslogtreecommitdiff
path: root/main.asm
diff options
context:
space:
mode:
Diffstat (limited to 'main.asm')
-rw-r--r--main.asm563
1 files changed, 274 insertions, 289 deletions
diff --git a/main.asm b/main.asm
index 9b39ebcc7..077205a37 100644
--- a/main.asm
+++ b/main.asm
@@ -1574,9 +1574,7 @@ Function1c07: ; 0x1c07
ret
Function1c10: ; 0x1c10
- ld hl, $446d
- ld a, $9
- rst $8
+ callab Function2446d
ret
Function1c17: ; 0x1c17
@@ -4630,9 +4628,7 @@ Function2b74: ; 0x2b74
call Function3200
ld b, $9
call GetSGBLayout
- ld a, $12
- ld hl, $5409
- rst $8
+ callba Function49409
call Function485
call DelayFrame
ld a, $1
@@ -5553,20 +5549,20 @@ Function2f66: ; 2f66
ret
; 2f79
-Function2f79: ; 2f79
+PickUpItem: ; 2f79
push hl
push de
push bc
ld a, [hROMBank]
push af
- ld a, BANK(Functiond244)
+ ld a, BANK(_PickUpItem)
rst Bankswitch
- call Functiond244
+ call _PickUpItem
+
pop bc
ld a, b
rst Bankswitch
-
pop bc
pop de
pop hl
@@ -5574,50 +5570,50 @@ Function2f79: ; 2f79
; 2f8c
-RNG: ; 2f8c
+Random: ; 2f8c
+; A simple hardware-based random number generator (RNG).
+
; Two random numbers are generated by adding and subtracting
; the divider to the respective values every time it's called.
-; The divider is a value that increments at a rate of 16384Hz.
+; The divider is a register that increments at a rate of 16384Hz.
; For comparison, the Game Boy operates at a clock speed of 4.2MHz.
-; Additionally, an equivalent function is called every frame.
+; Additionally, an equivalent function is executed in VBlank.
-; output:
-; a: rand2
-; ffe1: rand1
-; ffe2: rand2
+; This leaves a with the value in hRandomSub.
push bc
-; Added value
+
ld a, [rDIV]
ld b, a
ld a, [hRandomAdd]
adc b
ld [hRandomAdd], a
-; Subtracted value
+
ld a, [rDIV]
ld b, a
ld a, [hRandomSub]
sbc b
ld [hRandomSub], a
+
pop bc
ret
; 2f9f
-FarBattleRNG: ; 2f9f
-; BattleRNG lives in another bank.
-; It handles all RNG calls in the battle engine,
-; allowing link battles to remain in sync using a shared PRNG.
+BattleRandom: ; 2f9f
+; _BattleRandom lives in another bank.
+
+; It handles all RNG calls in the battle engine, allowing
+; link battles to remain in sync using a shared PRNG.
-; Save bank
- ld a, [hROMBank] ; bank
+ ld a, [hROMBank]
push af
-; Bankswitch
- ld a, BANK(BattleRNG)
+ ld a, BANK(_BattleRandom)
rst Bankswitch
- call BattleRNG
-; Restore bank
+
+ call _BattleRandom
+
ld [$cfb6], a
pop af
rst Bankswitch
@@ -5638,7 +5634,7 @@ Function2fb1: ; 2fb1
ld b, a
push bc
.asm_2fbb
- call RNG
+ call Random
ld a, [hRandomAdd]
ld c, a
add b
@@ -7378,19 +7374,20 @@ Function3718: ; 3718
-Function3741: ; 3741
+IsAPokemon: ; 3741
+; Return carry if species a is not a Pokemon.
and a
- jr z, .asm_374c
- cp $fd
- jr z, .asm_374e
- cp $fc
- jr c, .asm_374e
+ jr z, .NotAPokemon
+ cp EGG
+ jr z, .Pokemon
+ cp NUM_POKEMON + 1
+ jr c, .Pokemon
-.asm_374c
+.NotAPokemon
scf
ret
-.asm_374e
+.Pokemon
and a
ret
; 3750
@@ -7464,7 +7461,7 @@ Function3786: ; 3786
Function378b: ; 378b
ld a, [CurPartySpecies]
- call Function3741
+ call IsAPokemon
jr c, .asm_37ad
push hl
ld de, VTiles2
@@ -8181,24 +8178,25 @@ MobileTextBorder: ; 3ab2
BattleTextBox: ; 3ac3
+; Open a textbox and print text at hl.
push hl
call SpeechTextBox
call MobileTextBorder
- call Function1ad2 ; UpdateSprites
- call Function321c ; refresh?
+ call Function1ad2
+ call Function321c
pop hl
call PrintTextBoxText
ret
; 3ad5
-FarBattleTextBox: ; 3ad5
-; Open a textbox and print text at 20:hl.
+StdBattleTextBox: ; 3ad5
+; Open a textbox and print battle text at 20:hl.
ld a, [hROMBank]
push af
- ld a, $20
+ ld a, BANK(BattleText)
rst Bankswitch
call BattleTextBox
@@ -10419,14 +10417,14 @@ Function4821: ; 4821
; 4822
Function4822: ; 4822
- call RNG
+ call Random
ld a, [hRandomAdd]
and 1
jp Function4af0
; 482c
Function482c: ; 482c
- call RNG
+ call Random
ld a, [hRandomAdd]
and 1
or 2
@@ -10434,14 +10432,14 @@ Function482c: ; 482c
; 4838
Function4838: ; 4838
- call RNG
+ call Random
ld a, [hRandomAdd]
and 3
jp Function4af0
; 4842
Function4842: ; 4842
- call RNG
+ call Random
ld a, [hRandomAdd]
and $c
ld hl, $0008
@@ -10456,7 +10454,7 @@ Function4851: ; 4851
ld a, [hl]
and $c
ld d, a
- call RNG
+ call Random
ld a, [hRandomAdd]
and $c
cp d
@@ -10959,14 +10957,14 @@ Function4b17: ; 4b17
; 4b1d
Function4b1d: ; 4b1d
- call RNG
+ call Random
ld a, [hRandomAdd]
and $7f
jr Function4b2d
; 4b26
Function4b26: ; 4b26
- call RNG
+ call Random
ld a, [hRandomAdd]
and $1f
; fallthrough
@@ -13251,10 +13249,10 @@ Function5bae: ; 5bae
ld a, [hRandomAdd]
ld [PlayerID + 1], a
- call RNG
+ call Random
ld [$d84a], a
call DelayFrame
- call RNG
+ call Random
ld [$d84b], a
ld hl, PartyCount
@@ -13314,8 +13312,8 @@ Function5bae: ; 5bae
ld [JohtoBadges], a
ld [KantoBadges], a
- ld [$d855], a
- ld [$d856], a
+ ld [Coins], a
+ ld [Coins + 1], a
ld [Money], a
ld a, 3000 >> 8
@@ -13463,9 +13461,9 @@ Function5d33: ; 5d33
jr z, .asm_5d55
ld a, b
ld [$ac68], a
- call RNG
+ call Random
ld c, a
- call RNG
+ call Random
.asm_5d55
ld [$dc9f], a
@@ -13996,42 +13994,54 @@ Function60fa: ; 60fa
; 610f
Function610f: ; 610f
+
ld a, [hROMBank]
push af
- ld a, $20
+
+ ld a, 0 << 7 | 32 ; fade out
ld [MusicFade], a
ld de, MUSIC_NONE
ld a, e
ld [MusicFadeIDLo], a
ld a, d
ld [MusicFadeIDHi], a
+
ld de, SFX_ESCAPE_ROPE
call StartSFX
pop af
rst Bankswitch
- ld c, $8
+ ld c, 8
call DelayFrames
+
ld hl, $5249
ld b, $13
call Function61b4
- ld c, $8
+
+ ld c, 8
call DelayFrames
+
ld hl, $52d9
ld b, $13
call Function61b4
- ld c, $8
+
+ ld c, 8
call DelayFrames
+
ld hl, $c50a
- ld b, $7
- ld c, $7
+ ld b, 7
+ ld c, 7
call ClearBox
- ld c, $3
+
+ ld c, 3
call DelayFrames
+
call Function61cd
call Functione5f
- ld c, $32
+
+ ld c, 50
call DelayFrames
+
call Function4b6
call ClearTileMap
ret
@@ -14039,11 +14049,11 @@ Function610f: ; 610f
Function616a: ; 616a
ld hl, IntroFadePalettes
- ld b, $6
+ ld b, IntroFadePalettesEnd - IntroFadePalettes
.asm_616f
ld a, [hli]
call DmgToCgbBGPals
- ld c, $a
+ ld c, 10
call DelayFrames
dec b
jr nz, .asm_616f
@@ -14057,6 +14067,7 @@ IntroFadePalettes: ; 0x617c
db %11111000
db %11110100
db %11100100
+IntroFadePalettesEnd
; 6182
Function6182: ; 6182
@@ -14102,14 +14113,17 @@ Function61b4: ; 61b4
; 61cd
Function61cd: ; 61cd
+
callba GetPlayerIcon
ld c, $c
ld hl, VTiles0
call Request2bpp
+
ld hl, Sprites
ld de, .data_61fe
ld a, [de]
inc de
+
ld c, a
.asm_61e4
ld a, [de]
@@ -14121,14 +14135,15 @@ Function61cd: ; 61cd
ld a, [de]
inc de
ld [hli], a
- ld b, $0
+
+ ld b, 0
ld a, [PlayerGender]
bit 0, a
jr z, .asm_61f8
- ld b, $1
-
+ ld b, 1
.asm_61f8
ld a, b
+
ld [hli], a
dec c
jr nz, .asm_61e4
@@ -14158,7 +14173,7 @@ Function620b: ; 620b
push af
ld a, $5
ld [rSVBK], a
- call FarStartTitleScreen
+ call TitleScreen
call DelayFrame
.asm_6226
call Function627b
@@ -14186,7 +14201,6 @@ Function620b: ; 620b
cp $5
jr c, .asm_625e
xor a
-
.asm_625e
ld e, a
ld d, 0
@@ -14208,8 +14222,8 @@ Function620b: ; 620b
; 6274
-FarStartTitleScreen: ; 6274
- callba StartTitleScreen
+TitleScreen: ; 6274
+ callba _TitleScreen
ret
; 627b
@@ -15950,7 +15964,7 @@ DaycareStep: ; 7282
dec [hl]
ret nz
- call RNG
+ call Random
ld [hl], a
ld hl, $6e1d
ld a, $5
@@ -15970,7 +15984,7 @@ DaycareStep: ; 7282
ld b, $a
.asm_72f8
- call RNG
+ call Random
cp b
ret nc
ld hl, DaycareMan
@@ -16167,7 +16181,7 @@ Function7420: ; 7420
call GetCurNick
call Function746e
pop hl
- call RNG
+ call Random
.next
sub [hl]
jr c, .asm_7444
@@ -19499,7 +19513,7 @@ Functioncbd8: ; cbd8
ld a, [Buffer2]
cp $2
jr nz, .asm_cbf7
- ld hl, $4c35
+ ld hl, UnknownScript_0xcc35
call Function31cd
ld a, $81
ret
@@ -20262,7 +20276,7 @@ Functiond20d: ; d20d
jp Functiond2ff
; d244
-Functiond244: ; d244
+_PickUpItem: ; d244
call Functiond27b
jr nz, .asm_d278
push hl
@@ -20982,9 +20996,9 @@ Functiond88c: ; d88c
ld a, [IsInBattle]
and a
jr nz, .asm_d9f3
- call RNG
+ call Random
ld b, a
- call RNG
+ call Random
ld c, a
.asm_d9b5
@@ -22011,9 +22025,9 @@ Functione277: ; e277
call GetFarByte
ld b, a
ld hl, $ad2c
- call RNG
+ call Random
ld [hli], a
- call RNG
+ call Random
ld [hl], a
call CloseSRAM
ld a, $13
@@ -23576,9 +23590,7 @@ StartMenu: ; 125cd
call .DrawBugContestStatusBox
call Function2e31
call Function2e20
- ld a, $1
- ld hl, $64bf
- rst $8
+ callba Function64bf
call .DrawBugContestStatus
call Function485
jr .Select
@@ -24918,7 +24930,7 @@ INCBIN "baserom.gbc", $12f5b, $12fba - $12f5b
Function12fba: ; 12fba
ld a, [CurPartySpecies]
- cp $fd
+ cp EGG
jr z, .asm_12fd2
ld hl, Options
ld a, [hl]
@@ -25031,13 +25043,13 @@ Function1308f: ; 1308f
inc a
ld [CurPartyMon], a
ld c, a
- ld b, $0
+ ld b, 0
ld hl, PartySpecies
add hl, bc
ld a, [hl]
cp $ff
jr z, .asm_130a7
- cp $fd
+ cp EGG
ret nz
jr .asm_1308f
@@ -25050,11 +25062,11 @@ Function1308f: ; 1308f
dec a
ld [CurPartyMon], a
ld c, a
- ld b, $0
+ ld b, 0
ld hl, PartySpecies
add hl, bc
ld a, [hl]
- cp $fd
+ cp EGG
ret nz
ld a, [CurPartyMon]
and a
@@ -25308,16 +25320,16 @@ Function132da: ; 132da
ret z
ld c, a
ld e, a
- ld d, $0
+ ld d, 0
ld hl, PartyCount
add hl, de
.asm_132e7
ld a, [hl]
and a
jr z, .asm_132f3
- cp $fd
+ cp EGG
jr z, .asm_132f3
- cp $fc
+ cp NUM_POKEMON + 1
jr c, .asm_132f8
.asm_132f3
@@ -25340,7 +25352,7 @@ Function132fe: ; 132fe
cp c
ret z
ld e, c
- ld d, $0
+ ld d, 0
ld hl, PartySpecies
add hl, de
.asm_1330f
@@ -25349,9 +25361,9 @@ Function132fe: ; 132fe
ret z
and a
jr z, .asm_1331e
- cp $fd
+ cp EGG
jr z, .asm_1331e
- cp $fc
+ cp NUM_POKEMON + 1
jr c, .asm_13321
.asm_1331e
@@ -25359,8 +25371,8 @@ Function132fe: ; 132fe
jr .asm_1330f
.asm_13321
- ld hl, $c4b2
- ld [hl], $ed
+ hlcoord 18, 0
+ ld [hl], "▶"
ret
; 13327
@@ -28453,9 +28465,7 @@ Function157e9: ; 0x157e9
.askquantity
ld hl, .HowManyText
call Function1d4f
- ld a, $9
- ld hl, $4fbf
- rst $8
+ callba Function24fbf
call Function1c07
call Function1c07
jr c, .done
@@ -28550,20 +28560,14 @@ KrisDepositItemMenu: ; 0x1588b
jr c, .asm_158b6
call Function2ed3
call Function1d6e
- ld a, $4
- ld hl, $46a5
- rst $8
+ callba Function106a5
.asm_1589c
- ld a, $4
- ld hl, $46be
- rst $8
+ callba Function106be
ld a, [$cf66]
and a
jr z, .asm_158b3
call Function158cc
- ld a, $4
- ld hl, CheckRegisteredItem
- rst $8
+ callba CheckRegisteredItem
jr .asm_1589c
.asm_158b3
@@ -28595,9 +28599,7 @@ Function158cc: ; 0x158cc
push af
ld a, $0
ld [$c2ce], a
- ld a, $3
- ld hl, $5453
- rst $8
+ callba CheckItemMenu
ld a, [$d142]
ld hl, JumpTable158e7
rst JumpTable
@@ -28631,9 +28633,7 @@ JumpTable158e7: ; 0x158e7
; 0x1590a
Function1590a: ; 0x1590a
- ld a, $3
- ld hl, $5427
- rst $8
+ callba _CheckTossableItem
ld a, [$d142]
and a
jr z, .asm_1591d
@@ -28644,9 +28644,7 @@ Function1590a: ; 0x1590a
.asm_1591d
ld hl, .HowManyText
call Function1d4f
- ld a, $9
- ld hl, $4fbf
- rst $8
+ callba Function24fbf
push af
call Function1c07
call Function1c07
@@ -28698,9 +28696,7 @@ Function1590a: ; 0x1590a
KrisMailBoxMenu: ; 0x1597d
- ld a, $11
- ld hl, $47a0
- rst $8
+ callba _KrisMailBoxMenu
xor a
ret
; 0x15985
@@ -29656,7 +29652,7 @@ Function16053: ; 16053
Function1606f: ; 1606f
ld a, $2
- ld de, $d855
+ ld de, Coins
call $6055
ld a, $2
ld bc, $608d
@@ -29681,7 +29677,7 @@ INCBIN "baserom.gbc", $1608d, $1608f - $1608d
Function1608f: ; 1608f
ld a, $2
- ld de, $d855
+ ld de, Coins
call $6037
jr nc, .asm_1609f
xor a
@@ -29698,7 +29694,7 @@ Function1608f: ; 1608f
Function160a1: ; 160a1
ld a, $2
- ld de, $d855
+ ld de, Coins
jp $600d
; 160a9
@@ -32087,7 +32083,7 @@ Function24b25: ; 24b25
ld hl, $c4c5
ld de, String24b8e
call PlaceString
- ld de, $d855
+ ld de, Coins
ld bc, $0204
ld hl, $c4c1
call PrintNum
@@ -32110,7 +32106,7 @@ Function24b4e: ; 24b4e
ld de, CoinString
call PlaceString
ld hl, $c4eb
- ld de, $d855
+ ld de, Coins
ld bc, $0204
call PrintNum
ret
@@ -32240,7 +32236,7 @@ Function24c64: ; 24c64
push hl
ld [CurItem], a
ld hl, NumItems
- call Function2f79
+ call PickUpItem
pop hl
jr nc, .asm_24c89
ld a, [hl]
@@ -33730,7 +33726,7 @@ Function2a103: ; 2a103
call Function2a111
call Function2a124
call Function2a138
- call RNG
+ call Random
cp b
ret
; 2a111
@@ -33809,7 +33805,7 @@ Function2a14f: ; 2a14f
.asm_2a174
push hl
.asm_2a175
- call RNG
+ call Random
cp 100
jr nc, .asm_2a175
inc a
@@ -33833,7 +33829,7 @@ Function2a14f: ; 2a14f
call Function1852
jr nz, .asm_2a1aa
- call RNG
+ call Random
cp 89
jr c, .asm_2a1aa
inc b
@@ -34078,7 +34074,7 @@ Function2a2ce: ; 2a2ce
call Function1852
jr z, .asm_2a30a
call Function2a27f
- call RNG
+ call Random
cp 100
jr nc, .asm_2a30a
and 3
@@ -34187,7 +34183,7 @@ Function2a355: ; 2a355
.asm_2a36e
ld h, d
ld l, e
- call RNG
+ call Random
and $1f
jr z, .asm_2a3cd
and $3
@@ -34248,7 +34244,7 @@ Function2a355: ; 2a355
.asm_2a3cd
ld hl, $640f
.asm_2a3d0
- call RNG
+ call Random
and $f
cp $10
jr nc, .asm_2a3d0
@@ -34882,7 +34878,7 @@ Function2c7fb: ; 2c7fb
callba PartyMenuSelect
push af
ld a, [CurPartySpecies]
- cp $fd
+ cp EGG
pop bc
jr z, .asm_2c854
push bc
@@ -34949,7 +34945,7 @@ Function2ed44: ; 2ed44
ld hl, StatusFlags2
bit 6, [hl]
ret z
- call RNG
+ call Random
ld a, [hRandomAdd]
and a
ret nz
@@ -34959,7 +34955,7 @@ Function2ed44: ; 2ed44
ld a, [PartyCount]
ld b, a
.asm_2ed70
- call RNG
+ call Random
and $7
cp b
jr nc, .asm_2ed70
@@ -34969,7 +34965,7 @@ Function2ed44: ; 2ed44
and $f0
ret nz
.asm_2ed82
- call RNG
+ call Random
and a
jr z, .asm_2ed82
ld b, a
@@ -34989,7 +34985,7 @@ Function2ed44: ; 2ed44
ret
.asm_2ed9a
- call RNG
+ call Random
cp $55
ret nc
ld a, [PartyCount]
@@ -34999,7 +34995,7 @@ Function2ed44: ; 2ed44
ld a, b
cp $2
jr c, .asm_2edc3
- call RNG
+ call Random
cp $80
jr c, .asm_2edc3
.asm_2edb3
@@ -35052,7 +35048,7 @@ Function2ede6: ; 2ede6
ld hl, StatusFlags2
bit 6, [hl]
ret z
- call RNG
+ call Random
cp $10
ret nc
ld hl, PartyMons
@@ -35510,7 +35506,7 @@ Function38045: ; 38045
jp z, Function38041
cp $10
jr nz, .asm_38061
- call RNG
+ call Random
cp $80
jr c, .asm_38077
jp Function38041
@@ -35518,13 +35514,13 @@ Function38045: ; 38045
.asm_38061
cp $20
jr nz, .asm_3806f
- call RNG
+ call Random
cp $c8
jr c, .asm_38077
jp Function38041
.asm_3806f
- call RNG
+ call Random
cp $a
jp c, Function38041
@@ -35543,7 +35539,7 @@ Function38083: ; 38083
jp z, Function38041
cp $10
jr nz, .asm_3809f
- call RNG
+ call Random
cp $14
jr c, .asm_380b5
jp Function38041
@@ -35551,13 +35547,13 @@ Function38083: ; 38083
.asm_3809f
cp $20
jr nz, .asm_380ad
- call RNG
+ call Random
cp $1e
jr c, .asm_380b5
jp Function38041
.asm_380ad
- call RNG
+ call Random
cp $c8
jp c, Function38041
@@ -35576,7 +35572,7 @@ Function380c1: ; 380c1
jp z, Function38041
cp $10
jr nz, .asm_380dd
- call RNG
+ call Random
cp $32
jr c, .asm_380f3
jp Function38041
@@ -35584,13 +35580,13 @@ Function380c1: ; 380c1
.asm_380dd
cp $20
jr nz, .asm_380eb
- call RNG
+ call Random
cp $80
jr c, .asm_380f3
jp Function38041
.asm_380eb
- call RNG
+ call Random
cp $32
jp c, Function38041
@@ -36366,7 +36362,7 @@ Function3c0e5: ; 3c0e5
ld hl, $5863
.asm_3c115
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3c118
call Function3ceec
@@ -36629,7 +36625,7 @@ Function3c27c: ; 3c27c
ld [hl], a
call GetItemName
ld hl, $4bde
- call FarBattleTextBox
+ call StdBattleTextBox
callab BattleCommand8c
pop af
bit 7, a
@@ -36640,7 +36636,7 @@ Function3c27c: ; 3c27c
call Function3ee0f
call Function3c8e4
ld hl, $4d97
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3c300
Function3c300: ; 3c300
@@ -36678,13 +36674,13 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c341
- call FarBattleRNG
+ call BattleRandom
cp $80
jp c, $43f1
jp Function3c3f3
.asm_3c341
- call FarBattleRNG
+ call BattleRandom
cp $80
jp c, Function3c3f3
jp $43f1
@@ -36716,7 +36712,7 @@ Function3c314: ; 3c314
ld a, b
cp $4a
jr z, .asm_3c39f
- call FarBattleRNG
+ call BattleRandom
cp e
jr nc, .asm_3c3c5
jp $43f1
@@ -36725,7 +36721,7 @@ Function3c314: ; 3c314
ld a, b
cp $4a
jr nz, .asm_3c3c5
- call FarBattleRNG
+ call BattleRandom
cp c
jr nc, .asm_3c3c5
jp Function3c3f3
@@ -36734,19 +36730,19 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c3b5
- call FarBattleRNG
+ call BattleRandom
cp c
jp c, Function3c3f3
- call FarBattleRNG
+ call BattleRandom
cp e
jp c, $43f1
jr .asm_3c3c5
.asm_3c3b5
- call FarBattleRNG
+ call BattleRandom
cp e
jp c, $43f1
- call FarBattleRNG
+ call BattleRandom
cp c
jp c, Function3c3f3
jr .asm_3c3c5
@@ -36764,13 +36760,13 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c3e9
- call FarBattleRNG
+ call BattleRandom
cp $80
jp c, $43f1
jp Function3c3f3
.asm_3c3e9
- call FarBattleRNG
+ call BattleRandom
cp $80
jp c, Function3c3f3
scf
@@ -36950,7 +36946,7 @@ Function3c4df: ; 3c4df
res 4, [hl]
call SetEnemyTurn
ld hl, $4c8a
- jp FarBattleTextBox
+ jp StdBattleTextBox
.asm_3c518
ld hl, EnemySubStatus5
@@ -36974,7 +36970,7 @@ Function3c4df: ; 3c4df
res 4, [hl]
call SetPlayerTurn
ld hl, $4c8a
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3c543
@@ -37001,7 +36997,7 @@ Function3c543: ; 3c543
call IsInArray
jr c, .Flee
- call FarBattleRNG
+ call BattleRandom
ld b, a
cp $80
jr nc, .Stay
@@ -37283,7 +37279,7 @@ Function3c716: ; 3c716
.asm_3c733
push de
- call FarBattleTextBox
+ call StdBattleTextBox
pop de
xor a
ld [$cfca], a
@@ -37337,7 +37333,7 @@ Function3c716: ; 3c716
ld [hBGMapMode], a
call Function3ccef
ld hl, $480e
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3c7a1
call Function3c706
@@ -37353,7 +37349,7 @@ Function3c716: ; 3c716
call GetQuarterMaxHP
call Function3cc3f
ld hl, $4822
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3c7c5
call Function3c706
@@ -37369,7 +37365,7 @@ Function3c716: ; 3c716
call GetQuarterMaxHP
call Function3cc3f
ld hl, $4836
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3c7e9
ld hl, BattleMonHP
@@ -37420,7 +37416,7 @@ Function3c801: ; 3c801
ld [$d265], a
push af
ld hl, $4864
- call FarBattleTextBox
+ call StdBattleTextBox
pop af
ret nz
ld a, $0
@@ -37515,7 +37511,7 @@ Function3c874: ; 3c874
ld hl, $4df5
.asm_3c8e1
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3c8e4
Function3c8e4: ; 3c8e4
@@ -37568,7 +37564,7 @@ Function3c8eb: ; 3c8eb
call Function3c8e4
call Function3ccef
ld hl, $4880
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3c93c
Function3c93c: ; 3c93c
@@ -37707,7 +37703,7 @@ Function3c93c: ; 3c93c
call Function3ddc8
call Function3c8e4
ld hl, $4899
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3ca26
Function3ca26: ; 3ca26
@@ -37738,7 +37734,7 @@ Function3ca26: ; 3ca26
cp $1
ret nz
ld hl, $48b6
- call FarBattleTextBox
+ call StdBattleTextBox
ld a, $10
call GetBattleVarPair
push af
@@ -37777,7 +37773,7 @@ Function3ca8f: ; 3ca8f
ld a, [$c73f]
and a
ret nz
- call FarBattleRNG
+ call BattleRandom
cp $19
ret nc
xor a
@@ -37789,7 +37785,7 @@ Function3ca8f: ; 3ca8f
call UpdateBattleHuds
call SetEnemyTurn
ld hl, $524b
- jp FarBattleTextBox
+ jp StdBattleTextBox
.asm_3cac9
ld a, [EnemyMonStatus]
@@ -37798,7 +37794,7 @@ Function3ca8f: ; 3ca8f
ld a, [$c740]
and a
ret nz
- call FarBattleRNG
+ call BattleRandom
cp $19
ret nc
xor a
@@ -37815,7 +37811,7 @@ Function3ca8f: ; 3ca8f
call UpdateBattleHuds
call SetPlayerTurn
ld hl, $524b
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cafb
Function3cafb: ; 3cafb
@@ -37852,7 +37848,7 @@ Function3cafb: ; 3cafb
.asm_3cb2e
ld [hBattleTurn], a
ld hl, $48d2
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cb36
@@ -37909,7 +37905,7 @@ FadeLightScreen: ; 3cb80
push hl
push de
ld hl, BattleText_0x808e7
- call FarBattleTextBox
+ call StdBattleTextBox
pop de
pop hl
ret
@@ -37923,7 +37919,7 @@ FadeReflect: ; 3cb91
ret nz
res SCREENS_REFLECT, [hl]
ld hl, BattleText_0x80905
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cb9e
HandleWeather: ; 3cb9e
@@ -37996,7 +37992,7 @@ HandleWeather: ; 3cb9e
call Function3cc3f
ld hl, BattleText_0x8084d
- jp FarBattleTextBox
+ jp StdBattleTextBox
.asm_3cc13
ld hl, .WeatherEndedMessages
@@ -38015,7 +38011,7 @@ HandleWeather: ; 3cb9e
ld a, [hli]
ld h, [hl]
ld l, a
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cc2d
.WeatherMessages
@@ -38526,7 +38522,7 @@ Function3cef1: ; 3cef1
ld bc, $050b
call ClearBox
ld hl, BattleText_0x80a75
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cf14
Function3cf14: ; 3cf14
@@ -38540,7 +38536,7 @@ Function3cf14: ; 3cf14
ld bc, $040a
call ClearBox
ld hl, BattleText_0x809a8
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3cf35
Function3cf35: ; 3cf35
@@ -38625,7 +38621,7 @@ Function3cfa4: ; 3cfa4
call z, Function3d0ea
callab Function39939
ld hl, BattleText_0x809da
- call FarBattleTextBox
+ call StdBattleTextBox
call Function3d2f1
jr z, .asm_3cff5
ld a, [InLinkBattle]
@@ -38734,11 +38730,11 @@ Function3d02b: ; 3d02b
ld a, [hli]
ld h, [hl]
ld l, a
- jp FarBattleTextBox
+ jp StdBattleTextBox
.asm_3d07b
ld hl, BattleText_0x809be
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3d081
Function3d081: ; 3d081
@@ -39018,7 +39014,7 @@ Function3d1f8: ; 3d1f8
dec a
ret nz
ld hl, BattleText_0x80a83
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3d20a
ld bc, $0107
call Function1dd2
@@ -39193,7 +39189,7 @@ Function3d34f: ; 3d34f
cp [hl]
jr nz, .asm_3d360
ld hl, BattleText_0x80c0d
- call FarBattleTextBox
+ call StdBattleTextBox
scf
ret
@@ -39314,7 +39310,7 @@ LostBattle: ; 3d38e
jr z, .asm_3d417
.asm_3d412
- call FarBattleTextBox
+ call StdBattleTextBox
.end
scf
@@ -39736,7 +39732,7 @@ Function3d672: ; 3d672
.asm_3d6a7
ld a, [OTPartyCount]
ld b, a
- call FarBattleRNG
+ call BattleRandom
and $7
cp b
jr nc, .asm_3d6a7
@@ -39832,7 +39828,7 @@ Function3d74b: ; 3d74b
push af
callab Function39939
ld hl, BattleText_0x80aca
- call FarBattleTextBox
+ call StdBattleTextBox
ld bc, $0107
call Function1dd2
ld a, [$cfa9]
@@ -39883,7 +39879,7 @@ Function3d7a0: ; 3d7a0
Function3d7b8: ; 3d7b8
callab Function39939
ld hl, BattleText_0x80af8
- call FarBattleTextBox
+ call StdBattleTextBox
jp WaitBGMap
; 3d7c7
@@ -40005,16 +40001,16 @@ Function3d887: ; 3d887
ld hl, PartySpecies
ld a, [CurPartyMon]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
- cp $fd
+ cp EGG
ld hl, BattleText_0x80b26
jr z, .asm_3d8ae
ld hl, BattleText_0x80b0b
.asm_3d8ae
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3d8b1
xor a
@@ -40068,7 +40064,7 @@ Function3d8b3: ; 3d8b3
call SetPlayerTurn
call GetItemName
ld hl, BattleText_0x80b89
- call FarBattleTextBox
+ call StdBattleTextBox
jp .asm_3d9a2
.asm_3d916
@@ -40127,7 +40123,7 @@ Function3d8b3: ; 3d8b3
jr .asm_3d96c
.asm_3d97a
- call FarBattleRNG
+ call BattleRandom
ld b, a
ld a, [$ffb6]
cp b
@@ -40145,7 +40141,7 @@ Function3d8b3: ; 3d8b3
ld hl, BattleText_0x80b49
.asm_3d995
- call FarBattleTextBox
+ call StdBattleTextBox
ld a, $1
ld [$d266], a
call Function309d
@@ -40188,7 +40184,7 @@ Function3d8b3: ; 3d8b3
pop de
call WaitSFX
ld hl, BattleText_0x80b77
- call FarBattleTextBox
+ call StdBattleTextBox
call WaitSFX
call Function309d
scf
@@ -40200,7 +40196,7 @@ Function3d8b3: ; 3d8b3
bit 4, [hl]
jr nz, .asm_3da05
ld hl, BattleText_0x81863
- call FarBattleTextBox
+ call StdBattleTextBox
.asm_3da05
call WaitSFX
@@ -40493,7 +40489,7 @@ Function3dc23: ; 3dc23
ret z
push bc
ld hl, BattleText_0x80bae
- call FarBattleTextBox
+ call StdBattleTextBox
call GetEighthMaxHP
call Function3cc39
pop hl
@@ -40570,7 +40566,7 @@ Function3dc5b: ; 3dc5b
ld hl, BattleText_0x809a8
.asm_3dcdf
- call FarBattleTextBox
+ call StdBattleTextBox
scf
ret
@@ -40706,7 +40702,7 @@ Function3dd2f: ; 3dd2f
ld a, $9
rst FarCall
ld hl, RecoveredUsingText
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3ddc8
@@ -40817,7 +40813,7 @@ Function3de51: ; 3de51
call GetItemName
call Function3ddc8
ld hl, BattleText_0x80dab
- call FarBattleTextBox
+ call StdBattleTextBox
ld a, [hBattleTurn]
and a
jr nz, .asm_3de90
@@ -40897,7 +40893,7 @@ Function3deb1: ; 3deb1
ld [de], a
call GetItemName
ld hl, BattleText_0x80bde
- call FarBattleTextBox
+ call StdBattleTextBox
callab BattleCommand8c
ret
@@ -41333,7 +41329,7 @@ Function3e19b: ; 3e19b
bit 4, [hl]
jr nz, .asm_3e1c5
ld hl, $5863
- call FarBattleTextBox
+ call StdBattleTextBox
ld c, $3c
call DelayFrames
@@ -41396,7 +41392,7 @@ Function3e1c7: ; 3e1c7
Function3e22b: ; 3e22b
ld hl, BattleText_0x80bf3
- call FarBattleTextBox
+ call StdBattleTextBox
jp Function3e139
; 3e234
@@ -41551,7 +41547,7 @@ Function3e358: ; 3e358
cp d
jr nz, .asm_3e36b
ld hl, BattleText_0x80c0d
- call FarBattleTextBox
+ call StdBattleTextBox
jp $6299
.asm_3e36b
@@ -41564,7 +41560,7 @@ Function3e358: ; 3e358
.asm_3e378
ld hl, BattleText_0x80c22
- call FarBattleTextBox
+ call StdBattleTextBox
jp $6299
.asm_3e381
@@ -41924,7 +41920,7 @@ Function3e4bc: ; 3e4bc
ld hl, Function3cc39
.asm_3e613
- call FarBattleTextBox
+ call StdBattleTextBox
call Function30b4
jp Function3e4bc
; 3e61c
@@ -42173,7 +42169,7 @@ Function3e786: ; 3e786
.asm_3e7b4
ld hl, BattleText_0x80c72
- call FarBattleTextBox
+ call StdBattleTextBox
ld c, $3c
call DelayFrames
xor a
@@ -42263,7 +42259,7 @@ Function3e7c1: ; 3e7c1
jr nz, .asm_3e882
.asm_3e855
ld hl, EnemyMonMove1
- call FarBattleRNG
+ call BattleRandom
and $3
ld c, a
ld b, $0
@@ -42365,7 +42361,7 @@ LoadEnemyMon: ; 3e8eb
; To do this we pull the species from TempEnemyMonSpecies
; Notes:
-; FarBattleRNG is used to ensure sync between Game Boys
+; BattleRandom is used to ensure sync between Game Boys
; Clear the whole EnemyMon struct
xor a
@@ -42424,13 +42420,13 @@ LoadEnemyMon: ; 3e8eb
; 2% Item2
; 25% chance of getting an item
- call FarBattleRNG
+ call BattleRandom
cp a, $c0
ld a, NO_ITEM
jr c, .UpdateItem
; From there, an 8% chance for Item2
- call FarBattleRNG
+ call BattleRandom
cp a, $14 ; 8% of 25% = 2% Item2
ld a, [BaseItems]
jr nc, .UpdateItem
@@ -42510,10 +42506,10 @@ LoadEnemyMon: ; 3e8eb
; (HP is initialized at the end of the battle)
call GetRoamMonDVs
inc hl
- call FarBattleRNG
+ call BattleRandom
ld [hld], a
ld c, a
- call FarBattleRNG
+ call BattleRandom
ld [hl], a
ld b, a
; We're done with DVs
@@ -42534,9 +42530,9 @@ LoadEnemyMon: ; 3e8eb
.GenerateDVs
; Generate new random DVs
- call FarBattleRNG
+ call BattleRandom
ld b, a
- call FarBattleRNG
+ call BattleRandom
ld c, a
.UpdateDVs
@@ -42589,7 +42585,7 @@ LoadEnemyMon: ; 3e8eb
jr nz, .CheckMagikarpArea
; 5% chance of skipping size checks
- call RNG
+ call Random
cp a, $0c ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1614
@@ -42598,7 +42594,7 @@ LoadEnemyMon: ; 3e8eb
jr nc, .GenerateDVs
; 20% chance of skipping this check
- call RNG
+ call Random
cp a, $32 ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1598
@@ -42623,7 +42619,7 @@ LoadEnemyMon: ; 3e8eb
cp a, MAP_LAKE_OF_RAGE
jr z, .Happiness
; 40% chance of not flooring
- call RNG
+ call Random
cp a, $64 ; / $100
jr c, .Happiness
; Floor at length 1024
@@ -43394,14 +43390,14 @@ EmptyBattleTextBox: ; 3edd1
; 3edd8
-BattleRNG: ; 3edd8
+_BattleRandom: ; 3edd8
; If the normal RNG is used in a link battle it'll desync.
; To circumvent this a shared PRNG is used instead.
; But if we're in a non-link battle we're safe to use it
ld a, [InLinkBattle]
and a
- jp z, RNG
+ jp z, Random
; The PRNG operates in streams of 10 values.
@@ -43816,7 +43812,7 @@ Function3ee3b: ; 3ee3b
call StartSFX
call WaitSFX
ld hl, BattleText_0x80c9c
- call FarBattleTextBox
+ call StdBattleTextBox
call Function309d
.asm_3f057
@@ -44069,7 +44065,7 @@ Function3f136: ; 3f136
rst FarCall
call WaitSFX
ld hl, BattleText_0x80c9c
- call FarBattleTextBox
+ call StdBattleTextBox
pop de
inc e
ld b, $0
@@ -44358,7 +44354,7 @@ Function3f360: ; 3f360
push hl
call Function30b4
pop hl
- jp FarBattleTextBox
+ jp StdBattleTextBox
; 3f390
@@ -44917,7 +44913,7 @@ Function3f71d: ; 3f71d
ld de, $d850
call Function3d0be
ld hl, BattleText_0x80730
- call FarBattleTextBox
+ call StdBattleTextBox
ld a, [$cfc0]
bit 0, a
ret z
@@ -45213,7 +45209,7 @@ Function3f998: ; 3f998
ret
.asm_3f9c4
- call FarBattleRNG
+ call BattleRandom
and $f
ret nz
@@ -45757,7 +45753,7 @@ BattleStartMessage: ; 3fc8b
ld hl, $4000
rst FarCall
pop hl
- call FarBattleTextBox
+ call StdBattleTextBox
call Function3f830
ret nz
@@ -46790,7 +46786,7 @@ GetPreEvolution: ; 42581
.asm_425a2
inc c
ld a, c
- cp CELEBI
+ cp NUM_POKEMON
jr c, .asm_42583
and a
ret
@@ -47152,7 +47148,7 @@ AIChooseMove: ; 440ce
.asm_44197
ld hl, Buffer1
- call RNG
+ call Random
and 3
ld c, a
ld b, 0
@@ -47638,32 +47634,20 @@ Function4484a: ; 0x4484a
ld [PartyMenuActionText], a
call WhiteBGMap
.asm_448dc
- ld a, $14
- ld hl, $404f
- rst $8
- ld a, $14
- ld hl, $4405
- rst $8
- ld a, $14
- ld hl, $43e0
- rst $8
- ld a, $14
- ld hl, PickedFruitTree
- rst $8
- ld a, $14
- ld hl, $449a
- rst $8
+ callba Function5004f
+ callba Function50405
+ callba Function503e0
+ callba WritePartyMenuTilemap
+ callba PrintPartyMenuText
call WaitBGMap
call Function32f9
call DelayFrame
- ld a, $14
- ld hl, $4457
- rst $8
+ callba PartyMenuSelect
jr c, .asm_44939
ld a, [CurPartySpecies]
- cp $fd
+ cp EGG
jr z, .asm_44923
- ld a, $1
+ ld a, PartyMon1Item - PartyMon1
call GetPartyParamLocation
ld a, [hl]
and a
@@ -51438,14 +51422,14 @@ INCBIN "baserom.gbc", $5036b, $50389 - $5036b
Function50389: ; 50389
- ld a, $d8
+ ld a, PartySpecies & $ff
add b
ld e, a
- ld a, $dc
- adc $0
+ ld a, PartySpecies >> 8
+ adc 0
ld d, a
ld a, [de]
- cp $fd
+ cp EGG
ret
; 50396
@@ -51456,7 +51440,7 @@ Function50396: ; 50396
ld a, [PartyMenuActionText]
and $f
ld e, a
- ld d, $0
+ ld d, 0
ld hl, $43b2
add hl, de
add hl, de
@@ -54128,6 +54112,7 @@ INCLUDE "engine/engine_flags.asm"
INCBIN "baserom.gbc", $80648, $80730-$80648
+BattleText:
INCLUDE "text/battle.asm"
INCBIN "baserom.gbc", $818ac, $81fe3-$818ac
@@ -54832,12 +54817,12 @@ Function8653f: ; 8653f
ld [de], a
inc de
ld hl, PartySpecies
- ld c, $0
+ ld c, 0
.asm_86556
ld a, [hli]
cp $ff
jr z, .asm_865b1
- cp $fd
+ cp EGG
jr nz, .asm_86562
inc c
jr .asm_86556
@@ -55055,7 +55040,7 @@ Function86748: ; 86748
ld hl, $c50a
call Function378b
ld a, [CurPartySpecies]
- cp $fd
+ cp EGG
jr z, .asm_867f8
ld hl, $c5a5
ld a, $74
@@ -55502,7 +55487,7 @@ Function8adef: ; 8adef
ld a, WATER_STONE
ld [CurItem], a
ld hl, NumItems
- call Function2f79
+ call PickUpItem
jr c, .asm_8ae24
ld a, [PartyCount]
@@ -56192,7 +56177,7 @@ GetTimePalFade: ; 8c17c
Function8c20f: ; 8c20f
- call $426d
+ call Function8c26d
ld a, [rBGP]
ld [$cfc7], a
ld a, [rOBP0]
@@ -56208,7 +56193,7 @@ Function8c20f: ; 8c20f
ld a, [$cf63]
bit 7, a
jr nz, .asm_8c23a
- call $4314
+ call Function8c314
call DelayFrame
jr .asm_8c22b
@@ -56247,12 +56232,12 @@ Function8c26d: ; 8c26d
callba Function6454
call Function1ad2
call DelayFrame
- call $42a0
- call $4f4f
+ call Function8c2a0
+ call Function8cf4f
jr .asm_8c28b
.asm_8c288
- call $42aa
+ call Function8c2aa
.asm_8c28b
ld a, $90
@@ -56265,14 +56250,14 @@ Function8c26d: ; 8c26d
ld [hli], a
ld [hli], a
ld [hl], a
- call $46d8
+ call Function8c6d8
ret
; 8c2a0
Function8c2a0: ; 8c2a0
- call $42aa
+ call Function8c2aa
ld hl, VBGMap0
- call $42cf
+ call Function8c2cf
ret
; 8c2aa
@@ -56344,9 +56329,9 @@ Function8c6d8: ; 8c6d8
ld a, $5
ld [rSVBK], a
ld hl, $d100
- call $46ef
+ call Function8c6ef
ld hl, $d200
- call $46ef
+ call Function8c6ef
pop af
ld [rSVBK], a
ret
@@ -56378,7 +56363,7 @@ Function8c940: ; 8c940
ld a, e
and $1
ld [$cf63], a
- call $496d
+ call Function8c96d
call WaitSFX
ld de, $001e
call StartSFX
@@ -56388,10 +56373,10 @@ Function8c940: ; 8c940
jr nz, .asm_8c96c
ld a, $90
ld [$c3b5], a
- ld hl, $4f7a
+ ld hl, Function8cf7a
ld a, $23
rst FarCall
- call $4a0c
+ call Function8ca0c
call DelayFrame
jr .asm_8c952
@@ -56400,7 +56385,7 @@ Function8c940: ; 8c940
; 8c96d
Function8c96d: ; 8c96d
- ld hl, $4f53
+ ld hl, Function8cf53
ld a, $23
rst FarCall
ld de, $49cc
@@ -56605,9 +56590,9 @@ INCBIN "baserom.gbc", $8d03d, $8d04c - $8d03d
Function8d04c: ; 8d04c
call Function8d0ec
call Function8d132
- cp $fd
+ cp EGG
jr z, .asm_8d0b9
- cp $fc
+ cp NUM_POKEMON + 1
jr z, .asm_8d0b6
call Function8d1a2
ld a, [$c3ba]
@@ -59844,7 +59829,7 @@ Function97d23: ; 97d23
Function97d31: ; 97d31
.asm_97d31
- call RNG
+ call Random
cp 100 << 1
jr nc, .asm_97d31
srl a
@@ -59871,7 +59856,7 @@ Function97d31: ; 97d31
.asm_97d54
ld c, a
inc c
- call RNG
+ call Random
ld a, [hRandomAdd]
call SimpleDivide
add d
@@ -59896,7 +59881,7 @@ Function97d64: ; 97d64
ld a, $a
ld hl, $6138
rst FarCall
- call RNG
+ call Random
ld a, [hRandomAdd]
cp b
ret c
@@ -63353,9 +63338,9 @@ INCBIN "baserom.gbc", $cc9c4, $cca09 - $cc9c4
Functioncca09: ; cca09
call Functionccaaa
call Functionce7d1
- cp $fd
+ cp EGG
jp z, $4aa5
- cp $fc
+ cp NUM_POKEMON + 1
jp z, $4aa2
push af
ld hl, $d419
@@ -64197,7 +64182,7 @@ Options_Sound: ; e43dd
Options_Print: ; e4424
- call $4491
+ call Functione4491
ld a, [hJoyPressed]
bit 5, a
jr nz, .asm_e443c
@@ -68027,7 +68012,7 @@ Function100bc2: ; 100bc2
ld hl, $4c39
.asm_100c6b
- call FarBattleTextBox
+ call StdBattleTextBox
call Function30b4
jp Function100bc2
; 100c74
@@ -69699,7 +69684,7 @@ SECTION "bank43",ROMX,BANK[$43]
INCBIN "baserom.gbc", $10c000, $10ed67 - $10c000
-StartTitleScreen: ; 10ed67
+_TitleScreen: ; 10ed67
call WhiteBGMap
call ClearSprites