2018-06-24 14:09:41 +00:00
|
|
|
CheckForMobileBattleRules:
|
2017-12-27 03:57:19 +00:00
|
|
|
ld de, .PointerTables
|
|
|
|
call BattleTower_ExecuteJumptable
|
|
|
|
ret z
|
|
|
|
call BattleTower_PleaseReturnWhenReady
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PointerTables:
|
2017-12-27 03:57:19 +00:00
|
|
|
db 2
|
|
|
|
dw .Functions
|
|
|
|
dw .TextPointers
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Functions:
|
2017-12-27 03:57:19 +00:00
|
|
|
dw BattleTower_CheckPartyLengthIs3
|
|
|
|
dw BattleTower_CheckPartyHasThreeMonsThatAreNotEggs
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.TextPointers:
|
2017-12-27 03:57:19 +00:00
|
|
|
dw .ExcuseMeText
|
2019-04-10 18:46:16 +00:00
|
|
|
dw NeedAtLeastThreeMonText
|
|
|
|
dw EggDoesNotQualifyText
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
.ExcuseMeText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; Excuse me!
|
2018-10-28 16:16:55 +00:00
|
|
|
text_far UnknownText_0x1c5937
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_CheckForBattleTowerRules:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStringBuffer2
|
2017-12-27 03:57:19 +00:00
|
|
|
ld [hl], "3"
|
|
|
|
inc hl
|
|
|
|
ld [hl], "@"
|
|
|
|
ld de, .PointerTables
|
|
|
|
call BattleTower_ExecuteJumptable
|
|
|
|
ret z
|
|
|
|
call BattleTower_PleaseReturnWhenReady
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PointerTables:
|
2017-12-27 03:57:19 +00:00
|
|
|
db 4
|
|
|
|
dw .Functions
|
|
|
|
dw .TextPointers
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Functions:
|
2017-12-27 03:57:19 +00:00
|
|
|
dw Function_PartyCountEq3
|
|
|
|
dw Function_PartySpeciesAreUnique
|
|
|
|
dw Function_PartyItemsAreUnique
|
|
|
|
dw Function_HasPartyAnEgg
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.TextPointers:
|
2017-12-27 03:57:19 +00:00
|
|
|
dw JumpText_ExcuseMeYoureNotReady
|
2019-04-10 18:46:16 +00:00
|
|
|
dw OnlyThreeMonMayBeEnteredText
|
|
|
|
dw TheMonMustAllBeDifferentKindsText
|
|
|
|
dw TheMonMustNotHoldTheSameItemsText
|
|
|
|
dw YouCantTakeAnEggText
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
JumpText_ExcuseMeYoureNotReady:
|
2017-12-27 03:57:19 +00:00
|
|
|
; Excuse me. You're not ready.
|
2018-10-28 16:16:55 +00:00
|
|
|
text_far Text_ExcuseMeYoureNotReady
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTower_PleaseReturnWhenReady:
|
2017-12-27 03:57:19 +00:00
|
|
|
ld hl, .PleaseReturnWhenReady
|
|
|
|
call PrintText
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
.PleaseReturnWhenReady:
|
2017-12-27 03:57:19 +00:00
|
|
|
; Please return when you're ready.
|
2018-10-28 16:16:55 +00:00
|
|
|
text_far UnknownText_0x1c5962
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
NeedAtLeastThreeMonText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; You need at least three #MON.
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _NeedAtLeastThreeMonText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
EggDoesNotQualifyText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; Sorry, an EGG doesn't qualify.
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _EggDoesNotQualifyText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
OnlyThreeMonMayBeEnteredText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; Only three #MON may be entered.
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _OnlyThreeMonMayBeEnteredText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
TheMonMustAllBeDifferentKindsText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; The @ #MON must all be different kinds.
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _TheMonMustAllBeDifferentKindsText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
TheMonMustNotHoldTheSameItemsText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; The @ #MON must not hold the same items.
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _TheMonMustNotHoldTheSameItemsText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2019-04-10 18:46:16 +00:00
|
|
|
YouCantTakeAnEggText:
|
2017-12-27 03:57:19 +00:00
|
|
|
; You can't take an EGG!
|
2019-04-10 18:46:16 +00:00
|
|
|
text_far _YouCantTakeAnEggText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2017-12-27 03:57:19 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTower_ExecuteJumptable:
|
2017-12-27 03:57:19 +00:00
|
|
|
ld bc, 0
|
|
|
|
.loop
|
|
|
|
call .DoJumptableFunction
|
|
|
|
call c, .PrintFailureText
|
|
|
|
call .Next_CheckReachedEnd
|
|
|
|
jr nz, .loop
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DoJumptableFunction:
|
2017-12-27 03:57:19 +00:00
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
call .GetFunctionPointer
|
|
|
|
ld a, c
|
|
|
|
rst JumpTable
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Next_CheckReachedEnd:
|
2017-12-27 03:57:19 +00:00
|
|
|
inc c
|
|
|
|
ld a, [de]
|
|
|
|
cp c
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.GetFunctionPointer:
|
2017-12-27 03:57:19 +00:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld l, a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld h, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.GetTextPointers:
|
2017-12-27 03:57:19 +00:00
|
|
|
inc de
|
|
|
|
inc de
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld l, a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld h, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadTextPointer:
|
2017-12-27 03:57:19 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PrintFailureText:
|
2017-12-27 03:57:19 +00:00
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
call z, .PrintFirstText
|
|
|
|
pop bc
|
|
|
|
call .PrintNthText
|
2019-04-10 18:46:16 +00:00
|
|
|
ld b, 1
|
2017-12-27 03:57:19 +00:00
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PrintFirstText:
|
2017-12-27 03:57:19 +00:00
|
|
|
push de
|
|
|
|
call .GetTextPointers
|
|
|
|
call .LoadTextPointer
|
|
|
|
call PrintText
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PrintNthText:
|
2017-12-27 03:57:19 +00:00
|
|
|
push bc
|
|
|
|
call .GetTextPointers
|
|
|
|
inc hl
|
|
|
|
inc hl
|
2019-04-10 18:46:16 +00:00
|
|
|
ld b, 0
|
2017-12-27 03:57:19 +00:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
call .LoadTextPointer
|
|
|
|
call PrintText
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTower_CheckPartyLengthIs3:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2018-01-20 17:25:55 +00:00
|
|
|
cp BATTLETOWER_PARTY_LENGTH
|
2017-12-27 03:57:19 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleTower_CheckPartyHasThreeMonsThatAreNotEggs:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyCount
|
2017-12-27 03:57:19 +00:00
|
|
|
ld a, [hli]
|
2019-04-10 18:46:16 +00:00
|
|
|
ld b, 0
|
2017-12-27 03:57:19 +00:00
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp EGG
|
|
|
|
jr z, .egg
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.egg
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2017-12-27 03:57:19 +00:00
|
|
|
cp b
|
|
|
|
ret z
|
|
|
|
ld a, b
|
2018-01-20 17:25:55 +00:00
|
|
|
cp BATTLETOWER_PARTY_LENGTH
|
2017-12-27 03:57:19 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function_PartyCountEq3:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2018-01-20 17:25:55 +00:00
|
|
|
cp BATTLETOWER_PARTY_LENGTH
|
2017-12-27 03:57:19 +00:00
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function_PartySpeciesAreUnique:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1Species
|
2017-12-27 03:57:19 +00:00
|
|
|
call VerifyUniqueness
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VerifyUniqueness:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wPartyCount
|
2017-12-27 03:57:19 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
dec a
|
|
|
|
jr z, .done
|
|
|
|
ld b, a
|
|
|
|
.loop
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
ld c, b
|
|
|
|
call .isegg
|
|
|
|
jr z, .next
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .next
|
|
|
|
.loop2
|
|
|
|
call .nextmon
|
|
|
|
call .isegg
|
|
|
|
jr z, .next2
|
|
|
|
cp [hl]
|
|
|
|
jr z, .gotcha
|
|
|
|
|
|
|
|
.next2
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
|
|
|
|
.next
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
call .nextmon
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.gotcha
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.nextmon
|
2017-12-27 03:57:19 +00:00
|
|
|
push bc
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
inc de
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.isegg
|
2017-12-27 03:57:19 +00:00
|
|
|
push bc
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
cp EGG
|
|
|
|
ld a, b
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function_PartyItemsAreUnique:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1Item
|
2017-12-27 03:57:19 +00:00
|
|
|
call VerifyUniqueness
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Function_HasPartyAnEgg:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyCount
|
2017-12-27 03:57:19 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp EGG
|
|
|
|
jr z, .found
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.found
|
|
|
|
scf
|
|
|
|
ret
|