Further split bank 4

This commit is contained in:
PikalaxALT
2015-11-11 16:11:08 -05:00
parent b522b0f165
commit 91068077f0
41 changed files with 5044 additions and 5035 deletions

View File

@@ -2889,7 +2889,7 @@ AskUseNextPokemon: ; 3d1f8
ForcePlayerMonChoice: ; 3d227
call EmptyBattleTextBox
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
call Function3d2f7
call ForcePickPartyMonInBattle
ld a, [wLinkMode]
@@ -2996,7 +2996,7 @@ IsMobileBattle: ; 3d2f1
Function3d2f7: ; 3d2f7
call WhiteBGMap
Function3d2fa: ; 3d2fa
Function3d2fa: ; switch to fullscreen menu?
callba Function5004f
callba Function50405
callba Function8e85
@@ -3415,7 +3415,7 @@ ResetEnemyBattleVars: ; 3d557
ld a, $8
call Function3d490
call EmptyBattleTextBox
jp LoadPartyMenuDataHeader
jp LoadStandardMenuDataHeader
; 3d57a
ResetBattleParticipants: ; 3d57a
@@ -5233,7 +5233,7 @@ BattleMenu_Pack: ; 3e1c7
and a
jp nz, ItemsCantBeUsed
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
@@ -5328,10 +5328,10 @@ Function3e234: ; 3e234
; 3e28d
BattleMenu_PKMN: ; 3e28d
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
Function3e290:
call ExitMenu
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
call WhiteBGMap
Function3e299:
call Function3d2fa
@@ -5467,7 +5467,7 @@ PlayerSwitch: ; 3e3ad
ld a, [wLinkMode]
and a
jr z, .not_linked
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
call Function3e8e4
call WriteBackup

View File

@@ -8953,7 +8953,7 @@ BattleCommand_BatonPass: ; 379c9
call DelayFrames
; Transition into switchmon menu
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
callba Function3d2f7
callba ForcePickSwitchMonInBattle
@@ -9027,7 +9027,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67
ld a, 1
ld [wd0ec], a
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Function3e8e4
call CallBattleCore
call WriteBackup
@@ -9043,7 +9043,7 @@ BatonPass_LinkEnemySwitch: ; 37a82
and a
ret z
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Function3e8e4
call CallBattleCore

View File

@@ -45,7 +45,7 @@ const_value SET -1
const PLAYEREVENT_4
const PLAYEREVENT_WARP
const PLAYEREVENT_FALL
const PLAYEREVENT_7
const PLAYEREVENT_WHITEOUT
const PLAYEREVENT_HATCH
const PLAYEREVENT_9
NUM_PLAYER_EVENTS EQU const_value

View File

@@ -190,7 +190,7 @@ DoEggStep:: ; 16f3e
OverworldHatchEgg:: ; 16f5e
call ResetWindow
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
call Function16f70
call Function2b4d
call RestartMapMusic
@@ -324,7 +324,7 @@ Function16f7a: ; 16f7a (5:6f7a)
ld [MonType], a
push de
ld b, $0
callba Function116c1
callba NamingScreen
pop hl
ld de, StringBuffer1
call InitName

View File

@@ -38,7 +38,7 @@ RestartClock: ; 20021 (8:4021)
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
call ClearTileMap
ld hl, .Text_SetWithControlPad
call PrintText

View File

@@ -1078,7 +1078,7 @@ PlayerEventScriptPointers: ; 96c0c
dba UnknownScript_0x96c4d ; 4
dba WarpToNewMapScript ; 5
dba FallIntoMapScript ; 6
dba UnknownScript_0x124c8 ; 7
dba Script_OverworldWhiteout ; 7
dba HatchEggScript ; 8
dba UnknownScript_0x96c4f ; 9
dba Invalid_0x96c2d ; 10

View File

@@ -161,7 +161,7 @@ Function4e703: ; 4e703
Function4e708: ; 4e708
call GetBaseData
hlcoord 7, 2
jp Function3786
jp PrepMonFrontpic
; 4e711
Function4e711: ; 4e711

266
engine/healmachineanim.asm Executable file
View File

@@ -0,0 +1,266 @@
HealMachineAnim: ; 12324
; If you have no Pokemon, don't change the buffer. This can lead to some glitchy effects if you have no Pokemon.
ld a, [PartyCount]
and a
ret z
; The location of the healing machine relative to the player is stored in ScriptVar.
; 0: Up and left (Pokemon Center)
; 1: Left (Elm's Lab)
; 2: Up (Hall of Fame)
ld a, [ScriptVar]
ld [Buffer1], a
ld a, [rOBP1]
ld [Buffer2], a
call .DoJumptableFunctions
ld a, [Buffer2]
call Functiond24
ret
; 1233e
.DoJumptableFunctions: ; 1233e
xor a
ld [wd1ec], a
.jumpable_loop
ld a, [Buffer1]
ld e, a
ld d, 0
ld hl, .Pointers
rept 2
add hl, de
endr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wd1ec]
ld e, a
inc a
ld [wd1ec], a
add hl, de
ld a, [hl]
cp 5
jr z, .finish
ld hl, .Jumptable
rst JumpTable
jr .jumpable_loop
.finish
ret
; 12365
.Pointers: ; 12365
dw .Pokecenter
dw .ElmLab
dw .HallOfFame
; 1236b
.Pokecenter: ; 1236b
db 0, 1, 3, 5
.ElmLab: ; 1236f
db 0, 1, 3, 5
.HallOfFame: ; 12373
db 0, 2, 4, 5
; 12377
.Jumptable: ; 12377
dw .LoadGFX
dw .PC_LoadBallsOntoMachine
dw .HOF_LoadBallsOntoMachine
dw .PlayHealMusic
dw .HOF_PlaySFX
dw .dummy_5 ; never encountered
; 12383
.LoadGFX: ; 12383
call .LoadPalettes
ld de, .HealMachineGFX
ld hl, VTiles0 tile $7c
lb bc, BANK(.HealMachineGFX), $2
call Request2bpp
ret
; 12393
.PC_LoadBallsOntoMachine: ; 12393
ld hl, Sprites + $80
ld de, .PC_ElmsLab_TileMap
call .PlaceHealingMachineTile
call .PlaceHealingMachineTile
jr .LoadBallsOntoMachine
.HOF_LoadBallsOntoMachine: ; 123a1
ld hl, Sprites + $80
ld de, .HOF_TileMap
.LoadBallsOntoMachine: ; 123a7
ld a, [PartyCount]
ld b, a
.party_loop
call .PlaceHealingMachineTile
push de
ld de, SFX_SECOND_PART_OF_ITEMFINDER
call PlaySFX
pop de
ld c, 30
call DelayFrames
dec b
jr nz, .party_loop
ret
; 123bf
.PlayHealMusic: ; 123bf
ld de, MUSIC_HEAL
call PlayMusic
jp .FlashPalettes8Times
; 123c8
.HOF_PlaySFX: ; 123c8
ld de, SFX_GAME_FREAK_LOGO_GS
call PlaySFX
call .FlashPalettes8Times
call WaitSFX
ld de, SFX_BOOT_PC
call PlaySFX
ret
; 123db
.dummy_5: ; 123db
ret
; 123dc
.PC_ElmsLab_TileMap: ; 123dc
db $20, $22, $7c, $16
db $20, $26, $7c, $16
db $26, $20, $7d, $16
db $26, $28, $7d, $36
db $2b, $20, $7d, $16
db $2b, $28, $7d, $36
db $30, $20, $7d, $16
db $30, $28, $7d, $36
; 123fc
.HealMachineGFX: ; 123fc
INCBIN "gfx/unknown/0123fc.2bpp"
; 1241c
.HOF_TileMap: ; 1241c
db $3c, $51, $7d, $16
db $3c, $56, $7d, $16
db $3b, $4d, $7d, $16
db $3b, $5a, $7d, $16
db $39, $49, $7d, $16
db $39, $5d, $7d, $16
; 12434
.LoadPalettes: ; 12434
call IsCGB
jr nz, .cgb
ld a, %11100000
ld [rOBP1], a
ret
.cgb
ld hl, .palettes
ld de, OBPals + 8 * 6
ld bc, 8
ld a, $5
call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
ret
; 12451
.palettes: ; 12451
RGB 31, 31, 31
RGB 31, 19, 10
RGB 31, 07, 01
RGB 00, 00, 00
; 12459
.FlashPalettes8Times: ; 12459
ld c, $8
.palette_loop
push bc
call .FlashPalettes
ld c, 10
call DelayFrames
pop bc
dec c
jr nz, .palette_loop
ret
; 12469
.FlashPalettes: ; 12469
call IsCGB
jr nz, .go
ld a, [rOBP1]
xor %00101000
ld [rOBP1], a
ret
.go
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
ld hl, OBPals + 8 * 6
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
push de
ld c, $3
.palette_loop_2
ld a, [hli]
ld e, a
ld a, [hld]
ld d, a
dec hl
ld a, d
ld [hld], a
ld a, e
ld [hli], a
rept 3
inc hl
endr
dec c
jr nz, .palette_loop_2
pop de
dec hl
ld a, d
ld [hld], a
ld a, e
ld [hl], a
pop af
ld [rSVBK], a
ld a, $1
ld [hCGBPalUpdate], a
ret
; 124a3
.PlaceHealingMachineTile: ; 124a3
push bc
ld a, [Buffer1]
lb bc, $10, $20
cp $1 ; ElmsLab
jr z, .okay
lb bc, $00, $00
.okay
ld a, [de]
add c
inc de
ld [hli], a
ld a, [de]
add b
inc de
ld [hli], a
ld a, [de]
inc de
ld [hli], a
ld a, [de]
inc de
ld [hli], a
pop bc
ret
; 124c1

View File

@@ -1676,7 +1676,7 @@ Function28b87: ; 28b87
ld hl, UnknownText_0x28eb8
bccoord 1, 14
call PlaceWholeStringInBoxAtOnce
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
hlcoord 10, 7
ld b, $3
ld c, $7

View File

@@ -36,7 +36,7 @@ MartDialog: ; 15a61
HerbShop: ; 15a6e
call FarReadMart
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Text_HerbShop_Intro
call MartTextBox
call BuyMenu
@@ -50,7 +50,7 @@ BargainShop: ; 15a84
ld de, BargainShopData
call LoadMartPointer
call ReadMart
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Text_BargainShop_Intro
call MartTextBox
call BuyMenu
@@ -69,7 +69,7 @@ BargainShop: ; 15a84
Pharmacist: ; 15aae
call FarReadMart
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, UnknownText_0x15e90
call MartTextBox
call BuyMenu
@@ -90,7 +90,7 @@ RooftopSale: ; 15ac4
.ok
call LoadMartPointer
call ReadMart
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Text_Mart_HowMayIHelpYou
call MartTextBox
call BuyMenu
@@ -175,7 +175,7 @@ StandardMart: ; 15b47
; 15b62
.HowMayIHelpYou: ; 15b62
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Text_Mart_HowMayIHelpYou
call PrintText
ld a, $1 ; top menu
@@ -183,7 +183,7 @@ StandardMart: ; 15b47
; 15b6e
.TopMenu: ; 15b6e
ld hl, MenuDataHeader_0x15f88
ld hl, MenuDataHeader_BuySell
call CopyMenuDataHeader
call InterpretMenu2
jr c, .quit
@@ -228,7 +228,7 @@ StandardMart: ; 15b47
; 15baf
.AnythingElse: ; 15baf
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
ld hl, Text_Mart_AnythingElse
call PrintText
ld a, $1 ; top menu
@@ -472,7 +472,7 @@ endr
BuyMenuLoop: ; 15cef
callba Function24ae8
call UpdateSprites
ld hl, MenuDataHeader_0x15e18
ld hl, MenuDataHeader_Buy
call CopyMenuDataHeader
ld a, [wd045]
ld [wMenuCursorBuffer], a
@@ -643,19 +643,19 @@ Text_Mart_CostsThisMuch: ; 0x15e13
db "@"
; 0x15e18
MenuDataHeader_0x15e18: ; 0x15e18
MenuDataHeader_Buy: ; 0x15e18
db $40 ; flags
db 03, 01 ; start coords
db 11, 19 ; end coords
dw MenuData2_0x15e20
dw .menudata2
db 1 ; default option
; 0x15e20
MenuData2_0x15e20: ; 0x15e20
db $30 ; flags
.menudata2: ; 0x15e20
db $30 ; pointers
db 4, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, OBPals + 8 * 6
dbw 0, CurMart
dba PlaceMenuItemName
dba .PrintBCDPrices
dba Function244c3
@@ -929,16 +929,16 @@ Text_Mart_HowMayIHelpYou: ; 0x15f83
db "@"
; 0x15f88
MenuDataHeader_0x15f88: ; 0x15f88
MenuDataHeader_BuySell: ; 0x15f88
db $40 ; flags
db 00, 00 ; start coords
db 08, 07 ; end coords
dw MenuData2_0x15f90
dw .menudata2
db 1 ; default option
; 0x15f90
MenuData2_0x15f90: ; 0x15f90
db $80 ; flags
.menudata2: ; 0x15f90
db $80 ; strings
db 3 ; items
db "BUY@"
db "SELL@"

959
engine/namingscreen.asm Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
Function14a1a: ; 14a1a
call LoadPartyMenuDataHeader
call LoadStandardMenuDataHeader
callba Function5e9a
call SpeechTextBox
call UpdateSprites

View File

@@ -1560,8 +1560,8 @@ Script_returnafterbattle: ; 0x97459
and $3f
cp $1
jr nz, .notblackedout ; 0x97466 $8
ld b, BANK(UnknownScript_0x124c1)
ld hl, UnknownScript_0x124c1
ld b, BANK(Script_BattleWhiteout)
ld hl, Script_BattleWhiteout
jp ScriptJump
.notblackedout
@@ -2884,9 +2884,9 @@ Script_blackoutmod: ; 0x97a78
; map_id (MapIdParam)
call GetScriptByte
ld [wdcb2], a
ld [wLastSpawnMapGroup], a
call GetScriptByte
ld [wdcb3], a
ld [wLastSpawnMapNumber], a
ret
; 0x97a85

191
engine/selectmenu.asm Executable file
View File

@@ -0,0 +1,191 @@
SelectMenu:: ; 13327
call CheckRegisteredItem
jr c, .NotRegistered
jp UseRegisteredItem
.NotRegistered
call LoadFont
ld b, BANK(ItemMayBeRegisteredText)
ld hl, ItemMayBeRegisteredText
call MapTextbox
call CloseText
jp LoadMoveSprites
; 13340
ItemMayBeRegisteredText: ; 13340
text_jump UnknownText_0x1c1cf3
db "@"
; 13345
CheckRegisteredItem: ; 13345
ld a, [WhichRegisteredItem]
and a
jr z, .NoRegisteredItem
and REGISTERED_POCKET
rlca
rlca
ld hl, .Pockets
rst JumpTable
ret
.Pockets
dw .CheckItem
dw .CheckBall
dw .CheckKeyItem
dw .CheckTMHM
.CheckItem
ld hl, NumItems
call .CheckRegisteredNo
jr c, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
rept 2
add hl, de
endr
call .IsSameItem
jr c, .NoRegisteredItem
and a
ret
.CheckKeyItem
ld a, [RegisteredItem]
ld hl, KeyItems
ld de, 1
call IsInArray
jr nc, .NoRegisteredItem
ld a, [RegisteredItem]
ld [CurItem], a
and a
ret
.CheckBall
ld hl, NumBalls
call .CheckRegisteredNo
jr nc, .NoRegisteredItem
inc hl
ld e, a
ld d, 0
rept 2
add hl, de
endr
call .IsSameItem
jr c, .NoRegisteredItem
ret
.CheckTMHM
jr .NoRegisteredItem
.NoRegisteredItem
xor a
ld [WhichRegisteredItem], a
ld [RegisteredItem], a
scf
ret
; 133a6
.CheckRegisteredNo ; 133a6
ld a, [WhichRegisteredItem]
and REGISTERED_NUMBER
dec a
cp [hl]
jr nc, .NotEnoughItems
ld [wd107], a
and a
ret
.NotEnoughItems
scf
ret
; 133b6
.IsSameItem ; 133b6
ld a, [RegisteredItem]
cp [hl]
jr nz, .NotSameItem
ld [CurItem], a
and a
ret
.NotSameItem
scf
ret
; 133c3
UseRegisteredItem: ; 133c3
callba CheckItemMenu
ld a, [wItemAttributeParamBuffer]
ld hl, .SwitchTo
rst JumpTable
ret
.SwitchTo
dw .CantUse
dw .NoFunction
dw .NoFunction
dw .NoFunction
dw .Current
dw .Party
dw .Overworld
; 133df
.NoFunction ; 133df
call LoadFont
call CantUseItem
call LoadMoveSprites
and a
ret
; 133ea
.Current ; 133ea
call LoadFont
call DoItemEffect
call LoadMoveSprites
and a
ret
; 133f5
.Party ; 133f5
call ResetWindow
call FadeToMenu
call DoItemEffect
call Function2b3c
call LoadMoveSprites
and a
ret
; 13406
.Overworld ; 13406
call ResetWindow
ld a, 1
ld [wd0ef], a
call DoItemEffect
xor a
ld [wd0ef], a
ld a, [wd0ec]
cp 1
jr nz, ._cantuse
scf
ld a, HMENURETURN_SCRIPT
ld [hMenuReturn], a
ret
; 13422
.CantUse ; 13422
call ResetWindow
._cantuse
call CantUseItem
call LoadMoveSprites
and a
ret
; 1342d

View File

@@ -42,7 +42,7 @@ SpecialsPointers:: ; c029
; Map Events
add_special BugContestJudging
add_special CheckPartyFullAfterContest
add_special CheckFirstMonFainted
add_special ContestDropOffMons
add_special ContestReturnMons
add_special Special_GiveParkBalls
add_special Special_CheckMagikarpLength

1970
engine/startmenu.asm Executable file

File diff suppressed because it is too large Load Diff

113
engine/tmhm.asm Executable file
View File

@@ -0,0 +1,113 @@
CanLearnTMHMMove: ; 11639
ld a, [CurPartySpecies]
ld [CurSpecies], a
call GetBaseData
ld hl, BaseTMHM
push hl
ld a, [wd262]
ld b, a
ld c, 0
ld hl, TMHMMoves
.loop
ld a, [hli]
and a
jr z, .end
cp b
jr z, .asm_11659
inc c
jr .loop
.asm_11659
pop hl
ld b, CHECK_FLAG
push de
ld d, 0
predef FlagPredef
pop de
ret
.end
pop hl
ld c, 0
ret
; 1166a
GetTMHMMove: ; 1166a
ld a, [wd265]
dec a
ld hl, TMHMMoves
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
ld [wd265], a
ret
; 1167a
TMHMMoves: ; 1167a
db DYNAMICPUNCH
db HEADBUTT
db CURSE
db ROLLOUT
db ROAR
db TOXIC
db ZAP_CANNON
db ROCK_SMASH
db PSYCH_UP
db HIDDEN_POWER
db SUNNY_DAY
db SWEET_SCENT
db SNORE
db BLIZZARD
db HYPER_BEAM
db ICY_WIND
db PROTECT
db RAIN_DANCE
db GIGA_DRAIN
db ENDURE
db FRUSTRATION
db SOLARBEAM
db IRON_TAIL
db DRAGONBREATH
db THUNDER
db EARTHQUAKE
db RETURN
db DIG
db PSYCHIC_M
db SHADOW_BALL
db MUD_SLAP
db DOUBLE_TEAM
db ICE_PUNCH
db SWAGGER
db SLEEP_TALK
db SLUDGE_BOMB
db SANDSTORM
db FIRE_BLAST
db SWIFT
db DEFENSE_CURL
db THUNDERPUNCH
db DREAM_EATER
db DETECT
db REST
db ATTRACT
db THIEF
db STEEL_WING
db FIRE_PUNCH
db FURY_CUTTER
db NIGHTMARE
db CUT
db FLY
db SURF
db STRENGTH
db FLASH
db WHIRLPOOL
db WATERFALL
; Move tutor
db FLAMETHROWER
db THUNDERBOLT
db ICE_BEAM
db 0 ; end
; 116b7

136
event/bug_contest_2.asm Executable file
View File

@@ -0,0 +1,136 @@
Special_SelectRandomBugContestContestants: ; 139a8
; Select five random people to participate in the current contest.
; First we have to make sure that any old data is cleared away.
ld c, 10 ; Number of people to choose from.
ld hl, BugCatchingContestantEventFlagTable
.loop1
push bc
push hl
ld e, [hl]
inc hl
ld d, [hl]
ld b, RESET_FLAG
call EventFlagAction
pop hl
rept 2
inc hl
endr
pop bc
dec c
jr nz, .loop1
; Now that that's out of the way, we can get on to the good stuff.
ld c, 5
.loop2
push bc
.next
; Choose a flag at uniform random to be set.
call Random
cp $fa ; 250
jr nc, .next
ld c, $19 ; 25
call SimpleDivide
ld e, b
ld d, 0
ld hl, BugCatchingContestantEventFlagTable
rept 2
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
push de
; If we've already set it, it doesn't count.
ld b, CHECK_FLAG
call EventFlagAction
pop de
ld a, c
and a
jr nz, .next
; Set the flag. This will cause that sprite to not be visible in the contest.
ld b, SET_FLAG
call EventFlagAction
pop bc
; Check if we're done. If so, return. Otherwise, choose the next victim.
dec c
jr nz, .loop2
ret
; 139ed
Special_CheckBugContestContestantFlag: ; 139ed
; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
; Bug: If a >= 10 when this is called, it will read beyond the table.
ld hl, BugCatchingContestantEventFlagTable
ld e, a
ld d, 0
rept 2
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
ld b, CHECK_FLAG
call EventFlagAction
ret
; 139fe
BugCatchingContestantEventFlagTable: ; 139fe
dw EVENT_BUG_CATCHING_CONTESTANT_1A
dw EVENT_BUG_CATCHING_CONTESTANT_2A
dw EVENT_BUG_CATCHING_CONTESTANT_3A
dw EVENT_BUG_CATCHING_CONTESTANT_4A
dw EVENT_BUG_CATCHING_CONTESTANT_5A
dw EVENT_BUG_CATCHING_CONTESTANT_6A
dw EVENT_BUG_CATCHING_CONTESTANT_7A
dw EVENT_BUG_CATCHING_CONTESTANT_8A
dw EVENT_BUG_CATCHING_CONTESTANT_9A
dw EVENT_BUG_CATCHING_CONTESTANT_10A
; 13a12
ContestDropOffMons: ; 13a12
ld hl, PartyMon1HP
ld a, [hli]
or [hl]
jr z, .fainted
; Mask the rest of your party by setting the count to 1...
ld hl, PartyCount
ld a, 1
ld [hli], a
inc hl
; ... backing up the second mon index somewhere...
ld a, [hl]
ld [wBugContestSecondPartySpecies], a
; ... and replacing it with the terminator byte
ld [hl], $ff
xor a
ld [ScriptVar], a
ret
.fainted
ld a, $1
ld [ScriptVar], a
ret
; 13a31
ContestReturnMons: ; 13a31
; Restore the species of the second mon.
ld hl, PartySpecies + 1
ld a, [wBugContestSecondPartySpecies]
ld [hl], a
; Restore the party count, which must be recomputed.
ld b, $1
.loop
ld a, [hli]
cp $ff
jr z, .done
inc b
jr .loop
.done
ld a, b
ld [PartyCount], a
ret
; 13a47

480
event/bug_contest_judging.asm Executable file
View File

@@ -0,0 +1,480 @@
_BugContestJudging: ; 1369d
call ContestScore
callba MobileFn_105f79
call Function13819
ld a, [wd00a]
call LoadContestantName
ld a, [wd00b]
ld [wd265], a
call GetPokemonName
ld hl, BugContest_ThirdPlaceText
call PrintText
ld a, [EndFlypoint]
call LoadContestantName
ld a, [MovementBuffer]
ld [wd265], a
call GetPokemonName
ld hl, BugContest_SecondPlaceText
call PrintText
ld a, [wd002]
call LoadContestantName
ld a, [wd003]
ld [wd265], a
call GetPokemonName
ld hl, BugContest_FirstPlaceText
call PrintText
jp Function13807
; 136eb
BugContest_FirstPlaceText: ; 0x136eb
text_jump ContestJudging_FirstPlaceText
start_asm
BugContest_FirstPlace: ; 136f0
ld de, SFX_1ST_PLACE
call PlaySFX
call WaitSFX
ld hl, BugContest_FirstPlaceScoreText
ret
; 136fd
BugContest_FirstPlaceScoreText: ; 0x136fd
; The winning score was @ points!
text_jump ContestJudging_FirstPlaceScoreText
db "@"
; 0x13702
BugContest_SecondPlaceText: ; 0x13702
; Placing second was @ , who caught a @ !@ @
text_jump ContestJudging_SecondPlaceText
start_asm
BugContest_SecondPlace: ; 13707
ld de, SFX_2ND_PLACE
call PlaySFX
call WaitSFX
ld hl, BugContest_SecondPlaceScoreText
ret
; 13714
BugContest_SecondPlaceScoreText: ; 0x13714
; The score was @ points!
text_jump ContestJudging_SecondPlaceScoreText
db "@"
; 0x13719
BugContest_ThirdPlaceText: ; 0x13719
; Placing third was @ , who caught a @ !@ @
text_jump ContestJudging_ThirdPlaceText
start_asm
; 0x1371e
BugContest_ThirdPlace: ; 1371e
ld de, SFX_3RD_PLACE
call PlaySFX
call WaitSFX
ld hl, BugContest_ThirdPlaceScoreText
ret
; 1372b
BugContest_ThirdPlaceScoreText: ; 0x1372b
; The score was @ points!
text_jump ContestJudging_ThirdPlaceScoreText
db "@"
; 0x13730
LoadContestantName: ; 13730
; If a = 0, get your name.
dec a
jr z, .done
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a
ld b, 0
ld hl, BugContestantPointers
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
; Copy the Trainer Class to c.
ld a, [hli]
ld c, a
; Save hl and bc for later.
push hl
push bc
; Get the Trainer Class name and copy it into wd016.
callab GetTrainerClassName
ld hl, StringBuffer1
ld de, wd016
ld bc, TRAINER_CLASS_NAME_LENGTH
call CopyBytes
ld hl, wd016
; Delete the trailing terminator and replace it with a space.
.next
ld a, [hli]
cp "@"
jr nz, .next
dec hl
ld [hl], " "
inc hl
ld d, h
ld e, l
; Restore the Trainer Class ID and Trainer ID pointer. Save de for later.
pop bc
pop hl
push de
; Get the name of the trainer with class c and ID b.
ld a, [hl]
ld b, a
callab GetTrainerName
; Append the name to wd016.
ld hl, StringBuffer1
pop de
ld bc, NAME_LENGTH - 1
jp CopyBytes
.done
ld hl, PlayerName
ld de, wd016
ld bc, NAME_LENGTH
jp CopyBytes
; 13783
BugContestantPointers: ; 13783
dw BugContestant_BugCatcherDon ; This reverts back to the player
dw BugContestant_BugCatcherDon
dw BugContestant_BugCatcherEd
dw BugContestant_CooltrainerMNick
dw BugContestant_PokefanMWilliam
dw BugContestant_BugCatcherBenny
dw BugContestant_CamperBarry
dw BugContestant_PicnickerCindy
dw BugContestant_BugCatcherJosh
dw BugContestant_YoungsterSamuel
dw BugContestant_SchoolboyKipp
; 13799
BugContestant_BugCatcherDon:
db BUG_CATCHER, DON
dbw KAKUNA, 300
dbw METAPOD, 285
dbw CATERPIE, 226
BugContestant_BugCatcherEd:
db BUG_CATCHER, ED
dbw BUTTERFREE, 286
dbw BUTTERFREE, 251
dbw CATERPIE, 237
BugContestant_CooltrainerMNick:
db COOLTRAINERM, NICK
dbw SCYTHER, 357
dbw BUTTERFREE, 349
dbw PINSIR, 368
BugContestant_PokefanMWilliam:
db POKEFANM, WILLIAM
dbw PINSIR, 332
dbw BUTTERFREE, 324
dbw VENONAT, 321
BugContestant_BugCatcherBenny:
db BUG_CATCHER, BUG_CATCHER_BENNY
dbw BUTTERFREE, 318
dbw WEEDLE, 295
dbw CATERPIE, 285
BugContestant_CamperBarry:
db CAMPER, BARRY
dbw PINSIR, 366
dbw VENONAT, 329
dbw KAKUNA, 314
BugContestant_PicnickerCindy:
db PICNICKER, CINDY
dbw BUTTERFREE, 341
dbw METAPOD, 301
dbw CATERPIE, 264
BugContestant_BugCatcherJosh:
db BUG_CATCHER, JOSH
dbw SCYTHER, 326
dbw BUTTERFREE, 292
dbw METAPOD, 282
BugContestant_YoungsterSamuel:
db YOUNGSTER, SAMUEL
dbw WEEDLE, 270
dbw PINSIR, 282
dbw CATERPIE, 251
BugContestant_SchoolboyKipp:
db SCHOOLBOY, KIPP
dbw VENONAT, 267
dbw PARAS, 254
dbw KAKUNA, 259
; 13807
Function13807: ; 13807
ld hl, wd00a
ld de, -4
ld b, 3
.loop
ld a, [hl]
cp 1
jr z, .done
add hl, de
dec b
jr nz, .loop
.done
ret
; 13819
Function13819: ; 13819
call Function13833
call Function138b0
ld hl, wd00e
ld a, 1
ld [hli], a
ld a, [wContestMon]
ld [hli], a
ld a, [hProduct]
ld [hli], a
ld a, [hMultiplicand]
ld [hl], a
call Function1383e
ret
; 13833
Function13833: ; 13833
ld hl, wd002
ld b, 12
xor a
.loop
ld [hli], a
dec b
jr nz, .loop
ret
; 1383e
Function1383e: ; 1383e
ld de, wd010
ld hl, wd004
ld c, 2
call StringCmp
jr c, .next
ld hl, EndFlypoint
ld de, wd00a
ld bc, 4
call CopyBytes
ld hl, wd002
ld de, EndFlypoint
ld bc, 4
call CopyBytes
ld hl, wd002
call Function138a0
jr .done
.next
ld de, wd010
ld hl, wd008
ld c, 2
call StringCmp
jr c, .next2
ld hl, EndFlypoint
ld de, wd00a
ld bc, 4
call CopyBytes
ld hl, EndFlypoint
call Function138a0
jr .done
.next2
ld de, wd010
ld hl, wd00c
ld c, 2
call StringCmp
jr c, .done
ld hl, wd00a
call Function138a0
.done
ret
; 138a0
Function138a0: ; 138a0
ld de, wd00e
ld a, [de]
inc de
ld [hli], a
ld a, [de]
inc de
ld [hli], a
ld a, [de]
inc de
ld [hli], a
ld a, [de]
inc de
ld [hl], a
ret
; 138b0
Function138b0: ; 138b0
ld e, 0
.loop
push de
call Special_CheckBugContestContestantFlag
pop de
jr nz, .done
ld a, e
rept 2
inc a
endr
ld [wd00e], a
dec a
ld c, a
ld b, 0
ld hl, BugContestantPointers
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
rept 2
inc hl
endr
.loop2
call Random
and 3
cp 3
jr z, .loop2
ld c, a
ld b, 0
rept 3
add hl, bc
endr
ld a, [hli]
ld [wd00f], a
ld a, [hli]
ld h, [hl]
ld l, a
call Random
and 7
ld c, a
ld b, 0
add hl, bc
ld a, h
ld [wd010], a
ld a, l
ld [wd011], a
push de
call Function1383e
pop de
.done
inc e
ld a, e
cp 10
jr nz, .loop
ret
; 13900
ContestScore: ; 13900
; Determine the player's score in the Bug Catching Contest.
xor a
ld [hProduct], a
ld [hMultiplicand], a
ld a, [wContestMonSpecies] ; Species
and a
jr z, .done
; Tally the following:
; Max HP * 4
ld a, [wContestMonMaxHP + 1]
call .AddContestStat
ld a, [wContestMonMaxHP + 1]
call .AddContestStat
ld a, [wContestMonMaxHP + 1]
call .AddContestStat
ld a, [wContestMonMaxHP + 1]
call .AddContestStat
; Stats
ld a, [wContestMonAttack + 1]
call .AddContestStat
ld a, [wContestMonDefense + 1]
call .AddContestStat
ld a, [wContestMonSpeed + 1]
call .AddContestStat
ld a, [wContestMonSpclAtk + 1]
call .AddContestStat
ld a, [wContestMonSpclDef + 1]
call .AddContestStat
; DVs
ld a, [wContestMonDVs + 0]
ld b, a
and 2
rept 2
add a
endr
ld c, a
swap b
ld a, b
and 2
add a
add c
ld d, a
ld a, [wContestMonDVs + 1]
ld b, a
and 2
ld c, a
swap b
ld a, b
and 2
srl a
rept 2
add c
endr
rept 2
add d
endr
call .AddContestStat
; Remaining HP / 8
ld a, [wContestMonHP + 1]
srl a
srl a
srl a
call .AddContestStat
; Whether it's holding an item
ld a, [wContestMonItem]
and a
jr z, .done
ld a, 1
call .AddContestStat
.done
ret
; 1397f
.AddContestStat: ; 1397f
ld hl, hMultiplicand
add [hl]
ld [hl], a
ret nc
dec hl
inc [hl]
ret
; 13988

287
event/elevator.asm Executable file
View File

@@ -0,0 +1,287 @@
Elevator:: ; 1342d
call Function1344a
call Function1347d
jr c, .asm_13448
ld [wd041], a
call Function134dd
jr c, .asm_13448
ld hl, wd041
cp [hl]
jr z, .asm_13448
call Function134c0
and a
ret
.asm_13448
scf
ret
; 1344a
Function1344a: ; 1344a
ld a, b
ld [EngineBuffer1], a
ld a, e
ld [wd03f], a
ld a, d
ld [wd040], a
call Function1345a
ret
; 1345a
Function1345a: ; 1345a
ld de, OBPals + 8 * 6
ld bc, 4
ld hl, wd03f
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [EngineBuffer1]
call GetFarByte
inc hl
ld [de], a
inc de
.asm_1346f
ld a, [EngineBuffer1]
call GetFarByte
ld [de], a
inc de
add hl, bc
cp $ff
jr nz, .asm_1346f
ret
; 1347d
Function1347d: ; 1347d
ld hl, wd03f
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [EngineBuffer1]
call GetFarByte
ld c, a
inc hl
ld a, [BackupMapGroup]
ld d, a
ld a, [BackupMapNumber]
ld e, a
ld b, $0
.asm_13495
ld a, [EngineBuffer1]
call GetFarByte
cp $ff
jr z, .asm_134be
rept 2
inc hl
endr
ld a, [EngineBuffer1]
call GetFarByte
inc hl
cp d
jr nz, .asm_134b7
ld a, [EngineBuffer1]
call GetFarByte
inc hl
cp e
jr nz, .asm_134b8
jr .asm_134bb
.asm_134b7
inc hl
.asm_134b8
inc b
jr .asm_13495
.asm_134bb
xor a
ld a, b
ret
.asm_134be
scf
ret
; 134c0
Function134c0: ; 134c0
push af
ld hl, wd03f
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
pop af
ld bc, 4
call AddNTimes
inc hl
ld de, wdcac
ld a, [EngineBuffer1]
ld bc, 3
call FarCopyBytes
ret
; 134dd
Function134dd: ; 134dd
call LoadStandardMenuDataHeader
ld hl, Elevator_WhichFloorText
call PrintText
call Elevator_GetCurrentFloorText
ld hl, Elevator_MenuDataHeader
call CopyMenuDataHeader
call Function352f
call UpdateSprites
xor a
ld [wd0e4], a
call HandleScrollingMenu
call WriteBackup
ld a, [wcf73]
cp $2
jr z, .asm_1350b
xor a
ld a, [wcf77]
ret
.asm_1350b
scf
ret
; 1350d
Elevator_WhichFloorText: ; 0x1350d
; Which floor?
text_jump UnknownText_0x1bd2bc
db "@"
; 0x13512
Elevator_GetCurrentFloorText: ; 13512
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
hlcoord 0, 0
ld b, 4
ld c, 8
call TextBox
hlcoord 1, 2
ld de, Elevator_CurrentFloorText
call PlaceString
hlcoord 4, 4
call Elevator_GetCurrentFloorString
pop af
ld [Options], a
ret
; 13537
Elevator_CurrentFloorText: ; 13537
db "Now on:@"
; 1353f
Elevator_GetCurrentFloorString: ; 1353f
push hl
ld a, [wd041]
ld e, a
ld d, 0
ld hl, wd0f1
add hl, de
ld a, [hl]
pop de
call GetFloorString
ret
; 13550
Elevator_MenuDataHeader: ; 0x13550
db $40 ; flags
db 01, 12 ; start coords
db 09, 18 ; end coords
dw Elevator_MenuData2
db 1 ; default option
; 0x13558
Elevator_MenuData2: ; 0x13558
db $10 ; flags
db 4, 0 ; rows, columns
db 1 ; horizontal spacing
dbw 0, OBPals + 8 * 6
dba GetElevatorFlorStrings
dba NULL
dba NULL
; 13568
GetElevatorFlorStrings: ; 13568
ld a, [MenuSelection]
GetFloorString: ; 1356b
push de
call FloorToString
ld d, h
ld e, l
pop hl
jp PlaceString
; 13575
FloorToString: ; 13575
push de
ld e, a
ld d, 0
ld hl, .floors
rept 2
add hl, de
endr
ld a, [hli]
ld h, [hl]
ld l, a
pop de
ret
; 13583
.floors
dw .b4f
dw .b3f
dw .b2f
dw .b1f
dw ._1f
dw ._2f
dw ._3f
dw ._4f
dw ._5f
dw ._6f
dw ._7f
dw ._8f
dw ._9f
dw ._10f
dw ._11f
dw .roof
.b4f
db "B4F@"
.b3f
db "B3F@"
.b2f
db "B2F@"
.b1f
db "B1F@"
._1f
db "1F@"
._2f
db "2F@"
._3f
db "3F@"
._4f
db "4F@"
._5f
db "5F@"
._6f
db "6F@"
._7f
db "7F@"
._8f
db "8F@"
._9f
db "9F@"
._10f
db "10F@"
._11f
db "11F@"
.roof
db "ROOF@"
; 135db

Some files were not shown because too many files have changed in this diff Show More