2018-01-02 16:47:58 +00:00
|
|
|
Special_BattleTowerRoomMenu: ; 1700b0
|
2015-12-28 22:09:53 +00:00
|
|
|
; special
|
2015-12-08 21:06:13 +00:00
|
|
|
call InitBattleTowerChallengeRAM
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall _BattleTowerRoomMenu
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 1700ba
|
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_Function1700ba: ; 1700ba
|
2015-12-08 21:06:13 +00:00
|
|
|
call InitBattleTowerChallengeRAM
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function11811a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 1700c4
|
|
|
|
|
|
|
|
Function1700c4: ; 1700c4
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $3
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
call Function17042c
|
2015-11-25 15:16:29 +00:00
|
|
|
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, $1
|
|
|
|
ld [$be45], a
|
|
|
|
xor a
|
|
|
|
ld [$be46], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, w3_dffc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld de, $aa41
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, 4
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2015-12-26 04:34:33 +00:00
|
|
|
ld hl, w3_d202Name
|
2015-11-24 20:18:44 +00:00
|
|
|
ld de, $aa8e
|
2015-11-25 15:16:29 +00:00
|
|
|
ld bc, 7 * $cc ; length of battle tower struct from japanese games?
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, $aa5d ; some sort of count
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
|
|
|
inc hl
|
|
|
|
sla a
|
|
|
|
sla a
|
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
|
|
|
add hl, de
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, w3_dffc
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, 4
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 170114
|
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_Function170114: ; 170114
|
2015-12-08 21:06:13 +00:00
|
|
|
call InitBattleTowerChallengeRAM
|
2015-12-26 04:34:33 +00:00
|
|
|
call .Function170121
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function11805f
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 170121
|
|
|
|
|
2015-12-26 04:34:33 +00:00
|
|
|
.Function170121: ; 170121
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, $a948
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wMisc
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, $f6 ; 246
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
call Function170c8b
|
|
|
|
ret
|
|
|
|
; 170139
|
|
|
|
|
|
|
|
Function170139: ; 170139
|
2015-11-25 15:16:29 +00:00
|
|
|
; Convert the 4-digit decimal number at 5:aa41 into binary
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld de, $aa41
|
|
|
|
ld h, $0
|
|
|
|
ld l, h
|
2015-11-25 15:16:29 +00:00
|
|
|
ld bc, 1000
|
|
|
|
call .DecToBin
|
|
|
|
ld bc, 100
|
|
|
|
call .DecToBin
|
|
|
|
ld bc, 10
|
|
|
|
call .DecToBin
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
call CloseSRAM
|
2015-11-25 15:16:29 +00:00
|
|
|
; Store that number in wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, h
|
2015-11-25 15:16:29 +00:00
|
|
|
ld [wMisc], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, l
|
2015-11-25 15:16:29 +00:00
|
|
|
ld [wMisc + 1], a
|
|
|
|
ld hl, wBT_OTTempPkmn1DVs
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [PlayerID]
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [PlayerID + 1]
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [wSecretID]
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [wSecretID + 1]
|
|
|
|
ld [hli], a
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
ld hl, PlayerName
|
2017-12-21 16:56:33 +00:00
|
|
|
ld bc, NAME_LENGTH_JAPANESE - 1
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
ld bc, PlayerID
|
2017-12-28 12:15:46 +00:00
|
|
|
ld de, wPlayerGender
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall GetMobileOTTrainerClass
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wBT_OTTempPkmn1CaughtGender
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, c
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(PartyMons)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd49], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(PartyMons)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd4a], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(PartyMonNicknames)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd4b], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(PartyMonNicknames)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd4c], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld a, 3
|
2016-04-10 18:42:14 +00:00
|
|
|
.CopyLoop:
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld a, [wcd49]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wcd4a]
|
|
|
|
ld h, a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
ld a, l
|
|
|
|
ld [wcd49], a
|
|
|
|
ld a, h
|
|
|
|
ld [wcd4a], a
|
|
|
|
ld a, [wcd4b]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wcd4c]
|
|
|
|
ld h, a
|
|
|
|
ld bc, $0006
|
|
|
|
call CopyBytes
|
|
|
|
ld a, l
|
|
|
|
ld [wcd4b], a
|
|
|
|
ld a, h
|
|
|
|
ld [wcd4c], a
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .CopyLoop
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $4
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, $a013
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, $24
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, $a894
|
2017-12-21 16:56:33 +00:00
|
|
|
ld bc, NAME_LENGTH_JAPANESE
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld de, $a948
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, $f6
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
; 17020c
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.DecToBin: ; 17020c
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.digit_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, bc
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .digit_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 170215
|
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_BattleTowerBattle: ; 170215
|
2015-11-07 19:38:52 +00:00
|
|
|
xor a
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wBattleTowerBattleEnded], a
|
2015-11-07 19:38:52 +00:00
|
|
|
call _BattleTowerBattle
|
|
|
|
ret
|
|
|
|
; 17021d
|
|
|
|
|
2018-01-05 10:05:01 +00:00
|
|
|
DummySpecial_17021d: ; 17021d
|
2015-11-07 19:38:52 +00:00
|
|
|
ret
|
|
|
|
; 17021e
|
|
|
|
|
2015-12-08 21:06:13 +00:00
|
|
|
InitBattleTowerChallengeRAM: ; 17021e
|
2015-11-07 19:38:52 +00:00
|
|
|
xor a
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wBattleTowerBattleEnded], a
|
|
|
|
ld [wNrOfBeatenBattleTowerTrainers], a
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [wcf65], a
|
|
|
|
ld [wcf66], a
|
|
|
|
ret
|
|
|
|
; 17022c
|
|
|
|
|
|
|
|
_BattleTowerBattle: ; 17022c
|
|
|
|
.loop
|
2015-12-27 02:59:03 +00:00
|
|
|
call .do_dw
|
2015-11-07 19:38:52 +00:00
|
|
|
call DelayFrame
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wBattleTowerBattleEnded]
|
2015-11-07 19:38:52 +00:00
|
|
|
cp $1
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 17023a
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.do_dw ; 17023a
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wBattleTowerBattleEnded]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-12-27 02:59:03 +00:00
|
|
|
ld hl, .dw
|
2015-11-07 19:38:52 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 21:01:10 +00:00
|
|
|
jp hl
|
2015-11-07 19:38:52 +00:00
|
|
|
; 170249
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.dw ; 170249
|
2015-11-07 19:38:52 +00:00
|
|
|
dw RunBattleTowerTrainer
|
|
|
|
dw SkipBattleTowerTrainer
|
|
|
|
; 17024d
|
|
|
|
|
|
|
|
RunBattleTowerTrainer: ; 17024d
|
|
|
|
ld a, [Options]
|
|
|
|
push af
|
|
|
|
ld hl, Options
|
|
|
|
set BATTLE_SHIFT, [hl] ; SET MODE
|
|
|
|
|
|
|
|
ld a, [InBattleTowerBattle]
|
|
|
|
push af
|
|
|
|
or $1
|
|
|
|
ld [InBattleTowerBattle], a
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [wLinkMode], a
|
2018-01-02 19:00:14 +00:00
|
|
|
farcall Special_StubbedTrainerRankings_Healings
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall HealParty
|
2015-11-07 19:38:52 +00:00
|
|
|
call ReadBTTrainerParty
|
|
|
|
call Clears5_a89a
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2018-01-16 19:30:10 +00:00
|
|
|
predef StartBattle
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall LoadPokemonData
|
|
|
|
farcall HealParty
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [wBattleResult]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
and a
|
|
|
|
jr nz, .lost
|
|
|
|
ld a, BANK(sNrOfBeatenBattleTowerTrainers)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [sNrOfBeatenBattleTowerTrainers]
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wNrOfBeatenBattleTowerTrainers], a
|
2015-11-07 19:38:52 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld hl, StringBuffer3
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-07 19:38:52 +00:00
|
|
|
add "1"
|
|
|
|
ld [hli], a
|
|
|
|
ld a, "@"
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
.lost
|
|
|
|
pop af
|
|
|
|
ld [InBattleTowerBattle], a
|
|
|
|
pop af
|
|
|
|
ld [Options], a
|
|
|
|
ld a, $1
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wBattleTowerBattleEnded], a
|
2015-11-07 19:38:52 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
ReadBTTrainerParty: ; 1702b7
|
|
|
|
; Initialise the BattleTower-Trainer and his Pkmn
|
|
|
|
call CopyBTTrainer_FromBT_OT_TowBT_OTTemp
|
|
|
|
|
|
|
|
; Check the nicknames for illegal characters, and replace bad nicknames
|
|
|
|
; with their species names.
|
|
|
|
ld de, wBT_OTTempPkmn1Name ; $c643
|
|
|
|
ld c, PKMN_NAME_LENGTH
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckStringForErrors
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nc, .skip_mon_1
|
|
|
|
|
|
|
|
ld a, [wBT_OTTempPkmn1]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
|
|
|
ld de, wBT_OTTempPkmn1Name ; $c643
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_1
|
|
|
|
ld de, wBT_OTTempPkmn2Name ; $c67e
|
|
|
|
ld c, PKMN_NAME_LENGTH
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckStringForErrors
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nc, .skip_mon_2
|
|
|
|
ld a, [wBT_OTTempPkmn2] ; [$c64e]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
|
|
|
ld de, wBT_OTTempPkmn2Name ; $c67e
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_2
|
|
|
|
ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
|
|
|
|
ld c, PKMN_NAME_LENGTH
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckStringForErrors
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nc, .skip_mon_3
|
|
|
|
ld a, [wBT_OTTempPkmn3] ; [$c689]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
|
|
|
ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_3
|
|
|
|
; Add the terminator character to each of these names
|
|
|
|
ld a, "@"
|
|
|
|
ld [wBT_OTTempPkmn1NameEnd - 1], a ; $c64d
|
|
|
|
ld [wBT_OTTempPkmn2NameEnd - 1], a ; $c688
|
|
|
|
ld [wBT_OTTempPkmn3NameEnd - 1], a ; $c68a + 57 = $c6c3
|
|
|
|
; Fix errors in the movesets
|
|
|
|
call CheckBTMonMovesForErrors
|
|
|
|
; Repair the trainer name if needed, then copy it to OTPlayerName
|
|
|
|
ld de, wBT_OTTempName
|
|
|
|
ld c, NAME_LENGTH - 1
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckStringForErrors
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nc, .trainer_name_okay
|
|
|
|
ld hl, BT_ChrisName
|
|
|
|
jr .done_trainer_name
|
|
|
|
|
|
|
|
.trainer_name_okay
|
|
|
|
ld hl, wBT_OTTempName ; 0xc608
|
|
|
|
|
|
|
|
.done_trainer_name
|
|
|
|
ld de, OTPlayerName
|
|
|
|
ld bc, NAME_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
ld a, "@"
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
ld hl, wBT_OTTempTrainerClass
|
|
|
|
ld a, [hli]
|
|
|
|
ld [OtherTrainerClass], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, LOW(OTPartyMonNicknames)
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [BGMapBuffer], a
|
2017-12-25 18:40:10 +00:00
|
|
|
ld a, HIGH(OTPartyMonNicknames)
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [BGMapBuffer + 1], a
|
|
|
|
|
|
|
|
; Copy Pkmn into Memory from the address in hl
|
|
|
|
ld de, OTPartyMon1Species
|
|
|
|
ld bc, OTPartyCount
|
2018-01-20 17:05:16 +00:00
|
|
|
ld a, BATTLETOWER_PARTY_SIZE
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
.otpartymon_loop
|
|
|
|
push af
|
|
|
|
ld a, [hl]
|
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
push bc
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
push de
|
|
|
|
ld a, [BGMapBuffer]
|
|
|
|
ld e, a
|
|
|
|
ld a, [BGMapBuffer + 1]
|
|
|
|
ld d, a
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
ld a, e
|
|
|
|
ld [BGMapBuffer], a
|
|
|
|
ld a, d
|
|
|
|
ld [BGMapBuffer + 1], a
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
and a
|
|
|
|
jr nz, .otpartymon_loop
|
|
|
|
ld a, -1
|
|
|
|
ld [bc], a
|
|
|
|
ret
|
|
|
|
; 170394
|
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
ValidateBTParty: ; 170394
|
|
|
|
; Check for and fix errors in party data
|
|
|
|
ld hl, wBT_OTTempPkmn1Species
|
2018-01-20 17:05:16 +00:00
|
|
|
ld d, BATTLETOWER_PARTY_SIZE
|
2015-11-08 02:04:54 +00:00
|
|
|
.pkmn_loop
|
2015-11-07 19:38:52 +00:00
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-08 02:04:54 +00:00
|
|
|
idx = $ff
|
|
|
|
rept ($ff +- NUM_POKEMON)
|
|
|
|
jr z, .invalid
|
|
|
|
cp idx
|
|
|
|
idx = idx +- 1
|
|
|
|
endr
|
|
|
|
jr nz, .valid
|
2015-11-07 19:38:52 +00:00
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.invalid
|
|
|
|
ld a, SMEARGLE
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [hl], a
|
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.valid
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
2015-11-08 02:04:54 +00:00
|
|
|
ld a, [$b2fb] ; s5_b2fb ; max level?
|
2015-11-07 19:38:52 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld e, a
|
2015-11-08 02:04:54 +00:00
|
|
|
ld hl, MON_LEVEL
|
2015-11-07 19:38:52 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-11-08 02:04:54 +00:00
|
|
|
cp MIN_LEVEL
|
|
|
|
ld a, MIN_LEVEL
|
|
|
|
jr c, .load
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2015-11-08 02:04:54 +00:00
|
|
|
jr c, .dont_load
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, e
|
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.load
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [hl], a
|
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.dont_load
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [CurPartyLevel], a
|
2015-11-08 02:04:54 +00:00
|
|
|
ld hl, MON_MOVES
|
2015-11-07 19:38:52 +00:00
|
|
|
add hl, bc
|
2015-11-08 02:04:54 +00:00
|
|
|
ld d, NUM_MOVES - 1
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2015-11-08 02:04:54 +00:00
|
|
|
jr z, .not_move
|
|
|
|
cp NUM_ATTACKS + 1
|
|
|
|
jr nc, .not_move
|
|
|
|
jr .valid_move
|
2015-11-07 19:38:52 +00:00
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.not_move
|
2015-11-07 19:38:52 +00:00
|
|
|
dec hl
|
2015-11-08 02:04:54 +00:00
|
|
|
ld a, POUND
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [hli], a
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2016-05-04 15:46:23 +00:00
|
|
|
ld [hli], a
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [hl], a
|
2015-11-08 02:04:54 +00:00
|
|
|
jr .done_moves
|
2015-11-07 19:38:52 +00:00
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.valid_move
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [hl]
|
2015-11-08 02:04:54 +00:00
|
|
|
cp NUM_ATTACKS + 1
|
|
|
|
jr c, .next
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [hl], $0
|
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.next
|
2015-11-07 19:38:52 +00:00
|
|
|
inc hl
|
|
|
|
dec d
|
2015-11-08 02:04:54 +00:00
|
|
|
jr nz, .valid_move
|
2015-11-07 19:38:52 +00:00
|
|
|
|
2015-11-08 02:04:54 +00:00
|
|
|
.done_moves
|
|
|
|
ld hl, MON_MAXHP
|
2015-11-07 19:38:52 +00:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
push hl
|
|
|
|
push de
|
2015-12-21 19:10:16 +00:00
|
|
|
ld hl, MON_STAT_EXP - 1
|
2015-11-07 19:38:52 +00:00
|
|
|
add hl, bc
|
|
|
|
ld b, $1
|
2018-01-16 19:30:10 +00:00
|
|
|
predef CalcPkmnStats
|
2015-11-07 19:38:52 +00:00
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
dec de
|
2016-05-04 15:46:23 +00:00
|
|
|
dec de
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
pop hl
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
pop de
|
|
|
|
dec d
|
2015-11-08 02:04:54 +00:00
|
|
|
jp nz, .pkmn_loop
|
2015-11-07 19:38:52 +00:00
|
|
|
ret
|
|
|
|
; 170426
|
|
|
|
|
|
|
|
BT_ChrisName: ; 170426
|
|
|
|
db "CHRIS@"
|
|
|
|
; 17042c
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
Function17042c: ; 17042c
|
|
|
|
ld hl, w3_d202TrainerData
|
2018-01-20 17:05:16 +00:00
|
|
|
ld a, BATTLETOWER_STREAK_SIZE
|
2015-11-24 20:18:44 +00:00
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld c, BATTLETOWER_TRAINERDATALENGTH / 2
|
|
|
|
.loop2
|
|
|
|
; First byte is a comparison value.
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
; Second byte is a lookup index.
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .empty
|
2015-11-25 15:16:29 +00:00
|
|
|
cp 15
|
2015-11-24 20:18:44 +00:00
|
|
|
jr nc, .copy_data
|
|
|
|
|
|
|
|
push hl
|
|
|
|
ld hl, Unknown_170470
|
|
|
|
dec a
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
; If Unknown_170470[a-1] <= b, overwrite the current trainer's data
|
|
|
|
; with Unknown17047e, and exit the inner loop.
|
|
|
|
cp b
|
|
|
|
jr c, .copy_data
|
|
|
|
jr z, .copy_data
|
|
|
|
jr .next_iteration
|
|
|
|
|
|
|
|
.empty
|
|
|
|
; If a == 0 and b >= $fc, overwrite the current trainer's data with
|
|
|
|
; Unknown17047e, and exit the inner loop.
|
|
|
|
ld a, b
|
|
|
|
cp $fc
|
|
|
|
jr nc, .copy_data
|
|
|
|
|
|
|
|
.next_iteration
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
jr .next_trainer
|
|
|
|
|
|
|
|
.copy_data
|
|
|
|
pop de
|
|
|
|
push de
|
|
|
|
ld hl, Unknown_17047e
|
|
|
|
ld bc, BATTLETOWER_TRAINERDATALENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.next_trainer
|
|
|
|
pop hl
|
|
|
|
ld de, BATTLE_TOWER_STRUCT_LENGTH
|
|
|
|
add hl, de
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 170470
|
|
|
|
|
2018-01-06 23:53:30 +00:00
|
|
|
INCLUDE "data/battle_tower/unknown_levels.asm"
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
CopyBTTrainer_FromBT_OT_TowBT_OTTemp: ; 1704a2
|
|
|
|
; copy the BattleTower-Trainer data that lies at 'BT_OTTrainer' to 'wBT_OTTemp'
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2017-12-23 16:34:55 +00:00
|
|
|
ld a, BANK(BT_OTTrainer)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
2017-12-23 16:34:55 +00:00
|
|
|
ld hl, BT_OTTrainer
|
|
|
|
ld de, wBT_OTTemp
|
2015-11-24 20:18:44 +00:00
|
|
|
ld bc, BATTLE_TOWER_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
|
|
|
call GetSRAMBank
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, BATTLETOWER_CHALLENGE_IN_PROGESS
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [sBattleTowerChallengeState], a
|
|
|
|
ld hl, sNrOfBeatenBattleTowerTrainers
|
|
|
|
inc [hl]
|
|
|
|
call CloseSRAM
|
|
|
|
SkipBattleTowerTrainer: ; 1704c9
|
|
|
|
ret
|
|
|
|
; 1704ca
|
2015-11-25 15:16:29 +00:00
|
|
|
|
2018-01-02 15:04:21 +00:00
|
|
|
Unreferenced_Function1704ca: ; 1704ca
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [$be46]
|
|
|
|
cp $7
|
|
|
|
jr c, .asm_1704d3
|
|
|
|
ld a, $6
|
|
|
|
|
|
|
|
.asm_1704d3
|
|
|
|
ld hl, $afce
|
|
|
|
ld de, -$e0
|
|
|
|
.asm_1704d9
|
|
|
|
and a
|
|
|
|
jr z, .asm_1704e0
|
|
|
|
add hl, de
|
|
|
|
dec a
|
|
|
|
jr .asm_1704d9
|
|
|
|
|
|
|
|
.asm_1704e0
|
|
|
|
ret
|
|
|
|
; 1704e1
|
|
|
|
|
2018-01-02 18:38:56 +00:00
|
|
|
UnusedSpecial_Function1704e1: ; 1704e1
|
2015-11-24 20:18:44 +00:00
|
|
|
call SpeechTextBox
|
|
|
|
call FadeToMenu
|
2015-12-08 21:06:13 +00:00
|
|
|
call InitBattleTowerChallengeRAM
|
2015-11-25 15:16:29 +00:00
|
|
|
call .JumptableLoop
|
2015-12-02 02:54:11 +00:00
|
|
|
call CloseSubmenu
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 1704f1
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.JumptableLoop: ; 1704f1
|
2015-11-24 20:18:44 +00:00
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearSprites
|
|
|
|
call ClearScreen
|
2015-11-25 15:16:29 +00:00
|
|
|
.loop
|
2015-11-24 20:18:44 +00:00
|
|
|
call JoyTextDelay
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
bit 7, a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .done
|
|
|
|
call .DoJumptable
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ReloadMapPart
|
2015-11-25 15:16:29 +00:00
|
|
|
jr .loop
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.done
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 170510
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.DoJumptable: ; 170510
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-12-27 02:59:03 +00:00
|
|
|
ld hl, .dw
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 21:01:10 +00:00
|
|
|
jp hl
|
2015-11-24 20:18:44 +00:00
|
|
|
; 17051f
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.dw ; 17051f
|
2015-11-25 15:16:29 +00:00
|
|
|
dw .Jumptable_0
|
|
|
|
dw .Jumptable_1
|
|
|
|
dw .Jumptable_2
|
2015-11-24 20:18:44 +00:00
|
|
|
; 170525
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.Jumptable_0: ; 170525
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
|
|
|
|
ld hl, $a89c
|
|
|
|
ld de, StringBuffer3
|
2015-12-26 04:34:33 +00:00
|
|
|
ld bc, $16
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ld hl, $a8b2
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld bc, $0096
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
call CloseSRAM
|
|
|
|
hlcoord 1, 1
|
|
|
|
ld de, StringBuffer3
|
|
|
|
call PlaceString
|
|
|
|
hlcoord 1, 3
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, .String_Mail
|
2015-11-24 20:18:44 +00:00
|
|
|
call PlaceString
|
|
|
|
hlcoord 4, 3
|
|
|
|
ld de, StringBuffer4
|
|
|
|
call PlaceString
|
|
|
|
hlcoord 8, 3
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, .String_PastReaders
|
2015-11-24 20:18:44 +00:00
|
|
|
call PlaceString
|
2015-11-25 15:16:29 +00:00
|
|
|
call .DrawBorder
|
|
|
|
call .PlaceTextItems
|
|
|
|
jr .NextJumptableFunction
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.Jumptable_1:
|
2015-11-24 20:18:44 +00:00
|
|
|
call SetPalettes
|
2015-11-25 15:16:29 +00:00
|
|
|
call .NextJumptableFunction
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.Jumptable_2:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, hJoyPressed
|
|
|
|
ld a, [hl]
|
2015-11-25 15:16:29 +00:00
|
|
|
and A_BUTTON
|
|
|
|
jr nz, .pressed_a_or_b
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hl]
|
2015-11-25 15:16:29 +00:00
|
|
|
and B_BUTTON
|
|
|
|
jr nz, .pressed_a_or_b
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hl]
|
2015-11-25 15:16:29 +00:00
|
|
|
and D_UP
|
|
|
|
jr nz, .pressed_up
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hl]
|
2015-11-25 15:16:29 +00:00
|
|
|
and D_DOWN
|
|
|
|
jr nz, .pressed_down
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.pressed_up
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-24 20:18:44 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-25 15:16:29 +00:00
|
|
|
sub 15
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wNrOfBeatenBattleTowerTrainers], a
|
2015-11-25 15:16:29 +00:00
|
|
|
call .PlaceTextItems
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.pressed_down
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-25 15:16:29 +00:00
|
|
|
cp 60
|
2015-11-24 20:18:44 +00:00
|
|
|
ret z
|
2015-11-25 15:16:29 +00:00
|
|
|
add 15
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wNrOfBeatenBattleTowerTrainers], a
|
2015-11-25 15:16:29 +00:00
|
|
|
call .PlaceTextItems
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.pressed_a_or_b
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
set 7, [hl]
|
|
|
|
ret
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.NextJumptableFunction:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 1705b7
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.DrawBorder: ; 1705b7
|
2015-11-24 20:18:44 +00:00
|
|
|
hlcoord 0, 4
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "┌"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld c, SCREEN_WIDTH - 2
|
|
|
|
.top_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "─"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .top_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "┐"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, SCREEN_WIDTH
|
|
|
|
ld c, 12
|
|
|
|
.left_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "│"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .left_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "└"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld c, SCREEN_WIDTH - 2
|
|
|
|
.bottom_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "─"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .bottom_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "┘"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hl], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, -SCREEN_WIDTH
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
2015-11-25 15:16:29 +00:00
|
|
|
ld c, 12
|
|
|
|
.right_border_loop
|
2018-01-12 02:14:35 +00:00
|
|
|
ld a, "│"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .right_border_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 1705f0
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.PlaceTextItems: ; 1705f0
|
|
|
|
call .ClearBox
|
|
|
|
call .PlaceUpDownArrows
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $50
|
|
|
|
ld [wcd4e], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, wMisc
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld c, a
|
|
|
|
xor a
|
|
|
|
ld b, a
|
|
|
|
add hl, bc
|
|
|
|
push hl
|
|
|
|
pop bc
|
|
|
|
hlcoord 1, 6
|
2015-11-25 15:16:29 +00:00
|
|
|
ld a, 6
|
|
|
|
.loop1
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
push hl
|
2015-11-25 15:16:29 +00:00
|
|
|
ld a, 3
|
|
|
|
.loop2
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld de, wcd49
|
|
|
|
ld a, [bc]
|
|
|
|
and a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr z, .fill_with_e3
|
|
|
|
; .copy
|
|
|
|
ld a, 5
|
|
|
|
.loop3a
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld a, [bc]
|
|
|
|
ld [de], a
|
|
|
|
inc bc
|
|
|
|
inc de
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .loop3a
|
|
|
|
jr .rejoin
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.fill_with_e3
|
|
|
|
ld a, 5
|
|
|
|
.loop3b
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld a, $e3
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
inc bc
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .loop3b
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.rejoin
|
2015-11-24 20:18:44 +00:00
|
|
|
ld de, wcd49
|
|
|
|
push bc
|
|
|
|
call PlaceString
|
2017-12-21 16:56:33 +00:00
|
|
|
ld de, NAME_LENGTH_JAPANESE
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
|
|
|
pop bc
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .loop2
|
2015-11-24 20:18:44 +00:00
|
|
|
pop hl
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, $28
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .loop1
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 17064b
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.ClearBox: ; 17064b
|
2015-11-24 20:18:44 +00:00
|
|
|
hlcoord 1, 5
|
|
|
|
xor a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld b, 12
|
|
|
|
.clearbox_row
|
|
|
|
ld c, SCREEN_WIDTH - 2
|
|
|
|
.clearbox_column
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .clearbox_column
|
2015-11-24 20:18:44 +00:00
|
|
|
inc hl
|
2016-05-04 15:46:23 +00:00
|
|
|
inc hl
|
2015-11-24 20:18:44 +00:00
|
|
|
dec b
|
2015-11-25 15:16:29 +00:00
|
|
|
jr nz, .clearbox_row
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 17065d
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.PlaceUpDownArrows: ; 17065d
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-24 20:18:44 +00:00
|
|
|
and a
|
2015-11-25 15:16:29 +00:00
|
|
|
jr z, .nope
|
2015-11-24 20:18:44 +00:00
|
|
|
hlcoord 18, 5
|
2015-11-25 15:16:29 +00:00
|
|
|
ld a, "▲"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hl], a
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.nope
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [wNrOfBeatenBattleTowerTrainers]
|
2015-11-25 15:16:29 +00:00
|
|
|
cp 60
|
2015-11-24 20:18:44 +00:00
|
|
|
ret z
|
|
|
|
hlcoord 18, 16
|
2015-11-25 15:16:29 +00:00
|
|
|
ld a, "▼"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 170676
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.String_Mail: ; 170676
|
2015-11-24 20:18:44 +00:00
|
|
|
db "ルーム@"
|
|
|
|
; 17067a
|
|
|
|
|
2015-11-25 15:16:29 +00:00
|
|
|
.String_PastReaders: ; 17067a
|
2015-11-24 20:18:44 +00:00
|
|
|
db "れきだいりーダーいちらん@"
|
|
|
|
; 170687
|
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_BattleTowerAction: ; 170687
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [ScriptVar]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-12-27 02:59:03 +00:00
|
|
|
ld hl, .dw
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 21:01:10 +00:00
|
|
|
jp hl
|
2015-11-24 20:18:44 +00:00
|
|
|
; 170696
|
|
|
|
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.dw ; 170696 (5c:4696)
|
2017-11-19 10:52:42 +00:00
|
|
|
dw BattleTowerAction_CheckExplanationRead ; 0x00
|
|
|
|
dw BattleTowerAction_SetExplanationRead ; 0x01
|
|
|
|
dw BattleTowerAction_GetChallengeState ; 0x02
|
2015-11-27 02:05:32 +00:00
|
|
|
dw BattleTowerAction_SetByteToQuickSaveChallenge ; 0x03
|
|
|
|
dw BattleTowerAction_SetByteToCancelChallenge ; 0x04
|
2015-11-24 20:18:44 +00:00
|
|
|
dw Function1707ac ; 0x05
|
|
|
|
dw Function1707f4 ; 0x06
|
2015-11-27 02:05:32 +00:00
|
|
|
dw SaveBattleTowerLevelGroup ; 0x07
|
|
|
|
dw LoadBattleTowerLevelGroup ; 0x08
|
|
|
|
dw BattleTower_CheckSaveFileExistsAndIsYours ; 0x09
|
2015-11-24 20:18:44 +00:00
|
|
|
dw Function1708b1 ; 0x0a
|
|
|
|
dw CheckMobileEventIndex ; 0x0b
|
|
|
|
dw Function1708c8 ; 0x0c
|
|
|
|
dw Function1708f0 ; 0x0d
|
2017-11-19 10:52:42 +00:00
|
|
|
dw BattleTowerAction_EggTicket ; 0x0e
|
2015-11-24 20:18:44 +00:00
|
|
|
dw Function1709aa ; 0x0f
|
|
|
|
dw Function1709bb ; 0x10
|
|
|
|
dw Function170a9c ; 0x11
|
|
|
|
dw Function170aa0 ; 0x12
|
|
|
|
dw Function170aaf ; 0x13
|
|
|
|
dw Function170abe ; 0x14
|
|
|
|
dw Function170ad7 ; 0x15
|
|
|
|
dw Function170807 ; 0x16
|
|
|
|
dw Function17081d ; 0x17
|
2017-11-19 10:52:42 +00:00
|
|
|
dw BattleTowerAction_LevelCheck ; 0x18
|
|
|
|
dw BattleTowerAction_UbersCheck ; 0x19
|
2015-11-24 20:18:44 +00:00
|
|
|
dw ResetBattleTowerTrainersSRAM ; 0x1a
|
2015-12-08 21:06:13 +00:00
|
|
|
dw BattleTower_GiveReward ; 0x1b
|
2015-11-24 20:18:44 +00:00
|
|
|
dw Function17071b ; 0x1c
|
|
|
|
dw Function170729 ; 0x1d
|
2015-11-27 02:05:32 +00:00
|
|
|
dw BattleTower_RandomlyChooseReward ; 0x1e
|
2015-12-08 21:06:13 +00:00
|
|
|
dw BattleTower_SaveOptions ; 0x1f
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
|
|
|
|
ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) BattleTowerAction $1a
|
|
|
|
ld a, BANK(sBTTrainers)
|
|
|
|
call GetSRAMBank
|
|
|
|
|
|
|
|
ld a, $ff
|
|
|
|
ld hl, sBTTrainers
|
2018-01-20 17:05:16 +00:00
|
|
|
ld bc, BATTLETOWER_STREAK_SIZE
|
2015-11-24 20:18:44 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [sNrOfBeatenBattleTowerTrainers], a
|
|
|
|
|
|
|
|
call CloseSRAM
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2015-12-08 21:06:13 +00:00
|
|
|
BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerReward)
|
|
|
|
call GetSRAMBank
|
|
|
|
|
|
|
|
ld a, [sBattleTowerReward]
|
|
|
|
call CloseSRAM
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld hl, NumItems
|
|
|
|
ld a, [hli]
|
|
|
|
cp MAX_ITEMS
|
|
|
|
ret c
|
|
|
|
ld b, MAX_ITEMS
|
|
|
|
ld a, [ScriptVar]
|
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr nz, .next
|
|
|
|
ld a, [hl]
|
|
|
|
cp 95
|
|
|
|
ret c
|
|
|
|
.next
|
|
|
|
inc hl
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
ld a, POTION
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function17071b: ; 17071b (5c:471b) BattleTowerAction $1c
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
|
|
|
call GetSRAMBank
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, BATTLETOWER_WON_CHALLENGE
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [sBattleTowerChallengeState], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function170729: ; 170729 (5c:4729) BattleTowerAction $1d
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
|
|
|
call GetSRAMBank
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, BATTLETOWER_RECEIVED_REWARD
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [sBattleTowerChallengeState], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-12-08 21:06:13 +00:00
|
|
|
BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall SaveOptions
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2015-12-08 21:06:13 +00:00
|
|
|
BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e
|
2015-11-24 20:18:44 +00:00
|
|
|
; Generate a random stat boosting item.
|
|
|
|
.loop
|
|
|
|
call Random
|
|
|
|
ld a, [hRandomAdd]
|
|
|
|
and $7
|
|
|
|
cp 6
|
|
|
|
jr c, .okay
|
|
|
|
sub 6
|
|
|
|
.okay
|
|
|
|
add HP_UP
|
|
|
|
cp LUCKY_PUNCH
|
|
|
|
jr z, .loop
|
|
|
|
push af
|
|
|
|
ld a, BANK(sBattleTowerReward)
|
|
|
|
call GetSRAMBank
|
|
|
|
pop af
|
|
|
|
ld [sBattleTowerReward], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00
|
2015-11-27 02:05:32 +00:00
|
|
|
call BattleTower_CheckSaveFileExistsAndIsYours
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [ScriptVar]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2015-11-24 20:18:44 +00:00
|
|
|
and $2
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, sBattleTowerChallengeState
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [hl]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2015-11-24 20:18:44 +00:00
|
|
|
or $2
|
2017-12-16 02:22:26 +00:00
|
|
|
ld [sBattleTowerSaveFileFlags], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
BattleTowerAction_SetByteToQuickSaveChallenge: ; 170799 (5c:4799) BattleTowerAction $03
|
|
|
|
ld c, BATTLETOWER_SAVED_AND_LEFT
|
2015-11-24 20:18:44 +00:00
|
|
|
jr asm_17079f
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
BattleTowerAction_SetByteToCancelChallenge: ; 17079d (5c:479d) BattleTowerAction $04
|
|
|
|
ld c, BATTLETOWER_NO_CHALLENGE
|
2015-11-24 20:18:44 +00:00
|
|
|
asm_17079f: ; 17079f (5c:479f)
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, c
|
|
|
|
ld [sBattleTowerChallengeState], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function1707ac: ; 1707ac (5c:47ac) BattleTowerAction $05
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$aa8c]
|
|
|
|
ld b, a
|
|
|
|
ld a, [$be46]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld a, b
|
|
|
|
cp $2
|
|
|
|
jr nc, .asm_1707ef
|
|
|
|
push bc
|
|
|
|
call UpdateTime
|
|
|
|
pop bc
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$aa8b]
|
|
|
|
call CloseSRAM
|
|
|
|
ld c, a
|
|
|
|
ld a, [CurDay]
|
|
|
|
sub c
|
|
|
|
jr c, .asm_1707e5
|
|
|
|
cp $8
|
|
|
|
jr nc, .asm_1707ef
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr nz, .asm_1707ef
|
|
|
|
ret
|
|
|
|
.asm_1707e5
|
|
|
|
ld hl, CurDay
|
|
|
|
ld a, $8c
|
|
|
|
sub c
|
|
|
|
add [hl]
|
|
|
|
cp $8
|
|
|
|
ret c
|
|
|
|
.asm_1707ef
|
|
|
|
ld a, $8
|
|
|
|
ld [ScriptVar], a
|
|
|
|
|
|
|
|
Function1707f4: ; 1707f4 (5c:47f4) BattleTowerAction $06
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
xor a
|
|
|
|
ld [$be46], a
|
|
|
|
ld [$aa8b], a
|
|
|
|
ld [$aa8c], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function170807: ; 170807 (5c:4807) BattleTowerAction $16
|
|
|
|
call UpdateTime
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [CurDay]
|
|
|
|
ld [$b2f9], a
|
|
|
|
xor a
|
|
|
|
ld [$b2fa], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function17081d: ; 17081d (5c:481d) BattleTowerAction $17
|
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$b2f9]
|
|
|
|
ld c, a
|
|
|
|
ld a, [$b2fa]
|
|
|
|
ld b, a
|
|
|
|
call CloseSRAM
|
|
|
|
cp $2
|
|
|
|
jr nc, .asm_170853
|
|
|
|
push bc
|
|
|
|
call UpdateTime
|
|
|
|
pop bc
|
|
|
|
ld a, [CurDay]
|
|
|
|
sub c
|
|
|
|
jr c, .asm_170849
|
|
|
|
cp $b
|
|
|
|
jr nc, .asm_170853
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr nz, .asm_170853
|
|
|
|
ret
|
2015-11-27 02:05:32 +00:00
|
|
|
|
2015-11-24 20:18:44 +00:00
|
|
|
.asm_170849
|
|
|
|
ld hl, CurDay
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, 140
|
2015-11-24 20:18:44 +00:00
|
|
|
sub c
|
|
|
|
add [hl]
|
|
|
|
cp $b
|
|
|
|
ret c
|
|
|
|
.asm_170853
|
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
xor a
|
|
|
|
ld [$b2f9], a
|
|
|
|
ld [$b2fa], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
SaveBattleTowerLevelGroup: ; 170868 (5c:4868) BattleTowerAction $07
|
|
|
|
ld a, BANK(sBTChoiceOfLevelGroup)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $3
|
|
|
|
ld [rSVBK], a
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, [wBTChoiceOfLvlGroup]
|
|
|
|
ld [sBTChoiceOfLevelGroup], a
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
LoadBattleTowerLevelGroup: ; 170881 (5c:4881) BattleTowerAction $08 ; Load level group choice
|
|
|
|
ld a, BANK(sBTChoiceOfLevelGroup)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $3
|
|
|
|
ld [rSVBK], a
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, [sBTChoiceOfLevelGroup]
|
|
|
|
ld [wBTChoiceOfLvlGroup], a
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
BattleTower_CheckSaveFileExistsAndIsYours: ; 17089a BattleTowerAction $09
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [wSaveFileExists]
|
|
|
|
and a
|
|
|
|
jr z, .nope
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CompareLoadedAndSavedPlayerID
|
2015-11-24 20:18:44 +00:00
|
|
|
jr z, .yes
|
|
|
|
xor a
|
|
|
|
jr .nope
|
|
|
|
|
|
|
|
.yes
|
|
|
|
ld a, $1
|
|
|
|
|
|
|
|
.nope
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
; 1708b1
|
|
|
|
|
|
|
|
|
|
|
|
Function1708b1: ; 1708b1 (5c:48b1) BattleTowerAction $0a
|
|
|
|
xor a
|
|
|
|
ld [MusicFade], a
|
|
|
|
call MaxVolume
|
|
|
|
ret
|
|
|
|
|
|
|
|
CheckMobileEventIndex: ; 1708b9 (5c:48b9) BattleTowerAction $0b something to do with GS Ball
|
|
|
|
ld a, BANK(sMobileEventIndex)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [sMobileEventIndex]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function1708c8: ; 1708c8 (5c:48c8) BattleTowerAction $0c
|
|
|
|
call UpdateTime
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [CurDay]
|
|
|
|
ld [$aa8b], a
|
|
|
|
xor a
|
|
|
|
ld [$aa8c], a
|
|
|
|
ld a, [$aa5d]
|
|
|
|
cp $2
|
|
|
|
jr nc, .asm_1708ec
|
|
|
|
ld a, [CurDay]
|
|
|
|
ld [$aa48], a
|
|
|
|
ld a, $1
|
|
|
|
ld [$aa47], a
|
|
|
|
.asm_1708ec
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function1708f0: ; 1708f0 (5c:48f0) BattleTowerAction $0d
|
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call UpdateTime
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$aa48]
|
|
|
|
ld c, a
|
|
|
|
ld a, [$aa47]
|
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld hl, CurDay
|
|
|
|
ld a, c
|
|
|
|
cp [hl]
|
|
|
|
jr nz, Function170923
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$aa5d]
|
|
|
|
call CloseSRAM
|
|
|
|
cp $5
|
|
|
|
ret c
|
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
Function170923: ; 170923
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
xor a
|
|
|
|
ld [$aa48], a
|
|
|
|
ld [$aa47], a
|
|
|
|
ld hl, $aa5d
|
|
|
|
ld bc, $0011
|
|
|
|
call ByteFill
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
; 17093c
|
|
|
|
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_EggTicket: ; 17093c (5c:493c) BattleTowerAction $0e
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld a, EGG_TICKET
|
|
|
|
ld [CurItem], a
|
|
|
|
ld hl, NumItems
|
|
|
|
call CheckItem
|
|
|
|
ret nc
|
|
|
|
ld a, [PartyCount]
|
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
ld hl, PartySpecies
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp EGG
|
|
|
|
jr nz, .not_egg
|
|
|
|
push hl
|
2017-12-10 05:18:29 +00:00
|
|
|
ld hl, PartyMonOT
|
2017-12-21 16:56:33 +00:00
|
|
|
ld de, NAME_LENGTH_JAPANESE
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .skip
|
|
|
|
.loop2
|
|
|
|
add hl, de
|
|
|
|
dec a
|
|
|
|
jr nz, .loop2
|
|
|
|
.skip
|
|
|
|
ld de, String_1709a4
|
2017-12-21 16:56:33 +00:00
|
|
|
ld a, NAME_LENGTH_JAPANESE
|
2015-11-27 02:05:32 +00:00
|
|
|
.compare_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp [hl]
|
|
|
|
inc hl
|
2015-11-27 02:05:32 +00:00
|
|
|
jr nz, .different
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-27 02:05:32 +00:00
|
|
|
jr nz, .compare_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
rept 4
|
|
|
|
dec hl
|
|
|
|
endr
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, "@"
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
2016-05-04 15:46:23 +00:00
|
|
|
ld [hli], a
|
2015-11-24 20:18:44 +00:00
|
|
|
pop hl
|
|
|
|
ld a, EGG_TICKET
|
|
|
|
ld [CurItem], a
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, 1
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wItemQuantityChangeBuffer], a
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, -1
|
2015-12-18 03:31:16 +00:00
|
|
|
ld [CurItemQuantity], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, NumItems
|
|
|
|
call TossItem
|
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.different
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
|
|
|
pop hl
|
|
|
|
.not_egg
|
|
|
|
inc b
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 1709a4 (5c:49a4)
|
|
|
|
|
|
|
|
String_1709a4: ; 1709a4
|
|
|
|
db "なぞナゾ@@"
|
|
|
|
|
|
|
|
Function1709aa: ; 1709aa (5c:49aa) BattleTowerAction $0f
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, BANK(w3_d090)
|
|
|
|
ld [rSVBK], a
|
|
|
|
ld a, [w3_d090]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
|
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$a800]
|
|
|
|
call CloseSRAM
|
|
|
|
cp 6
|
|
|
|
jr nc, .invalid
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, Jumptable_1709e7
|
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 21:01:10 +00:00
|
|
|
jp hl
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
.invalid
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
xor a
|
|
|
|
ld [$a800], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
; 1709e7 (5c:49e7)
|
|
|
|
|
|
|
|
Jumptable_1709e7: ; 1709e7
|
2015-11-27 02:05:32 +00:00
|
|
|
dw .NoAction
|
|
|
|
dw .NoAction
|
|
|
|
dw .DoAction1
|
|
|
|
dw .DoAction1
|
|
|
|
dw .Action4
|
|
|
|
dw .Action5
|
2015-11-24 20:18:44 +00:00
|
|
|
; 1709f3
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.DoAction1: ; 1709f3
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, $1
|
|
|
|
ld [$a800], a
|
|
|
|
call CloseSRAM
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.NoAction: ; 170a00
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 170a01
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.Action4: ; 170a01
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, $b023
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld bc, $0069
|
|
|
|
call CopyBytes
|
|
|
|
ld a, [$a825]
|
|
|
|
ld [wcd30], a
|
|
|
|
ld a, [$a826]
|
|
|
|
ld [wcd31], a
|
|
|
|
call CloseSRAM
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function11b6b4
|
|
|
|
farcall Function17d0f3
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
; 170a33
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.Action5: ; 170a33
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $0
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, wRTC
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld bc, $0004
|
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld hl, $b08c
|
2015-11-25 15:16:29 +00:00
|
|
|
ld de, wMisc
|
2015-11-24 20:18:44 +00:00
|
|
|
ld c, $4
|
2015-11-27 02:05:32 +00:00
|
|
|
.compare_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp [hl]
|
2015-11-27 02:05:32 +00:00
|
|
|
jr nz, .different
|
2015-11-24 20:18:44 +00:00
|
|
|
inc hl
|
|
|
|
dec c
|
2015-11-27 02:05:32 +00:00
|
|
|
jr nz, .compare_loop
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld a, [MapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [MapNumber]
|
|
|
|
ld c, a
|
2017-12-24 18:46:34 +00:00
|
|
|
call GetMapSceneID
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, d
|
|
|
|
or e
|
2017-12-24 18:46:34 +00:00
|
|
|
jr z, .no_scene
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
.no_scene
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.different
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
xor a
|
|
|
|
ld [$a800], a
|
|
|
|
call CloseSRAM
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ld a, [MapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [MapNumber]
|
|
|
|
ld c, a
|
2017-12-24 18:46:34 +00:00
|
|
|
call GetMapSceneID
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, d
|
|
|
|
or e
|
2017-12-24 18:46:34 +00:00
|
|
|
jr z, .no_scene_2
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
.no_scene_2
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
; 170a9c
|
|
|
|
|
|
|
|
Function170a9c: ; 170a9c (5c:4a9c) BattleTowerAction $11
|
|
|
|
ld c, $0
|
|
|
|
jr asm_170aa2
|
|
|
|
|
|
|
|
Function170aa0: ; 170aa0 (5c:4aa0) BattleTowerAction $12
|
|
|
|
ld c, $1
|
|
|
|
asm_170aa2: ; 170aa2 (5c:4aa2)
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, c
|
|
|
|
ld [$aa8d], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function170aaf: ; 170aaf (5c:4aaf) BattleTowerAction $13
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$aa8d]
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14
|
2015-11-27 02:05:32 +00:00
|
|
|
call BattleTower_CheckSaveFileExistsAndIsYours
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [ScriptVar]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-11-27 02:05:32 +00:00
|
|
|
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2015-11-24 20:18:44 +00:00
|
|
|
and $1
|
|
|
|
ld [ScriptVar], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
|
|
|
Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2015-11-24 20:18:44 +00:00
|
|
|
call GetSRAMBank
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2015-11-24 20:18:44 +00:00
|
|
|
or $1
|
2017-12-16 02:22:26 +00:00
|
|
|
ld [sBattleTowerSaveFileFlags], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_LevelCheck: ; 170ae8 (5c:4ae8) BattleTowerAction $18
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$b2fb]
|
|
|
|
call CloseSRAM
|
2015-11-27 02:05:32 +00:00
|
|
|
ld c, 10
|
2015-11-24 20:18:44 +00:00
|
|
|
call SimpleDivide
|
|
|
|
ld a, b
|
|
|
|
ld [wcd4f], a
|
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall BattleTower_LevelCheck ; level check
|
2015-11-24 20:18:44 +00:00
|
|
|
ret nc
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$b2fb]
|
|
|
|
call CloseSRAM
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
|
2017-11-19 10:52:42 +00:00
|
|
|
BattleTowerAction_UbersCheck: ; 170b16 (5c:4b16) BattleTowerAction $19
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$b2fb]
|
|
|
|
call CloseSRAM
|
|
|
|
ld c, 10
|
|
|
|
call SimpleDivide
|
|
|
|
ld a, b
|
|
|
|
ld [wcd4f], a
|
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall BattleTower_UbersCheck
|
2015-11-24 20:18:44 +00:00
|
|
|
ret nc
|
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [$b2fb]
|
|
|
|
call CloseSRAM
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_LoadOpponentTrainerAndPokemonWithOTSprite: ; 0x170b44
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function_LoadOpponentTrainerAndPokemons
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $3
|
|
|
|
ld [rSVBK], a
|
|
|
|
ld hl, BT_OTTrainerClass
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, $0
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
2018-01-06 23:53:30 +00:00
|
|
|
ld hl, BTTrainerClassSprites
|
2015-12-08 21:06:13 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wBTTempOTSprite], a
|
|
|
|
|
|
|
|
; Load sprite of the opponent trainer
|
|
|
|
; because s/he is chosen randomly and appears out of nowhere
|
|
|
|
ld a, [ScriptVar]
|
|
|
|
dec a
|
|
|
|
sla a
|
|
|
|
ld e, a
|
|
|
|
sla a
|
|
|
|
sla a
|
|
|
|
sla a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld d, 0
|
|
|
|
ld hl, MapObjects
|
|
|
|
add hl, bc
|
|
|
|
inc hl
|
|
|
|
ld a, [wBTTempOTSprite]
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, UsedSprites
|
|
|
|
add hl, de
|
|
|
|
ld [hli], a
|
|
|
|
ld [hUsedSpriteIndex], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hUsedSpriteTile], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall GetUsedSprite
|
2015-12-08 21:06:13 +00:00
|
|
|
ret
|
|
|
|
; 170b90
|
|
|
|
|
2018-01-06 23:53:30 +00:00
|
|
|
INCLUDE "data/trainers/sprites.asm"
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2018-01-05 10:05:01 +00:00
|
|
|
DummySpecial_170bd2: ; 170bd2
|
2015-12-08 21:06:13 +00:00
|
|
|
ret
|
|
|
|
; 170bd3
|
|
|
|
|
2018-01-02 16:47:58 +00:00
|
|
|
Special_CheckForBattleTowerRules: ; 170bd3
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckForBattleTowerRules
|
2015-12-08 21:06:13 +00:00
|
|
|
jr c, .asm_170bde
|
2018-01-15 00:26:55 +00:00
|
|
|
xor a ; FALSE
|
2015-12-08 21:06:13 +00:00
|
|
|
jr .asm_170be0
|
|
|
|
|
|
|
|
.asm_170bde
|
2018-01-15 00:26:55 +00:00
|
|
|
ld a, TRUE
|
2015-12-08 21:06:13 +00:00
|
|
|
|
|
|
|
.asm_170be0
|
|
|
|
ld [ScriptVar], a
|
|
|
|
ret
|
|
|
|
; 170be4
|