2018-06-24 14:09:41 +00:00
|
|
|
BattleTowerRoomMenu:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1700ba:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1700c4:
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(w3_d202TrainerData) ; aka BANK(w3_dffc) and BANK(w3_d202Name)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
call Function17042c
|
2015-11-25 15:16:29 +00:00
|
|
|
|
2020-02-28 16:51:42 +00:00
|
|
|
ld a, BANK(s5_be45) ; aka BANK(s5_be46), BANK(s5_aa41), and BANK(s5_aa5d)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [s5_be45], a
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_be46], a
|
2015-11-25 15:16:29 +00:00
|
|
|
ld hl, w3_dffc
|
2019-04-10 18:46:16 +00:00
|
|
|
ld de, s5_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
|
2019-04-10 18:46:16 +00:00
|
|
|
ld de, s5_aa8e
|
2020-02-25 22:06:32 +00:00
|
|
|
ld bc, BATTLETOWER_STREAK_LENGTH * $cc ; length of battle tower struct from japanese games?
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_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
|
2019-04-10 18:46:16 +00:00
|
|
|
ld d, 0
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function170114:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Function170121:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a948)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_a948
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, wc608
|
2019-04-10 18:46:16 +00:00
|
|
|
ld bc, 246
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
call Function170c8b
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function170139:
|
2020-06-21 16:21:47 +00:00
|
|
|
; Convert the 4-digit decimal number at s5_aa41 into binary
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa41)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld de, s5_aa41
|
|
|
|
ld h, 0
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2019-04-10 18:46:16 +00:00
|
|
|
ld b, 0
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, bc
|
|
|
|
call CloseSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
; Store that number in wc608
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, h
|
2018-03-19 15:36:14 +00:00
|
|
|
ld [wc608], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, l
|
2018-03-19 15:36:14 +00:00
|
|
|
ld [wc608 + 1], a
|
2018-02-22 16:13:29 +00:00
|
|
|
ld hl, wBT_OTTempMon1DVs
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPlayerID]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPlayerID + 1]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld a, [wSecretID]
|
|
|
|
ld [hli], a
|
|
|
|
ld a, [wSecretID + 1]
|
|
|
|
ld [hli], a
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPlayerName
|
2017-12-21 16:56:33 +00:00
|
|
|
ld bc, NAME_LENGTH_JAPANESE - 1
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2018-01-23 22:39:09 +00:00
|
|
|
ld bc, wPlayerID
|
2017-12-28 12:15:46 +00:00
|
|
|
ld de, wPlayerGender
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall GetMobileOTTrainerClass
|
2018-02-22 16:13:29 +00:00
|
|
|
ld de, wBT_OTTempMon1CaughtGender
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, c
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, LOW(wPartyMons)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd49], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, HIGH(wPartyMons)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd4a], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, LOW(wPartyMonNicknames)
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd4b], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, HIGH(wPartyMonNicknames)
|
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
|
2019-04-10 18:46:16 +00:00
|
|
|
|
|
|
|
ld a, BANK(s4_a013)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s4_a013
|
|
|
|
ld bc, 36
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
|
|
|
|
ld a, BANK(s5_a894) ; aka BANK(s5_a948)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_a894
|
2017-12-21 16:56:33 +00:00
|
|
|
ld bc, NAME_LENGTH_JAPANESE
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2018-03-19 15:36:14 +00:00
|
|
|
ld hl, wc608
|
2019-04-10 18:46:16 +00:00
|
|
|
ld de, s5_a948
|
|
|
|
ld bc, 246
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DecToBin:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTowerBattle:
|
2019-04-10 18:46:16 +00:00
|
|
|
xor a ; FALSE
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wBattleTowerBattleEnded], a
|
2015-11-07 19:38:52 +00:00
|
|
|
call _BattleTowerBattle
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DummySpecial_17021d:
|
2015-11-07 19:38:52 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
InitBattleTowerChallengeRAM:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_BattleTowerBattle:
|
2015-11-07 19:38:52 +00:00
|
|
|
.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]
|
2019-04-10 18:46:16 +00:00
|
|
|
cp TRUE
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.do_dw
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.dw
|
2015-11-07 19:38:52 +00:00
|
|
|
dw RunBattleTowerTrainer
|
|
|
|
dw SkipBattleTowerTrainer
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
RunBattleTowerTrainer:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wOptions]
|
2015-11-07 19:38:52 +00:00
|
|
|
push af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wOptions
|
2015-11-07 19:38:52 +00:00
|
|
|
set BATTLE_SHIFT, [hl] ; SET MODE
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2015-11-07 19:38:52 +00:00
|
|
|
push af
|
2019-04-10 18:46:16 +00:00
|
|
|
or 1
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wInBattleTowerBattle], a
|
2015-11-07 19:38:52 +00:00
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [wLinkMode], a
|
2018-01-24 16:17:05 +00:00
|
|
|
farcall 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]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2018-04-05 15:44:02 +00:00
|
|
|
and a ; WIN?
|
2015-11-07 19:38:52 +00:00
|
|
|
jr nz, .lost
|
|
|
|
ld a, BANK(sNrOfBeatenBattleTowerTrainers)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, [sNrOfBeatenBattleTowerTrainers]
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wNrOfBeatenBattleTowerTrainers], a
|
2015-11-07 19:38:52 +00:00
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStringBuffer3
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wInBattleTowerBattle], a
|
2015-11-07 19:38:52 +00:00
|
|
|
pop af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wOptions], a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2015-12-08 21:06:13 +00:00
|
|
|
ld [wBattleTowerBattleEnded], a
|
2015-11-07 19:38:52 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ReadBTTrainerParty:
|
2018-02-22 16:13:29 +00:00
|
|
|
; Initialise the BattleTower-Trainer and his mon
|
2015-11-07 19:38:52 +00:00
|
|
|
call CopyBTTrainer_FromBT_OT_TowBT_OTTemp
|
|
|
|
|
|
|
|
; Check the nicknames for illegal characters, and replace bad nicknames
|
|
|
|
; with their species names.
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon1Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld c, MON_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
|
|
|
|
|
2018-02-22 16:13:29 +00:00
|
|
|
ld a, [wBT_OTTempMon1]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon1Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-11-07 19:38:52 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_1
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon2Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld c, MON_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
|
2018-07-15 11:18:28 +00:00
|
|
|
ld a, [wBT_OTTempMon2]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon2Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-11-07 19:38:52 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_2
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon3Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld c, MON_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
|
2018-07-15 11:18:28 +00:00
|
|
|
ld a, [wBT_OTTempMon3]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
2018-07-15 11:18:28 +00:00
|
|
|
ld de, wBT_OTTempMon3Name
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-11-07 19:38:52 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.skip_mon_3
|
|
|
|
; Add the terminator character to each of these names
|
|
|
|
ld a, "@"
|
2018-07-15 11:18:28 +00:00
|
|
|
ld [wBT_OTTempMon1NameEnd - 1], a
|
|
|
|
ld [wBT_OTTempMon2NameEnd - 1], a
|
|
|
|
ld [wBT_OTTempMon3NameEnd - 1], a
|
2015-11-07 19:38:52 +00:00
|
|
|
; Fix errors in the movesets
|
|
|
|
call CheckBTMonMovesForErrors
|
2018-01-23 22:39:09 +00:00
|
|
|
; Repair the trainer name if needed, then copy it to wOTPlayerName
|
2015-11-07 19:38:52 +00:00
|
|
|
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
|
2018-06-25 00:10:37 +00:00
|
|
|
ld hl, wBT_OTTempName
|
2015-11-07 19:38:52 +00:00
|
|
|
|
|
|
|
.done_trainer_name
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wOTPlayerName
|
2015-11-07 19:38:52 +00:00
|
|
|
ld bc, NAME_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
ld a, "@"
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
ld hl, wBT_OTTempTrainerClass
|
|
|
|
ld a, [hli]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wOtherTrainerClass], a
|
|
|
|
ld a, LOW(wOTPartyMonNicknames)
|
|
|
|
ld [wBGMapBuffer], a
|
|
|
|
ld a, HIGH(wOTPartyMonNicknames)
|
|
|
|
ld [wBGMapBuffer + 1], a
|
2015-11-07 19:38:52 +00:00
|
|
|
|
2018-02-22 16:13:29 +00:00
|
|
|
; Copy mon into Memory from the address in hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wOTPartyMon1Species
|
|
|
|
ld bc, wOTPartyCount
|
2018-01-20 17:25:55 +00:00
|
|
|
ld a, BATTLETOWER_PARTY_LENGTH
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBGMapBuffer]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld e, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBGMapBuffer + 1]
|
2015-11-07 19:38:52 +00:00
|
|
|
ld d, a
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2015-11-07 19:38:52 +00:00
|
|
|
call CopyBytes
|
|
|
|
ld a, e
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBGMapBuffer], a
|
2015-11-07 19:38:52 +00:00
|
|
|
ld a, d
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBGMapBuffer + 1], a
|
2015-11-07 19:38:52 +00:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
and a
|
|
|
|
jr nz, .otpartymon_loop
|
|
|
|
ld a, -1
|
|
|
|
ld [bc], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ValidateBTParty:
|
2015-11-08 02:04:54 +00:00
|
|
|
; Check for and fix errors in party data
|
2018-02-22 16:13:29 +00:00
|
|
|
ld hl, wBT_OTTempMon1Species
|
2018-01-20 17:25:55 +00:00
|
|
|
ld d, BATTLETOWER_PARTY_LENGTH
|
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
|
2018-01-23 15:56:36 +00:00
|
|
|
x = $ff
|
2020-03-21 18:01:05 +00:00
|
|
|
rept ($ff - NUM_POKEMON)
|
2015-11-08 02:04:54 +00:00
|
|
|
jr z, .invalid
|
2018-01-23 15:56:36 +00:00
|
|
|
cp x
|
2020-03-21 18:01:05 +00:00
|
|
|
x = x - 1
|
2015-11-08 02:04:54 +00:00
|
|
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurSpecies], a
|
2015-11-07 19:38:52 +00:00
|
|
|
call GetBaseData
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2fb)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurPartyLevel], 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
|
2018-02-22 17:12:43 +00:00
|
|
|
ld b, TRUE
|
2018-02-22 16:13:29 +00:00
|
|
|
predef CalcMonStats
|
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
|
2019-01-03 00:04:50 +00:00
|
|
|
ld bc, NICKNAMED_MON_STRUCT_LENGTH
|
2015-11-07 19:38:52 +00:00
|
|
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BT_ChrisName:
|
2015-11-07 19:38:52 +00:00
|
|
|
db "CHRIS@"
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function17042c:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, w3_d202TrainerData
|
2018-01-20 17:25:55 +00:00
|
|
|
ld a, BATTLETOWER_STREAK_LENGTH
|
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
|
|
|
|
|
2018-01-06 23:53:30 +00:00
|
|
|
INCLUDE "data/battle_tower/unknown_levels.asm"
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CopyBTTrainer_FromBT_OT_TowBT_OTTemp:
|
2018-01-23 22:39:09 +00:00
|
|
|
; copy the BattleTower-Trainer data that lies at 'wBT_OTTrainer' to 'wBT_OTTemp'
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, BANK(wBT_OTTrainer)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wBT_OTTrainer
|
2017-12-23 16:34:55 +00:00
|
|
|
ld de, wBT_OTTemp
|
2015-11-24 20:18:44 +00:00
|
|
|
ld bc, BATTLE_TOWER_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-06-24 14:09:41 +00:00
|
|
|
SkipBattleTowerTrainer:
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
2015-11-25 15:16:29 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Unreferenced_Function1704ca:
|
2020-02-25 22:06:32 +00:00
|
|
|
ld a, [s5_be46]
|
|
|
|
cp BATTLETOWER_STREAK_LENGTH
|
|
|
|
jr c, .not_max
|
|
|
|
ld a, BATTLETOWER_STREAK_LENGTH - 1
|
|
|
|
|
|
|
|
.not_max
|
|
|
|
ld hl, s5_aa8e + BATTLE_TOWER_STRUCT_LENGTH * (BATTLETOWER_STREAK_LENGTH - 1)
|
|
|
|
ld de, -BATTLE_TOWER_STRUCT_LENGTH
|
|
|
|
.loop
|
2015-11-24 20:18:44 +00:00
|
|
|
and a
|
2020-02-25 22:06:32 +00:00
|
|
|
jr z, .done
|
2015-11-24 20:18:44 +00:00
|
|
|
add hl, de
|
|
|
|
dec a
|
2020-02-25 22:06:32 +00:00
|
|
|
jr .loop
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2020-02-25 22:06:32 +00:00
|
|
|
.done
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1704e1:
|
2019-04-08 12:15:10 +00:00
|
|
|
call SpeechTextbox
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.JumptableLoop:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DoJumptable:
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.dw
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Jumptable_0:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a89c)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_a89c
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wStringBuffer3
|
2019-04-10 18:46:16 +00:00
|
|
|
ld bc, 22
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_a8b2
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, wc608
|
2019-04-10 18:46:16 +00:00
|
|
|
ld bc, 150
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
call CloseSRAM
|
|
|
|
hlcoord 1, 1
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wStringBuffer3
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wStringBuffer4
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DrawBorder:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PlaceTextItems:
|
2015-11-25 15:16:29 +00:00
|
|
|
call .ClearBox
|
|
|
|
call .PlaceUpDownArrows
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $50
|
|
|
|
ld [wcd4e], a
|
2018-03-19 15:36:14 +00:00
|
|
|
ld hl, wc608
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.ClearBox:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PlaceUpDownArrows:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.String_Mail:
|
2015-11-24 20:18:44 +00:00
|
|
|
db "ルーム@"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.String_PastReaders:
|
2015-11-24 20:18:44 +00:00
|
|
|
db "れきだいりーダーいちらん@"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTowerAction:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.dw
|
2019-04-10 18:46:16 +00:00
|
|
|
dw BattleTowerAction_CheckExplanationRead
|
|
|
|
dw BattleTowerAction_SetExplanationRead
|
|
|
|
dw BattleTowerAction_GetChallengeState
|
|
|
|
dw BattleTowerAction_SetByteToQuickSaveChallenge
|
|
|
|
dw BattleTowerAction_SetByteToCancelChallenge
|
|
|
|
dw Function1707ac
|
|
|
|
dw Function1707f4
|
|
|
|
dw SaveBattleTowerLevelGroup
|
|
|
|
dw LoadBattleTowerLevelGroup
|
|
|
|
dw BattleTower_CheckSaveFileExistsAndIsYours
|
|
|
|
dw Function1708b1
|
|
|
|
dw CheckMobileEventIndex
|
|
|
|
dw Function1708c8
|
|
|
|
dw Function1708f0
|
|
|
|
dw BattleTowerAction_EggTicket
|
|
|
|
dw Function1709aa
|
|
|
|
dw Function1709bb
|
|
|
|
dw Function170a9c
|
|
|
|
dw Function170aa0
|
|
|
|
dw Function170aaf
|
|
|
|
dw Function170abe
|
|
|
|
dw Function170ad7
|
|
|
|
dw Function170807
|
|
|
|
dw Function17081d
|
|
|
|
dw BattleTowerAction_LevelCheck
|
|
|
|
dw BattleTowerAction_UbersCheck
|
|
|
|
dw ResetBattleTowerTrainersSRAM
|
|
|
|
dw BattleTower_GiveReward
|
|
|
|
dw Function17071b
|
|
|
|
dw Function170729
|
|
|
|
dw BattleTower_RandomlyChooseReward
|
|
|
|
dw BattleTower_SaveOptions
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
|
2019-04-10 18:46:16 +00:00
|
|
|
ResetBattleTowerTrainersSRAM:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBTTrainers)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
ld a, $ff
|
|
|
|
ld hl, sBTTrainers
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, BATTLETOWER_STREAK_LENGTH
|
2015-11-24 20:18:44 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [sNrOfBeatenBattleTowerTrainers], a
|
|
|
|
|
|
|
|
call CloseSRAM
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTower_GiveReward:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerReward)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
ld a, [sBattleTowerReward]
|
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
|
|
|
ld hl, wNumItems
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hli]
|
|
|
|
cp MAX_ITEMS
|
|
|
|
ret c
|
|
|
|
ld b, MAX_ITEMS
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function17071b:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170729:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTower_SaveOptions:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall SaveOptions
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTower_RandomlyChooseReward:
|
2015-11-24 20:18:44 +00:00
|
|
|
; Generate a random stat boosting item.
|
|
|
|
.loop
|
|
|
|
call Random
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hRandomAdd]
|
2015-11-24 20:18:44 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
|
|
|
ld [sBattleTowerReward], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_CheckExplanationRead:
|
2015-11-27 02:05:32 +00:00
|
|
|
call BattleTower_CheckSaveFileExistsAndIsYours
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-11-24 20:18:44 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2019-04-10 18:46:16 +00:00
|
|
|
and 2
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_GetChallengeState:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, sBattleTowerChallengeState
|
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [hl]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_SetExplanationRead:
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2019-04-10 18:46:16 +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
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_SetByteToQuickSaveChallenge:
|
2015-11-27 02:05:32 +00:00
|
|
|
ld c, BATTLETOWER_SAVED_AND_LEFT
|
2015-11-24 20:18:44 +00:00
|
|
|
jr asm_17079f
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_SetByteToCancelChallenge:
|
2015-11-27 02:05:32 +00:00
|
|
|
ld c, BATTLETOWER_NO_CHALLENGE
|
2018-06-24 14:09:41 +00:00
|
|
|
asm_17079f:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, c
|
|
|
|
ld [sBattleTowerChallengeState], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function1707ac:
|
|
|
|
ld a, BANK(s5_aa8c) ; aka BANK(s5_be46)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa8c]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld b, a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_be46]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld a, b
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 2
|
2015-11-24 20:18:44 +00:00
|
|
|
jr nc, .asm_1707ef
|
|
|
|
push bc
|
|
|
|
call UpdateTime
|
|
|
|
pop bc
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa8c)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa8b]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurDay]
|
2015-11-24 20:18:44 +00:00
|
|
|
sub c
|
|
|
|
jr c, .asm_1707e5
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 8
|
2015-11-24 20:18:44 +00:00
|
|
|
jr nc, .asm_1707ef
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr nz, .asm_1707ef
|
|
|
|
ret
|
|
|
|
.asm_1707e5
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wCurDay
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, $8c
|
|
|
|
sub c
|
|
|
|
add [hl]
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 8
|
2015-11-24 20:18:44 +00:00
|
|
|
ret c
|
|
|
|
.asm_1707ef
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, 8
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function1707f4:
|
|
|
|
ld a, BANK(s5_be46) ; aka BANK(s5_aa8b) and BANK(s5_aa8c)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_be46], a
|
|
|
|
ld [s5_aa8b], a
|
|
|
|
ld [s5_aa8c], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170807:
|
2015-11-24 20:18:44 +00:00
|
|
|
call UpdateTime
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2f9) ; aka BANK(s5_b2fa)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurDay]
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_b2f9], a
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_b2fa], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function17081d:
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2f9) ; aka BANK(s5_b2fa)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2f9]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld c, a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2fa]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld b, a
|
|
|
|
call CloseSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 2
|
2015-11-24 20:18:44 +00:00
|
|
|
jr nc, .asm_170853
|
|
|
|
push bc
|
|
|
|
call UpdateTime
|
|
|
|
pop bc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurDay]
|
2015-11-24 20:18:44 +00:00
|
|
|
sub c
|
|
|
|
jr c, .asm_170849
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 11
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wCurDay
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, 140
|
2015-11-24 20:18:44 +00:00
|
|
|
sub c
|
|
|
|
add [hl]
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 11
|
2015-11-24 20:18:44 +00:00
|
|
|
ret c
|
|
|
|
.asm_170853
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, 1
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2f9) ; aka BANK(s5_b2fa)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_b2f9], a
|
|
|
|
ld [s5_b2fa], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
SaveBattleTowerLevelGroup:
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, BANK(sBTChoiceOfLevelGroup)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(wBTChoiceOfLvlGroup)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [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
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
LoadBattleTowerLevelGroup: ; Load level group choice
|
2015-11-27 02:05:32 +00:00
|
|
|
ld a, BANK(sBTChoiceOfLevelGroup)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(wBTChoiceOfLvlGroup)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [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
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTower_CheckSaveFileExistsAndIsYours:
|
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
|
2019-04-10 18:46:16 +00:00
|
|
|
xor a ; FALSE
|
2015-11-24 20:18:44 +00:00
|
|
|
jr .nope
|
|
|
|
|
|
|
|
.yes
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2015-11-24 20:18:44 +00:00
|
|
|
|
|
|
|
.nope
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1708b1: ; BattleTowerAction $0a
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMusicFade], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call MaxVolume
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckMobileEventIndex: ; BattleTowerAction $0b something to do with GS Ball
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sMobileEventIndex)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [sMobileEventIndex]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1708c8: ; BattleTowerAction $0c
|
2015-11-24 20:18:44 +00:00
|
|
|
call UpdateTime
|
2020-02-28 16:51:42 +00:00
|
|
|
ld a, BANK(s5_aa8b) ; aka BANK(s5_aa8c), BANK(s5_aa5d), BANK(s5_aa48), and BANK(s5_aa47)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurDay]
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_aa8b], a
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_aa8c], a
|
|
|
|
ld a, [s5_aa5d]
|
|
|
|
cp 2
|
2015-11-24 20:18:44 +00:00
|
|
|
jr nc, .asm_1708ec
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurDay]
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_aa48], a
|
|
|
|
ld a, 1
|
|
|
|
ld [s5_aa47], a
|
2015-11-24 20:18:44 +00:00
|
|
|
.asm_1708ec
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1708f0: ; BattleTowerAction $0d
|
2019-04-10 18:46:16 +00:00
|
|
|
xor a ; FALSE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call UpdateTime
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa48) ; aka BANK(s5_aa47)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa48]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld c, a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa47]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
and a
|
|
|
|
ret z
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wCurDay
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, c
|
|
|
|
cp [hl]
|
|
|
|
jr nz, Function170923
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa5d)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa5d]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
cp 5
|
2015-11-24 20:18:44 +00:00
|
|
|
ret c
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function170923:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa48) ; aka BANK(s5_aa47) and BANK(s5_aa5d)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_aa48], a
|
|
|
|
ld [s5_aa47], a
|
|
|
|
ld hl, s5_aa5d
|
|
|
|
ld bc, MOBILE_LOGIN_PASSWORD_LENGTH
|
2015-11-24 20:18:44 +00:00
|
|
|
call ByteFill
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTowerAction_EggTicket: ; BattleTowerAction $0e
|
2019-04-10 18:46:16 +00:00
|
|
|
xor a ; FALSE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, EGG_TICKET
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurItem], a
|
|
|
|
ld hl, wNumItems
|
2015-11-24 20:18:44 +00:00
|
|
|
call CheckItem
|
|
|
|
ret nc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartySpecies
|
2015-11-24 20:18:44 +00:00
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp EGG
|
|
|
|
jr nz, .not_egg
|
|
|
|
push hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMonOT
|
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
|
2018-03-03 00:39:16 +00:00
|
|
|
ld de, String_MysteryJP
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurItem], 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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurItemQuantity], a
|
|
|
|
ld hl, wNumItems
|
2015-11-24 20:18:44 +00:00
|
|
|
call TossItem
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
String_MysteryJP:
|
2018-03-03 00:39:16 +00:00
|
|
|
db "なぞナゾ@@" ; MYSTERY
|
2015-11-24 20:18:44 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1709aa: ; BattleTowerAction $0f
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-24 20:18:44 +00:00
|
|
|
push af
|
|
|
|
ld a, BANK(w3_d090)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, [w3_d090]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function1709bb: ; BattleTowerAction $10
|
2019-04-10 18:46:16 +00:00
|
|
|
xor a ; FALSE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a800)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_a800]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
cp 6
|
|
|
|
jr nc, .invalid
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-03-03 00:39:16 +00:00
|
|
|
ld hl, .jumptable
|
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
|
|
|
|
|
|
|
.invalid
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a800)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_a800], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.jumptable:
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DoAction1:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a800)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [s5_a800], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.NoAction:
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Action4:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b023) ; aka BANK(s5_a825) and BANK(s5_a826)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_b023
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, wc608
|
2019-04-10 18:46:16 +00:00
|
|
|
ld bc, 105
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_a825]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd30], a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_a826]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld [wcd31], a
|
|
|
|
call CloseSRAM
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function11b6b4
|
|
|
|
farcall Function17d0f3
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Action5:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, 0 ; ???
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld hl, wRTC
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, wc608
|
2019-04-10 18:46:16 +00:00
|
|
|
ld bc, 4
|
2015-11-24 20:18:44 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b08c)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld hl, s5_b08c
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, wc608
|
2019-04-10 18:46:16 +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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapGroup]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld b, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapNumber]
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, TRUE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2015-11-27 02:05:32 +00:00
|
|
|
.different
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_a800)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
xor a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_a800], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
|
|
|
ld a, [wMapGroup]
|
2015-11-24 20:18:44 +00:00
|
|
|
ld b, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapNumber]
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170a9c:
|
2018-03-03 00:39:16 +00:00
|
|
|
ld c, FALSE
|
2015-11-24 20:18:44 +00:00
|
|
|
jr asm_170aa2
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170aa0:
|
2018-03-03 00:39:16 +00:00
|
|
|
ld c, TRUE
|
2018-06-24 14:09:41 +00:00
|
|
|
asm_170aa2:
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_aa8d)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, c
|
2019-04-10 18:46:16 +00:00
|
|
|
ld [s5_aa8d], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170aaf:
|
|
|
|
ld a, BANK(s5_aa8d)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_aa8d]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170abe:
|
2015-11-27 02:05:32 +00:00
|
|
|
call BattleTower_CheckSaveFileExistsAndIsYours
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-11-24 20:18:44 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-27 02:05:32 +00:00
|
|
|
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2019-04-10 18:46:16 +00:00
|
|
|
and 1
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
Function170ad7:
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, BANK(sBattleTowerSaveFileFlags)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBattleTowerSaveFileFlags]
|
2019-04-10 18:46:16 +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
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_LevelCheck:
|
|
|
|
ld a, BANK(s5_b2fb)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2fb]
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2019-04-10 18:46:16 +00:00
|
|
|
farcall BattleTower_LevelCheck
|
2015-11-24 20:18:44 +00:00
|
|
|
ret nc
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2fb)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2fb]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
BattleTowerAction_UbersCheck:
|
|
|
|
ld a, BANK(s5_b2fb)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2fb]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ld c, 10
|
|
|
|
call SimpleDivide
|
|
|
|
ld a, b
|
|
|
|
ld [wcd4f], a
|
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall BattleTower_UbersCheck
|
2015-11-24 20:18:44 +00:00
|
|
|
ret nc
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(s5_b2fb)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, [s5_b2fb]
|
2015-11-24 20:18:44 +00:00
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-24 20:18:44 +00:00
|
|
|
ret
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
LoadOpponentTrainerAndPokemonWithOTSprite:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall Function_LoadOpponentTrainerAndPokemons
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-12-08 21:06:13 +00:00
|
|
|
push af
|
2019-04-10 18:46:16 +00:00
|
|
|
ld a, BANK(wBT_OTTrainerClass)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wBT_OTTrainerClass
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld c, a
|
2019-04-10 18:46:16 +00:00
|
|
|
ld b, 0
|
2015-12-08 21:06:13 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [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
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-12-08 21:06:13 +00:00
|
|
|
dec a
|
|
|
|
sla a
|
|
|
|
ld e, a
|
|
|
|
sla a
|
|
|
|
sla a
|
|
|
|
sla a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld d, 0
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wMapObjects
|
2015-12-08 21:06:13 +00:00
|
|
|
add hl, bc
|
|
|
|
inc hl
|
|
|
|
ld a, [wBTTempOTSprite]
|
|
|
|
ld [hl], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wUsedSprites
|
2015-12-08 21:06:13 +00:00
|
|
|
add hl, de
|
|
|
|
ld [hli], a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hUsedSpriteIndex], a
|
2015-12-08 21:06:13 +00:00
|
|
|
ld a, [hl]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hUsedSpriteTile], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall GetUsedSprite
|
2015-12-08 21:06:13 +00:00
|
|
|
ret
|
|
|
|
|
2018-01-06 23:53:30 +00:00
|
|
|
INCLUDE "data/trainers/sprites.asm"
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DummySpecial_170bd2:
|
2015-12-08 21:06:13 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckForBattleTowerRules:
|
2018-01-24 16:12:02 +00:00
|
|
|
farcall _CheckForBattleTowerRules
|
2019-04-10 18:46:16 +00:00
|
|
|
jr c, .ready
|
2018-01-15 00:26:55 +00:00
|
|
|
xor a ; FALSE
|
2019-04-10 18:46:16 +00:00
|
|
|
jr .end
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
.ready
|
2018-01-15 00:26:55 +00:00
|
|
|
ld a, TRUE
|
2015-12-08 21:06:13 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
.end
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-12-08 21:06:13 +00:00
|
|
|
ret
|