ref: f1b2466cc3672fa72f5b43e96a634dd83796f047
parent: 77d0a8a39696f28a78450225d60d1149f554ad88
author: PikalaxALT <[email protected]>
date: Mon Nov 9 18:01:45 EST 2015
Cleaning up static HRAM labels; movement stuff, route 38 trainers
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -26,7 +26,7 @@
.clearsound
; sound channel 1 2 3 4
xor a
- ld [hli], a ; rNR10, $ff15, rNR30, $ff1f ; sweep = 0
+ ld [hli], a ; rNR10, rNR20, rNR30, rNR40 ; sweep = 0
ld [hli], a ; rNR11, rNR21, rNR31, rNR41 ; length/wavepattern = 0
ld a, $08
@@ -345,7 +345,7 @@
ld a, [rNR52]
and a, %10001101 ; ch2 off
ld [rNR52], a
- ld hl, $ff15
+ ld hl, rNR20
call ClearChannel
ret
.asm_e8204
@@ -418,39 +418,39 @@
endr
ld de, WaveSamples
add hl, de
- ; load wavepattern into $ff30-$ff3f
+ ; load wavepattern into rWave_0-rWave_f
ld a, [hli]
- ld [$ff30], a
+ ld [rWave_0], a
ld a, [hli]
- ld [$ff31], a
+ ld [rWave_1], a
ld a, [hli]
- ld [$ff32], a
+ ld [rWave_2], a
ld a, [hli]
- ld [$ff33], a
+ ld [rWave_3], a
ld a, [hli]
- ld [$ff34], a
+ ld [rWave_4], a
ld a, [hli]
- ld [$ff35], a
+ ld [rWave_5], a
ld a, [hli]
- ld [$ff36], a
+ ld [rWave_6], a
ld a, [hli]
- ld [$ff37], a
+ ld [rWave_7], a
ld a, [hli]
- ld [$ff38], a
+ ld [rWave_8], a
ld a, [hli]
- ld [$ff39], a
+ ld [rWave_9], a
ld a, [hli]
- ld [$ff3a], a
+ ld [rWave_a], a
ld a, [hli]
- ld [$ff3b], a
+ ld [rWave_b], a
ld a, [hli]
- ld [$ff3c], a
+ ld [rWave_c], a
ld a, [hli]
- ld [$ff3d], a
+ ld [rWave_d], a
ld a, [hli]
- ld [$ff3e], a
+ ld [rWave_e], a
ld a, [hli]
- ld [$ff3f], a
+ ld [rWave_f], a
pop hl
ld a, [wc293]
and a, $f0
@@ -475,7 +475,7 @@
ld a, [rNR52]
and a, %10000111 ; ch4 off
ld [rNR52], a
- ld hl, $ff1f
+ ld hl, rNR40
call ClearChannel
ret
.asm_e82d4
@@ -3179,12 +3179,12 @@
; e8ffe
ClearChannel: ; e8ffe
-; input: hl = beginning hw sound register (rNR10, $ff15, rNR30, $ff1f)
+; input: hl = beginning hw sound register (rNR10, rNR20, rNR30, rNR40)
; output: 00 00 80 00 80
; sound channel 1 2 3 4
xor a
- ld [hli], a ; rNR10, $ff15, rNR30, $ff1f ; sweep = 0
+ ld [hli], a ; rNR10, rNR20, rNR30, rNR40 ; sweep = 0
ld [hli], a ; rNR11, rNR21, rNR31, rNR41 ; length/wavepattern = 0
ld a, $08
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -5093,14 +5093,14 @@
rr a
srl b
rr a
- ld [$ffb6], a
+ ld [hProduct + 3], a
ld a, b
- ld [$ffb5], a
+ ld [hProduct + 2], a
.asm_3e105
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [hDividend + 0], a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [hDividend + 1], a
ld a, $2
ld b, a
@@ -7796,17 +7796,17 @@
DoubleExp: ; 3f106
push bc
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld b, a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld c, a
srl b
rr c
add c
- ld [$ffb6], a
- ld a, [$ffb5]
+ ld [hProduct + 3], a
+ ld a, [hProduct + 2]
adc b
- ld [$ffb5], a
+ ld [hProduct + 2], a
pop bc
ret
; 3f11b
@@ -7846,10 +7846,10 @@
cp MAX_LEVEL
jp nc, .asm_3f219
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld [wd004], a
push af
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld [wd003], a
push af
xor a
@@ -7883,11 +7883,11 @@
.asm_3f186
ld d, MAX_LEVEL
callab CalcExpAtLevel
- ld a, [hMultiplicand]
+ ld a, [hProduct + 1]
ld b, a
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld c, a
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld d, a
ld hl, TempMonExp + 2
ld a, [hld]
@@ -7958,9 +7958,9 @@
call Function3f22c
call Function3dfe
pop af
- ld [$ffb5], a
+ ld [hProduct + 2], a
pop af
- ld [$ffb6], a
+ ld [hProduct + 3], a
.asm_3f219
pop bc
@@ -8264,14 +8264,14 @@
push af
inc d
callab CalcExpAtLevel
- ld hl, $ffb6
+ ld hl, hProduct + 3
ld a, [hl]
- ld [$ffba], a
+ ld [hPrintNum8], a
pop bc
sub b
ld [hld], a
ld a, [hl]
- ld [$ffb9], a
+ ld [hPrintNum7], a
pop bc
sbc b
ld [hld], a
@@ -8281,7 +8281,7 @@
sbc b
ld [hl], a
pop de
- ld hl, $ffb5
+ ld hl, hProduct + 2
ld a, [hli]
push af
ld a, [hl]
@@ -8289,13 +8289,13 @@
ld a, [de]
dec de
ld c, a
- ld a, [$ffba]
+ ld a, [hPrintNum8]
sub c
ld [hld], a
ld a, [de]
dec de
ld b, a
- ld a, [$ffb9]
+ ld a, [hPrintNum7]
sbc b
ld [hld], a
ld a, [de]
@@ -9194,7 +9194,7 @@
add hl, bc
dec d
jr nz, .asm_3fa62
- ld bc, $ffee
+ ld bc, -18
add hl, bc
push hl
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -1966,9 +1966,9 @@
ld a, [hQuotient + 1]
or b
jr nz, .asm_34ea2
- ld [$ffb5], a
+ ld [hQuotient + 1], a
ld a, $1
- ld [$ffb6], a
+ ld [hQuotient + 2], a
.asm_34ea2
ld b, c
@@ -1975,9 +1975,9 @@
dec d
jr nz, .asm_34e7a
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
and a
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
jr z, .asm_34eaf
ld a, $ff
@@ -2683,7 +2683,7 @@
dec a
add hl, bc
jr nc, .asm_35290
- ld hl, $ffff
+ ld hl, -1
.asm_3529a
ld a, h
ld [CurDamage], a
@@ -3371,20 +3371,20 @@
; Selfdestruct and Explosion halve defense.
cp EFFECT_EXPLOSION
- jr nz, .asm_35620
+ jr nz, .dont_explode
srl c
- jr nz, .asm_35620
+ jr nz, .dont_explode
inc c
-.asm_35620
+.dont_explode
; Variable-hit moves and Conversion can have a power of 0.
cp EFFECT_MULTI_HIT
- jr z, .asm_3562b
+ jr z, .skip_zero_damage_check
cp EFFECT_CONVERSION
- jr z, .asm_3562b
+ jr z, .skip_zero_damage_check
; No damage if move power is 0.
ld a, d
@@ -3391,13 +3391,13 @@
and a
ret z
-.asm_3562b
+.skip_zero_damage_check
; Minimum defense value is 1.
ld a, c
and a
- jr nz, .asm_35631
+ jr nz, .not_dividing_by_zero
ld c, 1
-.asm_35631
+.not_dividing_by_zero
xor a
ld hl, hDividend
@@ -3409,9 +3409,9 @@
; Level * 2
ld a, e
add a
- jr nc, .asm_3563e
+ jr nc, .level_not_overflowing
ld [hl], $1
-.asm_3563e
+.level_not_overflowing
inc hl
ld [hli], a
@@ -3493,44 +3493,44 @@
; Update CurDamage (capped at 997).
ld hl, CurDamage
ld b, [hl]
- ld a, [hQuotient + 2]
+ ld a, [hProduct + 3]
add b
- ld [$ffb6], a
- jr nc, .asm_356a5
+ ld [hProduct + 3], a
+ jr nc, .dont_cap_1
- ld a, [hQuotient + 1]
+ ld a, [hProduct + 2]
inc a
- ld [$ffb5], a
+ ld [hProduct + 2], a
and a
jr z, .Cap
-.asm_356a5
- ld a, [$ffb3]
+.dont_cap_1
+ ld a, [hProduct]
ld b, a
- ld a, [$ffb4]
+ ld a, [hProduct + 1]
or a
jr nz, .Cap
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
cp 998 / $100
- jr c, .asm_356bd
+ jr c, .dont_cap_2
cp 998 / $100 + 1
jr nc, .Cap
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
cp 998 % $100
jr nc, .Cap
-.asm_356bd
+.dont_cap_2
inc hl
- ld a, [$ffb6]
+ ld a, [hProduct + 3]
ld b, [hl]
add b
ld [hld], a
- ld a, [$ffb5]
+ ld a, [hProduct + 2]
ld b, [hl]
adc b
ld [hl], a
@@ -3538,7 +3538,7 @@
ld a, [hl]
cp 998 / $100
- jr c, .asm_356df
+ jr c, .dont_cap_3
cp 998 / $100 + 1
jr nc, .Cap
@@ -3546,7 +3546,7 @@
inc hl
ld a, [hld]
cp 998 % $100
- jr c, .asm_356df
+ jr c, .dont_cap_3
.Cap
ld a, 997 / $100
@@ -3555,15 +3555,15 @@
ld [hld], a
-.asm_356df
+.dont_cap_3
; Minimum neutral damage is 2 (bringing the cap to 999).
inc hl
ld a, [hl]
add 2
ld [hld], a
- jr nc, .asm_356e7
+ jr nc, .dont_floor
inc [hl]
-.asm_356e7
+.dont_floor
ld a, 1
and a
@@ -3576,20 +3576,20 @@
ret z
; x2
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
add a
- ld [$ffb6], a
+ ld [hProduct + 3], a
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
rl a
- ld [$ffb5], a
+ ld [hProduct + 2], a
; Cap at $ffff.
ret nc
ld a, $ff
- ld [$ffb5], a
- ld [$ffb6], a
+ ld [hProduct + 2], a
+ ld [hProduct + 3], a
ret
; 35703
@@ -3623,55 +3623,56 @@
ld hl, BattleMonLevel
ld a, [hBattleTurn]
and a
- jr z, .asm_35731
+ jr z, .got_turn
ld hl, EnemyMonLevel
-.asm_35731
+.got_turn
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
cp EFFECT_LEVEL_DAMAGE
ld b, [hl]
ld a, 0
- jr z, .asm_3578c
+ jr z, .got_power
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
cp EFFECT_PSYWAVE
- jr z, .asm_35758
+ jr z, .psywave
cp EFFECT_SUPER_FANG
- jr z, .asm_3576b
+ jr z, .super_fang
cp EFFECT_REVERSAL
- jr z, .asm_35792
+ jr z, .reversal
ld a, BATTLE_VARS_MOVE_POWER
call GetBattleVar
ld b, a
ld a, $0
- jr .asm_3578c
+ jr .got_power
-.asm_35758
+.psywave
ld a, b
srl a
add b
ld b, a
-.asm_3575d
+.psywave_loop
call BattleRandom
and a
- jr z, .asm_3575d ; 35761 $fa
+ jr z, .psywave_loop ; 35761 $fa
cp b
- jr nc, .asm_3575d ; 35764 $f7
+ jr nc, .psywave_loop ; 35764 $f7
ld b, a
ld a, $0
- jr .asm_3578c ; 35769 $21
-.asm_3576b
+ jr .got_power ; 35769 $21
+
+.super_fang
ld hl, EnemyMonHP
ld a, [hBattleTurn]
and a
- jr z, .asm_35776 ; 35771 $3
+ jr z, .got_hp ; 35771 $3
ld hl, BattleMonHP
-.asm_35776
+.got_hp
ld a, [hli]
srl a
ld b, a
@@ -3681,26 +3682,28 @@
ld a, b
pop bc
and a
- jr nz, .asm_3578c ; 35781 $9
+ jr nz, .got_power ; 35781 $9
or b
ld a, $0
- jr nz, .asm_3578c ; 35786 $4
+ jr nz, .got_power ; 35786 $4
ld b, $1
- jr .asm_3578c ; 3578a $0
-.asm_3578c
+ jr .got_power ; 3578a $0
+
+.got_power
ld hl, CurDamage
ld [hli], a
ld [hl], b
ret
-.asm_35792
+
+.reversal
ld hl, BattleMonHP
ld a, [hBattleTurn]
and a
- jr z, .asm_3579d ; 35798 $3
+ jr z, .reversal_got_hp ; 35798 $3
ld hl, EnemyMonHP
-.asm_3579d
+.reversal_got_hp
xor a
- ld [$ffb3], a
+ ld [hDividend], a
ld [hMultiplicand + 0], a
ld a, [hli]
ld [hMultiplicand + 1], a
@@ -3715,9 +3718,9 @@
ld [hDivisor], a
ld a, b
and a
- jr z, .asm_357d6
+ jr z, .skip_to_divide
- ld a, [$ffb7]
+ ld a, [hProduct + 4]
srl b
rr a
srl b
@@ -3734,7 +3737,7 @@
ld a, b
ld [hDividend + 2], a
-.asm_357d6
+.skip_to_divide
ld b, $4
call Divide
ld a, [hQuotient + 2]
@@ -3741,14 +3744,14 @@
ld b, a
ld hl, .FlailPower
-.asm_357e1
+.reversal_loop
ld a, [hli]
cp b
- jr nc, .asm_357e8
+ jr nc, .break_loop
inc hl
- jr .asm_357e1
+ jr .reversal_loop
-.asm_357e8
+.break_loop
ld a, [hBattleTurn]
and a
ld a, [hl]
@@ -6277,16 +6280,16 @@
jr c, .not_maxed_out
ld a, 999 % $100
- ld [$ffb6], a
+ ld [hQuotient + 2], a
ld a, 999 / $100
- ld [$ffb5], a
+ ld [hQuotient + 1], a
.not_maxed_out
pop bc
- ld a, [$ffb5]
+ ld a, [hQuotient + 1]
ld [bc], a
inc bc
- ld a, [$ffb6]
+ ld a, [hQuotient + 2]
ld [bc], a
inc bc
pop hl
--- a/constants/radio_constants.asm
+++ b/constants/radio_constants.asm
@@ -93,3 +93,18 @@
const BUENA_ITEM
const BUENA_MOVE
const BUENA_STRING
+
+ const_def
+ const BUENA_STARTERS
+ const BUENA_DRINKS
+ const BUENA_ITEMS
+ const BUENA_BALLS
+ const BUENA_MON1
+ const BUENA_MON2
+ const BUENA_TOWNS
+ const BUENA_TYPES
+ const BUENA_MOVES
+ const BUENA_XITEMS
+ const BUENA_STATIONS
+NUM_PASSWORD_CATEGORIES EQU const_value
+NUM_PASSWORDS_PER_CATEGORY EQU 3
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -899,7 +899,7 @@
CheckMenuOW: ; 96b30
xor a
ld [hMenuReturn], a
- ld [$ffa1], a
+ ld [hMenuReturn + 1], a
ld a, [hJoyPressed]
bit 2, a ; SELECT
--- a/engine/evolution_animation.asm
+++ b/engine/evolution_animation.asm
@@ -342,7 +342,7 @@
Function4e80c: ; 4e80c
push bc
callab Function8cf69
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $e
srl a
rept 2
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2926,7 +2926,7 @@
srl a
srl a
srl a
- cp $14
+ cp SCREEN_WIDTH
jr c, .ok3
sub $20
--- a/engine/radio.asm
+++ b/engine/radio.asm
@@ -1,7 +1,7 @@
PlayRadioShow: ; b8612
; If we're already in the radio program proper, we don't need to be here.
- ld a, [wd002]
- cp 8
+ ld a, [wCurrentRadioLine]
+ cp POKE_FLUTE_RADIO
jr nc, .ok
; If Team Rocket is not occupying the radio tower, we don't need to be here.
ld a, [StatusFlags2]
@@ -12,11 +12,11 @@
and a
jr nz, .ok
; Team Rocket broadcasts on all stations.
- ld a, 7
- ld [wd002], a
+ ld a, ROCKET_RADIO
+ ld [wCurrentRadioLine], a
.ok
-; Jump to the currently loaded station. The index to which we need to jump is in wd002.
- ld a, [wd002]
+; Jump to the currently loaded station. The index to which we need to jump is in wCurrentRadioLine.
+ ld a, [wCurrentRadioLine]
ld e, a
ld d, 0
ld hl, RadioJumptable
@@ -128,16 +128,16 @@
PrintRadioLine: ; b86ea (2e:46ea)
- ld [wd003], a
- ld hl, wd00c
- ld a, [wd005]
- cp $2
+ ld [wNextRadioLine], a
+ ld hl, wRadioText
+ ld a, [wNumRadioLinesPrinted]
+ cp 2
jr nc, .print
inc hl
- ld [hl], $0
+ ld [hl], "<START>"
inc a
- ld [wd005], a
- cp $2
+ ld [wNumRadioLinesPrinted], a
+ cp 2
jr nz, .print
bccoord 1, 16
call PlaceWholeStringInBoxAtOnce
@@ -146,9 +146,9 @@
call PrintTextBoxText
.skip
ld a, RADIO_SCROLL
- ld [wd002], a
+ ld [wCurrentRadioLine], a
ld a, 100
- ld [wd004], a
+ ld [wRadioTextDelay], a
ret
; b8718 (2e:4718)
@@ -170,7 +170,7 @@
; b8728
RadioScroll: ; b8728 (2e:4728)
- ld hl, wd004
+ ld hl, wRadioTextDelay
ld a, [hl]
and a
jr z, .proceed
@@ -177,16 +177,16 @@
dec [hl]
ret
.proceed
- ld a, [wd003]
- ld [wd002], a
- ld a, [wd005]
+ ld a, [wNextRadioLine]
+ ld [wCurrentRadioLine], a
+ ld a, [wNumRadioLinesPrinted]
cp 1
call nz, CopyBottomLineToTopLine
jp ClearBottomLine
OaksPkmnTalk1: ; b8742 (2e:4742)
- ld a, $5
- ld [wd006], a
+ ld a, 5
+ ld [wOaksPkmnTalkSegmentCounter], a
call StartRadioStation
ld hl, UnknownText_0xb8820
ld a, OAKS_POKEMON_TALK_2
@@ -274,7 +274,7 @@
ld [CurPartySpecies], a
call GetPokemonName
ld hl, StringBuffer1
- ld de, wd050
+ ld de, wOaksPkmnTalkPkmnNameBuffer
ld bc, PKMN_NAME_LENGTH
call CopyBytes
; Now that we've chosen our wild Pokemon,
@@ -290,7 +290,7 @@
.overflow
pop bc
- ld a, $0
+ ld a, OAKS_POKEMON_TALK
jp PrintRadioLine
; b87f2 (2e:47f2)
@@ -361,7 +361,7 @@
OaksPkmnTalk7: ; b883e (2e:483e)
ld a, [CurPartySpecies]
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, UnknownText_0xb884f
ld a, OAKS_POKEMON_TALK_8
@@ -517,13 +517,13 @@
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wd006]
+ ld a, [wOaksPkmnTalkSegmentCounter]
dec a
- ld [wd006], a
+ ld [wOaksPkmnTalkSegmentCounter], a
ld a, OAKS_POKEMON_TALK_4
jr nz, .ok
- ld a, $5
- ld [wd006], a
+ ld a, 5
+ ld [wOaksPkmnTalkSegmentCounter], a
ld a, OAKS_POKEMON_TALK_10
.ok
jp NextRadioLine
@@ -652,9 +652,9 @@
ld hl, UnknownText_0xb898e
call PrintText
ld a, OAKS_POKEMON_TALK_11
- ld [wd002], a
+ ld [wCurrentRadioLine], a
ld a, 100
- ld [wd004], a
+ ld [wRadioTextDelay], a
ret
; b898e (2e:498e)
@@ -669,7 +669,7 @@
; 0xb8994
OaksPkmnTalk11: ; b8994 (2e:4994)
- ld hl, wd004
+ ld hl, wRadioTextDelay
dec [hl]
ret nz
hlcoord 9, 14
@@ -683,7 +683,7 @@
; b89a9
OaksPkmnTalk12: ; b89a9 (2e:49a9)
- ld hl, wd004
+ ld hl, wRadioTextDelay
dec [hl]
ret nz
hlcoord 1, 16
@@ -697,7 +697,7 @@
; b89c6
OaksPkmnTalk13: ; b89c6 (2e:49c6)
- ld hl, wd004
+ ld hl, wRadioTextDelay
dec [hl]
ret nz
hlcoord 12, 16
@@ -711,7 +711,7 @@
; b89d7
OaksPkmnTalk14: ; b89d7 (2e:49d7)
- ld hl, wd004
+ ld hl, wRadioTextDelay
dec [hl]
ret nz
ld de, $1d
@@ -719,13 +719,13 @@
ld hl, .terminator
call PrintText
ld a, OAKS_POKEMON_TALK_4
- ld [wd003], a
+ ld [wNextRadioLine], a
xor a
- ld [wd005], a
+ ld [wNumRadioLinesPrinted], a
ld a, RADIO_SCROLL
- ld [wd002], a
+ ld [wCurrentRadioLine], a
ld a, 10
- ld [wd004], a
+ ld [wRadioTextDelay], a
ret
; b89ff (2e:49ff)
@@ -734,9 +734,9 @@
; 0xb8a00
PlaceRadioString: ; b8a00 (2e:4a00)
- ld [wd002], a
+ ld [wCurrentRadioLine], a
ld a, 100
- ld [wd004], a
+ ld [wRadioTextDelay], a
jp PlaceString
CopyBottomLineToTopLine: ; b8a0b (2e:4a0b)
@@ -747,11 +747,11 @@
ClearBottomLine: ; b8a17 (2e:4a17)
hlcoord 1, 15
- ld bc, $12
+ ld bc, SCREEN_WIDTH - 2
ld a, " "
call ByteFill
hlcoord 1, 16
- ld bc, $12
+ ld bc, SCREEN_WIDTH - 2
ld a, " "
jp ByteFill
@@ -784,7 +784,7 @@
call StartRadioStation
.loop
call Random
- cp CELEBI
+ cp NUM_POKEMON
jr nc, .loop
ld c, a
push bc
@@ -795,7 +795,7 @@
inc c
ld a, c
ld [CurPartySpecies], a
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, UnknownText_0xb8b30
ld a, POKEDEX_SHOW_2
@@ -817,8 +817,8 @@
push hl
call CopyDexEntryPart1
dec hl
- ld [hl], $57
- ld hl, wd26b
+ ld [hl], "<DONE>"
+ ld hl, wPokedexShowPointerAddr
call CopyRadioTextToRAM
pop hl
pop af
@@ -827,9 +827,9 @@
inc hl
endr
ld a, l
- ld [wd26b], a
+ ld [wPokedexShowPointerAddr], a
ld a, h
- ld [wd26c], a
+ ld [wPokedexShowPointerAddr + 1], a
ld a, POKEDEX_SHOW_3
jp PrintRadioLine
@@ -864,17 +864,17 @@
jp PrintRadioLine
CopyDexEntry: ; b8ad4 (2e:4ad4)
- ld a, [wd26b]
+ ld a, [wPokedexShowPointerAddr]
ld l, a
- ld a, [wd26c]
+ ld a, [wPokedexShowPointerAddr + 1]
ld h, a
- ld a, [wd26d]
+ ld a, [wPokedexShowPointerBank]
push af
push hl
call CopyDexEntryPart1
dec hl
ld [hl], "<DONE>"
- ld hl, wd26b
+ ld hl, wPokedexShowPointerAddr
call CopyRadioTextToRAM
pop hl
pop af
@@ -882,10 +882,10 @@
ret
CopyDexEntryPart1: ; b8af3 (2e:4af3)
- ld de, wd26d
+ ld de, wPokedexShowPointerBank
ld bc, SCREEN_WIDTH - 1
call FarCopyBytes
- ld hl, wd26b
+ ld hl, wPokedexShowPointerAddr
ld [hl], "<START>"
inc hl
ld [hl], "<LINE>"
@@ -914,11 +914,11 @@
jr nz, .loop
.okay
ld a, l
- ld [wd26b], a
+ ld [wPokedexShowPointerAddr], a
ld a, h
- ld [wd26c], a
+ ld [wPokedexShowPointerAddr + 1], a
ld a, d
- ld [wd26d], a
+ ld [wPokedexShowPointerBank], a
ret
; b8b30 (2e:4b30)
@@ -1302,9 +1302,9 @@
jp NextRadioLine
; b8d3e (2e:4d3e)
-.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION ; $0b, $0d, $0e, $0f, $10
-.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE ; $11, $12, $13, $15, $1a, $23, $2e, $40
-.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED ; $09, $0a, $0c, $2a, $3f
+.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION
+.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE
+.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED
db -1
; b8d51
@@ -1507,11 +1507,11 @@
ld l, a
call CopyRadioTextToRAM
call Random
- cp $a ; 6.25 percent
+ cp 4 percent
ld a, PLACES_AND_PEOPLE
jr c, .ok
call Random
- cp $7b ; 48 percent
+ cp 1 + 48 percent
ld a, PLACES_AND_PEOPLE_4 ; People
jr c, .ok
ld a, PLACES_AND_PEOPLE_6 ; Places
@@ -1653,26 +1653,26 @@
PokeFluteRadio: ; b8ef7 (2e:4ef7)
call StartRadioStation
ld a, 1
- ld [wd005], a
+ ld [wNumRadioLinesPrinted], a
ret
UnownRadio: ; b8f00 (2e:4f00)
call StartRadioStation
ld a, 1
- ld [wd005], a
+ ld [wNumRadioLinesPrinted], a
ret
EvolutionRadio: ; b8f09 (2e:4f09)
call StartRadioStation
ld a, 1
- ld [wd005], a
+ ld [wNumRadioLinesPrinted], a
ret
BuenasPassword1: ; b8f12 (2e:4f12)
; Determine if we need to be here
- call BuenasPasswordCheckMidnight
+ call BuenasPasswordCheckTime
jp nc, .PlayPassword
- ld a, [wd005]
+ ld a, [wNumRadioLinesPrinted]
and a
jp z, BuenasPassword20
jp BuenasPassword8
@@ -1698,7 +1698,7 @@
jp NextRadioLine
BuenasPassword3: ; b8f47 (2e:4f47)
- call BuenasPasswordCheckMidnight
+ call BuenasPasswordCheckTime
ld hl, UnknownText_0xb918c
jp c, BuenasPasswordAfterMidnight
ld a, BUENAS_PASSWORD_4
@@ -1705,7 +1705,7 @@
jp NextRadioLine
BuenasPassword4: ; b8f55 (2e:4f55)
- call BuenasPasswordCheckMidnight
+ call BuenasPasswordCheckTime
jp c, BuenasPassword8
ld a, [wBuenasPassword]
; If we already generated the password today, we don't need to generate a new one.
@@ -1716,7 +1716,7 @@
.greater_than_11
call Random
and $f
- cp $b
+ cp NUM_PASSWORD_CATEGORIES
jr nc, .greater_than_11
; Store it in the high nybble of e.
swap a
@@ -1725,7 +1725,7 @@
.greater_than_three
call Random
and $3
- cp $3
+ cp NUM_PASSWORDS_PER_CATEGORY
jr nc, .greater_than_three
; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password.
add e
@@ -1808,7 +1808,7 @@
ld l, c
add hl, de
ld a, [hl]
- ld [wd265], a
+ ld [wNamedObjectIndexBuffer], a
ret
.RawString: ; b8fde (2e:4fde)
@@ -1874,7 +1874,7 @@
jp NextRadioLine
BuenasPassword7: ; b90ac (2e:50ac)
- call BuenasPasswordCheckMidnight
+ call BuenasPasswordCheckTime
ld hl, UnknownText_0xb91a0
jr c, BuenasPasswordAfterMidnight
ld a, BUENAS_PASSWORD
@@ -1959,29 +1959,29 @@
ld [hBGMapMode], a ; $ff00+$d4
ld hl, WeeklyFlags
res 7, [hl]
- ld a, $4
- ld [wd002], a
+ ld a, BUENAS_PASSWORD
+ ld [wCurrentRadioLine], a
xor a
- ld [wd005], a
+ ld [wNumRadioLinesPrinted], a
ld hl, UnknownText_0xb91d7
ld a, BUENAS_PASSWORD_21
jp NextRadioLine
BuenasPassword21: ; b9152 (2e:5152)
- ld a, $4
- ld [wd002], a
+ ld a, BUENAS_PASSWORD
+ ld [wCurrentRadioLine], a
xor a
- ld [wd005], a
- call BuenasPasswordCheckMidnight
+ ld [wNumRadioLinesPrinted], a
+ call BuenasPasswordCheckTime
jp nc, BuenasPassword1
ld hl, UnknownText_0xb91d7
ld a, BUENAS_PASSWORD_21
jp NextRadioLine
-BuenasPasswordCheckMidnight: ; b9169 (2e:5169)
+BuenasPasswordCheckTime: ; b9169 (2e:5169)
call UpdateTime
ld a, [hHours] ; $ff00+$94
- cp $12
+ cp 18 ; 6 PM
ret
; b9171 (2e:5171)
@@ -2100,19 +2100,19 @@
CopyRadioTextToRAM: ; b91dc (2e:51dc)
ld a, [hl]
cp TX_FAR
- jp z, FarJumpText
- ld de, wd00c
+ jp z, FarCopyRadioText
+ ld de, wRadioText
ld bc, SCREEN_WIDTH * 2
jp CopyBytes
StartRadioStation: ; b91eb (2e:51eb)
- ld a, [wd005]
+ ld a, [wNumRadioLinesPrinted]
and a
ret nz
call RadioTerminator
call PrintText
ld hl, RadioChannelSongs
- ld a, [wd002]
+ ld a, [wCurrentRadioLine]
ld c, a
ld b, 0
rept 2
--- a/event/mom.asm
+++ b/event/mom.asm
@@ -510,7 +510,7 @@
ld de, StringBuffer2
lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6
call PrintNum
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $10
jr nz, .skip
hlcoord 13, 6
--- a/gbhw.asm
+++ b/gbhw.asm
@@ -59,6 +59,7 @@
rNR12 EQU $ff12 ; Channel 1 Volume Envelope (R/W)
rNR13 EQU $ff13 ; Channel 1 Frequency lo (Write Only)
rNR14 EQU $ff14 ; Channel 1 Frequency hi (R/W)
+rNR20 EQU $ff15 ; Channel 2 Sweep register (R/W)
rNR21 EQU $ff16 ; Channel 2 Sound Length/Wave Pattern Duty (R/W)
rNR22 EQU $ff17 ; Channel 2 Volume Envelope (R/W)
rNR23 EQU $ff18 ; Channel 2 Frequency lo data (W)
@@ -68,6 +69,7 @@
rNR32 EQU $ff1c ; Channel 3 Select output level (R/W)
rNR33 EQU $ff1d ; Channel 3 Frequency's lower data (W)
rNR34 EQU $ff1e ; Channel 3 Frequency's higher data (R/W)
+rNR40 EQU $ff1f ; Channel 4 Sweep register (R/W)
rNR41 EQU $ff20 ; Channel 4 Sound Length (R/W)
rNR42 EQU $ff21 ; Channel 4 Volume Envelope (R/W)
rNR43 EQU $ff22 ; Channel 4 Polynomial Counter (R/W)
@@ -75,6 +77,22 @@
rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W)
rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W)
rNR52 EQU $ff26 ; Sound on/off
+rWave_0 EQU $ff30
+rWave_1 EQU $ff31
+rWave_2 EQU $ff32
+rWave_3 EQU $ff33
+rWave_4 EQU $ff34
+rWave_5 EQU $ff35
+rWave_6 EQU $ff36
+rWave_7 EQU $ff37
+rWave_8 EQU $ff38
+rWave_9 EQU $ff39
+rWave_a EQU $ff3a
+rWave_b EQU $ff3b
+rWave_c EQU $ff3c
+rWave_d EQU $ff3d
+rWave_e EQU $ff3e
+rWave_f EQU $ff3f
rLCDC EQU $ff40 ; LCD Control (R/W)
rSTAT EQU $ff41 ; LCDC Status (R/W)
rSCY EQU $ff42 ; Scroll Y (R/W)
--- a/home.asm
+++ b/home.asm
@@ -1460,17 +1460,17 @@
pop af
ld [hLastTalked], a
ld a, b
- ld [CurFruit], a
+ ld [EngineBuffer2], a
ld a, c
- ld [wd040], a
+ ld [EngineBuffer3], a
jr Function367e
; 3674
Function3674:: ; 3674
ld a, 1
- ld [CurFruit], a
+ ld [EngineBuffer2], a
ld a, -1
- ld [wd040], a
+ ld [EngineBuffer3], a
Function367e:: ; 367e
call GetMapScriptHeaderBank
--- a/home/battle.asm
+++ b/home/battle.asm
@@ -234,7 +234,7 @@
; 3a90
-FarJumpText:: ; 3a90
+FarCopyRadioText:: ; 3a90
inc hl
ld a, [hROMBank]
push af
@@ -249,8 +249,8 @@
ld l, a
ld a, d
ld h, a
- ld de, wd00c
- ld bc, $0028
+ ld de, wRadioText
+ ld bc, 2 * SCREEN_WIDTH
call CopyBytes
pop af
ld [hROMBank], a
--- a/home/joypad.asm
+++ b/home/joypad.asm
@@ -437,7 +437,7 @@
; af5
.blink_cursor: ; af5
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and %00010000 ; bit 4, a
jr z, .cursor_off
ld a, "▼"
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -1,29 +1,29 @@
-Function1b1e:: ; 1b1e
- ld [wd003], a
+InitMovementBuffer:: ; 1b1e
+ ld [wMovementBufferPerson], a
xor a
- ld [DefaultFlypoint], a
- ld a, $0
+ ld [wMovementBufferCount], a
+ ld a, $0 ; useless
ld [wd004], a
ld a, $7
- ld [StartFlypoint], a
+ ld [wd005], a
ld a, $d0
- ld [EndFlypoint], a
+ ld [wd006], a
ret
; 1b35
-Function1b35:: ; 1b35
- ld a, [DefaultFlypoint]
+DecrementMovementBufferCount:: ; 1b35
+ ld a, [wMovementBufferCount]
and a
ret z
dec a
- ld [DefaultFlypoint], a
+ ld [wMovementBufferCount], a
ret
; 1b3f
-Function1b3f:: ; 1b3f
+AppendToMovementBuffer:: ; 1b3f
push hl
push de
- ld hl, DefaultFlypoint
+ ld hl, wMovementBufferCount
ld e, [hl]
inc [hl]
ld d, 0
@@ -35,47 +35,50 @@
ret
; 1b50
-Function1b50:: ; 1b50
+AppendToMovementBufferNTimes:: ; 1b50
push af
ld a, c
and a
- jr nz, .asm_1b57
+ jr nz, .okay
pop af
ret
-.asm_1b57
+.okay
pop af
-.asm_1b58
- call Function1b3f
+.loop
+ call AppendToMovementBuffer
dec c
- jr nz, .asm_1b58
+ jr nz, .loop
ret
; 1b5f
-Function1b5f:: ; 1b5f
+ComputePathToWalkToPlayer:: ; 1b5f
push af
+; compare x coords, load left/right into h, and x distance into d
ld a, b
sub d
- ld h, $2
- jr nc, .asm_1b6a
+ ld h, LEFT
+ jr nc, .got_x_distance
dec a
cpl
- ld h, $3
+ ld h, RIGHT
-.asm_1b6a
+.got_x_distance
ld d, a
+; compare y coords, load up/down into l, and y distance into e
ld a, c
sub e
- ld l, $1
- jr nc, .asm_1b75
+ ld l, UP
+ jr nc, .got_y_distance
dec a
cpl
- ld l, $0
+ ld l, DOWN
-.asm_1b75
+.got_y_distance
ld e, a
+; if the x distance is less than the y distance, swap h and l, and swap d and e
cp d
- jr nc, .asm_1b7f
+ jr nc, .done
ld a, h
ld h, l
ld l, a
@@ -83,21 +86,23 @@
ld d, e
ld e, a
-.asm_1b7f
+.done
pop af
ld b, a
+; Add movement in the longer direction first...
ld a, h
- call Function1b92
+ call .GetMovementData
ld c, d
- call Function1b50
+ call AppendToMovementBufferNTimes
+; ... then add the shorter direction.
ld a, l
- call Function1b92
+ call .GetMovementData
ld c, e
- call Function1b50
+ call AppendToMovementBufferNTimes
ret
; 1b92
-Function1b92:: ; 1b92
+.GetMovementData: ; 1b92
push de
push hl
ld l, b
@@ -108,7 +113,7 @@
ld e, a
ld d, 0
add hl, de
- ld de, .data_1ba5
+ ld de, .MovementData
add hl, de
ld a, [hl]
pop hl
@@ -116,8 +121,19 @@
ret
; 1ba5
-.data_1ba5
- db 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
+.MovementData
+ slow_step_down
+ slow_step_up
+ slow_step_left
+ slow_step_right
+ step_down
+ step_up
+ step_left
+ step_right
+ big_step_down
+ big_step_up
+ big_step_left
+ big_step_right
; 1bb1
Function1bb1:: ; 1bb1
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -64,7 +64,7 @@
; sound
; inc frame counter
- ld hl, $ff9b
+ ld hl, hVBlankCounter
inc [hl]
; advance random variables
@@ -418,7 +418,7 @@
ld [hROMBankBackup], a
; inc frame counter
- ld hl, $ff9b
+ ld hl, hVBlankCounter
inc [hl]
call UpdateCGBPals
--- a/main.asm
+++ b/main.asm
@@ -1149,7 +1149,7 @@
; 6292
Function6292: ; 6292 ; unreferenced
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $7
ret nz
ld hl, LYOverrides + $5f
@@ -3688,28 +3688,29 @@
TrainerWalkToPlayer: ; 831e
ld a, [hLastTalked]
- call Function1b1e
- ld a, $3e
- call Function1b3f
+ call InitMovementBuffer
+ ld a, movement_show_person
+ call AppendToMovementBuffer
ld a, [wd03f]
dec a
- jr z, Function833b
+ jr z, .TerminateStep
ld a, [hLastTalked]
ld b, a
- ld c, 0
+ ld c, PLAYER
ld d, 1
- call Function8341
- call Function1b35
+ call .GetPathToPlayer
+ call DecrementMovementBufferCount
-Function833b
- ld a, $47
- call Function1b3f
+.TerminateStep
+ ld a, movement_step_end
+ call AppendToMovementBuffer
ret
; 8341
-Function8341: ; 8341
+.GetPathToPlayer: ; 8341
push de
push bc
+; get player object struct, load to de
ld a, c
call GetMapObject
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
@@ -3718,6 +3719,8 @@
call GetObjectStruct
ld d, b
ld e, c
+
+; get last talked object struct, load to bc
pop bc
ld a, b
call GetMapObject
@@ -3725,6 +3728,8 @@
add hl, bc
ld a, [hl]
call GetObjectStruct
+
+; get last talked coords, load to bc
ld hl, OBJECT_MAP_X
add hl, bc
ld a, [hl]
@@ -3732,6 +3737,8 @@
add hl, bc
ld c, [hl]
ld b, a
+
+; get player coords, load to de
ld hl, OBJECT_MAP_X
add hl, de
ld a, [hl]
@@ -3739,21 +3746,22 @@
add hl, de
ld e, [hl]
ld d, a
+
pop af
- call Function1b5f
+ call ComputePathToWalkToPlayer
ret
; 8379
Special_SurfStartStep: ; 8379
- call Function1b1e
- call Function8388
- call Function1b3f
- ld a, $47
- call Function1b3f
+ call InitMovementBuffer
+ call .GetMovementData
+ call AppendToMovementBuffer
+ ld a, movement_step_end
+ call AppendToMovementBuffer
ret
; 8388
-Function8388: ; 8388
+.GetMovementData: ; 8388
ld a, [PlayerDirection]
srl a
srl a
@@ -3760,14 +3768,17 @@
and 3
ld e, a
ld d, 0
- ld hl, .data_839a
+ ld hl, .movement_data
add hl, de
ld a, [hl]
ret
; 839a
-.data_839a
- db 8 + DOWN, 8 + UP, 8 + LEFT, 8 + RIGHT
+.movement_data
+ slow_step_down
+ slow_step_up
+ slow_step_left
+ slow_step_right
; 839e
@@ -23185,7 +23196,7 @@
ld de, GameTimeMinutes
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $1f
ret nz
hlcoord 15, 12
@@ -23195,7 +23206,7 @@
ret
Function25438: ; 25438 (9:5438)
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $7
ret nz
ld a, [wcf64]
@@ -59041,7 +59052,7 @@
; 91dcd
Function91dcd: ; 91dcd
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
ld e, a
and $f
ret nz
@@ -64357,7 +64368,7 @@
.CheckTheCard: ; e02da
xor a
- ld [$ff9b], a
+ ld [hVBlankCounter], a
call Functione0960
call WaitSFX
ld de, SFX_CHOOSE_A_CARD
@@ -65463,7 +65474,7 @@
ld a, [hCGB]
and a
jr nz, .asm_e096d
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $4
ret nz
@@ -65867,7 +65878,7 @@
ld a, [wcf64]
and a
jr nz, .asm_e1230
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and $10
jr z, .asm_e1235
--- a/maps/Route38.asm
+++ b/maps/Route38.asm
@@ -6,9 +6,9 @@
db 0
TrainerBird_keeperToby:
- trainer EVENT_BEAT_BIRD_KEEPER_TOBY, BIRD_KEEPER, TOBY, Bird_keeperTobySeenText, Bird_keeperTobyBeatenText, 0, Bird_keeperTobyScript
+ trainer EVENT_BEAT_BIRD_KEEPER_TOBY, BIRD_KEEPER, TOBY, Bird_keeperTobySeenText, Bird_keeperTobyBeatenText, 0, .script
-Bird_keeperTobyScript:
+.script:
talkaftercancel
loadfont
writetext UnknownText_0x1a1f86
@@ -17,9 +17,9 @@
end
TrainerSailorHarry:
- trainer EVENT_BEAT_SAILOR_HARRY, SAILOR, HARRY, SailorHarrySeenText, SailorHarryBeatenText, 0, SailorHarryScript
+ trainer EVENT_BEAT_SAILOR_HARRY, SAILOR, HARRY, SailorHarrySeenText, SailorHarryBeatenText, 0, .script
-SailorHarryScript:
+.script:
talkaftercancel
loadfont
writetext UnknownText_0x1a220c
@@ -28,38 +28,38 @@
end
TrainerLassDana1:
- trainer EVENT_BEAT_LASS_DANA, LASS, DANA1, LassDana1SeenText, LassDana1BeatenText, 0, LassDana1Script
+ trainer EVENT_BEAT_LASS_DANA, LASS, DANA1, LassDana1SeenText, LassDana1BeatenText, 0, .script
-LassDana1Script:
+.script:
writecode VAR_CALLERID, PHONE_LASS_DANA
talkaftercancel
loadfont
checkflag ENGINE_DANA
- iftrue UnknownScript_0x1a1d82
+ iftrue .DanaRematch
checkflag ENGINE_DANA_HAS_THUNDERSTONE
- iftrue UnknownScript_0x1a1df6
+ iftrue .TryGiveThunderstone
checkcellnum PHONE_LASS_DANA
- iftrue UnknownScript_0x1a1e17
+ iftrue .NumberAccepted
checkevent EVENT_DANA_ASKED_FOR_PHONE_NUMBER
- iftrue UnknownScript_0x1a1d6b
+ iftrue .SecondTimeAsking
writetext UnknownText_0x1a20ec
keeptextopen
setevent EVENT_DANA_ASKED_FOR_PHONE_NUMBER
- scall UnknownScript_0x1a1e0b
- jump UnknownScript_0x1a1d6e
+ scall .AskNumber1F
+ jump .AskForPhoneNumber
-UnknownScript_0x1a1d6b:
- scall UnknownScript_0x1a1e0f
-UnknownScript_0x1a1d6e:
+.SecondTimeAsking:
+ scall .AskNumber2F
+.AskForPhoneNumber:
askforphonenumber PHONE_LASS_DANA
- if_equal $1, UnknownScript_0x1a1e1f
- if_equal $2, UnknownScript_0x1a1e1b
+ if_equal $1, .PhoneFull
+ if_equal $2, .DeclinedPhoneNumber
trainertotext LASS, DANA1, $0
- scall UnknownScript_0x1a1e13
- jump UnknownScript_0x1a1e17
+ scall .RegisteredPhoneNumber
+ jump .NumberAccepted
-UnknownScript_0x1a1d82:
- scall UnknownScript_0x1a1e23
+.DanaRematch:
+ scall .Rematch
winlosstext LassDana1BeatenText, 0
copybytetovar wDanaFightCount
if_equal 4, .Fight4
@@ -118,84 +118,84 @@
clearflag ENGINE_DANA
end
-UnknownScript_0x1a1df6:
- scall UnknownScript_0x1a1e27
+.TryGiveThunderstone:
+ scall .Gift
verbosegiveitem THUNDERSTONE
- iffalse UnknownScript_0x1a1e08
+ iffalse .NoRoomForThunderstone
clearflag ENGINE_DANA_HAS_THUNDERSTONE
setevent EVENT_DANA_GAVE_THUNDERSTONE
- jump UnknownScript_0x1a1e17
+ jump .NumberAccepted
-UnknownScript_0x1a1e08:
- jump UnknownScript_0x1a1e2b
+.NoRoomForThunderstone:
+ jump .PackFull
-UnknownScript_0x1a1e0b:
+.AskNumber1F:
jumpstd asknumber1f
end
-UnknownScript_0x1a1e0f:
+.AskNumber2F:
jumpstd asknumber2f
end
-UnknownScript_0x1a1e13:
+.RegisteredPhoneNumber:
jumpstd registerednumberf
end
-UnknownScript_0x1a1e17:
+.NumberAccepted:
jumpstd numberacceptedf
end
-UnknownScript_0x1a1e1b:
+.DeclinedPhoneNumber:
jumpstd numberdeclinedf
end
-UnknownScript_0x1a1e1f:
+.PhoneFull:
jumpstd phonefullf
end
-UnknownScript_0x1a1e23:
+.Rematch:
jumpstd rematchf
end
-UnknownScript_0x1a1e27:
+.Gift:
jumpstd giftf
end
-UnknownScript_0x1a1e2b:
+.PackFull:
jumpstd packfullf
end
TrainerSchoolboyChad1:
- trainer EVENT_BEAT_SCHOOLBOY_CHAD, SCHOOLBOY, CHAD1, SchoolboyChad1SeenText, SchoolboyChad1BeatenText, 0, SchoolboyChad1Script
+ trainer EVENT_BEAT_SCHOOLBOY_CHAD, SCHOOLBOY, CHAD1, SchoolboyChad1SeenText, SchoolboyChad1BeatenText, 0, .script
-SchoolboyChad1Script:
+.script:
writecode VAR_CALLERID, PHONE_SCHOOLBOY_CHAD
talkaftercancel
loadfont
checkflag ENGINE_CHAD
- iftrue UnknownScript_0x1a1e75
+ iftrue .ChadRematch
checkcellnum PHONE_SCHOOLBOY_CHAD
- iftrue UnknownScript_0x1a1ef5
+ iftrue .HaveChadsNumber
checkevent EVENT_CHAD_ASKED_FOR_PHONE_NUMBER
- iftrue UnknownScript_0x1a1e5e
+ iftrue .SecondTimeAsking
writetext UnknownText_0x1a200e
keeptextopen
setevent EVENT_CHAD_ASKED_FOR_PHONE_NUMBER
- scall UnknownScript_0x1a1ee9
- jump UnknownScript_0x1a1e61
+ scall .AskPhoneNumber1
+ jump .AskToRegisterNumber
-UnknownScript_0x1a1e5e:
- scall UnknownScript_0x1a1eed
-UnknownScript_0x1a1e61:
+.SecondTimeAsking:
+ scall .AskPhoneNumber2
+.AskToRegisterNumber:
askforphonenumber PHONE_SCHOOLBOY_CHAD
- if_equal $1, UnknownScript_0x1a1efd
- if_equal $2, UnknownScript_0x1a1ef9
+ if_equal $1, .PhoneFull
+ if_equal $2, .SaidNo
trainertotext SCHOOLBOY, CHAD1, $0
- scall UnknownScript_0x1a1ef1
- jump UnknownScript_0x1a1ef5
+ scall .RegisteredChad
+ jump .HaveChadsNumber
-UnknownScript_0x1a1e75:
- scall UnknownScript_0x1a1f01
+.ChadRematch:
+ scall .Rematch
winlosstext SchoolboyChad1BeatenText, 0
copybytetovar wChadFightCount
if_equal 4, .Fight4
@@ -254,38 +254,38 @@
clearflag ENGINE_CHAD
end
-UnknownScript_0x1a1ee9:
+.AskPhoneNumber1:
jumpstd asknumber1m
end
-UnknownScript_0x1a1eed:
+.AskPhoneNumber2:
jumpstd asknumber2m
end
-UnknownScript_0x1a1ef1:
+.RegisteredChad:
jumpstd registerednumberm
end
-UnknownScript_0x1a1ef5:
+.HaveChadsNumber:
jumpstd numberacceptedm
end
-UnknownScript_0x1a1ef9:
+.SaidNo:
jumpstd numberdeclinedm
end
-UnknownScript_0x1a1efd:
+.PhoneFull:
jumpstd phonefullm
end
-UnknownScript_0x1a1f01:
+.Rematch:
jumpstd rematchm
end
TrainerBeautyValerie:
- trainer EVENT_BEAT_BEAUTY_VALERIE, BEAUTY, VALERIE, BeautyValerieSeenText, BeautyValerieBeatenText, 0, BeautyValerieScript
+ trainer EVENT_BEAT_BEAUTY_VALERIE, BEAUTY, VALERIE, BeautyValerieSeenText, BeautyValerieBeatenText, 0, .script
-BeautyValerieScript:
+.script:
talkaftercancel
loadfont
writetext UnknownText_0x1a2185
@@ -294,9 +294,9 @@
end
TrainerBeautyOlivia:
- trainer EVENT_BEAT_BEAUTY_OLIVIA, BEAUTY, OLIVIA, BeautyOliviaSeenText, BeautyOliviaBeatenText, 0, BeautyOliviaScript
+ trainer EVENT_BEAT_BEAUTY_OLIVIA, BEAUTY, OLIVIA, BeautyOliviaSeenText, BeautyOliviaBeatenText, 0, .script
-BeautyOliviaScript:
+.script:
talkaftercancel
loadfont
writetext UnknownText_0x1a229a
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -2357,38 +2357,45 @@
asm_100f02:
ld a, c
ld [StringBuffer2], a
+ ; someting that was previously stored in de gets backed up to here
ld a, e
ld [StringBuffer2 + 1], a
ld a, d
ld [StringBuffer2 + 2], a
+ ; empty this
xor a
ld [StringBuffer2 + 4], a
ld [StringBuffer2 + 5], a
-.asm_100f15
+.loop
ld a, [hl]
cp $ff
- jr z, .asm_100f34
- ld [StringBuffer2 + 3], a
+ jr z, .done
+ ld [StringBuffer2 + 3], a ; bank
push hl
inc hl
+ ; addr 1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
+ ; size
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
+ ; addr 2
ld a, [hli]
ld h, [hl]
ld l, a
call Function100f3d
+ ; next line
pop hl
ld de, $0007
add hl, de
- jr .asm_100f15
+ jr .loop
-.asm_100f34
+.done
+ ; recover the values into bc
ld a, [StringBuffer2 + 4]
ld c, a
ld a, [StringBuffer2 + 5]
@@ -2397,16 +2404,20 @@
; 100f3d
Function100f3d: ; 100f3d
+ ; parameter
ld a, [StringBuffer2]
cp $2
- jr z, .asm_100f61
+ jr z, .two
cp $1
- jr z, .asm_100f77
+ jr z, .one
cp $3
- jr z, .asm_100f4d
+ jr z, .three
ret
-.asm_100f4d
+.three
+ ; what was once in de gets copied to hl,
+ ; modified by Function100f8d, and put back
+ ; into this backup
ld a, [StringBuffer2 + 1]
ld l, a
ld a, [StringBuffer2 + 2]
@@ -2418,7 +2429,9 @@
ld [StringBuffer2 + 2], a
ret
-.asm_100f61
+.two
+ ; hl gets backed up to de, then
+ ; do the same as in .three
ld d, h
ld e, l
ld a, [StringBuffer2 + 1]
@@ -2432,7 +2445,11 @@
ld [StringBuffer2 + 2], a
ret
-.asm_100f77
+.one
+ ; de gets copied to hl, then
+ ; load the backup into de,
+ ; finally run Function100f8d
+ ; and store the de result
ld h, d
ld l, e
ld a, [StringBuffer2 + 1]
@@ -2462,18 +2479,18 @@
ld a, [StringBuffer2 + 3]
bit 7, a
res 7, a
- jr z, .asm_100fb6
+ jr z, .sram
and a
- jr nz, .asm_100fb0
+ jr nz, .wram
call CopyBytes
ret
-.asm_100fb0
+.wram
and $7f
call FarCopyWRAM
ret
-.asm_100fb6
+.sram
call GetSRAMBank
call CopyBytes
call CloseSRAM
@@ -2481,16 +2498,20 @@
; 100fc0
Unknown_100fc0: ; 100fc0
- dbwww $80, PlayerName, NAME_LENGTH, wd26b
+ ; first byte:
+ ; Bit 7 set: Not SRAM
+ ; Lower 7 bits: Bank
+ ; Address, size (dw), address
+ dbwww $80, PlayerName, NAME_LENGTH, OTPlayerName
dbwww $80, PartyCount, 1 + PARTY_LENGTH + 1, OTPartyCount
- dbwww $80, PlayerID, 2, wd276
- dbwww $80, PartyMons, $30 * PARTY_LENGTH, OTPartyMons
+ dbwww $80, PlayerID, 2, OTPlayerID
+ dbwww $80, PartyMons, PARTYMON_STRUCT_LENGTH * PARTY_LENGTH, OTPartyMons
dbwww $80, PartyMonOT, NAME_LENGTH * PARTY_LENGTH, OTPartyMonOT
dbwww $80, PartyMonNicknames, PKMN_NAME_LENGTH * PARTY_LENGTH, OTPartyMonNicknames
db -1
Unknown_100feb: ; 100feb
- dbwww $00, $a600, $2f * PARTY_LENGTH, NULL
+ dbwww $00, sPartyScratch1, SCRATCHMON_STRUCT_LENGTH * PARTY_LENGTH, NULL
db -1
Unknown_100ff3: ; 100ff3
@@ -2501,15 +2522,15 @@
dbwww $80, wSecretID, 2, NULL
dbwww $80, PlayerGender, 1, NULL
dbwww $04, $a603, 8, NULL
- dbwww $04, $a007, $30, NULL
+ dbwww $04, $a007, PARTYMON_STRUCT_LENGTH, NULL
db -1
Unknown_10102c: ; 10102c
- dbwww $80, wd26b, 11, NULL
- dbwww $80, wd276, 2, NULL
+ dbwww $80, OTPlayerName, 11, NULL
+ dbwww $80, OTPlayerID, 2, NULL
dbwww $80, OTPartyMonNicknames, PKMN_NAME_LENGTH * PARTY_LENGTH, NULL
dbwww $80, OTPartyMonOT, NAME_LENGTH * PARTY_LENGTH, NULL
- dbwww $80, OTPartyMons, $30 * PARTY_LENGTH, NULL
+ dbwww $80, OTPartyMons, PARTYMON_STRUCT_LENGTH * PARTY_LENGTH, NULL
db -1
; 10104f
--- a/tilesets/animations.asm
+++ b/tilesets/animations.asm
@@ -1008,7 +1008,7 @@
; Ready for BGPD input...
ld a, %10100000 ; auto-increment, index $20 (pal 4 color 0)
ld [rBGPI], a
- ld a, [$ff9b]
+ ld a, [hVBlankCounter]
and %00000010
jr nz, .bit1set
ld hl, Unkn1Pals + $20 ; pal 4 color 0
--- a/wram.asm
+++ b/wram.asm
@@ -1395,26 +1395,33 @@
PhoneScriptBank::
DefaultFlypoint:: ; d002
LuckyNumberDigit1Buffer::
+wCurrentRadioLine::
+wMovementBufferCount::
ds 1
wd003::
MiscBuffer3::
LuckyNumberDigit2Buffer::
PhoneCallerLo::
+wNextRadioLine::
+wMovementBufferPerson::
ds 1
wd004::
MiscBuffer4::
LuckyNumberDigit3Buffer::
PhoneCallerHi::
+wRadioTextDelay::
ds 1
wd005::
MiscBuffer5::
LuckyNumberDigit4Buffer::
StartFlypoint:: ; d005
+wNumRadioLinesPrinted::
ds 1
wd006::
MiscBuffer6::
LuckyNumberDigit5Buffer::
EndFlypoint:: ; d006
+wOaksPkmnTalkSegmentCounter::
ds 1
wd007::
@@ -1425,6 +1432,11 @@
wd008:: ds 2
wd00a:: ds 1
wd00b:: ds 1
+
+wRadioText:: ds 2 * SCREEN_WIDTH
+wRadioTextEnd::
+ ds wRadioText - @
+
wd00c:: ds 1
wd00d:: ds 1
wd00e:: ds 1
@@ -1474,20 +1486,27 @@
wd041::
EngineBuffer4::
+wTempTrainerEventFlagLo::
ds 1
+
+wTempTrainerEventFlagHi::
MovementAnimation:: ; d042
ds 1
+wTempTrainerClass::
WalkingDirection:: ; d043
ds 1
+wTempTrainerID::
FacingDirection:: ; d044
ds 1
+wSeenTextPointer::
WalkingX:: ; d045
ds 1
WalkingY:: ; d046
ds 1
+
WalkingTile:: ; d047
wWinTextPointer::
ds 1
@@ -1494,11 +1513,13 @@
wd048:: ds 1
wLossTextPointer:: ds 2
+wScriptAfterPointer::
wd04b:: ds 2
wd04d:: ds 1
MenuItemsListEnd::
wd04e:: ds 2
-wd050:: ds 10
+wOaksPkmnTalkPkmnNameBuffer::
+wd050:: ds PKMN_NAME_LENGTH +- 1
wd05a:: ds 12
wd066:: ds 10
wd070:: ds 3
@@ -1929,11 +1950,16 @@
ds 1
SECTION "Enemy Party", WRAMX, BANK [1]
-OTPlayerName::
+OTPlayerName:: ds NAME_LENGTH
+ ds OTPlayerName - @
+wPokedexShowPointerAddr::
wd26b:: ds 1
wd26c:: ds 1
-wd26d:: ds 4
+wPokedexShowPointerBank::
+wd26d:: ds 1
+ ds 3
wd271:: ds 5
+OTPlayerID::
wd276:: ds 10
OTPartyCount:: ds 1 ; d280