summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/bank3c.asm158
-rwxr-xr-xengine/hidden_object_functions17.asm2
-rwxr-xr-xengine/items/items.asm4
-rwxr-xr-xengine/overworld/pokecenter.asm2
-rwxr-xr-xengine/pikachu_emotions.asm171
-rwxr-xr-xengine/pikachu_pic_animation.asm4
-rwxr-xr-xengine/vermilion_gym_trash_cans.asm108
7 files changed, 219 insertions, 230 deletions
diff --git a/engine/bank3c.asm b/engine/bank3c.asm
index 99226f51..3683f2b1 100644
--- a/engine/bank3c.asm
+++ b/engine/bank3c.asm
@@ -50,7 +50,7 @@ ResetStatusAndHalveMoneyOnBlackout: ; f0274 (3c:4274)
ld [wJoyIgnore], a
predef_jump HealParty
-Func_f02da: ; f02da (3c:42da)
+SetMapSpecificScriptFlagsOnMapReload: ; f02da (3c:42da)
ld a, [wCurMap]
cp VERMILION_GYM ; ??? new thing about verm gym?
jr z, .verm_gym
@@ -111,9 +111,9 @@ BeachHouse_Block: ; f0914 (3c:4914)
Func_f0a54: ; f0a54 (3c:4a54)
ret
-Func_f0a55: ; f0a55 (3c:4a55)
+LoadUnusedBluesHouseMissableObjectData: ; f0a55 (3c:4a55)
; referenced in an unused function
- ld hl, Pointer_f0a76 ; 3c:4a76
+ ld hl, .MissableObjectsMaps
.loop
ld a, [hli]
cp a, $ff
@@ -121,13 +121,13 @@ Func_f0a55: ; f0a55 (3c:4a55)
ld b, a
ld a, [wCurMap]
cp b
- jr z, .asm_f0a68
+ jr z, .found
inc hl
inc hl
inc hl
jr .loop
-.asm_f0a68
+.found
ld a, [hli]
ld c, a
ld b, 0
@@ -138,16 +138,16 @@ Func_f0a55: ; f0a55 (3c:4a55)
call CopyData
ret
-Pointer_f0a76: ; f0a76 (3c:4a76)
- dbbw BLUES_HOUSE, Pointer_f0a7bEnd - Pointer_f0a7b, Pointer_f0a7b
+.MissableObjectsMaps:
+ dbbw BLUES_HOUSE, .End - .Start, .Start
db $ff
-Pointer_f0a7b:
+.Start:
db 1, HS_DAISY_SITTING_COPY
db 2, HS_DAISY_WALKING_COPY
db 3, HS_TOWN_MAP_COPY
db $ff
-Pointer_f0a7bEnd:
+.End:
TryApplyPikachuMovementData: ; f0a82
ld a, [wd472]
@@ -209,41 +209,14 @@ INCLUDE "scripts/oakslab2.asm"
INCLUDE "scripts/school2.asm"
INCLUDE "scripts/museum1f2.asm"
INCLUDE "scripts/pewterpokecenter2.asm"
-
-Func_f1e22:
- ld hl, PikachuMovementData_f1e2b
- ld b, SPRITE_FACING_RIGHT
- call TryApplyPikachuMovementData
- ret
-
-PikachuMovementData_f1e2b:
- db $00
- db $1d
- db $1f
- db $38
- db $3f
-
+INCLUDE "scripts/pokemontower2_2.asm"
INCLUDE "scripts/celadonmart3_2.asm"
INCLUDE "scripts/celadonmansion1_2.asm"
INCLUDE "scripts/celadonmansion3_2.asm"
-
-Func_f1f23:
- ld hl, PikachuMovementData_f1f2c
- ld b, SPRITE_FACING_DOWN
- call TryApplyPikachuMovementData
- ret
-
-PikachuMovementData_f1f2c:
- db $00
- db $20
- db $1e
- db $35
- db $3f
-
+INCLUDE "scripts/celadongamecorner2.asm"
INCLUDE "scripts/celadondiner2.asm"
INCLUDE "scripts/safarizoneentrance2.asm"
INCLUDE "scripts/cinnabargym3.asm"
-
INCLUDE "scripts/mtmoonpokecenter2.asm"
INCLUDE "data/mapHeaders/beach_house.asm"
@@ -259,111 +232,4 @@ INCLUDE "scripts/ssanne9_2.asm"
INCLUDE "scripts/silphco11_2.asm"
INCLUDE "engine/overworld/hidden_objects.asm"
-
-Func_f2cd0:
- ld d, 0
- ld hl, Jumptable_f2ce1
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call JumpToAddress
- ld e, a
- ld d, 0
- ret
-
-Jumptable_f2ce1:
- dw Func_f2ceb
- dw Func_f2ceb
- dw Func_f2cee
- dw Func_f2cf4
- dw Func_f2d06
-
-Func_f2ceb:
- ld a, 0
- ret
-
-Func_f2cee:
- call Random
- and $1
- ret
-
-Func_f2cf4: ; should return to a, instead returns to b
- call Random
- swap a
- cp 1 * $ff / 3
- ld b, 0
- ret c
- cp 2 * $ff / 3
- ld b, 1
- ret c
- ld b, 2
- ret
-
-Func_f2d06:
- call Random
- and $3
- ret
-
-Func_f2d0c:
- ld hl, GymTrashCans3c
- ld a, [wGymTrashCanIndex]
- ld c, a
- ld b, 0
- ld a, 9
- call AddNTimes
- call AddNTimes ; ????
- ld a, [hli]
- ld [hGymTrashCanRandNumMask], a
- ld e, a
- push hl
- call Func_f2cd0
- pop hl
- add hl, de
- add hl, de
- ld a, [hli]
- ld [wSecondLockTrashCanIndex], a
- ld a, [hl]
- ld [wSecondLockTrashCanIndex + 1], a
- ret
-
-GymTrashCans3c: ; f2d31 (3c:6d31)
-; First byte: number of trashcan entries
-; Following four byte pairs: indices for the second trash can.
-; BUG: Rows that have 3 trashcan entries are sampled incorrectly.
-; The sampling occurs by taking a random number and seeing which
-; third of the range 0-255 the number falls in. However, it returns
-; that value to the wrong register, so the result is never used.
-; Instead of using an offset in [0,1,2], the offset is instead
-; in the full range 0-255. This results in truly random behavior.
- db 4
- db 1,3, 3,1, 1,-1, 3,-1
- db 3
- db 0,2, 2,4, 4,0, -1,-1
- db 4
- db 1,5, 5,1, 1,-1, 5,-1
- db 3
- db 0,4, 4,6, 6,0, -1,-1
- db 4
- db 1,3, 3,1, 5,5, 7,7
- db 3
- db 2,4, 4,8, 8,2, -1,-1
- db 3
- db 3,7, 7,9, 9,3, -1,-1
- db 4
- db 4,8, 6,10, 8,4, 10,6
- db 3
- db 5,7, 7,11, 11,5, -1,-1
- db 3
- db 6,10, 10,12, 12,6, -1,-1
- db 4
- db 7,9, 9,7, 11,13, 13,11
- db 3
- db 8,10, 10,14, 14,8, -1,-1
- db 4
- db 9,13, 13,9, 9,-1, 13,-1
- db 3
- db 10,12, 12,14, 14,10, -1,-1
- db 4
- db 11,13, 13,11, 11,-1, 13,-1
+INCLUDE "engine/vermilion_gym_trash_cans.asm"
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index 31f9befc..58838434 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -365,7 +365,7 @@ GymTrashScript: ; 5ddfc (17:5dfc)
.openFirstLock
; Next can is trying for the second switch.
SetEvent EVENT_1ST_LOCK_OPENED
- callab Func_f2d0c
+ callab Yellow_SampleSecondTrashCan
tx_pre_id VermilionGymTrashSuccesText1
jr .done
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 197e5e5d..96dd0a00 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -1803,8 +1803,8 @@ ItemUsePokeflute: ; dfbd (3:5fbd)
ld hl, PlayedFluteHadEffectText
call PrintText
call ItemUseReloadOverworldData
- ld e, $1a
- callab Func_fd001
+ ldpikaemotion e, PikachuEmotion26
+ callab PlaySpecificPikachuEmotion
ret
.noSnorlaxOrPikachuToWakeUp
diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm
index 51afc383..0f355889 100755
--- a/engine/overworld/pokecenter.asm
+++ b/engine/overworld/pokecenter.asm
@@ -32,7 +32,7 @@ DisplayPokemonCenterDialogue_: ; 6d97 (1:6d97)
call LoadCurrentMapView
call Delay3
call UpdateSprites
- callab Func_fd252 ; todo
+ callab PikachuWalksToNurseJoy ; todo
.notHealingPlayerPikachu
ld hl, NeedYourPokemonText
call PrintText
diff --git a/engine/pikachu_emotions.asm b/engine/pikachu_emotions.asm
index 9040e612..fdb17e69 100755
--- a/engine/pikachu_emotions.asm
+++ b/engine/pikachu_emotions.asm
@@ -1,4 +1,4 @@
-IsPlayerTalkingToPikachu:: ; fcf0c (3f:4f0c)
+IsPlayerTalkingToPikachu: ; fcf0c (3f:4f0c)
ld a, [wd436]
and a
ret z
@@ -185,11 +185,11 @@ DeletedFunction_fcffb: ; fcffb (3f:4ffb)
endr
ret
-Func_fd001:: ; fd001 (3f:5001)
+PlaySpecificPikachuEmotion: ; fd001 (3f:5001)
ld a, e
jr load_expression
-Func_fd004:: ; fd004 (3f:5004)
+TalkToPikachu: ; fd004 (3f:5004)
call MapSpecificPikachuExpression
jr c, load_expression
call GetPikaPicAnimationScriptIndex
@@ -201,42 +201,46 @@ load_expression: ; fd00f (3f:500f)
ret
PikachuEmotionTable: ; fd019 (3f:4019)
- dw PikachuEmotion0_fd115
- dw PikachuEmotion1_fd141
- dw PikachuEmotion2_fd116
- dw PikachuEmotion3_fd160
- dw PikachuEmotion4_fd136
- dw PikachuEmotion5_fd14d
- dw PikachuEmotion6_fd153
- dw PikachuEmotion7_fd128
- dw PikachuEmotion8_fd147
- dw PikachuEmotion9_fd166
- dw PikachuEmotion10_fd11e
- dw PikachuEmotion11_fd173
- dw PikachuEmotion12_fd17a
- dw PikachuEmotion13_fd180
- dw PikachuEmotion14_fd189
- dw PikachuEmotion15_fd191
- dw PikachuEmotion16_fd197
- dw PikachuEmotion17_fd19d
- dw PikachuEmotion18_fd1a3
- dw PikachuEmotion19_fd1a9
- dw PikachuEmotion20_fd1b1
- dw PikachuEmotion21_fd1b9 ; used a fishing rod
- dw PikachuEmotion22_fd1c1
- dw PikachuEmotion23_fd1c7
- dw PikachuEmotion24_fd1cf
- dw PikachuEmotion25_fd1d7
- dw PikachuEmotion26_fd1df ; wake up pikachu in pewter pokemon center
- dw PikachuEmotion27_fd1eb
- dw PikachuEmotion28_fd1f1
- dw PikachuEmotion29_fd1f7
- dw PikachuEmotion30_fd1fc
- dw PikachuEmotion31_fd20a
- dw PikachuEmotion32_fd213
- dw PikachuEmotion33_fd05d
+pikaemotion_def: MACRO
+\1_id: dw \1
+ endm
+
+ pikaemotion_def PikachuEmotion0
+ pikaemotion_def PikachuEmotion1
+ pikaemotion_def PikachuEmotion2
+ pikaemotion_def PikachuEmotion3
+ pikaemotion_def PikachuEmotion4
+ pikaemotion_def PikachuEmotion5
+ pikaemotion_def PikachuEmotion6
+ pikaemotion_def PikachuEmotion7
+ pikaemotion_def PikachuEmotion8
+ pikaemotion_def PikachuEmotion9
+ pikaemotion_def PikachuEmotion10
+ pikaemotion_def PikachuEmotion11
+ pikaemotion_def PikachuEmotion12
+ pikaemotion_def PikachuEmotion13
+ pikaemotion_def PikachuEmotion14
+ pikaemotion_def PikachuEmotion15
+ pikaemotion_def PikachuEmotion16
+ pikaemotion_def PikachuEmotion17
+ pikaemotion_def PikachuEmotion18
+ pikaemotion_def PikachuEmotion19
+ pikaemotion_def PikachuEmotion20
+ pikaemotion_def PikachuEmotion21 ; used a fishing rod
+ pikaemotion_def PikachuEmotion22
+ pikaemotion_def PikachuEmotion23
+ pikaemotion_def PikachuEmotion24
+ pikaemotion_def PikachuEmotion25
+ pikaemotion_def PikachuEmotion26 ; wake up pikachu in pewter pokemon center
+ pikaemotion_def PikachuEmotion27
+ pikaemotion_def PikachuEmotion28
+ pikaemotion_def PikachuEmotion29
+ pikaemotion_def PikachuEmotion30
+ pikaemotion_def PikachuEmotion31
+ pikaemotion_def PikachuEmotion32
+ pikaemotion_def PikachuEmotion33
-PikachuEmotion33_fd05d: ; fd05d (3f:505d)
+PikachuEmotion33: ; fd05d (3f:505d)
db $ff
MapSpecificPikachuExpression: ; fd05e (3f:505e)
@@ -245,10 +249,10 @@ MapSpecificPikachuExpression: ; fd05e (3f:505e)
jr nz, .notFanClub
ld hl, wd492
bit 7, [hl]
- ld a, $1d
+ ldpikaemotion a, PikachuEmotion29
jr z, .set_carry
call CheckPikachuFollowingPlayer
- ld a, $1e
+ ldpikaemotion a, PikachuEmotion30
jr nz, .set_carry
jr .check_pikachu_status
@@ -257,7 +261,7 @@ MapSpecificPikachuExpression: ; fd05e (3f:505e)
cp PEWTER_POKECENTER
jr nz, .notPewterPokecenter
call CheckPikachuFollowingPlayer
- ld a, $1a
+ ldpikaemotion a, PikachuEmotion26
jr nz, .set_carry
jr .check_pikachu_status
@@ -270,16 +274,16 @@ MapSpecificPikachuExpression: ; fd05e (3f:505e)
.check_pikachu_status
call IsPlayerPikachuAsleepInParty
- ld a, $b
+ ldpikaemotion a, PikachuEmotion11
jr c, .set_carry
callab CheckPikachuFaintedOrStatused ; same bank
- ld a, $1c
+ ldpikaemotion a, PikachuEmotion28
jr c, .set_carry
ld a, [wCurMap]
cp POKEMONTOWER_1
jr c, .notInLavenderTower
cp POKEMONTOWER_7 + 1
- ld a, $16
+ ldpikaemotion a, PikachuEmotion22
jr c, .set_carry
.notInLavenderTower
ld a, [wd49c]
@@ -288,7 +292,7 @@ MapSpecificPikachuExpression: ; fd05e (3f:505e)
dec a
ld c, a
ld b, $0
- ld hl, Pointer_fd0cb
+ ld hl, .Emotions
add hl, bc
ld a, [hl]
jr .set_carry
@@ -301,10 +305,14 @@ MapSpecificPikachuExpression: ; fd05e (3f:505e)
scf
ret
-Pointer_fd0cb:
- db $12, $15, $17, $18, $19
+.Emotions:
+ dpikaemotion PikachuEmotion18
+ dpikaemotion PikachuEmotion21
+ dpikaemotion PikachuEmotion23
+ dpikaemotion PikachuEmotion24
+ dpikaemotion PikachuEmotion25
-IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0)
+IsPlayerPikachuAsleepInParty: ; fd0d0 (3f:50d0)
xor a
ld [wWhichPokemon], a
.loop
@@ -328,6 +336,7 @@ IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0)
and SLP
jr z, .done
jr .curMonSleepingPikachu
+
.curMonNotStarterPikachu
ld a, [wWhichPokemon]
cp PARTY_LENGTH - 1
@@ -335,75 +344,77 @@ IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0)
inc a
ld [wWhichPokemon], a
jr .loop
+
.curMonSleepingPikachu
scf
ret
+
.done
and a
ret
INCLUDE "data/pikachu_emotions.asm"
-Func_fd252: ; fd252 (3f:5252)
+PikachuWalksToNurseJoy: ; fd252 (3f:5252)
ld a, $40
ld [h_0xFFFC], a
call LoadPikachuSpriteIntoVRAM
- call Func_fd266
+ call .GetMovementData
and a
- jr z, .asm_fd262
+ jr z, .skip
call ApplyPikachuMovementData
-.asm_fd262
+.skip
xor a
ld [h_0xFFFC], a
ret
-Func_fd266:
- ld a, [wSpriteStateData2 + 15 * 16 + 4]
+.GetMovementData:
+ ld a, [wPikachuMapY]
ld e, a
- ld a, [wSpriteStateData2 + 15 * 16 + 5]
+ ld a, [wPikachuMapX]
ld d, a
ld a, [wYCoord]
add 4
cp e
- jr z, .asm_fd280
- jr nc, .asm_fd27e
- ld hl, Data_fd294
+ jr z, .pikachu_at_same_y_as_player
+ jr nc, .pikachu_above_player
+ ld hl, .PikaMovementData1
ld a, 1
ret
-.asm_fd27e
+.pikachu_above_player
xor a
ret
-.asm_fd280
+.pikachu_at_same_y_as_player
ld a, [wXCoord]
add 4
cp d
- jr c, .asm_fd28e
- ld hl, Data_fd299
+ jr c, .pikachu_to_right_of_player
+ ld hl, .PikaMovementData2
ld a, 2
ret
-.asm_fd28e
- ld hl, Data_fd29d
+.pikachu_to_right_of_player
+ ld hl, .PikaMovementData3
ld a, 3
ret
-Data_fd294:
- db $00
- db $36
- db $2b
- db $34
- db $3f
+.PikaMovementData1:
+ db $00 ; init
+ db $36 ; look up
+ db $2b ; walk up left
+ db $34 ; hop up right
+ db $3f ; ret
-Data_fd299:
- db $00
- db $36
- db $34
- db $3f
+.PikaMovementData2:
+ db $00 ; init
+ db $36 ; look up
+ db $34 ; hop up right
+ db $3f ; ret
-Data_fd29d:
- db $00
- db $36
- db $33
- db $3f
+.PikaMovementData3:
+ db $00 ; init
+ db $36 ; look up
+ db $33 ; hop up left
+ db $3f ; ret
diff --git a/engine/pikachu_pic_animation.asm b/engine/pikachu_pic_animation.asm
index 0295775c..b935da19 100755
--- a/engine/pikachu_pic_animation.asm
+++ b/engine/pikachu_pic_animation.asm
@@ -164,6 +164,10 @@ LoadCurrentPikaPicAnimScriptPointer:
ret
PikaPicAnimPointers:
+pikapic_def: macro
+\1_id: dw \1
+endm
+
pikapic_def PikaPicAnimScript0 ; 00
pikapic_def PikaPicAnimScript1 ; 01
pikapic_def PikaPicAnimScript2 ; 02
diff --git a/engine/vermilion_gym_trash_cans.asm b/engine/vermilion_gym_trash_cans.asm
new file mode 100755
index 00000000..63ac04eb
--- /dev/null
+++ b/engine/vermilion_gym_trash_cans.asm
@@ -0,0 +1,108 @@
+TrashCanRandom:
+ ld d, 0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call JumpToAddress
+ ld e, a
+ ld d, 0
+ ret
+
+.Jumptable:
+ dw .zero
+ dw .one
+ dw .two
+ dw .three
+ dw .four
+
+.zero
+.one
+ ld a, 0
+ ret
+
+.two
+ call Random
+ and $1
+ ret
+
+.three ; should return to a, instead returns to b
+ call Random
+ swap a
+ cp 1 * $ff / 3
+ ld b, 0
+ ret c
+ cp 2 * $ff / 3
+ ld b, 1
+ ret c
+ ld b, 2
+ ret
+
+.four
+ call Random
+ and $3
+ ret
+
+Yellow_SampleSecondTrashCan:
+ ld hl, GymTrashCans3c
+ ld a, [wGymTrashCanIndex]
+ ld c, a
+ ld b, 0
+ ld a, 9
+ call AddNTimes
+ call AddNTimes ; ????
+ ld a, [hli]
+ ld [hGymTrashCanRandNumMask], a
+ ld e, a
+ push hl
+ call TrashCanRandom
+ pop hl
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld [wSecondLockTrashCanIndex], a
+ ld a, [hl]
+ ld [wSecondLockTrashCanIndex + 1], a
+ ret
+
+GymTrashCans3c: ; f2d31 (3c:6d31)
+; First byte: number of trashcan entries
+; Following four byte pairs: indices for the second trash can.
+; BUG: Rows that have 3 trashcan entries are sampled incorrectly.
+; The sampling occurs by taking a random number and seeing which
+; third of the range 0-255 the number falls in. However, it returns
+; that value to the wrong register, so the result is never used.
+; Instead of using an offset in [0,1,2], the offset is instead
+; in the full range 0-255. This results in truly random behavior.
+ db 4
+ db 1,3, 3,1, 1,-1, 3,-1
+ db 3
+ db 0,2, 2,4, 4,0, -1,-1
+ db 4
+ db 1,5, 5,1, 1,-1, 5,-1
+ db 3
+ db 0,4, 4,6, 6,0, -1,-1
+ db 4
+ db 1,3, 3,1, 5,5, 7,7
+ db 3
+ db 2,4, 4,8, 8,2, -1,-1
+ db 3
+ db 3,7, 7,9, 9,3, -1,-1
+ db 4
+ db 4,8, 6,10, 8,4, 10,6
+ db 3
+ db 5,7, 7,11, 11,5, -1,-1
+ db 3
+ db 6,10, 10,12, 12,6, -1,-1
+ db 4
+ db 7,9, 9,7, 11,13, 13,11
+ db 3
+ db 8,10, 10,14, 14,8, -1,-1
+ db 4
+ db 9,13, 13,9, 9,-1, 13,-1
+ db 3
+ db 10,12, 12,14, 14,10, -1,-1
+ db 4
+ db 11,13, 13,11, 11,-1, 13,-1