Battle Tent Port

This is...most of the stuff necessary for the Battle Tent to work. I've faithfully restored most things so far, including doing a few grammar tweaks.

Main issue is that we get a really strange softlock when the Pokemon selection menu comes up. Not sure why, but point is, it can't progress to the next bit for debugging like this. Committing now to ask for assistance.
This commit is contained in:
Llinos Evans 2023-05-13 02:50:31 +01:00
parent cdb00af812
commit ec61a039b8
23 changed files with 1340 additions and 18 deletions

View file

@ -836,6 +836,9 @@ FaintEnemyPokemon:
call SaveScreenTilesToBuffer1
xor a
ld [wBattleResult], a
ld a, [wCurMap]
cp BATTLE_TENT
ret z ; one of Battle Tower's rules
ld b, EXP_ALL
call IsItemInBag
push af
@ -961,6 +964,9 @@ TrainerBattleVictory:
ld c, 40
call DelayFrames
call PrintEndBattleText
ld a, [wCurMap]
cp BATTLE_TENT
ret z ; We will give it later ;)
; win money
ld hl, MoneyForWinningText
call PrintText
@ -2189,13 +2195,16 @@ DisplayBattleMenu::
.throwSafariBallWasSelected
ld a, SAFARI_BALL
ld [wcf91], a
jr UseBagItem
jp UseBagItem
.upperLeftMenuItemWasNotSelected ; a menu item other than the upper left item was selected
cp $2
jp nz, PartyMenuOrRockOrRun
; either the bag (normal battle) or bait (safari battle) was selected
ld a, [wCurMap]
cp BATTLE_TENT
jr z, .battletent
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr nz, .notLinkBattle
@ -2205,6 +2214,11 @@ DisplayBattleMenu::
call PrintText
jp DisplayBattleMenu
.battletent
ld hl, ItemsCantBeUsedHereText
call PrintText
jp DisplayBattleMenu
.notLinkBattle
call SaveScreenTilesToBuffer2
ld a, [wBattleType]
@ -6286,6 +6300,8 @@ LoadEnemyMonData:
ld de, wEnemyMonNick
ld bc, NAME_LENGTH
call CopyData
cp BATTLE_TENT
jr z, .skipSeenFlagAdding ; one of Battle Tower's rules
ld a, [wEnemyMonSpecies2]
ld [wd11e], a
predef IndexToPokedex
@ -6305,6 +6321,14 @@ LoadEnemyMonData:
ld a, $7 ; default stat mod
ld b, NUM_STAT_MODS ; number of stat mods
ld hl, wEnemyMonStatMods
.skipSeenFlagAdding
ld hl, wEnemyMonLevel
ld de, wEnemyMonUnmodifiedLevel
ld bc, $b
call CopyData
ld a, $7 ; default stat mod
ld b, $8 ; number of stat mods
ld hl, wEnemyMonStatMods
.statModLoop
ld [hli], a
dec b

View file

@ -14,7 +14,15 @@ ReadTrainer:
dec a
ld [hl], a
; check if we are in battle tent since we need a random pokemon data
ld a,[wCurMap]
cp BATTLE_TENT
jr nz, .notBT
farcall ReadBattleTentTrainer
jp .FinishUp
; get the pointer to trainer data for this class
.notBT
ld a, [wTrainerClass] ; get trainer class
dec a
add a

View file

@ -286,14 +286,15 @@ INCLUDE "engine/battle/read_trainer_party.asm"
INCLUDE "data/trainers/special_moves.asm"
INCLUDE "data/trainers/parties.asm"
;INCLUDE "data/trainers/scaled_parties.asm"
;INCLUDE "data/trainers/rival_parties.asm"
TrainerAI:
and a
ld a, [wIsInBattle]
dec a
ret z ; if not a trainer, we're done here
ld a, [wCurMap]
cp BATTLE_TENT
ret z ; if we are in battle tent, we are done
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z ; if in a link battle, we're done as well

369
engine/battletentdata.asm Normal file
View file

@ -0,0 +1,369 @@
;btlibs
BTLib1::
db "ready@@@@"
db "prepared@"
db "excited@@"
db "hyped@@@@"
BTLib2::
db "go@@@@@"
db "do it@@"
db "battle@"
db "rock@@@"
BTLib3::
db "Oh no@@@@@"
db "Argh no@@@"
db "Oh well@@@"
db "My streak@"
BTLib4::
db "game@@@"
db "battle@"
db "play@@@"
db "job@@@@"
BTBeforeBattlePtrTable::
dw BTBeforeBattleTemplate1
dw BTBeforeBattleTemplate2
dw BTBeforeBattleTemplate3
dw BTBeforeBattleTemplate4
dw BTBeforeBattleTemplate5
dw BTBeforeBattleTemplate6
dw BTBeforeBattleTemplate7
dw BTBeforeBattleTemplate8
BTAfterBattlePtrTable::
dw BTAfterBattleTemplate1
dw BTAfterBattleTemplate2
dw BTAfterBattleTemplate3
dw BTAfterBattleTemplate4
dw BTAfterBattleTemplate5
dw BTAfterBattleTemplate6
dw BTAfterBattleTemplate7
dw BTAfterBattleTemplate8
BTBeforeBattleTemplate1:
text "I'm @"
text_ram wStringBuffer1
text "!"
done
BTBeforeBattleTemplate2:
text "Get @"
text_ram wStringBuffer1
text "!"
done
BTBeforeBattleTemplate3:
text "Let's @"
text_ram wStringBuffer2
text "!"
done
BTBeforeBattleTemplate4:
text "I'm @"
text_ram wStringBuffer1
db 0
line "for this!"
para "Let's @"
text_ram wStringBuffer2
text "!"
done
BTBeforeBattleTemplate5:
text "Here I come!"
line "Let's @"
text_ram wStringBuffer2
text "!"
done
BTBeforeBattleTemplate6:
text "Let's @"
text_ram wStringBuffer2
db 0
line "together!"
done
BTBeforeBattleTemplate7:
text "I'm waiting for"
line "a while now."
para "Let's @"
text_ram wStringBuffer2
text "!"
done
BTBeforeBattleTemplate8:
text "Well, I'm"
line "@"
text_ram wStringBuffer1
text " now."
para "Let's @"
text_ram wStringBuffer2
text "."
done
BTAfterBattleTemplate1:
text "@"
text_ram wStringBuffer1
text "!"
para "Oh man.."
prompt
BTAfterBattleTemplate2:
text "@"
text_ram wStringBuffer1
text "!"
prompt
BTAfterBattleTemplate3:
text "@"
text_ram wStringBuffer1
text "!"
line "Good @"
text_ram wStringBuffer2
text "!"
prompt
BTAfterBattleTemplate4:
text "That was a nice"
line "@"
text_ram wStringBuffer2
text "!"
prompt
BTAfterBattleTemplate5:
text "I did the best"
line "I could."
para "I have no"
line "regrets!"
prompt
BTAfterBattleTemplate6:
text "@"
text_ram wStringBuffer1
text "!"
line "Nice @"
text_ram wStringBuffer2
text "!"
prompt
BTAfterBattleTemplate7:
text "That was a nice"
line "@"
text_ram wStringBuffer2
text ","
cont "don't you think?"
prompt
BTAfterBattleTemplate8:
text "Awesome"
line "@"
text_ram wStringBuffer2
text "!"
para "Shall we do this"
line "again?"
prompt
;data
BTTrainerClassList::
; structure:
; common - has 2 entries each in order to make the entire list exactly 32
db YOUNGSTER, SPRITE_YOUNGSTER, 0
db YOUNGSTER, SPRITE_YOUNGSTER, 0
db JR_TRAINER_M, SPRITE_COOLTRAINER_M, 0
db JR_TRAINER_M, SPRITE_COOLTRAINER_M, 0
db JR_TRAINER_F, SPRITE_COOLTRAINER_F, 0
db JR_TRAINER_F, SPRITE_COOLTRAINER_F, 0
db COOLTRAINER_M, SPRITE_COOLTRAINER_M, 9
db COOLTRAINER_M, SPRITE_COOLTRAINER_M, 9
db COOLTRAINER_F, SPRITE_COOLTRAINER_F, 9
db COOLTRAINER_F, SPRITE_COOLTRAINER_F, 9
; uncommon
db BUG_CATCHER, SPRITE_YOUNGSTER, 1
db LASS, SPRITE_COOLTRAINER_F, 7
db HIKER, SPRITE_HIKER, 2
db SAILOR, SPRITE_SAILOR, 3
db POKEMANIAC, SPRITE_SUPER_NERD, 0
db SUPER_NERD, SPRITE_SUPER_NERD, 0
db BURGLAR, SPRITE_SUPER_NERD, 0
db ENGINEER, SPRITE_SUPER_NERD, 4
db FISHER, SPRITE_FISHER, 3
db CUE_BALL, SPRITE_HIKER, 0
db GAMBLER, SPRITE_GAMBLER, 0
db BEAUTY, SPRITE_BEAUTY, 7
db PSYCHIC_TR, SPRITE_YOUNGSTER, 5
db ROCKER, SPRITE_ROCKER, 4
db JUGGLER, SPRITE_ROCKER, 5
db TAMER, SPRITE_ROCKER, 0
db BIRD_KEEPER, SPRITE_COOLTRAINER_M, 6
db BLACKBELT, SPRITE_HIKER, 2
db SCIENTIST, SPRITE_SCIENTIST, 8
db FIREFIGHTER, SPRITE_COOLTRAINER_M, 0
db JACK, SPRITE_BALDING_GUY, 0
db CHANNELER, SPRITE_CHANNELER, 8
BTMonList::
; List of 'mons, grouped in 8 roughly by types
; Normal+Bug set
db TAUROS
db PERSIAN
db TRAMPEL
db SNORLAX
db BUTTERFREE
db PURAKKUSU
db SCIZOR
db PARASECT
; Rock+Fighting set
db GYAOON
db KABUTOPS
db RHYPERIOR
db ARCANINE_H
db HITMONTOP
db TAUROS_P
db POLIWRATH
db HITMONLEE
; Water set
db JABETTA
db CLOYSTER
db LAPRAS
db GYARADOS
db BLASTOISE
db JAGG
db POLITOED
db PENDRAKEN
; Electric+Fire set
db JOLTEON
db ZAPDOS
db GOROCHU
db SANDY_SHOCKS
db CHARIZARD
db NINETALES
db MAGMORTAR
db MOLTRES
; Psychic+Ice set
db ALAKAZAM
db SLOWBRO
db STARMIE
db EXEGGUTOR
db ARTICUNO
db JYNX
db NINETALES_A
db MR_RIME
; Flying+Fire set
db MADAAMU
db AERODACTYL
db DRAGONITE
db DODRIO
db MAROWAK_A
db FLAREON
db RAPIDASH
db TAUROS_PB
; Normal+Grass set
db DEER
db CHANSEY
db KANGASKHAN
db RATICATE_A
db TANGROWTH
db CACTUS
db TSUBOMITTO
db VICTREEBEL
; Ghost+Ground+Poison set
db STEELIX
db GUARDIA
db GOLEM
db GENGAR
db ANNIHILAPE
db CROBAT
db NIDOKING
db TENTACRUEL
; Normal+Dragon set
db PORYGON2
db PORYGONZ
db CLEFABLE
db RATICATE
db CROCKY
db EXEGGUTOR_A
db CRYITHAN
db KINGDRA
;engine
ReadBattleTentTrainer::
ld a, 50
ld [wCurEnemyLVL],a
ld a, [wBTClass]
ld hl, BTTrainerClassList + 2 ; Team selector
ld bc, 3
call AddNTimes
ld a, [hl]
and a
jr z, .anyTeam
dec a
ld hl, BTMonList
ld bc, 8
call AddNTimes ; now hl points to the specific team
ld b, 3
.SpecificTeam
push hl
push bc
call Random
and 7
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
ld [wcf91],a
ld a,1
ld [wMonDataLocation],a
call AddPartyMon
pop bc
pop hl
dec b
jr nz, .SpecificTeam
ret
.anyTeam
ld hl, BTMonList
ld b, 3
.anyTeamLoop
push hl
push bc
call Random
and 63
ld c, a ; max = 63
ld a, [hRandomSub]
bit 7, a
jr z, .skipinc
inc c ; max = 64
.skipinc
and 7
add c
ld c, a ; max = 71
ld b, 0
add hl, bc
ld a, [hl]
ld [wcf91],a
ld a,1
ld [wMonDataLocation],a
call AddPartyMon
pop bc
pop hl
dec b
jr nz, .anyTeamLoop
ret

View file

@ -22,12 +22,12 @@ SetIshiharaTeam:
IshiharaTeam:
db EXEGGUTOR_A, 90
db ONIX, 90
db PINSIR, 90
db PURAKKUSU, 90
db TRAMPEL, 90
IF DEF(_DEBUG)
db DITTO, 50
db SCYTHER, 50
db SCYTHER, 50
db TAUROS_PB, 50
db SNORLAX, 50
db TANGROWTH, 50
ENDC
db -1 ; end

View file

@ -62,7 +62,9 @@ RedrawPartyMenu_::
cp TMHM_PARTY_MENU
jr z, .teachMoveMenu
cp EVO_STONE_PARTY_MENU
jr z, .evolutionStoneMenu
jp z, .evolutionStoneMenu ; battle tent stuff
cp a, $06
jr z, .battleTentMenu
push hl
ld bc, 14 ; 14 columns to the right
add hl, bc
@ -97,6 +99,11 @@ RedrawPartyMenu_::
add hl, bc
call PlaceString
pop hl
.placeMoveLearnabilityString2
push hl
add hl,bc
call PlaceString
pop hl
.printLevel
ld bc, 10 ; move 10 columns to the right
add hl, bc
@ -113,6 +120,37 @@ RedrawPartyMenu_::
db "ABLE@"
.notAbleToLearnMoveText
db "NOT ABLE@"
.battleTentMenu
ld a, [wWhichPokemon]
inc a
ld b, a
ld a, [wBTOrder]
and $7
cp b
ld de,.BTFirstText
jr z,.placeMoveLearnabilityString
ld a, [wBTOrder]
swap a
and $7
cp b
ld de,.BTSecondText
jr z,.placeMoveLearnabilityString
ld a, [wBTOrder+1]
cp b
ld de,.BTThirdText
jr z,.placeMoveLearnabilityString
ld de,.BTNotEnteredText
ld bc,20 + 6
jr .placeMoveLearnabilityString2
.BTNotEnteredText
db "NOT ENTERED@"
.BTFirstText
db "FIRST@"
.BTSecondText
db "SECOND@"
.BTThirdText
db "THIRD@"
;bt end
.evolutionStoneMenu
push hl
ld hl, EvosMovesPointerTable
@ -165,7 +203,7 @@ RedrawPartyMenu_::
add hl, bc
call PlaceString
pop hl
jr .printLevel
jp .printLevel
.ableToEvolveText
db "ABLE@"
.notAbleToEvolveText
@ -235,6 +273,7 @@ PartyMenuMessagePointers:
dw PartyMenuUseTMText
dw PartyMenuSwapMonText
dw PartyMenuItemUseText
dw PartyMenuBattleTentText
PartyMenuNormalText:
text_far _PartyMenuNormalText
@ -256,6 +295,10 @@ PartyMenuSwapMonText:
text_far _PartyMenuSwapMonText
text_end
PartyMenuBattleTentText: ; 12e93 (4:6e93)
text_far _PartyMenuBattleTentText
db "@"
PotionText:
text_far _PotionText
text_end