pokecrystal-board/event/battle_tower.asm

343 lines
4.7 KiB
NASM
Raw Normal View History

2015-12-17 19:31:16 -08:00
CheckForMobileBattleRules: ; 8b1e1
ld de, .PointerTables
call BattleTower_ExecuteJumptable
2015-10-16 10:35:43 -07:00
ret z
2015-12-17 19:31:16 -08:00
call BattleTower_PleaseReturnWhenReady
2015-10-16 10:35:43 -07:00
scf
ret
; 8b1ed
2015-12-17 19:31:16 -08:00
.PointerTables: ; 8b1ed
2015-10-16 10:35:43 -07:00
db 2
2015-12-17 19:31:16 -08:00
dw .Functions
dw .TextPointers
2015-10-16 10:35:43 -07:00
2015-12-17 19:31:16 -08:00
.Functions: ; 8b1f2
dw BattleTower_CheckPartyLengthIs3
dw BattleTower_CheckPartyHasThreeMonsThatAreNotEggs
2015-10-16 10:35:43 -07:00
; 8b1f6
2015-12-17 19:31:16 -08:00
.TextPointers: ; 8b1f6
dw .ExcuseMeText
dw JumpText_NeedAtLeastThreeMon
dw JumpText_EggDoesNotQualify
2015-10-16 10:35:43 -07:00
; 8b1fc
2015-12-17 19:31:16 -08:00
.ExcuseMeText: ; 0x8b1fc
2015-10-16 10:35:43 -07:00
; Excuse me!
text_jump UnknownText_0x1c5937
db "@"
; 0x8b201
CheckForBattleTowerRules: ; 8b201
ld hl, StringBuffer2
ld [hl], "3"
inc hl
ld [hl], "@"
2015-12-17 19:31:16 -08:00
ld de, .PointerTables
call BattleTower_ExecuteJumptable
2015-10-16 10:35:43 -07:00
ret z
2015-12-17 19:31:16 -08:00
call BattleTower_PleaseReturnWhenReady
2015-10-16 10:35:43 -07:00
scf
ret
; 8b215
2015-12-17 19:31:16 -08:00
.PointerTables: ; 8b215
2015-10-16 10:35:43 -07:00
db 4
2015-12-17 19:31:16 -08:00
dw .Functions
dw .TextPointers
2015-10-16 10:35:43 -07:00
2015-12-17 19:31:16 -08:00
.Functions: ; 8b21a
2015-10-16 10:35:43 -07:00
dw Function_PartyCountEq3
dw Function_PartySpeciesAreUnique
dw Function_PartyItemsAreUnique
dw Function_HasPartyAnEgg
; 8b222
2015-12-17 19:31:16 -08:00
.TextPointers: ; 8b222
2015-10-16 10:35:43 -07:00
dw JumpText_ExcuseMeYoureNotReady
2015-10-25 08:44:35 -07:00
dw JumpText_OnlyThreePkmnMayBeEntered
2015-10-16 10:35:43 -07:00
dw JumpText_ThePkmnMustAllBeDifferentKinds
dw JumpText_ThePkmnMustNotHoldTheSameItems
dw JumpText_YouCantTakeAnEgg
; 8b22c
JumpText_ExcuseMeYoureNotReady: ; 0x8b22c
; Excuse me. You're not ready.
text_jump Text_ExcuseMeYoureNotReady
db "@"
; 0x8b231
2015-12-17 19:31:16 -08:00
BattleTower_PleaseReturnWhenReady: ; 8b231
ld hl, .PleaseReturnWhenReady
2015-10-16 10:35:43 -07:00
call PrintText
ret
; 8b238
2015-12-17 19:31:16 -08:00
.PleaseReturnWhenReady: ; 0x8b238
2015-10-16 10:35:43 -07:00
; Please return when you're ready.
text_jump UnknownText_0x1c5962
db "@"
; 0x8b23d
2015-12-17 19:31:16 -08:00
JumpText_NeedAtLeastThreeMon: ; 0x8b23d
2015-10-16 10:35:43 -07:00
; You need at least three #MON.
text_jump UnknownText_0x1c5983
db "@"
; 0x8b242
2015-12-17 19:31:16 -08:00
JumpText_EggDoesNotQualify: ; 0x8b242
2015-10-16 10:35:43 -07:00
; Sorry, an EGG doesn't qualify.
text_jump UnknownText_0x1c59a3
db "@"
; 0x8b247
2015-10-25 08:44:35 -07:00
JumpText_OnlyThreePkmnMayBeEntered: ; 0x8b247
2015-10-16 10:35:43 -07:00
; Only three #MON may be entered.
text_jump Text_OnlyThreePkmnMayBeEntered
db "@"
; 0x8b24c
JumpText_ThePkmnMustAllBeDifferentKinds: ; 0x8b24c
; The @ #MON must all be different kinds.
text_jump Text_ThePkmnMustAllBeDifferentKinds
db "@"
; 0x8b251
JumpText_ThePkmnMustNotHoldTheSameItems: ; 0x8b251
; The @ #MON must not hold the same items.
text_jump Text_ThePkmnMustNotHoldTheSameItems
db "@"
; 0x8b256
JumpText_YouCantTakeAnEgg: ; 0x8b256
; You can't take an EGG!
text_jump Text_YouCantTakeAnEgg
db "@"
; 0x8b25b
2015-12-17 19:31:16 -08:00
BattleTower_ExecuteJumptable: ; 8b25b
2015-11-02 11:37:02 -08:00
ld bc, 0
2015-12-17 19:31:16 -08:00
.loop
call .DoJumptableFunction
call c, .PrintFailureText
call .Next_CheckReachedEnd
jr nz, .loop
2015-10-16 10:35:43 -07:00
ld a, b
and a
ret
; 8b26c
2015-12-17 19:31:16 -08:00
.DoJumptableFunction: ; 8b26c
2015-10-16 10:35:43 -07:00
push de
push bc
2015-12-17 19:31:16 -08:00
call .GetFunctionPointer
2015-10-16 10:35:43 -07:00
ld a, c
rst JumpTable
pop bc
pop de
ret
; 8b276
2015-12-17 19:31:16 -08:00
.Next_CheckReachedEnd: ; 8b276
2015-10-16 10:35:43 -07:00
inc c
ld a, [de]
cp c
ret
; 8b27a
2015-12-17 19:31:16 -08:00
.GetFunctionPointer: ; 8b27a
2015-10-16 10:35:43 -07:00
inc de
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
ret
; 8b281
2015-12-17 19:31:16 -08:00
.GetTextPointers: ; 8b281
2015-10-16 10:35:43 -07:00
rept 3
inc de
endr
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
ret
; 8b28a
2015-12-17 19:31:16 -08:00
.LoadTextPointer: ; 8b28a
2015-10-16 10:35:43 -07:00
ld a, [hli]
ld h, [hl]
ld l, a
ret
; 8b28e
2015-12-17 19:31:16 -08:00
.PrintFailureText: ; 8b28e
2015-10-16 10:35:43 -07:00
push de
push bc
ld a, b
and a
2015-12-17 19:31:16 -08:00
call z, .PrintFirstText
2015-10-16 10:35:43 -07:00
pop bc
2015-12-17 19:31:16 -08:00
call .PrintNthText
2015-10-16 10:35:43 -07:00
ld b, $1
pop de
ret
; 8b29d
2015-12-17 19:31:16 -08:00
.PrintFirstText: ; 8b29d
2015-10-16 10:35:43 -07:00
push de
2015-12-17 19:31:16 -08:00
call .GetTextPointers
call .LoadTextPointer
2015-10-16 10:35:43 -07:00
call PrintText
pop de
ret
; 8b2a9
2015-12-17 19:31:16 -08:00
.PrintNthText: ; 8b2a9
2015-10-16 10:35:43 -07:00
push bc
2015-12-17 19:31:16 -08:00
call .GetTextPointers
2015-10-16 10:35:43 -07:00
inc hl
inc hl
2015-10-16 10:35:43 -07:00
ld b, $0
add hl, bc
add hl, bc
2015-12-17 19:31:16 -08:00
call .LoadTextPointer
2015-10-16 10:35:43 -07:00
call PrintText
pop bc
ret
; 8b2bb
2015-12-17 19:31:16 -08:00
BattleTower_CheckPartyLengthIs3: ; 8b2bb
2015-10-16 10:35:43 -07:00
ld a, [PartyCount]
cp 3
ret
; 8b2c1
2015-12-17 19:31:16 -08:00
BattleTower_CheckPartyHasThreeMonsThatAreNotEggs: ; 8b2c1
2015-10-16 10:35:43 -07:00
ld hl, PartyCount
ld a, [hli]
ld b, $0
ld c, a
2015-12-17 19:31:16 -08:00
.loop
2015-10-16 10:35:43 -07:00
ld a, [hli]
cp EGG
2015-12-17 19:31:16 -08:00
jr z, .egg
2015-10-16 10:35:43 -07:00
inc b
2015-12-17 19:31:16 -08:00
.egg
2015-10-16 10:35:43 -07:00
dec c
2015-12-17 19:31:16 -08:00
jr nz, .loop
2015-10-16 10:35:43 -07:00
ld a, [PartyCount]
cp b
ret z
ld a, b
cp 3
ret
; 8b2da
Function_PartyCountEq3: ; 8b2da
ld a, [PartyCount]
cp 3
ret z
scf
ret
; 8b2e2
Function_PartySpeciesAreUnique: ; 8b2e2
ld hl, PartyMon1Species
call VerifyUniqueness
ret
; 8b2e9
VerifyUniqueness: ; 8b2e9
ld de, PartyCount
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
; 8b31a
.nextmon ; 8b31a
2015-10-16 10:35:43 -07:00
push bc
ld bc, PARTYMON_STRUCT_LENGTH
2015-10-16 10:35:43 -07:00
add hl, bc
inc de
pop bc
ret
; 8b322
.isegg ; 8b322
2015-10-16 10:35:43 -07:00
push bc
ld b, a
ld a, [de]
cp EGG
ld a, b
pop bc
ret
; 8b32a
Function_PartyItemsAreUnique: ; 8b32a
ld hl, PartyMon1Item
call VerifyUniqueness
ret
; 8b331
Function_HasPartyAnEgg: ; 8b331
ld hl, PartyCount
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
; 8b342