diff options
author | xCrystal <rgr.crystal@gmail.com> | 2015-04-01 17:27:51 +0200 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2015-04-01 17:27:51 +0200 |
commit | ce9940a2eb89caa9f53507a6d6071f8eaf85ee48 (patch) | |
tree | b30d2f676d5ad0d78b959c8ffcf0f8dcfca13943 | |
parent | 10211cc461b35140c815e18e95f7070eb0dcc586 (diff) |
Further split bank e stuff
-rw-r--r-- | engine/battle/bank_e_misc.asm | 122 | ||||
-rw-r--r-- | engine/battle/read_trainer_party.asm | 164 | ||||
-rw-r--r-- | engine/battle/trainer_ai.asm (renamed from engine/battle/trainer_party_ai_misc.asm) | 436 | ||||
-rw-r--r-- | engine/battle/trainer_pic_money_pointers.asm | 143 | ||||
-rwxr-xr-x | main.asm | 2 |
5 files changed, 435 insertions, 432 deletions
diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm new file mode 100644 index 00000000..78b27108 --- /dev/null +++ b/engine/battle/bank_e_misc.asm @@ -0,0 +1,122 @@ +; formats a string at wMovesString that lists the moves at wMoves +FormatMovesString: ; 39b87 (e:5b87) + ld hl, wMoves + ld de, wMovesString + ld b, $0 +.printMoveNameLoop + ld a, [hli] + and a ; end of move list? + jr z, .printDashLoop ; print dashes when no moves are left + push hl + ld [wd0b5], a + ld a, BANK(MoveNames) + ld [wPredefBank], a + ld a, MOVE_NAME + ld [wNameListType], a + call GetName + ld hl, wcd6d +.copyNameLoop + ld a, [hli] + cp $50 + jr z, .doneCopyingName + ld [de], a + inc de + jr .copyNameLoop +.doneCopyingName + ld a, b + ld [wcd6c], a + inc b + ld a, $4e ; line break + ld [de], a + inc de + pop hl + ld a, b + cp NUM_MOVES + jr z, .done + jr .printMoveNameLoop +.printDashLoop + ld a, "-" + ld [de], a + inc de + inc b + ld a, b + cp NUM_MOVES + jr z, .done + ld a, $4e ; line break + ld [de], a + inc de + jr .printDashLoop +.done + ld a, "@" + ld [de], a + ret + +; XXX this is called in a few places, but it doesn't appear to do anything useful +Func_39bd5: ; 39bd5 (e:5bd5) + ld a, [wd11b] + cp $1 + jr nz, .asm_39be6 + ld hl, wEnemyPartyCount + ld de, wEnemyMonOT + ld a, ENEMYOT_NAME + jr .asm_39c18 +.asm_39be6 + cp $4 + jr nz, .calcAttackStat4 + ld hl, wPartyCount + ld de, wPartyMonOT + ld a, PLAYEROT_NAME + jr .asm_39c18 +.calcAttackStat4 + cp $5 + jr nz, .asm_39c02 + ld hl, wStringBuffer2 + 11 + ld de, MonsterNames + ld a, MONSTER_NAME + jr .asm_39c18 +.asm_39c02 + cp $2 + jr nz, .asm_39c10 + ld hl, wNumBagItems + ld de, ItemNames + ld a, ITEM_NAME + jr .asm_39c18 +.asm_39c10 + ld hl, wStringBuffer2 + 11 + ld de, ItemNames + ld a, ITEM_NAME +.asm_39c18 + ld [wNameListType], a + ld a, l + ld [wList], a + ld a, h + ld [wList + 1], a + ld a, e + ld [wcf8d], a + ld a, d + ld [wcf8e], a + ld bc, ItemPrices + ld a, c + ld [wItemPrices], a + ld a, b + ld [wItemPrices + 1], a + ret + +; get species of mon e in list [wcc49] for LoadMonData +GetMonSpecies: ; 39c37 (e:5c37) + ld hl, wPartySpecies + ld a, [wcc49] + and a + jr z, .getSpecies + dec a + jr z, .enemyParty + ld hl, wBoxSpecies + jr .getSpecies +.enemyParty + ld hl, wEnemyPartyMons +.getSpecies + ld d, 0 + add hl, de + ld a, [hl] + ld [wcf91], a + ret
\ No newline at end of file diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm new file mode 100644 index 00000000..f1e3aaf1 --- /dev/null +++ b/engine/battle/read_trainer_party.asm @@ -0,0 +1,164 @@ +ReadTrainer: ; 39c53 (e:5c53) + +; don't change any moves in a link battle + ld a,[wLinkState] + and a + ret nz + +; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF +; XXX first is total enemy pokemon? +; XXX second is species of first pokemon? + ld hl,wEnemyPartyCount + xor a + ld [hli],a + dec a + ld [hl],a + +; get the pointer to trainer data for this class + ld a,[W_CUROPPONENT] + sub $C9 ; convert value from pokemon to trainer + add a,a + ld hl,TrainerDataPointers + ld c,a + ld b,0 + add hl,bc ; hl points to trainer class + ld a,[hli] + ld h,[hl] + ld l,a + ld a,[W_TRAINERNO] + ld b,a +; At this point b contains the trainer number, +; and hl points to the trainer class. +; Our next task is to iterate through the trainers, +; decrementing b each time, until we get to the right one. +.outer + dec b + jr z,.IterateTrainer +.inner + ld a,[hli] + and a + jr nz,.inner + jr .outer + +; if the first byte of trainer data is FF, +; - each pokemon has a specific level +; (as opposed to the whole team being of the same level) +; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move +; else the first byte is the level of every pokemon on the team +.IterateTrainer + ld a,[hli] + cp $FF ; is the trainer special? + jr z,.SpecialTrainer ; if so, check for special moves + ld [W_CURENEMYLVL],a +.LoopTrainerData + ld a,[hli] + and a ; have we reached the end of the trainer data? + jr z,.FinishUp + ld [wcf91],a ; write species somewhere (XXX why?) + ld a,1 + ld [wcc49],a + push hl + call AddPartyMon + pop hl + jr .LoopTrainerData +.SpecialTrainer +; if this code is being run: +; - each pokemon has a specific level +; (as opposed to the whole team being of the same level) +; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move + ld a,[hli] + and a ; have we reached the end of the trainer data? + jr z,.AddLoneMove + ld [W_CURENEMYLVL],a + ld a,[hli] + ld [wcf91],a + ld a,1 + ld [wcc49],a + push hl + call AddPartyMon + pop hl + jr .SpecialTrainer +.AddLoneMove +; does the trainer have a single monster with a different move + ld a,[W_LONEATTACKNO] ; Brock is 01, Misty is 02, Erika is 04, etc + and a + jr z,.AddTeamMove + dec a + add a,a + ld c,a + ld b,0 + ld hl,LoneMoves + add hl,bc + ld a,[hli] + ld d,[hl] + ld hl,wEnemyMon1Moves + 2 + ld bc,wEnemyMon2 - wEnemyMon1 + call AddNTimes + ld [hl],d + jr .FinishUp +.AddTeamMove +; check if our trainer's team has special moves + +; get trainer class number + ld a,[W_CUROPPONENT] + sub $C8 + ld b,a + ld hl,TeamMoves + +; iterate through entries in TeamMoves, checking each for our trainer class +.IterateTeamMoves + ld a,[hli] + cp b + jr z,.GiveTeamMoves ; is there a match? + inc hl ; if not, go to the next entry + inc a + jr nz,.IterateTeamMoves + +; no matches found. is this trainer champion rival? + ld a,b + cp SONY3 + jr z,.ChampionRival + jr .FinishUp ; nope +.GiveTeamMoves + ld a,[hl] + ld [wEnemyMon5Moves + 2],a + jr .FinishUp +.ChampionRival ; give moves to his team + +; pidgeot + ld a,SKY_ATTACK + ld [wEnemyMon1Moves + 2],a + +; starter + ld a,[W_RIVALSTARTER] + cp STARTER3 + ld b,MEGA_DRAIN + jr z,.GiveStarterMove + cp STARTER1 + ld b,FIRE_BLAST + jr z,.GiveStarterMove + ld b,BLIZZARD ; must be squirtle +.GiveStarterMove + ld a,b + ld [wEnemyMon6Moves + 2],a +.FinishUp ; XXX this needs documenting + xor a ; clear D079-D07B + ld de,wd079 + ld [de],a + inc de + ld [de],a + inc de + ld [de],a + ld a,[W_CURENEMYLVL] + ld b,a +.LastLoop + ld hl,wd047 + ld c,2 + push bc + predef AddBCDPredef + pop bc + inc de + inc de + dec b + jr nz,.LastLoop + ret
\ No newline at end of file diff --git a/engine/battle/trainer_party_ai_misc.asm b/engine/battle/trainer_ai.asm index 8cbb9329..191cfd5e 100644 --- a/engine/battle/trainer_party_ai_misc.asm +++ b/engine/battle/trainer_ai.asm @@ -324,439 +324,13 @@ TrainerClassMoveChoiceModifications: ; 3989b (e:589b) db 1,0 ; AGATHA db 1,3,0 ; LANCE -TrainerPicAndMoneyPointers: ; 39914 (e:5914) -; trainer pic pointers and base money. -; money received after battle = base money × level of highest-level enemy mon - dw YoungsterPic - money 1500 +INCLUDE "engine/battle/trainer_pic_money_pointers.asm" + +INCLUDE "text/trainer_names.asm" - dw BugCatcherPic - money 1000 +INCLUDE "engine/battle/bank_e_misc.asm" - dw LassPic - money 1500 - - dw SailorPic - money 3000 - - dw JrTrainerMPic - money 2000 - - dw JrTrainerFPic - money 2000 - - dw PokemaniacPic - money 5000 - - dw SuperNerdPic - money 2500 - - dw HikerPic - money 3500 - - dw BikerPic - money 2000 - - dw BurglarPic - money 9000 - - dw EngineerPic - money 5000 - - dw JugglerPic - money 3500 - - dw FisherPic - money 3500 - - dw SwimmerPic - money 500 - - dw CueBallPic - money 2500 - - dw GamblerPic - money 7000 - - dw BeautyPic - money 7000 - - dw PsychicPic - money 1000 - - dw RockerPic - money 2500 - - dw JugglerPic - money 3500 - - dw TamerPic - money 4000 - - dw BirdKeeperPic - money 2500 - - dw BlackbeltPic - money 2500 - - dw Rival1Pic - money 3500 - - dw ProfOakPic - money 9900 - - dw ChiefPic - money 3000 - - dw ScientistPic - money 5000 - - dw GiovanniPic - money 9900 - - dw RocketPic - money 3000 - - dw CooltrainerMPic - money 3500 - - dw CooltrainerFPic - money 3500 - - dw BrunoPic - money 9900 - - dw BrockPic - money 9900 - - dw MistyPic - money 9900 - - dw LtSurgePic - money 9900 - - dw ErikaPic - money 9900 - - dw KogaPic - money 9900 - - dw BlainePic - money 9900 - - dw SabrinaPic - money 9900 - - dw GentlemanPic - money 7000 - - dw Rival2Pic - money 6500 - - dw Rival3Pic - money 9900 - - dw LoreleiPic - money 9900 - - dw ChannelerPic - money 3000 - - dw AgathaPic - money 9900 - - dw LancePic - money 9900 - -INCLUDE "text/trainer_names.asm" - -; formats a string at wMovesString that lists the moves at wMoves -FormatMovesString: ; 39b87 (e:5b87) - ld hl, wMoves - ld de, wMovesString - ld b, $0 -.printMoveNameLoop - ld a, [hli] - and a ; end of move list? - jr z, .printDashLoop ; print dashes when no moves are left - push hl - ld [wd0b5], a - ld a, BANK(MoveNames) - ld [wPredefBank], a - ld a, MOVE_NAME - ld [wNameListType], a - call GetName - ld hl, wcd6d -.copyNameLoop - ld a, [hli] - cp $50 - jr z, .doneCopyingName - ld [de], a - inc de - jr .copyNameLoop -.doneCopyingName - ld a, b - ld [wcd6c], a - inc b - ld a, $4e ; line break - ld [de], a - inc de - pop hl - ld a, b - cp NUM_MOVES - jr z, .done - jr .printMoveNameLoop -.printDashLoop - ld a, "-" - ld [de], a - inc de - inc b - ld a, b - cp NUM_MOVES - jr z, .done - ld a, $4e ; line break - ld [de], a - inc de - jr .printDashLoop -.done - ld a, "@" - ld [de], a - ret - -; XXX this is called in a few places, but it doesn't appear to do anything useful -Func_39bd5: ; 39bd5 (e:5bd5) - ld a, [wd11b] - cp $1 - jr nz, .asm_39be6 - ld hl, wEnemyPartyCount - ld de, wEnemyMonOT - ld a, ENEMYOT_NAME - jr .asm_39c18 -.asm_39be6 - cp $4 - jr nz, .calcAttackStat4 - ld hl, wPartyCount - ld de, wPartyMonOT - ld a, PLAYEROT_NAME - jr .asm_39c18 -.calcAttackStat4 - cp $5 - jr nz, .asm_39c02 - ld hl, wStringBuffer2 + 11 - ld de, MonsterNames - ld a, MONSTER_NAME - jr .asm_39c18 -.asm_39c02 - cp $2 - jr nz, .asm_39c10 - ld hl, wNumBagItems - ld de, ItemNames - ld a, ITEM_NAME - jr .asm_39c18 -.asm_39c10 - ld hl, wStringBuffer2 + 11 - ld de, ItemNames - ld a, ITEM_NAME -.asm_39c18 - ld [wNameListType], a - ld a, l - ld [wList], a - ld a, h - ld [wList + 1], a - ld a, e - ld [wcf8d], a - ld a, d - ld [wcf8e], a - ld bc, ItemPrices - ld a, c - ld [wItemPrices], a - ld a, b - ld [wItemPrices + 1], a - ret - -; get species of mon e in list [wcc49] for LoadMonData -GetMonSpecies: ; 39c37 (e:5c37) - ld hl, wPartySpecies - ld a, [wcc49] - and a - jr z, .getSpecies - dec a - jr z, .enemyParty - ld hl, wBoxSpecies - jr .getSpecies -.enemyParty - ld hl, wEnemyPartyMons -.getSpecies - ld d, 0 - add hl, de - ld a, [hl] - ld [wcf91], a - ret - -ReadTrainer: ; 39c53 (e:5c53) - -; don't change any moves in a link battle - ld a,[wLinkState] - and a - ret nz - -; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF -; XXX first is total enemy pokemon? -; XXX second is species of first pokemon? - ld hl,wEnemyPartyCount - xor a - ld [hli],a - dec a - ld [hl],a - -; get the pointer to trainer data for this class - ld a,[W_CUROPPONENT] - sub $C9 ; convert value from pokemon to trainer - add a,a - ld hl,TrainerDataPointers - ld c,a - ld b,0 - add hl,bc ; hl points to trainer class - ld a,[hli] - ld h,[hl] - ld l,a - ld a,[W_TRAINERNO] - ld b,a -; At this point b contains the trainer number, -; and hl points to the trainer class. -; Our next task is to iterate through the trainers, -; decrementing b each time, until we get to the right one. -.outer - dec b - jr z,.IterateTrainer -.inner - ld a,[hli] - and a - jr nz,.inner - jr .outer - -; if the first byte of trainer data is FF, -; - each pokemon has a specific level -; (as opposed to the whole team being of the same level) -; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move -; else the first byte is the level of every pokemon on the team -.IterateTrainer - ld a,[hli] - cp $FF ; is the trainer special? - jr z,.SpecialTrainer ; if so, check for special moves - ld [W_CURENEMYLVL],a -.LoopTrainerData - ld a,[hli] - and a ; have we reached the end of the trainer data? - jr z,.FinishUp - ld [wcf91],a ; write species somewhere (XXX why?) - ld a,1 - ld [wcc49],a - push hl - call AddPartyMon - pop hl - jr .LoopTrainerData -.SpecialTrainer -; if this code is being run: -; - each pokemon has a specific level -; (as opposed to the whole team being of the same level) -; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move - ld a,[hli] - and a ; have we reached the end of the trainer data? - jr z,.AddLoneMove - ld [W_CURENEMYLVL],a - ld a,[hli] - ld [wcf91],a - ld a,1 - ld [wcc49],a - push hl - call AddPartyMon - pop hl - jr .SpecialTrainer -.AddLoneMove -; does the trainer have a single monster with a different move - ld a,[W_LONEATTACKNO] ; Brock is 01, Misty is 02, Erika is 04, etc - and a - jr z,.AddTeamMove - dec a - add a,a - ld c,a - ld b,0 - ld hl,LoneMoves - add hl,bc - ld a,[hli] - ld d,[hl] - ld hl,wEnemyMon1Moves + 2 - ld bc,wEnemyMon2 - wEnemyMon1 - call AddNTimes - ld [hl],d - jr .FinishUp -.AddTeamMove -; check if our trainer's team has special moves - -; get trainer class number - ld a,[W_CUROPPONENT] - sub $C8 - ld b,a - ld hl,TeamMoves - -; iterate through entries in TeamMoves, checking each for our trainer class -.IterateTeamMoves - ld a,[hli] - cp b - jr z,.GiveTeamMoves ; is there a match? - inc hl ; if not, go to the next entry - inc a - jr nz,.IterateTeamMoves - - ; no matches found. is this trainer champion rival? - ld a,b - cp SONY3 - jr z,.ChampionRival - jr .FinishUp ; nope -.GiveTeamMoves - ld a,[hl] - ld [wEnemyMon5Moves + 2],a - jr .FinishUp -.ChampionRival ; give moves to his team - -; pidgeot - ld a,SKY_ATTACK - ld [wEnemyMon1Moves + 2],a - -; starter - ld a,[W_RIVALSTARTER] - cp STARTER3 - ld b,MEGA_DRAIN - jr z,.GiveStarterMove - cp STARTER1 - ld b,FIRE_BLAST - jr z,.GiveStarterMove - ld b,BLIZZARD ; must be squirtle -.GiveStarterMove - ld a,b - ld [wEnemyMon6Moves + 2],a -.FinishUp ; XXX this needs documenting - xor a ; clear D079-D07B - ld de,wd079 - ld [de],a - inc de - ld [de],a - inc de - ld [de],a - ld a,[W_CURENEMYLVL] - ld b,a -.LastLoop - ld hl,wd047 - ld c,2 - push bc - predef AddBCDPredef - pop bc - inc de - inc de - dec b - jr nz,.LastLoop - ret +INCLUDE "engine/battle/read_trainer_party.asm" INCLUDE "data/trainer_moves.asm" diff --git a/engine/battle/trainer_pic_money_pointers.asm b/engine/battle/trainer_pic_money_pointers.asm new file mode 100644 index 00000000..3d32eb00 --- /dev/null +++ b/engine/battle/trainer_pic_money_pointers.asm @@ -0,0 +1,143 @@ +TrainerPicAndMoneyPointers: ; 39914 (e:5914) +; trainer pic pointers and base money. +; money received after battle = base money × level of highest-level enemy mon + dw YoungsterPic + money 1500 + + dw BugCatcherPic + money 1000 + + dw LassPic + money 1500 + + dw SailorPic + money 3000 + + dw JrTrainerMPic + money 2000 + + dw JrTrainerFPic + money 2000 + + dw PokemaniacPic + money 5000 + + dw SuperNerdPic + money 2500 + + dw HikerPic + money 3500 + + dw BikerPic + money 2000 + + dw BurglarPic + money 9000 + + dw EngineerPic + money 5000 + + dw JugglerPic + money 3500 + + dw FisherPic + money 3500 + + dw SwimmerPic + money 500 + + dw CueBallPic + money 2500 + + dw GamblerPic + money 7000 + + dw BeautyPic + money 7000 + + dw PsychicPic + money 1000 + + dw RockerPic + money 2500 + + dw JugglerPic + money 3500 + + dw TamerPic + money 4000 + + dw BirdKeeperPic + money 2500 + + dw BlackbeltPic + money 2500 + + dw Rival1Pic + money 3500 + + dw ProfOakPic + money 9900 + + dw ChiefPic + money 3000 + + dw ScientistPic + money 5000 + + dw GiovanniPic + money 9900 + + dw RocketPic + money 3000 + + dw CooltrainerMPic + money 3500 + + dw CooltrainerFPic + money 3500 + + dw BrunoPic + money 9900 + + dw BrockPic + money 9900 + + dw MistyPic + money 9900 + + dw LtSurgePic + money 9900 + + dw ErikaPic + money 9900 + + dw KogaPic + money 9900 + + dw BlainePic + money 9900 + + dw SabrinaPic + money 9900 + + dw GentlemanPic + money 7000 + + dw Rival2Pic + money 6500 + + dw Rival3Pic + money 9900 + + dw LoreleiPic + money 9900 + + dw ChannelerPic + money 3000 + + dw AgathaPic + money 9900 + + dw LancePic + money 9900
\ No newline at end of file @@ -5465,7 +5465,7 @@ BaseStats: INCLUDE "data/base_stats.asm" INCLUDE "data/cries.asm" INCLUDE "engine/battle/unused_stats_functions.asm" INCLUDE "engine/battle/scroll_draw_trainer_pic.asm" -INCLUDE "engine/battle/trainer_party_ai_misc.asm" +INCLUDE "engine/battle/trainer_ai.asm" INCLUDE "engine/battle/draw_hud_pokeball_gfx.asm" TradingAnimationGraphics: |