From 948b270a83dce5f985cf347e88cd3ed0b110e1c1 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Thu, 12 Sep 2019 12:29:47 -0400 Subject: Script reversing --- src/constants/npc_constants.asm | 18 ++++++++++ src/data/npcs.asm | 3 +- src/engine/bank03.asm | 77 ++++++++++++++++++++++++++++++----------- src/engine/bank04.asm | 31 +++++++++-------- src/engine/bank07.asm | 31 ++++++++++++++++- src/engine/home.asm | 4 +-- src/macros/scripts.asm | 2 +- src/wram.asm | 8 ++--- 8 files changed, 128 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index f4972dc..c023a58 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -1,3 +1,20 @@ +; npc_struct constants + const_def + const NPC_TRAINER_ID + const NPC_DATA_FIELD_01 + const NPC_DATA_FIELD_02 + const NPC_DATA_FIELD_03 + const NPC_DATA_FIELD_04 + const NPC_DATA_OWSEQUENCE_PTR + const NPC_DATA_OWSEQUENCE_PTR_2 + const NPC_DATA_NAME_TEXT + const NPC_DATA_NAME_TEXT_2 + const NPC_DATA_BATTLE_PICTURE + const NPC_DATA_FIELD_0A + const NPC_DATA_FIELD_0B + const NPC_DATA_FIELD_0C +NPC_DATA_LENGTH EQU const_value + const_def 1 const PLAYER_PIC ; $01 const RONALD_PIC ; $02 @@ -41,5 +58,6 @@ const STEPHANIE_PIC ; $28 const AARON_PIC ; $29 +DRMASON EQU $01 SARA EQU $1F AMANDA EQU $20 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index caa11af..41cd562 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -124,8 +124,7 @@ Data_119dd: db $26 db $00 dw $5727 ; Pointer to NPC Data - db $ac - db $03 + tx Text03ac db $00 db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index b33fd35..e63481f 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1207,6 +1207,7 @@ Func_c926: ; c926 (3:4926) ld [wd3b6], a farcall Func_1c768 pop bc +; fallthrough Func_c935: ; c935 (3:4935) push hl @@ -1567,7 +1568,7 @@ EventFlagMods: ; cb37 (3:4b37) Func_cc32: ; cc32 (3:4c32) push hl - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld e, [hl] inc hl ld d, [hl] @@ -2200,13 +2201,14 @@ Func_cfd4: ; cfd4 (3:4fd4) dec l pop bc ld b, $0 - ld hl, $5006 + ld hl, Data_d006 add hl, bc ld c, [hl] call Func_ca8f dec hl jp IncreaseOWScriptPointerBy1 +Data_d006: ; d006 (3:5006) INCROM $d006, $d00b Func_d00b: ; d00b (3:500b) @@ -2277,9 +2279,9 @@ OWScript_MovePlayer: ; 505c (3:505c) call SetScreenScroll jp IncreaseOWScriptPointerBy3 -Func_d080: ; d080 (3:5080) +OWScript_SetDialogName: ; d080 (3:5080) ld a, c - farcall Func_11893 + farcall SetNPCDialogName jp IncreaseOWScriptPointerBy2 Func_d088: ; d088 (3:5088) @@ -2408,7 +2410,7 @@ Func_d135: ; d135 (3:5135) INCROM $d153, $d16b Func_d16b: ; d16b (3:516b) - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld e, [hl] inc hl ld d, [hl] @@ -2419,14 +2421,14 @@ Func_d16b: ; d16b (3:516b) add hl, bc push hl ld a, [wd696] - farcall Func_11893 + farcall SetNPCDialogName pop hl - ld a, [wd0c8] + ld a, [wCurrentNPCNameTx] ld [hli], a - ld a, [wd0c9] + ld a, [wCurrentNPCNameTx+1] ld [hl], a pop de - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld [hl], e inc hl ld [hl], d @@ -2916,7 +2918,25 @@ asm_d4e6 jp IncreaseOWScriptPointerBy4 ; 0xd4ec - INCROM $d4ec, $d753 + INCROM $d4ec, $d52e + +OWSequence_d52e: ; d52e (3:552e) + start_script + run_script Func_d0ce + db $3c + run_script Func_d3e0 + run_script Func_d0ce + db $78 + run_script Func_d36d + db $02 + db $01 + db $0e + db $1a + db $00 + run_script OWScript_EndScriptCloseText +; 0xd53b + + INCROM $d53b, $d753 OWSequence_d753: ; d753 (3:5753) start_script @@ -2950,22 +2970,39 @@ OWSequence_d753: ; d753 (3:5753) run_script OWScript_PrintTextString tx Text05e3 run_script OWScript_CloseTextBox - run_script Func_d088 + run_script Func_d088 ; run OWSequence with given npc (ID corresponds to a row in the wd34a table, i dont know why they correspond to what number though) db $07 - db $79 - db $57 + dw OWSequence_d779 run_script OWScript_EndScriptLoop1 ret +OWSequence_d779: ; d779 (03:5779) start_script - run_script Func_ce4a + run_script Func_ce4a ; handles some sort of npc movement, and rotation? db $80 db $58 - db $02 - - ; there's more to this script but it hasn't been disassembled yet + run_script OWScript_PrintTextString + tx Text05e4 + run_script OWScript_SetDialogName + db DRMASON + run_script OWScript_PrintTextString + tx Text05e5 + run_script Func_ce84 + run_script Func_ce4a + db $82 + db $58 + run_script Func_cfc6 + db $01 + run_script Func_d055 + db $03 + run_script OWScript_CloseTextBox + run_script Func_d088 + db $01 + db $94 + db $57 + run_script OWScript_EndScriptLoop1 - INCROM $d77e, $e13f + INCROM $d793, $e13f WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] @@ -3200,9 +3237,9 @@ Func_fc2b: ; fc2b (3:7c2b) inc hl ld b, [hl] ld a, $b0 - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, $3 - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a jp Func_c935 PointerTable_fc4c: ; fc4c (3:7c4c) diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index e2ca66c..48b6c12 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -839,7 +839,7 @@ Func_115a3: ; 115a3 (4:55a3) INCLUDE "data/map_scripts.asm" ; loads a pointer into hl found on PointerTable_118f5 -Func_1184a: ; 1184a (4:584a) +GetNPCDataPointer: ; 1184a (4:584a) ; this may have been a macro rlca add LOW(PointerTable_118f5) @@ -855,7 +855,7 @@ Func_1184a: ; 1184a (4:584a) Func_11857: ; 11857 (4:5857) push hl push bc - call Func_1184a + call GetNPCDataPointer ld a, [hli] ld [wd3ab], a ld a, [hli] @@ -880,30 +880,31 @@ Func_11857: ; 11857 (4:5857) ; this appears to find data about the NPC we're talking to Func_1187d: ; 1187d (4:587d) push hl - call Func_1184a - ld bc, $5 + call GetNPCDataPointer + ld bc, NPC_DATA_OWSEQUENCE_PTR add hl, bc ld c, [hl] inc hl ld b, [hl] inc hl ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop hl ret -Func_11893: ; 11893 (4:5893) +; Sets Dialog Box title to the name of the npc in 'a' +SetNPCDialogName: ; 11893 (4:5893) push hl push bc - call Func_1184a - ld bc, $0007 + call GetNPCDataPointer + ld bc, NPC_DATA_NAME_TEXT add hl, bc ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop bc pop hl ret @@ -911,7 +912,7 @@ Func_11893: ; 11893 (4:5893) Func_118a7: ; 118a7 (4:58a7) push hl push bc - call Func_1184a + call GetNPCDataPointer ld bc, $0007 add hl, bc ld a, [hli] @@ -927,7 +928,7 @@ Func_118a7: ; 118a7 (4:58a7) Func_118bf: ; 118bf (4:58bf) push hl push bc - call Func_1184a + call GetNPCDataPointer ld bc, $000a add hl, bc ld a, [hli] @@ -942,7 +943,7 @@ Func_118d3: ; 118d3 (4:58d3) push hl push bc push af - call Func_1184a + call GetNPCDataPointer ld bc, $000c add hl, bc ld a, [hli] @@ -999,7 +1000,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d055 dw OWScript_MovePlayer dw Func_cee2 - dw Func_d080 + dw OWScript_SetDialogName dw Func_d088 dw Func_d095 dw Func_d0be diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 7c53b96..ecc281d 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -224,7 +224,36 @@ Func_1c57b: ; 1c57b (7:457b) ret Func_1c58e: ; 1c58e (7:458e) - INCROM $1c58e, $1c5e9 + push hl + push bc + ld a, [wWhichSprite] + push af + ld a, [wd3aa] + call Func_39a7 + ld a, [hli] + or a + jr z, .asm_1c5b2 + ld a, [hl] + ld [wWhichSprite], a + ld bc, $5 + add hl, bc + ld a, [hld] + bit 4, [hl] + jr nz, .asm_1c5ae + dec hl + add [hl] + inc hl +.asm_1c5ae + farcall Func_12ab5 +.asm_1c5b2 + pop af + ld [wWhichSprite], a + pop bc + pop hl + ret +; 0x1c5b9 + + INCROM $1c5b9, $1c5e9 Func_1c5e9: ; 1c5e9 (7:45e9) INCROM $1c5e9, $1c610 diff --git a/src/engine/home.asm b/src/engine/home.asm index 15778ca..5acb742 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -11091,9 +11091,9 @@ Func_3a5e: ; 3a5e (0:3a5e) ld a, [hli] ld [wd0cb], a ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop hl pop bc pop af diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index b9ab4ec..9c81bda 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -46,7 +46,7 @@ ENDM const Func_d055_index ; $1d const OWScript_MovePlayer_index ; $1e const Func_cee2_index ; $1f - const Func_d080_index ; $20 + const OWScript_SetDialogName_index ; $20 const Func_d088_index ; $21 const Func_d095_index ; $22 const Func_d0be_index ; $23 diff --git a/src/wram.asm b/src/wram.asm index 401cc44..cee7340 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1825,11 +1825,8 @@ wd0c6:: ; d0c6 wd0c7:: ; d0c7 ds $1 -wd0c8:: ; d0c8 - ds $1 - -wd0c9:: ; d0c9 - ds $1 +wCurrentNPCNameTx:: ; d0c8 + ds $2 wd0ca:: ; d0ca ds $1 @@ -2068,6 +2065,7 @@ wd348:: ; d348 wd349:: ; d349 ds $1 +; some kind of array with 8 sets of c data wd34a:: ; d34a ds $60 -- cgit v1.2.3 From 751b28d4fee472af4d0de83ef22a1f11ec6fade6 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sun, 15 Sep 2019 21:55:11 -0400 Subject: Lots of NPC data, some temp. comments on mapdatapointers --- src/constants/npc_constants.asm | 124 ++++- src/data/npcs.asm | 1006 ++++++++++++++++++--------------------- src/engine/bank03.asm | 19 +- src/engine/bank04.asm | 6 +- src/engine/bank20.asm | 225 ++++++++- src/engine/home.asm | 35 +- src/macros/scripts.asm | 2 +- src/wram.asm | 2 + 8 files changed, 812 insertions(+), 607 deletions(-) (limited to 'src') diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index c023a58..d7eeaa8 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -6,9 +6,9 @@ const NPC_DATA_FIELD_03 const NPC_DATA_FIELD_04 const NPC_DATA_OWSEQUENCE_PTR - const NPC_DATA_OWSEQUENCE_PTR_2 +const_value = const_value+1 const NPC_DATA_NAME_TEXT - const NPC_DATA_NAME_TEXT_2 +const_value = const_value+1 const NPC_DATA_BATTLE_PICTURE const NPC_DATA_FIELD_0A const NPC_DATA_FIELD_0B @@ -58,6 +58,120 @@ NPC_DATA_LENGTH EQU const_value const STEPHANIE_PIC ; $28 const AARON_PIC ; $29 -DRMASON EQU $01 -SARA EQU $1F -AMANDA EQU $20 + const_def 1 + const DRMASON ; $01 + const RONALD1 ; $02 + const ISHIHARA ; $03 + const IMAKUNI ; $04 +const_value = const_value+1 ; DRMASON duplicate +const_value = const_value+1 ; DRMASON duplicate + const SAM ; $07 + const TECH1 ; $08 + const TECH2 ; $09 + const TECH3 ; $0a + const TECH4 ; $0b + const TECH5 ; $0c + const TECH6 ; $0d + const CLERK1 ; $0e + const CLERK2 ; $0f + const CLERK3 ; $10 + const CLERK4 ; $11 + const CLERK5 ; $12 + const CLERK6 ; $13 + const CLERK7 ; $14 + const CLERK8 ; $15 + const CLERK9 ; $16 + const CHRIS ; $17 + const MICHAEL ; $18 + const JESSICA ; $19 + const MITCH ; $1a + const MATTHEW ; $1b + const RYAN ; $1c + const ANDREW ; $1d + const GENE ; $1e + const SARA ; $1f + const AMANDA ; $20 + const JOSHUA ; $21 + const AMY ; $22 + const JENNIFER ; $23 + const NICHOLAS ; $24 + const BRANDON ; $25 + const ISAAC ; $26 + const BRITTANY ; $27 + const KRISTIN ; $28 + const HEATHER ; $29 + const NIKKI ; $2a + const ROBERT ; $2b + const DANIEL ; $2c + const STEPHANIE ; $2d + const MURRAY1 ; $2e + const JOSEPH ; $2f + const DAVID ; $30 + const ERIK ; $31 + const RICK ; $32 + const JOHN ; $33 + const ADAM ; $34 + const JONATHAN ; $35 + const KEN ; $36 + const COURTNEY ; $37 + const STEVE ; $38 + const JACK ; $39 + const ROD ; $3a + const CLERK10 ; $3b + const CLERK11 ; $3c + const MAN1 ; $3d + const WOMAN1 ; $3e + const CHAP1 ; $3f + const GAL1 ; $40 + const LASS1 ; $41 + const CHAP2 ; $42 + const LASS2 ; $43 + const PAPPY1 ; $44 + const LAD1 ; $45 + const LAD2 ; $46 + const CHAP3 ; $47 + const CLERK12 ; $48 + const CLERK13 ; $49 + const HOST ; $4a + const SPECS1 ; $4b + const BUTCH ; $4c + const GRANNY1 ; $4d + const LASS3 ; $4e + const MAN2 ; $4f + const PAPPY2 ; $50 + const LASS4 ; $51 + const HOOD1 ; $52 + const GRANNY2 ; $53 + const GAL2 ; $54 + const LAD3 ; $55 + const GAL3 ; $56 + const CHAP4 ; $57 + const MAN3 ; $58 + const SPECS2 ; $59 + const SPECS3 ; $5a + const WOMAN2 ; $5b + const MANIA ; $5c + const PAPPY3 ; $5d + const GAL4 ; $5e + const CHAMP ; $5f + const HOOD2 ; $60 + const LASS5 ; $61 + const CHAP5 ; $62 + const AARON ; $63 + const GUIDE ; $64 + const TECH7 ; $65 + const TECH8 ; $66 + const _11F18 ; $67 + const _11F1F ; $68 + const _11F26 ; $69 + const _11F2D ; $6a + const _11F34 ; $6b + const _11F3B ; $6c + const _11F42 ; $6d + const _11F49 ; $6e +const_value = const_value+1 ; _11F49 duplicate + const MURRAY2 ; $70 + const RONALD2 ; $71 + const RONALD3 ; $72 +const_value = const_value+1 ; _11f49 duplicate + diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 41cd562..23b4330 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1,110 +1,110 @@ ; When you press the A button in front of something it will find a data entry somewhere on this list ; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation. PointerTable_118f5: - dw Data_119dd - dw Data_119dd - dw Data_119ea - dw Data_11a11 - dw Data_11a1e - dw Data_119dd - dw Data_119dd - dw Data_11a2b - dw Data_11a38 - dw Data_11a45 - dw Data_11a52 - dw Data_11a5f - dw Data_11a6c - dw Data_11a79 - dw Data_11a86 - dw Data_11a93 - dw Data_11aa0 - dw Data_11aad - dw Data_11aba - dw Data_11ac7 - dw Data_11ad4 - dw Data_11ae1 - dw Data_11aee - dw Data_11afb - dw Data_11b08 - dw Data_11b15 - dw Data_11b22 - dw Data_11b2f - dw Data_11b3c - dw Data_11b49 - dw Data_11b56 + dw DrMasonData + dw DrMasonData + dw Ronald1Data + dw IshiharaData + dw ImakuniData + dw DrMasonData + dw DrMasonData + dw SamData + dw Tech1Data + dw Tech2Data + dw Tech3Data + dw Tech4Data + dw Tech5Data + dw Tech6Data + dw Clerk1Data + dw Clerk2Data + dw Clerk3Data + dw Clerk4Data + dw Clerk5Data + dw Clerk6Data + dw Clerk7Data + dw Clerk8Data + dw Clerk9Data + dw ChrisData + dw MichaelData + dw JessicaData + dw MitchData + dw MatthewData + dw RyanData + dw AndrewData + dw GeneData dw SaraData dw AmandaData - dw Data_11b7d - dw Data_11b8a - dw Data_11b97 - dw Data_11ba4 - dw Data_11bb1 - dw Data_11bbe - dw Data_11bcb - dw Data_11bd8 - dw Data_11be5 - dw Data_11bf2 - dw Data_11bff - dw Data_11c0c - dw Data_11c19 - dw Data_11c26 - dw Data_11c40 - dw Data_11c4d - dw Data_11c5a - dw Data_11c67 - dw Data_11c74 - dw Data_11c81 - dw Data_11c8e - dw Data_11c9b - dw Data_11ca8 - dw Data_11cb5 - dw Data_11cc2 - dw Data_11ccf - dw Data_11cdc - dw Data_11ce9 - dw Data_11cf6 - dw Data_11d03 - dw Data_11d10 - dw Data_11d1d - dw Data_11d2a - dw Data_11d37 - dw Data_11d44 - dw Data_11d51 - dw Data_11d5e - dw Data_11d6b - dw Data_11d78 - dw Data_11d85 - dw Data_11d92 - dw Data_11d9f - dw Data_11dac - dw Data_11db9 - dw Data_11dc6 - dw Data_11dd3 - dw Data_11de0 - dw Data_11ded - dw Data_11dfa - dw Data_11e07 - dw Data_11e14 - dw Data_11e21 - dw Data_11e2e - dw Data_11e3b - dw Data_11e48 - dw Data_11e55 - dw Data_11e62 - dw Data_11e6f - dw Data_11e7c - dw Data_11e89 - dw Data_11e96 - dw Data_11ea3 - dw Data_11eb0 - dw Data_11ebd - dw Data_11eca - dw Data_11ed7 - dw Data_11ee4 - dw Data_11ef1 - dw Data_11efe - dw Data_11f0b - dw Data_11f18 + dw JoshuaData + dw AmyData + dw JenniferData + dw NicholasData + dw BrandonData + dw IsaacData + dw BrittanyData + dw KristinData + dw HeatherData + dw NikkiData + dw RobertData + dw DanielData + dw StephanieData + dw Murray1Data + dw JosephData + dw DavidData + dw ErikData + dw RickData + dw JohnData + dw AdamData + dw JonathanData + dw KenData + dw CourtneyData + dw SteveData + dw JackData + dw RodData + dw Clerk10Data + dw Clerk11Data + dw Man1Data + dw Woman1Data + dw Chap1Data + dw Gal1Data + dw Lass1Data + dw Chap2Data + dw Lass2Data + dw Pappy1Data + dw Lad1Data + dw Lad2Data + dw Chap3Data + dw Clerk12Data + dw Clerk13Data + dw HostData + dw Specs1Data + dw ButchData + dw Granny1Data + dw Lass3Data + dw Man2Data + dw Pappy2Data + dw Lass4Data + dw Hood1Data + dw Granny2Data + dw Gal2Data + dw Lad3Data + dw Gal3Data + dw Chap4Data + dw Man3Data + dw Specs2Data + dw Specs3Data + dw Woman2Data + dw ManiaData + dw Pappy3Data + dw Gal4Data + dw ChampData + dw Hood2Data + dw Lass5Data + dw Chap5Data + dw AaronData + dw GuideData + dw Tech7Data + dw Tech8Data + dw Data_11f18 ; these actually are used for the effects around the legendary cards dw Data_11f1f dw Data_11f26 dw Data_11f2d @@ -113,12 +113,12 @@ PointerTable_118f5: dw Data_11f42 dw Data_11f49 dw Data_11f49 - dw Data_11c33 - dw Data_119f7 - dw Data_11a04 + dw Murray2Data + dw Ronald2Data + dw Ronald3Data dw Data_11f49 -Data_119dd: - db $01 +DrMasonData: + db DRMASON db $02 db $00 db $26 @@ -129,393 +129,363 @@ Data_119dd: db $00 db $00 db $00 -Data_119ea: - db $02 +Ronald1Data: + db RONALD1 db $01 db $04 db $0e db $00 dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 + tx Text03ad + db RONALD_PIC db $1a db $0f db $16 -Data_119f7: - db $71 +Ronald2Data: + db RONALD2 db $01 db $04 db $0e db $00 dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 + tx Text03ad + db RONALD_PIC db $1a db $0f db $16 -Data_11a04: - db $72 +Ronald3Data: + db RONALD3 db $01 db $04 db $0e db $00 dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 + tx Text03ad + db RONALD_PIC db $1a db $0f db $16 -Data_11a11: - db $03 +IshiharaData: + db ISHIHARA db $03 db $04 db $22 db $00 dw $5b4a ; Pointer to NPC Data - db $ae - db $03 + tx Text03ae db $00 db $00 db $00 db $00 -Data_11a1e: - db $04 +ImakuniData: + db IMAKUNI db $04 db $00 db $0e db $00 dw $5d0d ; Pointer to NPC Data - db $af - db $03 - db $04 + tx Text03af + db IMAKUNI_PIC db $34 db $10 db $15 -Data_11a2b: - db $07 +SamData: + db SAM db $18 db $00 db $0e db $00 dw $561d ; Pointer to NPC Data - db $b1 - db $03 - db $03 + tx Text03b1 + db SAM_PIC db $02 db $02 db $15 -Data_11a38: - db $08 +Tech1Data: + db TECH1 db $18 db $00 db $0e db $00 dw $5583 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a45: - db $09 +Tech2Data: + db TECH2 db $18 db $00 db $0e db $00 dw $55ca ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a52: - db $0a +Tech3Data: + db TECH3 db $18 db $00 db $0e db $00 dw $55d5 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a5f: - db $0b +Tech4Data: + db TECH4 db $18 db $00 db $0e db $00 dw $55e0 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a6c: - db $0c +Tech5Data: + db TECH5 db $18 db $00 db $0e db $00 dw $55f9 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a79: - db $0d +Tech6Data: + db TECH6 db $18 db $00 db $0e db $00 dw $58bb ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a86: - db $0e +Clerk1Data: + db CLERK1 db $21 db $0a db $30 db $00 dw $5c64 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11a93: - db $0f +Clerk2Data: + db CLERK2 db $21 db $0a db $30 db $00 dw $5ed1 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aa0: - db $10 +Clerk3Data: + db CLERK3 db $21 db $0a db $30 db $00 dw $609e ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aad: - db $11 +Clerk4Data: + db CLERK4 db $21 db $0a db $30 db $00 dw $6369 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aba: - db $12 +Clerk5Data: + db CLERK5 db $21 db $0a db $30 db $00 dw $6566 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ac7: - db $13 +Clerk6Data: + db CLERK6 db $21 db $0a db $30 db $00 dw $684c ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ad4: - db $14 +Clerk7Data: + db CLERK7 db $21 db $0a db $30 db $00 dw $6b53 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ae1: - db $15 +Clerk8Data: + db CLERK8 db $21 db $0a db $30 db $00 dw $6d45 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aee: - db $16 +Clerk9Data: + db CLERK9 db $21 db $0a db $30 db $00 dw $7025 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11afb: - db $17 +ChrisData: + db CHRIS db $15 db $00 db $26 db $00 dw $5ef2 ; Pointer to NPC Data - db $b4 - db $03 - db $1d + tx Text03b4 + db CHRIS_PIC db $1c db $03 db $15 -Data_11b08: - db $18 +MichaelData: + db MICHAEL db $15 db $00 db $26 db $00 dw $6573 ; Pointer to NPC Data - db $b5 - db $03 - db $1e + tx Text03b5 + db MICHAEL_PIC db $1d db $03 db $15 -Data_11b15: - db $19 +JessicaData: + db JESSICA db $1f db $04 db $1a db $00 dw $6d96 ; Pointer to NPC Data - db $b6 - db $03 - db $27 + tx Text03b6 + db JESSICA_PIC db $1e db $03 db $15 -Data_11b22: - db $1a +MitchData: + db MITCH db $0a db $00 db $0e db $00 dw $5dc3 ; Pointer to NPC Data - db $b7 - db $03 - db $0a + tx Text03b7 + db MITCH_PIC db $10 db $03 db $16 -Data_11b2f: - db $1b +MatthewData: + db MATTHEW db $15 db $00 db $16 db $00 dw $5f39 ; Pointer to NPC Data - db $b8 - db $03 - db $1a + tx Text03b8 + db MATTHEW_PIC db $21 db $03 db $15 -Data_11b3c: - db $1c +RyanData: + db RYAN db $11 db $00 db $26 db $00 dw $5ff0 ; Pointer to NPC Data - db $b9 - db $03 - db $1b + tx Text03b9 + db RYAN_PIC db $1f db $03 db $15 -Data_11b49: - db $1d +AndrewData: + db ANDREW db $1a db $00 db $16 db $00 dw $6017 ; Pointer to NPC Data - db $ba - db $03 - db $1c + tx Text03ba + db ANDREW_PIC db $20 db $03 db $15 -Data_11b56: - db $1e +GeneData: + db GENE db $0b db $04 db $1e db $00 dw $603e ; Pointer to NPC Data - db $bb - db $03 - db $0b + tx Text03bb + db GENE_PIC db $11 db $03 db $16 SaraData: - db SARA ; trainer id + db SARA db $20 db $00 db $0e db $00 dw OWSequence_Sara ; Pointer to NPC Data - db $bc - db $03 - db SARA_PIC ; battle profile picture + tx Text03bc + db SARA_PIC db $22 db $03 db $15 @@ -526,931 +496,859 @@ AmandaData: db $16 db $00 dw OWSequence_Amanda ; Pointer to NPC Data - db $bd - db $03 + tx Text03bd db AMANDA_PIC ; battle profile picture db $23 db $03 db $15 -Data_11b7d: - db $21 +JoshuaData: + db JOSHUA db $16 db $00 db $26 db $00 dw OWSequence_Joshua ; Pointer to NPC Data - db $be - db $03 - db $17 + tx Text03be + db JOSHUA_PIC db $24 db $03 db $15 -Data_11b8a: - db $22 +AmyData: + db AMY db $08 db $08 db $2e db $10 dw $6304 ; Pointer to NPC Data - db $bf - db $03 - db $08 + tx Text03bf + db AMY_PIC db $12 db $03 db $16 -Data_11b97: - db $23 +JenniferData: + db JENNIFER db $1c db $04 db $0e db $00 dw $6408 ; Pointer to NPC Data - db $c0 - db $03 - db $26 + tx Text03c0 + db JENNIFER_PIC db $25 db $03 db $15 -Data_11ba4: - db $24 +NicholasData: + db NICHOLAS db $17 db $04 db $1e db $00 dw $642f ; Pointer to NPC Data - db $c1 - db $03 - db $18 + tx Text03c1 + db NICHOLAS_PIC db $26 db $03 db $15 -Data_11bb1: - db $25 +BrandonData: + db BRANDON db $17 db $04 db $1e db $00 dw $6456 ; Pointer to NPC Data - db $c2 - db $03 - db $19 + tx Text03c2 + db BRANDON_PIC db $27 db $03 db $15 -Data_11bbe: - db $26 +IsaacData: + db ISAAC db $09 db $00 db $16 db $00 dw $64ad ; Pointer to NPC Data - db $c3 - db $03 - db $09 + tx Text03c3 + db ISAAC_PIC db $13 db $03 db $16 -Data_11bcb: - db $27 +BrittanyData: + db BRITTANY db $1c db $04 db $0e db $00 dw $65d2 ; Pointer to NPC Data - db $c4 - db $03 - db $21 + tx Text03c4 + db BRITTANY_PIC db $28 db $03 db $15 -Data_11bd8: - db $28 +KristinData: + db KRISTIN db $1e db $00 db $1e db $00 dw $6701 ; Pointer to NPC Data - db $c5 - db $03 - db $22 + tx Text03c5 + db KRISTIN_PIC db $29 db $03 db $15 -Data_11be5: - db $29 +HeatherData: + db HEATHER db $1d db $04 db $22 db $00 dw $6745 ; Pointer to NPC Data - db $c6 - db $03 - db $23 + tx Text03c6 + db HEATHER_PIC db $2a db $03 db $15 -Data_11bf2: - db $2a +NikkiData: + db NIKKI db $05 db $00 db $1a db $00 dw $679e ; Pointer to NPC Data - db $c7 - db $03 - db $05 + tx Text03c7 + db NIKKI_PIC db $14 db $03 db $16 -Data_11bff: - db $2b +RobertData: + db ROBERT db $11 db $04 db $16 db $00 dw $6980 ; Pointer to NPC Data - db $c8 - db $03 - db $20 + tx Text03c8 + db ROBERT_PIC db $2b db $03 db $15 -Data_11c0c: - db $2c +DanielData: + db DANIEL db $12 db $04 db $1a db $00 dw $6a60 ; Pointer to NPC Data - db $c9 - db $03 - db $1f + tx Text03c9 + db DANIEL_PIC db $2c db $03 db $15 -Data_11c19: - db $2d +StephanieData: + db STEPHANIE db $1c db $04 db $0e db $00 dw $6aa2 ; Pointer to NPC Data - db $ca - db $03 - db $28 + tx Text03ca + db STEPHANIE_PIC db $2d db $03 db $15 -Data_11c26: - db $2e +Murray1Data: + db MURRAY1 db $0c db $00 db $12 db $00 dw $6adf ; Pointer to NPC Data - db $cb - db $03 - db $0c + tx Text03cb + db MURRAY_PIC db $15 db $03 db $16 -Data_11c33: - db $70 +Murray2Data: + db MURRAY2 db $0c db $03 db $15 db $10 dw $6adf ; Pointer to NPC Data - db $cb - db $03 - db $0c + tx Text03cb + db MURRAY_PIC db $15 db $03 db $16 -Data_11c40: - db $2f +JosephData: + db JOSEPH db $18 db $00 db $0e db $00 dw $6cdb ; Pointer to NPC Data - db $cc - db $03 - db $11 + tx Text03cc + db JOSEPH_PIC db $2e db $03 db $15 -Data_11c4d: - db $30 +DavidData: + db DAVID db $18 db $00 db $0e db $00 dw $6c11 ; Pointer to NPC Data - db $cd - db $03 - db $12 + tx Text03cd + db DAVID_PIC db $2f db $03 db $15 -Data_11c5a: - db $31 +ErikData: + db ERIK db $18 db $00 db $0e db $00 dw $6c42 ; Pointer to NPC Data - db $ce - db $03 - db $13 + tx Text03ce + db ERIK_PIC db $30 db $03 db $15 -Data_11c67: - db $32 +RickData: + db RICK db $06 db $00 db $0e db $00 dw $6c67 ; Pointer to NPC Data - db $cf - db $03 - db $06 + tx Text03cf + db RICK_PIC db $16 db $03 db $16 -Data_11c74: - db $33 +JohnData: + db JOHN db $12 db $04 db $1a db $00 dw $6eb3 ; Pointer to NPC Data - db $d0 - db $03 - db $14 + tx Text03d0 + db JOHN_PIC db $31 db $03 db $15 -Data_11c81: - db $34 +AdamData: + db ADAM db $13 db $00 db $22 db $00 dw $6ed8 ; Pointer to NPC Data - db $d1 - db $03 - db $15 + tx Text03d1 + db ADAM_PIC db $32 db $03 db $15 -Data_11c8e: - db $35 +JonathanData: + db JONATHAN db $11 db $04 db $16 db $00 dw $6efd ; Pointer to NPC Data - db $d2 - db $03 - db $16 + tx Text03d2 + db JONATHAN_PIC db $33 db $03 db $15 -Data_11c9b: - db $36 +KenData: + db KEN db $07 db $04 db $1e db $00 dw $6f22 ; Pointer to NPC Data - db $d3 - db $03 - db $07 + tx Text03d3 + db KEN_PIC db $17 db $03 db $16 -Data_11ca8: - db $37 +CourtneyData: + db COURTNEY db $0d db $00 db $12 db $00 dw $771f ; Pointer to NPC Data - db $d4 - db $03 - db $0d + tx Text03d4 + db COURTNEY_PIC db $0c db $04 db $17 -Data_11cb5: - db $38 +SteveData: + db STEVE db $0e db $00 db $2a db $00 dw $772a ; Pointer to NPC Data - db $d5 - db $03 - db $0e + tx Text03d5 + db STEVE_PIC db $0d db $04 db $17 -Data_11cc2: - db $39 +JackData: + db JACK db $0f db $00 db $26 db $00 dw $7735 ; Pointer to NPC Data - db $d6 - db $03 - db $0f + tx Text03d6 + db JACK_PIC db $0e db $04 db $17 -Data_11ccf: - db $3a +RodData: + db ROD db $10 db $00 db $0e db $00 dw $7740 ; Pointer to NPC Data - db $d7 - db $03 - db $10 + tx Text03d7 + db ROD_PIC db $0f db $04 db $17 -Data_11cdc: - db $3b +Clerk10Data: + db CLERK10 db $21 db $0a db $30 db $00 dw $4c3e ; Pointer to NPC Data - db $b0 - db $03 + tx Text03b0 db $00 db $00 db $00 db $00 -Data_11ce9: - db $3c +Clerk11Data: + db CLERK11 db $21 db $0a db $30 db $00 dw $4c3e ; Pointer to NPC Data - db $b0 - db $03 + tx Text03b0 db $00 db $00 db $00 db $00 -Data_11cf6: - db $3d +Man1Data: + db MAN1 db $1a db $00 db $16 db $00 dw $5c76 ; Pointer to NPC Data - db $d8 - db $03 + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11d03: - db $3e +Woman1Data: + db WOMAN1 db $23 db $04 db $1e db $00 dw $5f83 ; Pointer to NPC Data - db $d9 - db $03 + tx Text03d9 db $00 db $00 db $00 db $00 -Data_11d10: - db $3f +Chap1Data: + db CHAP1 db $19 db $00 db $1a db $00 dw $5fc0 ; Pointer to NPC Data - db $da - db $03 + tx Text03da db $00 db $00 db $00 db $00 -Data_11d1d: - db $40 +Gal1Data: + db GAL1 db $22 db $00 db $16 db $00 dw $60cf ; Pointer to NPC Data - db $db - db $03 + tx Text03db db $00 db $00 db $00 db $00 -Data_11d2a: - db $41 +Lass1Data: + db LASS1 db $1e db $00 db $1e db $00 dw $6111 ; Pointer to NPC Data - db $dc - db $03 + tx Text03dc db $00 db $00 db $00 db $00 -Data_11d37: - db $42 +Chap2Data: + db CHAP2 db $19 db $00 db $1a db $00 dw $639a ; Pointer to NPC Data - db $da - db $03 + tx Text03da db $00 db $00 db $00 db $00 -Data_11d44: - db $43 +Lass2Data: + db LASS2 db $1e db $00 db $1e db $00 dw $661f ; Pointer to NPC Data - db $dc - db $03 + tx Text03dc db $00 db $00 db $00 db $00 -Data_11d51: - db $44 +Pappy1Data: + db PAPPY1 db $1b db $00 db $22 db $00 dw $69a5 ; Pointer to NPC Data - db $dd - db $03 + tx Text03dd db $00 db $00 db $00 db $00 -Data_11d5e: - db $45 +Lad1Data: + db LAD1 db $12 db $04 db $1a db $00 dw $6b84 ; Pointer to NPC Data - db $de - db $03 + tx Text03de db $00 db $00 db $00 db $00 -Data_11d6b: - db $46 +Lad2Data: + db LAD2 db $11 db $04 db $16 db $00 dw $6e2c ; Pointer to NPC Data - db $de - db $03 + tx Text03de db $00 db $00 db $00 db $00 -Data_11d78: - db $47 +Chap3Data: + db CHAP3 db $19 db $00 db $1a db $00 dw $6de8 ; Pointer to NPC Data - db $da - db $03 + tx Text03da db $00 db $00 db $00 db $00 -Data_11d85: - db $48 +Clerk12Data: + db CLERK12 db $22 db $00 db $16 db $00 dw $7295 ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11d92: - db $49 +Clerk13Data: + db CLERK13 db $22 db $00 db $16 db $00 dw $726c ; Pointer to NPC Data - db $b3 - db $03 + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11d9f: - db $4a +HostData: + db HOST db $22 db $00 db $16 db $00 dw $7352 ; Pointer to NPC Data - db $df - db $03 + tx Text03df db $00 db $00 db $00 db $00 -Data_11dac: - db $4b +Specs1Data: + db SPECS1 db $13 db $00 db $22 db $00 dw $5d82 ; Pointer to NPC Data - db $e0 - db $03 + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11db9: - db $4c +ButchData: + db BUTCH db $14 db $00 db $16 db $00 dw $5d8d ; Pointer to NPC Data - db $e1 - db $03 + tx Text03e1 db $00 db $00 db $00 db $00 -Data_11dc6: - db $4d +Granny1Data: + db GRANNY1 db $24 db $00 db $16 db $00 dw $5d9f ; Pointer to NPC Data - db $e5 - db $03 + tx Text03e5 db $00 db $00 db $00 db $00 -Data_11dd3: - db $4e +Lass3Data: + db LASS3 db $1d db $04 db $22 db $00 dw $5fd2 ; Pointer to NPC Data - db $dc - db $03 + tx Text03dc db $00 db $00 db $00 db $00 -Data_11de0: - db $4f +Man2Data: + db MAN2 db $1a db $00 db $16 db $00 dw $6137 ; Pointer to NPC Data - db $d8 - db $03 + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11ded: - db $50 +Pappy2Data: + db PAPPY2 db $1b db $00 db $22 db $00 dw $613b ; Pointer to NPC Data - db $dd - db $03 + tx Text03dd db $00 db $00 db $00 db $00 -Data_11dfa: - db $51 +Lass4Data: + db LASS4 db $1d db $04 db $22 db $00 dw $63d9 ; Pointer to NPC Data - db $dc - db $03 + tx Text03dc db $00 db $00 db $00 db $00 -Data_11e07: - db $52 +Hood1Data: + db HOOD1 db $17 db $04 db $1e db $00 dw $63dd ; Pointer to NPC Data - db $e2 - db $03 + tx Text03e2 db $00 db $00 db $00 db $00 -Data_11e14: - db $53 +Granny2Data: + db GRANNY2 db $24 db $00 db $16 db $00 dw $66d8 ; Pointer to NPC Data - db $e5 - db $03 + tx Text03e5 db $00 db $00 db $00 db $00 -Data_11e21: - db $54 +Gal2Data: + db GAL2 db $22 db $00 db $16 db $00 dw $66e3 ; Pointer to NPC Data - db $db - db $03 + tx Text03db db $00 db $00 db $00 db $00 -Data_11e2e: - db $55 +Lad3Data: + db LAD3 db $12 db $04 db $1a db $00 dw $6850 ; Pointer to NPC Data - db $de - db $03 + tx Text03de db $00 db $00 db $00 db $00 -Data_11e3b: - db $56 +Gal3Data: + db GAL3 db $22 db $00 db $16 db $00 dw $6a30 ; Pointer to NPC Data - db $db - db $03 + tx Text03db db $00 db $00 db $00 db $00 -Data_11e48: - db $57 +Chap4Data: + db CHAP4 db $19 db $00 db $1a db $00 dw $6a3b ; Pointer to NPC Data - db $da - db $03 + tx Text03da db $00 db $00 db $00 db $00 -Data_11e55: - db $58 +Man3Data: + db MAN3 db $1a db $00 db $16 db $00 dw $6bc1 ; Pointer to NPC Data - db $d8 - db $03 + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11e62: - db $59 +Specs2Data: + db SPECS2 db $18 db $00 db $0e db $00 dw $6bc5 ; Pointer to NPC Data - db $e0 - db $03 + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11e6f: - db $5a +Specs3Data: + db SPECS3 db $13 db $00 db $22 db $00 dw $6bed ; Pointer to NPC Data - db $e0 - db $03 + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11e7c: - db $5b +Woman2Data: + db WOMAN2 db $23 db $04 db $1e db $00 dw $4c3e ; Pointer to NPC Data - db $d9 - db $03 + tx Text03d9 db $00 db $00 db $00 db $00 -Data_11e89: - db $5c +ManiaData: + db MANIA db $15 db $00 db $26 db $00 dw $6e88 ; Pointer to NPC Data - db $e4 - db $03 + tx Text03e4 db $00 db $00 db $00 db $00 -Data_11e96: - db $5d +Pappy3Data: + db PAPPY3 db $1b db $00 db $22 db $00 dw $709c ; Pointer to NPC Data - db $dd - db $03 + tx Text03dd db $00 db $00 db $00 db $00 -Data_11ea3: - db $5e +Gal4Data: + db GAL4 db $22 db $00 db $16 db $00 dw $70a0 ; Pointer to NPC Data - db $db - db $03 + tx Text03db db $00 db $00 db $00 db $00 -Data_11eb0: - db $5f +ChampData: + db CHAMP db $15 db $00 db $26 db $00 dw $70a4 ; Pointer to NPC Data - db $e3 - db $03 + tx Text03e3 db $00 db $00 db $00 db $00 -Data_11ebd: - db $60 +Hood2Data: + db HOOD2 db $17 db $04 db $1e db $00 dw $70a8 ; Pointer to NPC Data - db $e2 - db $03 + tx Text03e2 db $00 db $00 db $00 db $00 -Data_11eca: - db $61 +Lass5Data: + db LASS5 db $1f db $04 db $1a db $00 dw $70ac ; Pointer to NPC Data - db $dc - db $03 + tx Text03dc db $00 db $00 db $00 db $00 -Data_11ed7: - db $62 +Chap5Data: + db CHAP5 db $19 db $00 db $1a db $00 dw $70b0 ; Pointer to NPC Data - db $da - db $03 + tx Text03da db $00 db $00 db $00 db $00 -Data_11ee4: - db $63 +AaronData: + db AARON db $18 db $00 db $0e db $00 dw $58dd ; Pointer to NPC Data - db $e7 - db $03 - db $29 + tx Text03e7 + db AARON_PIC db $09 db $02 db $15 -Data_11ef1: - db $64 +GuideData: + db GUIDE db $1a db $00 db $16 db $00 dw $7283 ; Pointer to NPC Data - db $e6 - db $03 + tx Text03e6 db $00 db $00 db $00 db $00 -Data_11efe: - db $65 +Tech7Data: + db TECH7 db $18 db $00 db $0e db $00 dw $58c6 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11f0b: - db $66 +Tech8Data: + db TECH8 db $18 db $00 db $0e db $00 dw $58d1 ; Pointer to NPC Data - db $b2 - db $03 + tx Text03b2 db $00 db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index e63481f..e89bbfb 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -128,9 +128,9 @@ Func_c10a: ; c10a (3:410a) ; closes dialogue window. seems to be for other things as well. CloseDialogueBox: ; c111 (3:4111) - ld a, [wd0c1] + ld a, [wd0c1] ; with 0 set i can't move cursors, can move around bit 0, a - call nz, Func_c135 + call nz, Func_c135 ; seems to actually close the dialog window ld a, [wd0c1] bit 1, a jr z, .asm_c12a @@ -144,10 +144,11 @@ CloseDialogueBox: ; c111 (3:4111) ld [wd0bf], a ret +; this seems to legitimately close the dialogue box Func_c135: ; c135 (3:4135) push hl - farcall Func_80028 - ld hl, wd0c1 + farcall Func_80028 ; Draw background of the current room, I think + ld hl, wd0c1 ; at this point, the background tiles are back to normal res 0, [hl] pop hl ret @@ -1236,7 +1237,7 @@ Func_c943: ; c943 (3:4943) ld [wd4c6], a ld de, wd3ab ld bc, $0006 - call Func_3bf5 + call CopyBankedDataToDE ld a, [wd3ab] or a jr z, .asm_c98f @@ -2324,12 +2325,12 @@ Func_d0be: ; d0be (3:50be) farcall Func_1c461 jp IncreaseOWScriptPointerBy3 -Func_d0ce: ; d0ce (3:50ce) +OWScript_DoFrames: ; d0ce (3:50ce) push bc call DoFrameIfLCDEnabled pop bc dec c - jr nz, Func_d0ce + jr nz, OWScript_DoFrames jp IncreaseOWScriptPointerBy2 Func_d0d9: ; d0d9 (3:50d9) @@ -2922,10 +2923,10 @@ asm_d4e6 OWSequence_d52e: ; d52e (3:552e) start_script - run_script Func_d0ce + run_script OWScript_DoFrames db $3c run_script Func_d3e0 - run_script Func_d0ce + run_script OWScript_DoFrames db $78 run_script Func_d36d db $02 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 48b6c12..2ebb399 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1004,7 +1004,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d088 dw Func_d095 dw Func_d0be - dw Func_d0ce + dw OWScript_DoFrames dw Func_d0d9 dw Func_d0f2 dw Func_ce4a @@ -1331,7 +1331,7 @@ Func_12ae2: ; 12ae2 (4:6ae2) ld [hli], a push hl ld l, $6 - farcall Func_8020f + farcall GetMapDataPointer farcall Func_80229 pop hl ld a, [wd4c6] @@ -1374,7 +1374,7 @@ Func_12b13: ; 12b13 (4:6b13) ld [hl], a ld de, wd23e ld bc, $0004 - call Func_3bf5 + call CopyBankedDataToDE pop hl ld de, wd23e ld a, [de] diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index d2acf6a..967ffb0 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -2,7 +2,7 @@ Func_80000: ; 80000 (20:4000) INCROM $80000, $80028 Func_80028: ; 80028 (20:4028) - call Func_801f1 + call Func_801f1 ; Clears the first x800 bytes of S1:a000 ld bc, $0000 call Func_80077 farcall $3, $49c7 @@ -13,6 +13,7 @@ Func_80028: ; 80028 (20:4028) INCROM $8003d, $80077 +; loads the background it seems. Also includes background tile permissions? Func_80077: ; 80077 (20:4077) ld a, $1 ld [wd292], a @@ -25,37 +26,187 @@ Func_80077: ; 80077 (20:4077) push hl push bc push de - call BCCoordToBGMap0Address + call BCCoordToBGMap0Address ; de ld hl, wd4c2 ld [hl], e inc hl ld [hl], d - call $43b9 + call Func_803b9 ; load more d4c* stuff from mapdatapointers ld a, [wd4c6] - ld [wd23d], a + ld [wd23d], a ; copies the bank of the data we loaded to wd23d ld de, wd23e ld bc, $0006 - call Func_3bf5 + call CopyBankedDataToDE ; copies 6 bytes to wd23e+ ld l, e - ld h, d + ld h, d ; then copies that data into various other places? ld a, [hli] - ld [wd12f], a + ld [wd12f], a ; just happens to correspond to size of room ld a, [hli] - ld [wd130], a + ld [wd130], a ; hmmm ld a, [hli] - ld [wd23a], a + ld [wd23a], a ; these 3 are before this data and after room collision ld a, [hli] ld [wd23b], a ld a, [hli] ld [wd23c], a - call $40bd + call Func_800bd ; moves the background data to some place vblank knows about pop de pop bc pop hl ret -; 0x800bd - INCROM $800bd, $801a1 +Func_800bd: ; 800bd (20:40bd) + push hl + push bc + push de + ld a, [wd4c4] ; these are still the copy locations + add $05 + ld e, a + ld a, [wd4c5] + adc $00 + ld d, a ; de = [wd4c4/5] + 5 + ld b, $c0 ; b = c0 + call Func_08bf + ld a, [wd4c2] + ld e, a + ld a, [wd4c3] ; bg map coord from earlier + ld d, a + call Func_800e0 + pop de + pop bc + pop hl + ret + +; de is a bg map coord +Func_800e0: ; 800e0 (20:40e0) + push hl + ld hl, $d28e + ld a, [wd12f] + ld [hl], a + ld a, [wd23c] + or a + jr z, .asm_800f0 + sla [hl] ; if wd23c is nonzero, double d28e +.asm_800f0 + ld c, $40 + ld hl, wd23e + xor a +.asm_800f6 + ld [hli], a + dec c + jr nz, .asm_800f6 ; clear out wd23e-40+ + ld a, [wd130] + ld c, a +.asm_800fe + push bc ; push the height of this map + push de ; push the destination of this map + ld b, $00 + ld a, [$d28e] + ld c, a ; bc is now the width + ld de, wd23e ; wd23e is the place we copied map data to (The 6 bytes) before + call Func_3be4 + ld a, [wd12f] + ld b, a + pop de + push de + ld hl, wd23e + call Func_8016e + ld a, [wConsole] + cp $02 + jr nz, .asm_8013b + call BankswitchVRAM1 + ld a, [wd12f] + ld c, a + ld b, $00 + ld hl, wd23e + add hl, bc + pop de + push de + ld a, [wd12f] + ld b, a + call Func_80148 + call Func_8016e + call BankswitchVRAM0 +.asm_8013b + pop de + ld hl, $20 + add hl, de + ld e, l + ld d, h + pop bc + dec c + jr nz, .asm_800fe + pop hl + ret +; 0x80148 + +Func_80148: ; 80148 (20:4148) + ld a, [$d291] + or a + ret z + ld a, [$d23c] + or a + jr z, .asm_80162 + push hl + push bc +.asm_80155 + push bc + ld a, [$d291] + add [hl] + ld [hli], a + pop bc + dec b + jr nz, .asm_80155 + pop bc + pop hl + ret +.asm_80162 + push hl + push bc + ld a, [$d291] +.asm_80167 + ld [hli], a + dec b + jr nz, .asm_80167 + pop bc + pop hl + ret + +Func_8016e: ; 8016e (20:416e) + ld a, [wd292] + or a + jp z, SafeCopyDataHLtoDE + push hl + push bc + push de + ldh a, [hBankSRAM] + push af + ld a, $01 + call BankswitchSRAM + push hl + ld hl, $800 + ldh a, [hBankVRAM] + or a + jr z, .asm_8018c + ld hl, $c00 +.asm_8018c + add hl, de + ld e, l + ld d, h + pop hl +.asm_80190 + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .asm_80190 + pop af + call BankswitchSRAM + call DisableSRAM + pop de + pop bc + pop hl + ret Func_801a1: ; 801a1 (20:41a1) push hl @@ -108,6 +259,7 @@ Func_801a1: ; 801a1 (20:41a1) pop hl ret +; Clears the first x800 bytes of S1:a000 Func_801f1: ; 801f1 (20:41f1) push hl push bc @@ -118,7 +270,7 @@ Func_801f1: ; 801f1 (20:41f1) ld hl, $a000 ld bc, $0800 xor a - call $3c10 + call FillMemoryWithA pop af call BankswitchSRAM call DisableSRAM @@ -126,7 +278,7 @@ Func_801f1: ; 801f1 (20:41f1) pop hl ret -Func_8020f: ; 8020f (20:420f) +GetMapDataPointer: ; 8020f (20:420f) push bc push af ld bc, MapDataPointers @@ -135,17 +287,18 @@ Func_8020f: ; 8020f (20:420f) ld c, [hl] inc hl ld b, [hl] - pop af + pop af ; bc = [MapDataPointers+l] ld l, a ld h, $0 sla l rl h sla l rl h - add hl, bc + add hl, bc ; hl = [MapDataPointers+l] + 4*a pop bc ret +; These vars are used as a copy source for something about drawing the background? Func_80229: ; 80229 (20:4229) ld a, [hli] ld [wd4c4], a @@ -162,7 +315,7 @@ Func_80229: ; 80229 (20:4229) Func_8025b: ; 8025b (20:425b) push hl ld l, $4 - call Func_8020f + call GetMapDataPointer call Func_80229 ld a, [hl] push af @@ -234,7 +387,19 @@ Func_802bb: ; 802bb (20:42bb) ret ; 0x802d4 - INCROM $802d4, $80418 + INCROM $802d4, $803b9 + +Func_803b9: ; 803b9 (20:43b9) + ld l, $00 + ld a, [wd131] ; current screen/state/almost room? + call GetMapDataPointer + call Func_80229 ; basically get pointer to background tilemap? + ld a, [hl] + ld [$d239], a ; the final value in mapDataPointer goes to this mystery + ret +; 0x803c9 + + INCROM $803c9, $80418 Func_80418: ; 80418 (20:4418) INCROM $80418, $80480 @@ -332,5 +497,27 @@ Func_80ba4: ; 80ba4 (20:4ba4) Unknown_80e5a: ; 80e5a (20:4e5a) INCROM $80e5a, $80e5d +; might be closer to "screen specific data" than map data +; ex: one thing is reading from something that changes multipl times in loading +; of screens, and changes in duels (4d131) MapDataPointers: ; 80e5d (20:4e5d) - INCROM $80e5d, $84000 + dw MapDataPointers_80e67 + dw MapDataPointers_8100f + dw MapDataPointers_8116b + dw MapDataPointers_81333 + dw MapDataPointers_81697 + +MapDataPointers_80e67: ; 80e67 (20:4e67) + INCROM $80e67, $8100f + +MapDataPointers_8100f: ; 8100f (20:500f) + INCROM $8100f, $8116b + +MapDataPointers_8116b: ; 8116b (20:516b) + INCROM $8116b, $81333 + +MapDataPointers_81333: ; 81333 (20:5333) + INCROM $81333, $81697 + +MapDataPointers_81697: ; 81697 (20:5697) + INCROM $81697, $84000 diff --git a/src/engine/home.asm b/src/engine/home.asm index 5acb742..450d9c1 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1537,37 +1537,39 @@ UpdateRNGSources: ; 089b (0:089b) pop hl ret +; ld d, a ; de = wd4c4/5 + 5 +; ld b, $c0 ; b = c0 Func_08bf: ; 08bf (0:08bf) ld hl, wcad6 ld [hl], e inc hl - ld [hl], d + ld [hl], d ; load wcad6/7 with [wd4c4]+5 ld hl, wcad8 ld [hl], $1 - inc hl + inc hl ; wcad8 is 1, a bunch of things after it are 0 xor a ld [hli], a ld [hli], a ld [hli], a ld [hli], a - ld [hl], b + ld [hl], b ; then wcad i think is set to c0 inc hl - ld [hli], a - ld [hl], $ef + ld [hli], a ; 0 + ld [hl], $ef ; and ef ld h, b - ld l, $0 + ld l, $0 ; hl is now c000, first byte of wram, first card collection or no name xor a .asm_8d9 - ld [hl], a - inc l + ld [hl], a ; 0 out ff bytes + inc l ; inc the first ff bytes of wram (was an arg so could be other stuff) jr nz, .asm_8d9 ret Func_08de: ; 08de (0:08de) - push hl - push de + push hl ; wd23e + 40 i think? + push de ; 6 mdp bytes .asm_8e0 - push bc + push bc ; as of first run, bc is the width call Func_08ef ld [de], a inc de @@ -1584,7 +1586,7 @@ Func_08ef: ; 08ef (0:08ef) ld hl, wcadc ld a, [hl] or a - jr z, .asm_902 + jr z, .asm_902 ; for the purpose of this, we made it 0 earlier dec [hl] inc hl .asm_8f8 @@ -1603,9 +1605,9 @@ Func_08ef: ; 08ef (0:08ef) ld c, [hl] inc hl ld b, [hl] - inc hl - dec [hl] - inc hl + inc hl ; get pointer from wcad6/7 + dec [hl] ; dec wcad8 (was 1) + inc hl ; wcad9 jr nz, .asm_914 dec hl ld [hl], $8 @@ -11329,7 +11331,8 @@ Func_3be4: ; 3be4 (0:3be4) ret ; 0x3bf5 -Func_3bf5: ; 3bf5 (0:3bf5) +; Copies bc bytes from [wd4c4] to de +CopyBankedDataToDE: ; 3bf5 (0:3bf5) ldh a, [hBankROM] push af push hl diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 9c81bda..2fa15fb 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -50,7 +50,7 @@ ENDM const Func_d088_index ; $21 const Func_d095_index ; $22 const Func_d0be_index ; $23 - const Func_d0ce_index ; $24 + const OWScript_DoFrames_index ; $24 const Func_d0d9_index ; $25 const Func_d0f2_index ; $26 const Func_ce4a_index ; $27 diff --git a/src/wram.asm b/src/wram.asm index cee7340..7ae9e59 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1900,6 +1900,7 @@ wd12f:: ; d12f wd130:: ; d130 ds $1 +; current screen, at least for some purpose -- changed multiple times on loads and changes when screen changes in battle? wd131:: ; d131 ds $1 @@ -2210,6 +2211,7 @@ wd4c2:: ; d4c2 wd4c3:: ; d4c3 ds $1 +; these next 3 seem to be an address (bank @ end) for copying bg data wd4c4:: ; d4c4 ds $1 -- cgit v1.2.3 From f3f374e6b7e26bc93c8428c8cb7b8c210223b2f4 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Mon, 23 Sep 2019 12:27:12 -0400 Subject: Fleshed out flags a lot --- src/constants/duel_constants.asm | 7 + src/constants/event_constants.asm | 6 +- src/constants/misc_constants.asm | 3 + src/data/npcs.asm | 2 +- src/engine/bank03.asm | 670 +++++++++++++++++++++++++++++--------- src/engine/bank04.asm | 65 ++-- src/engine/bank07.asm | 17 +- src/engine/bank1c.asm | 4 +- src/engine/home.asm | 10 +- src/macros/constants.asm | 7 + src/macros/scripts.asm | 34 +- src/wram.asm | 10 +- 12 files changed, 616 insertions(+), 219 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index f3e2912..044b888 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -224,3 +224,10 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 + +PRIZES_1 EQU $01 +PRIZES_2 EQU $02 +PRIZES_3 EQU $03 +PRIZES_4 EQU $04 +PRIZES_5 EQU $05 +PRIZES_6 EQU $06 diff --git a/src/constants/event_constants.asm b/src/constants/event_constants.asm index 496f5a3..f6ac803 100644 --- a/src/constants/event_constants.asm +++ b/src/constants/event_constants.asm @@ -1,3 +1,3 @@ -; Event Flags -EVENT_BEAT_SARA EQU $15 -EVENT_BEAT_AMANDA EQU $16 +; EVENT_JOSHUA_STATE ; $33 +JOSHUA_TALKED EQU 1 +JOSHUA_BEATEN EQU 2 diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index b31631a..c513111 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -44,3 +44,6 @@ FLUSH_ALL_PALS_F EQU 6 const GAME_EVENT_CONTINUE_DUEL ; $5 const GAME_EVENT_CHALLENGE_MACHINE ; $6 NUM_GAME_EVENTS EQU const_value + +; Script constant +NO_JUMP EQU $0000 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 23b4330..f667077 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -519,7 +519,7 @@ AmyData: db $08 db $2e db $10 - dw $6304 ; Pointer to NPC Data + dw OWSequence_Amy ; Pointer to NPC Data tx Text03bf db AMY_PIC db $12 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index e89bbfb..d7f3496 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -127,10 +127,10 @@ Func_c10a: ; c10a (3:410a) jp hl ; closes dialogue window. seems to be for other things as well. -CloseDialogueBox: ; c111 (3:4111) - ld a, [wd0c1] ; with 0 set i can't move cursors, can move around +CloseAdvancedDialogueBox: ; c111 (3:4111) + ld a, [wd0c1] bit 0, a - call nz, Func_c135 ; seems to actually close the dialog window + call nz, CloseTextBox ld a, [wd0c1] bit 1, a jr z, .asm_c12a @@ -144,11 +144,11 @@ CloseDialogueBox: ; c111 (3:4111) ld [wd0bf], a ret -; this seems to legitimately close the dialogue box -Func_c135: ; c135 (3:4135) +; redraws the background and removes textbox control +CloseTextBox: ; c135 (3:4135) push hl - farcall Func_80028 ; Draw background of the current room, I think - ld hl, wd0c1 ; at this point, the background tiles are back to normal + farcall Func_80028 + ld hl, wd0c1 res 0, [hl] pop hl ret @@ -971,7 +971,7 @@ Func_c74d: ; c74d (3:474d) push bc push de call MainMenu_c75a - call CloseDialogueBox + call CloseAdvancedDialogueBox pop de pop bc pop hl @@ -1088,11 +1088,11 @@ PC_c7ea: ; c7ea (3:47ea) call Func_c32b jr .asm_c801 .asm_c82f - call Func_c135 + call CloseTextBox call DoFrameIfLCDEnabled ldtx hl, TurnedPCOffText call Func_c891 - call CloseDialogueBox + call CloseAdvancedDialogueBox xor a ld [wd112], a call Func_39fc @@ -1109,7 +1109,7 @@ Func_c891: ; c891 (3:4891) ld hl, wd3b9 ld a, [hli] or [hl] - call nz, Func_c135 + call nz, CloseTextBox .asm_c8a1 xor a @@ -1142,7 +1142,7 @@ Func_c8ba: ; c8ba (3:48ba) jr z, .asm_c8d4 .asm_c8d1 - call Func_c135 + call CloseTextBox .asm_c8d4 ld hl, wd3b9 @@ -1412,19 +1412,22 @@ Func_ca0e: ; ca0e (3:4a0e) Func_ca69: ; ca69 (3:4a69) call Func_cab3 -CheckIfEventFlagSet: ; ca6c (3:4a6c) + +; returns the event flag's value in a +; also ors it with itself before returning +GetEventFlagValue: ; ca6c (3:4a6c) push hl push bc - call GetEventFlagMod + call GetEventFlag ld c, [hl] - ld a, [wd3d1] -.asm_ca75 + ld a, [wLoadedFlagBits] +.shiftLoop bit 0, a - jr nz, .asm_ca7f + jr nz, .lsbReached srl a srl c - jr .asm_ca75 -.asm_ca7f + jr .shiftLoop +.lsbReached and c pop bc pop hl @@ -1437,12 +1440,13 @@ CheckIfEventFlagSet: ; ca6c (3:4a6c) Func_ca8f: ; ca8f (3:4a8f) call Func_cab3 -; a - pointer on table for cb1d, c - set or reset control bit -ModifyEventFlags: ; ca92 (3:4a92) +; a - flag +; c - value - truncated to fit only the flag's bounds +SetEventFlagValue: ; ca92 (3:4a92) push hl push bc - call GetEventFlagMod - ld a, [wd3d1] + call GetEventFlag + ld a, [wLoadedFlagBits] .asm_ca9a bit 0, a jr nz, .asm_caa4 @@ -1450,10 +1454,10 @@ ModifyEventFlags: ; ca92 (3:4a92) sla c jr .asm_ca9a .asm_caa4 - ld a, [wd3d1] + ld a, [wLoadedFlagBits] and c ld c, a - ld a, [wd3d1] + ld a, [wLoadedFlagBits] cpl and [hl] or c @@ -1481,20 +1485,20 @@ Func_cab3: ; cab3 (3:4ab3) INCROM $cac2, $cac5 -SetEventFlags: ; cac5 (3:4ac5) +MaxOutEventFlag: ; cac5 (3:4ac5) push bc ld c, $ff - call ModifyEventFlags + call SetEventFlagValue pop bc ret ; 0xcacd INCROM $cacd, $cad0 -Func_cad0: ; cad0 (3:4ad0) +ZeroOutEventFlag: ; cad0 (3:4ad0) push bc ld c, $0 - call ModifyEventFlags + call SetEventFlagValue pop bc ret @@ -1505,7 +1509,7 @@ Func_cad8: ; cad8 (3:4ad8) ld bc, $0008 .asm_cae0 ld a, [hli] - call CheckIfEventFlagSet + call GetEventFlagValue jr z, .asm_cae7 inc b @@ -1545,7 +1549,8 @@ Func_cad8: ; cad8 (3:4ad8) INCROM $cb15, $cb1d -GetEventFlagMod: ; cb1d (3:4b1d) +; returns wEventFlags byte in hl, related bits in wLoadedFlagBits +GetEventFlag: ; cb1d (3:4b1d) push bc ld c, a ld b, $0 @@ -1556,7 +1561,7 @@ GetEventFlagMod: ; cb1d (3:4b1d) ld a, [hli] ld c, a ld a, [hl] - ld [wd3d1], a + ld [wLoadedFlagBits], a ld b, $0 ld hl, wEventFlags add hl, bc @@ -1565,7 +1570,61 @@ GetEventFlagMod: ; cb1d (3:4b1d) ; offset - bytes to set or reset EventFlagMods: ; cb37 (3:4b37) - INCROM $cb37, $cc32 + const_def + flag_def EVENT_FLAG_00, $3f, %10000000 + flag_def EVENT_FLAG_01, $3f, %01000000 + flag_def EVENT_FLAG_02, $3f, %00100000 + flag_def EVENT_FLAG_03, $3f, %00010000 + flag_def EVENT_FLAG_04, $3f, %00001000 + flag_def EVENT_FLAG_05, $3f, %00000100 + flag_def EVENT_FLAG_06, $3f, %00000010 + flag_def EVENT_FLAG_07, $3f, %00000001 + flag_def EVENT_FLAG_08, $00, %10000000 + flag_def EVENT_FLAG_09, $00, %01000000 + flag_def EVENT_FLAG_0A, $00, %00100000 + flag_def EVENT_BEAT_AMY, $00, %00010000 + flag_def EVENT_FLAG_0C, $00, %00001000 + flag_def EVENT_FLAG_0D, $00, %00000100 + flag_def EVENT_FLAG_0E, $00, %00000010 + flag_def EVENT_FLAG_0F, $00, %00000001 + flag_def EVENT_FLAG_10, $00, %11111111 + flag_def EVENT_FLAG_11, $01, %11110000 + flag_def EVENT_FLAG_12, $01, %00001111 + flag_def EVENT_FLAG_13, $02, %11000000 + flag_def EVENT_FLAG_14, $02, %00110000 + flag_def EVENT_BEAT_SARA, $02, %00001000 + flag_def EVENT_BEAT_AMANDA, $02, %00000100 + flag_def EVENT_FLAG_17, $03, %11110000 + flag_def EVENT_FLAG_18, $03, %00001111 + flag_def EVENT_FLAG_19, $04, %11110000 + flag_def EVENT_FLAG_1A, $04, %00001111 + flag_def EVENT_FLAG_1B, $05, %10000000 + flag_def EVENT_FLAG_1C, $05, %01000000 + flag_def EVENT_FLAG_1D, $05, %00100000 + flag_def EVENT_FLAG_1E, $05, %00010000 + flag_def EVENT_FLAG_1F, $05, %00001111 + flag_def EVENT_FLAG_20, $06, %11110000 + flag_def EVENT_FLAG_21, $06, %00001100 + flag_def EVENT_FLAG_22, $06, %00000010 + flag_def EVENT_FLAG_23, $06, %00000001 + flag_def EVENT_FLAG_24, $07, %11000000 + flag_def EVENT_FLAG_25, $07, %00100000 + flag_def EVENT_FLAG_26, $07, %00010000 + flag_def EVENT_FLAG_27, $07, %00001000 + flag_def EVENT_FLAG_28, $07, %00000100 + flag_def EVENT_FLAG_29, $07, %00000010 + flag_def EVENT_FLAG_2A, $07, %00000001 + flag_def EVENT_FLAG_2B, $08, %11111111 + flag_def EVENT_FLAG_2C, $09, %11100000 + flag_def EVENT_FLAG_2D, $09, %00011111 + flag_def EVENT_FLAG_2E, $0a, %11110000 + flag_def EVENT_FLAG_2F, $0a, %00001000 + flag_def EVENT_FLAG_30, $0a, %00000100 + flag_def EVENT_FLAG_31, $0a, %00000011 + flag_def EVENT_FLAG_32, $0b, %10000000 + flag_def EVENT_JOSHUA_STATE, $0b, %01110000 + + INCROM $cb9f, $cc32 Func_cc32: ; cc32 (3:4c32) push hl @@ -1669,14 +1728,14 @@ GetOWSArgsAfterPointer: ; cca0 (3:4ca0) or b ret -Func_ccb3: ; ccb3 (3:4cb3) +SetScriptControlBytePass: ; ccb3 (3:4cb3) ld a, $ff - ld [wd415], a + ld [wScriptControlByte], a ret -Func_ccb9: ; ccb9 (3:4cb9) +SetScriptControlByteFail: ; ccb9 (3:4cb9) xor a - ld [wd415], a + ld [wScriptControlByte], a ret OWScript_EndScriptLoop1: ; ccbe (3:4cbe) @@ -1693,12 +1752,12 @@ OWScript_EndScriptLoop10: ; ccbe (3:4cbe) ld [wBreakOWScriptLoop], a jp IncreaseOWScriptPointerBy1 -OWScript_CloseTextBox: ; ccc6 (3:4cc6) - call CloseDialogueBox +OWScript_CloseAdvancedTextBox: ; ccc6 (3:4cc6) + call CloseAdvancedDialogueBox jp IncreaseOWScriptPointerBy1 OWScript_EndScriptCloseText: ; cccc (3:4ccc) - call OWScript_CloseTextBox + call OWScript_CloseAdvancedTextBox call OWScript_EndScriptLoop1 pop hl ret @@ -1726,7 +1785,7 @@ OWScript_AskQuestionJump: ; cce9 (3:4ce9) ld h, b call Func_c8ed ld a, [hCurMenuItem] - ld [wd415], a + ld [wScriptControlByte], a jr c, .asm_ccfe call GetOWSArgs3AfterPointer jr z, .asm_ccfe @@ -1802,12 +1861,13 @@ Func_cd76: ; cd76 (3:4d76) set 6, [hl] jp IncreaseOWScriptPointerBy1 -Func_cd83: ; cd83 (3:4d83) - ld a, [wd415] +; prints text arg 1 or arg 2 depending on wScriptControlByte. +OWScript_PrintVariableText: ; cd83 (3:4d83) + ld a, [wScriptControlByte] or a - jr nz, .asm_cd8c + jr nz, .printText call GetOWSArgs3AfterPointer -.asm_cd8c +.printText ld l, c ld h, b call Func_cc32 @@ -1828,7 +1888,7 @@ Unknown_cd98: jp IncreaseOWScriptPointerBy7 Func_cda8: ; cda8 (3:4da8) - ld a, [wd415] + ld a, [wScriptControlByte] or a jr nz, .asm_cdb1 call GetOWSArgs3AfterPointer @@ -1842,7 +1902,7 @@ OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) ld l, c ld h, b call Func_cc32 - call CloseDialogueBox + call CloseAdvancedDialogueBox ld a, $1 ld [wBreakOWScriptLoop], a call IncreaseOWScriptPointerBy3 @@ -1950,8 +2010,8 @@ Func_ce6f: ; ce6f (3:4e6f) pop af jr asm_ce5d -Func_ce84: ; ce84 (3:4e84) - call Func_c135 +OWScript_CloseTextBox: ; ce84 (3:4e84) + call CloseTextBox jp IncreaseOWScriptPointerBy1 ; args: booster pack index, booster pack index, booster pack index @@ -2041,11 +2101,11 @@ asm_cf16 jr nz, asm_cf1f asm_cf19 - call Func_ccb9 + call SetScriptControlByteFail jp IncreaseOWScriptPointerBy4 asm_cf1f - call Func_ccb3 + call SetScriptControlBytePass call GetOWSArgs2AfterPointer jr z, asm_cf2a jp SetOWScriptPointer @@ -2099,11 +2159,11 @@ Func_cf53: ; cf53 (3:4f53) or a jr nz, Func_cf6d Func_cf67: ; cf67 (3:4f67) - call Func_ccb9 + call SetScriptControlByteFail jp IncreaseOWScriptPointerBy3 Func_cf6d: ; cf6d (3:4f6d) - call Func_ccb3 + call SetScriptControlBytePass call GetOWSArgs1AfterPointer jr z, .asm_cf78 jp SetOWScriptPointer @@ -2249,7 +2309,7 @@ Func_d03f: ; d03f (3:503f) call RemoveCardFromCollection jp IncreaseOWScriptPointerBy1 -OWScript_ScriptJump: ; d049 (3:5049) +OWScript_Jump: ; d049 (3:5049) call GetOWSArgs1AfterPointer jp SetOWScriptPointer @@ -2285,6 +2345,8 @@ OWScript_SetDialogName: ; d080 (3:5080) farcall SetNPCDialogName jp IncreaseOWScriptPointerBy2 +; Calls another OWSequence with a specified NPC +; Not confident enough to give it a name yet Func_d088: ; d088 (3:5088) ld a, c ld [wd3ab], a @@ -2341,20 +2403,20 @@ Func_d0d9: ; d0d9 (3:50d9) farcall Func_1c477 ld a, e cp c - jp nz, Func_d48a + jp nz, ScriptEventFailedNoJump ld a, d cp b - jp nz, Func_d48a - jp Func_d490 + jp nz, ScriptEventFailedNoJump + jp ScriptEventPassedTryJump Func_d0f2: ; d0f2 (3:50f2) ld a, [wPlayerXCoord] cp c - jp nz, Func_d48a + jp nz, ScriptEventFailedNoJump ld a, [wPlayerYCoord] cp b - jp nz, Func_d48a - jp Func_d490 + jp nz, ScriptEventFailedNoJump + jp ScriptEventPassedTryJump Func_d103: ; d103 (3:5103) ld a, [wd3aa] @@ -2507,7 +2569,7 @@ Func_d209: ; d209 (3:5209) ld hl, $5240 add hl, bc ld a, [hl] - call SetEventFlags + call MaxOutEventFlag pop bc ld hl, $5234 ld a, c @@ -2726,9 +2788,9 @@ Func_d3b9: ; d3b9 (3:53b9) set 6, [hl] jp IncreaseOWScriptPointerBy1 -Func_d3c9: ; d3c9 (3:53c9) +OWScript_GivePCPack: ; d3c9 (3:53c9) ld a, c - farcall Func_10a70 + farcall GivePCPack jp IncreaseOWScriptPointerBy2 Func_d3d1: ; d3d1 (3:53d1) @@ -2803,119 +2865,126 @@ Func_d43d: ; d43d (3:543d) set 6, [hl] jp IncreaseOWScriptPointerBy1 -OWScript_CustomModifyEventFlags: ; d44a (3:544a) +; sets the event flag in arg 1 to the value in arg 2 +OWScript_SetFlagValue: ; d44a (3:544a) ld a, c ld c, b - call ModifyEventFlags + call SetEventFlagValue jp IncreaseOWScriptPointerBy3 -Func_d452: ; d452 (3:5452) +OWScript_IncrementFlagValue: ; d452 (3:5452) ld a, c push af - call CheckIfEventFlagSet + call GetEventFlagValue inc a ld c, a pop af - call ModifyEventFlags + call SetEventFlagValue jp IncreaseOWScriptPointerBy2 -Func_d460: ; d460 (3:5460) +OWScript_JumpIfFlagZero1: ; d460 (3:5460) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, asm_d46d -asm_d467 - call Func_ccb9 + jr z, OWScript_JumpIfFlagZero1.passTryJump + +.fail + call SetScriptControlByteFail ; 0 out wScriptControlByte jp IncreaseOWScriptPointerBy4 -asm_d46d - call Func_ccb3 +.passTryJump + call SetScriptControlBytePass ; ff wScriptControlByte call GetOWSArgs2AfterPointer - jr z, .asm_d478 + jr z, .noJumpTarget jp SetOWScriptPointer -.asm_d478 +.noJumpTarget jp IncreaseOWScriptPointerBy4 -OWScript_JumpIfFlagSet: ; d47b (3:547b) +OWScript_JumpIfFlagNonzero1: ; d47b (3:547b) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr nz, asm_d46d - jr asm_d467 + jr nz, OWScript_JumpIfFlagZero1.passTryJump + jr OWScript_JumpIfFlagZero1.fail -Func_d484: ; d484 (3:5484) - call Func_d4b6 +; args - event flag, value, jump address +OWScript_JumpIfFlagEqual: ; d484 (3:5484) + call GetEventFlagValueBC cp c - jr z, Func_d490 + jr z, ScriptEventPassedTryJump -Func_d48a: ; d48a (3:548a) - call Func_ccb9 +ScriptEventFailedNoJump ; d48a (3:548a) + call SetScriptControlByteFail jp IncreaseOWScriptPointerBy5 -Func_d490: ; d490 (3:5490) - call Func_ccb3 +ScriptEventPassedTryJump ; d490 (3:5490) + call SetScriptControlBytePass call GetOWSArgs3AfterPointer - jr z, .asm_d49b + jr z, .noJumpAddress jp SetOWScriptPointer -.asm_d49b +.noJumpAddress jp IncreaseOWScriptPointerBy5 -Func_d49e: ; d49e (3:549e) - call Func_d4b6 +OWScript_JumpIfFlagNotEqual: ; d49e (3:549e) + call GetEventFlagValueBC cp c - jr nz, Func_d490 - jr Func_d48a + jr nz, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4a6: ; d4a6 (3:54a6) - call Func_d4b6 +OWScript_JumpIfFlagNotLessThan: ; d4a6 (3:54a6) + call GetEventFlagValueBC cp c - jr nc, Func_d490 - jr Func_d48a + jr nc, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4ae: ; d4ae (3:54ae) - call Func_d4b6 +OWScript_JumpIfFlagLessThan: ; d4ae (3:54ae) + call GetEventFlagValueBC cp c - jr c, Func_d490 ; 0xd4b2 $dc - jr Func_d48a ; 0xd4b4 $d4 + jr c, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4b6: ; d4b6 (3:54b6) +; Gets event flag at c (OWScript defaults) +; c takes on the value of b as a side effect +GetEventFlagValueBC: ; d4b6 (3:54b6) ld a, c ld c, b - call CheckIfEventFlagSet + call GetEventFlagValue ret -OWScript_SetEventFlags: ; d4bc (3:54bc) +OWScript_MaxOutFlagValue: ; d4bc (3:54bc) ld a, c - call SetEventFlags + call MaxOutEventFlag jp IncreaseOWScriptPointerBy2 -Func_d4c3: ; d4c3 (3:54c3) +OWScript_ZeroOutFlagValue: ; d4c3 (3:54c3) ld a, c - call Func_cad0 + call ZeroOutEventFlag jp IncreaseOWScriptPointerBy2 -Func_d4ca: ; d4ca (3:54ca) +OWScript_JumpIfFlagNonzero2: ; d4ca (3:54ca) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, asm_d4e6 -Func_d4d1: - call Func_ccb3 + jr z, OWScript_JumpIfFlagZero2.fail + +.passTryJump: + call SetScriptControlBytePass call GetOWSArgs2AfterPointer - jr z, .asm_d4dc + jr z, .noJumpArgs jp SetOWScriptPointer -.asm_d4dc +.noJumpArgs jp IncreaseOWScriptPointerBy4 -OWScript_JumpIfFlagNotSet: +OWScript_JumpIfFlagZero2: ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, Func_d4d1 -asm_d4e6 - call Func_ccb9 + jr z, OWScript_JumpIfFlagNonzero2.passTryJump + +.fail + call SetScriptControlByteFail jp IncreaseOWScriptPointerBy4 ; 0xd4ec @@ -2970,9 +3039,9 @@ OWSequence_d753: ; d753 (3:5753) db $02 run_script OWScript_PrintTextString tx Text05e3 - run_script OWScript_CloseTextBox - run_script Func_d088 ; run OWSequence with given npc (ID corresponds to a row in the wd34a table, i dont know why they correspond to what number though) - db $07 + run_script OWScript_CloseAdvancedTextBox + run_script Func_d088 + db SAM dw OWSequence_d779 run_script OWScript_EndScriptLoop1 ret @@ -2988,7 +3057,7 @@ OWSequence_d779: ; d779 (03:5779) db DRMASON run_script OWScript_PrintTextString tx Text05e5 - run_script Func_ce84 + run_script OWScript_CloseTextBox run_script Func_ce4a db $82 db $58 @@ -2996,7 +3065,7 @@ OWSequence_d779: ; d779 (03:5779) db $01 run_script Func_d055 db $03 - run_script OWScript_CloseTextBox + run_script OWScript_CloseAdvancedTextBox run_script Func_d088 db $01 db $94 @@ -3024,21 +3093,25 @@ WaterClubAfterDuel: ;e157 (3:6157) ret .after_duel_table - dw $1f1f + db SARA + db SARA dw OWSequence_BeatSara dw OWSequence_LostToSara - dw $2020 + db AMANDA + db AMANDA dw OWSequence_BeatAmanda dw OWSequence_LostToAmanda - dw $2121 - dw $626c - dw $6260 + db JOSHUA + db JOSHUA + dw OWSequence_BeatJoshua + dw OWSequence_LostToJoshua - dw $2222 - dw $6322 - dw $6344 + db AMY + db AMY + dw OWSequence_BeatAmy + dw OWSequence_LostToAmy db $00 OWSequence_Sara: ; e177 (3:6177) @@ -3055,14 +3128,14 @@ OWSequence_Sara: ; e177 (3:6177) run_script OWScript_PrintTextString tx Text042f run_script OWScript_StartBattle - db 2 + db PRIZES_2 db WATERFRONT_POKEMON_DECK_ID ; 6189 db MUSIC_DUEL_THEME_1 run_script OWScript_EndScriptCloseText OWSequence_BeatSara: ; e18c (3:618c) start_script - run_script OWScript_SetEventFlags + run_script OWScript_MaxOutFlagValue db EVENT_BEAT_SARA run_script OWScript_PrintTextString tx Text0430 @@ -3093,14 +3166,14 @@ OWSequence_Amanda: ; e19e (03:619e) run_script OWScript_PrintTextString tx Text0436 run_script OWScript_StartBattle - db 03 + db PRIZES_3 db LONELY_FRIENDS_DECK_ID db MUSIC_DUEL_THEME_1 run_script OWScript_EndScriptCloseText OWSequence_BeatAmanda: ; e1b3 (03:61b3) start_script - run_script OWScript_SetEventFlags + run_script OWScript_MaxOutFlagValue db EVENT_BEAT_AMANDA run_script OWScript_PrintTextString tx Text0437 @@ -3118,41 +3191,332 @@ OWSequence_LostToAmanda: ; e1c1 (03:61c1) tx Text0439 OWSequence_NotReadyToSeeAmy: - INCROM $e1c5, $e21c + start_script + run_script Func_d0f2 + db $12 + db $08 + dw $61ec + run_script Func_d0f2 + db $14 + db $08 + dw $61f2 + run_script Func_d0f2 + db $18 + db $08 + dw $61f8 + run_script OWScript_MovePlayer + db $02 + db $04 + run_script Func_ce4a + db $13 + db $62 + run_script OWScript_PrintTextString + tx Text043a + run_script Func_d0f2 + db $12 + db $0a + dw $61fe + run_script Func_d0f2 + db $14 + db $0a + dw $6202 + run_script Func_ce4a + db $15 + db $62 + run_script OWScript_EndScriptCloseText + +.ows_e1ec + run_script Func_ce4a + db $06 + db $62 + run_script OWScript_Jump + dw $61d5 + run_script Func_ce4a + db $0b + db $62 + run_script OWScript_Jump + dw $61d5 + run_script Func_ce4a + db $0f + db $62 + run_script OWScript_Jump + dw $61d5 + run_script Func_ce4a + db $18 + db $62 + run_script OWScript_EndScriptCloseText +; 0xe202 + + INCROM $e202, $e21c OWSequence_Joshua: start_script - run_script OWScript_JumpIfFlagNotSet + run_script OWScript_JumpIfFlagZero2 db EVENT_BEAT_AMANDA dw .sara_and_amanda_not_beaten - run_script OWScript_JumpIfFlagNotSet + run_script OWScript_JumpIfFlagZero2 db EVENT_BEAT_SARA dw .sara_and_amanda_not_beaten - run_script OWScript_ScriptJump + run_script OWScript_Jump dw .beat_sara_and_amanda .sara_and_amanda_not_beaten - run_script OWScript_CustomModifyEventFlags - db $33 ; offset on flagmod table - db $01 ; the control bit + run_script OWScript_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED run_script OWScript_PrintTextString tx Text043b run_script OWScript_EndScriptCloseText + .beat_sara_and_amanda - run_script OWScript_JumpIfFlagSet - db $33 - dw $623c - run_script OWScript_CustomModifyEventFlags - db $33 - db $01 + run_script OWScript_JumpIfFlagNonzero1 + db EVENT_JOSHUA_STATE + dw .already_talked + run_script OWScript_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED run_script OWScript_PrintTextString tx Text043b run_script OWScript_PrintTextString tx Text043c - run_script Func_d484 - db $33 +.already_talked + run_script OWScript_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text043d + tx Text043e + run_script OWScript_AskQuestionJump + tx Text043f + dw .startDuel + run_script OWScript_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0440 + tx Text0441 + run_script OWScript_EndScriptCloseText + +.startDuel: + run_script OWScript_PrintTextString + tx Text0442 + run_script OWScript_GivePCPack + db $04 + run_script OWScript_StartBattle + db PRIZES_4 + db SOUND_OF_THE_WAVES_DECK_ID + db MUSIC_DUEL_THEME_1 + run_script OWScript_EndScriptCloseText + +OWSequence_LostToJoshua: ; e260 (3:6260) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0443 + tx Text0444 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatJoshua: ; e26c (3:626c) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0445 + tx Text0446 + run_script OWScript_GiveBoosterPacks + db BOOSTER_MYSTERY_WATER_COLORLESS + db BOOSTER_MYSTERY_WATER_COLORLESS + db NO_BOOSTER + run_script OWScript_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0447 + tx Text0448 + run_script OWScript_JumpIfFlagNotEqual + db EVENT_JOSHUA_STATE + db JOSHUA_BEATEN + dw .firstJoshuaWin + run_script OWScript_EndScriptCloseText + +.firstJoshuaWin: + run_script OWScript_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_BEATEN + run_script OWScript_PrintTextString + tx Text0449 + run_script OWScript_CloseTextBox + run_script Func_ce26 + dw $62a1 + run_script OWScript_PrintTextString + tx Text044a + run_script Func_cfc6 + db $00 + run_script OWScript_CloseAdvancedTextBox + run_script Func_d088 + db AMY + dw OWSequence_MeetAmy + run_script OWScript_EndScriptLoop1 +; 0xe2a0 + + INCROM $e2a0, $e2d1 + +OWSequence_MeetAmy: ; e2d1 (3:62d1) + start_script + run_script OWScript_PrintTextString + tx Text044b + run_script OWScript_SetDialogName + db JOSHUA + run_script OWScript_PrintTextString + tx Text044c + run_script OWScript_SetDialogName + db AMY + run_script OWScript_PrintTextString + tx Text044d + run_script OWScript_CloseTextBox + run_script Func_d095 + db $09 + db $2f + db $10 + run_script OWScript_DoFrames + db $20 + run_script Func_d095 + db $04 + db $0e + db $00 + run_script Func_d0be + db $14 + db $04 + run_script Func_d055 + db $03 + run_script OWScript_MovePlayer + db $03 db $01 + run_script Func_d055 + db $00 + run_script OWScript_MovePlayer + db $00 + db $01 + run_script OWScript_MovePlayer + db $00 + db $01 + run_script Func_ce6f + db $21 + db $ab + db $62 + run_script OWScript_PrintTextString + tx Text044e + run_script OWScript_Jump + dw OWSequence_Amy.askConfirmDuel + +OWSequence_Amy: ; e304 (3:6304) + start_script + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_BEAT_AMY + dw OWJump_TalkToAmyAgain + run_script OWScript_PrintTextString + tx Text044f +.askConfirmDuel + run_script OWScript_AskQuestionJump + tx Text0450 + dw .startDuel + +.denyDuel + run_script OWScript_PrintTextString + tx Text0451 + run_script Func_d0d9 + db $14 + db $04 + dw OWSequence_LostToAmy.ows_e34e + run_script OWScript_EndScriptCloseText + +.startDuel + run_script OWScript_PrintTextString + tx Text0452 + run_script OWScript_StartBattle + db PRIZES_6 + db GO_GO_RAIN_DANCE_DECK_ID + db MUSIC_DUEL_THEME_2 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatAmy: ; e322 (3:6322) + start_script + run_script OWScript_PrintTextString + tx Text0453 + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_BEAT_AMY + dw .beatAmyCommon + run_script OWScript_PrintTextString + tx Text0454 + run_script OWScript_MaxOutFlagValue + db EVENT_BEAT_AMY + run_script Func_d04f + run_script Func_d125 + db EVENT_BEAT_AMY + run_script Func_d435 + db $03 + run_script OWScript_PrintTextString + tx Text0455 +.beatAmyCommon + run_script OWScript_GiveBoosterPacks + db BOOSTER_LABORATORY_WATER + db BOOSTER_LABORATORY_WATER + db NO_BOOSTER + run_script OWScript_PrintTextString + tx Text0456 + run_script Func_d0d9 + db $14 + db $04 + dw OWSequence_LostToAmy.ows_e34e + run_script OWScript_EndScriptCloseText + +OWSequence_LostToAmy: ; e344 (3:6344) + start_script + run_script OWScript_PrintTextString + tx Text0457 + run_script Func_d0d9 + db $14 + db $04 + dw .ows_e34e + run_script OWScript_EndScriptCloseText + +.ows_e34e + run_script Func_d095 + db $08 + db $2e + db $10 + run_script Func_d0be + db $16 + db $04 + run_script OWScript_EndScriptCloseText + +OWJump_TalkToAmyAgain: ; e356 (3:6356) + run_script OWScript_PrintTextString + tx Text0458 + run_script OWScript_AskQuestionJump + tx Text0450 + dw .startDuel + run_script OWScript_Jump + dw OWSequence_Amy.denyDuel + +.startDuel + run_script OWScript_PrintTextString + tx Text0459 + run_script OWScript_StartBattle + db PRIZES_6 + db GO_GO_RAIN_DANCE_DECK_ID + db MUSIC_DUEL_THEME_2 + run_script OWScript_EndScriptCloseText +; 0xe369 - INCROM $e23f, $e52c + INCROM $e369, $e52c FindEndOfBattleScript: ; e52c (3:652c) ld c, $0 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 2ebb399..0c91398 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -239,38 +239,39 @@ Func_10548: ; 10548 (4:4548) Func_10756: ; 10756 (4:4756) INCROM $10756, $10a70 -Func_10a70: ; 10a70 (4:4a70) +; gives the pc pack described in a +GivePCPack: ; 10a70 (4:4a70) push hl push bc push de ld b, a - ld c, $f + ld c, $f ; number of packs possible ld hl, wPCPacks -.asm_10a79 +.searchLoop1 ld a, [hli] and $7f cp b - jr z, .asm_10a97 + jr z, .quit dec c - jr nz, .asm_10a79 + jr nz, .searchLoop1 ld c, $f ld hl, wPCPacks -.asm_10a87 +.findFreeSlotLoop ld a, [hl] and $7f - jr z, .asm_10a93 + jr z, .foundFreeSlot inc hl dec c - jr nz, .asm_10a87 + jr nz, .findFreeSlotLoop debug_ret - jr .asm_10a97 + jr .quit -.asm_10a93 +.foundFreeSlot ld a, b - or $80 + or $80 ; mark pack as unopened ld [hl], a -.asm_10a97 +.quit pop de pop bc pop hl @@ -332,7 +333,7 @@ Func_10dba: ; 10dba (4:4dba) push af ld hl, $4df0 call JumpToFunctionInTable - farcall Func_c135 + farcall CloseTextBox call DoFrameIfLCDEnabled pop af ret @@ -457,7 +458,7 @@ Func_10f4a: ; 10f4a (4:4f4a) jr nz, .asm_10f5f ld c, a ld a, $1e - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a ld a, c jr nz, .asm_10f5f @@ -530,7 +531,7 @@ Func_10fde: ; 10fde (4:4fde) ld [wd33c], a call Func_12ab5 ld a, $3e - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a jr nz, .asm_11015 ld c, SPRITE_ANIM_FIELD_0F @@ -969,17 +970,17 @@ Func_11f4e: ; 11f4e (4:5f4e) OverworldScriptTable: ; 1217b (4:617b) dw OWScript_EndScriptLoop1 - dw OWScript_CloseTextBox + dw OWScript_CloseAdvancedTextBox dw OWScript_PrintTextString dw Func_ccdc dw OWScript_AskQuestionJump dw OWScript_StartBattle - dw Func_cd83 + dw OWScript_PrintVariableText dw Func_cda8 dw OWScript_PrintTextCloseBox dw Func_cdcb dw Func_ce26 - dw Func_ce84 + dw OWScript_CloseTextBox dw OWScript_GiveBoosterPacks dw Func_cf0c dw Func_cf12 @@ -995,7 +996,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d025 dw Func_d032 dw Func_d03f - dw OWScript_ScriptJump + dw OWScript_Jump dw Func_d04f dw Func_d055 dw OWScript_MovePlayer @@ -1034,7 +1035,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_cd76 dw Func_d39d dw Func_d3b9 - dw Func_d3c9 + dw OWScript_GivePCPack dw Func_d3d1 dw Func_d3d4 dw Func_d3e0 @@ -1056,18 +1057,18 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_EndScriptLoop4 dw OWScript_EndScriptLoop5 dw OWScript_EndScriptLoop6 - dw OWScript_CustomModifyEventFlags - dw Func_d460 - dw OWScript_JumpIfFlagSet - dw Func_d484 - dw Func_d49e - dw Func_d4a6 - dw Func_d4ae - dw OWScript_SetEventFlags - dw Func_d4c3 - dw Func_d4ca - dw OWScript_JumpIfFlagNotSet - dw Func_d452 + dw OWScript_SetFlagValue + dw OWScript_JumpIfFlagZero1 + dw OWScript_JumpIfFlagNonzero1 + dw OWScript_JumpIfFlagEqual + dw OWScript_JumpIfFlagNotEqual + dw OWScript_JumpIfFlagNotLessThan + dw OWScript_JumpIfFlagLessThan + dw OWScript_MaxOutFlagValue + dw OWScript_ZeroOutFlagValue + dw OWScript_JumpIfFlagNonzero2 + dw OWScript_JumpIfFlagZero2 + dw OWScript_IncrementFlagValue dw OWScript_EndScriptLoop7 dw OWScript_EndScriptLoop8 dw OWScript_EndScriptLoop9 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index ecc281d..25534f1 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -256,7 +256,22 @@ Func_1c58e: ; 1c58e (7:458e) INCROM $1c5b9, $1c5e9 Func_1c5e9: ; 1c5e9 (7:45e9) - INCROM $1c5e9, $1c610 + push hl + push bc + ld a, [wd3aa] + ld l, $07 + call Func_39ad + ld a, [hl] + ld bc, $fffd + add hl, bc + ld [hl], a + call Func_1c58e + pop bc + pop hl + ret +; 0x1c5ff + + INCROM $1c5ff, $1c610 Func_1c610: ; 1c610 (7:4610) INCROM $1c610, $1c6f8 diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 7b5cbc5..7fa5bf4 100644 --- a/src/engine/bank1c.asm +++ b/src/engine/bank1c.asm @@ -4,7 +4,7 @@ Func_70000: ; 70000 (1c:4000) ret nz ld b, $1 ld a, $22 - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a jr z, .asm_70013 ld b, $2 @@ -294,7 +294,7 @@ Func_70214: ; 70214 (1c:4214) ret nz ld hl, Unknown_7024a ld a, $10 - farcall CheckIfEventFlagSet + farcall GetEventFlagValue ld c, $8 .asm_70227 push bc diff --git a/src/engine/home.asm b/src/engine/home.asm index 450d9c1..62eaa62 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1586,7 +1586,7 @@ Func_08ef: ; 08ef (0:08ef) ld hl, wcadc ld a, [hl] or a - jr z, .asm_902 ; for the purpose of this, we made it 0 earlier + jr z, .asm_902 dec [hl] inc hl .asm_8f8 @@ -1605,9 +1605,9 @@ Func_08ef: ; 08ef (0:08ef) ld c, [hl] inc hl ld b, [hl] - inc hl ; get pointer from wcad6/7 - dec [hl] ; dec wcad8 (was 1) - inc hl ; wcad9 + inc hl + dec [hl] + inc hl jr nz, .asm_914 dec hl ld [hl], $8 @@ -10803,7 +10803,7 @@ GameEvent_Credits: ; 3911 (0:3911) Func_3917: ; 3917 (0:3917) ld a, $22 - farcall CheckIfEventFlagSet + farcall GetEventFlagValue call EnableSRAM ld [s0a00a], a call DisableSRAM diff --git a/src/macros/constants.asm b/src/macros/constants.asm index 177fcd6..c841972 100644 --- a/src/macros/constants.asm +++ b/src/macros/constants.asm @@ -10,3 +10,10 @@ const: MACRO \1 EQU const_value const_value = const_value + 1 ENDM + +flag_def: MACRO +\1 EQU const_value +const_value = const_value + 1 +db \2 +db \3 +ENDM diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 2fa15fb..2bf40e4 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -15,17 +15,17 @@ ENDM const_def const OWScript_EndScriptLoop1_index ; $00 - const OWScript_CloseTextBox_index ; $01 + const OWScript_CloseAdvancedTextBox_index ; $01 const OWScript_PrintTextString_index ; $02 const Func_ccdc_index ; $03 const OWScript_AskQuestionJump_index ; $04 const OWScript_StartBattle_index ; $05 - const Func_cd83_index ; $06 + const OWScript_PrintVariableText_index ; $06 const Func_cda8_index ; $07 const OWScript_PrintTextCloseBox_index ; $08 const Func_cdcb_index ; $09 const Func_ce26_index ; $0a - const Func_ce84_index ; $0b + const OWScript_CloseTextBox_index ; $0b const OWScript_GiveBoosterPacks_index ; $0c const Func_cf0c_index ; $0d const Func_cf12_index ; $0e @@ -41,7 +41,7 @@ ENDM const Func_d025_index ; $18 const Func_d032_index ; $19 const Func_d03f_index ; $1a - const OWScript_ScriptJump_index ; $1b + const OWScript_Jump_index ; $1b const Func_d04f_index ; $1c const Func_d055_index ; $1d const OWScript_MovePlayer_index ; $1e @@ -80,7 +80,7 @@ ENDM const Func_cd76_index ; $3f const Func_d39d_index ; $40 const Func_d3b9_index ; $41 - const Func_d3c9_index ; $42 + const OWScript_GivePCPack_index ; $42 const Func_d3d1_index ; $43 const Func_d3d4_index ; $44 const Func_d3e0_index ; $45 @@ -102,18 +102,18 @@ ENDM const OWScript_EndScriptLoop4_index ; $55 const OWScript_EndScriptLoop5_index ; $56 const OWScript_EndScriptLoop6_index ; $57 - const OWScript_CustomModifyEventFlags_index ; $58 - const Func_d460_index ; $59 - const OWScript_JumpIfFlagSet_index ; $5a - const Func_d484_index ; $5b - const Func_d49e_index ; $5c - const Func_d4a6_index ; $5d - const Func_d4ae_index ; $5e - const OWScript_SetEventFlags_index ; $5f - const Func_d4c3_index ; $60 - const Func_d4ca_index ; $61 - const OWScript_JumpIfFlagNotSet_index ; $62 - const Func_d452_index ; $63 + const OWScript_SetFlagValue_index ; $58 + const OWScript_JumpIfFlagZero1_index ; $59 + const OWScript_JumpIfFlagNonzero1_index ; $5a + const OWScript_JumpIfFlagEqual_index ; $5b + const OWScript_JumpIfFlagNotEqual_index ; $5c + const OWScript_JumpIfFlagNotLessThan_index ; $5d + const OWScript_JumpIfFlagLessThan_index ; $5e + const OWScript_MaxOutFlagValue_index ; $5f + const OWScript_ZeroOutFlagValue_index ; $60 + const OWScript_JumpIfFlagNonzero2_index ; $61 + const OWScript_JumpIfFlagZero2_index ; $62 + const OWScript_IncrementFlagValue_index ; $63 const OWScript_EndScriptLoop7_index ; $64 const OWScript_EndScriptLoop8_index ; $65 const OWScript_EndScriptLoop9_index ; $66 diff --git a/src/wram.asm b/src/wram.asm index 7ae9e59..a689451 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1885,9 +1885,7 @@ wPCPackSelection:: ; d11d ; 7th bit of each pack corresponds to whether or not it's been read wPCPacks:: ; d11e - ds $c - - ds $3 + ds $f wPCLastDirectionPressed:: ; d12d ds $1 @@ -2122,7 +2120,8 @@ wd3bb:: ; d3bb wd3d0:: ; d3d0 ds $1 -wd3d1:: ; d3d1 +; the bits relevant to the currently worked on flag, obtained from EventFlagMods +wLoadedFlagBits:: ; d3d1 ds $1 wEventFlags:: @@ -2138,7 +2137,8 @@ wBreakOWScriptLoop:: ; d412 wOWScriptPointer:: ; d413 ds $2 -wd415:: ; d415 +; generally set to ff when a flag check passes, 0 otherwise +wScriptControlByte:: ; d415 ds $1 wd416:: ; d416 -- cgit v1.2.3 From 1b2d7cbaa7aba718b8ef1e9ae0cbe1f349d673be Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Mon, 23 Sep 2019 12:37:41 -0400 Subject: Fix style, remove excess comments --- src/engine/bank03.asm | 4 ++-- src/engine/bank20.asm | 55 +++++++++++++++++++++++---------------------------- src/engine/home.asm | 22 ++++++++++----------- src/wram.asm | 1 - 4 files changed, 37 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index d7f3496..f873953 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -2889,11 +2889,11 @@ OWScript_JumpIfFlagZero1: ; d460 (3:5460) jr z, OWScript_JumpIfFlagZero1.passTryJump .fail - call SetScriptControlByteFail ; 0 out wScriptControlByte + call SetScriptControlByteFail jp IncreaseOWScriptPointerBy4 .passTryJump - call SetScriptControlBytePass ; ff wScriptControlByte + call SetScriptControlBytePass call GetOWSArgs2AfterPointer jr z, .noJumpTarget jp SetOWScriptPointer diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 967ffb0..1502ea4 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -2,7 +2,7 @@ Func_80000: ; 80000 (20:4000) INCROM $80000, $80028 Func_80028: ; 80028 (20:4028) - call Func_801f1 ; Clears the first x800 bytes of S1:a000 + call Func_801f1 ld bc, $0000 call Func_80077 farcall $3, $49c7 @@ -13,7 +13,6 @@ Func_80028: ; 80028 (20:4028) INCROM $8003d, $80077 -; loads the background it seems. Also includes background tile permissions? Func_80077: ; 80077 (20:4077) ld a, $1 ld [wd292], a @@ -26,30 +25,30 @@ Func_80077: ; 80077 (20:4077) push hl push bc push de - call BCCoordToBGMap0Address ; de + call BCCoordToBGMap0Address ld hl, wd4c2 ld [hl], e inc hl ld [hl], d - call Func_803b9 ; load more d4c* stuff from mapdatapointers + call Func_803b9 ld a, [wd4c6] - ld [wd23d], a ; copies the bank of the data we loaded to wd23d + ld [wd23d], a ld de, wd23e ld bc, $0006 - call CopyBankedDataToDE ; copies 6 bytes to wd23e+ + call CopyBankedDataToDE ld l, e - ld h, d ; then copies that data into various other places? + ld h, d ld a, [hli] - ld [wd12f], a ; just happens to correspond to size of room + ld [wd12f], a ld a, [hli] - ld [wd130], a ; hmmm + ld [wd130], a ld a, [hli] - ld [wd23a], a ; these 3 are before this data and after room collision + ld [wd23a], a ld a, [hli] ld [wd23b], a ld a, [hli] ld [wd23c], a - call Func_800bd ; moves the background data to some place vblank knows about + call Func_800bd pop de pop bc pop hl @@ -59,17 +58,17 @@ Func_800bd: ; 800bd (20:40bd) push hl push bc push de - ld a, [wd4c4] ; these are still the copy locations + ld a, [wd4c4] add $05 ld e, a ld a, [wd4c5] adc $00 - ld d, a ; de = [wd4c4/5] + 5 - ld b, $c0 ; b = c0 + ld d, a + ld b, $c0 call Func_08bf ld a, [wd4c2] ld e, a - ld a, [wd4c3] ; bg map coord from earlier + ld a, [wd4c3] ld d, a call Func_800e0 pop de @@ -77,7 +76,6 @@ Func_800bd: ; 800bd (20:40bd) pop hl ret -; de is a bg map coord Func_800e0: ; 800e0 (20:40e0) push hl ld hl, $d28e @@ -86,7 +84,7 @@ Func_800e0: ; 800e0 (20:40e0) ld a, [wd23c] or a jr z, .asm_800f0 - sla [hl] ; if wd23c is nonzero, double d28e + sla [hl] .asm_800f0 ld c, $40 ld hl, wd23e @@ -94,16 +92,16 @@ Func_800e0: ; 800e0 (20:40e0) .asm_800f6 ld [hli], a dec c - jr nz, .asm_800f6 ; clear out wd23e-40+ + jr nz, .asm_800f6 ld a, [wd130] ld c, a .asm_800fe - push bc ; push the height of this map - push de ; push the destination of this map + push bc + push de ld b, $00 ld a, [$d28e] - ld c, a ; bc is now the width - ld de, wd23e ; wd23e is the place we copied map data to (The 6 bytes) before + ld c, a + ld de, wd23e call Func_3be4 ld a, [wd12f] ld b, a @@ -287,18 +285,17 @@ GetMapDataPointer: ; 8020f (20:420f) ld c, [hl] inc hl ld b, [hl] - pop af ; bc = [MapDataPointers+l] + pop af ld l, a ld h, $0 sla l rl h sla l rl h - add hl, bc ; hl = [MapDataPointers+l] + 4*a + add hl, bc pop bc ret -; These vars are used as a copy source for something about drawing the background? Func_80229: ; 80229 (20:4229) ld a, [hli] ld [wd4c4], a @@ -391,11 +388,11 @@ Func_802bb: ; 802bb (20:42bb) Func_803b9: ; 803b9 (20:43b9) ld l, $00 - ld a, [wd131] ; current screen/state/almost room? + ld a, [wd131] call GetMapDataPointer - call Func_80229 ; basically get pointer to background tilemap? + call Func_80229 ld a, [hl] - ld [$d239], a ; the final value in mapDataPointer goes to this mystery + ld [$d239], a ret ; 0x803c9 @@ -498,8 +495,6 @@ Unknown_80e5a: ; 80e5a (20:4e5a) INCROM $80e5a, $80e5d ; might be closer to "screen specific data" than map data -; ex: one thing is reading from something that changes multipl times in loading -; of screens, and changes in duels (4d131) MapDataPointers: ; 80e5d (20:4e5d) dw MapDataPointers_80e67 dw MapDataPointers_8100f diff --git a/src/engine/home.asm b/src/engine/home.asm index 62eaa62..8545b3d 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1537,39 +1537,37 @@ UpdateRNGSources: ; 089b (0:089b) pop hl ret -; ld d, a ; de = wd4c4/5 + 5 -; ld b, $c0 ; b = c0 Func_08bf: ; 08bf (0:08bf) ld hl, wcad6 ld [hl], e inc hl - ld [hl], d ; load wcad6/7 with [wd4c4]+5 + ld [hl], d ld hl, wcad8 ld [hl], $1 - inc hl ; wcad8 is 1, a bunch of things after it are 0 + inc hl xor a ld [hli], a ld [hli], a ld [hli], a ld [hli], a - ld [hl], b ; then wcad i think is set to c0 + ld [hl], b inc hl ld [hli], a ; 0 - ld [hl], $ef ; and ef + ld [hl], $ef ld h, b - ld l, $0 ; hl is now c000, first byte of wram, first card collection or no name + ld l, $0 xor a .asm_8d9 - ld [hl], a ; 0 out ff bytes - inc l ; inc the first ff bytes of wram (was an arg so could be other stuff) + ld [hl], a + inc l jr nz, .asm_8d9 ret Func_08de: ; 08de (0:08de) - push hl ; wd23e + 40 i think? - push de ; 6 mdp bytes + push hl + push de .asm_8e0 - push bc ; as of first run, bc is the width + push bc call Func_08ef ld [de], a inc de diff --git a/src/wram.asm b/src/wram.asm index a689451..4d71b86 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1898,7 +1898,6 @@ wd12f:: ; d12f wd130:: ; d130 ds $1 -; current screen, at least for some purpose -- changed multiple times on loads and changes when screen changes in battle? wd131:: ; d131 ds $1 -- cgit v1.2.3 From 516f47dd3efc34ee938b14f74e4c7eda0c19fc2d Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Wed, 2 Oct 2019 23:50:47 -0400 Subject: layout another NPC script, make some assumptions about flags --- src/data/npcs.asm | 2 +- src/engine/bank01.asm | 4 +- src/engine/bank02.asm | 37 ++++++++++-- src/engine/bank03.asm | 161 +++++++++++++++++++++++++++++++++++++++++++++++++- src/sram.asm | 2 +- 5 files changed, 193 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/data/npcs.asm b/src/data/npcs.asm index f667077..f1a6737 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -579,7 +579,7 @@ BrittanyData: db $04 db $0e db $00 - dw $65d2 ; Pointer to NPC Data + dw OWSequence_Brittany ; Pointer to NPC Data tx Text03c4 db BRITTANY_PIC db $28 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index f9f8781..d5926df 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6288,10 +6288,10 @@ DiscardSavedDuelData: ; 6785 (1:6785) ; 0x6793 ; loads a player deck (sDeck*Cards) from SRAM to wPlayerDeck -; s0b700 determines which sDeck*Cards source (0-3) +; sCurrentlySelectedDeck determines which sDeck*Cards source (0-3) LoadPlayerDeck: ; 6793 (1:6793) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld l, a ld h, sDeck2Cards - sDeck1Cards call HtimesL diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 51127a2..108a34d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2171,7 +2171,7 @@ Func_8f8a: ; 8f8a (2:4f8a) Func_8f9d: ; 8f9d (2:4f9d) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, $3 ld l, a @@ -2185,7 +2185,7 @@ Func_8f9d: ; 8f9d (2:4f9d) call FillRectangle ld a, [wceb1] call EnableSRAM - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call GetPointerToDeckName @@ -2519,7 +2519,7 @@ Func_9168: ; 9168 (2:5168) ld [wceb5], a .asm_9214 call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld c, a ld b, $0 ld d, $2 @@ -2539,7 +2539,7 @@ Func_9168: ; 9168 (2:5168) jr .asm_921f .asm_9234 ld a, c - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call EnableLCD @@ -2628,7 +2628,7 @@ Func_9314: ; 9314 (2:5314) Func_9326: ; 9326 (2:5326) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, 3 ld l, a @@ -2643,7 +2643,32 @@ Func_9326: ; 9326 (2:5326) ret Func_9345: ; 9345 (2:5345) - INCROM $9345, $9843 + INCROM $9345, $9649 + +; checks if selected deck has any basics +Func_9649: ; 9649 (2:5649) + ld hl, wcf17 +.asm_964c + ld a, [hli] + ld e, a + or a + jr z, .asm_9665 + call LoadCardDataToBuffer1_FromCardID + jr c, .asm_9665 + ld a, [wLoadedCard1Type] + and $08 + jr nz, .asm_964c + ld a, [wLoadedCard1Stage] + or a + jr nz, .asm_964c + scf + ret +.asm_9665 + or a + ret +; 0x9667 + + INCROM $9667, $9843 Func_9843: ; 9843 (2:5843) INCROM $9843, $98a6 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index f873953..1f1fbc5 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1623,8 +1623,82 @@ EventFlagMods: ; cb37 (3:4b37) flag_def EVENT_FLAG_31, $0a, %00000011 flag_def EVENT_FLAG_32, $0b, %10000000 flag_def EVENT_JOSHUA_STATE, $0b, %01110000 - - INCROM $cb9f, $cc32 + flag_def EVENT_FLAG_34, $0b, %00001100 + flag_def EVENT_FLAG_35, $0b, %00000011 + flag_def EVENT_FLAG_36, $0c, %11100000 + flag_def EVENT_FLAG_37, $0c, %00011100 + flag_def EVENT_FLAG_38, $0c, %00000010 + flag_def EVENT_FLAG_39, $0c, %00000001 + flag_def EVENT_FLAG_3A, $0d, %10000000 + flag_def EVENT_FLAG_3B, $0d, %01000000 + flag_def EVENT_FLAG_3C, $0d, %00100000 + flag_def EVENT_FLAG_3D, $0d, %00010000 + flag_def EVENT_FLAG_3E, $0d, %00001110 + flag_def EVENT_FLAG_3F, $0e, %11100000 + flag_def EVENT_FLAG_40, $0e, %00011100 + flag_def EVENT_FLAG_41, $0f, %11100000 + flag_def EVENT_FLAG_42, $10, %10000000 + flag_def EVENT_FLAG_43, $10, %01000000 + flag_def EVENT_FLAG_44, $10, %00110000 + flag_def EVENT_FLAG_45, $10, %00001100 + flag_def EVENT_FLAG_46, $10, %00000010 + flag_def EVENT_FLAG_47, $10, %00000001 + flag_def EVENT_FLAG_48, $11, %11100000 + flag_def EVENT_FLAG_49, $11, %00011100 + flag_def EVENT_FLAG_4A, $12, %11100000 + flag_def EVENT_FLAG_4B, $13, %10000000 + flag_def EVENT_FLAG_4C, $13, %01100000 + flag_def EVENT_FLAG_4D, $13, %00011000 + flag_def EVENT_FLAG_4E, $13, %00000100 + flag_def EVENT_FLAG_4F, $13, %00000010 + flag_def EVENT_FLAG_50, $14, %10000000 + flag_def EVENT_FLAG_51, $14, %01000000 + flag_def EVENT_FLAG_52, $14, %00100000 + flag_def EVENT_FLAG_53, $14, %00010000 + flag_def EVENT_FLAG_54, $14, %00001000 + flag_def EVENT_FLAG_55, $14, %00000100 + flag_def EVENT_FLAG_56, $14, %00000010 + flag_def EVENT_FLAG_57, $14, %00000001 + flag_def EVENT_FLAG_58, $15, %11110000 + flag_def EVENT_FLAG_59, $15, %00001000 + flag_def EVENT_FLAG_5A, $16, %10000000 + flag_def EVENT_FLAG_5B, $16, %01000000 + flag_def EVENT_FLAG_5C, $16, %00100000 + flag_def EVENT_FLAG_5D, $16, %00010000 + flag_def EVENT_FLAG_5E, $16, %00001000 + flag_def EVENT_FLAG_5F, $16, %00000100 + flag_def EVENT_FLAG_60, $16, %00000010 + flag_def EVENT_FLAG_61, $16, %00000001 + flag_def EVENT_FLAG_62, $16, %11111111 + flag_def EVENT_FLAG_63, $17, %10000000 + flag_def EVENT_FLAG_64, $17, %01000000 + flag_def EVENT_FLAG_65, $17, %00110000 + flag_def EVENT_FLAG_66, $17, %00001000 + flag_def EVENT_FLAG_67, $17, %00000100 + flag_def EVENT_FLAG_68, $18, %11000000 + flag_def EVENT_FLAG_69, $18, %00110000 + flag_def EVENT_FLAG_6A, $18, %00001100 + flag_def EVENT_FLAG_6B, $18, %00000011 + flag_def EVENT_FLAG_6C, $19, %11000000 + flag_def EVENT_FLAG_6D, $19, %00100000 + flag_def EVENT_FLAG_6E, $19, %00010000 + flag_def EVENT_FLAG_6F, $19, %00001000 + flag_def EVENT_FLAG_70, $19, %00000100 + flag_def EVENT_FLAG_71, $19, %00111100 + flag_def EVENT_FLAG_72, $1a, %11111100 + flag_def EVENT_FLAG_73, $1a, %00000011 + flag_def EVENT_FLAG_74, $1b, %11111111 + flag_def EVENT_FLAG_75, $1c, %11110000 + flag_def EVENT_FLAG_76, $1c, %00001111 + +Func_cc25: ; cc25 (3:4c25) + ld hl, wd0ca + ld a, [hli] + ld h, [hl] + ld l, a + call Func_cc32 + call CloseAdvancedDialogueBox + ret Func_cc32: ; cc32 (3:4c32) push hl @@ -3549,7 +3623,88 @@ FindEndOfBattleScript: ; e52c (3:652c) jp Func_c926 ; 0xe553 - INCROM $e553, $f580 + INCROM $e553, $e5c4 + +GrassClubLobbyAfterDuel: ; e5c4 (3:65cb) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret +.after_duel_table + db BRITTANY + db BRITTANY + dw OWSequence_BeatBrittany + dw OWSequence_LostToBrittany + db $00 + +OWSequence_Brittany: ; e5d2 (3:65d2) + start_script + run_script OWScript_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06e0 + tx Text06e1 + run_script OWScript_AskQuestionJump + tx Text06e2 + dw .wantToDuel + run_script OWScript_PrintTextString + tx Text06e3 + run_script OWScript_EndScriptCloseText + +.wantToDuel + run_script OWScript_PrintTextString + tx Text06e4 + run_script OWScript_StartBattle + db PRIZES_4 + db ETCETERA_DECK_ID + db MUSIC_DUEL_THEME_1 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatBrittany: ; e5ee (3:65ee) + start_script + run_script OWScript_PrintTextString + tx Text06e5 + run_script OWScript_GiveBoosterPacks + db BOOSTER_MYSTERY_GRASS_COLORLESS + db BOOSTER_MYSTERY_GRASS_COLORLESS + db NO_BOOSTER + run_script OWScript_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06e6 + tx Text06e7 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_3C + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_35 + db $02 + dw .ows_e617 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_3A + dw .ows_e617 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_3B + dw .ows_e617 + run_script OWScript_SetFlagValue + db EVENT_FLAG_35 + db $01 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_1E + run_script OWScript_PrintTextString + tx Text06e8 +.ows_e617 + run_script OWScript_EndScriptCloseText + +OWSequence_LostToBrittany: ; e618 (3:6618) + start_script + run_script OWScript_PrintTextCloseBox + tx Text06e9 +; 0xe61c + + INCROM $e61c, $f580 Func_f580: ; f580 (3:7580) call Func_ca69 diff --git a/src/sram.asm b/src/sram.asm index 272fbfd..f9c1a9e 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -63,7 +63,7 @@ s0a3f8:: ; a3f8 ds $12b4 -s0b700:: ; b700 +sCurrentlySelectedDeck:: ; b700 ds $1 SECTION "SRAM1", SRAM -- cgit v1.2.3 From 8c416b556348fe9a98e28fd0ba5628b5c74edcc8 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Thu, 3 Oct 2019 22:04:51 -0400 Subject: Ronald scripts and overworld data routines. Also made script extractor better --- src/data/map_scripts.asm | 34 +++--- src/engine/bank03.asm | 309 ++++++++++++++++++++++++++++++++++++++++++++--- src/engine/bank04.asm | 4 +- src/macros/scripts.asm | 4 +- 4 files changed, 315 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index ae4e355..ec8c292 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -57,8 +57,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -87,8 +87,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -117,8 +117,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -147,8 +147,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -177,8 +177,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $6525 + dw LoadClubEntrance + dw GrassClubEntranceAfterDuel dw $0000 dw $0000 @@ -188,7 +188,7 @@ MapScripts: ; 1162a (4:562a) dw $7d4b dw $0000 dw $0000 - dw $65c4 + dw GrassClubLobbyAfterDuel dw $0000 dw $0000 @@ -207,8 +207,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -237,8 +237,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 @@ -267,8 +267,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 1f1fbc5..6149c08 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1631,7 +1631,7 @@ EventFlagMods: ; cb37 (3:4b37) flag_def EVENT_FLAG_39, $0c, %00000001 flag_def EVENT_FLAG_3A, $0d, %10000000 flag_def EVENT_FLAG_3B, $0d, %01000000 - flag_def EVENT_FLAG_3C, $0d, %00100000 + flag_def FLAG_BEAT_BRITTANY, $0d, %00100000 flag_def EVENT_FLAG_3D, $0d, %00010000 flag_def EVENT_FLAG_3E, $0d, %00001110 flag_def EVENT_FLAG_3F, $0e, %11100000 @@ -1852,8 +1852,10 @@ Func_ccdc: ; ccdc (3:4cdc) Func_cce4: ; cce4 (3:4ce4) ld a, $1 ld [wDefaultYesOrNo], a +; fallthrough -; Asks the player a question then jumps if they answer yes +; Asks the player a question then jumps if they answer yes. Seem to be able to +; take a text of 0000 to overwrite last with (yes no) prompt at the bottom OWScript_AskQuestionJump: ; cce9 (3:4ce9) ld l, c ld h, b @@ -2202,17 +2204,18 @@ Func_cf2d: ; cf2d (3:4f2d) jr nc, asm_cf1f jr asm_cf19 -Func_cf3f: ; cf3f (3:4f3f) +; Gives the first arg as a card. If that's 0 pulls from wd697 +OWScript_GiveCard: ; cf3f (3:4f3f) ld a, c or a - jr nz, .asm_cf46 + jr nz, .giveCard ld a, [wd697] -.asm_cf46 +.giveCard call AddCardToCollection jp IncreaseOWScriptPointerBy2 -Func_cf4c: ; cf4c (3:4f4c) +OWScript_TakeCard: ; cf4c (3:4f4c) ld a, c call RemoveCardFromCollection jp IncreaseOWScriptPointerBy2 @@ -3590,7 +3593,12 @@ OWJump_TalkToAmyAgain: ; e356 (3:6356) run_script OWScript_EndScriptCloseText ; 0xe369 - INCROM $e369, $e52c + INCROM $e369, $e525 + +GrassClubEntranceAfterDuel: ; e525 (3:6525) + ld hl, GrassClubEntranceAfterDuelTable + call FindEndOfBattleScript + ret FindEndOfBattleScript: ; e52c (3:652c) ld c, $0 @@ -3623,12 +3631,30 @@ FindEndOfBattleScript: ; e52c (3:652c) jp Func_c926 ; 0xe553 - INCROM $e553, $e5c4 +GrassClubEntranceAfterDuelTable: ; e553 (3:6553) + db MICHAEL + db MICHAEL + dw $6597 + dw $65ab + + db RONALD2 + db RONALD2 + dw OWSequence_BeatFirstRonaldFight + dw OWSequence_LostToFirstRonaldFight + + db RONALD3 + db RONALD3 + dw OWSequence_BeatSecondRonaldFight + dw OWSequence_LostToSecondRonaldFight + db $00 + + INCROM $e566, $e5c4 -GrassClubLobbyAfterDuel: ; e5c4 (3:65cb) +GrassClubLobbyAfterDuel: ; e5c4 (3:65c4) ld hl, .after_duel_table call FindEndOfBattleScript ret + .after_duel_table db BRITTANY db BRITTANY @@ -3677,17 +3703,17 @@ OWSequence_BeatBrittany: ; e5ee (3:65ee) tx Text06e6 tx Text06e7 run_script OWScript_MaxOutFlagValue - db EVENT_FLAG_3C + db FLAG_BEAT_BRITTANY run_script OWScript_JumpIfFlagNotLessThan db EVENT_FLAG_35 db $02 - dw .ows_e617 + dw .finishSequence run_script OWScript_JumpIfFlagZero2 db EVENT_FLAG_3A - dw .ows_e617 + dw .finishSequence run_script OWScript_JumpIfFlagZero2 db EVENT_FLAG_3B - dw .ows_e617 + dw .finishSequence run_script OWScript_SetFlagValue db EVENT_FLAG_35 db $01 @@ -3695,7 +3721,7 @@ OWSequence_BeatBrittany: ; e5ee (3:65ee) db EVENT_FLAG_1E run_script OWScript_PrintTextString tx Text06e8 -.ows_e617 +.finishSequence run_script OWScript_EndScriptCloseText OWSequence_LostToBrittany: ; e618 (3:6618) @@ -3704,7 +3730,260 @@ OWSequence_LostToBrittany: ; e618 (3:6618) tx Text06e9 ; 0xe61c - INCROM $e61c, $f580 + INCROM $e61c, $e7f6 + +ClubEntranceAfterDuel: ; e7f6 (3:67f6) + ld hl, .after_duel_table + jp FindEndOfBattleScript + +.after_duel_table + db RONALD2 + db RONALD2 + dw OWSequence_BeatFirstRonaldFight + dw OWSequence_LostToFirstRonaldFight + + db RONALD3 + db RONALD3 + dw OWSequence_BeatSecondRonaldFight + dw OWSequence_LostToSecondRonaldFight + db $00 + +LoadClubEntrance: ; e809 (3:6809) + call TryFirstRonaldFight + call TrySecondRonaldFight + call TryFirstRonaldEncounter + ret + +TryFirstRonaldEncounter: ; e813 (3:6813) + ld a, RONALD1 + ld [wd3ab], a + call Func_39c3 + ret c + ld bc, OWSequence_FirstRonaldEncounter + jp Func_c926 + +TryFirstRonaldFight: ; e822 (3:6822) + ld a, RONALD2 + ld [$d3ab], a + call Func_39c3 + ret c + call Func_ca69 + ld c, h + or a + ret nz + ld bc, OWSequence_FirstRonaldFight + jp Func_c926 + +TrySecondRonaldFight: ; e837 (3:6837) + ld a, RONALD3 + ld [$d3ab], a + call Func_39c3 + ret c + call Func_ca69 + ld c, l + or a + ret nz + ld bc, OWSequenceSecondRonaldFight + jp Func_c926 +; 0xe84c + + INCROM $e84c, $e862 + +OWSequence_FirstRonaldEncounter: ; e862 (3:6862) + start_script + run_script OWScript_MaxOutFlagValue + db $4b + run_script Func_ce4a + db $94 + db $68 + run_script Func_d135 + db $00 + run_script OWScript_PrintTextString + tx Text0645 + run_script OWScript_CloseTextBox + run_script OWScript_MovePlayer + db $00 + db $01 + run_script OWScript_MovePlayer + db $00 + db $01 + run_script OWScript_PrintTextString + tx Text0646 + run_script Func_cce4 + dw 0000 + dw .ows_e882 + run_script OWScript_PrintTextString + tx Text0647 + run_script OWScript_Jump + dw .ows_e885 + +.ows_e882 + run_script OWScript_PrintTextString + tx Text0648 +.ows_e885 + run_script OWScript_PrintTextString + tx Text0649 + run_script OWScript_CloseTextBox + run_script Func_d055 + db $03 + run_script OWScript_MovePlayer + db $01 + db $04 + run_script Func_ce4a + db $94 + db $68 + run_script Func_cdcb + run_script Func_d41d + run_script OWScript_EndScriptCloseText +; 0xe894 + + INCROM $e894, $e8c0 + +OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) + start_script + run_script Func_ce4a + db $05 + db $69 + run_script OWScript_DoFrames + db $3c + run_script Func_ce4a + db $0d + db $69 + run_script OWScript_PrintTextString + tx Text064a + run_script Func_d0f2 + db $08 + db $02 + dw $68d6 + run_script Func_d055 + db $03 + run_script OWScript_MovePlayer + db $03 + db $01 + run_script Func_d055 + db $02 + run_script OWScript_MovePlayer + db $02 + db $01 + run_script OWScript_MovePlayer + db $02 + db $01 + run_script OWScript_PrintTextString + tx Text064b + run_script OWScript_SetFlagValue + db $4c + db $01 + run_script OWScript_StartBattle + db PRIZES_6 + db IM_RONALD_DECK_ID + db MUSIC_RONALD + run_script OWScript_EndScriptCloseText + +OWSequence_BeatFirstRonaldFight: ; e8e9 (3:68e9) + start_script + run_script OWScript_PrintTextString + tx Text064c + run_script OWScript_GiveCard + db JIGGLYPUFF1 + run_script Func_cee2 + db JIGGLYPUFF1 + run_script OWScript_PrintTextString + tx Text064d + run_script OWScript_Jump + dw OWJump_FinishedFirstRonaldFight + +OWSequence_LostToFirstRonaldFight: ; e8f7 (3:68f7) + start_script + run_script OWScript_PrintTextString + tx Text064e + +OWJump_FinishedFirstRonaldFight + run_script OWScript_SetFlagValue + db EVENT_FLAG_4C + db $02 + run_script OWScript_CloseTextBox + run_script Func_ce4a + db $0f + db $69 + run_script Func_cdcb + run_script Func_d41d + run_script OWScript_EndScriptCloseText +; 0xe905 + + INCROM $e905, $e91e + +OWSequenceSecondRonaldFight: ; e91e (3:691e) + start_script + run_script Func_ce4a + db $05 + db $69 + run_script OWScript_DoFrames + db $3c + run_script Func_ce4a + db $0d + db $69 + run_script OWScript_PrintTextString + tx Text064f + run_script Func_d0f2 + db $08 + db $02 + dw $6934 + run_script Func_d055 + db $03 + run_script OWScript_MovePlayer + db $03 + db $01 + run_script Func_d055 + db $02 + run_script OWScript_MovePlayer + db $02 + db $01 + run_script OWScript_MovePlayer + db $02 + db $01 + run_script OWScript_PrintTextString + tx Text0650 + run_script OWScript_SetFlagValue + db $4d + db $01 + run_script OWScript_StartBattle + db PRIZES_6 + db POWERFUL_RONALD_DECK_ID + db MUSIC_RONALD + run_script OWScript_EndScriptCloseText + +OWSequence_BeatSecondRonaldFight: ; e947 (3:6947) + start_script + run_script OWScript_PrintTextString + tx Text0651 + run_script OWScript_GiveCard + db SUPER_ENERGY_RETRIEVAL + run_script Func_cee2 + db SUPER_ENERGY_RETRIEVAL + run_script OWScript_PrintTextString + tx Text0652 + run_script OWScript_Jump + dw OWJump_FinishedSecondRonaldFight + +OWSequence_LostToSecondRonaldFight: ; e955 (3:6955) + start_script + run_script OWScript_PrintTextString + tx Text0653 + +OWJump_FinishedSecondRonaldFight ; e959 (3:6959) + run_script OWScript_SetFlagValue + db $4d + db $02 + run_script OWScript_CloseTextBox + run_script Func_ce4a + db $0f + db $69 + run_script Func_cdcb + run_script Func_d41d + run_script OWScript_EndScriptCloseText +; 0xe963 + + INCROM $e963, $f580 Func_f580: ; f580 (3:7580) call Func_ca69 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 0c91398..e127f70 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -984,8 +984,8 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_GiveBoosterPacks dw Func_cf0c dw Func_cf12 - dw Func_cf3f - dw Func_cf4c + dw OWScript_GiveCard + dw OWScript_TakeCard dw Func_cf53 dw Func_cf7b dw Func_cf2d diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 2bf40e4..1f36cba 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -29,8 +29,8 @@ ENDM const OWScript_GiveBoosterPacks_index ; $0c const Func_cf0c_index ; $0d const Func_cf12_index ; $0e - const Func_cf3f_index ; $0f - const Func_cf4c_index ; $10 + const OWScript_GiveCard_index ; $0f + const OWScript_TakeCard_index ; $10 const Func_cf53_index ; $11 const Func_cf7b_index ; $12 const Func_cf2d_index ; $13 -- cgit v1.2.3 From fda59356c20813bb57d59de8d9b2b100f0fe275d Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sun, 6 Oct 2019 11:24:18 -0400 Subject: Uncovered a lot of NPC map data and loading functions. --- src/constants/map_constants.asm | 14 ++ src/constants/misc_constants.asm | 5 + src/constants/npc_constants.asm | 6 +- src/data/map_scripts.asm | 72 +++---- src/data/npc_map_data.asm | 418 +++++++++++++++++++++++++++++++++++++++ src/data/npcs.asm | 222 ++++++++++----------- src/engine/bank03.asm | 264 +++++++++++++++---------- src/engine/bank04.asm | 106 +++++----- src/engine/bank07.asm | 104 +++++++++- src/engine/bank20.asm | 14 +- src/engine/home.asm | 44 +++-- src/wram.asm | 25 +-- 12 files changed, 940 insertions(+), 354 deletions(-) create mode 100644 src/data/npc_map_data.asm (limited to 'src') diff --git a/src/constants/map_constants.asm b/src/constants/map_constants.asm index 4b74a29..5e01d0a 100644 --- a/src/constants/map_constants.asm +++ b/src/constants/map_constants.asm @@ -33,3 +33,17 @@ const POKEMON_DOME_ENTRANCE ; $1F const POKEMON_DOME ; $20 const HALL_OF_HONOR ; $21 + + +NPC_MAP_SIZE EQU $06 + +; Most of these aren't fully understood so the names aren't great +MAP_SCRIPT_SIZE EQU $0f +MAP_SCRIPT_NPCS EQU $00 +MAP_SCRIPT_POST_NPC EQU $02 +MAP_SCRIPT_PRESSED_A_1 EQU $04 +MAP_SCRIPT_PRESSED_A_2 EQU $06 +MAP_SCRIPT_LOAD_MAP EQU $08 +MAP_SCRIPT_AFTER_DUEL EQU $0a +MAP_SCRIPT_MOVED_PLAYER EQU $0c +MAP_SCRIPT_CLOSE_TEXTBOX EQU $0e diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index c513111..53b2be4 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -47,3 +47,8 @@ NUM_GAME_EVENTS EQU const_value ; Script constant NO_JUMP EQU $0000 + +NORTH EQU $00 +EAST EQU $01 +SOUTH EQU $02 +WEST EQU $03 diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index d7eeaa8..f85dc1c 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -1,9 +1,9 @@ ; npc_struct constants const_def const NPC_TRAINER_ID - const NPC_DATA_FIELD_01 - const NPC_DATA_FIELD_02 - const NPC_DATA_FIELD_03 + const NPC_DATA_FIELD_01 ; Sprite + const NPC_DATA_FIELD_02 ; DMG/SGB pal + const NPC_DATA_FIELD_03 ; CGB pal const NPC_DATA_FIELD_04 const NPC_DATA_OWSEQUENCE_PTR const_value = const_value+1 diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index ec8c292..e156a1c 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -2,8 +2,8 @@ ; scripts are referenced with ids [0,2,4,6,8,a,c,e] ; each script id is used for a specific event ; if a script pointer is $0000, that map has no script for that event -; 0: load texts -; 2: unused +; 0: NPC data +; 2: Called after every NPC is loaded (unused) ; 4: pressed A button ; 6: pressed A button ; 8: load map @@ -17,13 +17,13 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $54ec + dw LoadOverworld dw $0000 dw $0000 dw $0000 ; MASON_LABORATORY - dw $772f + dw NPCData_772f dw $0000 dw $7b04 dw $5565 @@ -33,7 +33,7 @@ MapScripts: ; 1162a (4:562a) dw $555e ; DECK_MACHINE_ROOM - dw $775a + dw NPCData_775a dw $0000 dw $7b4d dw $0000 @@ -43,7 +43,7 @@ MapScripts: ; 1162a (4:562a) dw $58ad ; ISHIHARAS_HOUSE - dw $7773 + dw NPCData_7773 dw $0000 dw $7c02 dw $0000 @@ -53,7 +53,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB_ENTRANCE - dw $7786 + dw NPCData_7786 dw $0000 dw $0000 dw $0000 @@ -63,7 +63,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB_LOBBY - dw $779f + dw NPCData_779f dw $0000 dw $7c6f dw $0000 @@ -73,7 +73,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB - dw $77ca + dw NPCData_77ca dw $0000 dw $0000 dw $0000 @@ -83,7 +83,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB_ENTRANCE - dw $77e3 + dw NPCData_77e3 dw $0000 dw $0000 dw $0000 @@ -93,7 +93,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB_LOBBY - dw $77fc + dw NPCData_77fc dw $0000 dw $7ca6 dw $0000 @@ -103,7 +103,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB - dw $7827 + dw NPCData_7827 dw $0000 dw $0000 dw $0000 @@ -113,7 +113,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB_ENTRANCE - dw $783a + dw NPCData_783a dw $0000 dw $0000 dw $0000 @@ -123,7 +123,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB_LOBBY - dw $7853 + dw NPCData_7853 dw $0000 dw $7cdd dw $0000 @@ -133,7 +133,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB - dw $787e + dw NPCData_787e dw $0000 dw $0000 dw $0000 @@ -143,7 +143,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB_ENTRANCE - dw $7897 + dw NPCData_7897 dw $0000 dw $0000 dw $0000 @@ -153,7 +153,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB_LOBBY - dw $78b0 + dw NPCData_78b0 dw $0000 dw $7d14 dw $0000 @@ -163,7 +163,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB - dw $78d5 + dw NPCData_78d5 dw $0000 dw $0000 dw $0000 @@ -173,7 +173,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB_ENTRANCE - dw $78ee + dw NPCData_78ee dw $0000 dw $0000 dw $0000 @@ -183,7 +183,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB_LOBBY - dw $790d + dw NPCData_790d dw $0000 dw $7d4b dw $0000 @@ -193,7 +193,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB - dw $7932 + dw NPCData_7932 dw $0000 dw $0000 dw $0000 @@ -203,7 +203,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB_ENTRANCE - dw $7945 + dw NPCData_7945 dw $0000 dw $0000 dw $0000 @@ -213,7 +213,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB_LOBBY - dw $7964 + dw NPCData_7964 dw $0000 dw $7d82 dw $0000 @@ -223,7 +223,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB - dw $798f + dw NPCData_798f dw $0000 dw $0000 dw $0000 @@ -233,7 +233,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB_ENTRANCE - dw $79a8 + dw NPCData_79a8 dw $0000 dw $0000 dw $0000 @@ -243,7 +243,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB_LOBBY - dw $79c1 + dw NPCData_79c1 dw $0000 dw $7db9 dw $0000 @@ -253,7 +253,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB - dw $79ec + dw NPCData_79ec dw $0000 dw $0000 dw $0000 @@ -263,7 +263,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB_ENTRANCE - dw $7a05 + dw NPCData_7a05 dw $0000 dw $0000 dw $0000 @@ -273,7 +273,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB_LOBBY - dw $7a1e + dw NPCData_7a1e dw $0000 dw $7df0 dw $6d57 @@ -283,7 +283,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB - dw $7a43 + dw NPCData_7a43 dw $0000 dw $0000 dw $0000 @@ -293,7 +293,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_ENTRANCE - dw $7a5c + dw NPCData_7a5c dw $0000 dw $0000 dw $0000 @@ -303,7 +303,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_LOBBY - dw $7a63 + dw NPCData_7a63 dw $0000 dw $7e27 dw $0000 @@ -313,7 +313,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL - dw $7a9a + dw NPCData_7a9a dw $0000 dw $0000 dw $0000 @@ -323,7 +323,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; POKEMON_DOME_ENTRANCE - dw $7ab9 + dw NPCData_7ab9 dw $0000 dw $7e5e dw $0000 @@ -333,7 +333,7 @@ MapScripts: ; 1162a (4:562a) dw $762a ; POKEMON_DOME - dw $7ac0 + dw NPCData_7ac0 dw $0000 dw $0000 dw $0000 @@ -343,7 +343,7 @@ MapScripts: ; 1162a (4:562a) dw $7718 ; HALL_OF_HONOR - dw $7adf + dw NPCData_7adf dw $0000 dw $7ec2 dw $0000 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm new file mode 100644 index 0000000..7bc69cb --- /dev/null +++ b/src/data/npc_map_data.asm @@ -0,0 +1,418 @@ +; NPC Map data. Format: +; NPC, X position, Y Position, Direction, +; pre-load function. (Resets c flag if NPC should not be loaded) +NPCData_772f: ; 772f (4:1372f) + db DRMASON, $0e, $06, SOUTH + dw $5710 + db SAM, $04, $0e, EAST + dw $5604 + db TECH1, $16, $08, WEST + dw $0000 + db TECH2, $16, $14, SOUTH + dw $0000 + db TECH3, $16, $16, WEST + dw $0000 + db TECH4, $0a, $16, EAST + dw $0000 + db TECH5, $06, $04, SOUTH + dw $55eb + db $00 + +NPCData_775a: ; 775a (4:1375a) + db TECH6, $06, $08, SOUTH + dw $0000 + db TECH7, $06, $16, WEST + dw $0000 + db TECH8, $0a, $12, WEST + dw $0000 + db AARON, $0c, $0c, WEST + dw $0000 + db $00 + +NPCData_7773: ; 7773 (4:13773) + db NIKKI, $04, $04, NORTH + dw $5add + db ISHIHARA, $08, $08, SOUTH + dw $5b3d + db RONALD1, $02, $04, WEST + dw $5c43 + db $00 + +NPCData_7786: ; 7786 (4:13786) + db CLERK1, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_779f: ; 779f (4:1379f) + db MAN1, $0c, $0e, WEST + dw $0000 + db IMAKUNI, $12, $02, NORTH + dw $5ceb + db SPECS1, $12, $10, EAST + dw $0000 + db BUTCH, $14, $10, WEST + dw $0000 + db GRANNY1, $04, $10, WEST + dw $5d98 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_77ca: ; 77ca (4:137ca) + db CHRIS, $04, $08, SOUTH + dw $5e43 + db MICHAEL, $0e, $0a, SOUTH + dw $5e79 + db JESSICA, $12, $06, EAST + dw $5ea5 + db MITCH, $0a, $04, SOUTH + dw $0000 + db $00 + +NPCData_77e3: ; 77e3 (4:137e3) + db CLERK2, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_77fc: ; 77fc (4:137fc) + db CHRIS, $12, $08, WEST + dw $5ee9 + db MATTHEW, $06, $0e, EAST + dw $0000 + db WOMAN1, $14, $12, NORTH + dw $0000 + db CHAP1, $0e, $10, EAST + dw $0000 + db LASS3, $10, $04, SOUTH + dw $5fcb + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_7827: ; 7827 (4:13827) + db RYAN, $14, $0e, EAST + dw $0000 + db ANDREW, $06, $14, NORTH + dw $0000 + db GENE, $0c, $06, NORTH + dw $0000 + db $00 + +NPCData_783a: ; 783a (4:1383a) + db CLERK3, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_7853: ; 7853 (4:13853) + db GAL1, $06, $0e, SOUTH + dw $0000 + db LASS1, $10, $0a, SOUTH + dw $0000 + db IMAKUNI, $12, $02, NORTH + dw $60b0 + db MAN2, $04, $12, EAST + dw $6130 + db PAPPY2, $16, $10, NORTH + dw $0000 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_787e: ; 787e (4:1387e) + db SARA, $06, $12, EAST + dw $0000 + db AMANDA, $16, $14, WEST + dw $0000 + db JOSHUA, $16, $08, SOUTH + dw $0000 + db AMY, $16, $04, SOUTH + dw $62ad + db $00 + +NPCData_7897: ; 7897 (4:13897) + db CLERK4, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_78b0: ; 78b0 (4:138b0) + db CHAP2, $12, $10, WEST + dw $0000 + db IMAKUNI, $12, $02, NORTH + dw $637b + db LASS4, $08, $0c, SOUTH + dw $0000 + db HOOD1, $14, $08, SOUTH + dw $0000 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_78d5: ; 78d5 (4:138d5) + db JENNIFER, $0e, $12, SOUTH + dw $0000 + db NICHOLAS, $06, $0a, SOUTH + dw $0000 + db BRANDON, $16, $0c, NORTH + dw $0000 + db ISAAC, $0c, $04, NORTH + dw $6494 + db $00 + +NPCData_78ee: ; 78ee (4:138ee) + db CLERK5, $06, $02, SOUTH + dw $0000 + db MICHAEL, $0e, $08, SOUTH + dw $656a + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_790d: ; 790d (4:1390d) + db BRITTANY, $0c, $0e, WEST + dw $0000 + db LASS2, $12, $08, SOUTH + dw $0000 + db GRANNY2, $04, $10, EAST + dw $0000 + db GAL2, $14, $10, NORTH + dw $66dc + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_7932: ; 7932 (4:13932) + db KRISTIN, $04, $0a, EAST + dw $0000 + db HEATHER, $0e, $10, SOUTH + dw $0000 + db NIKKI, $0c, $04, SOUTH + dw $6796 + db $00 + +NPCData_7945: ; 7945 (4:13945) + db CLERK6, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db LAD3, $0e, $04, SOUTH + dw $0000 + db $00 + +NPCData_7964: ; 7964 (4:13964) + db ROBERT, $14, $08, NORTH + dw $0000 + db PAPPY1, $04, $10, EAST + dw $0000 + db RONALD1, $0c, $0a, EAST + dw $69f7 + db GAL3, $10, $0e, WEST + dw $0000 + db CHAP4, $18, $10, SOUTH + dw $0000 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_798f: ; 798f (4:1398f) + db DANIEL, $08, $08, NORTH + dw $0000 + db STEPHANIE, $16, $0c, EAST + dw $0000 + db MURRAY2, $02, $02, WEST + dw $6ad0 + db MURRAY1, $0c, $06, SOUTH + dw $6ada + db $00 + +NPCData_79a8: ; 79a8 (4:139a8) + db CLERK7, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_79c1: ; 79c1 (4:139c1) + db LAD1, $12, $12, NORTH + dw $0000 + db IMAKUNI, $12, $02, NORTH + dw $6b65 + db MAN3, $04, $0e, WEST + dw $0000 + db SPECS2, $0c, $0e, WEST + dw $0000 + db SPECS3, $16, $08, SOUTH + dw $0000 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_79ec: ; 79ec (4:139ec) + db JOSEPH, $08, $0a, SOUTH + dw $6cc4 + db DAVID, $14, $04, NORTH + dw $0000 + db ERIK, $06, $12, SOUTH + dw $0000 + db RICK, $04, $04, NORTH + dw $0000 + db $00 + +NPCData_7a05: ; 7a05 (4:13a05) + db CLERK8, $06, $02, SOUTH + dw $0000 + db RONALD1, $08, $fe, SOUTH + dw $685b + db RONALD2, $fe, $08, NORTH + dw $689a + db RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +NPCData_7a1e: ; 7a1e (4:13a1e) + db JESSICA, $0c, $0e, WEST + dw $6d8d + db LAD2, $12, $06, EAST + dw $6e25 + db CHAP3, $06, $0a, NORTH + dw $0000 + db MANIA, $14, $12, NORTH + dw $0000 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_7a43: ; 7a43 (4:13a43) + db JOHN, $0c, $12, SOUTH + dw $0000 + db ADAM, $08, $0e, SOUTH + dw $0000 + db JONATHAN, $12, $0a, SOUTH + dw $0000 + db KEN, $0e, $04, SOUTH + dw $0000 + db $00 + +NPCData_7a5c: ; 7a5c (4:13a5c) + db CLERK9, $06, $02, SOUTH + dw $6f96 + db $00 + +NPCData_7a63: ; 7a63 (4:13a63) + db PAPPY3, $06, $0e, EAST + dw $707a + db CHAMP, $10, $12, WEST + dw $707a + db HOOD2, $14, $08, SOUTH + dw $707a + db LASS5, $16, $10, WEST + dw $707a + db GAL4, $0c, $0e, EAST + dw $7075 + db CHAP5, $10, $08, WEST + dw $7075 + db RONALD1, $08, $0c, SOUTH + dw $70b4 + db CLERK10, $06, $04, SOUTH + dw $0000 + db CLERK11, $0a, $04, SOUTH + dw $7c6c + db $00 + +NPCData_7a9a: ; 7a9a (4:13a9a) + db CLERK12, $0a, $12, SOUTH + dw $707a + db CLERK13, $14, $12, SOUTH + dw $707a + db GUIDE, $0e, $14, SOUTH + dw $7270 + db HOST, $0e, $04, SOUTH + dw $707a + db $ff, $12, $08, WEST ; pre-load function chooses NPC to load + dw $7559 + db $00 + +NPCData_7ab9: ; 7ab9 (4:13ab9) + db RONALD1, $0e, $12, SOUTH + dw $0000 + db $00 + +NPCData_7ac0: ; 7ac0 (4:13ac0) + db COURTNEY, $12, $02, SOUTH + dw $774b + db STEVE, $16, $02, SOUTH + dw $778c + db JACK, $08, $02, SOUTH + dw $77a3 + db ROD, $0c, $02, SOUTH + dw $77ba + db RONALD1, $1e, $00, SOUTH + dw $77d6 + db $00 + +NPCData_7adf: ; 7adf (4:13adf) + db _11F1F, $0a, $08, SOUTH + dw $0000 + db _11F26, $0c, $08, SOUTH + dw $0000 + db _11F2D, $08, $0a, SOUTH + dw $0000 + db _11F34, $0a, $0a, SOUTH + dw $0000 + db _11F3B, $0c, $0a, SOUTH + dw $0000 + db _11F42, $0e, $0a, SOUTH + dw $0000 + db $00 + diff --git a/src/data/npcs.asm b/src/data/npcs.asm index f1a6737..bda574f 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1,6 +1,6 @@ ; When you press the A button in front of something it will find a data entry somewhere on this list ; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation. -PointerTable_118f5: +NPCDataTable: dw DrMasonData dw DrMasonData dw Ronald1Data @@ -123,7 +123,7 @@ DrMasonData: db $00 db $26 db $00 - dw $5727 ; Pointer to NPC Data + dw $5727 ; Pointer to OWScript tx Text03ac db $00 db $00 @@ -135,7 +135,7 @@ Ronald1Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data + dw $5c4b ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -147,7 +147,7 @@ Ronald2Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data + dw $5c4b ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -159,7 +159,7 @@ Ronald3Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data + dw $5c4b ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -171,7 +171,7 @@ IshiharaData: db $04 db $22 db $00 - dw $5b4a ; Pointer to NPC Data + dw $5b4a ; Pointer to OWScript tx Text03ae db $00 db $00 @@ -183,7 +183,7 @@ ImakuniData: db $00 db $0e db $00 - dw $5d0d ; Pointer to NPC Data + dw $5d0d ; Pointer to OWScript tx Text03af db IMAKUNI_PIC db $34 @@ -195,7 +195,7 @@ SamData: db $00 db $0e db $00 - dw $561d ; Pointer to NPC Data + dw $561d ; Pointer to OWScript tx Text03b1 db SAM_PIC db $02 @@ -207,7 +207,7 @@ Tech1Data: db $00 db $0e db $00 - dw $5583 ; Pointer to NPC Data + dw $5583 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -219,7 +219,7 @@ Tech2Data: db $00 db $0e db $00 - dw $55ca ; Pointer to NPC Data + dw $55ca ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -231,7 +231,7 @@ Tech3Data: db $00 db $0e db $00 - dw $55d5 ; Pointer to NPC Data + dw $55d5 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -243,7 +243,7 @@ Tech4Data: db $00 db $0e db $00 - dw $55e0 ; Pointer to NPC Data + dw $55e0 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -255,7 +255,7 @@ Tech5Data: db $00 db $0e db $00 - dw $55f9 ; Pointer to NPC Data + dw $55f9 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -267,7 +267,7 @@ Tech6Data: db $00 db $0e db $00 - dw $58bb ; Pointer to NPC Data + dw $58bb ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -279,7 +279,7 @@ Clerk1Data: db $0a db $30 db $00 - dw $5c64 ; Pointer to NPC Data + dw $5c64 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -291,7 +291,7 @@ Clerk2Data: db $0a db $30 db $00 - dw $5ed1 ; Pointer to NPC Data + dw $5ed1 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -303,7 +303,7 @@ Clerk3Data: db $0a db $30 db $00 - dw $609e ; Pointer to NPC Data + dw $609e ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -315,7 +315,7 @@ Clerk4Data: db $0a db $30 db $00 - dw $6369 ; Pointer to NPC Data + dw $6369 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -327,7 +327,7 @@ Clerk5Data: db $0a db $30 db $00 - dw $6566 ; Pointer to NPC Data + dw $6566 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -339,7 +339,7 @@ Clerk6Data: db $0a db $30 db $00 - dw $684c ; Pointer to NPC Data + dw $684c ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -351,7 +351,7 @@ Clerk7Data: db $0a db $30 db $00 - dw $6b53 ; Pointer to NPC Data + dw $6b53 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -363,7 +363,7 @@ Clerk8Data: db $0a db $30 db $00 - dw $6d45 ; Pointer to NPC Data + dw $6d45 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -375,7 +375,7 @@ Clerk9Data: db $0a db $30 db $00 - dw $7025 ; Pointer to NPC Data + dw $7025 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -387,7 +387,7 @@ ChrisData: db $00 db $26 db $00 - dw $5ef2 ; Pointer to NPC Data + dw $5ef2 ; Pointer to OWScript tx Text03b4 db CHRIS_PIC db $1c @@ -399,7 +399,7 @@ MichaelData: db $00 db $26 db $00 - dw $6573 ; Pointer to NPC Data + dw $6573 ; Pointer to OWScript tx Text03b5 db MICHAEL_PIC db $1d @@ -411,7 +411,7 @@ JessicaData: db $04 db $1a db $00 - dw $6d96 ; Pointer to NPC Data + dw $6d96 ; Pointer to OWScript tx Text03b6 db JESSICA_PIC db $1e @@ -423,7 +423,7 @@ MitchData: db $00 db $0e db $00 - dw $5dc3 ; Pointer to NPC Data + dw $5dc3 ; Pointer to OWScript tx Text03b7 db MITCH_PIC db $10 @@ -435,7 +435,7 @@ MatthewData: db $00 db $16 db $00 - dw $5f39 ; Pointer to NPC Data + dw $5f39 ; Pointer to OWScript tx Text03b8 db MATTHEW_PIC db $21 @@ -447,7 +447,7 @@ RyanData: db $00 db $26 db $00 - dw $5ff0 ; Pointer to NPC Data + dw $5ff0 ; Pointer to OWScript tx Text03b9 db RYAN_PIC db $1f @@ -459,7 +459,7 @@ AndrewData: db $00 db $16 db $00 - dw $6017 ; Pointer to NPC Data + dw $6017 ; Pointer to OWScript tx Text03ba db ANDREW_PIC db $20 @@ -471,7 +471,7 @@ GeneData: db $04 db $1e db $00 - dw $603e ; Pointer to NPC Data + dw $603e ; Pointer to OWScript tx Text03bb db GENE_PIC db $11 @@ -483,7 +483,7 @@ SaraData: db $00 db $0e db $00 - dw OWSequence_Sara ; Pointer to NPC Data + dw OWSequence_Sara ; Pointer to OWScript tx Text03bc db SARA_PIC db $22 @@ -495,7 +495,7 @@ AmandaData: db $00 db $16 db $00 - dw OWSequence_Amanda ; Pointer to NPC Data + dw OWSequence_Amanda ; Pointer to OWScript tx Text03bd db AMANDA_PIC ; battle profile picture db $23 @@ -507,7 +507,7 @@ JoshuaData: db $00 db $26 db $00 - dw OWSequence_Joshua ; Pointer to NPC Data + dw OWSequence_Joshua ; Pointer to OWScript tx Text03be db JOSHUA_PIC db $24 @@ -519,7 +519,7 @@ AmyData: db $08 db $2e db $10 - dw OWSequence_Amy ; Pointer to NPC Data + dw OWSequence_Amy ; Pointer to OWScript tx Text03bf db AMY_PIC db $12 @@ -531,7 +531,7 @@ JenniferData: db $04 db $0e db $00 - dw $6408 ; Pointer to NPC Data + dw $6408 ; Pointer to OWScript tx Text03c0 db JENNIFER_PIC db $25 @@ -543,7 +543,7 @@ NicholasData: db $04 db $1e db $00 - dw $642f ; Pointer to NPC Data + dw $642f ; Pointer to OWScript tx Text03c1 db NICHOLAS_PIC db $26 @@ -555,7 +555,7 @@ BrandonData: db $04 db $1e db $00 - dw $6456 ; Pointer to NPC Data + dw $6456 ; Pointer to OWScript tx Text03c2 db BRANDON_PIC db $27 @@ -567,7 +567,7 @@ IsaacData: db $00 db $16 db $00 - dw $64ad ; Pointer to NPC Data + dw $64ad ; Pointer to OWScript tx Text03c3 db ISAAC_PIC db $13 @@ -579,7 +579,7 @@ BrittanyData: db $04 db $0e db $00 - dw OWSequence_Brittany ; Pointer to NPC Data + dw OWSequence_Brittany ; Pointer to OWScript tx Text03c4 db BRITTANY_PIC db $28 @@ -591,7 +591,7 @@ KristinData: db $00 db $1e db $00 - dw $6701 ; Pointer to NPC Data + dw $6701 ; Pointer to OWScript tx Text03c5 db KRISTIN_PIC db $29 @@ -603,7 +603,7 @@ HeatherData: db $04 db $22 db $00 - dw $6745 ; Pointer to NPC Data + dw $6745 ; Pointer to OWScript tx Text03c6 db HEATHER_PIC db $2a @@ -615,7 +615,7 @@ NikkiData: db $00 db $1a db $00 - dw $679e ; Pointer to NPC Data + dw $679e ; Pointer to OWScript tx Text03c7 db NIKKI_PIC db $14 @@ -627,7 +627,7 @@ RobertData: db $04 db $16 db $00 - dw $6980 ; Pointer to NPC Data + dw $6980 ; Pointer to OWScript tx Text03c8 db ROBERT_PIC db $2b @@ -639,7 +639,7 @@ DanielData: db $04 db $1a db $00 - dw $6a60 ; Pointer to NPC Data + dw $6a60 ; Pointer to OWScript tx Text03c9 db DANIEL_PIC db $2c @@ -651,7 +651,7 @@ StephanieData: db $04 db $0e db $00 - dw $6aa2 ; Pointer to NPC Data + dw $6aa2 ; Pointer to OWScript tx Text03ca db STEPHANIE_PIC db $2d @@ -663,7 +663,7 @@ Murray1Data: db $00 db $12 db $00 - dw $6adf ; Pointer to NPC Data + dw $6adf ; Pointer to OWScript tx Text03cb db MURRAY_PIC db $15 @@ -675,7 +675,7 @@ Murray2Data: db $03 db $15 db $10 - dw $6adf ; Pointer to NPC Data + dw $6adf ; Pointer to OWScript tx Text03cb db MURRAY_PIC db $15 @@ -687,7 +687,7 @@ JosephData: db $00 db $0e db $00 - dw $6cdb ; Pointer to NPC Data + dw $6cdb ; Pointer to OWScript tx Text03cc db JOSEPH_PIC db $2e @@ -699,7 +699,7 @@ DavidData: db $00 db $0e db $00 - dw $6c11 ; Pointer to NPC Data + dw $6c11 ; Pointer to OWScript tx Text03cd db DAVID_PIC db $2f @@ -711,7 +711,7 @@ ErikData: db $00 db $0e db $00 - dw $6c42 ; Pointer to NPC Data + dw $6c42 ; Pointer to OWScript tx Text03ce db ERIK_PIC db $30 @@ -723,7 +723,7 @@ RickData: db $00 db $0e db $00 - dw $6c67 ; Pointer to NPC Data + dw $6c67 ; Pointer to OWScript tx Text03cf db RICK_PIC db $16 @@ -735,7 +735,7 @@ JohnData: db $04 db $1a db $00 - dw $6eb3 ; Pointer to NPC Data + dw $6eb3 ; Pointer to OWScript tx Text03d0 db JOHN_PIC db $31 @@ -747,7 +747,7 @@ AdamData: db $00 db $22 db $00 - dw $6ed8 ; Pointer to NPC Data + dw $6ed8 ; Pointer to OWScript tx Text03d1 db ADAM_PIC db $32 @@ -759,7 +759,7 @@ JonathanData: db $04 db $16 db $00 - dw $6efd ; Pointer to NPC Data + dw $6efd ; Pointer to OWScript tx Text03d2 db JONATHAN_PIC db $33 @@ -771,7 +771,7 @@ KenData: db $04 db $1e db $00 - dw $6f22 ; Pointer to NPC Data + dw $6f22 ; Pointer to OWScript tx Text03d3 db KEN_PIC db $17 @@ -783,7 +783,7 @@ CourtneyData: db $00 db $12 db $00 - dw $771f ; Pointer to NPC Data + dw $771f ; Pointer to OWScript tx Text03d4 db COURTNEY_PIC db $0c @@ -795,7 +795,7 @@ SteveData: db $00 db $2a db $00 - dw $772a ; Pointer to NPC Data + dw $772a ; Pointer to OWScript tx Text03d5 db STEVE_PIC db $0d @@ -807,7 +807,7 @@ JackData: db $00 db $26 db $00 - dw $7735 ; Pointer to NPC Data + dw $7735 ; Pointer to OWScript tx Text03d6 db JACK_PIC db $0e @@ -819,7 +819,7 @@ RodData: db $00 db $0e db $00 - dw $7740 ; Pointer to NPC Data + dw $7740 ; Pointer to OWScript tx Text03d7 db ROD_PIC db $0f @@ -831,7 +831,7 @@ Clerk10Data: db $0a db $30 db $00 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript tx Text03b0 db $00 db $00 @@ -843,7 +843,7 @@ Clerk11Data: db $0a db $30 db $00 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript tx Text03b0 db $00 db $00 @@ -855,7 +855,7 @@ Man1Data: db $00 db $16 db $00 - dw $5c76 ; Pointer to NPC Data + dw $5c76 ; Pointer to OWScript tx Text03d8 db $00 db $00 @@ -867,7 +867,7 @@ Woman1Data: db $04 db $1e db $00 - dw $5f83 ; Pointer to NPC Data + dw $5f83 ; Pointer to OWScript tx Text03d9 db $00 db $00 @@ -879,7 +879,7 @@ Chap1Data: db $00 db $1a db $00 - dw $5fc0 ; Pointer to NPC Data + dw $5fc0 ; Pointer to OWScript tx Text03da db $00 db $00 @@ -891,7 +891,7 @@ Gal1Data: db $00 db $16 db $00 - dw $60cf ; Pointer to NPC Data + dw $60cf ; Pointer to OWScript tx Text03db db $00 db $00 @@ -903,7 +903,7 @@ Lass1Data: db $00 db $1e db $00 - dw $6111 ; Pointer to NPC Data + dw $6111 ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -915,7 +915,7 @@ Chap2Data: db $00 db $1a db $00 - dw $639a ; Pointer to NPC Data + dw $639a ; Pointer to OWScript tx Text03da db $00 db $00 @@ -927,7 +927,7 @@ Lass2Data: db $00 db $1e db $00 - dw $661f ; Pointer to NPC Data + dw $661f ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -939,7 +939,7 @@ Pappy1Data: db $00 db $22 db $00 - dw $69a5 ; Pointer to NPC Data + dw $69a5 ; Pointer to OWScript tx Text03dd db $00 db $00 @@ -951,7 +951,7 @@ Lad1Data: db $04 db $1a db $00 - dw $6b84 ; Pointer to NPC Data + dw $6b84 ; Pointer to OWScript tx Text03de db $00 db $00 @@ -963,7 +963,7 @@ Lad2Data: db $04 db $16 db $00 - dw $6e2c ; Pointer to NPC Data + dw $6e2c ; Pointer to OWScript tx Text03de db $00 db $00 @@ -975,7 +975,7 @@ Chap3Data: db $00 db $1a db $00 - dw $6de8 ; Pointer to NPC Data + dw $6de8 ; Pointer to OWScript tx Text03da db $00 db $00 @@ -987,7 +987,7 @@ Clerk12Data: db $00 db $16 db $00 - dw $7295 ; Pointer to NPC Data + dw $7295 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -999,7 +999,7 @@ Clerk13Data: db $00 db $16 db $00 - dw $726c ; Pointer to NPC Data + dw $726c ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -1011,7 +1011,7 @@ HostData: db $00 db $16 db $00 - dw $7352 ; Pointer to NPC Data + dw $7352 ; Pointer to OWScript tx Text03df db $00 db $00 @@ -1023,7 +1023,7 @@ Specs1Data: db $00 db $22 db $00 - dw $5d82 ; Pointer to NPC Data + dw $5d82 ; Pointer to OWScript tx Text03e0 db $00 db $00 @@ -1035,7 +1035,7 @@ ButchData: db $00 db $16 db $00 - dw $5d8d ; Pointer to NPC Data + dw $5d8d ; Pointer to OWScript tx Text03e1 db $00 db $00 @@ -1047,7 +1047,7 @@ Granny1Data: db $00 db $16 db $00 - dw $5d9f ; Pointer to NPC Data + dw $5d9f ; Pointer to OWScript tx Text03e5 db $00 db $00 @@ -1059,7 +1059,7 @@ Lass3Data: db $04 db $22 db $00 - dw $5fd2 ; Pointer to NPC Data + dw $5fd2 ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1071,7 +1071,7 @@ Man2Data: db $00 db $16 db $00 - dw $6137 ; Pointer to NPC Data + dw $6137 ; Pointer to OWScript tx Text03d8 db $00 db $00 @@ -1083,7 +1083,7 @@ Pappy2Data: db $00 db $22 db $00 - dw $613b ; Pointer to NPC Data + dw $613b ; Pointer to OWScript tx Text03dd db $00 db $00 @@ -1095,7 +1095,7 @@ Lass4Data: db $04 db $22 db $00 - dw $63d9 ; Pointer to NPC Data + dw $63d9 ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1107,7 +1107,7 @@ Hood1Data: db $04 db $1e db $00 - dw $63dd ; Pointer to NPC Data + dw $63dd ; Pointer to OWScript tx Text03e2 db $00 db $00 @@ -1119,7 +1119,7 @@ Granny2Data: db $00 db $16 db $00 - dw $66d8 ; Pointer to NPC Data + dw $66d8 ; Pointer to OWScript tx Text03e5 db $00 db $00 @@ -1131,7 +1131,7 @@ Gal2Data: db $00 db $16 db $00 - dw $66e3 ; Pointer to NPC Data + dw $66e3 ; Pointer to OWScript tx Text03db db $00 db $00 @@ -1143,7 +1143,7 @@ Lad3Data: db $04 db $1a db $00 - dw $6850 ; Pointer to NPC Data + dw $6850 ; Pointer to OWScript tx Text03de db $00 db $00 @@ -1155,7 +1155,7 @@ Gal3Data: db $00 db $16 db $00 - dw $6a30 ; Pointer to NPC Data + dw $6a30 ; Pointer to OWScript tx Text03db db $00 db $00 @@ -1167,7 +1167,7 @@ Chap4Data: db $00 db $1a db $00 - dw $6a3b ; Pointer to NPC Data + dw $6a3b ; Pointer to OWScript tx Text03da db $00 db $00 @@ -1179,7 +1179,7 @@ Man3Data: db $00 db $16 db $00 - dw $6bc1 ; Pointer to NPC Data + dw $6bc1 ; Pointer to OWScript tx Text03d8 db $00 db $00 @@ -1191,7 +1191,7 @@ Specs2Data: db $00 db $0e db $00 - dw $6bc5 ; Pointer to NPC Data + dw $6bc5 ; Pointer to OWScript tx Text03e0 db $00 db $00 @@ -1203,7 +1203,7 @@ Specs3Data: db $00 db $22 db $00 - dw $6bed ; Pointer to NPC Data + dw $6bed ; Pointer to OWScript tx Text03e0 db $00 db $00 @@ -1215,7 +1215,7 @@ Woman2Data: db $04 db $1e db $00 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript tx Text03d9 db $00 db $00 @@ -1227,7 +1227,7 @@ ManiaData: db $00 db $26 db $00 - dw $6e88 ; Pointer to NPC Data + dw $6e88 ; Pointer to OWScript tx Text03e4 db $00 db $00 @@ -1239,7 +1239,7 @@ Pappy3Data: db $00 db $22 db $00 - dw $709c ; Pointer to NPC Data + dw $709c ; Pointer to OWScript tx Text03dd db $00 db $00 @@ -1251,7 +1251,7 @@ Gal4Data: db $00 db $16 db $00 - dw $70a0 ; Pointer to NPC Data + dw $70a0 ; Pointer to OWScript tx Text03db db $00 db $00 @@ -1263,7 +1263,7 @@ ChampData: db $00 db $26 db $00 - dw $70a4 ; Pointer to NPC Data + dw $70a4 ; Pointer to OWScript tx Text03e3 db $00 db $00 @@ -1275,7 +1275,7 @@ Hood2Data: db $04 db $1e db $00 - dw $70a8 ; Pointer to NPC Data + dw $70a8 ; Pointer to OWScript tx Text03e2 db $00 db $00 @@ -1287,7 +1287,7 @@ Lass5Data: db $04 db $1a db $00 - dw $70ac ; Pointer to NPC Data + dw $70ac ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1299,7 +1299,7 @@ Chap5Data: db $00 db $1a db $00 - dw $70b0 ; Pointer to NPC Data + dw $70b0 ; Pointer to OWScript tx Text03da db $00 db $00 @@ -1311,7 +1311,7 @@ AaronData: db $00 db $0e db $00 - dw $58dd ; Pointer to NPC Data + dw $58dd ; Pointer to OWScript tx Text03e7 db AARON_PIC db $09 @@ -1323,7 +1323,7 @@ GuideData: db $00 db $16 db $00 - dw $7283 ; Pointer to NPC Data + dw $7283 ; Pointer to OWScript tx Text03e6 db $00 db $00 @@ -1335,7 +1335,7 @@ Tech7Data: db $00 db $0e db $00 - dw $58c6 ; Pointer to NPC Data + dw $58c6 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -1347,7 +1347,7 @@ Tech8Data: db $00 db $0e db $00 - dw $58d1 ; Pointer to NPC Data + dw $58d1 ; Pointer to OWScript tx Text03b2 db $00 db $00 @@ -1359,49 +1359,49 @@ Data_11f18: db $3a db $3a db $10 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f1f: db $68 db $27 db $3b db $41 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f26: db $69 db $27 db $3c db $42 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f2d: db $6a db $27 db $3d db $43 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f34: db $6b db $27 db $3e db $44 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f3b: db $6c db $27 db $3f db $45 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f42: db $6d db $27 db $40 db $46 db $50 - dw $4c3e ; Pointer to NPC Data + dw $4c3e ; Pointer to OWScript Data_11f49: db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 6149c08..5330bd1 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -176,7 +176,7 @@ Func_c158: ; c158 (3:4158) cp $1 ret nz ld a, [wd0c4] - ld [wd3ab], a + ld [wTempNPC], a call Func_39c3 jr c, .asm_c179 ld a, [wd3aa] @@ -580,7 +580,7 @@ Func_c4b9: ; c4b9 (3:44b9) ld a, b ld [wd337], a ld a, $0 - farcall Func_1299f + farcall CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] ld [wd336], a ld b, $2 @@ -1225,51 +1225,51 @@ Func_c943: ; c943 (3:4943) push hl push bc push de - ld l, $0 - call Func_3abd - jr nc, .asm_c98f -.asm_c94d + ld l, MAP_SCRIPT_NPCS + call GetMapScriptPointer + jr nc, .quit +.loadNPCLoop ld a, l - ld [wd4c4], a + ld [wTempPointer], a ld a, h - ld [wd4c5], a - ld a, $4 - ld [wd4c6], a - ld de, wd3ab - ld bc, $0006 + ld [wTempPointer + 1], a + ld a, BANK(MapScripts) + ld [wTempPointerBank], a + ld de, wTempNPC + ld bc, NPC_MAP_SIZE call CopyBankedDataToDE - ld a, [wd3ab] + ld a, [wTempNPC] or a - jr z, .asm_c98f + jr z, .quit push hl - ld a, [wd3af] + ld a, [wLoadNPCFunction] ld l, a - ld a, [wd3b0] + ld a, [wLoadNPCFunction+1] ld h, a or l - jr z, .asm_c97a + jr z, .noScript call CallHL2 - jr nc, .asm_c988 -.asm_c97a - ld a, [wd3ab] - farcall Func_11857 + jr nc, .nextNPC +.noScript + ld a, [wTempNPC] + farcall LoadNPCSpriteData call Func_c998 farcall Func_1c485 -.asm_c988 +.nextNPC pop hl - ld bc, $0006 + ld bc, NPC_MAP_SIZE add hl, bc - jr .asm_c94d -.asm_c98f - ld l, $2 - call Func_c9c2 + jr .loadNPCLoop +.quit + ld l, MAP_SCRIPT_POST_NPC + call CallMapScriptPointerIfExists pop de pop bc pop hl ret Func_c998: ; c998 (3:4998) - ld a, [wd3ab] + ld a, [wTempNPC] cp $22 ret nz ld a, [wd3d0] @@ -1289,23 +1289,23 @@ Func_c998: ; c998 (3:4998) Func_c9b8: ; c9b8 (3:49b8) ld l, $8 - jr Func_c9c2 + jr CallMapScriptPointerIfExists Func_c9bc: ; c9bc (3:49bc) ld l, $a - jr Func_c9c2 + jr CallMapScriptPointerIfExists Func_c9c0: ; c9c0 (3:49c0) ld l, $c -Func_c9c2: ; c9c2 (3:49c2) - call Func_3abd +CallMapScriptPointerIfExists: ; c9c2 (3:49c2) + call GetMapScriptPointer ret nc jp hl Func_c9c7: ; c9c7 (3:49c7) ld l, $e - jr Func_c9c2 + jr CallMapScriptPointerIfExists Func_c9cb: ; c9cb (3:49cb) push hl @@ -1493,7 +1493,9 @@ MaxOutEventFlag: ; cac5 (3:4ac5) ret ; 0xcacd - INCROM $cacd, $cad0 +Func_cacd: ; cacd (3:4acd) + call Func_cab3 +; fallthrough ZeroOutEventFlag: ; cad0 (3:4ad0) push bc @@ -1951,7 +1953,7 @@ OWScript_PrintVariableText: ; cd83 (3:4d83) Func_cd94: ; cd94 (3:4d94) call Func_ca69 - ld b, h + db $44 Unknown_cd98: dec a and $3 @@ -1995,14 +1997,14 @@ Func_cdd1: ; cdd1 (3:4dd1) Func_cdd8: ; cdd8 (3:4dd8) ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] - ld [wd3ab], a + ld [wTempNPC], a call Func_39c3 call Func_cdd1 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af ld [wd3aa], a ret @@ -2010,21 +2012,21 @@ Func_cdd8: ; cdd8 (3:4dd8) Func_cdf5: ; cdf5 (3:4df5) ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] - ld [wd3ab], a + ld [wTempNPC], a ld a, c - ld [wd3ac], a + ld [wLoadNPCXPos], a ld a, b - ld [wd3ad], a + ld [wLoadNPCYPos], a ld a, $2 - ld [wd3ae], a - ld a, [wd3ab] - farcall Func_11857 + ld [wLoadNPCDirection], a + ld a, [wTempNPC] + farcall LoadNPCSpriteData farcall Func_1c485 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af ld [wd3aa], a jp IncreaseOWScriptPointerBy3 @@ -2059,15 +2061,15 @@ Func_ce4a: ; ce4a (3:4e4a) Func_ce52: ; ce52 (3:4e52) ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] asm_ce5d - ld [wd3ab], a + ld [wTempNPC], a call Func_39c3 call Func_ce3a pop af - ld [wd3ab], a + ld [wTempNPC], a pop af ld [wd3aa], a ret @@ -2075,7 +2077,7 @@ asm_ce5d Func_ce6f: ; ce6f (3:4e6f) ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c push af @@ -2270,28 +2272,30 @@ Func_cf7b: ; cf7b (3:4f7b) jr c, .asm_cf7d jp IncreaseOWScriptPointerBy1 -; This function doesn't look like a valid function, but it's pointed to in the table. Func_cf96: ; cf96 (3:4f96) ld c, $0 call Func_ca69 - ld de, $28b7 - ld hl, $08fe + db $11 + or a + jr z, Func_cfc0 + cp a, $08 jr c, .asm_cfa4 inc c .asm_cfa4 call Func_ca69 - rla + db $17 cp $8 jr c, .asm_cfad inc c .asm_cfad call Func_ca69 -.asm_cfb0 - jr nz, .asm_cfb0 - ld [$0138], sp + db $20 + cp a, $08 + jr c, .asm_cfb6 inc c +.asm_cfb6 ld a, c rlca add $3 @@ -2311,7 +2315,7 @@ Func_cfc6: ; cfc6 (3:4fc6) Func_cfd4: ; cfd4 (3:4fd4) call Func_ca69 - dec l + db $2d ld b, a .asm_cfd9 ld a, $5 @@ -2356,7 +2360,7 @@ Func_d00b: ; d00b (3:500b) add hl, bc push hl call Func_ca69 - dec hl + db $2b ld e, a ld d, $0 call GetCardName @@ -2368,21 +2372,21 @@ Func_d00b: ; d00b (3:500b) Func_d025: ; d025 (3:5025) call Func_ca69 - dec hl + db $2b call GetCardCountInCollectionAndDecks jp c, Func_cf67 jp Func_cf6d Func_d032: ; d032 (3:5032) call Func_ca69 - dec hl + db $2b call GetCardCountInCollection jp c, Func_cf67 jp Func_cf6d Func_d03f: ; d03f (3:503f) call Func_ca69 - dec hl + db $2b call RemoveCardFromCollection jp IncreaseOWScriptPointerBy1 @@ -2399,7 +2403,8 @@ Func_d055: ; d055 (3:5055) call Func_c5ce jp IncreaseOWScriptPointerBy2 - +; arg1 - Direction (index in ScriptedMovementOffsetTable) +; arg2 - Tiles Moves (Speed) OWScript_MovePlayer: ; 505c (3:505c) ld a, c ld [wd339], a @@ -2426,7 +2431,7 @@ OWScript_SetDialogName: ; d080 (3:5080) ; Not confident enough to give it a name yet Func_d088: ; d088 (3:5088) ld a, c - ld [wd3ab], a + ld [wTempNPC], a call GetOWSArgs2AfterPointer call Func_c926 jp IncreaseOWScriptPointerBy4 @@ -2498,10 +2503,10 @@ Func_d0f2: ; d0f2 (3:50f2) Func_d103: ; d103 (3:5103) ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c - ld [wd3ab], a + ld [wTempNPC], a call Func_39c3 jr c, .asm_d119 call $54d1 @@ -2512,7 +2517,7 @@ Func_d103: ; d103 (3:5103) .asm_d11c pop af - ld [wd3ab], a + ld [wTempNPC], a pop af ld [wd3aa], a ret @@ -2575,17 +2580,17 @@ Func_d16b: ; d16b (3:516b) jp IncreaseOWScriptPointerBy2 Func_d195: ; d195 (3:5195) - ld a, [wd3ab] + ld a, [wTempNPC] push af call Func_ca69 - ld b, l + db $45 inc a ld c, a call Func_ca8f ld b, l call Func_f580 pop af - ld [wd3ab], a + ld [wTempNPC], a jp IncreaseOWScriptPointerBy1 Func_d1ad: ; d1ad (3:51ad) @@ -2594,7 +2599,7 @@ Func_d1ad: ; d1ad (3:51ad) Func_d1b3: ; d1b3 (3:51b3) call Func_ca69 - ld b, h + db $44 dec a cp $2 jr c, .asm_d1c3 @@ -2623,7 +2628,7 @@ asm_d1c6 Func_d209: ; d209 (3:5209) call Func_ca69 - ld [hl], c + db $71 ld e, a .asm_d20e call UpdateRNGSources @@ -2870,7 +2875,7 @@ OWScript_GivePCPack: ; d3c9 (3:53c9) farcall GivePCPack jp IncreaseOWScriptPointerBy2 -Func_d3d1: ; d3d1 (3:53d1) +OWScript_nop: ; d3d1 (3:53d1) jp IncreaseOWScriptPointerBy1 Func_d3d4: ; d3d4 (3:53d4) @@ -3065,7 +3070,44 @@ OWScript_JumpIfFlagZero2: jp IncreaseOWScriptPointerBy4 ; 0xd4ec - INCROM $d4ec, $d52e +LoadOverworld: ; d4ec (3:54ec) + call Func_d4fb + call Func_ca69 + ld a, $b7 + ret nz + ld bc, OWSequence_d52e + jp Func_c935 + +Func_d4fb: ; d4fb (3:54fb) + call Func_cacd + ld e, c + call Func_f602 + call Func_ca69 + db $3f + cp $02 + jr z, .asm_d527 + call Func_ca69 + db $40 + cp $02 + jr z, .asm_d521 + call Func_ca69 + db $41 + cp $02 + jr z, .asm_d51b + ret +.asm_d51b + ld c, $07 + call Func_ca8f + ld b, c +.asm_d521 + ld c, $07 + call Func_ca8f + ld b, b +.asm_d527 + ld c, $07 + call Func_ca8f + ccf + ret OWSequence_d52e: ; d52e (3:552e) start_script @@ -3088,31 +3130,31 @@ OWSequence_d52e: ; d52e (3:552e) OWSequence_d753: ; d753 (3:5753) start_script run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_MovePlayer - db $00 + db NORTH db $02 run_script OWScript_PrintTextString tx Text05e3 @@ -3145,8 +3187,7 @@ OWSequence_d779: ; d779 (03:5779) run_script OWScript_CloseAdvancedTextBox run_script Func_d088 db $01 - db $94 - db $57 + dw $5794 run_script OWScript_EndScriptLoop1 INCROM $d793, $e13f @@ -3156,11 +3197,11 @@ WaterClubMovePlayer: ; e13f (3:613f) cp $8 ret nz call Func_ca69 - inc sp + db $33 cp $2 ret nc ld a, $21 - ld [wd3ab], a + ld [wTempNPC], a ld bc, OWSequence_NotReadyToSeeAmy jp Func_c926 @@ -3282,7 +3323,7 @@ OWSequence_NotReadyToSeeAmy: db $08 dw $61f8 run_script OWScript_MovePlayer - db $02 + db SOUTH db $04 run_script Func_ce4a db $13 @@ -3474,15 +3515,15 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) run_script Func_d055 db $03 run_script OWScript_MovePlayer - db $03 + db WEST db $01 run_script Func_d055 db $00 run_script OWScript_MovePlayer - db $00 + db NORTH db $01 run_script OWScript_MovePlayer - db $00 + db NORTH db $01 run_script Func_ce6f db $21 @@ -3622,7 +3663,7 @@ FindEndOfBattleScript: ; e52c (3:652c) .found_enemy ld a, [hli] - ld [wd3ab], a + ld [wTempNPC], a ld b, $0 add hl, bc ld c, [hl] @@ -3748,6 +3789,8 @@ ClubEntranceAfterDuel: ; e7f6 (3:67f6) dw OWSequence_LostToSecondRonaldFight db $00 +; A Ronald is already loaded or not loaded depending on Pre-Load scripts +; in data/npc_map_data.asm. This just starts a sequence if possible. LoadClubEntrance: ; e809 (3:6809) call TryFirstRonaldFight call TrySecondRonaldFight @@ -3756,7 +3799,7 @@ LoadClubEntrance: ; e809 (3:6809) TryFirstRonaldEncounter: ; e813 (3:6813) ld a, RONALD1 - ld [wd3ab], a + ld [wTempNPC], a call Func_39c3 ret c ld bc, OWSequence_FirstRonaldEncounter @@ -3768,7 +3811,7 @@ TryFirstRonaldFight: ; e822 (3:6822) call Func_39c3 ret c call Func_ca69 - ld c, h + db $4c or a ret nz ld bc, OWSequence_FirstRonaldFight @@ -3780,7 +3823,7 @@ TrySecondRonaldFight: ; e837 (3:6837) call Func_39c3 ret c call Func_ca69 - ld c, l + db $4d or a ret nz ld bc, OWSequenceSecondRonaldFight @@ -3792,7 +3835,7 @@ TrySecondRonaldFight: ; e837 (3:6837) OWSequence_FirstRonaldEncounter: ; e862 (3:6862) start_script run_script OWScript_MaxOutFlagValue - db $4b + db EVENT_FLAG_4B run_script Func_ce4a db $94 db $68 @@ -3802,10 +3845,10 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) tx Text0645 run_script OWScript_CloseTextBox run_script OWScript_MovePlayer - db $00 + db NORTH db $01 run_script OWScript_MovePlayer - db $00 + db NORTH db $01 run_script OWScript_PrintTextString tx Text0646 @@ -3827,7 +3870,7 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) run_script Func_d055 db $03 run_script OWScript_MovePlayer - db $01 + db EAST db $04 run_script Func_ce4a db $94 @@ -3858,15 +3901,15 @@ OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) run_script Func_d055 db $03 run_script OWScript_MovePlayer - db $03 + db WEST db $01 run_script Func_d055 db $02 run_script OWScript_MovePlayer - db $02 + db SOUTH db $01 run_script OWScript_MovePlayer - db $02 + db SOUTH db $01 run_script OWScript_PrintTextString tx Text064b @@ -3931,15 +3974,15 @@ OWSequenceSecondRonaldFight: ; e91e (3:691e) run_script Func_d055 db $03 run_script OWScript_MovePlayer - db $03 + db WEST db $01 run_script Func_d055 db $02 run_script OWScript_MovePlayer - db $02 + db SOUTH db $01 run_script OWScript_MovePlayer - db $02 + db SOUTH db $01 run_script OWScript_PrintTextString tx Text0650 @@ -3987,11 +4030,11 @@ OWJump_FinishedSecondRonaldFight ; e959 (3:6959) Func_f580: ; f580 (3:7580) call Func_ca69 - ld b, h + db $44 cp $3 jr z, .asm_f596 call Func_ca69 - ld b, l + db $45 cp $3 ld d, $18 jr nz, .asm_f598 @@ -4014,12 +4057,15 @@ Func_f580: ; f580 (3:7580) ld a, [hl] .asm_f5ac - ld [wd3ab], a + ld [wTempNPC], a ld [wd696], a ret ; 0xf5b3 - INCROM $f5b3, $fc2b + INCROM $f5b3, $f602 + +Func_f602: ; f602 (3:7602) + INCROM $f602, $fc2b Func_fc2b: ; fc2b (3:7c2b) ld a, [wDuelResult] diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index e127f70..4cba1d9 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -495,7 +495,7 @@ INCLUDE "data/overworld_indexes.asm" Func_10fbc: ; 10fbc (4:4fbc) ld a, $25 - farcall Func_1299f + farcall CreateSpriteAndAnimBufferEntry ld c, SPRITE_ANIM_COORD_X call GetSpriteAnimBufferProperty ld a, $80 @@ -518,7 +518,7 @@ Func_10fde: ; 10fde (4:4fde) xor a ld [wd33e], a ld a, $25 - call Func_1299f + call CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] ld [wd33b], a ld b, $35 @@ -839,13 +839,13 @@ Func_115a3: ; 115a3 (4:55a3) INCLUDE "data/map_scripts.asm" -; loads a pointer into hl found on PointerTable_118f5 +; loads a pointer into hl found on NPCDataTable GetNPCDataPointer: ; 1184a (4:584a) ; this may have been a macro rlca - add LOW(PointerTable_118f5) + add LOW(NPCDataTable) ld l, a - ld a, HIGH(PointerTable_118f5) + ld a, HIGH(NPCDataTable) adc $00 ld h, a ld a, [hli] @@ -853,12 +853,12 @@ GetNPCDataPointer: ; 1184a (4:584a) ld l, a ret -Func_11857: ; 11857 (4:5857) +LoadNPCSpriteData: ; 11857 (4:5857) push hl push bc call GetNPCDataPointer ld a, [hli] - ld [wd3ab], a + ld [wTempNPC], a ld a, [hli] ld [wd3b3], a ld a, [hli] @@ -869,7 +869,7 @@ Func_11857: ; 11857 (4:5857) ld [wd3b2], a pop bc ld a, [wConsole] - cp $2 + cp CONSOLE_CGB jr nz, .asm_1187a ld a, b ld [wd3b1], a @@ -1036,7 +1036,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d39d dw Func_d3b9 dw OWScript_GivePCPack - dw Func_d3d1 + dw OWScript_nop dw Func_d3d4 dw Func_d3e0 dw Func_d3fe @@ -1231,14 +1231,15 @@ Unknown_128fb: ; 128fb Func_1296e: ; 1296e (4:696e) INCROM $1296e, $1299f -Func_1299f: ; 1299f (4:699f) +; creates a new entry in SpriteAnimBuffer, Alse loads the sprite if need be +CreateSpriteAndAnimBufferEntry: ; 1299f (4:699f) push af ld a, [wd5d7] or a - jr z, .asm_129a8 + jr z, .continue pop af ret -.asm_129a8 +.continue pop af push bc push hl @@ -1246,50 +1247,50 @@ Func_1299f: ; 1299f (4:699f) ld [wd5d3], a xor a ld [wWhichSprite], a - call Func_3db7 - ld bc, $0010 -.asm_129bb + call GetFirstSpriteAnimBufferProperty + ld bc, SPRITE_ANIM_LENGTH +.findFirstEmptyAnimField ld a, [hl] or a - jr z, .asm_129cf + jr z, .foundEmptyAnimField add hl, bc ld a, [wWhichSprite] inc a ld [wWhichSprite], a cp $10 - jr nz, .asm_129bb + jr nz, .findFirstEmptyAnimField debug_ret scf - jr .asm_129d6 -.asm_129cf + jr .quit +.foundEmptyAnimField ld a, $1 ld [hl], a - call Func_129d9 + call FillNewSpriteAnimBufferEntry or a -.asm_129d6 +.quit pop hl pop bc ret -Func_129d9: ; 129d9 (4:69d9) +FillNewSpriteAnimBufferEntry: ; 129d9 (4:69d9) push hl push bc push hl inc hl - ld c, $f + ld c, SPRITE_ANIM_LENGTH - 1 xor a -.asm_129e0 +.clearSpriteAnimBufferEntryLoop ld [hli], a dec c - jr nz, .asm_129e0 + jr nz, .clearSpriteAnimBufferEntryLoop pop hl - ld bc, $0004 + ld bc, SPRITE_ANIM_FIELD_05 - 1 add hl, bc ld a, [wd5d3] ld [hli], a ld a, $ff ld [hl], a - ld bc, $0009 + ld bc, SPRITE_ANIM_MOVEMENT_COUNTER - SPRITE_ANIM_FIELD_05 add hl, bc ld a, $ff ld [hl], a @@ -1324,7 +1325,7 @@ Func_12ab5: ; 12ab5 (4:6ab5) Func_12ae2: ; 12ae2 (4:6ae2) push bc push af - call Func_3db7 + call GetFirstSpriteAnimBufferProperty pop af push hl ld bc, $0005 @@ -1335,12 +1336,12 @@ Func_12ae2: ; 12ae2 (4:6ae2) farcall GetMapDataPointer farcall Func_80229 pop hl - ld a, [wd4c6] + ld a, [wTempPointerBank] ld [hli], a - ld a, [wd4c4] + ld a, [wTempPointer] ld [hli], a ld c, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld [hli], a ld b, a ld a, $3 @@ -1362,15 +1363,15 @@ Func_12b13: ; 12b13 (4:6b13) ld bc, $0006 add hl, bc ld a, [hli] - ld [wd4c6], a + ld [wTempPointerBank], a inc hl inc hl ld a, [hl] - ld [wd4c4], a + ld [wTempPointer], a add $4 ld [hli], a ld a, [hl] - ld [wd4c5], a + ld [wTempPointer + 1], a adc $0 ld [hl], a ld de, wd23e @@ -1423,11 +1424,11 @@ Func_12b6a: ; 12b6a (4:6b6a) ld bc, $0006 add hl, bc ld a, [hli] - ld [wd4c6], a + ld [wTempPointerBank], a ld a, [hli] - ld [wd4c4], a + ld [wTempPointer], a ld a, [hli] - ld [wd4c5], a + ld [wTempPointer + 1], a pop hl call Func_3d72 pop de @@ -1467,6 +1468,8 @@ Func_12ba7: ; 12ba7 (4:6ba7) Func_12bcd: ; 12bcd (4:6bcd) INCROM $12bcd, $12c05 +; gets some value based on the sprite in b and wd5d8 +; loads the sprites data if it doesn't already exist Func_12c05: ; 12c05 (4:6c05) push hl push bc @@ -1477,23 +1480,24 @@ Func_12c05: ; 12c05 (4:6c05) ld c, a ld hl, wd5d8 or a - jr z, .asm_12c22 -.asm_12c15 + jr z, .tryToAddSprite + +.findSpriteMatchLoop inc hl ld a, [hl] cp b - jr z, .asm_12c3a + jr z, .foundSpriteMatch inc hl ld a, [hli] add [hl] ld d, a inc hl dec c - jr nz, .asm_12c15 -.asm_12c22 + jr nz, .findSpriteMatchLoop +.tryToAddSprite ld a, [wd618] cp $10 - jr nc, .asm_12c48 + jr nc, .quitFail inc a ld [wd618], a inc hl @@ -1507,7 +1511,7 @@ Func_12c05: ; 12c05 (4:6c05) pop af ld [hl], a pop hl -.asm_12c3a +.foundSpriteMatch dec hl inc [hl] inc hl @@ -1515,15 +1519,15 @@ Func_12c05: ; 12c05 (4:6c05) ld a, [hli] add [hl] cp $81 - jr nc, .asm_12c48 + jr nc, .quitFail ld a, d or a - jr .asm_12c4b -.asm_12c48 + jr .quitSucceed +.quitFail debug_ret xor a scf -.asm_12c4b +.quitSucceed pop de pop bc pop hl @@ -1584,4 +1588,8 @@ Func_13485: ; 13485 (4:7485) ret ; 0x134b1 - INCROM $134b1, $14000 + INCROM $134b1, $1372f + +INCLUDE "data/npc_map_data.asm" + + INCROM $13b04, $14000 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 25534f1..0b2ec00 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -128,8 +128,83 @@ Func_1c477: ; 1c477 (7:4477) pop hl ret +; Loads NPC Sprite Data Func_1c485: ; 1c485 (7:4485) - INCROM $1c485, $1c50a + push hl + push bc + push de + xor a + ld [wd3aa], a + ld b, a + ld c, $08 + ld hl, wd34a + ld de, $c +.findEmptyIndexLoop + ld a, [hl] + or a + jr z, .foundEmptyIndex + add hl, de + inc b + dec c + jr nz, .findEmptyIndexLoop + ld hl, wd34a + debug_ret + jr .exit +.foundEmptyIndex + ld a, b + ld [wd3aa], a + ld a, [wd3b3] + farcall CreateSpriteAndAnimBufferEntry + jr c, .exit + ld a, [wd3aa] + call Func_39a7 + push hl + ld a, [wTempNPC] + ld [hli], a + ld a, [wWhichSprite] + ld [hli], a + ld a, [wLoadNPCXPos] + ld [hli], a + ld a, [wLoadNPCYPos] + ld [hli], a + ld a, [wLoadNPCDirection] + ld [hli], a + ld a, [wd3b2] + ld [hli], a + ld a, [wd3b1] + ld [hli], a + ld a, [wLoadNPCDirection] + ld [hli], a + call Func_1c58e + call Func_1c5b9 + ld hl, wd349 + inc [hl] + pop hl + call Func_1c665 + call Func_1c6e3 + ld a, [wTempNPC] + call Func_1c4fa + jr nc, .exit + ld a, $01 + ld [wd3b8], a +.exit + pop de + pop bc + pop hl + ret + +Func_1c4fa: ; 1c4fa (7:44fa) + cp RONALD1 + jr z, .asm_1c508 + cp RONALD2 + jr z, .asm_1c508 + cp RONALD3 + jr z, .asm_1c508 + or a + ret +.asm_1c508 + scf + ret Func_1c50a: ; 1c50a (7:450a) push hl @@ -190,10 +265,10 @@ Func_1c557: ; 1c557 (7:4557) ld c, a ld a, [wd3aa] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c - ld [wd3ab], a + ld [wTempNPC], a ld c, $0 call Func_39c3 jr c, .asm_1c570 @@ -202,7 +277,7 @@ Func_1c557: ; 1c557 (7:4557) .asm_1c570 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af ld [wd3aa], a ld a, c @@ -253,6 +328,7 @@ Func_1c58e: ; 1c58e (7:458e) ret ; 0x1c5b9 +Func_1c5b9: ; 1c5b9 (7:45b9) INCROM $1c5b9, $1c5e9 Func_1c5e9: ; 1c5e9 (7:45e9) @@ -274,7 +350,25 @@ Func_1c5e9: ; 1c5e9 (7:45e9) INCROM $1c5ff, $1c610 Func_1c610: ; 1c610 (7:4610) - INCROM $1c610, $1c6f8 + INCROM $1c610, $1c665 + +Func_1c665: ; 1c665 (7:4665) + INCROM $1c665, $1c6e3 + +Func_1c6e3: ; 1c6e3 (7:46e3) + push hl + push bc + ld a, [$d3aa] + ld l, $02 + call Func_39ad + ld a, [hli] + ld b, a + ld c, [hl] + ld a, $40 + call SetPermissionOfMapPosition + pop bc + pop hl + ret Func_1c6f8: ; 1c6f8 (7:46f8) INCROM $1c6f8, $1c719 diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 1502ea4..0086f96 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -31,7 +31,7 @@ Func_80077: ; 80077 (20:4077) inc hl ld [hl], d call Func_803b9 - ld a, [wd4c6] + ld a, [wTempPointerBank] ld [wd23d], a ld de, wd23e ld bc, $0006 @@ -58,10 +58,10 @@ Func_800bd: ; 800bd (20:40bd) push hl push bc push de - ld a, [wd4c4] + ld a, [wTempPointer] add $05 ld e, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] adc $00 ld d, a ld b, $c0 @@ -298,12 +298,12 @@ GetMapDataPointer: ; 8020f (20:420f) Func_80229: ; 80229 (20:4229) ld a, [hli] - ld [wd4c4], a + ld [wTempPointer], a ld a, [hli] - ld [wd4c5], a + ld [wTempPointer + 1], a ld a, [hli] add $20 - ld [wd4c6], a + ld [wTempPointerBank], a ret ; 0x80238 @@ -342,7 +342,7 @@ asm_8027c ld e, [hl] inc hl ld d, [hl] - ld hl, wd4c4 + ld hl, wTempPointer ld a, [hli] ld h, [hl] ld l, a diff --git a/src/engine/home.asm b/src/engine/home.asm index 8545b3d..adcbabd 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -10865,7 +10865,7 @@ GetPermissionByteOfMapPosition: ; 3946 (0:3946) Func_395a: ; 395a (0:395a) ldh a, [hBankROM] push af - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM call CopyGfxData pop af @@ -10934,6 +10934,9 @@ Func_39ad: ; 39ad (0:39ad) pop bc ret +; Finds the index on wd34a table of the npc in wTempNPC +; returns it in a and puts it into wd3aa +; c flag set if no npc found Func_39c3: ; 39c3 (0:39c3) push hl push bc @@ -10944,21 +10947,21 @@ Func_39c3: ; 39c3 (0:39c3) ld c, $8 ld de, $000c ld hl, wd34a - ld a, [wd3ab] -.asm_39d6 + ld a, [wTempNPC] +.findNPCLoop cp [hl] - jr z, .asm_39e1 + jr z, .foundNPCMatch add hl, de inc b dec c - jr nz, .asm_39d6 + jr nz, .findNPCLoop scf - jr z, .asm_39e6 -.asm_39e1 + jr z, .exit +.foundNPCMatch ld a, b ld [wd3aa], a or a -.asm_39e6 +.exit pop de pop bc pop hl @@ -11059,7 +11062,7 @@ Func_3a5e: ; 3a5e (0:3a5e) ldh a, [hBankROM] push af ld l, $4 - call Func_3abd + call GetMapScriptPointer jr nc, .asm_3ab3 ld a, BANK(Func_c653) call BankswitchROM @@ -11113,7 +11116,10 @@ Func_3a5e: ; 3a5e (0:3a5e) call $49c2 ret -Func_3abd: ; 3abd (0:3abd) +; returns a map script pointer in hl given +; current map in wCurMap and which sub-script in l +; sets c if pointer is found +GetMapScriptPointer: ; 3abd (0:3abd) push bc push hl ld a, [wCurMap] @@ -11321,7 +11327,7 @@ ResetDoFrameFunction: ; 3bdb (0:3bdb) Func_3be4: ; 3be4 (0:3be4) ldh a, [hBankROM] push af - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM call Func_08de pop af @@ -11329,16 +11335,16 @@ Func_3be4: ; 3be4 (0:3be4) ret ; 0x3bf5 -; Copies bc bytes from [wd4c4] to de +; Copies bc bytes from [wTempPointer] to de CopyBankedDataToDE: ; 3bf5 (0:3bf5) ldh a, [hBankROM] push af push hl - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM - ld a, [wd4c4] + ld a, [wTempPointer] ld l, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld h, a call CopyDataHLtoDE_SaveRegisters pop hl @@ -11635,11 +11641,11 @@ Func_3d72: ; 3d72 (0:3d72) xor a jr .asm_3da1 .asm_3d84 - ld a, [wd4c4] + ld a, [wTempPointer] ld l, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld h, a - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM ld a, [hli] push af @@ -11670,7 +11676,7 @@ Func_3d72: ; 3d72 (0:3d72) call BankswitchROM ret -Func_3db7: ; 3db7 (0:3db7) +GetFirstSpriteAnimBufferProperty: ; 3db7 (0:3db7) push bc ld c, SPRITE_ANIM_FIELD_00 call GetSpriteAnimBufferProperty diff --git a/src/wram.asm b/src/wram.asm index 4d71b86..0259c7a 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -2070,23 +2070,20 @@ wd34a:: ; d34a wd3aa:: ; d3aa ds $1 -wd3ab:: ; d3ab +wTempNPC:: ; d3ab ds $1 -wd3ac:: ; d3ac +wLoadNPCXPos:: ; d3ac ds $1 -wd3ad:: ; d3ad +wLoadNPCYPos:: ; d3ad ds $1 -wd3ae:: ; d3ae +wLoadNPCDirection:: ; d3ae ds $1 -wd3af:: ; d3af - ds $1 - -wd3b0:: ; d3b0 - ds $1 +wLoadNPCFunction:: ; d3af + ds $2 wd3b1:: ; d3b1 ds $1 @@ -2211,13 +2208,10 @@ wd4c3:: ; d4c3 ds $1 ; these next 3 seem to be an address (bank @ end) for copying bg data -wd4c4:: ; d4c4 - ds $1 - -wd4c5:: ; d4c5 - ds $1 +wTempPointer:: ; d4c4 + ds $2 -wd4c6:: ; d4c6 +wTempPointerBank:: ; d4c6 ds $1 wd4c7:: ; d4c7 @@ -2286,6 +2280,7 @@ wd5d7:: ; d5d7 wd5d8:: ; d5d8 ds $40 +; seems to be the amount of entries in wd5d8 wd618:: ; d618 ds $1 -- cgit v1.2.3 From a44f17b9a15cf1a572d5e8056a69c368265729f2 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sun, 6 Oct 2019 23:00:27 -0400 Subject: Fixed a few macros that were giving weird code. Updated tcgdisasm --- src/constants.asm | 3 +- src/constants/misc_constants.asm | 8 - src/constants/npc_constants.asm | 18 ++ src/constants/script_constants.asm | 128 ++++++++++ src/engine/bank03.asm | 507 +++++++++++++++++-------------------- src/engine/bank04.asm | 12 +- src/engine/bank07.asm | 128 +++++----- src/engine/home.asm | 37 +-- src/macros/code.asm | 18 ++ src/macros/constants.asm | 6 +- src/macros/scripts.asm | 2 +- src/macros/wram.asm | 15 ++ src/wram.asm | 24 +- 13 files changed, 523 insertions(+), 383 deletions(-) create mode 100644 src/constants/script_constants.asm (limited to 'src') diff --git a/src/constants.asm b/src/constants.asm index 76b206c..7ad156b 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -16,4 +16,5 @@ INCLUDE "constants/sgb_constants.asm" INCLUDE "constants/sfx_constants.asm" INCLUDE "constants/sprite_constants.asm" INCLUDE "constants/text_constants.asm" -INCLUDE "constants/charmaps.asm" \ No newline at end of file +INCLUDE "constants/charmaps.asm" +INCLUDE "constants/script_constants.asm" diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index 53b2be4..b31631a 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -44,11 +44,3 @@ FLUSH_ALL_PALS_F EQU 6 const GAME_EVENT_CONTINUE_DUEL ; $5 const GAME_EVENT_CHALLENGE_MACHINE ; $6 NUM_GAME_EVENTS EQU const_value - -; Script constant -NO_JUMP EQU $0000 - -NORTH EQU $00 -EAST EQU $01 -SOUTH EQU $02 -WEST EQU $03 diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index f85dc1c..9e3911c 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -1,3 +1,21 @@ +LOADED_NPC_MAX EQU $08 + +; wLoadedNPCs structure + const_def + const LOADED_NPC_ID + const LOADED_NPC_SPRITE + const LOADED_NPC_COORD_X + const LOADED_NPC_COORD_Y + const LOADED_NPC_DIRECTION + const LOADED_NPC_FIELD_05 + const LOADED_NPC_FIELD_06 + const LOADED_NPC_FIELD_07 + const LOADED_NPC_FIELD_08 + const LOADED_NPC_FIELD_09 + const LOADED_NPC_FIELD_0A + const LOADED_NPC_FIELD_0B +LOADED_NPC_LENGTH EQU const_value + ; npc_struct constants const_def const NPC_TRAINER_ID diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm new file mode 100644 index 0000000..398eeb3 --- /dev/null +++ b/src/constants/script_constants.asm @@ -0,0 +1,128 @@ + const_def + const EVENT_FLAG_00 + const EVENT_FLAG_01 + const EVENT_FLAG_02 + const EVENT_FLAG_03 + const EVENT_FLAG_04 + const EVENT_FLAG_05 + const EVENT_FLAG_06 + const EVENT_FLAG_07 + const EVENT_FLAG_08 + const EVENT_FLAG_09 + const EVENT_FLAG_0A + const EVENT_BEAT_AMY + const EVENT_FLAG_0C + const EVENT_FLAG_0D + const EVENT_FLAG_0E + const EVENT_FLAG_0F + const EVENT_FLAG_10 + const EVENT_FLAG_11 + const EVENT_FLAG_12 + const EVENT_FLAG_13 + const EVENT_FLAG_14 + const EVENT_BEAT_SARA + const EVENT_BEAT_AMANDA + const EVENT_FLAG_17 + const EVENT_FLAG_18 + const EVENT_FLAG_19 + const EVENT_FLAG_1A + const EVENT_FLAG_1B + const EVENT_FLAG_1C + const EVENT_FLAG_1D + const EVENT_FLAG_1E + const EVENT_FLAG_1F + const EVENT_FLAG_20 + const EVENT_FLAG_21 + const EVENT_FLAG_22 + const EVENT_FLAG_23 + const EVENT_FLAG_24 + const EVENT_FLAG_25 + const EVENT_FLAG_26 + const EVENT_FLAG_27 + const EVENT_FLAG_28 + const EVENT_FLAG_29 + const EVENT_FLAG_2A + const EVENT_FLAG_2B + const EVENT_FLAG_2C + const EVENT_FLAG_2D + const EVENT_FLAG_2E + const EVENT_FLAG_2F + const EVENT_FLAG_30 + const EVENT_FLAG_31 + const EVENT_FLAG_32 + const EVENT_JOSHUA_STATE + const EVENT_FLAG_34 + const EVENT_FLAG_35 + const EVENT_FLAG_36 + const EVENT_FLAG_37 + const EVENT_FLAG_38 + const EVENT_FLAG_39 + const EVENT_FLAG_3A + const EVENT_FLAG_3B + const FLAG_BEAT_BRITTANY + const EVENT_FLAG_3D + const EVENT_FLAG_3E + const EVENT_FLAG_3F + const EVENT_FLAG_40 + const EVENT_FLAG_41 + const EVENT_FLAG_42 + const EVENT_FLAG_43 + const EVENT_FLAG_44 + const EVENT_FLAG_45 + const EVENT_FLAG_46 + const EVENT_FLAG_47 + const EVENT_FLAG_48 + const EVENT_FLAG_49 + const EVENT_FLAG_4A + const EVENT_FLAG_4B + const EVENT_FLAG_4C + const EVENT_FLAG_4D + const EVENT_FLAG_4E + const EVENT_FLAG_4F + const EVENT_FLAG_50 + const EVENT_FLAG_51 + const EVENT_FLAG_52 + const EVENT_FLAG_53 + const EVENT_FLAG_54 + const EVENT_FLAG_55 + const EVENT_FLAG_56 + const EVENT_FLAG_57 + const EVENT_FLAG_58 + const EVENT_FLAG_59 + const EVENT_FLAG_5A + const EVENT_FLAG_5B + const EVENT_FLAG_5C + const EVENT_FLAG_5D + const EVENT_FLAG_5E + const EVENT_FLAG_5F + const EVENT_FLAG_60 + const EVENT_FLAG_61 + const EVENT_FLAG_62 + const EVENT_FLAG_63 + const EVENT_FLAG_64 + const EVENT_FLAG_65 + const EVENT_FLAG_66 + const EVENT_FLAG_67 + const EVENT_FLAG_68 + const EVENT_FLAG_69 + const EVENT_FLAG_6A + const EVENT_FLAG_6B + const EVENT_FLAG_6C + const EVENT_FLAG_6D + const EVENT_FLAG_6E + const EVENT_FLAG_6F + const EVENT_FLAG_70 + const EVENT_FLAG_71 + const EVENT_FLAG_72 + const EVENT_FLAG_73 + const EVENT_FLAG_74 + const EVENT_FLAG_75 + const EVENT_FLAG_76 +EVENT_FLAG_AMOUNT EQU const_value + +NO_JUMP EQU $0000 + +NORTH EQU $00 +EAST EQU $01 +SOUTH EQU $02 +WEST EQU $03 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 5330bd1..c75c009 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -109,18 +109,18 @@ Func_c0ed: ; c0ed (3:40ed) Func_c0f1: ; c0f1 (3:40f1) ld a, [wd3b6] - ld [wd3aa], a - farcall Func_1c768 + ld [wLoadedNPCTempIndex], a + farcall SetNewOWSequenceNPC ld a, c - ld [wd0c6], a + ld [wNextOWSequence], a ld a, b - ld [wd0c7], a + ld [wNextOWSequence+1], a ld a, $3 ld [wd0bf], a jr Func_c10a Func_c10a: ; c10a (3:410a) - ld hl, wd0c6 + ld hl, wNextOWSequence ld a, [hli] ld h, [hl] ld l, a @@ -135,7 +135,7 @@ CloseAdvancedDialogueBox: ; c111 (3:4111) bit 1, a jr z, .asm_c12a ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a farcall Func_1c5e9 .asm_c12a xor a @@ -177,11 +177,11 @@ Func_c158: ; c158 (3:4158) ret nz ld a, [wd0c4] ld [wTempNPC], a - call Func_39c3 + call FindLoadedNPC jr c, .asm_c179 - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [wd0c5] ld [hl], a farcall Func_1c58e @@ -283,7 +283,7 @@ Func_c228: ; c228 (3:4228) ld [wd0bc], a ld a, [wPlayerYCoord] ld [wd0bd], a - ld a, [wd334] + ld a, [wPlayerDirection] ld [wd0be], a ret @@ -591,7 +591,7 @@ Func_c4b9: ; c4b9 (3:44b9) ld b, a .asm_c4ee ld a, b - ld [wd334], a + ld [wPlayerDirection], a call Func_c5e9 ld a, [wCurMap] cp OVERWORLD_MAP @@ -716,7 +716,7 @@ Func_c5ac: ; c5ac (3:45ac) Func_c5cb: ; c5cb (3:45cb) call Func_c5d5 Func_c5ce: ; c5ce (3:45ce) - ld [wd334], a + ld [wPlayerDirection], a call Func_c5e9 ret @@ -744,7 +744,7 @@ Func_c5e9: ; c5e9 (3:45e9) ld [wWhichSprite], a ld a, [wd337] ld b, a - ld a, [wd334] + ld a, [wPlayerDirection] add b farcall Func_12ab5 pop bc @@ -802,7 +802,7 @@ AttemptScriptedMovement: ; c619 (3:4619) ret Func_c653: ; c653 (3:4653) - ld a, [wd334] + ld a, [wPlayerDirection] FindScriptedMovementWithOffset: ; c656 (3:4656) rlca @@ -833,7 +833,7 @@ Func_c66c: ; c66c (3:466c) jr c, .asm_c67e inc c .asm_c67e - ld a, [wd334] + ld a, [wPlayerDirection] call Func_c694 pop bc pop hl @@ -949,7 +949,7 @@ Func_c71e: ; c71e (3:471e) jr z, .asm_c73d farcall Func_1c72e jr c, .asm_c73d - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] ld [wd3b6], a ld a, $2 jr .asm_c748 @@ -1201,18 +1201,18 @@ Func_c915: ; c915 (3:4915) pop bc ret -Func_c926: ; c926 (3:4926) +SetNextNPCAndOWSequence: ; c926 (3:4926) push bc - call Func_39c3 - ld a, [wd3aa] + call FindLoadedNPC + ld a, [wLoadedNPCTempIndex] ld [wd3b6], a - farcall Func_1c768 + farcall SetNewOWSequenceNPC pop bc ; fallthrough -Func_c935: ; c935 (3:4935) +SetNextOWSequence: ; c935 (3:4935) push hl - ld hl, wd0c6 + ld hl, wNextOWSequence ld [hl], c inc hl ld [hl], b @@ -1332,8 +1332,7 @@ Func_c9dd: ; c9dd (3:49dd) Func_c9e8: ; c9e8 (3:49e8) ld c, $0 - call Func_ca69 - db $13 + get_flag_value EVENT_FLAG_13 cp $2 jr c, .asm_ca04 .asm_c9f2 @@ -1348,8 +1347,7 @@ Func_c9e8: ; c9e8 (3:49e8) jr z, .asm_c9f2 .asm_ca04 ld a, c - call Func_ca8f - db $34 + set_flag_value EVENT_FLAG_34 ret Unknown_ca0a: ; ca0a (3:4a04) @@ -1359,12 +1357,10 @@ Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] cp $b jr z, .asm_ca68 - call Func_ca69 - db $22 + get_flag_value EVENT_FLAG_22 or a jr nz, .asm_ca4a - call Func_ca69 - db $40 + get_flag_value EVENT_FLAG_40 cp $7 jr z, .asm_ca68 or a @@ -1372,12 +1368,10 @@ Func_ca0e: ; ca0e (3:4a0e) cp $2 jr z, .asm_ca62 ld c, $1 - call Func_ca8f - db $40 + set_flag_value EVENT_FLAG_40 jr .asm_ca62 .asm_ca33 - call Func_ca69 - db $3f + get_flag_value EVENT_FLAG_3F cp $7 jr z, .asm_ca68 or a @@ -1385,8 +1379,7 @@ Func_ca0e: ; ca0e (3:4a0e) cp $2 jr z, .asm_ca68 ld c, $1 - call Func_ca8f - db $3f + set_flag_value EVENT_FLAG_3F jr .asm_ca68 .asm_ca4a call UpdateRNGSources @@ -1396,22 +1389,20 @@ Func_ca0e: ; ca0e (3:4a0e) jr z, .asm_ca56 ld c, $0 .asm_ca56 - call Func_ca8f - db $41 + set_flag_value EVENT_FLAG_41 jr .asm_ca5c .asm_ca5c ld c, $7 - call Func_ca8f - db $40 + set_flag_value EVENT_FLAG_40 .asm_ca62 ld c, $7 - call Func_ca8f - db $3f + set_flag_value EVENT_FLAG_3F .asm_ca68 ret -Func_ca69: ; ca69 (3:4a69) - call Func_cab3 +GetStackFlagValue: ; ca69 (3:4a69) + call GetByteAfterCall +; fallthrough ; returns the event flag's value in a ; also ors it with itself before returning @@ -1437,8 +1428,11 @@ GetEventFlagValue: ; ca6c (3:4a6c) INCROM $ca84, $ca8f -Func_ca8f: ; ca8f (3:4a8f) - call Func_cab3 +; Use macro set_flag_value. The byte db'd after this func is called +; is used at the flag argument for SetEventFlagValue +SetStackFlagValue: ; ca8f (3:4a8f) + call GetByteAfterCall +; fallthrough ; a - flag ; c - value - truncated to fit only the flag's bounds @@ -1466,7 +1460,8 @@ SetEventFlagValue: ; ca92 (3:4a92) pop hl ret -Func_cab3: ; cab3 (3:4ab3) +; returns in a the byte db'd after the call to a function that calls this +GetByteAfterCall: ; cab3 (3:4ab3) push hl ld hl, sp+$4 push bc @@ -1493,8 +1488,8 @@ MaxOutEventFlag: ; cac5 (3:4ac5) ret ; 0xcacd -Func_cacd: ; cacd (3:4acd) - call Func_cab3 +ZeroStackFlagValue: ; cacd (3:4acd) + call GetByteAfterCall ; fallthrough ZeroOutEventFlag: ; cad0 (3:4ad0) @@ -1519,8 +1514,8 @@ Func_cad8: ; cad8 (3:4ad8) dec c jr nz, .asm_cae0 ld c, b - call Func_ca8f - ld l, $79 + set_flag_value EVENT_FLAG_2E + ld a, c push af cp $8 jr nc, .asm_caff @@ -1572,126 +1567,125 @@ GetEventFlag: ; cb1d (3:4b1d) ; offset - bytes to set or reset EventFlagMods: ; cb37 (3:4b37) - const_def - flag_def EVENT_FLAG_00, $3f, %10000000 - flag_def EVENT_FLAG_01, $3f, %01000000 - flag_def EVENT_FLAG_02, $3f, %00100000 - flag_def EVENT_FLAG_03, $3f, %00010000 - flag_def EVENT_FLAG_04, $3f, %00001000 - flag_def EVENT_FLAG_05, $3f, %00000100 - flag_def EVENT_FLAG_06, $3f, %00000010 - flag_def EVENT_FLAG_07, $3f, %00000001 - flag_def EVENT_FLAG_08, $00, %10000000 - flag_def EVENT_FLAG_09, $00, %01000000 - flag_def EVENT_FLAG_0A, $00, %00100000 - flag_def EVENT_BEAT_AMY, $00, %00010000 - flag_def EVENT_FLAG_0C, $00, %00001000 - flag_def EVENT_FLAG_0D, $00, %00000100 - flag_def EVENT_FLAG_0E, $00, %00000010 - flag_def EVENT_FLAG_0F, $00, %00000001 - flag_def EVENT_FLAG_10, $00, %11111111 - flag_def EVENT_FLAG_11, $01, %11110000 - flag_def EVENT_FLAG_12, $01, %00001111 - flag_def EVENT_FLAG_13, $02, %11000000 - flag_def EVENT_FLAG_14, $02, %00110000 - flag_def EVENT_BEAT_SARA, $02, %00001000 - flag_def EVENT_BEAT_AMANDA, $02, %00000100 - flag_def EVENT_FLAG_17, $03, %11110000 - flag_def EVENT_FLAG_18, $03, %00001111 - flag_def EVENT_FLAG_19, $04, %11110000 - flag_def EVENT_FLAG_1A, $04, %00001111 - flag_def EVENT_FLAG_1B, $05, %10000000 - flag_def EVENT_FLAG_1C, $05, %01000000 - flag_def EVENT_FLAG_1D, $05, %00100000 - flag_def EVENT_FLAG_1E, $05, %00010000 - flag_def EVENT_FLAG_1F, $05, %00001111 - flag_def EVENT_FLAG_20, $06, %11110000 - flag_def EVENT_FLAG_21, $06, %00001100 - flag_def EVENT_FLAG_22, $06, %00000010 - flag_def EVENT_FLAG_23, $06, %00000001 - flag_def EVENT_FLAG_24, $07, %11000000 - flag_def EVENT_FLAG_25, $07, %00100000 - flag_def EVENT_FLAG_26, $07, %00010000 - flag_def EVENT_FLAG_27, $07, %00001000 - flag_def EVENT_FLAG_28, $07, %00000100 - flag_def EVENT_FLAG_29, $07, %00000010 - flag_def EVENT_FLAG_2A, $07, %00000001 - flag_def EVENT_FLAG_2B, $08, %11111111 - flag_def EVENT_FLAG_2C, $09, %11100000 - flag_def EVENT_FLAG_2D, $09, %00011111 - flag_def EVENT_FLAG_2E, $0a, %11110000 - flag_def EVENT_FLAG_2F, $0a, %00001000 - flag_def EVENT_FLAG_30, $0a, %00000100 - flag_def EVENT_FLAG_31, $0a, %00000011 - flag_def EVENT_FLAG_32, $0b, %10000000 - flag_def EVENT_JOSHUA_STATE, $0b, %01110000 - flag_def EVENT_FLAG_34, $0b, %00001100 - flag_def EVENT_FLAG_35, $0b, %00000011 - flag_def EVENT_FLAG_36, $0c, %11100000 - flag_def EVENT_FLAG_37, $0c, %00011100 - flag_def EVENT_FLAG_38, $0c, %00000010 - flag_def EVENT_FLAG_39, $0c, %00000001 - flag_def EVENT_FLAG_3A, $0d, %10000000 - flag_def EVENT_FLAG_3B, $0d, %01000000 - flag_def FLAG_BEAT_BRITTANY, $0d, %00100000 - flag_def EVENT_FLAG_3D, $0d, %00010000 - flag_def EVENT_FLAG_3E, $0d, %00001110 - flag_def EVENT_FLAG_3F, $0e, %11100000 - flag_def EVENT_FLAG_40, $0e, %00011100 - flag_def EVENT_FLAG_41, $0f, %11100000 - flag_def EVENT_FLAG_42, $10, %10000000 - flag_def EVENT_FLAG_43, $10, %01000000 - flag_def EVENT_FLAG_44, $10, %00110000 - flag_def EVENT_FLAG_45, $10, %00001100 - flag_def EVENT_FLAG_46, $10, %00000010 - flag_def EVENT_FLAG_47, $10, %00000001 - flag_def EVENT_FLAG_48, $11, %11100000 - flag_def EVENT_FLAG_49, $11, %00011100 - flag_def EVENT_FLAG_4A, $12, %11100000 - flag_def EVENT_FLAG_4B, $13, %10000000 - flag_def EVENT_FLAG_4C, $13, %01100000 - flag_def EVENT_FLAG_4D, $13, %00011000 - flag_def EVENT_FLAG_4E, $13, %00000100 - flag_def EVENT_FLAG_4F, $13, %00000010 - flag_def EVENT_FLAG_50, $14, %10000000 - flag_def EVENT_FLAG_51, $14, %01000000 - flag_def EVENT_FLAG_52, $14, %00100000 - flag_def EVENT_FLAG_53, $14, %00010000 - flag_def EVENT_FLAG_54, $14, %00001000 - flag_def EVENT_FLAG_55, $14, %00000100 - flag_def EVENT_FLAG_56, $14, %00000010 - flag_def EVENT_FLAG_57, $14, %00000001 - flag_def EVENT_FLAG_58, $15, %11110000 - flag_def EVENT_FLAG_59, $15, %00001000 - flag_def EVENT_FLAG_5A, $16, %10000000 - flag_def EVENT_FLAG_5B, $16, %01000000 - flag_def EVENT_FLAG_5C, $16, %00100000 - flag_def EVENT_FLAG_5D, $16, %00010000 - flag_def EVENT_FLAG_5E, $16, %00001000 - flag_def EVENT_FLAG_5F, $16, %00000100 - flag_def EVENT_FLAG_60, $16, %00000010 - flag_def EVENT_FLAG_61, $16, %00000001 - flag_def EVENT_FLAG_62, $16, %11111111 - flag_def EVENT_FLAG_63, $17, %10000000 - flag_def EVENT_FLAG_64, $17, %01000000 - flag_def EVENT_FLAG_65, $17, %00110000 - flag_def EVENT_FLAG_66, $17, %00001000 - flag_def EVENT_FLAG_67, $17, %00000100 - flag_def EVENT_FLAG_68, $18, %11000000 - flag_def EVENT_FLAG_69, $18, %00110000 - flag_def EVENT_FLAG_6A, $18, %00001100 - flag_def EVENT_FLAG_6B, $18, %00000011 - flag_def EVENT_FLAG_6C, $19, %11000000 - flag_def EVENT_FLAG_6D, $19, %00100000 - flag_def EVENT_FLAG_6E, $19, %00010000 - flag_def EVENT_FLAG_6F, $19, %00001000 - flag_def EVENT_FLAG_70, $19, %00000100 - flag_def EVENT_FLAG_71, $19, %00111100 - flag_def EVENT_FLAG_72, $1a, %11111100 - flag_def EVENT_FLAG_73, $1a, %00000011 - flag_def EVENT_FLAG_74, $1b, %11111111 - flag_def EVENT_FLAG_75, $1c, %11110000 - flag_def EVENT_FLAG_76, $1c, %00001111 + flag_def $3f, %10000000 ; EVENT_FLAG_00 + flag_def $3f, %01000000 ; EVENT_FLAG_01 + flag_def $3f, %00100000 ; EVENT_FLAG_02 + flag_def $3f, %00010000 ; EVENT_FLAG_03 + flag_def $3f, %00001000 ; EVENT_FLAG_04 + flag_def $3f, %00000100 ; EVENT_FLAG_05 + flag_def $3f, %00000010 ; EVENT_FLAG_06 + flag_def $3f, %00000001 ; EVENT_FLAG_07 + flag_def $00, %10000000 ; EVENT_FLAG_08 + flag_def $00, %01000000 ; EVENT_FLAG_09 + flag_def $00, %00100000 ; EVENT_FLAG_0A + flag_def $00, %00010000 ; EVENT_BEAT_AMY + flag_def $00, %00001000 ; EVENT_FLAG_0C + flag_def $00, %00000100 ; EVENT_FLAG_0D + flag_def $00, %00000010 ; EVENT_FLAG_0E + flag_def $00, %00000001 ; EVENT_FLAG_0F + flag_def $00, %11111111 ; EVENT_FLAG_10 + flag_def $01, %11110000 ; EVENT_FLAG_11 + flag_def $01, %00001111 ; EVENT_FLAG_12 + flag_def $02, %11000000 ; EVENT_FLAG_13 + flag_def $02, %00110000 ; EVENT_FLAG_14 + flag_def $02, %00001000 ; EVENT_BEAT_SARA + flag_def $02, %00000100 ; EVENT_BEAT_AMANDA + flag_def $03, %11110000 ; EVENT_FLAG_17 + flag_def $03, %00001111 ; EVENT_FLAG_18 + flag_def $04, %11110000 ; EVENT_FLAG_19 + flag_def $04, %00001111 ; EVENT_FLAG_1A + flag_def $05, %10000000 ; EVENT_FLAG_1B + flag_def $05, %01000000 ; EVENT_FLAG_1C + flag_def $05, %00100000 ; EVENT_FLAG_1D + flag_def $05, %00010000 ; EVENT_FLAG_1E + flag_def $05, %00001111 ; EVENT_FLAG_1F + flag_def $06, %11110000 ; EVENT_FLAG_20 + flag_def $06, %00001100 ; EVENT_FLAG_21 + flag_def $06, %00000010 ; EVENT_FLAG_22 + flag_def $06, %00000001 ; EVENT_FLAG_23 + flag_def $07, %11000000 ; EVENT_FLAG_24 + flag_def $07, %00100000 ; EVENT_FLAG_25 + flag_def $07, %00010000 ; EVENT_FLAG_26 + flag_def $07, %00001000 ; EVENT_FLAG_27 + flag_def $07, %00000100 ; EVENT_FLAG_28 + flag_def $07, %00000010 ; EVENT_FLAG_29 + flag_def $07, %00000001 ; EVENT_FLAG_2A + flag_def $08, %11111111 ; EVENT_FLAG_2B + flag_def $09, %11100000 ; EVENT_FLAG_2C + flag_def $09, %00011111 ; EVENT_FLAG_2D + flag_def $0a, %11110000 ; EVENT_FLAG_2E + flag_def $0a, %00001000 ; EVENT_FLAG_2F + flag_def $0a, %00000100 ; EVENT_FLAG_30 + flag_def $0a, %00000011 ; EVENT_FLAG_31 + flag_def $0b, %10000000 ; EVENT_FLAG_32 + flag_def $0b, %01110000 ; EVENT_JOSHUA_STATE + flag_def $0b, %00001100 ; EVENT_FLAG_34 + flag_def $0b, %00000011 ; EVENT_FLAG_35 + flag_def $0c, %11100000 ; EVENT_FLAG_36 + flag_def $0c, %00011100 ; EVENT_FLAG_37 + flag_def $0c, %00000010 ; EVENT_FLAG_38 + flag_def $0c, %00000001 ; EVENT_FLAG_39 + flag_def $0d, %10000000 ; EVENT_FLAG_3A + flag_def $0d, %01000000 ; EVENT_FLAG_3B + flag_def $0d, %00100000 ; FLAG_BEAT_BRITTANY + flag_def $0d, %00010000 ; EVENT_FLAG_3D + flag_def $0d, %00001110 ; EVENT_FLAG_3E + flag_def $0e, %11100000 ; EVENT_FLAG_3F + flag_def $0e, %00011100 ; EVENT_FLAG_40 + flag_def $0f, %11100000 ; EVENT_FLAG_41 + flag_def $10, %10000000 ; EVENT_FLAG_42 + flag_def $10, %01000000 ; EVENT_FLAG_43 + flag_def $10, %00110000 ; EVENT_FLAG_44 + flag_def $10, %00001100 ; EVENT_FLAG_45 + flag_def $10, %00000010 ; EVENT_FLAG_46 + flag_def $10, %00000001 ; EVENT_FLAG_47 + flag_def $11, %11100000 ; EVENT_FLAG_48 + flag_def $11, %00011100 ; EVENT_FLAG_49 + flag_def $12, %11100000 ; EVENT_FLAG_4A + flag_def $13, %10000000 ; EVENT_FLAG_4B + flag_def $13, %01100000 ; EVENT_FLAG_4C + flag_def $13, %00011000 ; EVENT_FLAG_4D + flag_def $13, %00000100 ; EVENT_FLAG_4E + flag_def $13, %00000010 ; EVENT_FLAG_4F + flag_def $14, %10000000 ; EVENT_FLAG_50 + flag_def $14, %01000000 ; EVENT_FLAG_51 + flag_def $14, %00100000 ; EVENT_FLAG_52 + flag_def $14, %00010000 ; EVENT_FLAG_53 + flag_def $14, %00001000 ; EVENT_FLAG_54 + flag_def $14, %00000100 ; EVENT_FLAG_55 + flag_def $14, %00000010 ; EVENT_FLAG_56 + flag_def $14, %00000001 ; EVENT_FLAG_57 + flag_def $15, %11110000 ; EVENT_FLAG_58 + flag_def $15, %00001000 ; EVENT_FLAG_59 + flag_def $16, %10000000 ; EVENT_FLAG_5A + flag_def $16, %01000000 ; EVENT_FLAG_5B + flag_def $16, %00100000 ; EVENT_FLAG_5C + flag_def $16, %00010000 ; EVENT_FLAG_5D + flag_def $16, %00001000 ; EVENT_FLAG_5E + flag_def $16, %00000100 ; EVENT_FLAG_5F + flag_def $16, %00000010 ; EVENT_FLAG_60 + flag_def $16, %00000001 ; EVENT_FLAG_61 + flag_def $16, %11111111 ; EVENT_FLAG_62 + flag_def $17, %10000000 ; EVENT_FLAG_63 + flag_def $17, %01000000 ; EVENT_FLAG_64 + flag_def $17, %00110000 ; EVENT_FLAG_65 + flag_def $17, %00001000 ; EVENT_FLAG_66 + flag_def $17, %00000100 ; EVENT_FLAG_67 + flag_def $18, %11000000 ; EVENT_FLAG_68 + flag_def $18, %00110000 ; EVENT_FLAG_69 + flag_def $18, %00001100 ; EVENT_FLAG_6A + flag_def $18, %00000011 ; EVENT_FLAG_6B + flag_def $19, %11000000 ; EVENT_FLAG_6C + flag_def $19, %00100000 ; EVENT_FLAG_6D + flag_def $19, %00010000 ; EVENT_FLAG_6E + flag_def $19, %00001000 ; EVENT_FLAG_6F + flag_def $19, %00000100 ; EVENT_FLAG_70 + flag_def $19, %00111100 ; EVENT_FLAG_71 + flag_def $1a, %11111100 ; EVENT_FLAG_72 + flag_def $1a, %00000011 ; EVENT_FLAG_73 + flag_def $1b, %11111111 ; EVENT_FLAG_74 + flag_def $1c, %11110000 ; EVENT_FLAG_75 + flag_def $1c, %00001111 ; EVENT_FLAG_76 Func_cc25: ; cc25 (3:4c25) ld hl, wd0ca @@ -1877,8 +1871,8 @@ OWScript_AskQuestionJump: ; cce9 (3:4ce9) OWScript_StartBattle: ; cd01 (3:4d01) call Func_cd66 ld a, [wd3b6] - ld l, $0 - call Func_39ad + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ld a, [hl] farcall Func_118d3 ld a, [wcc19] @@ -1893,8 +1887,8 @@ OWScript_StartBattle: ; cd01 (3:4d01) ld [wcc19], a .asm_cd26 ld a, [wd3b6] - ld l, $0 - call Func_39ad + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ld a, [hl] asm_cd2f ld [wd0c4], a @@ -1952,8 +1946,7 @@ OWScript_PrintVariableText: ; cd83 (3:4d83) jp IncreaseOWScriptPointerBy5 Func_cd94: ; cd94 (3:4d94) - call Func_ca69 - db $44 + get_flag_value EVENT_FLAG_44 Unknown_cd98: dec a and $3 @@ -1989,28 +1982,28 @@ OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) Func_cdcb: ; cdcb (3:4dcb) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a Func_cdd1: ; cdd1 (3:4dd1) farcall Func_1c50a jp IncreaseOWScriptPointerBy1 Func_cdd8: ; cdd8 (3:4dd8) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af ld a, [wd696] ld [wTempNPC], a - call Func_39c3 + call FindLoadedNPC call Func_cdd1 pop af ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret Func_cdf5: ; cdf5 (3:4df5) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af @@ -2028,12 +2021,12 @@ Func_cdf5: ; cdf5 (3:4df5) pop af ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a jp IncreaseOWScriptPointerBy3 Func_ce26: ; ce26 (3:4e26) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a farcall Func_1c455 rlca add c @@ -2055,27 +2048,27 @@ Func_ce3a: ; ce3a (3:4e3a) Func_ce4a: ; ce4a (3:4e4a) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a jr Func_ce3a Func_ce52: ; ce52 (3:4e52) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af ld a, [wd696] asm_ce5d ld [wTempNPC], a - call Func_39c3 + call FindLoadedNPC call Func_ce3a pop af ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret Func_ce6f: ; ce6f (3:4e6f) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af @@ -2274,8 +2267,7 @@ Func_cf7b: ; cf7b (3:4f7b) Func_cf96: ; cf96 (3:4f96) ld c, $0 - call Func_ca69 - db $11 + get_flag_value EVENT_FLAG_11 or a jr z, Func_cfc0 cp a, $08 @@ -2283,15 +2275,13 @@ Func_cf96: ; cf96 (3:4f96) inc c .asm_cfa4 - call Func_ca69 - db $17 + get_flag_value EVENT_FLAG_17 cp $8 jr c, .asm_cfad inc c .asm_cfad - call Func_ca69 - db $20 + get_flag_value EVENT_FLAG_20 cp a, $08 jr c, .asm_cfb6 inc c @@ -2308,14 +2298,13 @@ Func_cfc0: ; cfc0 (3:4fc0) Func_cfc6: ; cfc6 (3:4fc6) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld a, c farcall Func_1c52e jp IncreaseOWScriptPointerBy2 Func_cfd4: ; cfd4 (3:4fd4) - call Func_ca69 - db $2d + get_flag_value EVENT_FLAG_2D ld b, a .asm_cfd9 ld a, $5 @@ -2339,15 +2328,13 @@ Func_cfd4: ; cfd4 (3:4fd4) or b push bc ld c, a - call Func_ca8f - dec l + set_flag_value EVENT_FLAG_2D pop bc ld b, $0 ld hl, Data_d006 add hl, bc ld c, [hl] - call Func_ca8f - dec hl + set_flag_value EVENT_FLAG_2B jp IncreaseOWScriptPointerBy1 Data_d006: ; d006 (3:5006) @@ -2359,8 +2346,7 @@ Func_d00b: ; d00b (3:500b) ld hl, wTxRam2 add hl, bc push hl - call Func_ca69 - db $2b + get_flag_value EVENT_FLAG_2B ld e, a ld d, $0 call GetCardName @@ -2371,22 +2357,19 @@ Func_d00b: ; d00b (3:500b) jp IncreaseOWScriptPointerBy2 Func_d025: ; d025 (3:5025) - call Func_ca69 - db $2b + get_flag_value EVENT_FLAG_2B call GetCardCountInCollectionAndDecks jp c, Func_cf67 jp Func_cf6d Func_d032: ; d032 (3:5032) - call Func_ca69 - db $2b + get_flag_value EVENT_FLAG_2B call GetCardCountInCollection jp c, Func_cf67 jp Func_cf6d Func_d03f: ; d03f (3:503f) - call Func_ca69 - db $2b + get_flag_value EVENT_FLAG_2B call RemoveCardFromCollection jp IncreaseOWScriptPointerBy1 @@ -2433,17 +2416,17 @@ Func_d088: ; d088 (3:5088) ld a, c ld [wTempNPC], a call GetOWSArgs2AfterPointer - call Func_c926 + call SetNextNPCAndOWSequence jp IncreaseOWScriptPointerBy4 Func_d095: ; d095 (3:5095) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a push bc call GetOWSArgs3AfterPointer ld a, [wd3b6] - ld l, $5 - call Func_39ad + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex res 4, [hl] ld a, [hl] or c @@ -2462,7 +2445,7 @@ Func_d095: ; d095 (3:5095) Func_d0be: ; d0be (3:50be) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld a, c ld c, b ld b, a @@ -2479,7 +2462,7 @@ OWScript_DoFrames: ; d0ce (3:50ce) Func_d0d9: ; d0d9 (3:50d9) ld a, [wd3b6] - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld d, c ld e, b farcall Func_1c477 @@ -2501,13 +2484,13 @@ Func_d0f2: ; d0f2 (3:50f2) jp ScriptEventPassedTryJump Func_d103: ; d103 (3:5103) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af ld a, c ld [wTempNPC], a - call Func_39c3 + call FindLoadedNPC jr c, .asm_d119 call $54d1 jr .asm_d11c @@ -2519,7 +2502,7 @@ Func_d103: ; d103 (3:5103) pop af ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret Func_d125: ; d125 (3:5125) @@ -2582,12 +2565,10 @@ Func_d16b: ; d16b (3:516b) Func_d195: ; d195 (3:5195) ld a, [wTempNPC] push af - call Func_ca69 - db $45 + get_flag_value EVENT_FLAG_45 inc a ld c, a - call Func_ca8f - ld b, l + set_flag_value EVENT_FLAG_45 call Func_f580 pop af ld [wTempNPC], a @@ -2598,8 +2579,7 @@ Func_d1ad: ; d1ad (3:51ad) jp IncreaseOWScriptPointerBy1 Func_d1b3: ; d1b3 (3:51b3) - call Func_ca69 - db $44 + get_flag_value EVENT_FLAG_44 dec a cp $2 jr c, .asm_d1c3 @@ -2627,8 +2607,7 @@ asm_d1c6 INCROM $d1dc, $d209 Func_d209: ; d209 (3:5209) - call Func_ca69 - db $71 + get_flag_value EVENT_FLAG_71 ld e, a .asm_d20e call UpdateRNGSources @@ -2670,8 +2649,7 @@ Func_d24c: ; d24c (3:524c) call Func_d28c ld a, [wd695] ld c, a - call Func_ca8f - halt + set_flag_value EVENT_FLAG_76 jp IncreaseOWScriptPointerBy1 INCROM $d25e, $d271 @@ -2767,8 +2745,7 @@ Func_d2f6: ; d2f6 (3:52f6) call Func_d28c ld a, [wd694] ld c, a - call Func_ca8f - ld [hl], l + set_flag_value EVENT_FLAG_75 xor a ld [wd694], a jp IncreaseOWScriptPointerBy1 @@ -2782,8 +2759,7 @@ Func_d317: ; d317 (3:5317) call Func_d28c ld a, [wd694] ld c, a - call Func_ca8f - ld [hl], l + set_flag_value EVENT_FLAG_75 jp IncreaseOWScriptPointerBy1 @@ -2849,8 +2825,7 @@ Func_d39d: ; d39d (3:539d) jr nz, .asm_d3ac farcall Func_10dba ld c, a - call Func_ca8f - ld [hl], d + set_flag_value EVENT_FLAG_72 jr .asm_d3b6 .asm_d3ac @@ -3072,41 +3047,34 @@ OWScript_JumpIfFlagZero2: LoadOverworld: ; d4ec (3:54ec) call Func_d4fb - call Func_ca69 - ld a, $b7 + get_flag_value EVENT_FLAG_3E + or a ret nz ld bc, OWSequence_d52e - jp Func_c935 + jp SetNextOWSequence Func_d4fb: ; d4fb (3:54fb) - call Func_cacd - ld e, c + zero_out_flag EVENT_FLAG_59 call Func_f602 - call Func_ca69 - db $3f + get_flag_value EVENT_FLAG_3F cp $02 jr z, .asm_d527 - call Func_ca69 - db $40 + get_flag_value EVENT_FLAG_40 cp $02 jr z, .asm_d521 - call Func_ca69 - db $41 + get_flag_value EVENT_FLAG_41 cp $02 jr z, .asm_d51b ret .asm_d51b ld c, $07 - call Func_ca8f - ld b, c + set_flag_value EVENT_FLAG_41 .asm_d521 ld c, $07 - call Func_ca8f - ld b, b + set_flag_value EVENT_FLAG_40 .asm_d527 ld c, $07 - call Func_ca8f - ccf + set_flag_value EVENT_FLAG_3F ret OWSequence_d52e: ; d52e (3:552e) @@ -3196,14 +3164,13 @@ WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] cp $8 ret nz - call Func_ca69 - db $33 + get_flag_value EVENT_JOSHUA_STATE cp $2 ret nc ld a, $21 ld [wTempNPC], a ld bc, OWSequence_NotReadyToSeeAmy - jp Func_c926 + jp SetNextNPCAndOWSequence WaterClubAfterDuel: ;e157 (3:6157) ld hl, .after_duel_table @@ -3669,7 +3636,7 @@ FindEndOfBattleScript: ; e52c (3:652c) ld c, [hl] inc hl ld b, [hl] - jp Func_c926 + jp SetNextNPCAndOWSequence ; 0xe553 GrassClubEntranceAfterDuelTable: ; e553 (3:6553) @@ -3800,34 +3767,32 @@ LoadClubEntrance: ; e809 (3:6809) TryFirstRonaldEncounter: ; e813 (3:6813) ld a, RONALD1 ld [wTempNPC], a - call Func_39c3 + call FindLoadedNPC ret c ld bc, OWSequence_FirstRonaldEncounter - jp Func_c926 + jp SetNextNPCAndOWSequence TryFirstRonaldFight: ; e822 (3:6822) ld a, RONALD2 ld [$d3ab], a - call Func_39c3 + call FindLoadedNPC ret c - call Func_ca69 - db $4c + get_flag_value EVENT_FLAG_4C or a ret nz ld bc, OWSequence_FirstRonaldFight - jp Func_c926 + jp SetNextNPCAndOWSequence TrySecondRonaldFight: ; e837 (3:6837) ld a, RONALD3 ld [$d3ab], a - call Func_39c3 + call FindLoadedNPC ret c - call Func_ca69 - db $4d + get_flag_value EVENT_FLAG_4D or a ret nz ld bc, OWSequenceSecondRonaldFight - jp Func_c926 + jp SetNextNPCAndOWSequence ; 0xe84c INCROM $e84c, $e862 @@ -4029,12 +3994,10 @@ OWJump_FinishedSecondRonaldFight ; e959 (3:6959) INCROM $e963, $f580 Func_f580: ; f580 (3:7580) - call Func_ca69 - db $44 + get_flag_value EVENT_FLAG_44 cp $3 jr z, .asm_f596 - call Func_ca69 - db $45 + get_flag_value EVENT_FLAG_45 cp $3 ld d, $18 jr nz, .asm_f598 @@ -4085,7 +4048,7 @@ Func_fc2b: ; fc2b (3:7c2b) ld [wCurrentNPCNameTx], a ld a, $3 ld [wCurrentNPCNameTx+1], a - jp Func_c935 + jp SetNextOWSequence PointerTable_fc4c: ; fc4c (3:7c4c) dw Unknown_fc64 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 4cba1d9..c81db5c 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -366,7 +366,7 @@ Func_10e71: ; 10e71 (4:4e71) and D_PAD jr z, .asm_10e83 farcall Func_c5d5 - ld [wd334], a + ld [wPlayerDirection], a call Func_10e97 jr .asm_10e96 .asm_10e83 @@ -388,7 +388,7 @@ Func_10e97: ; 10e97 (4:4e97) rlca rlca ld c, a - ld a, [wd334] + ld a, [wPlayerDirection] add c ld c, a ld b, $0 @@ -711,7 +711,7 @@ Func_11102: ; 11102 (4:5102) jr z, .asm_1113a ld a, $3 .asm_1113a - ld [wd334], a + ld [wPlayerDirection], a ret Func_1113e: ; 1113e (4:513e) @@ -747,7 +747,7 @@ Func_1113e: ; 1113e (4:513e) jr z, .asm_11175 ld a, $0 .asm_11175 - ld [wd334], a + ld [wPlayerDirection], a ret Func_11179: ; 11179 (4:5179) @@ -878,8 +878,8 @@ LoadNPCSpriteData: ; 11857 (4:5857) pop hl ret -; this appears to find data about the NPC we're talking to -Func_1187d: ; 1187d (4:587d) +; Loads Name into wCurrentNPCNameTx and gets OWSequence ptr into bc +GetNPCNameAndOWSequence: ; 1187d (4:587d) push hl call GetNPCDataPointer ld bc, NPC_DATA_OWSEQUENCE_PTR diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 0b2ec00..4455d3f 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -40,7 +40,7 @@ Func_1c056: ; 1c056 (7:4056) ld [wd0bc], a ld a, [hli] ld [wd0bd], a - ld a, [wd334] + ld a, [wPlayerDirection] ld [wd0be], a .asm_1c095 pop de @@ -95,9 +95,9 @@ Func_1c440: ; 1c440 (7:4440) Func_1c455: ; 1c455 (7:4455) push hl - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [hl] pop hl ret @@ -106,9 +106,9 @@ Func_1c461: ; 1c461 (7:4461) push hl push bc call Func_1c719 - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, b ld [hli], a ld [hl], c @@ -119,9 +119,9 @@ Func_1c461: ; 1c461 (7:4461) Func_1c477: ; 1c477 (7:4477) push hl - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, [hli] ld b, a ld c, [hl] @@ -134,11 +134,11 @@ Func_1c485: ; 1c485 (7:4485) push bc push de xor a - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld b, a - ld c, $08 - ld hl, wd34a - ld de, $c + ld c, LOADED_NPC_MAX + ld hl, wLoadedNPCs + ld de, LOADED_NPC_LENGTH .findEmptyIndexLoop ld a, [hl] or a @@ -147,17 +147,17 @@ Func_1c485: ; 1c485 (7:4485) inc b dec c jr nz, .findEmptyIndexLoop - ld hl, wd34a + ld hl, wLoadedNPCs debug_ret jr .exit .foundEmptyIndex ld a, b - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld a, [wd3b3] farcall CreateSpriteAndAnimBufferEntry jr c, .exit - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID push hl ld a, [wTempNPC] ld [hli], a @@ -209,8 +209,8 @@ Func_1c4fa: ; 1c4fa (7:44fa) Func_1c50a: ; 1c50a (7:450a) push hl call Func_1c719 - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID ld a, [hl] or a jr z, .asm_1c52c @@ -234,9 +234,9 @@ Func_1c50a: ; 1c50a (7:450a) Func_1c52e: ; 1c52e (7:452e) push hl push af - ld a, [wd3aa] - ld l, $7 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_07 + call GetItemInLoadedNPCIndex pop af ld [hl], a call Func_1c5e9 @@ -246,9 +246,9 @@ Func_1c52e: ; 1c52e (7:452e) Func_1c53f: ; 1c53f (7:453f) push hl push bc - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [hl] ld bc, $0003 add hl, bc @@ -263,14 +263,14 @@ Func_1c53f: ; 1c53f (7:453f) Func_1c557: ; 1c557 (7:4557) push bc ld c, a - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af ld a, c ld [wTempNPC], a ld c, $0 - call Func_39c3 + call FindLoadedNPC jr c, .asm_1c570 call Func_1c53f ld c, a @@ -279,7 +279,7 @@ Func_1c557: ; 1c557 (7:4557) pop af ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld a, c pop bc ret @@ -288,9 +288,9 @@ Func_1c57b: ; 1c57b (7:457b) push hl push bc push af - ld a, [wd3aa] - ld l, $6 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_06 + call GetItemInLoadedNPCIndex pop af ld [hl], a call Func_1c58e @@ -303,14 +303,14 @@ Func_1c58e: ; 1c58e (7:458e) push bc ld a, [wWhichSprite] push af - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID ld a, [hli] or a - jr z, .asm_1c5b2 + jr z, .quit ld a, [hl] ld [wWhichSprite], a - ld bc, $5 + ld bc, LOADED_NPC_FIELD_06 - LOADED_NPC_SPRITE add hl, bc ld a, [hld] bit 4, [hl] @@ -320,7 +320,7 @@ Func_1c58e: ; 1c58e (7:458e) inc hl .asm_1c5ae farcall Func_12ab5 -.asm_1c5b2 +.quit pop af ld [wWhichSprite], a pop bc @@ -334,9 +334,9 @@ Func_1c5b9: ; 1c5b9 (7:45b9) Func_1c5e9: ; 1c5e9 (7:45e9) push hl push bc - ld a, [wd3aa] - ld l, $07 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_07 + call GetItemInLoadedNPCIndex ld a, [hl] ld bc, $fffd add hl, bc @@ -358,9 +358,9 @@ Func_1c665: ; 1c665 (7:4665) Func_1c6e3: ; 1c6e3 (7:46e3) push hl push bc - ld a, [$d3aa] - ld l, $02 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, [hli] ld b, a ld c, [hl] @@ -376,9 +376,9 @@ Func_1c6f8: ; 1c6f8 (7:46f8) Func_1c719: ; 1c719 (7:4719) push hl push bc - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, [hli] ld b, a ld c, [hl] @@ -391,33 +391,35 @@ Func_1c719: ; 1c719 (7:4719) Func_1c72e: ; 1c72e (7:472e) INCROM $1c72e, $1c768 -Func_1c768: ; 1c768 (7:4768) +; Probably needs a new name. Loads data for NPC that the next OWSequence is for +; Sets direction, Loads Image data for it, loads name, and more +SetNewOWSequenceNPC: ; 1c768 (7:4768) push hl - ld a, [wd3aa] - ld l, $04 - call Func_39ad - ld a, [wd334] + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex + ld a, [wPlayerDirection] xor $02 ld [hl], a call Func_1c58e ld a, $02 farcall Func_c29b - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID ld a, [hl] - farcall Func_1187d + farcall GetNPCNameAndOWSequence pop hl ret Func_1c78d: ; 1c78d (7:478d) push hl - ld a, [wd3aa] - ld l, $5 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex set 5, [hl] - ld a, [wd3aa] - ld l, $8 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_08 + call GetItemInLoadedNPCIndex xor a ld [hli], a .asm_1c7a2 @@ -457,9 +459,9 @@ Func_1c78d: ; 1c78d (7:478d) jr .asm_1c7a2 .asm_1c7d2 - ld a, [wd3aa] - ld l, $5 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex res 5, [hl] .asm_1c7dc diff --git a/src/engine/home.asm b/src/engine/home.asm index adcbabd..4135afa 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -10908,15 +10908,16 @@ Func_3997: ; 3997 (0:3997) call BankswitchROM ret -Func_39a7: ; 39a7 (0:39a7) - ld l, $0 - call Func_39ad +; returns in hl a pointer to the first element for the a'th NPC +GetLoadedNPCID: ; 39a7 (0:39a7) + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ret -; return hl = wd34a + a * $c + l, with a < $8 -Func_39ad: ; 39ad (0:39ad) +; return in hl a pointer to the a'th items element l +GetItemInLoadedNPCIndex: ; 39ad (0:39ad) push bc - cp $8 + cp LOADED_NPC_MAX jr c, .asm_39b4 debug_ret xor a @@ -10929,24 +10930,24 @@ Func_39ad: ; 39ad (0:39ad) add l ld l, a ld h, $0 - ld bc, wd34a + ld bc, wLoadedNPCs add hl, bc pop bc ret -; Finds the index on wd34a table of the npc in wTempNPC -; returns it in a and puts it into wd3aa +; Finds the index on wLoadedNPCs table of the npc in wTempNPC +; returns it in a and puts it into wLoadedNPCTempIndex ; c flag set if no npc found -Func_39c3: ; 39c3 (0:39c3) +FindLoadedNPC: ; 39c3 (0:39c3) push hl push bc push de xor a - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld b, a - ld c, $8 - ld de, $000c - ld hl, wd34a + ld c, LOADED_NPC_MAX + ld de, LOADED_NPC_LENGTH + ld hl, wLoadedNPCs ld a, [wTempNPC] .findNPCLoop cp [hl] @@ -10959,7 +10960,7 @@ Func_39c3: ; 39c3 (0:39c3) jr z, .exit .foundNPCMatch ld a, b - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a or a .exit pop de @@ -11069,7 +11070,7 @@ Func_3a5e: ; 3a5e (0:3a5e) call Func_c653 ld a, $4 call BankswitchROM - ld a, [wd334] + ld a, [wPlayerDirection] ld d, a .asm_3a79 ld a, [hli] @@ -11086,9 +11087,9 @@ Func_3a5e: ; 3a5e (0:3a5e) cp c jr nz, .asm_3aab ld a, [hli] - ld [wd0c6], a + ld [wNextOWSequence], a ld a, [hli] - ld [wd0c7], a + ld [wNextOWSequence+1], a ld a, [hli] ld [wd0ca], a ld a, [hli] diff --git a/src/macros/code.asm b/src/macros/code.asm index 55f4b63..8f2bd0d 100644 --- a/src/macros/code.asm +++ b/src/macros/code.asm @@ -26,6 +26,24 @@ else endc ENDM +; runs SetEventFlagValue with the next value as the flag, c as the new value +set_flag_value: MACRO + call SetStackFlagValue + db \1 +ENDM + +; runs ZeroOutEventFlag with the next value as the flag +zero_out_flag: MACRO + call ZeroStackFlagValue + db \1 +ENDM + +; runs GetEventFlagValue with the next value as the flag. returns value in a +get_flag_value: MACRO + call GetStackFlagValue + db \1 +ENDM + ; the rst $38 handler is a single ret instruction ; probably used for testing purposes during development debug_ret EQUS "rst $38" diff --git a/src/macros/constants.asm b/src/macros/constants.asm index c841972..264e3ed 100644 --- a/src/macros/constants.asm +++ b/src/macros/constants.asm @@ -12,8 +12,6 @@ const_value = const_value + 1 ENDM flag_def: MACRO -\1 EQU const_value -const_value = const_value + 1 -db \2 -db \3 + db \1 + db \2 ENDM diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 1f36cba..7f2bbb5 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -81,7 +81,7 @@ ENDM const Func_d39d_index ; $40 const Func_d3b9_index ; $41 const OWScript_GivePCPack_index ; $42 - const Func_d3d1_index ; $43 + const OWScript_nop_index ; $43 const Func_d3d4_index ; $44 const Func_d3e0_index ; $45 const Func_d3fe_index ; $46 diff --git a/src/macros/wram.asm b/src/macros/wram.asm index ca8a9d0..415d19a 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -65,3 +65,18 @@ sprite_anim_struct: MACRO \1MovementCounter:: ds 1 \1Field0x0f:: ds 1 ENDM + +loaded_npc_struct: MACRO +\1ID:: ds 1 +\1Sprite:: ds 1 +\1CoordX:: ds 1 +\1CoordY:: ds 1 +\1Direction:: ds 1 +\1Field0x05:: ds 1 +\1Field0x06:: ds 1 +\1Field0x07:: ds 1 +\1Field0x08:: ds 1 +\1Field0x09:: ds 1 +\1Field0x0a:: ds 1 +\1Field0x0b:: ds 1 +ENDM diff --git a/src/wram.asm b/src/wram.asm index 0259c7a..fd24dbd 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1819,11 +1819,9 @@ wd0c4:: ; d0c4 wd0c5:: ; d0c5 ds $1 -wd0c6:: ; d0c6 - ds $1 - -wd0c7:: ; d0c7 - ds $1 +; used to store the location of an overworld sequence, which is jumped to later +wNextOWSequence:: ; d0c6 + ds $2 wCurrentNPCNameTx:: ; d0c8 ds $2 @@ -1998,7 +1996,7 @@ wd332:: ; d332 wd333:: ; d333 ds $1 -wd334:: ; d334 +wPlayerDirection:: ; d334 ds $1 wd335:: ; d335 @@ -2063,11 +2061,17 @@ wd348:: ; d348 wd349:: ; d349 ds $1 -; some kind of array with 8 sets of c data -wd34a:: ; d34a - ds $60 +wLoadedNPCs:: ; d34a + loaded_npc_struct wLoadedNPC1 + loaded_npc_struct wLoadedNPC2 + loaded_npc_struct wLoadedNPC3 + loaded_npc_struct wLoadedNPC4 + loaded_npc_struct wLoadedNPC5 + loaded_npc_struct wLoadedNPC6 + loaded_npc_struct wLoadedNPC7 + loaded_npc_struct wLoadedNPC8 -wd3aa:: ; d3aa +wLoadedNPCTempIndex:: ; d3aa ds $1 wTempNPC:: ; d3ab -- cgit v1.2.3 From cb88ee5a13498f060da1be80eb0cc0fcd1357a05 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Tue, 8 Oct 2019 00:20:52 -0400 Subject: Created python script to calculate progress and documented some scripts --- src/data/map_scripts.asm | 70 +++---- src/data/npc_map_data.asm | 66 +++--- src/data/npcs.asm | 2 +- src/engine/bank03.asm | 511 ++++++++++++++++++++++++++++++++++++---------- src/engine/bank04.asm | 32 +-- src/engine/bank07.asm | 8 +- src/macros/scripts.asm | 16 +- src/wram.asm | 8 +- 8 files changed, 501 insertions(+), 212 deletions(-) (limited to 'src') diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index e156a1c..bd0229d 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -23,17 +23,17 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; MASON_LABORATORY - dw NPCData_772f + dw MasonLabNPCS dw $0000 dw $7b04 dw $5565 dw $5549 - dw $553b + dw MasonLaboratoryAfterDuel dw $0000 dw $555e ; DECK_MACHINE_ROOM - dw NPCData_775a + dw DeckMachineRoomNPCS dw $0000 dw $7b4d dw $0000 @@ -43,7 +43,7 @@ MapScripts: ; 1162a (4:562a) dw $58ad ; ISHIHARAS_HOUSE - dw NPCData_7773 + dw IshiharasHouseNPCS dw $0000 dw $7c02 dw $0000 @@ -53,7 +53,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB_ENTRANCE - dw NPCData_7786 + dw FightingClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -63,17 +63,17 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB_LOBBY - dw NPCData_779f + dw FightingClubLobbyNPCS dw $0000 dw $7c6f dw $0000 dw $0000 - dw $5c68 + dw FightingClubLobbyAfterDuel dw $0000 dw $0000 ; FIGHTING_CLUB - dw NPCData_77ca + dw FightingClubNPCS dw $0000 dw $0000 dw $0000 @@ -83,7 +83,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB_ENTRANCE - dw NPCData_77e3 + dw RockClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -93,7 +93,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB_LOBBY - dw NPCData_77fc + dw RockClubLobbyNPCS dw $0000 dw $7ca6 dw $0000 @@ -103,7 +103,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB - dw NPCData_7827 + dw RockClubNPCS dw $0000 dw $0000 dw $0000 @@ -113,7 +113,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB_ENTRANCE - dw NPCData_783a + dw WaterClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -123,7 +123,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB_LOBBY - dw NPCData_7853 + dw WaterClubLobbyNPCS dw $0000 dw $7cdd dw $0000 @@ -133,7 +133,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB - dw NPCData_787e + dw WaterClubNPCS dw $0000 dw $0000 dw $0000 @@ -143,7 +143,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB_ENTRANCE - dw NPCData_7897 + dw LightningClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -153,7 +153,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB_LOBBY - dw NPCData_78b0 + dw LightningClubLobbyNPCS dw $0000 dw $7d14 dw $0000 @@ -163,7 +163,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB - dw NPCData_78d5 + dw LightningClubNPCS dw $0000 dw $0000 dw $0000 @@ -173,7 +173,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB_ENTRANCE - dw NPCData_78ee + dw GrassClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -183,7 +183,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB_LOBBY - dw NPCData_790d + dw GrassClubLobbyNPCS dw $0000 dw $7d4b dw $0000 @@ -193,7 +193,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB - dw NPCData_7932 + dw GrassClubNPCS dw $0000 dw $0000 dw $0000 @@ -203,7 +203,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB_ENTRANCE - dw NPCData_7945 + dw PsychicClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -213,7 +213,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB_LOBBY - dw NPCData_7964 + dw PsychicClubLobbyNPCS dw $0000 dw $7d82 dw $0000 @@ -223,7 +223,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB - dw NPCData_798f + dw PsychicClubNPCS dw $0000 dw $0000 dw $0000 @@ -233,7 +233,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB_ENTRANCE - dw NPCData_79a8 + dw ScienceClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -243,7 +243,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB_LOBBY - dw NPCData_79c1 + dw ScienceClubLobbyNPCS dw $0000 dw $7db9 dw $0000 @@ -253,7 +253,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB - dw NPCData_79ec + dw ScienceClubNPCS dw $0000 dw $0000 dw $0000 @@ -263,7 +263,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB_ENTRANCE - dw NPCData_7a05 + dw FireClubEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -273,7 +273,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB_LOBBY - dw NPCData_7a1e + dw FireClubLobbyNPCS dw $0000 dw $7df0 dw $6d57 @@ -283,7 +283,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB - dw NPCData_7a43 + dw FireClubNPCS dw $0000 dw $0000 dw $0000 @@ -293,7 +293,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_ENTRANCE - dw NPCData_7a5c + dw ChallengeHallEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -303,7 +303,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_LOBBY - dw NPCData_7a63 + dw ChallengeHallLobbyNPCS dw $0000 dw $7e27 dw $0000 @@ -313,7 +313,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL - dw NPCData_7a9a + dw ChallengeHallNPCS dw $0000 dw $0000 dw $0000 @@ -323,7 +323,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; POKEMON_DOME_ENTRANCE - dw NPCData_7ab9 + dw PokemonDomeEntranceNPCS dw $0000 dw $7e5e dw $0000 @@ -333,7 +333,7 @@ MapScripts: ; 1162a (4:562a) dw $762a ; POKEMON_DOME - dw NPCData_7ac0 + dw PokemonDomeNPCS dw $0000 dw $0000 dw $0000 @@ -343,7 +343,7 @@ MapScripts: ; 1162a (4:562a) dw $7718 ; HALL_OF_HONOR - dw NPCData_7adf + dw HallOfHonorNPCS dw $0000 dw $7ec2 dw $0000 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index 7bc69cb..bae46d1 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -1,7 +1,7 @@ ; NPC Map data. Format: ; NPC, X position, Y Position, Direction, ; pre-load function. (Resets c flag if NPC should not be loaded) -NPCData_772f: ; 772f (4:1372f) +MasonLabNPCS: ; 772f (4:1372f) db DRMASON, $0e, $06, SOUTH dw $5710 db SAM, $04, $0e, EAST @@ -18,7 +18,7 @@ NPCData_772f: ; 772f (4:1372f) dw $55eb db $00 -NPCData_775a: ; 775a (4:1375a) +DeckMachineRoomNPCS: ; 775a (4:1375a) db TECH6, $06, $08, SOUTH dw $0000 db TECH7, $06, $16, WEST @@ -29,7 +29,7 @@ NPCData_775a: ; 775a (4:1375a) dw $0000 db $00 -NPCData_7773: ; 7773 (4:13773) +IshiharasHouseNPCS: ; 7773 (4:13773) db NIKKI, $04, $04, NORTH dw $5add db ISHIHARA, $08, $08, SOUTH @@ -38,7 +38,7 @@ NPCData_7773: ; 7773 (4:13773) dw $5c43 db $00 -NPCData_7786: ; 7786 (4:13786) +FightingClubEntranceNPCS: ; 7786 (4:13786) db CLERK1, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -49,7 +49,7 @@ NPCData_7786: ; 7786 (4:13786) dw $6915 db $00 -NPCData_779f: ; 779f (4:1379f) +FightingClubLobbyNPCS: ; 779f (4:1379f) db MAN1, $0c, $0e, WEST dw $0000 db IMAKUNI, $12, $02, NORTH @@ -66,7 +66,7 @@ NPCData_779f: ; 779f (4:1379f) dw $7c6c db $00 -NPCData_77ca: ; 77ca (4:137ca) +FightingClubNPCS: ; 77ca (4:137ca) db CHRIS, $04, $08, SOUTH dw $5e43 db MICHAEL, $0e, $0a, SOUTH @@ -77,7 +77,7 @@ NPCData_77ca: ; 77ca (4:137ca) dw $0000 db $00 -NPCData_77e3: ; 77e3 (4:137e3) +RockClubEntranceNPCS: ; 77e3 (4:137e3) db CLERK2, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -88,7 +88,7 @@ NPCData_77e3: ; 77e3 (4:137e3) dw $6915 db $00 -NPCData_77fc: ; 77fc (4:137fc) +RockClubLobbyNPCS: ; 77fc (4:137fc) db CHRIS, $12, $08, WEST dw $5ee9 db MATTHEW, $06, $0e, EAST @@ -105,7 +105,7 @@ NPCData_77fc: ; 77fc (4:137fc) dw $7c6c db $00 -NPCData_7827: ; 7827 (4:13827) +RockClubNPCS: ; 7827 (4:13827) db RYAN, $14, $0e, EAST dw $0000 db ANDREW, $06, $14, NORTH @@ -114,7 +114,7 @@ NPCData_7827: ; 7827 (4:13827) dw $0000 db $00 -NPCData_783a: ; 783a (4:1383a) +WaterClubEntranceNPCS: ; 783a (4:1383a) db CLERK3, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -125,7 +125,7 @@ NPCData_783a: ; 783a (4:1383a) dw $6915 db $00 -NPCData_7853: ; 7853 (4:13853) +WaterClubLobbyNPCS: ; 7853 (4:13853) db GAL1, $06, $0e, SOUTH dw $0000 db LASS1, $10, $0a, SOUTH @@ -142,7 +142,7 @@ NPCData_7853: ; 7853 (4:13853) dw $7c6c db $00 -NPCData_787e: ; 787e (4:1387e) +WaterClubNPCS: ; 787e (4:1387e) db SARA, $06, $12, EAST dw $0000 db AMANDA, $16, $14, WEST @@ -153,7 +153,7 @@ NPCData_787e: ; 787e (4:1387e) dw $62ad db $00 -NPCData_7897: ; 7897 (4:13897) +LightningClubEntranceNPCS: ; 7897 (4:13897) db CLERK4, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -164,7 +164,7 @@ NPCData_7897: ; 7897 (4:13897) dw $6915 db $00 -NPCData_78b0: ; 78b0 (4:138b0) +LightningClubLobbyNPCS: ; 78b0 (4:138b0) db CHAP2, $12, $10, WEST dw $0000 db IMAKUNI, $12, $02, NORTH @@ -179,7 +179,7 @@ NPCData_78b0: ; 78b0 (4:138b0) dw $7c6c db $00 -NPCData_78d5: ; 78d5 (4:138d5) +LightningClubNPCS: ; 78d5 (4:138d5) db JENNIFER, $0e, $12, SOUTH dw $0000 db NICHOLAS, $06, $0a, SOUTH @@ -190,7 +190,7 @@ NPCData_78d5: ; 78d5 (4:138d5) dw $6494 db $00 -NPCData_78ee: ; 78ee (4:138ee) +GrassClubEntranceNPCS: ; 78ee (4:138ee) db CLERK5, $06, $02, SOUTH dw $0000 db MICHAEL, $0e, $08, SOUTH @@ -203,7 +203,7 @@ NPCData_78ee: ; 78ee (4:138ee) dw $6915 db $00 -NPCData_790d: ; 790d (4:1390d) +GrassClubLobbyNPCS: ; 790d (4:1390d) db BRITTANY, $0c, $0e, WEST dw $0000 db LASS2, $12, $08, SOUTH @@ -218,7 +218,7 @@ NPCData_790d: ; 790d (4:1390d) dw $7c6c db $00 -NPCData_7932: ; 7932 (4:13932) +GrassClubNPCS: ; 7932 (4:13932) db KRISTIN, $04, $0a, EAST dw $0000 db HEATHER, $0e, $10, SOUTH @@ -227,7 +227,7 @@ NPCData_7932: ; 7932 (4:13932) dw $6796 db $00 -NPCData_7945: ; 7945 (4:13945) +PsychicClubEntranceNPCS: ; 7945 (4:13945) db CLERK6, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -240,7 +240,7 @@ NPCData_7945: ; 7945 (4:13945) dw $0000 db $00 -NPCData_7964: ; 7964 (4:13964) +PsychicClubLobbyNPCS: ; 7964 (4:13964) db ROBERT, $14, $08, NORTH dw $0000 db PAPPY1, $04, $10, EAST @@ -257,7 +257,7 @@ NPCData_7964: ; 7964 (4:13964) dw $7c6c db $00 -NPCData_798f: ; 798f (4:1398f) +PsychicClubNPCS: ; 798f (4:1398f) db DANIEL, $08, $08, NORTH dw $0000 db STEPHANIE, $16, $0c, EAST @@ -268,7 +268,7 @@ NPCData_798f: ; 798f (4:1398f) dw $6ada db $00 -NPCData_79a8: ; 79a8 (4:139a8) +ScienceClubEntranceNPCS: ; 79a8 (4:139a8) db CLERK7, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -279,7 +279,7 @@ NPCData_79a8: ; 79a8 (4:139a8) dw $6915 db $00 -NPCData_79c1: ; 79c1 (4:139c1) +ScienceClubLobbyNPCS: ; 79c1 (4:139c1) db LAD1, $12, $12, NORTH dw $0000 db IMAKUNI, $12, $02, NORTH @@ -296,7 +296,7 @@ NPCData_79c1: ; 79c1 (4:139c1) dw $7c6c db $00 -NPCData_79ec: ; 79ec (4:139ec) +ScienceClubNPCS: ; 79ec (4:139ec) db JOSEPH, $08, $0a, SOUTH dw $6cc4 db DAVID, $14, $04, NORTH @@ -307,7 +307,7 @@ NPCData_79ec: ; 79ec (4:139ec) dw $0000 db $00 -NPCData_7a05: ; 7a05 (4:13a05) +FireClubEntranceNPCS: ; 7a05 (4:13a05) db CLERK8, $06, $02, SOUTH dw $0000 db RONALD1, $08, $fe, SOUTH @@ -318,7 +318,7 @@ NPCData_7a05: ; 7a05 (4:13a05) dw $6915 db $00 -NPCData_7a1e: ; 7a1e (4:13a1e) +FireClubLobbyNPCS: ; 7a1e (4:13a1e) db JESSICA, $0c, $0e, WEST dw $6d8d db LAD2, $12, $06, EAST @@ -333,7 +333,7 @@ NPCData_7a1e: ; 7a1e (4:13a1e) dw $7c6c db $00 -NPCData_7a43: ; 7a43 (4:13a43) +FireClubNPCS: ; 7a43 (4:13a43) db JOHN, $0c, $12, SOUTH dw $0000 db ADAM, $08, $0e, SOUTH @@ -344,12 +344,12 @@ NPCData_7a43: ; 7a43 (4:13a43) dw $0000 db $00 -NPCData_7a5c: ; 7a5c (4:13a5c) +ChallengeHallEntranceNPCS: ; 7a5c (4:13a5c) db CLERK9, $06, $02, SOUTH dw $6f96 db $00 -NPCData_7a63: ; 7a63 (4:13a63) +ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) db PAPPY3, $06, $0e, EAST dw $707a db CHAMP, $10, $12, WEST @@ -370,7 +370,7 @@ NPCData_7a63: ; 7a63 (4:13a63) dw $7c6c db $00 -NPCData_7a9a: ; 7a9a (4:13a9a) +ChallengeHallNPCS: ; 7a9a (4:13a9a) db CLERK12, $0a, $12, SOUTH dw $707a db CLERK13, $14, $12, SOUTH @@ -383,12 +383,12 @@ NPCData_7a9a: ; 7a9a (4:13a9a) dw $7559 db $00 -NPCData_7ab9: ; 7ab9 (4:13ab9) +PokemonDomeEntranceNPCS: ; 7ab9 (4:13ab9) db RONALD1, $0e, $12, SOUTH dw $0000 db $00 -NPCData_7ac0: ; 7ac0 (4:13ac0) +PokemonDomeNPCS: ; 7ac0 (4:13ac0) db COURTNEY, $12, $02, SOUTH dw $774b db STEVE, $16, $02, SOUTH @@ -401,7 +401,7 @@ NPCData_7ac0: ; 7ac0 (4:13ac0) dw $77d6 db $00 -NPCData_7adf: ; 7adf (4:13adf) +HallOfHonorNPCS: ; 7adf (4:13adf) db _11F1F, $0a, $08, SOUTH dw $0000 db _11F26, $0c, $08, SOUTH diff --git a/src/data/npcs.asm b/src/data/npcs.asm index bda574f..4ff42c8 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -183,7 +183,7 @@ ImakuniData: db $00 db $0e db $00 - dw $5d0d ; Pointer to OWScript + dw OWSequence_Imakuni ; Pointer to OWScript tx Text03af db IMAKUNI_PIC db $34 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index c75c009..02ddc67 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -29,11 +29,11 @@ LoadMap: ; c000 (3:4000) ld a, PLAYER_TURN ldh [hWhoseTurn], a farcall Func_1c440 - ld a, [wd0bb] + ld a, [wTempMap] ld [wCurMap], a - ld a, [wd0bc] + ld a, [wTempPlayerXCoord] ld [wPlayerXCoord], a - ld a, [wd0bd] + ld a, [wTempPlayerYCoord] ld [wPlayerYCoord], a call Func_c36a call Func_c184 @@ -231,13 +231,13 @@ Func_c1b1: ; c1b1 (3:41b1) ld a, $c ld [wd32e], a ld a, $0 - ld [wd0bb], a + ld [wTempMap], a ld a, $c - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, $c - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $2 - ld [wd0be], a + ld [wTempPlayerDirection], a call Func_c9cb call Func_c9dd farcall Func_80b7a @@ -278,13 +278,13 @@ Func_c1f8: ; c1f8 (3:41f8) Func_c228: ; c228 (3:4228) ld a, [wCurMap] - ld [wd0bb], a + ld [wTempMap], a ld a, [wPlayerXCoord] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [wPlayerYCoord] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, [wPlayerDirection] - ld [wd0be], a + ld [wTempPlayerDirection], a ret Func_c241: ; c241 (3:4241) @@ -587,7 +587,7 @@ Func_c4b9: ; c4b9 (3:44b9) ld a, [wCurMap] cp OVERWORLD_MAP jr z, .asm_c4ee - ld a, [wd0be] + ld a, [wTempPlayerDirection] ld b, a .asm_c4ee ld a, b @@ -930,7 +930,7 @@ Func_c6f7: ; c6f7 (3:46f7) Func_c70d: ; c70d (3:470d) push hl - ld hl, wd0bb + ld hl, wTempMap ld a, [wCurMap] cp [hl] jr z, .asm_c71c @@ -1288,15 +1288,15 @@ Func_c998: ; c998 (3:4998) ret Func_c9b8: ; c9b8 (3:49b8) - ld l, $8 + ld l, MAP_SCRIPT_LOAD_MAP jr CallMapScriptPointerIfExists Func_c9bc: ; c9bc (3:49bc) - ld l, $a + ld l, MAP_SCRIPT_AFTER_DUEL jr CallMapScriptPointerIfExists Func_c9c0: ; c9c0 (3:49c0) - ld l, $c + ld l, MAP_SCRIPT_MOVED_PLAYER CallMapScriptPointerIfExists: ; c9c2 (3:49c2) call GetMapScriptPointer @@ -1304,7 +1304,7 @@ CallMapScriptPointerIfExists: ; c9c2 (3:49c2) jp hl Func_c9c7: ; c9c7 (3:49c7) - ld l, $e + ld l, MAP_SCRIPT_CLOSE_TEXTBOX jr CallMapScriptPointerIfExists Func_c9cb: ; c9cb (3:49cb) @@ -1342,7 +1342,7 @@ Func_c9e8: ; c9e8 (3:49e8) ld b, $0 ld hl, Unknown_ca0a add hl, bc - ld a, [wd0bb] + ld a, [wTempMap] cp [hl] jr z, .asm_c9f2 .asm_ca04 @@ -1719,11 +1719,11 @@ RST20: ; cc42 (3:4c42) ld [wOWScriptPointer+1], a xor a ld [wBreakOWScriptLoop], a -.asm_cc4f +.continueScriptLoop call RunOverworldScript ld a, [wBreakOWScriptLoop] ; if you break out, it jumps or a - jr z, .asm_cc4f + jr z, .continueScriptLoop ld hl, wOWScriptPointer ld a, [hli] ld c, a @@ -1808,6 +1808,7 @@ SetScriptControlByteFail: ; ccb9 (3:4cb9) ld [wScriptControlByte], a ret +; Exits Script mode and runs the next instruction like normal OWScript_EndScriptLoop1: ; ccbe (3:4cbe) OWScript_EndScriptLoop2: ; ccbe (3:4cbe) OWScript_EndScriptLoop3: ; ccbe (3:4cbe) @@ -1826,7 +1827,7 @@ OWScript_CloseAdvancedTextBox: ; ccc6 (3:4cc6) call CloseAdvancedDialogueBox jp IncreaseOWScriptPointerBy1 -OWScript_EndScriptCloseText: ; cccc (3:4ccc) +OWScript_QuitScriptFully: ; cccc (3:4ccc) call OWScript_CloseAdvancedTextBox call OWScript_EndScriptLoop1 pop hl @@ -1845,7 +1846,7 @@ Func_ccdc: ; ccdc (3:4cdc) call Func_c891 jp IncreaseOWScriptPointerBy3 -Func_cce4: ; cce4 (3:4ce4) +OWScript_AskQuestionJumpDefaultYes: ; cce4 (3:4ce4) ld a, $1 ld [wDefaultYesOrNo], a ; fallthrough @@ -2099,42 +2100,48 @@ OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) ld [wd117], a pop bc ld a, b - cp $ff + cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b call GetOWSArgs3AfterPointer ld a, c - cp $ff + cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b .asm_ceb4 call Func_c2d4 jp IncreaseOWScriptPointerBy4 -Func_ceba: ; ceba (3:4eba) +OWScript_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) xor a ld [wd117], a call Func_c2a3 - ld hl, $4edd -.asm_cec4 + ld hl, .booster_type_table +.giveBoosterLoop ld a, [hl] - cp $ff - jr z, .asm_ced7 + cp NO_BOOSTER + jr z, .done push hl farcall BoosterPack_1031b ld a, $1 ld [wd117], a pop hl inc hl - jr .asm_cec4 -.asm_ced7 + jr .giveBoosterLoop +.done call Func_c2d4 jp IncreaseOWScriptPointerBy1 -; 0xcedd - INCROM $cedd, $cee2 +.booster_type_table + db BOOSTER_COLOSSEUM_TRAINER + db BOOSTER_EVOLUTION_TRAINER + db BOOSTER_MYSTERY_TRAINER_COLORLESS + db BOOSTER_LABORATORY_TRAINER + db NO_BOOSTER ; $ff -Func_cee2: ; cee2 (3:4ee2) +; Shows the card received screen for a given promotional card +; arg can either be the card, $00 for a wram card, or $ff for the 4 legends +OWScript_ShowCardReceivedScreen: ; cee2 (3:4ee2) call Func_c2a3 ld a, c cp $ff @@ -2381,7 +2388,7 @@ Func_d04f: ; d04f (3:504f) call Func_cad8 jp IncreaseOWScriptPointerBy1 -Func_d055: ; d055 (3:5055) +OWScript_SetPlayerDirection: ; d055 (3:5055) ld a, c call Func_c5ce jp IncreaseOWScriptPointerBy2 @@ -2410,9 +2417,7 @@ OWScript_SetDialogName: ; d080 (3:5080) farcall SetNPCDialogName jp IncreaseOWScriptPointerBy2 -; Calls another OWSequence with a specified NPC -; Not confident enough to give it a name yet -Func_d088: ; d088 (3:5088) +OWScript_SetNextNPCandOWSequence: ; d088 (3:5088) ld a, c ld [wTempNPC], a call GetOWSArgs2AfterPointer @@ -2474,7 +2479,7 @@ Func_d0d9: ; d0d9 (3:50d9) jp nz, ScriptEventFailedNoJump jp ScriptEventPassedTryJump -Func_d0f2: ; d0f2 (3:50f2) +OWScript_JumpIfPlayerCoordMatches: ; d0f2 (3:50f2) ld a, [wPlayerXCoord] cp c jp nz, ScriptEventFailedNoJump @@ -2792,7 +2797,8 @@ OWScript_OpenDeckMachine: ; d336 (3:5336) call Func_c2d4 jp IncreaseOWScriptPointerBy2 -Func_d36d: ; d36d (3:536d) +; args: unused, room, new player x, new player y, new player direction +OWScript_EnterMap: ; d36d (3:536d) ld a, [wOWScriptPointer] ld l, a ld a, [wOWScriptPointer+1] @@ -2800,13 +2806,13 @@ Func_d36d: ; d36d (3:536d) inc hl ld a, [hli] ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, [hli] - ld [wd0be], a + ld [wTempPlayerDirection], a ld hl, wd0b4 set 4, [hl] jp IncreaseOWScriptPointerBy6 @@ -3050,7 +3056,7 @@ LoadOverworld: ; d4ec (3:54ec) get_flag_value EVENT_FLAG_3E or a ret nz - ld bc, OWSequence_d52e + ld bc, OWSequence_BeginGame jp SetNextOWSequence Func_d4fb: ; d4fb (3:54fb) @@ -3077,23 +3083,34 @@ Func_d4fb: ; d4fb (3:54fb) set_flag_value EVENT_FLAG_3F ret -OWSequence_d52e: ; d52e (3:552e) +OWSequence_BeginGame: ; d52e (3:552e) start_script run_script OWScript_DoFrames db $3c run_script Func_d3e0 run_script OWScript_DoFrames db $78 - run_script Func_d36d + run_script OWScript_EnterMap db $02 - db $01 - db $0e - db $1a + db MASON_LABORATORY + db 14 + db 26 + db NORTH + run_script OWScript_QuitScriptFully + +MasonLaboratoryAfterDuel: ; d53b (3:553b) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret + +.after_duel_table + db SAM + db SAM + dw $568a + dw $569f db $00 - run_script OWScript_EndScriptCloseText -; 0xd53b - INCROM $d53b, $d753 + INCROM $d549, $d753 OWSequence_d753: ; d753 (3:5753) start_script @@ -3127,7 +3144,7 @@ OWSequence_d753: ; d753 (3:5753) run_script OWScript_PrintTextString tx Text05e3 run_script OWScript_CloseAdvancedTextBox - run_script Func_d088 + run_script OWScript_SetNextNPCandOWSequence db SAM dw OWSequence_d779 run_script OWScript_EndScriptLoop1 @@ -3150,15 +3167,286 @@ OWSequence_d779: ; d779 (03:5779) db $58 run_script Func_cfc6 db $01 - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $03 run_script OWScript_CloseAdvancedTextBox - run_script Func_d088 + run_script OWScript_SetNextNPCandOWSequence + db DRMASON + dw OWSequence_d794 + run_script OWScript_EndScriptLoop1 + ret + +OWSequence_d794: ; d794 (3:5794) + start_script + run_script Func_ce4a + db $8b + db $58 + run_script OWScript_DoFrames + db $28 + run_script OWScript_PrintTextString + tx Text05e6 + run_script OWScript_CloseTextBox + run_script OWScript_MovePlayer + db WEST + db $01 + run_script OWScript_MovePlayer + db WEST + db $01 + run_script OWScript_SetPlayerDirection + db SOUTH + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_SetPlayerDirection + db WEST + run_script Func_ce4a + db $94 + db $58 + run_script OWScript_PrintTextString + tx Text05e7 + run_script OWScript_SetDialogName + db $07 + run_script OWScript_PrintTextString + tx Text05e8 + +.ows_d7bc + run_script OWScript_CloseTextBox + run_script Func_d317 + run_script OWScript_CloseTextBox + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $07 + dw .ows_d80c + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $01 + dw .ows_d7e8 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $02 + dw .ows_d7ee + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $03 + dw .ows_d7f4 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $04 + dw .ows_d7fa + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $05 + dw .ows_d800 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_75 + db $06 + dw .ows_d806 + run_script OWScript_PrintTextString + tx Text05d6 + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d7e8 + run_script OWScript_PrintTextString + tx Text05d7 + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d7ee + run_script OWScript_PrintTextString + tx Text05d8 + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d7f4 + run_script OWScript_PrintTextString + tx Text05d9 + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d7fa + run_script OWScript_PrintTextString + tx Text05da + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d800 + run_script OWScript_PrintTextString + tx Text05db + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d806 + run_script OWScript_PrintTextString + tx Text05dc + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d80c + run_script OWScript_PrintTextString + tx Text05e9 + run_script OWScript_AskQuestionJumpDefaultYes + dw 0000 + dw .ows_d817 + run_script OWScript_Jump + dw .ows_d7bc + +.ows_d817 + run_script OWScript_SetDialogName + db $01 + run_script OWScript_PrintTextString + tx Text05ea + run_script OWScript_nop + run_script OWScript_SetFlagValue + db EVENT_FLAG_3E db $01 - dw $5794 + run_script OWScript_CloseAdvancedTextBox + run_script OWScript_SetNextNPCandOWSequence + db SAM + dw OWSequence_d827 run_script OWScript_EndScriptLoop1 + ret + +OWSequence_d827: ; d827 (3:5827) + start_script + run_script OWScript_StartBattle + db PRIZES_2 + db SAMS_PRACTICE_DECK_ID + db MUSIC_DUEL_THEME_1 + run_script OWScript_QuitScriptFully +; 0xd82d + + INCROM $d82d, $dc68 + +FightingClubLobbyAfterDuel: ; dc68 (3:5c68) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret +.after_duel_table + db IMAKUNI + db IMAKUNI + dw OWSequence_BeatImakuni + dw OWSequence_LostToImakuni + db $00 + + INCROM $dc76, $dd0d + +OWSequence_Imakuni: ; dd0d (3:5d0d) + start_script + run_script OWScript_SetFlagValue + db EVENT_FLAG_13 + db $02 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0467 + tx Text0468 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_02 + run_script OWScript_AskQuestionJump + tx Text0469 + dw .declineDuel + run_script OWScript_PrintTextString + tx Text046a + run_script OWScript_QuitScriptFully + +.declineDuel + run_script OWScript_PrintTextString + tx Text046b + run_script OWScript_StartBattle + db PRIZES_6 + db IMAKUNI_DECK_ID + db MUSIC_IMAKUNI + run_script OWScript_QuitScriptFully +; 0xdd2d + +OWSequence_BeatImakuni: ; dd2d (3:5d2d) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_36 + db $07 + dw .ows_dd3f + run_script OWScript_IncrementFlagValue + db EVENT_FLAG_36 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_36 + db $03 + dw .ows_dd46 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_36 + db $06 + dw .ows_dd4c +.ows_dd3f + run_script OWScript_PrintTextString + tx Text046c + run_script OWScript_GiveOneOfEachTrainerBooster + run_script OWScript_Jump + dw .ows_dd56 + +.ows_dd46 + run_script OWScript_PrintTextString + tx Text046d + run_script OWScript_Jump + dw .ows_dd4f + +.ows_dd4c + run_script OWScript_PrintTextString + tx Text046e +.ows_dd4f + run_script OWScript_PrintTextString + tx Text046f + run_script OWScript_GiveCard + db IMAKUNI_CARD + run_script OWScript_ShowCardReceivedScreen + db IMAKUNI_CARD +.ows_dd56 + run_script OWScript_PrintTextString + tx Text0470 + run_script OWScript_Jump + dw OWJump_ImakuniCommon - INCROM $d793, $e13f +OWSequence_LostToImakuni: ; dd5c (3:5d5c) + start_script + run_script OWScript_PrintTextString + tx Text0471 + +OWJump_ImakuniCommon: ; dd60 (3:5d60) + run_script OWScript_CloseTextBox + run_script OWScript_JumpIfPlayerCoordMatches + db 18 + db 4 + dw .ows_dd69 + run_script OWScript_Jump + dw .ows_dd6e + +.ows_dd69 + run_script OWScript_SetPlayerDirection + db EAST + run_script OWScript_MovePlayer + db WEST + db $01 + +.ows_dd6e + run_script Func_ce4a + db $78 + db $5d + run_script Func_cdcb + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_03 + run_script Func_d408 + db $09 + run_script Func_d41d + run_script OWScript_QuitScriptFully +; 0xdd78 + + INCROM $dd78, $e13f WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] @@ -3167,7 +3455,7 @@ WaterClubMovePlayer: ; e13f (3:613f) get_flag_value EVENT_JOSHUA_STATE cp $2 ret nc - ld a, $21 + ld a, JOSHUA ld [wTempNPC], a ld bc, OWSequence_NotReadyToSeeAmy jp SetNextNPCAndOWSequence @@ -3208,7 +3496,7 @@ OWSequence_Sara: ; e177 (3:6177) dw .yes_duel run_script OWScript_PrintTextString tx Text042e - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .yes_duel run_script OWScript_PrintTextString tx Text042f @@ -3216,7 +3504,7 @@ OWSequence_Sara: ; e177 (3:6177) db PRIZES_2 db WATERFRONT_POKEMON_DECK_ID ; 6189 db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatSara: ; e18c (3:618c) start_script @@ -3230,7 +3518,7 @@ OWSequence_BeatSara: ; e18c (3:618c) db NO_BOOSTER run_script OWScript_PrintTextString tx Text0431 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_LostToSara: ; e19a (03:619a) start_script @@ -3246,7 +3534,7 @@ OWSequence_Amanda: ; e19e (03:619e) dw .yes_duel run_script OWScript_PrintTextString tx Text0435 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .yes_duel run_script OWScript_PrintTextString tx Text0436 @@ -3254,7 +3542,7 @@ OWSequence_Amanda: ; e19e (03:619e) db PRIZES_3 db LONELY_FRIENDS_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatAmanda: ; e1b3 (03:61b3) start_script @@ -3268,24 +3556,24 @@ OWSequence_BeatAmanda: ; e1b3 (03:61b3) db NO_BOOSTER run_script OWScript_PrintTextString tx Text0438 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_LostToAmanda: ; e1c1 (03:61c1) start_script run_script OWScript_PrintTextCloseBox tx Text0439 -OWSequence_NotReadyToSeeAmy: +OWSequence_NotReadyToSeeAmy: ; e15c (03:6153) start_script - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $12 db $08 dw $61ec - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $14 db $08 dw $61f2 - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $18 db $08 dw $61f8 @@ -3297,18 +3585,18 @@ OWSequence_NotReadyToSeeAmy: db $62 run_script OWScript_PrintTextString tx Text043a - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $12 db $0a dw $61fe - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $14 db $0a dw $6202 run_script Func_ce4a db $15 db $62 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .ows_e1ec run_script Func_ce4a @@ -3329,7 +3617,7 @@ OWSequence_NotReadyToSeeAmy: run_script Func_ce4a db $18 db $62 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully ; 0xe202 INCROM $e202, $e21c @@ -3350,7 +3638,7 @@ OWSequence_Joshua: db JOSHUA_TALKED run_script OWScript_PrintTextString tx Text043b - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .beat_sara_and_amanda run_script OWScript_JumpIfFlagNonzero1 @@ -3381,7 +3669,7 @@ OWSequence_Joshua: run_script OWScript_PrintVariableText tx Text0440 tx Text0441 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .startDuel: run_script OWScript_PrintTextString @@ -3392,7 +3680,7 @@ OWSequence_Joshua: db PRIZES_4 db SOUND_OF_THE_WAVES_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_LostToJoshua: ; e260 (3:6260) start_script @@ -3403,7 +3691,7 @@ OWSequence_LostToJoshua: ; e260 (3:6260) run_script OWScript_PrintVariableText tx Text0443 tx Text0444 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatJoshua: ; e26c (3:626c) start_script @@ -3429,7 +3717,7 @@ OWSequence_BeatJoshua: ; e26c (3:626c) db EVENT_JOSHUA_STATE db JOSHUA_BEATEN dw .firstJoshuaWin - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .firstJoshuaWin: run_script OWScript_SetFlagValue @@ -3445,13 +3733,13 @@ OWSequence_BeatJoshua: ; e26c (3:626c) run_script Func_cfc6 db $00 run_script OWScript_CloseAdvancedTextBox - run_script Func_d088 + run_script OWScript_SetNextNPCandOWSequence db AMY dw OWSequence_MeetAmy run_script OWScript_EndScriptLoop1 -; 0xe2a0 + ret - INCROM $e2a0, $e2d1 + INCROM $e2a1, $e2d1 OWSequence_MeetAmy: ; e2d1 (3:62d1) start_script @@ -3479,12 +3767,12 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) run_script Func_d0be db $14 db $04 - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $03 run_script OWScript_MovePlayer db WEST db $01 - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $00 run_script OWScript_MovePlayer db NORTH @@ -3520,7 +3808,7 @@ OWSequence_Amy: ; e304 (3:6304) db $14 db $04 dw OWSequence_LostToAmy.ows_e34e - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .startDuel run_script OWScript_PrintTextString @@ -3529,7 +3817,7 @@ OWSequence_Amy: ; e304 (3:6304) db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatAmy: ; e322 (3:6322) start_script @@ -3560,7 +3848,7 @@ OWSequence_BeatAmy: ; e322 (3:6322) db $14 db $04 dw OWSequence_LostToAmy.ows_e34e - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_LostToAmy: ; e344 (3:6344) start_script @@ -3570,7 +3858,7 @@ OWSequence_LostToAmy: ; e344 (3:6344) db $14 db $04 dw .ows_e34e - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .ows_e34e run_script Func_d095 @@ -3580,7 +3868,7 @@ OWSequence_LostToAmy: ; e344 (3:6344) run_script Func_d0be db $16 db $04 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWJump_TalkToAmyAgain: ; e356 (3:6356) run_script OWScript_PrintTextString @@ -3598,7 +3886,7 @@ OWJump_TalkToAmyAgain: ; e356 (3:6356) db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully ; 0xe369 INCROM $e369, $e525 @@ -3684,7 +3972,7 @@ OWSequence_Brittany: ; e5d2 (3:65d2) dw .wantToDuel run_script OWScript_PrintTextString tx Text06e3 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully .wantToDuel run_script OWScript_PrintTextString @@ -3693,7 +3981,7 @@ OWSequence_Brittany: ; e5d2 (3:65d2) db PRIZES_4 db ETCETERA_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatBrittany: ; e5ee (3:65ee) start_script @@ -3730,7 +4018,7 @@ OWSequence_BeatBrittany: ; e5ee (3:65ee) run_script OWScript_PrintTextString tx Text06e8 .finishSequence - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_LostToBrittany: ; e618 (3:6618) start_script @@ -3817,7 +4105,7 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) db $01 run_script OWScript_PrintTextString tx Text0646 - run_script Func_cce4 + run_script OWScript_AskQuestionJumpDefaultYes dw 0000 dw .ows_e882 run_script OWScript_PrintTextString @@ -3832,7 +4120,7 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) run_script OWScript_PrintTextString tx Text0649 run_script OWScript_CloseTextBox - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $03 run_script OWScript_MovePlayer db EAST @@ -3842,7 +4130,7 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) db $68 run_script Func_cdcb run_script Func_d41d - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully ; 0xe894 INCROM $e894, $e8c0 @@ -3859,16 +4147,16 @@ OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) db $69 run_script OWScript_PrintTextString tx Text064a - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $08 db $02 dw $68d6 - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $03 run_script OWScript_MovePlayer db WEST db $01 - run_script Func_d055 + run_script OWScript_SetPlayerDirection db $02 run_script OWScript_MovePlayer db SOUTH @@ -3885,7 +4173,7 @@ OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) db PRIZES_6 db IM_RONALD_DECK_ID db MUSIC_RONALD - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatFirstRonaldFight: ; e8e9 (3:68e9) start_script @@ -3893,7 +4181,7 @@ OWSequence_BeatFirstRonaldFight: ; e8e9 (3:68e9) tx Text064c run_script OWScript_GiveCard db JIGGLYPUFF1 - run_script Func_cee2 + run_script OWScript_ShowCardReceivedScreen db JIGGLYPUFF1 run_script OWScript_PrintTextString tx Text064d @@ -3915,7 +4203,7 @@ OWJump_FinishedFirstRonaldFight db $69 run_script Func_cdcb run_script Func_d41d - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully ; 0xe905 INCROM $e905, $e91e @@ -3926,22 +4214,23 @@ OWSequenceSecondRonaldFight: ; e91e (3:691e) db $05 db $69 run_script OWScript_DoFrames - db $3c + db 60 run_script Func_ce4a db $0d db $69 run_script OWScript_PrintTextString tx Text064f - run_script Func_d0f2 + run_script OWScript_JumpIfPlayerCoordMatches db $08 db $02 - dw $6934 - run_script Func_d055 + dw .ows_6934 + run_script OWScript_SetPlayerDirection db $03 run_script OWScript_MovePlayer db WEST db $01 - run_script Func_d055 +.ows_6934 + run_script OWScript_SetPlayerDirection db $02 run_script OWScript_MovePlayer db SOUTH @@ -3952,13 +4241,13 @@ OWSequenceSecondRonaldFight: ; e91e (3:691e) run_script OWScript_PrintTextString tx Text0650 run_script OWScript_SetFlagValue - db $4d + db EVENT_FLAG_4D db $01 run_script OWScript_StartBattle db PRIZES_6 db POWERFUL_RONALD_DECK_ID db MUSIC_RONALD - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully OWSequence_BeatSecondRonaldFight: ; e947 (3:6947) start_script @@ -3966,7 +4255,7 @@ OWSequence_BeatSecondRonaldFight: ; e947 (3:6947) tx Text0651 run_script OWScript_GiveCard db SUPER_ENERGY_RETRIEVAL - run_script Func_cee2 + run_script OWScript_ShowCardReceivedScreen db SUPER_ENERGY_RETRIEVAL run_script OWScript_PrintTextString tx Text0652 @@ -3980,7 +4269,7 @@ OWSequence_LostToSecondRonaldFight: ; e955 (3:6955) OWJump_FinishedSecondRonaldFight ; e959 (3:6959) run_script OWScript_SetFlagValue - db $4d + db EVENT_FLAG_4D db $02 run_script OWScript_CloseTextBox run_script Func_ce4a @@ -3988,7 +4277,7 @@ OWJump_FinishedSecondRonaldFight ; e959 (3:6959) db $69 run_script Func_cdcb run_script Func_d41d - run_script OWScript_EndScriptCloseText + run_script OWScript_QuitScriptFully ; 0xe963 INCROM $e963, $f580 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index c81db5c..1613204 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -478,13 +478,13 @@ LoadOverworldMapSelection: ; 10f61 (4:4f61) ld hl, OverworldMapIndexes add hl, bc ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $0 - ld [wd0be], a + ld [wTempPlayerDirection], a ld hl, wd0b4 set 4, [hl] pop bc @@ -819,13 +819,13 @@ Func_1157c: ; 1157c (4:557c) .asm_11586 ld a, $2 - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, $4 - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $2 - ld [wd0be], a + ld [wTempPlayerDirection], a ld a, $1 - ld [wd0bb], a + ld [wTempMap], a ld a, $1 ld [wd32e], a @@ -998,18 +998,18 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d03f dw OWScript_Jump dw Func_d04f - dw Func_d055 + dw OWScript_SetPlayerDirection dw OWScript_MovePlayer - dw Func_cee2 + dw OWScript_ShowCardReceivedScreen dw OWScript_SetDialogName - dw Func_d088 + dw OWScript_SetNextNPCandOWSequence dw Func_d095 dw Func_d0be dw OWScript_DoFrames dw Func_d0d9 - dw Func_d0f2 + dw OWScript_JumpIfPlayerCoordMatches dw Func_ce4a - dw Func_ceba + dw OWScript_GiveOneOfEachTrainerBooster dw Func_d103 dw Func_d125 dw Func_d135 @@ -1022,12 +1022,12 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d195 dw Func_d1ad dw Func_d1b3 - dw OWScript_EndScriptCloseText + dw OWScript_QuitScriptFully dw Func_d244 dw Func_d24c dw OWScript_OpenDeckMachine dw Func_d271 - dw Func_d36d + dw OWScript_EnterMap dw Func_ce6f dw Func_d209 dw Func_d38f @@ -1048,7 +1048,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d41d dw Func_d42f dw Func_d435 - dw Func_cce4 + dw OWScript_AskQuestionJumpDefaultYes dw Func_d2f6 dw Func_d317 dw Func_d43d diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 4455d3f..b5b9504 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -35,13 +35,13 @@ Func_1c056: ; 1c056 (7:4056) inc hl inc hl ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, [wPlayerDirection] - ld [wd0be], a + ld [wTempPlayerDirection], a .asm_1c095 pop de pop bc diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 7f2bbb5..942fb82 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -43,18 +43,18 @@ ENDM const Func_d03f_index ; $1a const OWScript_Jump_index ; $1b const Func_d04f_index ; $1c - const Func_d055_index ; $1d + const OWScript_SetPlayerDirection_index ; $1d const OWScript_MovePlayer_index ; $1e - const Func_cee2_index ; $1f + const OWScript_ShowCardReceivedScreen_index ; $1f const OWScript_SetDialogName_index ; $20 - const Func_d088_index ; $21 + const OWScript_SetNextNPCandOWSequence_index ; $21 const Func_d095_index ; $22 const Func_d0be_index ; $23 const OWScript_DoFrames_index ; $24 const Func_d0d9_index ; $25 - const Func_d0f2_index ; $26 + const OWScript_JumpIfPlayerCoordMatches_index ; $26 const Func_ce4a_index ; $27 - const Func_ceba_index ; $28 + const OWScript_GiveOneOfEachTrainerBooster_index ; $28 const Func_d103_index ; $29 const Func_d125_index ; $2a const Func_d135_index ; $2b @@ -67,12 +67,12 @@ ENDM const Func_d195_index ; $32 const Func_d1ad_index ; $33 const Func_d1b3_index ; $34 - const OWScript_EndScriptCloseText_index ; $35 + const OWScript_QuitScriptFully_index ; $35 const Func_d244_index ; $36 const Func_d24c_index ; $37 const OWScript_OpenDeckMachine_index ; $38 const Func_d271_index ; $39 - const Func_d36d_index ; $3a + const OWScript_EnterMap_index ; $3a const Func_ce6f_index ; $3b const Func_d209_index ; $3c const Func_d38f_index ; $3d @@ -93,7 +93,7 @@ ENDM const Func_d41d_index ; $4c const Func_d42f_index ; $4d const Func_d435_index ; $4e - const Func_cce4_index ; $4f + const OWScript_AskQuestionJumpDefaultYes_index ; $4f const Func_d2f6_index ; $50 const Func_d317_index ; $51 const Func_d43d_index ; $52 diff --git a/src/wram.asm b/src/wram.asm index fd24dbd..c3fb738 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1784,16 +1784,16 @@ wd0b9:: ; d0b9 wd0ba:: ; d0ba ds $1 -wd0bb:: ; d0bb +wTempMap:: ; d0bb ds $1 -wd0bc:: ; d0bc +wTempPlayerXCoord:: ; d0bc ds $1 -wd0bd:: ; d0bd +wTempPlayerYCoord:: ; d0bd ds $1 -wd0be:: ; d0be +wTempPlayerDirection:: ; d0be ds $1 wd0bf:: ; d0bf -- cgit v1.2.3 From 299f013b8b14184b9f06da3b89ba87ce2ba9e0f3 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sun, 13 Oct 2019 19:39:13 -0400 Subject: More scripts, start to figure out mapscripts --- src/constants.asm | 3 +- src/constants/event_constants.asm | 3 - src/constants/npc_constants.asm | 222 ++++----- src/constants/script_constants.asm | 256 +++++----- src/data/level_objects.asm | 602 +++++++++++++++++++++++ src/data/npc_map_data.asm | 58 +-- src/data/npcs.asm | 24 +- src/engine/bank03.asm | 945 ++++++++++++++++++++++++++++++------- src/engine/bank04.asm | 41 +- src/engine/bank07.asm | 53 ++- src/engine/home.asm | 48 +- src/macros/code.asm | 6 + src/macros/scripts.asm | 14 +- src/wram.asm | 13 +- 14 files changed, 1773 insertions(+), 515 deletions(-) delete mode 100644 src/constants/event_constants.asm create mode 100644 src/data/level_objects.asm (limited to 'src') diff --git a/src/constants.asm b/src/constants.asm index 7ad156b..421c8ac 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -4,7 +4,6 @@ INCLUDE "constants/card_data_constants.asm" INCLUDE "constants/deck_constants.asm" INCLUDE "constants/duel_constants.asm" INCLUDE "constants/duel_interface_constants.asm" -INCLUDE "constants/event_constants.asm" INCLUDE "constants/gfx_constants.asm" INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/map_constants.asm" @@ -12,9 +11,9 @@ INCLUDE "constants/misc_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/name_constants.asm" INCLUDE "constants/npc_constants.asm" +INCLUDE "constants/script_constants.asm" INCLUDE "constants/sgb_constants.asm" INCLUDE "constants/sfx_constants.asm" INCLUDE "constants/sprite_constants.asm" INCLUDE "constants/text_constants.asm" INCLUDE "constants/charmaps.asm" -INCLUDE "constants/script_constants.asm" diff --git a/src/constants/event_constants.asm b/src/constants/event_constants.asm deleted file mode 100644 index f6ac803..0000000 --- a/src/constants/event_constants.asm +++ /dev/null @@ -1,3 +0,0 @@ -; EVENT_JOSHUA_STATE ; $33 -JOSHUA_TALKED EQU 1 -JOSHUA_BEATEN EQU 2 diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index 9e3911c..5ae8f99 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -77,119 +77,119 @@ NPC_DATA_LENGTH EQU const_value const AARON_PIC ; $29 const_def 1 - const DRMASON ; $01 - const RONALD1 ; $02 - const ISHIHARA ; $03 - const IMAKUNI ; $04 + const DRMASON ; $01 + const RONALD1 ; $02 + const ISHIHARA ; $03 + const IMAKUNI ; $04 const_value = const_value+1 ; DRMASON duplicate const_value = const_value+1 ; DRMASON duplicate - const SAM ; $07 - const TECH1 ; $08 - const TECH2 ; $09 - const TECH3 ; $0a - const TECH4 ; $0b - const TECH5 ; $0c - const TECH6 ; $0d - const CLERK1 ; $0e - const CLERK2 ; $0f - const CLERK3 ; $10 - const CLERK4 ; $11 - const CLERK5 ; $12 - const CLERK6 ; $13 - const CLERK7 ; $14 - const CLERK8 ; $15 - const CLERK9 ; $16 - const CHRIS ; $17 - const MICHAEL ; $18 - const JESSICA ; $19 - const MITCH ; $1a - const MATTHEW ; $1b - const RYAN ; $1c - const ANDREW ; $1d - const GENE ; $1e - const SARA ; $1f - const AMANDA ; $20 - const JOSHUA ; $21 - const AMY ; $22 - const JENNIFER ; $23 - const NICHOLAS ; $24 - const BRANDON ; $25 - const ISAAC ; $26 - const BRITTANY ; $27 - const KRISTIN ; $28 - const HEATHER ; $29 - const NIKKI ; $2a - const ROBERT ; $2b - const DANIEL ; $2c - const STEPHANIE ; $2d - const MURRAY1 ; $2e - const JOSEPH ; $2f - const DAVID ; $30 - const ERIK ; $31 - const RICK ; $32 - const JOHN ; $33 - const ADAM ; $34 - const JONATHAN ; $35 - const KEN ; $36 - const COURTNEY ; $37 - const STEVE ; $38 - const JACK ; $39 - const ROD ; $3a - const CLERK10 ; $3b - const CLERK11 ; $3c - const MAN1 ; $3d - const WOMAN1 ; $3e - const CHAP1 ; $3f - const GAL1 ; $40 - const LASS1 ; $41 - const CHAP2 ; $42 - const LASS2 ; $43 - const PAPPY1 ; $44 - const LAD1 ; $45 - const LAD2 ; $46 - const CHAP3 ; $47 - const CLERK12 ; $48 - const CLERK13 ; $49 - const HOST ; $4a - const SPECS1 ; $4b - const BUTCH ; $4c - const GRANNY1 ; $4d - const LASS3 ; $4e - const MAN2 ; $4f - const PAPPY2 ; $50 - const LASS4 ; $51 - const HOOD1 ; $52 - const GRANNY2 ; $53 - const GAL2 ; $54 - const LAD3 ; $55 - const GAL3 ; $56 - const CHAP4 ; $57 - const MAN3 ; $58 - const SPECS2 ; $59 - const SPECS3 ; $5a - const WOMAN2 ; $5b - const MANIA ; $5c - const PAPPY3 ; $5d - const GAL4 ; $5e - const CHAMP ; $5f - const HOOD2 ; $60 - const LASS5 ; $61 - const CHAP5 ; $62 - const AARON ; $63 - const GUIDE ; $64 - const TECH7 ; $65 - const TECH8 ; $66 - const _11F18 ; $67 - const _11F1F ; $68 - const _11F26 ; $69 - const _11F2D ; $6a - const _11F34 ; $6b - const _11F3B ; $6c - const _11F42 ; $6d - const _11F49 ; $6e + const SAM ; $07 + const TECH1 ; $08 + const TECH2 ; $09 + const TECH3 ; $0a + const TECH4 ; $0b + const TECH5 ; $0c + const TECH6 ; $0d + const CLERK1 ; $0e + const CLERK2 ; $0f + const CLERK3 ; $10 + const CLERK4 ; $11 + const CLERK5 ; $12 + const CLERK6 ; $13 + const CLERK7 ; $14 + const CLERK8 ; $15 + const CLERK9 ; $16 + const CHRIS ; $17 + const MICHAEL ; $18 + const JESSICA ; $19 + const MITCH ; $1a + const MATTHEW ; $1b + const RYAN ; $1c + const ANDREW ; $1d + const GENE ; $1e + const SARA ; $1f + const AMANDA ; $20 + const JOSHUA ; $21 + const AMY ; $22 + const JENNIFER ; $23 + const NICHOLAS ; $24 + const BRANDON ; $25 + const ISAAC ; $26 + const BRITTANY ; $27 + const KRISTIN ; $28 + const HEATHER ; $29 + const NIKKI ; $2a + const ROBERT ; $2b + const DANIEL ; $2c + const STEPHANIE ; $2d + const MURRAY1 ; $2e + const JOSEPH ; $2f + const DAVID ; $30 + const ERIK ; $31 + const RICK ; $32 + const JOHN ; $33 + const ADAM ; $34 + const JONATHAN ; $35 + const KEN ; $36 + const COURTNEY ; $37 + const STEVE ; $38 + const JACK ; $39 + const ROD ; $3a + const CLERK10 ; $3b + const GIFT_CENTER_CLERK ; $3c + const MAN1 ; $3d + const WOMAN1 ; $3e + const CHAP1 ; $3f + const GAL1 ; $40 + const LASS1 ; $41 + const CHAP2 ; $42 + const LASS2 ; $43 + const PAPPY1 ; $44 + const LAD1 ; $45 + const LAD2 ; $46 + const CHAP3 ; $47 + const CLERK12 ; $48 + const CLERK13 ; $49 + const HOST ; $4a + const SPECS1 ; $4b + const BUTCH ; $4c + const GRANNY1 ; $4d + const LASS3 ; $4e + const MAN2 ; $4f + const PAPPY2 ; $50 + const LASS4 ; $51 + const HOOD1 ; $52 + const GRANNY2 ; $53 + const GAL2 ; $54 + const LAD3 ; $55 + const GAL3 ; $56 + const CHAP4 ; $57 + const MAN3 ; $58 + const SPECS2 ; $59 + const SPECS3 ; $5a + const WOMAN2 ; $5b + const MANIA ; $5c + const PAPPY3 ; $5d + const GAL4 ; $5e + const CHAMP ; $5f + const HOOD2 ; $60 + const LASS5 ; $61 + const CHAP5 ; $62 + const AARON ; $63 + const GUIDE ; $64 + const TECH7 ; $65 + const TECH8 ; $66 + const _11F18 ; $67 + const LEGEND_CARDS_TOP_LEFT ; $68 + const LEGEND_CARDS_TOP_RIGHT ; $69 + const LEGEND_CARDS_LEFT_SPARK ; $6a + const LEGEND_CARDS_BOTTOM_LEFT ; $6b + const LEGEND_CARDS_BOTTOM_RIGHT ; $6c + const LEGEND_CARDS_RIGHT_SPARK ; $6d + const _11F49 ; $6e const_value = const_value+1 ; _11F49 duplicate - const MURRAY2 ; $70 - const RONALD2 ; $71 - const RONALD3 ; $72 + const MURRAY2 ; $70 + const RONALD2 ; $71 + const RONALD3 ; $72 const_value = const_value+1 ; _11f49 duplicate diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 398eeb3..2ce9a54 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -1,125 +1,143 @@ const_def - const EVENT_FLAG_00 - const EVENT_FLAG_01 - const EVENT_FLAG_02 - const EVENT_FLAG_03 - const EVENT_FLAG_04 - const EVENT_FLAG_05 - const EVENT_FLAG_06 - const EVENT_FLAG_07 - const EVENT_FLAG_08 - const EVENT_FLAG_09 - const EVENT_FLAG_0A - const EVENT_BEAT_AMY - const EVENT_FLAG_0C - const EVENT_FLAG_0D - const EVENT_FLAG_0E - const EVENT_FLAG_0F - const EVENT_FLAG_10 - const EVENT_FLAG_11 - const EVENT_FLAG_12 - const EVENT_FLAG_13 - const EVENT_FLAG_14 - const EVENT_BEAT_SARA - const EVENT_BEAT_AMANDA - const EVENT_FLAG_17 - const EVENT_FLAG_18 - const EVENT_FLAG_19 - const EVENT_FLAG_1A - const EVENT_FLAG_1B - const EVENT_FLAG_1C - const EVENT_FLAG_1D - const EVENT_FLAG_1E - const EVENT_FLAG_1F - const EVENT_FLAG_20 - const EVENT_FLAG_21 - const EVENT_FLAG_22 - const EVENT_FLAG_23 - const EVENT_FLAG_24 - const EVENT_FLAG_25 - const EVENT_FLAG_26 - const EVENT_FLAG_27 - const EVENT_FLAG_28 - const EVENT_FLAG_29 - const EVENT_FLAG_2A - const EVENT_FLAG_2B - const EVENT_FLAG_2C - const EVENT_FLAG_2D - const EVENT_FLAG_2E - const EVENT_FLAG_2F - const EVENT_FLAG_30 - const EVENT_FLAG_31 - const EVENT_FLAG_32 - const EVENT_JOSHUA_STATE - const EVENT_FLAG_34 - const EVENT_FLAG_35 - const EVENT_FLAG_36 - const EVENT_FLAG_37 - const EVENT_FLAG_38 - const EVENT_FLAG_39 - const EVENT_FLAG_3A - const EVENT_FLAG_3B - const FLAG_BEAT_BRITTANY - const EVENT_FLAG_3D - const EVENT_FLAG_3E - const EVENT_FLAG_3F - const EVENT_FLAG_40 - const EVENT_FLAG_41 - const EVENT_FLAG_42 - const EVENT_FLAG_43 - const EVENT_FLAG_44 - const EVENT_FLAG_45 - const EVENT_FLAG_46 - const EVENT_FLAG_47 - const EVENT_FLAG_48 - const EVENT_FLAG_49 - const EVENT_FLAG_4A - const EVENT_FLAG_4B - const EVENT_FLAG_4C - const EVENT_FLAG_4D - const EVENT_FLAG_4E - const EVENT_FLAG_4F - const EVENT_FLAG_50 - const EVENT_FLAG_51 - const EVENT_FLAG_52 - const EVENT_FLAG_53 - const EVENT_FLAG_54 - const EVENT_FLAG_55 - const EVENT_FLAG_56 - const EVENT_FLAG_57 - const EVENT_FLAG_58 - const EVENT_FLAG_59 - const EVENT_FLAG_5A - const EVENT_FLAG_5B - const EVENT_FLAG_5C - const EVENT_FLAG_5D - const EVENT_FLAG_5E - const EVENT_FLAG_5F - const EVENT_FLAG_60 - const EVENT_FLAG_61 - const EVENT_FLAG_62 - const EVENT_FLAG_63 - const EVENT_FLAG_64 - const EVENT_FLAG_65 - const EVENT_FLAG_66 - const EVENT_FLAG_67 - const EVENT_FLAG_68 - const EVENT_FLAG_69 - const EVENT_FLAG_6A - const EVENT_FLAG_6B - const EVENT_FLAG_6C - const EVENT_FLAG_6D - const EVENT_FLAG_6E - const EVENT_FLAG_6F - const EVENT_FLAG_70 - const EVENT_FLAG_71 - const EVENT_FLAG_72 - const EVENT_FLAG_73 - const EVENT_FLAG_74 - const EVENT_FLAG_75 - const EVENT_FLAG_76 + const EVENT_FLAG_00 ; $00 + const EVENT_FLAG_01 ; $01 + const EVENT_TEMP_TALKED_TO_IMAKUNI ; $02 + const EVENT_TEMP_BATTLED_IMAKUNI ; $03 + const EVENT_FLAG_04 ; $04 + const EVENT_FLAG_05 ; $05 + const EVENT_FLAG_06 ; $06 + const EVENT_FLAG_07 ; $07 + const EVENT_FLAG_08 ; $08 + const EVENT_FLAG_09 ; $09 + const EVENT_FLAG_0A ; $0a + const EVENT_BEAT_AMY ; $0b + const EVENT_FLAG_0C ; $0c + const EVENT_FLAG_0D ; $0d + const EVENT_FLAG_0E ; $0e + const EVENT_FLAG_0F ; $0f + const EVENT_FLAG_10 ; $10 + const EVENT_FLAG_11 ; $11 + const EVENT_FLAG_12 ; $12 + const EVENT_IMAKUNI_STATE ; $13 + const EVENT_FLAG_14 ; $14 + const EVENT_BEAT_SARA ; $15 + const EVENT_BEAT_AMANDA ; $16 + const EVENT_FLAG_17 ; $17 + const EVENT_FLAG_18 ; $18 + const EVENT_FLAG_19 ; $19 + const EVENT_FLAG_1A ; $1a + const EVENT_FLAG_1B ; $1b + const EVENT_FLAG_1C ; $1c + const EVENT_FLAG_1D ; $1d + const EVENT_FLAG_1E ; $1e + const EVENT_FLAG_1F ; $1f + const EVENT_FLAG_20 ; $20 + const EVENT_FLAG_21 ; $21 + const EVENT_FLAG_22 ; $22 + const EVENT_FLAG_23 ; $23 + const EVENT_FLAG_24 ; $24 + const EVENT_FLAG_25 ; $25 + const EVENT_FLAG_26 ; $26 + const EVENT_FLAG_27 ; $27 + const EVENT_FLAG_28 ; $28 + const EVENT_FLAG_29 ; $29 + const EVENT_FLAG_2A ; $2a + const EVENT_FLAG_2B ; $2b + const EVENT_FLAG_2C ; $2c + const EVENT_FLAG_2D ; $2d + const EVENT_MEDAL_COUNT ; $2e + const EVENT_FLAG_2F ; $2f + const EVENT_FLAG_30 ; $30 + const EVENT_FLAG_31 ; $31 + const EVENT_FLAG_32 ; $32 + const EVENT_JOSHUA_STATE ; $33 + const EVENT_IMAKUNI_ROOM ; $34 + const EVENT_FLAG_35 ; $35 + const EVENT_IMAKUNI_WIN_COUNT ; $36 + const EVENT_FLAG_37 ; $37 + const EVENT_FLAG_38 ; $38 + const EVENT_FLAG_39 ; $39 + const EVENT_FLAG_3A ; $3a + const EVENT_FLAG_3B ; $3b + const FLAG_BEAT_BRITTANY ; $3c + const EVENT_FLAG_3D ; $3d + const EVENT_FLAG_3E ; $3e + const EVENT_FLAG_3F ; $3f + const EVENT_FLAG_40 ; $40 + const EVENT_FLAG_41 ; $41 + const EVENT_FLAG_42 ; $42 + const EVENT_FLAG_43 ; $43 + const EVENT_FLAG_44 ; $44 + const EVENT_FLAG_45 ; $45 + const EVENT_FLAG_46 ; $46 + const EVENT_FLAG_47 ; $47 + const EVENT_FLAG_48 ; $48 + const EVENT_FLAG_49 ; $49 + const EVENT_FLAG_4A ; $4a + const EVENT_FLAG_4B ; $4b + const EVENT_FLAG_4C ; $4c + const EVENT_FLAG_4D ; $4d + const EVENT_FLAG_4E ; $4e + const EVENT_FLAG_4F ; $4f + const EVENT_FLAG_50 ; $50 + const EVENT_FLAG_51 ; $51 + const EVENT_FLAG_52 ; $52 + const EVENT_FLAG_53 ; $53 + const EVENT_FLAG_54 ; $54 + const EVENT_FLAG_55 ; $55 + const EVENT_FLAG_56 ; $56 + const EVENT_FLAG_57 ; $57 + const EVENT_FLAG_58 ; $58 + const EVENT_FLAG_59 ; $59 + const EVENT_FLAG_5A ; $5a + const EVENT_FLAG_5B ; $5b + const EVENT_FLAG_5C ; $5c + const EVENT_FLAG_5D ; $5d + const EVENT_FLAG_5E ; $5e + const EVENT_FLAG_5F ; $5f + const EVENT_FLAG_60 ; $60 + const EVENT_FLAG_61 ; $61 + const EVENT_FLAG_62 ; $62 + const EVENT_FLAG_63 ; $63 + const EVENT_FLAG_64 ; $64 + const EVENT_FLAG_65 ; $65 + const EVENT_FLAG_66 ; $66 + const EVENT_FLAG_67 ; $67 + const EVENT_FLAG_68 ; $68 + const EVENT_FLAG_69 ; $69 + const EVENT_FLAG_6A ; $6a + const EVENT_FLAG_6B ; $6b + const EVENT_FLAG_6C ; $6c + const EVENT_FLAG_6D ; $6d + const EVENT_FLAG_6E ; $6e + const EVENT_FLAG_6F ; $6f + const EVENT_FLAG_70 ; $70 + const EVENT_FLAG_71 ; $71 + const EVENT_FLAG_72 ; $72 + const EVENT_FLAG_73 ; $73 + const EVENT_FLAG_74 ; $74 + const EVENT_FLAG_75 ; $75 + const EVENT_FLAG_76 ; $76 EVENT_FLAG_AMOUNT EQU const_value +EVENT_FLAG_BYTES EQU $40 + +; EVENT_IMAKUNI_STATE +; Starts at 0, Talking to lass moves it to MENTIONED (1), then +; talking to Imakuni at least once sets it to TALKED (2) +IMAKUNI_MENTIONED EQU 1 +IMAKUNI_TALKED EQU 2 + +; EVENT_JOSHUA_STATE +JOSHUA_TALKED EQU 1 +JOSHUA_BEATEN EQU 2 + +; EVENT_IMAKUNI_ROOM +IMAKUNI_FIGHTING_CLUB EQU 0 +IMAKUNI_SCIENCE_CLUB EQU 1 +IMAKUNI_LIGHTNING_CLUB EQU 2 +IMAKUNI_WATER_CLUB EQU 3 + NO_JUMP EQU $0000 NORTH EQU $00 diff --git a/src/data/level_objects.asm b/src/data/level_objects.asm new file mode 100644 index 0000000..a0d51cc --- /dev/null +++ b/src/data/level_objects.asm @@ -0,0 +1,602 @@ +LevelObjects_13b04: ; 13b04 (3:7b04) + db NORTH, 18, 2 + dw PrintInteractableObjectText + tx Text04a0 + tx Text049f + + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04a2 + tx Text04a1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04a4 + tx Text04a3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04a6 + tx Text04a5 + + db NORTH, 20, 14 + dw PrintInteractableObjectText + tx Text04a8 + tx Text04a7 + + db NORTH, 22, 14 + dw PrintInteractableObjectText + tx Text04aa + tx Text04a9 + + db NORTH, 24, 14 + dw PrintInteractableObjectText + tx Text04ac + tx Text04ab + + db NORTH, 2, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +LevelObjects_13b4d: ; 13b4d (3:7b4d) + db NORTH, 2, 2 + dw OWSequence_d932 + tx Text041b + tx Text041a + + db NORTH, 4, 2 + dw OWSequence_d932 + tx Text041b + tx Text041a + + db NORTH, 6, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 8, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 10, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 14, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 16, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 18, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 20, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 14, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 16, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 18, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 20, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 14, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 16, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 18, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 20, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 2, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db NORTH, 4, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db $ff + + +LevelObjects_13c02: ; 13c02 (3:7c02) + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text04ae + tx Text04ad + + db NORTH, 8, 2 + dw PrintInteractableObjectText + tx Text04b0 + tx Text04af + + db NORTH, 10, 2 + dw PrintInteractableObjectText + tx Text04b2 + tx Text04b1 + + db NORTH, 12, 2 + dw PrintInteractableObjectText + tx Text04b4 + tx Text04b3 + + db NORTH, 14, 2 + dw PrintInteractableObjectText + tx Text04b6 + tx Text04b5 + + db NORTH, 16, 2 + dw PrintInteractableObjectText + tx Text04b8 + tx Text04b7 + + db NORTH, 2, 12 + dw PrintInteractableObjectText + tx Text04ba + tx Text04b9 + + db NORTH, 4, 12 + dw PrintInteractableObjectText + tx Text04bc + tx Text04bb + + db NORTH, 6, 12 + dw PrintInteractableObjectText + tx Text04be + tx Text04bd + + db NORTH, 12, 12 + dw PrintInteractableObjectText + tx Text04c0 + tx Text04bf + + db NORTH, 14, 12 + dw PrintInteractableObjectText + tx Text04c2 + tx Text04c1 + + db NORTH, 16, 12 + dw PrintInteractableObjectText + tx Text04c4 + tx Text04c3 + + db $ff + + +LevelObjects_13c6f: ; 13c6f (3:7c6f) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04c6 + tx Text04c5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04c8 + tx Text04c7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ca + tx Text04c9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13ca6: ; 13ca6 (3:7ca6) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04cc + tx Text04cb + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ce + tx Text04cd + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d0 + tx Text04cf + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13cdd: ; 13cdd (3:7cdd) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d2 + tx Text04d1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04d4 + tx Text04d3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d6 + tx Text04d5 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13d14: ; 13d14 (3:7d14) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d8 + tx Text04d7 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04da + tx Text04d9 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04dc + tx Text04db + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13d4b: ; 13d4b (3:7d4b) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04de + tx Text04dd + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e0 + tx Text04df + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e2 + tx Text04e1 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13d82: ; 13d82 (3:7d82) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04e4 + tx Text04e3 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e6 + tx Text04e5 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e8 + tx Text04e7 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13db9: ; 13db9 (3:7db9) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04ea + tx Text04e9 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ec + tx Text04eb + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ee + tx Text04ed + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13df0: ; 13df0 (3:7df0) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f0 + tx Text04ef + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f2 + tx Text04f1 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04f4 + tx Text04f3 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13e27: ; 13e27 (3:7e27) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f6 + tx Text04f5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f8 + tx Text04f7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04fa + tx Text04f9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LevelObjects_13e5e: ; 13e5e (3:7e5e) + db NORTH, 2, 2 + dw PrintInteractableObjectText + tx Text04fc + tx Text04fb + + db NORTH, 4, 2 + dw PrintInteractableObjectText + tx Text04fe + tx Text04fd + + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text0500 + tx Text04ff + + + db NORTH, 2, 8 + dw PrintInteractableObjectText + tx Text0502 + tx Text0501 + + db NORTH, 4, 8 + dw PrintInteractableObjectText + tx Text0504 + tx Text0503 + + db NORTH, 6, 8 + dw PrintInteractableObjectText + tx Text0506 + tx Text0505 + + db NORTH, 18, 0 + dw OWSequence_f631 + tx Text0508 + tx Text0507 + + db NORTH, 20, 0 + dw OWSequence_f631 + tx Text0508 + tx Text0507 + + db NORTH, 22, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 24, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 28, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +LevelObjects_13ec2: ; 13ec2 (3:7ec2) + db NORTH, 10, 10 + dw $7bf1 + dw $0000 + dw $0000 + + db NORTH, 12, 10 + dw $7bf1 + dw $0000 + dw $0000 + + db NORTH, 10, 2 + dw $7be1 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $7be1 + tx Text041b + tx Text041a + + db $ff + + diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index bae46d1..629eb91 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -31,11 +31,11 @@ DeckMachineRoomNPCS: ; 775a (4:1375a) IshiharasHouseNPCS: ; 7773 (4:13773) db NIKKI, $04, $04, NORTH - dw $5add + dw Preload_NikkiInIshiharasHouse db ISHIHARA, $08, $08, SOUTH - dw $5b3d + dw Preload_IshiharaInIshiharasHouse db RONALD1, $02, $04, WEST - dw $5c43 + dw Preload_Ronald1InIshiharasHouse db $00 FightingClubEntranceNPCS: ; 7786 (4:13786) @@ -62,8 +62,8 @@ FightingClubLobbyNPCS: ; 779f (4:1379f) dw $5d98 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 FightingClubNPCS: ; 77ca (4:137ca) @@ -101,8 +101,8 @@ RockClubLobbyNPCS: ; 77fc (4:137fc) dw $5fcb db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 RockClubNPCS: ; 7827 (4:13827) @@ -131,15 +131,15 @@ WaterClubLobbyNPCS: ; 7853 (4:13853) db LASS1, $10, $0a, SOUTH dw $0000 db IMAKUNI, $12, $02, NORTH - dw $60b0 + dw Preload_ImakuniInWaterClubLobby db MAN2, $04, $12, EAST - dw $6130 + dw Preload_Man2InWaterClubLobby db PAPPY2, $16, $10, NORTH dw $0000 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 WaterClubNPCS: ; 787e (4:1387e) @@ -175,8 +175,8 @@ LightningClubLobbyNPCS: ; 78b0 (4:138b0) dw $0000 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 LightningClubNPCS: ; 78d5 (4:138d5) @@ -214,8 +214,8 @@ GrassClubLobbyNPCS: ; 790d (4:1390d) dw $66dc db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 GrassClubNPCS: ; 7932 (4:13932) @@ -253,8 +253,8 @@ PsychicClubLobbyNPCS: ; 7964 (4:13964) dw $0000 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 PsychicClubNPCS: ; 798f (4:1398f) @@ -292,8 +292,8 @@ ScienceClubLobbyNPCS: ; 79c1 (4:139c1) dw $0000 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 ScienceClubNPCS: ; 79ec (4:139ec) @@ -329,8 +329,8 @@ FireClubLobbyNPCS: ; 7a1e (4:13a1e) dw $0000 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 FireClubNPCS: ; 7a43 (4:13a43) @@ -366,8 +366,8 @@ ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) dw $70b4 db CLERK10, $06, $04, SOUTH dw $0000 - db CLERK11, $0a, $04, SOUTH - dw $7c6c + db GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk db $00 ChallengeHallNPCS: ; 7a9a (4:13a9a) @@ -402,17 +402,17 @@ PokemonDomeNPCS: ; 7ac0 (4:13ac0) db $00 HallOfHonorNPCS: ; 7adf (4:13adf) - db _11F1F, $0a, $08, SOUTH + db LEGEND_CARDS_TOP_LEFT, $0a, $08, SOUTH dw $0000 - db _11F26, $0c, $08, SOUTH + db LEGEND_CARDS_TOP_RIGHT, $0c, $08, SOUTH dw $0000 - db _11F2D, $08, $0a, SOUTH + db LEGEND_CARDS_LEFT_SPARK, $08, $0a, SOUTH dw $0000 - db _11F34, $0a, $0a, SOUTH + db LEGEND_CARDS_BOTTOM_LEFT, $0a, $0a, SOUTH dw $0000 - db _11F3B, $0c, $0a, SOUTH + db LEGEND_CARDS_BOTTOM_RIGHT, $0c, $0a, SOUTH dw $0000 - db _11F42, $0e, $0a, SOUTH + db LEGEND_CARDS_RIGHT_SPARK, $0e, $0a, SOUTH dw $0000 db $00 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 4ff42c8..8fb8773 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -61,7 +61,7 @@ NPCDataTable: dw JackData dw RodData dw Clerk10Data - dw Clerk11Data + dw GiftCenterClerkData dw Man1Data dw Woman1Data dw Chap1Data @@ -135,7 +135,7 @@ Ronald1Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to OWScript + dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -147,7 +147,7 @@ Ronald2Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to OWScript + dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -159,7 +159,7 @@ Ronald3Data: db $04 db $0e db $00 - dw $5c4b ; Pointer to OWScript + dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC db $1a @@ -171,7 +171,7 @@ IshiharaData: db $04 db $22 db $00 - dw $5b4a ; Pointer to OWScript + dw OWSequence_Ishihara ; Pointer to OWScript tx Text03ae db $00 db $00 @@ -279,7 +279,7 @@ Clerk1Data: db $0a db $30 db $00 - dw $5c64 ; Pointer to OWScript + dw OWSequence_Clerk1 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -837,8 +837,8 @@ Clerk10Data: db $00 db $00 db $00 -Clerk11Data: - db CLERK11 +GiftCenterClerkData: + db GIFT_CENTER_CLERK db $21 db $0a db $30 @@ -891,7 +891,7 @@ Gal1Data: db $00 db $16 db $00 - dw $60cf ; Pointer to OWScript + dw OWSequence_Gal1 ; Pointer to OWScript tx Text03db db $00 db $00 @@ -903,7 +903,7 @@ Lass1Data: db $00 db $1e db $00 - dw $6111 ; Pointer to OWScript + dw OWSequence_Lass1 ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1071,7 +1071,7 @@ Man2Data: db $00 db $16 db $00 - dw $6137 ; Pointer to OWScript + dw OWSequence_Man2 ; Pointer to OWScript tx Text03d8 db $00 db $00 @@ -1083,7 +1083,7 @@ Pappy2Data: db $00 db $22 db $00 - dw $613b ; Pointer to OWScript + dw OWSequence_Pappy2 ; Pointer to OWScript tx Text03dd db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 02ddc67..b573956 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -94,10 +94,10 @@ Func_c0ce: ; c0ce (3:40ce) jp hl PointerTable_c0e0: ; c0e0 (3:40e0) - dw Func_c0e8 - dw Func_c0ed - dw Func_c0f1 - dw Func_c10a + dw Func_c0e8 ; on map + dw Func_c0ed ; walking around + dw SetOWSequenceData ; beginning ows + dw EnterOWSequence ; mid-ows Func_c0e8: ; c0e8 (3:40e8) farcall Func_10e55 @@ -107,8 +107,8 @@ Func_c0ed: ; c0ed (3:40ed) call Func_c510 ret -Func_c0f1: ; c0f1 (3:40f1) - ld a, [wd3b6] +SetOWSequenceData: ; c0f1 (3:40f1) + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a farcall SetNewOWSequenceNPC ld a, c @@ -117,9 +117,9 @@ Func_c0f1: ; c0f1 (3:40f1) ld [wNextOWSequence+1], a ld a, $3 ld [wd0bf], a - jr Func_c10a + jr EnterOWSequence -Func_c10a: ; c10a (3:410a) +EnterOWSequence: ; c10a (3:410a) ld hl, wNextOWSequence ld a, [hli] ld h, [hl] @@ -134,7 +134,7 @@ CloseAdvancedDialogueBox: ; c111 (3:4111) ld a, [wd0c1] bit 1, a jr z, .asm_c12a - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a farcall Func_1c5e9 .asm_c12a @@ -582,7 +582,7 @@ Func_c4b9: ; c4b9 (3:44b9) ld a, $0 farcall CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] - ld [wd336], a + ld [wPlayerSpriteIndex], a ld b, $2 ld a, [wCurMap] cp OVERWORLD_MAP @@ -592,12 +592,12 @@ Func_c4b9: ; c4b9 (3:44b9) .asm_c4ee ld a, b ld [wPlayerDirection], a - call Func_c5e9 + call UpdatePlayerSprite ld a, [wCurMap] cp OVERWORLD_MAP call nz, Func_c6f7 xor a - ld [wd335], a + ld [wPlayerCurrentlyMoving], a ld [wd338], a ld a, [wCurMap] cp OVERWORLD_MAP @@ -607,41 +607,41 @@ Func_c4b9: ; c4b9 (3:44b9) ret Func_c510: ; c510 (3:4510) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 4, a ret nz bit 0, a call z, Func_c5ac - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] or a jr z, .asm_c535 bit 0, a call nz, Func_c66c - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 1, a call nz, Func_c6dc ret .asm_c535 ldh a, [hKeysPressed] and START - call nz, Func_c74d + call nz, OpenStartMenu ret Func_c53d: ; c53d (3:453d) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 0, a call nz, Func_c687 - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 1, a call nz, Func_c6dc ret Func_c554: ; c554 (3:4554) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wCurMap] cp OVERWORLD_MAP @@ -698,49 +698,50 @@ Func_c58b: ; c58b (3:458b) Func_c5ac: ; c5ac (3:45ac) ldh a, [hKeysHeld] and D_PAD - jr z, .asm_c5bf - call Func_c5cb - call Func_c5fe - ld a, [wd335] + jr z, .skipMoving + call UpdatePlayerDirectionFromDPad + call AttemptPlayerMovementFromDirection + ld a, [wPlayerCurrentlyMoving] and $1 - jr nz, .asm_c5ca -.asm_c5bf + jr nz, .done +.skipMoving ldh a, [hKeysPressed] and A_BUTTON - jr z, .asm_c5ca + jr z, .done call Func_c71e - jr .asm_c5ca -.asm_c5ca + jr .done +.done ret -Func_c5cb: ; c5cb (3:45cb) - call Func_c5d5 -Func_c5ce: ; c5ce (3:45ce) +UpdatePlayerDirectionFromDPad: ; c5cb (3:45cb) + call GetDirectionFromDPad +UpdatePlayerDirection: ; c5ce (3:45ce) ld [wPlayerDirection], a - call Func_c5e9 + call UpdatePlayerSprite ret -Func_c5d5: ; c5d5 (3:45d5) +GetDirectionFromDPad: ; c5d5 (3:45d5) push hl - ld hl, Unknown_c5e5 + ld hl, KeypadDirectionMap or a - jr z, .asm_c5e2 -.asm_c5dc + jr z, .loadDirectionMapping +.findDirectionMappingLoop rlca - jr c, .asm_c5e2 + jr c, .loadDirectionMapping inc hl - jr .asm_c5dc -.asm_c5e2 + jr .findDirectionMappingLoop +.loadDirectionMapping ld a, [hl] pop hl ret -Unknown_c5e5: ; c5e5 (3:45e5) - db $02,$00,$03,$01 +KeypadDirectionMap: ; c5e5 (3:45e5) + db SOUTH, NORTH, WEST, EAST -Func_c5e9: ; c5e9 (3:45e9) +; Updates sprite depending on direction +UpdatePlayerSprite: ; c5e9 (3:45e9) push bc - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd337] ld b, a @@ -750,25 +751,25 @@ Func_c5e9: ; c5e9 (3:45e9) pop bc ret -Func_c5fe: ; c5fe (3:45fe) +AttemptPlayerMovementFromDirection: ; c5fe (3:45fe) push bc - call Func_c653 - call AttemptScriptedMovement + call FindPlayerMovementFromDirection + call AttemptPlayerMovement pop bc ret StartScriptedMovement: ; c607 (3:4607) push bc - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd339] - call FindScriptedMovementWithOffset - call AttemptScriptedMovement + call FindPlayerMovementWithOffset + call AttemptPlayerMovement pop bc ret ; bc is the location the player is being scripted to move towards. -AttemptScriptedMovement: ; c619 (3:4619) +AttemptPlayerMovement: ; c619 (3:4619) push hl push bc ld a, b @@ -784,9 +785,9 @@ AttemptScriptedMovement: ; c619 (3:4619) ld [wPlayerXCoord], a ld a, c ld [wPlayerYCoord], a - ld a, [wd335] ; I believe everything starting here is animation related. + ld a, [wPlayerCurrentlyMoving] ; I believe everything starting here is animation related. or $1 - ld [wd335], a + ld [wPlayerCurrentlyMoving], a ld a, $10 ld [wd338], a ld c, SPRITE_ANIM_FIELD_0F @@ -801,15 +802,15 @@ AttemptScriptedMovement: ; c619 (3:4619) pop hl ret -Func_c653: ; c653 (3:4653) +FindPlayerMovementFromDirection: ; c653 (3:4653) ld a, [wPlayerDirection] -FindScriptedMovementWithOffset: ; c656 (3:4656) +FindPlayerMovementWithOffset: ; c656 (3:4656) rlca ld c, a ld b, $0 push hl - ld hl, ScriptedMovementOffsetTable + ld hl, PlayerMovementOffsetTable add hl, bc ld a, [wPlayerXCoord] add [hl] @@ -877,7 +878,7 @@ Func_c694: ; c694 (3:4694) ld a, [wd338] or a jr nz, .asm_c6c3 - ld hl, wd335 + ld hl, wPlayerCurrentlyMoving set 1, [hl] .asm_c6c3 call Func_c41c @@ -904,7 +905,7 @@ Func_c6d4: ; c6d4 (3:46d4) Func_c6dc: ; c6dc (3:46dc) push hl - ld hl, wd335 + ld hl, wPlayerCurrentlyMoving res 0, [hl] res 1, [hl] call Func_c6f7 @@ -917,7 +918,7 @@ Func_c6dc: ; c6dc (3:46dc) ret Func_c6f7: ; c6f7 (3:46f7) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld c, SPRITE_ANIM_FIELD_0F call GetSpriteAnimBufferProperty @@ -940,20 +941,22 @@ Func_c70d: ; c70d (3:470d) pop hl ret +; Arrives here if A button is pressed when not moving + in map move state Func_c71e: ; c71e (3:471e) ld a, $ff - ld [wd3b6], a - call Func_c653 + ld [wScriptNPC], a + call FindPlayerMovementFromDirection call GetPermissionOfMapPosition and $40 - jr z, .asm_c73d - farcall Func_1c72e - jr c, .asm_c73d + jr z, .noNPC + farcall FindNPCAtLocation + jr c, .noNPC ld a, [wLoadedNPCTempIndex] - ld [wd3b6], a - ld a, $2 + ld [wScriptNPC], a + ld a, $2 ; start OWScript jr .asm_c748 -.asm_c73d + +.noNPC call Func_3a5e jr nc, .asm_c746 ld a, $3 @@ -966,7 +969,7 @@ Func_c71e: ; c71e (3:471e) scf ret -Func_c74d: ; c74d (3:474d) +OpenStartMenu: ; c74d (3:474d) push hl push bc push de @@ -1061,7 +1064,7 @@ PC_c7ea: ; c7ea (3:47ea) ld a, MUSIC_PC_MAIN_MENU call PlaySong call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled ldtx hl, TurnedPCOnText call PrintScrollableText_NoTextBoxLabel @@ -1120,7 +1123,7 @@ Func_c891: ; c891 (3:4891) ld a, $1 call Func_c29b call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled call PrintScrollableText_NoTextBoxLabel ret @@ -1153,20 +1156,20 @@ Func_c8ba: ; c8ba (3:48ba) ld a, $1 call Func_c29b call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled call $2c62 ret ; 0xc8ed -Func_c8ed: ; c8ed (3:c8ed) +Func_c8ed: ; c8ed (3:48ed) push hl push bc push de push hl ld a, $1 call Func_c29b - call $4915 + call Func_c915 call DoFrameIfLCDEnabled pop hl ld a, l @@ -1205,7 +1208,7 @@ SetNextNPCAndOWSequence: ; c926 (3:4926) push bc call FindLoadedNPC ld a, [wLoadedNPCTempIndex] - ld [wd3b6], a + ld [wScriptNPC], a farcall SetNewOWSequenceNPC pop bc ; fallthrough @@ -1323,35 +1326,41 @@ Func_c9cb: ; c9cb (3:49cb) pop hl ret +; Clears temporary flags before determining Imakuni Room Func_c9dd: ; c9dd (3:49dd) xor a - ld [wd411], a - call Func_c9e8 + ld [wEventFlags + EVENT_FLAG_BYTES - 1], a + call DetermineImakuniRoom call Func_ca0e ret -Func_c9e8: ; c9e8 (3:49e8) +; Determines what room Imakuni is in when you reset +; Skips current room and does not occur if you haven't talked to Imakuni +DetermineImakuniRoom: ; c9e8 (3:49e8) ld c, $0 - get_flag_value EVENT_FLAG_13 - cp $2 - jr c, .asm_ca04 -.asm_c9f2 + get_flag_value EVENT_IMAKUNI_STATE + cp IMAKUNI_TALKED + jr c, .finish +.tryLoadImakuniLoop call UpdateRNGSources and $3 ld c, a ld b, $0 - ld hl, Unknown_ca0a + ld hl, ImakuniPossibleRooms add hl, bc ld a, [wTempMap] cp [hl] - jr z, .asm_c9f2 -.asm_ca04 + jr z, .tryLoadImakuniLoop +.finish ld a, c - set_flag_value EVENT_FLAG_34 + set_flag_value EVENT_IMAKUNI_ROOM ret -Unknown_ca0a: ; ca0a (3:4a04) - INCROM $ca0a, $ca0e +ImakuniPossibleRooms: ; ca0a (3:4a04) + db FIGHTING_CLUB_LOBBY + db SCIENCE_CLUB_LOBBY + db LIGHTNING_CLUB_LOBBY + db WATER_CLUB_LOBBY Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] @@ -1499,52 +1508,60 @@ ZeroOutEventFlag: ; cad0 (3:4ad0) pop bc ret -Func_cad8: ; cad8 (3:4ad8) +TryGiveMedalPCPacks: ; cad8 (3:4ad8) push hl push bc - ld hl, $4b15 + ld hl, MedalEventFlags ld bc, $0008 -.asm_cae0 +.countMedalsLoop ld a, [hli] call GetEventFlagValue - jr z, .asm_cae7 + jr z, .noMedal inc b - -.asm_cae7 +.noMedal dec c - jr nz, .asm_cae0 + jr nz, .countMedalsLoop + ld c, b - set_flag_value EVENT_FLAG_2E + set_flag_value EVENT_MEDAL_COUNT ld a, c push af cp $8 - jr nc, .asm_caff + jr nc, .givePacksForEightMedals cp $7 - jr nc, .asm_cb05 + jr nc, .givePacksForSevenMedals cp $3 - jr nc, .asm_cb0b - jr .asm_cb11 + jr nc, .givePacksForTwoMedals + jr .finish -.asm_caff +.givePacksForEightMedals ld a, $c - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb05 +.givePacksForSevenMedals ld a, $b - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb0b +.givePacksForTwoMedals ld a, $a - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb11 +.finish pop af pop bc pop hl ret ; 0xcb15 - INCROM $cb15, $cb1d +MedalEventFlags: ; cb15 (3:4b15) + db EVENT_FLAG_08 + db EVENT_FLAG_09 + db EVENT_FLAG_0A + db EVENT_BEAT_AMY + db EVENT_FLAG_0C + db EVENT_FLAG_0D + db EVENT_FLAG_0E + db EVENT_FLAG_0F ; returns wEventFlags byte in hl, related bits in wLoadedFlagBits GetEventFlag: ; cb1d (3:4b1d) @@ -1567,10 +1584,10 @@ GetEventFlag: ; cb1d (3:4b1d) ; offset - bytes to set or reset EventFlagMods: ; cb37 (3:4b37) - flag_def $3f, %10000000 ; EVENT_FLAG_00 + flag_def $3f, %10000000 ; EVENT_FLAG_00 ; 0-7 are reset when game resets flag_def $3f, %01000000 ; EVENT_FLAG_01 - flag_def $3f, %00100000 ; EVENT_FLAG_02 - flag_def $3f, %00010000 ; EVENT_FLAG_03 + flag_def $3f, %00100000 ; EVENT_TEMP_TALKED_TO_IMAKUNI + flag_def $3f, %00010000 ; EVENT_TEMP_BATTLED_IMAKUNI flag_def $3f, %00001000 ; EVENT_FLAG_04 flag_def $3f, %00000100 ; EVENT_FLAG_05 flag_def $3f, %00000010 ; EVENT_FLAG_06 @@ -1586,7 +1603,7 @@ EventFlagMods: ; cb37 (3:4b37) flag_def $00, %11111111 ; EVENT_FLAG_10 flag_def $01, %11110000 ; EVENT_FLAG_11 flag_def $01, %00001111 ; EVENT_FLAG_12 - flag_def $02, %11000000 ; EVENT_FLAG_13 + flag_def $02, %11000000 ; EVENT_IMAKUNI_STATE flag_def $02, %00110000 ; EVENT_FLAG_14 flag_def $02, %00001000 ; EVENT_BEAT_SARA flag_def $02, %00000100 ; EVENT_BEAT_AMANDA @@ -1613,15 +1630,15 @@ EventFlagMods: ; cb37 (3:4b37) flag_def $08, %11111111 ; EVENT_FLAG_2B flag_def $09, %11100000 ; EVENT_FLAG_2C flag_def $09, %00011111 ; EVENT_FLAG_2D - flag_def $0a, %11110000 ; EVENT_FLAG_2E + flag_def $0a, %11110000 ; EVENT_MEDAL_COUNT flag_def $0a, %00001000 ; EVENT_FLAG_2F flag_def $0a, %00000100 ; EVENT_FLAG_30 flag_def $0a, %00000011 ; EVENT_FLAG_31 flag_def $0b, %10000000 ; EVENT_FLAG_32 flag_def $0b, %01110000 ; EVENT_JOSHUA_STATE - flag_def $0b, %00001100 ; EVENT_FLAG_34 + flag_def $0b, %00001100 ; EVENT_IMAKUNI_ROOM flag_def $0b, %00000011 ; EVENT_FLAG_35 - flag_def $0c, %11100000 ; EVENT_FLAG_36 + flag_def $0c, %11100000 ; EVENT_IMAKUNI_WIN_COUNT flag_def $0c, %00011100 ; EVENT_FLAG_37 flag_def $0c, %00000010 ; EVENT_FLAG_38 flag_def $0c, %00000001 ; EVENT_FLAG_39 @@ -1687,7 +1704,8 @@ EventFlagMods: ; cb37 (3:4b37) flag_def $1c, %11110000 ; EVENT_FLAG_75 flag_def $1c, %00001111 ; EVENT_FLAG_76 -Func_cc25: ; cc25 (3:4c25) +; Used for basic level objects that just print text and quit +PrintInteractableObjectText: ; cc25 (3:4c25) ld hl, wd0ca ld a, [hli] ld h, [hl] @@ -1705,12 +1723,14 @@ Func_cc32: ; cc32 (3:4c32) pop hl call Func_c8ba ret -; 0xcc3e - INCROM $cc3e, $cc42 +Func_cc3e: ; cc3e (3:4c3e) + call CloseAdvancedDialogueBox + ret -; called when pressing a in front of an object. creates a pointer to the data right after an RST20 -; was called, then runs RunOverworldScript to handle that data +; Enters into the script loop, continuing until wBreakOWScriptLoop > 0 +; When the loop is broken, it resumes normal code execution where script ended +; Note: Some scripts "double return" and skip this. RST20: ; cc42 (3:4c42) pop hl ld a, l @@ -1728,8 +1748,7 @@ RST20: ; cc42 (3:4c42) ld a, [hli] ld c, a ld b, [hl] - push bc - ret + retbc IncreaseOWScriptPointerBy1: ; cc60 (3:4c60) ld a, 1 @@ -1871,7 +1890,7 @@ OWScript_AskQuestionJump: ; cce9 (3:4ce9) ; sets a battle up, doesn't start until we break out of the script system. OWScript_StartBattle: ; cd01 (3:4d01) call Func_cd66 - ld a, [wd3b6] + ld a, [wScriptNPC] ld l, LOADED_NPC_ID call GetItemInLoadedNPCIndex ld a, [hl] @@ -1887,7 +1906,7 @@ OWScript_StartBattle: ; cd01 (3:4d01) ld a, [hl] ld [wcc19], a .asm_cd26 - ld a, [wd3b6] + ld a, [wScriptNPC] ld l, LOADED_NPC_ID call GetItemInLoadedNPCIndex ld a, [hl] @@ -1970,7 +1989,8 @@ Func_cda8: ; cda8 (3:4da8) call Func_c891 jp IncreaseOWScriptPointerBy5 -OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) +; Does not return to RST20 - pops an extra time to skip that. +OWScript_PrintTextQuitFully: ; cdb9 (3:4db9) ld l, c ld h, b call Func_cc32 @@ -1982,7 +2002,7 @@ OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) ret Func_cdcb: ; cdcb (3:4dcb) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a Func_cdd1: ; cdd1 (3:4dd1) farcall Func_1c50a @@ -2026,7 +2046,7 @@ Func_cdf5: ; cdf5 (3:4df5) jp IncreaseOWScriptPointerBy3 Func_ce26: ; ce26 (3:4e26) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a farcall Func_1c455 rlca @@ -2048,7 +2068,7 @@ Func_ce3a: ; ce3a (3:4e3a) jp IncreaseOWScriptPointerBy3 Func_ce4a: ; ce4a (3:4e4a) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a jr Func_ce3a @@ -2304,7 +2324,7 @@ Func_cfc0: ; cfc0 (3:4fc0) jp SetOWScriptPointer Func_cfc6: ; cfc6 (3:4fc6) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a ld a, c farcall Func_1c52e @@ -2384,16 +2404,16 @@ OWScript_Jump: ; d049 (3:5049) call GetOWSArgs1AfterPointer jp SetOWScriptPointer -Func_d04f: ; d04f (3:504f) - call Func_cad8 +OWScript_TryGiveMedalPCPacks: ; d04f (3:504f) + call TryGiveMedalPCPacks jp IncreaseOWScriptPointerBy1 OWScript_SetPlayerDirection: ; d055 (3:5055) ld a, c - call Func_c5ce + call UpdatePlayerDirection jp IncreaseOWScriptPointerBy2 -; arg1 - Direction (index in ScriptedMovementOffsetTable) +; arg1 - Direction (index in PlayerMovementOffsetTable) ; arg2 - Tiles Moves (Speed) OWScript_MovePlayer: ; 505c (3:505c) ld a, c @@ -2405,7 +2425,7 @@ OWScript_MovePlayer: ; 505c (3:505c) call DoFrameIfLCDEnabled call SetScreenScroll call Func_c53d - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] and $03 jr nz, .asm_d067 call DoFrameIfLCDEnabled @@ -2425,11 +2445,11 @@ OWScript_SetNextNPCandOWSequence: ; d088 (3:5088) jp IncreaseOWScriptPointerBy4 Func_d095: ; d095 (3:5095) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a push bc call GetOWSArgs3AfterPointer - ld a, [wd3b6] + ld a, [wScriptNPC] ld l, LOADED_NPC_FIELD_05 call GetItemInLoadedNPCIndex res 4, [hl] @@ -2449,7 +2469,7 @@ Func_d095: ; d095 (3:5095) jp IncreaseOWScriptPointerBy4 Func_d0be: ; d0be (3:50be) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a ld a, c ld c, b @@ -2466,7 +2486,7 @@ OWScript_DoFrames: ; d0ce (3:50ce) jp IncreaseOWScriptPointerBy2 Func_d0d9: ; d0d9 (3:50d9) - ld a, [wd3b6] + ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a ld d, c ld e, b @@ -2767,7 +2787,7 @@ Func_d317: ; d317 (3:5317) set_flag_value EVENT_FLAG_75 jp IncreaseOWScriptPointerBy1 - +Unknown_d32b: ; d32b (3:532b) INCROM $d32b, $d336 OWScript_OpenDeckMachine: ; d336 (3:5336) @@ -2851,9 +2871,9 @@ Func_d3b9: ; d3b9 (3:53b9) set 6, [hl] jp IncreaseOWScriptPointerBy1 -OWScript_GivePCPack: ; d3c9 (3:53c9) +OWScript_TryGivePCPack: ; d3c9 (3:53c9) ld a, c - farcall GivePCPack + farcall TryGivePCPack jp IncreaseOWScriptPointerBy2 OWScript_nop: ; d3d1 (3:53d1) @@ -2892,10 +2912,10 @@ Func_d408: ; d408 (3:5408) Func_d40f: ; d40f (3:540f) ld a, c - call Func_3c83 + call CallPlaySong jp IncreaseOWScriptPointerBy2 -Func_d416: ; d416 (3:5416) +OWScript_PlaySFX: ; d416 (3:5416) ld a, c call PlaySFX jp IncreaseOWScriptPointerBy2 @@ -2904,16 +2924,16 @@ Func_d41d: ; d41d (3:541d) call Func_39fc jp IncreaseOWScriptPointerBy1 -Func_d423: ; d423 (3:5423) +OWScript_PauseSong: ; d423 (3:5423) call PauseSong jp IncreaseOWScriptPointerBy1 -Func_d429: ; d429 (3:5429) +OWScript_ResumeSong: ; d429 (3:5429) call ResumeSong jp IncreaseOWScriptPointerBy1 -Func_d42f: ; d42f (3:542f) - call Func_3c96 +OWScript_WaitForSongToFinish: ; d42f (3:542f) + call WaitForSongToFinish jp IncreaseOWScriptPointerBy1 Func_d435: ; d435 (3:5435) @@ -3322,7 +3342,312 @@ OWSequence_d827: ; d827 (3:5827) run_script OWScript_QuitScriptFully ; 0xd82d - INCROM $d82d, $dc68 + INCROM $d82d, $d932 + +OWSequence_d932: ; d932 (3:5932) + start_script + run_script Func_ccdc + tx Text0605 + run_script OWScript_AskQuestionJumpDefaultYes + tx Text0606 + dw .ows_d93c + run_script OWScript_QuitScriptFully + +.ows_d93c + run_script OWScript_OpenDeckMachine + db $09 + run_script OWScript_QuitScriptFully +; 0xd93f + + INCROM $d93f, $dadd + +Preload_NikkiInIshiharasHouse: ; dadd (3:5add) + get_flag_value EVENT_FLAG_35 + cp $01 + jr nz, .dontLoadNikki + scf + ret +.dontLoadNikki + or a + ret +; 0xdae9 + + INCROM $dae9, $db3d + +Preload_IshiharaInIshiharasHouse: ; db3d (3:5b3d) + get_flag_value EVENT_FLAG_1C + or a + ret z + get_flag_value EVENT_FLAG_1F + cp $08 + ret + +OWSequence_Ishihara: ; db4a (3:5b4a) + start_script + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_1D + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $00 + dw .ows_db80 + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_39 + dw .ows_db5a + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_22 + dw .ows_dc3e +.ows_db5a + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_00 + dw .ows_db90 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_38 + dw .ows_db90 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $01 + dw .ows_db93 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $02 + dw .ows_db93 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $03 + dw .ows_dbcc + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $04 + dw .ows_dbcc + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $05 + dw .ows_dc05 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $06 + dw .ows_dc05 +.ows_db80 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_00 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $01 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_38 + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_22 + dw .ows_db8d + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_39 +.ows_db8d + run_script OWScript_PrintTextQuitFully + tx Text0727 + +.ows_db90 + run_script OWScript_PrintTextQuitFully + tx Text0728 + +.ows_db93 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0729 + tx Text072a + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $02 + run_script OWScript_AskQuestionJump + tx Text072b + dw .ows_dba8 + run_script OWScript_PrintTextQuitFully + tx Text072c + +.ows_dba8 + run_script Func_cf0c + db $ac + dw .ows_dbaf + run_script OWScript_PrintTextQuitFully + tx Text072d + +.ows_dbaf + run_script Func_cf12 + db $ac + dw .ows_dbb6 + run_script OWScript_PrintTextQuitFully + tx Text072e + +.ows_dbb6 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_00 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $03 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_38 + run_script OWScript_PrintTextString + tx Text072f + run_script Func_ccdc + tx Text0730 + run_script OWScript_TakeCard + db CLEFABLE + run_script OWScript_GiveCard + db SURFING_PIKACHU1 + run_script OWScript_ShowCardReceivedScreen + db SURFING_PIKACHU1 + run_script OWScript_PrintTextQuitFully + tx Text0731 + +.ows_dbcc + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $03 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0732 + tx Text0733 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $04 + run_script OWScript_AskQuestionJump + tx Text072b + dw .ows_dbe1 + run_script OWScript_PrintTextQuitFully + tx Text072c + +.ows_dbe1 + run_script Func_cf0c + db $bb + dw .ows_dbe8 + run_script OWScript_PrintTextQuitFully + tx Text0734 + +.ows_dbe8 + run_script Func_cf12 + db $bb + dw .ows_dbef + run_script OWScript_PrintTextQuitFully + tx Text0735 + +.ows_dbef + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_00 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $05 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_38 + run_script OWScript_PrintTextString + tx Text072f + run_script Func_ccdc + tx Text0736 + run_script OWScript_TakeCard + db DITTO + run_script OWScript_GiveCard + db FLYING_PIKACHU + run_script OWScript_ShowCardReceivedScreen + db FLYING_PIKACHU + run_script OWScript_PrintTextQuitFully + tx Text0737 + +.ows_dc05 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_1F + db $05 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0738 + tx Text0739 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $06 + run_script OWScript_AskQuestionJump + tx Text072b + dw .ows_dc1a + run_script OWScript_PrintTextQuitFully + tx Text072c + +.ows_dc1a + run_script Func_cf0c + db $b8 + dw .ows_dc21 + run_script OWScript_PrintTextQuitFully + tx Text073a + +.ows_dc21 + run_script Func_cf12 + db $b8 + dw .ows_dc28 + run_script OWScript_PrintTextQuitFully + tx Text073b + +.ows_dc28 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_00 + run_script OWScript_SetFlagValue + db EVENT_FLAG_1F + db $07 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_38 + run_script OWScript_PrintTextString + tx Text072f + run_script Func_ccdc + tx Text073c + run_script OWScript_TakeCard + db CHANSEY + run_script OWScript_GiveCard + db SURFING_PIKACHU2 + run_script OWScript_ShowCardReceivedScreen + db SURFING_PIKACHU2 + run_script OWScript_PrintTextQuitFully + tx Text073d + +.ows_dc3e + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_39 + run_script OWScript_PrintTextQuitFully + tx Text073e + +Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) + get_flag_value EVENT_FLAG_22 + cp $01 + ccf + ret + +OWSequence_Ronald: ; dc4b (3:5c4b) + start_script + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_4E + dw .ows_dc55 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_4E + run_script OWScript_PrintTextQuitFully + tx Text073f + +.ows_dc55 + run_script OWScript_PrintTextString + tx Text0740 + run_script OWScript_AskQuestionJump + tx Text0741 + dw .ows_dc60 + run_script OWScript_PrintTextQuitFully + tx Text0742 + +.ows_dc60 + run_script OWScript_PrintTextQuitFully + tx Text0743 +; 0xdc63 + + ; could be a commented function, or could be placed by mistake from + ; someone thinking that the Ronald script ended with more code execution + ret + +OWSequence_Clerk1: ; dc64 (3:5c64) + start_script + run_script OWScript_PrintTextQuitFully + tx Text045a FightingClubLobbyAfterDuel: ; dc68 (3:5c68) ld hl, .after_duel_table @@ -3340,16 +3665,16 @@ FightingClubLobbyAfterDuel: ; dc68 (3:5c68) OWSequence_Imakuni: ; dd0d (3:5d0d) start_script run_script OWScript_SetFlagValue - db EVENT_FLAG_13 - db $02 + db EVENT_IMAKUNI_STATE + db IMAKUNI_TALKED run_script OWScript_JumpIfFlagZero2 - db EVENT_FLAG_02 + db EVENT_TEMP_TALKED_TO_IMAKUNI dw NO_JUMP run_script OWScript_PrintVariableText tx Text0467 tx Text0468 run_script OWScript_MaxOutFlagValue - db EVENT_FLAG_02 + db EVENT_TEMP_TALKED_TO_IMAKUNI run_script OWScript_AskQuestionJump tx Text0469 dw .declineDuel @@ -3370,43 +3695,43 @@ OWSequence_Imakuni: ; dd0d (3:5d0d) OWSequence_BeatImakuni: ; dd2d (3:5d2d) start_script run_script OWScript_JumpIfFlagEqual - db EVENT_FLAG_36 + db EVENT_IMAKUNI_WIN_COUNT db $07 - dw .ows_dd3f + dw .giveBoosters run_script OWScript_IncrementFlagValue - db EVENT_FLAG_36 + db EVENT_IMAKUNI_WIN_COUNT run_script OWScript_JumpIfFlagEqual - db EVENT_FLAG_36 + db EVENT_IMAKUNI_WIN_COUNT db $03 - dw .ows_dd46 + dw .threeWins run_script OWScript_JumpIfFlagEqual - db EVENT_FLAG_36 + db EVENT_IMAKUNI_WIN_COUNT db $06 - dw .ows_dd4c -.ows_dd3f + dw .sixWins +.giveBoosters run_script OWScript_PrintTextString tx Text046c run_script OWScript_GiveOneOfEachTrainerBooster run_script OWScript_Jump - dw .ows_dd56 + dw .done -.ows_dd46 +.threeWins run_script OWScript_PrintTextString tx Text046d run_script OWScript_Jump - dw .ows_dd4f + dw .giveImakuniCard -.ows_dd4c +.sixWins run_script OWScript_PrintTextString tx Text046e -.ows_dd4f +.giveImakuniCard run_script OWScript_PrintTextString tx Text046f run_script OWScript_GiveCard db IMAKUNI_CARD run_script OWScript_ShowCardReceivedScreen db IMAKUNI_CARD -.ows_dd56 +.done run_script OWScript_PrintTextString tx Text0470 run_script OWScript_Jump @@ -3439,14 +3764,140 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60) db $5d run_script Func_cdcb run_script OWScript_MaxOutFlagValue - db EVENT_FLAG_03 + db EVENT_TEMP_BATTLED_IMAKUNI run_script Func_d408 db $09 run_script Func_d41d run_script OWScript_QuitScriptFully ; 0xdd78 - INCROM $dd78, $e13f + INCROM $dd78, $e0b0 + +Preload_ImakuniInWaterClubLobby: ; e0b0 (3:60b0) + get_flag_value EVENT_IMAKUNI_STATE + cp IMAKUNI_TALKED + jr c, .asm_e0c6 + get_flag_value EVENT_TEMP_BATTLED_IMAKUNI + jr nz, .asm_e0c6 + get_flag_value EVENT_IMAKUNI_ROOM + cp IMAKUNI_WATER_CLUB + jr z, .asm_e0c8 +.asm_e0c6 + or a + ret +.asm_e0c8 + ld a, $10 + ld [wd111], a + scf + ret +; 0xe0cf + +OWSequence_Gal1: ; e0cf (3:60cf) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_12 + db $02 + dw .ows_e10e + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_12 + db $00 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text041d + tx Text041e + run_script OWScript_SetFlagValue + db EVENT_FLAG_12 + db $01 + run_script OWScript_AskQuestionJump + tx Text041f + dw .ows_e0eb + run_script OWScript_PrintTextString + tx Text0420 + run_script OWScript_QuitScriptFully + +.ows_e0eb + run_script Func_cf0c + db $59 + dw .ows_e0f3 + run_script OWScript_PrintTextString + tx Text0421 + run_script OWScript_QuitScriptFully + +.ows_e0f3 + run_script Func_cf12 + db $59 + dw .ows_e0fb + run_script OWScript_PrintTextString + tx Text0422 + run_script OWScript_QuitScriptFully + +.ows_e0fb + run_script OWScript_SetFlagValue + db EVENT_FLAG_12 + db $02 + run_script OWScript_PrintTextString + tx Text0423 + run_script Func_ccdc + tx Text0424 + run_script OWScript_TakeCard + db LAPRAS + run_script OWScript_GiveCard + db ARCANINE1 + run_script OWScript_ShowCardReceivedScreen + db ARCANINE1 + run_script OWScript_PrintTextString + tx Text0425 + run_script OWScript_QuitScriptFully + +.ows_e10e + run_script OWScript_PrintTextQuitFully + tx Text0426 + +OWSequence_Lass1: ; e111 (3:6111) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_14 + db $01 + dw .ows_e121 + run_script OWScript_PrintTextString + tx Text0427 + run_script OWScript_SetFlagValue + db EVENT_FLAG_14 + db $01 + run_script OWScript_SetFlagValue + db EVENT_IMAKUNI_STATE + db IMAKUNI_MENTIONED + run_script OWScript_QuitScriptFully + +.ows_e121 + run_script OWScript_JumpIfFlagNotEqual + db EVENT_IMAKUNI_ROOM + db IMAKUNI_WATER_CLUB + dw .ows_e12d + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_TEMP_BATTLED_IMAKUNI + dw .ows_e12d + run_script OWScript_PrintTextQuitFully + tx Text0428 + +.ows_e12d + run_script OWScript_PrintTextQuitFully + tx Text0429 + +Preload_Man2InWaterClubLobby: ; e130 (3:6130) + get_flag_value EVENT_JOSHUA_STATE + cp JOSHUA_BEATEN + ret + +OWSequence_Man2: ; e137 (3:6137) + start_script + run_script OWScript_PrintTextQuitFully + tx Text042a + +OWSequence_Pappy2: ; e13b (3:613b) + start_script + run_script OWScript_PrintTextQuitFully + tx Text042b WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] @@ -3522,7 +3973,7 @@ OWSequence_BeatSara: ; e18c (3:618c) OWSequence_LostToSara: ; e19a (03:619a) start_script - run_script OWScript_PrintTextCloseBox + run_script OWScript_PrintTextQuitFully tx Text0432 OWSequence_Amanda: ; e19e (03:619e) @@ -3560,7 +4011,7 @@ OWSequence_BeatAmanda: ; e1b3 (03:61b3) OWSequence_LostToAmanda: ; e1c1 (03:61c1) start_script - run_script OWScript_PrintTextCloseBox + run_script OWScript_PrintTextQuitFully tx Text0439 OWSequence_NotReadyToSeeAmy: ; e15c (03:6153) @@ -3674,7 +4125,7 @@ OWSequence_Joshua: .startDuel: run_script OWScript_PrintTextString tx Text0442 - run_script OWScript_GivePCPack + run_script OWScript_TryGivePCPack db $04 run_script OWScript_StartBattle db PRIZES_4 @@ -3782,8 +4233,7 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) db $01 run_script Func_ce6f db $21 - db $ab - db $62 + dw $62ab run_script OWScript_PrintTextString tx Text044e run_script OWScript_Jump @@ -3830,7 +4280,7 @@ OWSequence_BeatAmy: ; e322 (3:6322) tx Text0454 run_script OWScript_MaxOutFlagValue db EVENT_BEAT_AMY - run_script Func_d04f + run_script OWScript_TryGiveMedalPCPacks run_script Func_d125 db EVENT_BEAT_AMY run_script Func_d435 @@ -4022,7 +4472,7 @@ OWSequence_BeatBrittany: ; e5ee (3:65ee) OWSequence_LostToBrittany: ; e618 (3:6618) start_script - run_script OWScript_PrintTextCloseBox + run_script OWScript_PrintTextQuitFully tx Text06e9 ; 0xe61c @@ -4317,7 +4767,22 @@ Func_f580: ; f580 (3:7580) INCROM $f5b3, $f602 Func_f602: ; f602 (3:7602) - INCROM $f602, $fc2b + INCROM $f602, $f631 + +OWSequence_f631: ; f631 (3:7631) + start_script + run_script OWScript_PrintTextString + tx Text0508 + run_script OWScript_CloseAdvancedTextBox + run_script OWScript_SetNextNPCandOWSequence + db $02 + dw $763c + run_script OWScript_EndScriptLoop1 + + ret +; 0xf63c + + INCROM $f63c, $fc2b Func_fc2b: ; fc2b (3:7c2b) ld a, [wDuelResult] @@ -4344,7 +4809,19 @@ PointerTable_fc4c: ; fc4c (3:7c4c) dw Unknown_fc68 dw Unknown_fc60 - INCROM $fc52, $fc60 +OWSequence_fc52: ; fc52 (3:7c52) + start_script + run_script OWScript_PrintTextString + tx Text06c8 + run_script OWScript_AskQuestionJumpDefaultYes + dw $0000 + dw .ows_fc5e + run_script OWScript_PrintTextQuitFully + tx Text06c9 + +.ows_fc5e + run_script Func_cd76 + run_script OWScript_QuitScriptFully Unknown_fc60: ; fc60 (3:7c60) INCROM $fc60, $fc64 @@ -4353,7 +4830,117 @@ Unknown_fc64: ; fc64 (3:7c64) INCROM $fc64, $fc68 Unknown_fc68: ; fc68 (3:7c68) - INCROM $fc68, $fcad + INCROM $fc68, $fc6c + +; Clerk looks away from you if you can't use infrared +; This is one of the preloads that does not change whether or not they appear +Preload_GiftCenterClerk: ; fc6c (3:7c6c) + ld a, [wConsole] + cp CONSOLE_CGB + jr z, .notCGB + ld a, NORTH + ld [wLoadNPCDirection], a +.notCGB + scf + ret + +Func_fc7a: ; fc7a (3:7c7a) + ld a, [wConsole] + ld c, a + set_flag_value EVENT_FLAG_74 + + start_script + run_script OWScript_JumpIfFlagNotEqual + db EVENT_FLAG_74 + db $02 + dw Func_fcad.ows_fcd5 + run_script OWScript_PrintTextString + tx Text06cd + run_script Func_d39d + db $00 + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_72 + db $04 + dw Func_fc7a.ows_fcaa + run_script OWScript_PrintTextString + tx Text06ce + run_script OWScript_AskQuestionJumpDefaultYes + tx Text06cf + dw .ows_fca0 + run_script OWScript_PrintTextString + tx Text06d0 + run_script OWScript_Jump + dw Func_fc7a.ows_fcaa + +.ows_fca0 + run_script Func_d396 + db $00 + run_script OWScript_PlaySFX + db $56 + run_script Func_ccdc + tx Text06d1 + run_script Func_d39d + db $01 + run_script OWScript_QuitScriptFully + +.ows_fcaa + run_script OWScript_PrintTextQuitFully + tx Text06d2 Func_fcad: ; fcad (3:7cad) - INCROM $fcad, $10000 + ld a, [wd10e] + ld c, a + set_flag_value EVENT_FLAG_72 + + start_script + run_script OWScript_PlaySFX + db $56 + run_script Func_d396 + db $00 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_72 + db $00 + dw .ows_fccc + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_72 + db $02 + dw .ows_fccf + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_72 + db $03 + dw .ows_fcd2 + run_script OWScript_Jump + dw Func_fc7a.ows_fcaa + +.ows_fccc + run_script OWScript_PrintTextQuitFully + tx Text06d3 + +.ows_fccf + run_script OWScript_PrintTextQuitFully + tx Text06d4 + +.ows_fcd2 + run_script OWScript_PrintTextQuitFully + tx Text06d5 + +.ows_fcd5 + run_script Func_ce6f + db $3c + dw Unknown_fce1 + run_script OWScript_PrintTextString + tx Text06d6 + run_script Func_ce6f + db $3c + dw Unknown_fce3 + run_script OWScript_QuitScriptFully + +Unknown_fce1: ; fce1 (3:7ce1) + db $82, $ff + +Unknown_fce3: ; fce3 (3:7ce3) + db $80, $ff + +rept $31b + db $ff +endr diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 1613204..b01c51b 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -92,7 +92,7 @@ Medal_1029e: ; 1029e (4:429e) jr nz, .asm_102e2 ldtx hl, WonTheMedalText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong pop af ld [wd291], a @@ -149,7 +149,7 @@ BoosterPack_1031b: ; 1031b (4:431b) ldtx hl, AndAnotherBoosterPackText .asm_10373 call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ldtx hl, CheckedCardsInBoosterPackText call PrintScrollableText_NoTextBoxLabel @@ -224,7 +224,7 @@ Duel_Init: ; 103d3 (4:43d3) lb de, 18, 17 ; x, y call SetCursorParametersForTextBox call WaitForButtonAorB - call Func_3c96 + call WaitForSongToFinish call Func_10ab4 ; fade out pop af ld [wd291], a @@ -240,7 +240,7 @@ Func_10756: ; 10756 (4:4756) INCROM $10756, $10a70 ; gives the pc pack described in a -GivePCPack: ; 10a70 (4:4a70) +TryGivePCPack: ; 10a70 (4:4a70) push hl push bc push de @@ -345,7 +345,7 @@ Func_10e28: ; 10e28 (4:4e28) INCROM $10e28, $10e55 Func_10e55: ; 10e55 (4:4e55) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd33e] or a @@ -365,7 +365,7 @@ Func_10e71: ; 10e71 (4:4e71) ldh a, [hKeysPressed] and D_PAD jr z, .asm_10e83 - farcall Func_c5d5 + farcall GetDirectionFromDPad ld [wPlayerDirection], a call Func_10e97 jr .asm_10e96 @@ -551,7 +551,7 @@ Func_11016: ; 11016 (4:5016) Func_11024: ; 11024 (4:5024) ld a, SFX_57 call PlaySFX - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld c, SPRITE_ANIM_FIELD_0F call GetSpriteAnimBufferProperty @@ -583,7 +583,7 @@ Func_11024: ; 11024 (4:5024) ret Func_11060: ; 11060 (4:5060) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd341] or a @@ -673,7 +673,7 @@ Func_110a6: ; 110a6 (4:50a6) xor a ld [wd347], a ld [wd348], a - farcall Func_c5e9 + farcall UpdatePlayerSprite pop hl ret @@ -977,7 +977,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_StartBattle dw OWScript_PrintVariableText dw Func_cda8 - dw OWScript_PrintTextCloseBox + dw OWScript_PrintTextQuitFully dw Func_cdcb dw Func_ce26 dw OWScript_CloseTextBox @@ -997,7 +997,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d032 dw Func_d03f dw OWScript_Jump - dw Func_d04f + dw OWScript_TryGiveMedalPCPacks dw OWScript_SetPlayerDirection dw OWScript_MovePlayer dw OWScript_ShowCardReceivedScreen @@ -1035,18 +1035,18 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_cd76 dw Func_d39d dw Func_d3b9 - dw OWScript_GivePCPack + dw OWScript_TryGivePCPack dw OWScript_nop dw Func_d3d4 dw Func_d3e0 dw Func_d3fe dw Func_d408 dw Func_d40f - dw Func_d416 - dw Func_d423 - dw Func_d429 + dw OWScript_PlaySFX + dw OWScript_PauseSong + dw OWScript_ResumeSong dw Func_d41d - dw Func_d42f + dw OWScript_WaitForSongToFinish dw Func_d435 dw OWScript_AskQuestionJumpDefaultYes dw Func_d2f6 @@ -1561,7 +1561,7 @@ Func_1344d: ; 1344d (4:744d) call PlaySong ldtx hl, DefeatedFiveOpponentsText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x13462 @@ -1583,7 +1583,7 @@ Func_13485: ; 13485 (4:7485) call PlaySong ldtx hl, ConsecutiveWinRecordIncreasedText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x134b1 @@ -1591,5 +1591,8 @@ Func_13485: ; 13485 (4:7485) INCROM $134b1, $1372f INCLUDE "data/npc_map_data.asm" +INCLUDE "data/level_objects.asm" - INCROM $13b04, $14000 +rept $119 + db $ff +endr diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index b5b9504..d655c42 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -388,8 +388,55 @@ Func_1c719: ; 1c719 (7:4719) pop hl ret -Func_1c72e: ; 1c72e (7:472e) - INCROM $1c72e, $1c768 +; Find NPC at coords b (x) c (y) +FindNPCAtLocation: ; 1c72e (7:472e) + push hl + push bc + push de + ld d, $00 + ld e, LOADED_NPC_MAX + ld hl, wLoadedNPC1CoordX +.findValidNPCLoop + ld a, [hli] + cp b + jr nz, .noValidNPCHere + ld a, [hl] + cp c + jr nz, .noValidNPCHere + push hl + inc hl + inc hl + bit 6, [hl] + pop hl + jr nz, .noValidNPCHere + push hl + dec hl + dec hl + ld a, [hl] + or a + pop hl + jr nz, .foundNPCExit +.noValidNPCHere + ld a, LOADED_NPC_LENGTH - 1 + add l + ld l, a + ld a, h + adc $00 + ld h, a + inc d + dec e + jr nz, .findValidNPCLoop + scf + jr .exit +.foundNPCExit + ld a, d + ld [wLoadedNPCTempIndex], a + or a +.exit + pop de + pop bc + pop hl + ret ; Probably needs a new name. Loads data for NPC that the next OWSequence is for ; Sets direction, Loads Image data for it, loads name, and more @@ -731,7 +778,7 @@ Credits_1d6ad: ; 1d6ad (7:56ad) ld a, [wd633] cp $ff jr nz, .asm_1d6c8 - call Func_3c96 + call WaitForSongToFinish ld a, $8 farcall $4, $6863 ld a, MUSIC_STOP diff --git a/src/engine/home.asm b/src/engine/home.asm index 4135afa..681069d 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -10800,7 +10800,7 @@ GameEvent_Credits: ; 3911 (0:3911) ret Func_3917: ; 3917 (0:3917) - ld a, $22 + ld a, EVENT_FLAG_22 farcall GetEventFlagValue call EnableSRAM ld [s0a00a], a @@ -10875,8 +10875,8 @@ Func_395a: ; 395a (0:395a) Unknown_396b: ; 396b (0:396b) db $00, -$01, $01, $00, $00, $01, -$01, $00 -; Movement offsets for scripted movements -ScriptedMovementOffsetTable: ; 3973 (0:3973) +; Movement offsets for player movements +PlayerMovementOffsetTable: ; 3973 (0:3973) db 0, -2 ; move 2 tiles up db 2, 0 ; move 2 tiles right db 0, 2 ; move 2 tiles down @@ -11062,30 +11062,30 @@ Func_3a4f: ; 3a4f (0:3a4f) Func_3a5e: ; 3a5e (0:3a5e) ldh a, [hBankROM] push af - ld l, $4 + ld l, MAP_SCRIPT_PRESSED_A_1 call GetMapScriptPointer - jr nc, .asm_3ab3 - ld a, BANK(Func_c653) + jr nc, .handleSecondAPressScript + ld a, BANK(FindPlayerMovementFromDirection) call BankswitchROM - call Func_c653 + call FindPlayerMovementFromDirection ld a, $4 call BankswitchROM ld a, [wPlayerDirection] ld d, a -.asm_3a79 +.findAPressMatchLoop ld a, [hli] bit 7, a - jr nz, .asm_3ab3 + jr nz, .handleSecondAPressScript push bc push hl cp d - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] cp b - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] cp c - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] ld [wNextOWSequence], a ld a, [hli] @@ -11104,17 +11104,17 @@ Func_3a5e: ; 3a5e (0:3a5e) call BankswitchROM scf ret -.asm_3aab +.noMatch pop hl ld bc, $0008 add hl, bc pop bc - jr .asm_3a79 -.asm_3ab3 + jr .findAPressMatchLoop +.handleSecondAPressScript pop af call BankswitchROM - ld l, $6 - call $49c2 + ld l, MAP_SCRIPT_PRESSED_A_2 + call CallMapScriptPointerIfExists ret ; returns a map script pointer in hl given @@ -11415,9 +11415,8 @@ CallHL2: ; 3c45 (0:3c45) jp hl ; 0x3c46 -PushBC_Ret: ; 3c46 (0:3c46) - push bc - ret +CallBC: ; 3c46 (0:3c46) + retbc ; 0x3c48 DoFrameIfLCDEnabled: ; 3c48 (0:3c48) @@ -11468,7 +11467,7 @@ DivideBCbyDE: ; 3c5a (0:3c5a) jr nz, .asm_3c63 ret -Func_3c83: ; 3c83 (0:3c83) +CallPlaySong: ; 3c83 (0:3c83) call PlaySong ret ; 0x3c87 @@ -11478,18 +11477,19 @@ Func_3c87: ; 3c87 (0:3c87) call PauseSong pop af call PlaySong - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x3c96 -Func_3c96: ; 3c96 (0:3c96) +WaitForSongToFinish: ; 3c96 (0:3c96) call DoFrameIfLCDEnabled call AssertSongFinished or a - jr nz, Func_3c96 + jr nz, WaitForSongToFinish ret +; clear [SOMETHING] - something relating to animations Func_3ca0: ; 3ca0 (0:3ca0) xor a ld [wd5d7], a diff --git a/src/macros/code.asm b/src/macros/code.asm index 8f2bd0d..3441ec3 100644 --- a/src/macros/code.asm +++ b/src/macros/code.asm @@ -47,3 +47,9 @@ ENDM ; the rst $38 handler is a single ret instruction ; probably used for testing purposes during development debug_ret EQUS "rst $38" + +; Returns to the pointer in bc instead of where the stack was. +retbc: MACRO + push bc + ret +ENDM diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 942fb82..42ff187 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -22,7 +22,7 @@ ENDM const OWScript_StartBattle_index ; $05 const OWScript_PrintVariableText_index ; $06 const Func_cda8_index ; $07 - const OWScript_PrintTextCloseBox_index ; $08 + const OWScript_PrintTextQuitFully_index ; $08 const Func_cdcb_index ; $09 const Func_ce26_index ; $0a const OWScript_CloseTextBox_index ; $0b @@ -42,7 +42,7 @@ ENDM const Func_d032_index ; $19 const Func_d03f_index ; $1a const OWScript_Jump_index ; $1b - const Func_d04f_index ; $1c + const OWScript_TryGiveMedalPCPacks_index ; $1c const OWScript_SetPlayerDirection_index ; $1d const OWScript_MovePlayer_index ; $1e const OWScript_ShowCardReceivedScreen_index ; $1f @@ -80,18 +80,18 @@ ENDM const Func_cd76_index ; $3f const Func_d39d_index ; $40 const Func_d3b9_index ; $41 - const OWScript_GivePCPack_index ; $42 + const OWScript_TryGivePCPack_index ; $42 const OWScript_nop_index ; $43 const Func_d3d4_index ; $44 const Func_d3e0_index ; $45 const Func_d3fe_index ; $46 const Func_d408_index ; $47 const Func_d40f_index ; $48 - const Func_d416_index ; $49 - const Func_d423_index ; $4a - const Func_d429_index ; $4b + const OWScript_PlaySFX_index ; $49 + const OWScript_PauseSong_index ; $4a + const OWScript_ResumeSong_index ; $4b const Func_d41d_index ; $4c - const Func_d42f_index ; $4d + const OWScript_WaitForSongToFinish_index ; $4d const Func_d435_index ; $4e const OWScript_AskQuestionJumpDefaultYes_index ; $4f const Func_d2f6_index ; $50 diff --git a/src/wram.asm b/src/wram.asm index c3fb738..eea0f04 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1999,10 +1999,11 @@ wd333:: ; d333 wPlayerDirection:: ; d334 ds $1 -wd335:: ; d335 +; seems to be 1 if moving 0 otherwise +wPlayerCurrentlyMoving:: ; d335 ds $1 -wd336:: ; d336 +wPlayerSpriteIndex:: ; d336 ds $1 wd337:: ; d337 @@ -2100,7 +2101,8 @@ wd3b3:: ; d3b3 ds $2 -wd3b6:: ; d3b6 +; ID of the NPC being interacted with in OWScript +wScriptNPC:: ; d3b6 ds $1 wc3b7:: ; d3b7 @@ -2125,10 +2127,7 @@ wLoadedFlagBits:: ; d3d1 ds $1 wEventFlags:: - ds $3f - -wd411:: ; d411 - ds $1 + ds $40 ; 0 keeps looping, other values break the loop in RST20 wBreakOWScriptLoop:: ; d412 -- cgit v1.2.3 From 3ac91a513dc9351734927182e46b0acd010053cf Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Thu, 24 Oct 2019 17:45:50 -0400 Subject: Uncovered NPC Movement and named OWObjects --- src/constants/map_constants.asm | 7 +- src/constants/misc_constants.asm | 5 + src/constants/script_constants.asm | 3 +- src/data/level_objects.asm | 40 +-- src/data/map_scripts.asm | 42 +-- src/engine/bank03.asm | 546 ++++++++++++++++++++++++++++--------- src/engine/bank04.asm | 2 +- src/engine/bank20.asm | 26 +- src/engine/home.asm | 16 +- src/macros/scripts.asm | 2 +- src/wram.asm | 10 +- 11 files changed, 512 insertions(+), 187 deletions(-) (limited to 'src') diff --git a/src/constants/map_constants.asm b/src/constants/map_constants.asm index 5e01d0a..92eaf4c 100644 --- a/src/constants/map_constants.asm +++ b/src/constants/map_constants.asm @@ -35,14 +35,17 @@ const HALL_OF_HONOR ; $21 +; Size of map data. See data/npc_map_data.asm and data/level_objects.asm +; for more info on what these represent NPC_MAP_SIZE EQU $06 +LEVEL_OBJECT_SIZE EQU $09 ; Most of these aren't fully understood so the names aren't great MAP_SCRIPT_SIZE EQU $0f MAP_SCRIPT_NPCS EQU $00 MAP_SCRIPT_POST_NPC EQU $02 -MAP_SCRIPT_PRESSED_A_1 EQU $04 -MAP_SCRIPT_PRESSED_A_2 EQU $06 +MAP_SCRIPT_OBJECTS EQU $04 +MAP_SCRIPT_PRESSED_A EQU $06 MAP_SCRIPT_LOAD_MAP EQU $08 MAP_SCRIPT_AFTER_DUEL EQU $0a MAP_SCRIPT_MOVED_PLAYER EQU $0c diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index b31631a..47b9bf6 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -44,3 +44,8 @@ FLUSH_ALL_PALS_F EQU 6 const GAME_EVENT_CONTINUE_DUEL ; $5 const GAME_EVENT_CHALLENGE_MACHINE ; $6 NUM_GAME_EVENTS EQU const_value + +OWMODE_MAP EQU 0 +OWMODE_MOVE EQU 1 +OWMODE_START_SCRIPT EQU 2 +OWMODE_SCRIPT EQU 3 diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 2ce9a54..05aaf57 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -33,7 +33,7 @@ const EVENT_FLAG_1F ; $1f const EVENT_FLAG_20 ; $20 const EVENT_FLAG_21 ; $21 - const EVENT_FLAG_22 ; $22 + const EVENT_RECEIVED_LEGEND_CARDS ; $22 const EVENT_FLAG_23 ; $23 const EVENT_FLAG_24 ; $24 const EVENT_FLAG_25 ; $25 @@ -144,3 +144,4 @@ NORTH EQU $00 EAST EQU $01 SOUTH EQU $02 WEST EQU $03 +NO_MOVE EQU %10000000 ; For rotations without movement diff --git a/src/data/level_objects.asm b/src/data/level_objects.asm index a0d51cc..0756f7f 100644 --- a/src/data/level_objects.asm +++ b/src/data/level_objects.asm @@ -1,4 +1,10 @@ -LevelObjects_13b04: ; 13b04 (3:7b04) +; Objects around maps that can be interacted with but are not represented +; by NPCs. Things like Deck Machines and the PCs. +; Format: +; Direction you need to face, X coord, Y coord +; Routine that gets called when you hit A in front of it +; Object Name, and Object default Text +MasonLabObjects: ; 13b04 (3:7b04) db NORTH, 18, 2 dw PrintInteractableObjectText tx Text04a0 @@ -42,7 +48,7 @@ LevelObjects_13b04: ; 13b04 (3:7b04) db $ff -LevelObjects_13b4d: ; 13b4d (3:7b4d) +DeckMachineRoomObjects: ; 13b4d (3:7b4d) db NORTH, 2, 2 dw OWSequence_d932 tx Text041b @@ -146,7 +152,7 @@ LevelObjects_13b4d: ; 13b4d (3:7b4d) db $ff -LevelObjects_13c02: ; 13c02 (3:7c02) +IshiharasHouseObjects: ; 13c02 (3:7c02) db NORTH, 6, 2 dw PrintInteractableObjectText tx Text04ae @@ -210,7 +216,7 @@ LevelObjects_13c02: ; 13c02 (3:7c02) db $ff -LevelObjects_13c6f: ; 13c6f (3:7c6f) +FightingClubLobbyObjects: ; 13c6f (3:7c6f) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04c6 @@ -244,7 +250,7 @@ LevelObjects_13c6f: ; 13c6f (3:7c6f) db $ff -LevelObjects_13ca6: ; 13ca6 (3:7ca6) +RockClubLobbyObjects: ; 13ca6 (3:7ca6) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04cc @@ -278,7 +284,7 @@ LevelObjects_13ca6: ; 13ca6 (3:7ca6) db $ff -LevelObjects_13cdd: ; 13cdd (3:7cdd) +WaterClubLobbyObjects: ; 13cdd (3:7cdd) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04d2 @@ -312,7 +318,7 @@ LevelObjects_13cdd: ; 13cdd (3:7cdd) db $ff -LevelObjects_13d14: ; 13d14 (3:7d14) +LightningClubLobbyObjects: ; 13d14 (3:7d14) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04d8 @@ -346,7 +352,7 @@ LevelObjects_13d14: ; 13d14 (3:7d14) db $ff -LevelObjects_13d4b: ; 13d4b (3:7d4b) +GrassClubLobbyObjects: ; 13d4b (3:7d4b) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04de @@ -380,7 +386,7 @@ LevelObjects_13d4b: ; 13d4b (3:7d4b) db $ff -LevelObjects_13d82: ; 13d82 (3:7d82) +PsychicClubLobbyObjects: ; 13d82 (3:7d82) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04e4 @@ -414,7 +420,7 @@ LevelObjects_13d82: ; 13d82 (3:7d82) db $ff -LevelObjects_13db9: ; 13db9 (3:7db9) +ScienceClubLobbyObjects: ; 13db9 (3:7db9) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04ea @@ -448,7 +454,7 @@ LevelObjects_13db9: ; 13db9 (3:7db9) db $ff -LevelObjects_13df0: ; 13df0 (3:7df0) +FireClubLobbyObjects: ; 13df0 (3:7df0) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04f0 @@ -482,7 +488,7 @@ LevelObjects_13df0: ; 13df0 (3:7df0) db $ff -LevelObjects_13e27: ; 13e27 (3:7e27) +ChallengeHallLobbyObjects: ; 13e27 (3:7e27) db NORTH, 20, 2 dw PrintInteractableObjectText tx Text04f6 @@ -516,7 +522,7 @@ LevelObjects_13e27: ; 13e27 (3:7e27) db $ff -LevelObjects_13e5e: ; 13e5e (3:7e5e) +PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) db NORTH, 2, 2 dw PrintInteractableObjectText tx Text04fc @@ -576,14 +582,16 @@ LevelObjects_13e5e: ; 13e5e (3:7e5e) db $ff -LevelObjects_13ec2: ; 13ec2 (3:7ec2) +HallOfHonorObjects: ; 13ec2 (3:7ec2) + ; Legendary Cards db NORTH, 10, 10 - dw $7bf1 + dw OWSequence_fbf1 dw $0000 dw $0000 + ; Legendary Cards db NORTH, 12, 10 - dw $7bf1 + dw OWSequence_fbf1 dw $0000 dw $0000 diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index bd0229d..8a3dad7 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -4,8 +4,8 @@ ; if a script pointer is $0000, that map has no script for that event ; 0: NPC data ; 2: Called after every NPC is loaded (unused) -; 4: pressed A button -; 6: pressed A button +; 4: Interactable Objects +; 6: pressed A button (if nothing interactable is found) ; 8: load map ; a: after duel ; c: moved player @@ -25,17 +25,17 @@ MapScripts: ; 1162a (4:562a) ; MASON_LABORATORY dw MasonLabNPCS dw $0000 - dw $7b04 - dw $5565 - dw $5549 + dw MasonLabObjects + dw MasonLabPressedA + dw MasonLabLoadMap dw MasonLaboratoryAfterDuel dw $0000 - dw $555e + dw MasonLabCloseTextBox ; DECK_MACHINE_ROOM dw DeckMachineRoomNPCS dw $0000 - dw $7b4d + dw DeckMachineRoomObjects dw $0000 dw $0000 dw $589f @@ -45,7 +45,7 @@ MapScripts: ; 1162a (4:562a) ; ISHIHARAS_HOUSE dw IshiharasHouseNPCS dw $0000 - dw $7c02 + dw IshiharasHouseObjects dw $0000 dw $0000 dw $0000 @@ -65,7 +65,7 @@ MapScripts: ; 1162a (4:562a) ; FIGHTING_CLUB_LOBBY dw FightingClubLobbyNPCS dw $0000 - dw $7c6f + dw FightingClubLobbyObjects dw $0000 dw $0000 dw FightingClubLobbyAfterDuel @@ -95,7 +95,7 @@ MapScripts: ; 1162a (4:562a) ; ROCK_CLUB_LOBBY dw RockClubLobbyNPCS dw $0000 - dw $7ca6 + dw RockClubLobbyObjects dw $0000 dw $0000 dw $5ed5 @@ -125,7 +125,7 @@ MapScripts: ; 1162a (4:562a) ; WATER_CLUB_LOBBY dw WaterClubLobbyNPCS dw $0000 - dw $7cdd + dw WaterClubLobbyObjects dw $0000 dw $0000 dw $60a2 @@ -155,7 +155,7 @@ MapScripts: ; 1162a (4:562a) ; LIGHTNING_CLUB_LOBBY dw LightningClubLobbyNPCS dw $0000 - dw $7d14 + dw LightningClubLobbyObjects dw $0000 dw $0000 dw $636d @@ -185,7 +185,7 @@ MapScripts: ; 1162a (4:562a) ; GRASS_CLUB_LOBBY dw GrassClubLobbyNPCS dw $0000 - dw $7d4b + dw GrassClubLobbyObjects dw $0000 dw $0000 dw GrassClubLobbyAfterDuel @@ -215,7 +215,7 @@ MapScripts: ; 1162a (4:562a) ; PSYCHIC_CLUB_LOBBY dw PsychicClubLobbyNPCS dw $0000 - dw $7d82 + dw PsychicClubLobbyObjects dw $0000 dw $6971 dw $6963 @@ -245,7 +245,7 @@ MapScripts: ; 1162a (4:562a) ; SCIENCE_CLUB_LOBBY dw ScienceClubLobbyNPCS dw $0000 - dw $7db9 + dw ScienceClubLobbyObjects dw $0000 dw $0000 dw $6b57 @@ -275,8 +275,8 @@ MapScripts: ; 1162a (4:562a) ; FIRE_CLUB_LOBBY dw FireClubLobbyNPCS dw $0000 - dw $7df0 - dw $6d57 + dw FireClubLobbyObjects + dw FireClubPressedA dw $0000 dw $6d49 dw $0000 @@ -305,7 +305,7 @@ MapScripts: ; 1162a (4:562a) ; CHALLENGE_HALL_LOBBY dw ChallengeHallLobbyNPCS dw $0000 - dw $7e27 + dw ChallengeHallLobbyObjects dw $0000 dw $7088 dw $0000 @@ -325,7 +325,7 @@ MapScripts: ; 1162a (4:562a) ; POKEMON_DOME_ENTRANCE dw PokemonDomeEntranceNPCS dw $0000 - dw $7e5e + dw PokemonDomeEntranceObjects dw $0000 dw $7607 dw $0000 @@ -345,9 +345,9 @@ MapScripts: ; 1162a (4:562a) ; HALL_OF_HONOR dw HallOfHonorNPCS dw $0000 - dw $7ec2 + dw HallOfHonorObjects dw $0000 - dw $7bdb + dw HallOfHonorLoadMap dw $0000 dw $0000 dw $0000 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index b573956..651109d 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -54,7 +54,7 @@ LoadMap: ; c000 (3:4000) .asm_c092 call DoFrameIfLCDEnabled call SetScreenScroll - call Func_c0ce + call HandleOverworldMode ld hl, wd0b4 ld a, [hl] and $d0 @@ -79,13 +79,13 @@ LoadMap: ; c000 (3:4000) call Func_c280 ret -Func_c0ce: ; c0ce (3:40ce) - ld a, [wd0bf] +HandleOverworldMode: ; c0ce (3:40ce) + ld a, [wOverworldMode] res 7, a rlca - add LOW(PointerTable_c0e0) + add LOW(OverworldModePointers) ld l, a - ld a, HIGH(PointerTable_c0e0) + ld a, HIGH(OverworldModePointers) adc $0 ld h, a ld a, [hli] @@ -93,18 +93,18 @@ Func_c0ce: ; c0ce (3:40ce) ld l, a jp hl -PointerTable_c0e0: ; c0e0 (3:40e0) +OverworldModePointers: ; c0e0 (3:40e0) dw Func_c0e8 ; on map - dw Func_c0ed ; walking around - dw SetOWSequenceData ; beginning ows - dw EnterOWSequence ; mid-ows + dw CallHandlePlayerMoveMode + dw SetOWSequenceData + dw EnterOWSequence Func_c0e8: ; c0e8 (3:40e8) farcall Func_10e55 ret -Func_c0ed: ; c0ed (3:40ed) - call Func_c510 +CallHandlePlayerMoveMode: ; c0ed (3:40ed) + call HandlePlayerMoveMode ret SetOWSequenceData: ; c0f1 (3:40f1) @@ -116,7 +116,7 @@ SetOWSequenceData: ; c0f1 (3:40f1) ld a, b ld [wNextOWSequence+1], a ld a, $3 - ld [wd0bf], a + ld [wOverworldMode], a jr EnterOWSequence EnterOWSequence: ; c10a (3:410a) @@ -141,7 +141,7 @@ CloseAdvancedDialogueBox: ; c111 (3:4111) xor a ld [wd0c1], a ld a, [wd0c0] - ld [wd0bf], a + ld [wOverworldMode], a ret ; redraws the background and removes textbox control @@ -189,7 +189,7 @@ Func_c158: ; c158 (3:4158) ret Func_c17a: ; c17a (3:417a) - ld a, [wd0bf] + ld a, [wOverworldMode] cp $3 ret z call Func_c9b8 @@ -204,7 +204,7 @@ Func_c184: ; c184 (3:4184) ld c, $0 .asm_c190 ld a, c - ld [wd0bf], a + ld [wOverworldMode], a ld [wd0c0], a pop bc ret @@ -606,24 +606,24 @@ Func_c4b9: ; c4b9 (3:44b9) .asm_c50f ret -Func_c510: ; c510 (3:4510) +HandlePlayerMoveMode: ; c510 (3:4510) ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wPlayerCurrentlyMoving] bit 4, a ret nz bit 0, a - call z, Func_c5ac + call z, HandlePlayerMoveModeInput ld a, [wPlayerCurrentlyMoving] or a - jr z, .asm_c535 + jr z, .notMoving bit 0, a call nz, Func_c66c ld a, [wPlayerCurrentlyMoving] bit 1, a call nz, Func_c6dc ret -.asm_c535 +.notMoving ldh a, [hKeysPressed] and START call nz, OpenStartMenu @@ -695,7 +695,7 @@ Func_c58b: ; c58b (3:458b) pop hl ret -Func_c5ac: ; c5ac (3:45ac) +HandlePlayerMoveModeInput: ; c5ac (3:45ac) ldh a, [hKeysHeld] and D_PAD jr z, .skipMoving @@ -708,7 +708,7 @@ Func_c5ac: ; c5ac (3:45ac) ldh a, [hKeysPressed] and A_BUTTON jr z, .done - call Func_c71e + call FindNPCOrObject jr .done .done ret @@ -911,7 +911,7 @@ Func_c6dc: ; c6dc (3:46dc) call Func_c6f7 call Func_3997 call Func_c70d - ld a, [wd0bf] + ld a, [wOverworldMode] cp $1 call z, Func_c9c0 pop hl @@ -942,7 +942,7 @@ Func_c70d: ; c70d (3:470d) ret ; Arrives here if A button is pressed when not moving + in map move state -Func_c71e: ; c71e (3:471e) +FindNPCOrObject: ; c71e (3:471e) ld a, $ff ld [wScriptNPC], a call FindPlayerMovementFromDirection @@ -953,19 +953,19 @@ Func_c71e: ; c71e (3:471e) jr c, .noNPC ld a, [wLoadedNPCTempIndex] ld [wScriptNPC], a - ld a, $2 ; start OWScript - jr .asm_c748 + ld a, OWMODE_START_SCRIPT + jr .changeStateExit .noNPC - call Func_3a5e - jr nc, .asm_c746 - ld a, $3 - jr .asm_c748 -.asm_c746 + call HandleMoveModeAPress + jr nc, .exit + ld a, OWMODE_SCRIPT + jr .changeStateExit +.exit or a ret -.asm_c748 - ld [wd0bf], a +.changeStateExit + ld [wOverworldMode], a scf ret @@ -1220,7 +1220,7 @@ SetNextOWSequence: ; c935 (3:4935) inc hl ld [hl], b ld a, $3 - ld [wd0bf], a + ld [wOverworldMode], a pop hl ret @@ -1366,7 +1366,7 @@ Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] cp $b jr z, .asm_ca68 - get_flag_value EVENT_FLAG_22 + get_flag_value EVENT_RECEIVED_LEGEND_CARDS or a jr nz, .asm_ca4a get_flag_value EVENT_FLAG_40 @@ -1618,7 +1618,7 @@ EventFlagMods: ; cb37 (3:4b37) flag_def $05, %00001111 ; EVENT_FLAG_1F flag_def $06, %11110000 ; EVENT_FLAG_20 flag_def $06, %00001100 ; EVENT_FLAG_21 - flag_def $06, %00000010 ; EVENT_FLAG_22 + flag_def $06, %00000010 ; EVENT_RECEIVED_LEGEND_CARDS flag_def $06, %00000001 ; EVENT_FLAG_23 flag_def $07, %11000000 ; EVENT_FLAG_24 flag_def $07, %00100000 ; EVENT_FLAG_25 @@ -1706,7 +1706,7 @@ EventFlagMods: ; cb37 (3:4b37) ; Used for basic level objects that just print text and quit PrintInteractableObjectText: ; cc25 (3:4c25) - ld hl, wd0ca + ld hl, wDefaultObjectText ld a, [hli] ld h, [hl] ld l, a @@ -2059,7 +2059,9 @@ Func_ce26: ; ce26 (3:4e26) inc hl ld b, [hl] -Func_ce3a: ; ce3a (3:4e3a) +; Moves an NPC given the list of directions pointed to by bc +; set bit 7 to only rotate the NPC +ExecuteNPCMovement: ; ce3a (3:4e3a) farcall Func_1c78d .asm_ce3e call DoFrameIfLCDEnabled @@ -2067,11 +2069,15 @@ Func_ce3a: ; ce3a (3:4e3a) jr nz, .asm_ce3e jp IncreaseOWScriptPointerBy3 -Func_ce4a: ; ce4a (3:4e4a) +; Begin a series of NPC movements on the currently talking NPC +; based on the series of directions pointed to by bc +OWScript_MoveActiveNPC: ; ce4a (3:4e4a) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a - jr Func_ce3a + jr ExecuteNPCMovement +; Begin a series of NPC movements on an arbitrary NPC +; based on the series of directions pointed to by bc Func_ce52: ; ce52 (3:4e52) ld a, [wLoadedNPCTempIndex] push af @@ -2081,7 +2087,7 @@ Func_ce52: ; ce52 (3:4e52) asm_ce5d ld [wTempNPC], a call FindLoadedNPC - call Func_ce3a + call ExecuteNPCMovement pop af ld [wTempNPC], a pop af @@ -2652,16 +2658,30 @@ Func_d209: ; d209 (3:5209) jr nz, .asm_d20e push bc ld b, $0 - ld hl, $5240 + ld hl, Flags_d240 add hl, bc ld a, [hl] call MaxOutEventFlag pop bc - ld hl, $5234 + ld hl, LegendCards ld a, c jr asm_d1c6 - INCROM $d234, $d244 +LegendCards: ; d234 (3:5234) + db ZAPDOS3 + tx Text03f0 + db MOLTRES2 + tx Text03f1 + db ARTICUNO2 + tx Text03f2 + db DRAGONITE1 + tx Text03f3 + +Flags_d240: ; d240 (3:5240) + db EVENT_FLAG_6D + db EVENT_FLAG_6E + db EVENT_FLAG_6F + db EVENT_FLAG_70 Func_d244: ; d244 (3:5244) ld a, c @@ -3130,9 +3150,41 @@ MasonLaboratoryAfterDuel: ; d53b (3:553b) dw $569f db $00 - INCROM $d549, $d753 +MasonLabLoadMap: ; d549 (3:5549) + get_flag_value EVENT_FLAG_3E + cp $03 + ret nc + ld a, DRMASON + ld [wTempNPC], a + call FindLoadedNPC + ld bc, OWSequence_EnterLabFirstTime + jp SetNextNPCAndOWSequence + +MasonLabCloseTextBox: ; d55e (3:555e) + ld a, $0a + farcall Func_80b89 + ret + +; Lets you access the Challenge Machine if available +MasonLabPressedA: ; d565 (3:5565) + get_flag_value EVENT_RECEIVED_LEGEND_CARDS + or a + ret z + ld hl, ChallengeMachineObjectTable + call FindExtraInteractableObjects + ret + +ChallengeMachineObjectTable: ; d572 (3:5572) + db 10, 4, NORTH + dw OWSequence_d57d + db 12, 4, NORTH + dw OWSequence_d57d + db $00 + +OWSequence_d57d: ; d57d (3:557d) + INCROM $d57d, $d753 -OWSequence_d753: ; d753 (3:5753) +OWSequence_EnterLabFirstTime: ; d753 (3:5753) start_script run_script OWScript_MovePlayer db NORTH @@ -3172,9 +3224,8 @@ OWSequence_d753: ; d753 (3:5753) OWSequence_d779: ; d779 (03:5779) start_script - run_script Func_ce4a ; handles some sort of npc movement, and rotation? - db $80 - db $58 + run_script OWScript_MoveActiveNPC + dw NPCMovement_d880 run_script OWScript_PrintTextString tx Text05e4 run_script OWScript_SetDialogName @@ -3182,9 +3233,8 @@ OWSequence_d779: ; d779 (03:5779) run_script OWScript_PrintTextString tx Text05e5 run_script OWScript_CloseTextBox - run_script Func_ce4a - db $82 - db $58 + run_script OWScript_MoveActiveNPC + dw NPCMovement_d882 run_script Func_cfc6 db $01 run_script OWScript_SetPlayerDirection @@ -3198,11 +3248,10 @@ OWSequence_d779: ; d779 (03:5779) OWSequence_d794: ; d794 (3:5794) start_script - run_script Func_ce4a - db $8b - db $58 + run_script OWScript_MoveActiveNPC + dw NPCMovement_d88b run_script OWScript_DoFrames - db $28 + db 40 run_script OWScript_PrintTextString tx Text05e6 run_script OWScript_CloseTextBox @@ -3225,9 +3274,8 @@ OWSequence_d794: ; d794 (3:5794) db $01 run_script OWScript_SetPlayerDirection db WEST - run_script Func_ce4a - db $94 - db $58 + run_script OWScript_MoveActiveNPC + dw NPCMovement_d894 run_script OWScript_PrintTextString tx Text05e7 run_script OWScript_SetDialogName @@ -3342,7 +3390,39 @@ OWSequence_d827: ; d827 (3:5827) run_script OWScript_QuitScriptFully ; 0xd82d - INCROM $d82d, $d932 + INCROM $d82d, $d880 + +NPCMovement_d880: ; d880 (3:5880) + db EAST + db $ff + +NPCMovement_d882: ; d882 (3:5882) + db SOUTH + db SOUTH + db WEST + db WEST + db WEST + db WEST + db SOUTH + db EAST | NO_MOVE + db $ff + +NPCMovement_d88b: ; d88b (3:588b) + db WEST + db SOUTH + db SOUTH + db SOUTH + db WEST + db WEST + db WEST + db EAST | NO_MOVE + db $ff + +NPCMovement_d894: ; d894 (4:5894) + db SOUTH | NO_MOVE + db $ff + + INCROM $d896, $d932 OWSequence_d932: ; d932 (3:5932) start_script @@ -3394,7 +3474,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) db EVENT_FLAG_39 dw .ows_db5a run_script OWScript_JumpIfFlagNonzero2 - db EVENT_FLAG_22 + db EVENT_RECEIVED_LEGEND_CARDS dw .ows_dc3e .ows_db5a run_script OWScript_JumpIfFlagNonzero2 @@ -3436,7 +3516,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) run_script OWScript_ZeroOutFlagValue db EVENT_FLAG_38 run_script OWScript_JumpIfFlagZero2 - db EVENT_FLAG_22 + db EVENT_RECEIVED_LEGEND_CARDS dw .ows_db8d run_script OWScript_MaxOutFlagValue db EVENT_FLAG_39 @@ -3611,7 +3691,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) tx Text073e Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) - get_flag_value EVENT_FLAG_22 + get_flag_value EVENT_RECEIVED_LEGEND_CARDS cp $01 ccf ret @@ -3759,9 +3839,8 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60) db $01 .ows_dd6e - run_script Func_ce4a - db $78 - db $5d + run_script OWScript_MoveActiveNPC + dw NPCMovement_dd78 run_script Func_cdcb run_script OWScript_MaxOutFlagValue db EVENT_TEMP_BATTLED_IMAKUNI @@ -3771,7 +3850,19 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60) run_script OWScript_QuitScriptFully ; 0xdd78 - INCROM $dd78, $e0b0 +NPCMovement_dd78 ; dd78 (3:5d78) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db EAST + db EAST + db EAST + db EAST + db EAST + db $ff + + INCROM $dd82, $e0b0 Preload_ImakuniInWaterClubLobby: ; e0b0 (3:60b0) get_flag_value EVENT_IMAKUNI_STATE @@ -4014,66 +4105,103 @@ OWSequence_LostToAmanda: ; e1c1 (03:61c1) run_script OWScript_PrintTextQuitFully tx Text0439 -OWSequence_NotReadyToSeeAmy: ; e15c (03:6153) +OWSequence_NotReadyToSeeAmy: ; e1c5 (03:61c5) start_script run_script OWScript_JumpIfPlayerCoordMatches db $12 db $08 - dw $61ec + dw .ows_e1ec run_script OWScript_JumpIfPlayerCoordMatches db $14 db $08 - dw $61f2 + dw .ows_e1f2 run_script OWScript_JumpIfPlayerCoordMatches db $18 db $08 - dw $61f8 + dw .ows_e1f8 +.ows_e1d5 run_script OWScript_MovePlayer db SOUTH db $04 - run_script Func_ce4a - db $13 - db $62 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e213 run_script OWScript_PrintTextString tx Text043a run_script OWScript_JumpIfPlayerCoordMatches db $12 db $0a - dw $61fe + dw .ows_e1fe run_script OWScript_JumpIfPlayerCoordMatches db $14 db $0a - dw $6202 - run_script Func_ce4a - db $15 - db $62 + dw .ows_e202 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e215 run_script OWScript_QuitScriptFully .ows_e1ec - run_script Func_ce4a - db $06 - db $62 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e206 run_script OWScript_Jump - dw $61d5 - run_script Func_ce4a - db $0b - db $62 + dw .ows_e1d5 +.ows_e1f2 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e20b run_script OWScript_Jump - dw $61d5 - run_script Func_ce4a - db $0f - db $62 + dw .ows_e1d5 +.ows_e1f8 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e20f run_script OWScript_Jump - dw $61d5 - run_script Func_ce4a - db $18 - db $62 + dw .ows_e1d5 +.ows_e1fe + run_script OWScript_MoveActiveNPC + dw NPCMovement_e218 run_script OWScript_QuitScriptFully -; 0xe202 - INCROM $e202, $e21c +.ows_e202 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e219 + run_script OWScript_QuitScriptFully + +NPCMovement_e206: ; e206 (3:6206) + db NORTH + db WEST + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e20b: ; e20b (3:620b) + db NORTH + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e20f: ; e20f (3:620f) + db NORTH + db EAST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e213: ; e213 (3:6213) + db SOUTH + db $ff + +NPCMovement_e215: ; e215 (3:6215) + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e218: ; e218 (3:6218) + db EAST +; fallthrough + +NPCMovement_e219: ; e219 (3:6219) + db EAST + db SOUTH | NO_MOVE + db $ff -OWSequence_Joshua: +OWSequence_Joshua: ; e21c (3:621c) start_script run_script OWScript_JumpIfFlagZero2 db EVENT_BEAT_AMANDA @@ -4539,9 +4667,8 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) start_script run_script OWScript_MaxOutFlagValue db EVENT_FLAG_4B - run_script Func_ce4a - db $94 - db $68 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e894 run_script Func_d135 db $00 run_script OWScript_PrintTextString @@ -4575,26 +4702,31 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862) run_script OWScript_MovePlayer db EAST db $04 - run_script Func_ce4a - db $94 - db $68 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e894 run_script Func_cdcb run_script Func_d41d run_script OWScript_QuitScriptFully -; 0xe894 - INCROM $e894, $e8c0 +NPCMovement_e894: ; e894 (3:6894) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff +; e89a + + INCROM $e89a, $e8c0 OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) start_script - run_script Func_ce4a - db $05 - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e905 run_script OWScript_DoFrames db $3c - run_script Func_ce4a - db $0d - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e90d run_script OWScript_PrintTextString tx Text064a run_script OWScript_JumpIfPlayerCoordMatches @@ -4602,12 +4734,12 @@ OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) db $02 dw $68d6 run_script OWScript_SetPlayerDirection - db $03 + db WEST run_script OWScript_MovePlayer db WEST db $01 run_script OWScript_SetPlayerDirection - db $02 + db SOUTH run_script OWScript_MovePlayer db SOUTH db $01 @@ -4648,26 +4780,45 @@ OWJump_FinishedFirstRonaldFight db EVENT_FLAG_4C db $02 run_script OWScript_CloseTextBox - run_script Func_ce4a - db $0f - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e90f run_script Func_cdcb run_script Func_d41d run_script OWScript_QuitScriptFully -; 0xe905 - INCROM $e905, $e91e +NPCMovement_e905: ; e905 (3:6905) + db EAST + db EAST + db EAST + db EAST + db EAST + db SOUTH + db NORTH | NO_MOVE + db $ff + +NPCMovement_e90d: ; e90d (3:690d) + db NORTH + db $ff + +NPCMovement_e90f: ; e90f (3:690f) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff +; e915 + + INCROM $e915, $e91e OWSequenceSecondRonaldFight: ; e91e (3:691e) start_script - run_script Func_ce4a - db $05 - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e905 run_script OWScript_DoFrames db 60 - run_script Func_ce4a - db $0d - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e90d run_script OWScript_PrintTextString tx Text064f run_script OWScript_JumpIfPlayerCoordMatches @@ -4675,13 +4826,13 @@ OWSequenceSecondRonaldFight: ; e91e (3:691e) db $02 dw .ows_6934 run_script OWScript_SetPlayerDirection - db $03 + db WEST run_script OWScript_MovePlayer db WEST db $01 .ows_6934 run_script OWScript_SetPlayerDirection - db $02 + db SOUTH run_script OWScript_MovePlayer db SOUTH db $01 @@ -4722,15 +4873,85 @@ OWJump_FinishedSecondRonaldFight ; e959 (3:6959) db EVENT_FLAG_4D db $02 run_script OWScript_CloseTextBox - run_script Func_ce4a - db $0f - db $69 + run_script OWScript_MoveActiveNPC + dw NPCMovement_e90f run_script Func_cdcb run_script Func_d41d run_script OWScript_QuitScriptFully ; 0xe963 - INCROM $e963, $f580 + INCROM $e963, $ed57 + +FireClubPressedA: ; ed57 (3:6d57) + ld hl, SlowpokePaintingObjectTable + call FindExtraInteractableObjects + ret + +SlowpokePaintingObjectTable: ; ed5e (3:6d5e) + db 16, 2, NORTH + dw OWSequence_ee76 + db $00 + +; Given a table with data of the form: +; X, Y, Dir, OWSequence +; Searches to try to find a match, and starts an OWSequence if possible +FindExtraInteractableObjects: ; ed64 (3:6d64) + ld de, $5 +.findObjectMatchLoop + ld a, [hl] + or a + ret z + push hl + ld a, [wPlayerXCoord] + cp [hl] + jr nz, .didNotMatch + inc hl + ld a, [wPlayerYCoord] + cp [hl] + jr nz, .didNotMatch + inc hl + ld a, [wPlayerDirection] + cp [hl] + jr z, .foundObject +.didNotMatch + pop hl + add hl, de + jr .findObjectMatchLoop +.foundObject + inc hl + ld c, [hl] + inc hl + ld b, [hl] + pop hl + call SetNextOWSequence + scf + ret +; 0xed8d + + INCROM $ed8d, $ee76 + +OWSequence_ee76: ; ee76 (3:6e76) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_21 + db $01 + dw .ows_ee7d + run_script OWScript_QuitScriptFully + +.ows_ee7d + run_script OWScript_SetFlagValue + db EVENT_FLAG_21 + db $02 + run_script Func_ccdc + tx Text06a2 + run_script OWScript_GiveCard + db SLOWPOKE1 + run_script OWScript_ShowCardReceivedScreen + db SLOWPOKE1 + run_script OWScript_QuitScriptFully +; 0xee88 + + INCROM $ee88, $f580 Func_f580: ; f580 (3:7580) get_flag_value EVENT_FLAG_44 @@ -4782,7 +5003,72 @@ OWSequence_f631: ; f631 (3:7631) ret ; 0xf63c - INCROM $f63c, $fc2b + INCROM $f63c, $fbdb + +HallOfHonorLoadMap: ; fbdb (3:7bdb) + ld a, SFX_10 + call PlaySFX + ret +; 0xfbe1 + + INCROM $fbe1, $fbf1 + +OWSequence_fbf1: ; fbf1 (3:7bf1) + start_script + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_RECEIVED_LEGEND_CARDS + dw .ows_fc10 + run_script OWScript_MaxOutFlagValue + db EVENT_RECEIVED_LEGEND_CARDS + run_script Func_ccdc + tx Text05b8 + run_script OWScript_GiveCard + db ZAPDOS3 + run_script OWScript_GiveCard + db MOLTRES2 + run_script OWScript_GiveCard + db ARTICUNO2 + run_script OWScript_GiveCard + db DRAGONITE1 + run_script OWScript_ShowCardReceivedScreen + db $ff +.ows_fc05 + run_script Func_d38f + db $00 + run_script Func_ccdc + tx Text05b9 +.ows_fc0a + run_script Func_d38f + db $01 + run_script Func_d396 + db $01 + run_script Func_d3b9 + run_script OWScript_QuitScriptFully + +.ows_fc10 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_71 + db $0f + dw .ows_fc20 + run_script Func_d209 + run_script Func_ccdc + tx Text05ba + run_script OWScript_GiveCard + db $00 + run_script OWScript_ShowCardReceivedScreen + db $00 + run_script OWScript_Jump + dw .ows_fc05 + +.ows_fc20 + run_script Func_ccdc + tx Text05bb + run_script Func_d38f + db $00 + run_script Func_ccdc + tx Text05bc + run_script OWScript_Jump + dw .ows_fc0a Func_fc2b: ; fc2b (3:7c2b) ld a, [wDuelResult] diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index b01c51b..3f1d4f4 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1008,7 +1008,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_DoFrames dw Func_d0d9 dw OWScript_JumpIfPlayerCoordMatches - dw Func_ce4a + dw OWScript_MoveActiveNPC dw OWScript_GiveOneOfEachTrainerBooster dw Func_d103 dw Func_d125 diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 0086f96..b656f90 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -408,13 +408,37 @@ Func_804d8: ; 804d8 (20:44d8) INCROM $804d8, $80b7a Func_80b7a: ; 80b7a (20:4b7a) - INCROM $80b7a, $80ba4 + INCROM $80b7a, $80b89 + +Func_80b89: ; 80b89 (20:4b89) + push hl + push bc + push af + ld c, a + ld a, $01 + ld [$d292], a + ld b, $00 + ld hl, $d323 + add hl, bc + ld a, [hl] + or a + jr z, .asm_80ba0 + ld a, c + call Func_80baa +.asm_80ba0 + pop af + pop bc + pop hl + ret Func_80ba4: ; 80ba4 (20:4ba4) push af xor a ld [wd292], a pop af +; Fallthrough + +Func_80baa: ; 80baa (20:4baa) push hl push bc push de diff --git a/src/engine/home.asm b/src/engine/home.asm index 681069d..ca0eb19 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -10800,7 +10800,7 @@ GameEvent_Credits: ; 3911 (0:3911) ret Func_3917: ; 3917 (0:3917) - ld a, EVENT_FLAG_22 + ld a, EVENT_RECEIVED_LEGEND_CARDS farcall GetEventFlagValue call EnableSRAM ld [s0a00a], a @@ -11059,16 +11059,16 @@ Func_3a4f: ; 3a4f (0:3a4f) ret ; 0x3a5e -Func_3a5e: ; 3a5e (0:3a5e) +HandleMoveModeAPress: ; 3a5e (0:3a5e) ldh a, [hBankROM] push af - ld l, MAP_SCRIPT_PRESSED_A_1 + ld l, MAP_SCRIPT_OBJECTS call GetMapScriptPointer jr nc, .handleSecondAPressScript ld a, BANK(FindPlayerMovementFromDirection) call BankswitchROM call FindPlayerMovementFromDirection - ld a, $4 + ld a, BANK(MapScripts) call BankswitchROM ld a, [wPlayerDirection] ld d, a @@ -11091,9 +11091,9 @@ Func_3a5e: ; 3a5e (0:3a5e) ld a, [hli] ld [wNextOWSequence+1], a ld a, [hli] - ld [wd0ca], a + ld [wDefaultObjectText], a ld a, [hli] - ld [wd0cb], a + ld [wDefaultObjectText+1], a ld a, [hli] ld [wCurrentNPCNameTx], a ld a, [hli] @@ -11106,14 +11106,14 @@ Func_3a5e: ; 3a5e (0:3a5e) ret .noMatch pop hl - ld bc, $0008 + ld bc, LEVEL_OBJECT_SIZE - 1 add hl, bc pop bc jr .findAPressMatchLoop .handleSecondAPressScript pop af call BankswitchROM - ld l, MAP_SCRIPT_PRESSED_A_2 + ld l, MAP_SCRIPT_PRESSED_A call CallMapScriptPointerIfExists ret diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 42ff187..b7d07cb 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -53,7 +53,7 @@ ENDM const OWScript_DoFrames_index ; $24 const Func_d0d9_index ; $25 const OWScript_JumpIfPlayerCoordMatches_index ; $26 - const Func_ce4a_index ; $27 + const OWScript_MoveActiveNPC_index ; $27 const OWScript_GiveOneOfEachTrainerBooster_index ; $28 const Func_d103_index ; $29 const Func_d125_index ; $2a diff --git a/src/wram.asm b/src/wram.asm index eea0f04..382b8e1 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1796,7 +1796,8 @@ wTempPlayerYCoord:: ; d0bd wTempPlayerDirection:: ; d0be ds $1 -wd0bf:: ; d0bf +; See constants/misc_constants.asm for OWMODE's +wOverworldMode:: ; d0bf ds $1 wd0c0:: ; d0c0 @@ -1826,11 +1827,8 @@ wNextOWSequence:: ; d0c6 wCurrentNPCNameTx:: ; d0c8 ds $2 -wd0ca:: ; d0ca - ds $1 - -wd0cb:: ; d0cb - ds $1 +wDefaultObjectText:: ; d0ca + ds $2 wd0cc:: ; d0cc ds 8 palettes -- cgit v1.2.3 From e58e93fdb14173ae7a9edcd782f70fe67402c42f Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Fri, 25 Oct 2019 19:41:50 -0400 Subject: a bit more scripting stuff, figured out more npc data --- src/data/npc_map_data.asm | 5 ++- src/data/npcs.asm | 87 +++++++++++++++++++++---------------------- src/engine/bank03.asm | 94 ++++++++++++++++++++++++++++++++++------------- src/engine/bank04.asm | 4 +- src/engine/bank07.asm | 2 +- src/macros/scripts.asm | 4 +- 6 files changed, 121 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index 629eb91..d40e086 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -1,4 +1,5 @@ -; NPC Map data. Format: +; NPC Map data. Note: pre-load functions also run after battles +; Format: ; NPC, X position, Y Position, Direction, ; pre-load function. (Resets c flag if NPC should not be loaded) MasonLabNPCS: ; 772f (4:1372f) @@ -150,7 +151,7 @@ WaterClubNPCS: ; 787e (4:1387e) db JOSHUA, $16, $08, SOUTH dw $0000 db AMY, $16, $04, SOUTH - dw $62ad + dw Preload_Amy db $00 LightningClubEntranceNPCS: ; 7897 (4:13897) diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 8fb8773..5d091a1 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1,5 +1,6 @@ ; When you press the A button in front of something it will find a data entry somewhere on this list ; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation. +; The Deck IDs are used for the challenge hall NPCDataTable: dw DrMasonData dw DrMasonData @@ -138,7 +139,7 @@ Ronald1Data: dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC - db $1a + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 Ronald2Data: @@ -150,7 +151,7 @@ Ronald2Data: dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC - db $1a + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 Ronald3Data: @@ -162,7 +163,7 @@ Ronald3Data: dw OWSequence_Ronald ; Pointer to OWScript tx Text03ad db RONALD_PIC - db $1a + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 IshiharaData: @@ -186,7 +187,7 @@ ImakuniData: dw OWSequence_Imakuni ; Pointer to OWScript tx Text03af db IMAKUNI_PIC - db $34 + db IMAKUNI_DECK_ID db $10 db $15 SamData: @@ -198,7 +199,7 @@ SamData: dw $561d ; Pointer to OWScript tx Text03b1 db SAM_PIC - db $02 + db SAMS_NORMAL_DECK_ID db $02 db $15 Tech1Data: @@ -390,7 +391,7 @@ ChrisData: dw $5ef2 ; Pointer to OWScript tx Text03b4 db CHRIS_PIC - db $1c + db MUSCLES_FOR_BRAINS_DECK_ID db $03 db $15 MichaelData: @@ -402,7 +403,7 @@ MichaelData: dw $6573 ; Pointer to OWScript tx Text03b5 db MICHAEL_PIC - db $1d + db HEATED_BATTLE_DECK_ID db $03 db $15 JessicaData: @@ -414,7 +415,7 @@ JessicaData: dw $6d96 ; Pointer to OWScript tx Text03b6 db JESSICA_PIC - db $1e + db LOVE_TO_BATTLE_DECK_ID db $03 db $15 MitchData: @@ -426,7 +427,7 @@ MitchData: dw $5dc3 ; Pointer to OWScript tx Text03b7 db MITCH_PIC - db $10 + db FIRST_STRIKE_DECK_ID db $03 db $16 MatthewData: @@ -438,7 +439,7 @@ MatthewData: dw $5f39 ; Pointer to OWScript tx Text03b8 db MATTHEW_PIC - db $21 + db HARD_POKEMON_DECK_ID db $03 db $15 RyanData: @@ -450,7 +451,7 @@ RyanData: dw $5ff0 ; Pointer to OWScript tx Text03b9 db RYAN_PIC - db $1f + db EXCAVATION_DECK_ID db $03 db $15 AndrewData: @@ -462,7 +463,7 @@ AndrewData: dw $6017 ; Pointer to OWScript tx Text03ba db ANDREW_PIC - db $20 + db BLISTERING_POKEMON_DECK_ID db $03 db $15 GeneData: @@ -474,7 +475,7 @@ GeneData: dw $603e ; Pointer to OWScript tx Text03bb db GENE_PIC - db $11 + db ROCK_CRUSHER_DECK_ID db $03 db $16 SaraData: @@ -486,7 +487,7 @@ SaraData: dw OWSequence_Sara ; Pointer to OWScript tx Text03bc db SARA_PIC - db $22 + db WATERFRONT_POKEMON_DECK_ID db $03 db $15 AmandaData: @@ -498,7 +499,7 @@ AmandaData: dw OWSequence_Amanda ; Pointer to OWScript tx Text03bd db AMANDA_PIC ; battle profile picture - db $23 + db LONELY_FRIENDS_DECK_ID db $03 db $15 JoshuaData: @@ -510,7 +511,7 @@ JoshuaData: dw OWSequence_Joshua ; Pointer to OWScript tx Text03be db JOSHUA_PIC - db $24 + db SOUND_OF_THE_WAVES_DECK_ID db $03 db $15 AmyData: @@ -522,7 +523,7 @@ AmyData: dw OWSequence_Amy ; Pointer to OWScript tx Text03bf db AMY_PIC - db $12 + db GO_GO_RAIN_DANCE_DECK_ID db $03 db $16 JenniferData: @@ -534,7 +535,7 @@ JenniferData: dw $6408 ; Pointer to OWScript tx Text03c0 db JENNIFER_PIC - db $25 + db PIKACHU_DECK_ID db $03 db $15 NicholasData: @@ -546,7 +547,7 @@ NicholasData: dw $642f ; Pointer to OWScript tx Text03c1 db NICHOLAS_PIC - db $26 + db BOOM_BOOM_SELFDESTRUCT_DECK_ID db $03 db $15 BrandonData: @@ -558,7 +559,7 @@ BrandonData: dw $6456 ; Pointer to OWScript tx Text03c2 db BRANDON_PIC - db $27 + db POWER_GENERATOR_DECK_ID db $03 db $15 IsaacData: @@ -570,7 +571,7 @@ IsaacData: dw $64ad ; Pointer to OWScript tx Text03c3 db ISAAC_PIC - db $13 + db ZAPPING_SELFDESTRUCT_DECK_ID db $03 db $16 BrittanyData: @@ -582,7 +583,7 @@ BrittanyData: dw OWSequence_Brittany ; Pointer to OWScript tx Text03c4 db BRITTANY_PIC - db $28 + db ETCETERA_DECK_ID db $03 db $15 KristinData: @@ -594,7 +595,7 @@ KristinData: dw $6701 ; Pointer to OWScript tx Text03c5 db KRISTIN_PIC - db $29 + db FLOWER_GARDEN_DECK_ID db $03 db $15 HeatherData: @@ -606,7 +607,7 @@ HeatherData: dw $6745 ; Pointer to OWScript tx Text03c6 db HEATHER_PIC - db $2a + db KALEIDOSCOPE_DECK_ID db $03 db $15 NikkiData: @@ -618,7 +619,7 @@ NikkiData: dw $679e ; Pointer to OWScript tx Text03c7 db NIKKI_PIC - db $14 + db FLOWER_POWER_DECK_ID db $03 db $16 RobertData: @@ -630,7 +631,7 @@ RobertData: dw $6980 ; Pointer to OWScript tx Text03c8 db ROBERT_PIC - db $2b + db GHOST_DECK_ID db $03 db $15 DanielData: @@ -642,7 +643,7 @@ DanielData: dw $6a60 ; Pointer to OWScript tx Text03c9 db DANIEL_PIC - db $2c + db NAP_TIME_DECK_ID db $03 db $15 StephanieData: @@ -654,7 +655,7 @@ StephanieData: dw $6aa2 ; Pointer to OWScript tx Text03ca db STEPHANIE_PIC - db $2d + db STRANGE_POWER_DECK_ID db $03 db $15 Murray1Data: @@ -666,7 +667,7 @@ Murray1Data: dw $6adf ; Pointer to OWScript tx Text03cb db MURRAY_PIC - db $15 + db STRANGE_PSYSHOCK_DECK_ID db $03 db $16 Murray2Data: @@ -678,7 +679,7 @@ Murray2Data: dw $6adf ; Pointer to OWScript tx Text03cb db MURRAY_PIC - db $15 + db STRANGE_PSYSHOCK_DECK_ID db $03 db $16 JosephData: @@ -690,7 +691,7 @@ JosephData: dw $6cdb ; Pointer to OWScript tx Text03cc db JOSEPH_PIC - db $2e + db FLYIN_POKEMON_DECK_ID db $03 db $15 DavidData: @@ -702,7 +703,7 @@ DavidData: dw $6c11 ; Pointer to OWScript tx Text03cd db DAVID_PIC - db $2f + db LOVELY_NIDORAN_DECK_ID db $03 db $15 ErikData: @@ -714,7 +715,7 @@ ErikData: dw $6c42 ; Pointer to OWScript tx Text03ce db ERIK_PIC - db $30 + db POISON_DECK_ID db $03 db $15 RickData: @@ -726,7 +727,7 @@ RickData: dw $6c67 ; Pointer to OWScript tx Text03cf db RICK_PIC - db $16 + db WONDERS_OF_SCIENCE_DECK_ID db $03 db $16 JohnData: @@ -738,7 +739,7 @@ JohnData: dw $6eb3 ; Pointer to OWScript tx Text03d0 db JOHN_PIC - db $31 + db ANGER_DECK_ID db $03 db $15 AdamData: @@ -750,7 +751,7 @@ AdamData: dw $6ed8 ; Pointer to OWScript tx Text03d1 db ADAM_PIC - db $32 + db FLAMETHROWER_DECK_ID db $03 db $15 JonathanData: @@ -762,7 +763,7 @@ JonathanData: dw $6efd ; Pointer to OWScript tx Text03d2 db JONATHAN_PIC - db $33 + db RESHUFFLE_DECK_ID db $03 db $15 KenData: @@ -774,7 +775,7 @@ KenData: dw $6f22 ; Pointer to OWScript tx Text03d3 db KEN_PIC - db $17 + db FIRE_CHARGE_DECK_ID db $03 db $16 CourtneyData: @@ -786,7 +787,7 @@ CourtneyData: dw $771f ; Pointer to OWScript tx Text03d4 db COURTNEY_PIC - db $0c + db LEGENDARY_MOLTRES_DECK_ID db $04 db $17 SteveData: @@ -798,7 +799,7 @@ SteveData: dw $772a ; Pointer to OWScript tx Text03d5 db STEVE_PIC - db $0d + db LEGENDARY_ZAPDOS_DECK_ID db $04 db $17 JackData: @@ -810,7 +811,7 @@ JackData: dw $7735 ; Pointer to OWScript tx Text03d6 db JACK_PIC - db $0e + db LEGENDARY_ARTICUNO_DECK_ID db $04 db $17 RodData: @@ -822,7 +823,7 @@ RodData: dw $7740 ; Pointer to OWScript tx Text03d7 db ROD_PIC - db $0f + db LEGENDARY_DRAGONITE_DECK_ID db $04 db $17 Clerk10Data: @@ -1314,7 +1315,7 @@ AaronData: dw $58dd ; Pointer to OWScript tx Text03e7 db AARON_PIC - db $09 + db LIGHTNING_AND_FIRE_DECK_ID db $02 db $15 GuideData: diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 651109d..38a736e 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1901,7 +1901,7 @@ OWScript_StartBattle: ; cd01 (3:4d01) ld a, [wd695] ld c, a ld b, $0 - ld hl, $4d63 + ld hl, AaronDeckIDs add hl, bc ld a, [hl] ld [wcc19], a @@ -1933,8 +1933,10 @@ Func_cd4f: ; cd4f (3:4d4f) ld a, [wd696] jr asm_cd2f -Unknown_dd63: ; cd4f (3:4d4f) - INCROM $cd63, $cd66 +AaronDeckIDs: ; cd63 (3:4d63) + db LIGHTNING_AND_FIRE_DECK_ID + db WATER_AND_FIGHTING_DECK_ID + db GRASS_AND_PSYCHIC_DECK_ID Func_cd66: ; cd66 (3:4d66) ld a, c @@ -2045,10 +2047,12 @@ Func_cdf5: ; cdf5 (3:4df5) ld [wLoadedNPCTempIndex], a jp IncreaseOWScriptPointerBy3 -Func_ce26: ; ce26 (3:4e26) +; Finds and executes an NPCMovement script in the table provided in bc +; based on the active NPC's current direction +OWScript_MoveActiveNPCByDirection: ; ce26 (3:4e26) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a - farcall Func_1c455 + farcall GetNPCDirection rlca add c ld l, a @@ -2058,6 +2062,7 @@ Func_ce26: ; ce26 (3:4e26) ld c, [hl] inc hl ld b, [hl] +; fallthrough ; Moves an NPC given the list of directions pointed to by bc ; set bit 7 to only rotate the NPC @@ -2084,7 +2089,11 @@ Func_ce52: ; ce52 (3:4e52) ld a, [wTempNPC] push af ld a, [wd696] -asm_ce5d +; fallthrough + +; Executes movement on an arbitrary NPC using values in a and on the stack +; Changes and fixes Temp NPC using stack values +ExecuteArbitraryNPCMovementFromStack ld [wTempNPC], a call FindLoadedNPC call ExecuteNPCMovement @@ -2094,7 +2103,7 @@ asm_ce5d ld [wLoadedNPCTempIndex], a ret -Func_ce6f: ; ce6f (3:4e6f) +OWScript_MoveArbitraryNPC: ; ce6f (3:4e6f) ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] @@ -2106,7 +2115,7 @@ Func_ce6f: ; ce6f (3:4e6f) call IncreaseOWScriptPointerBy1 pop bc pop af - jr asm_ce5d + jr ExecuteArbitraryNPCMovementFromStack OWScript_CloseTextBox: ; ce84 (3:4e84) call CloseTextBox @@ -4044,7 +4053,7 @@ OWSequence_Sara: ; e177 (3:6177) tx Text042f run_script OWScript_StartBattle db PRIZES_2 - db WATERFRONT_POKEMON_DECK_ID ; 6189 + db WATERFRONT_POKEMON_DECK_ID db MUSIC_DUEL_THEME_1 run_script OWScript_QuitScriptFully @@ -4305,8 +4314,8 @@ OWSequence_BeatJoshua: ; e26c (3:626c) run_script OWScript_PrintTextString tx Text0449 run_script OWScript_CloseTextBox - run_script Func_ce26 - dw $62a1 + run_script OWScript_MoveActiveNPCByDirection + dw NPCMovementTable_e2a1 run_script OWScript_PrintTextString tx Text044a run_script Func_cfc6 @@ -4318,7 +4327,39 @@ OWSequence_BeatJoshua: ; e26c (3:626c) run_script OWScript_EndScriptLoop1 ret - INCROM $e2a1, $e2d1 +NPCMovementTable_e2a1: ; e2a1 (3:62a1) + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 + +NPCMovement_e2a9: ; e2a9 (3:62a9) + db NORTH + db $ff + +NPCMovement_e2ab: ; e2ab (3:62ab) + db SOUTH + db $ff + +Preload_Amy: ; e2ad (3:62ad) + xor a + ld [wd3d0], a + ld a, [wd0c2] + or a + jr z, .asm_e2cf + ld a, [wPlayerXCoord] + cp $14 + jr nz, .asm_e2cf + ld a, [wPlayerYCoord] + cp $06 + jr nz, .asm_e2cf + ld a, $14 + ld [wLoadNPCXPos], a + ld a, $01 + ld [wd3d0], a +.asm_e2cf + scf + ret OWSequence_MeetAmy: ; e2d1 (3:62d1) start_script @@ -4359,9 +4400,9 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) run_script OWScript_MovePlayer db NORTH db $01 - run_script Func_ce6f - db $21 - dw $62ab + run_script OWScript_MoveArbitraryNPC + db JOSHUA + dw NPCMovement_e2ab run_script OWScript_PrintTextString tx Text044e run_script OWScript_Jump @@ -5211,21 +5252,24 @@ Func_fcad: ; fcad (3:7cad) tx Text06d5 .ows_fcd5 - run_script Func_ce6f - db $3c - dw Unknown_fce1 + run_script OWScript_MoveArbitraryNPC + db GIFT_CENTER_CLERK + dw NPCMovement_fce1 run_script OWScript_PrintTextString tx Text06d6 - run_script Func_ce6f - db $3c - dw Unknown_fce3 + run_script OWScript_MoveArbitraryNPC + db GIFT_CENTER_CLERK + dw NPCMovement_fce3 run_script OWScript_QuitScriptFully -Unknown_fce1: ; fce1 (3:7ce1) - db $82, $ff +NPCMovement_fce1: ; fce1 (3:7ce1) + db SOUTH | NO_MOVE + db $ff -Unknown_fce3: ; fce3 (3:7ce3) - db $80, $ff +NPCMovement_fce3: ; fce3 (3:7ce3) + db NORTH | NO_MOVE + db $ff +; fce5 rept $31b db $ff diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 3f1d4f4..76b7c0a 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -979,7 +979,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_cda8 dw OWScript_PrintTextQuitFully dw Func_cdcb - dw Func_ce26 + dw OWScript_MoveActiveNPCByDirection dw OWScript_CloseTextBox dw OWScript_GiveBoosterPacks dw Func_cf0c @@ -1028,7 +1028,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_OpenDeckMachine dw Func_d271 dw OWScript_EnterMap - dw Func_ce6f + dw OWScript_MoveArbitraryNPC dw Func_d209 dw Func_d38f dw Func_d396 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index d655c42..54e5c74 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -93,7 +93,7 @@ INCLUDE "data/map_headers.asm" Func_1c440: ; 1c440 (7:4440) INCROM $1c440, $1c455 -Func_1c455: ; 1c455 (7:4455) +GetNPCDirection: ; 1c455 (7:4455) push hl ld a, [wLoadedNPCTempIndex] ld l, LOADED_NPC_DIRECTION diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index b7d07cb..d74db03 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -24,7 +24,7 @@ ENDM const Func_cda8_index ; $07 const OWScript_PrintTextQuitFully_index ; $08 const Func_cdcb_index ; $09 - const Func_ce26_index ; $0a + const OWScript_MoveActiveNPCByDirection_index ; $0a const OWScript_CloseTextBox_index ; $0b const OWScript_GiveBoosterPacks_index ; $0c const Func_cf0c_index ; $0d @@ -73,7 +73,7 @@ ENDM const OWScript_OpenDeckMachine_index ; $38 const Func_d271_index ; $39 const OWScript_EnterMap_index ; $3a - const Func_ce6f_index ; $3b + const OWScript_MoveArbitraryNPC_index ; $3b const Func_d209_index ; $3c const Func_d38f_index ; $3d const Func_d396_index ; $3e -- cgit v1.2.3 From 3f99d5555ce7b8a2467aef9d24d7192f993343d9 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Mon, 28 Oct 2019 17:25:50 -0400 Subject: extracted a lot of challenge hall scripts --- src/data/map_scripts.asm | 4 +- src/data/npc_map_data.asm | 2 +- src/data/npcs.asm | 4 +- src/engine/bank03.asm | 684 +++++++++++++++++++++++++++++++++++++++++++++- src/engine/bank04.asm | 2 +- src/macros/scripts.asm | 2 +- 6 files changed, 688 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index 8a3dad7..f75d963 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -317,8 +317,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $7258 - dw $7239 + dw ChallengeHallLoadMap + dw ChallengeHallAfterDuel dw $0000 dw $0000 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index d40e086..a66c149 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -377,7 +377,7 @@ ChallengeHallNPCS: ; 7a9a (4:13a9a) db CLERK13, $14, $12, SOUTH dw $707a db GUIDE, $0e, $14, SOUTH - dw $7270 + dw Preload_Guide db HOST, $0e, $04, SOUTH dw $707a db $ff, $12, $08, WEST ; pre-load function chooses NPC to load diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 5d091a1..1ef61e9 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -928,7 +928,7 @@ Lass2Data: db $00 db $1e db $00 - dw $661f ; Pointer to OWScript + dw OWSequence_e61f ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1000,7 +1000,7 @@ Clerk13Data: db $00 db $16 db $00 - dw $726c ; Pointer to OWScript + dw OWSequence_Clerk13 ; Pointer to OWScript tx Text03b3 db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 38a736e..b36371d 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -2083,7 +2083,7 @@ OWScript_MoveActiveNPC: ; ce4a (3:4e4a) ; Begin a series of NPC movements on an arbitrary NPC ; based on the series of directions pointed to by bc -Func_ce52: ; ce52 (3:4e52) +OWScript_MoveWramNPC: ; ce52 (3:4e52) ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] @@ -2626,6 +2626,7 @@ Func_d1b3: ; d1b3 (3:51b3) ld a, $d call Random add $2 +; fallthrough .asm_d1c3 ld hl, $51dc @@ -4645,7 +4646,178 @@ OWSequence_LostToBrittany: ; e618 (3:6618) tx Text06e9 ; 0xe61c - INCROM $e61c, $e7f6 +OWSequence_e61c: ; e61c (3:661c) + run_script OWScript_PrintTextQuitFully + tx Text06ea + +OWSequence_e61f: ; e61f (3:661f) + start_script + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_04 + dw OWSequence_e61c + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $06 + dw OWSequence_e61c + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $04 + dw .ows_e6a1 + run_script OWScript_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $02 + dw .ows_e66a + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_37 + db $00 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06eb + tx Text06ec + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $01 + run_script OWScript_AskQuestionJump + tx Text06ed + dw .ows_e648 + run_script OWScript_PrintTextQuitFully + tx Text06ee + +.ows_e648 + run_script Func_cf0c + db $1c + dw .ows_e64f + run_script OWScript_PrintTextQuitFully + tx Text06ef + +.ows_e64f + run_script Func_cf12 + db $1c + dw .ows_e656 + run_script OWScript_PrintTextQuitFully + tx Text06f0 + +.ows_e656 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_04 + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $02 + run_script OWScript_PrintTextString + tx Text06f1 + run_script Func_ccdc + tx Text06f2 + run_script OWScript_TakeCard + db ODDISH + run_script OWScript_GiveCard + db VILEPLUME + run_script OWScript_ShowCardReceivedScreen + db VILEPLUME + run_script OWScript_PrintTextQuitFully + tx Text06f3 + +.ows_e66a + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_37 + db $02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06f4 + tx Text06f5 + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $03 + run_script OWScript_AskQuestionJump + tx Text06ed + dw .ows_e67f + run_script OWScript_PrintTextQuitFully + tx Text06f6 + +.ows_e67f + run_script Func_cf0c + db $ab + dw .ows_e686 + run_script OWScript_PrintTextQuitFully + tx Text06f7 + +.ows_e686 + run_script Func_cf12 + db $ab + dw .ows_e68d + run_script OWScript_PrintTextQuitFully + tx Text06f8 + +.ows_e68d + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_04 + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $04 + run_script OWScript_PrintTextString + tx Text06f9 + run_script Func_ccdc + tx Text06fa + run_script OWScript_TakeCard + db CLEFAIRY + run_script OWScript_GiveCard + db PIKACHU3 + run_script OWScript_ShowCardReceivedScreen + db PIKACHU3 + run_script OWScript_PrintTextQuitFully + tx Text06f3 + +.ows_e6a1 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_37 + db $04 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text06fb + tx Text06fc + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $05 + run_script OWScript_AskQuestionJump + tx Text06ed + dw .ows_e6b6 + run_script OWScript_PrintTextQuitFully + tx Text06fd + +.ows_e6b6 + run_script Func_cf0c + db $32 + dw .ows_e6bd + run_script OWScript_PrintTextQuitFully + tx Text06fe + +.ows_e6bd + run_script Func_cf12 + db $32 + dw .ows_e6c4 + run_script OWScript_PrintTextQuitFully + tx Text06ff + +.ows_e6c4 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_04 + run_script OWScript_SetFlagValue + db EVENT_FLAG_37 + db $06 + run_script OWScript_PrintTextString + tx Text0700 + run_script Func_ccdc + tx Text0701 + run_script OWScript_TakeCard + db CHARIZARD + run_script OWScript_GiveCard + db BLASTOISE + run_script OWScript_ShowCardReceivedScreen + db BLASTOISE + run_script OWScript_PrintTextQuitFully + tx Text06f3 +; 0xe6d8 + + INCROM $e6d8, $e7f6 ClubEntranceAfterDuel: ; e7f6 (3:67f6) ld hl, .after_duel_table @@ -4992,7 +5164,513 @@ OWSequence_ee76: ; ee76 (3:6e76) run_script OWScript_QuitScriptFully ; 0xee88 - INCROM $ee88, $f580 + INCROM $ee88, $f239 + +ChallengeHallAfterDuel: ; f239 (3:7239) + ld c, $00 + ld a, [wDuelResult] + or a + jr z, .won + ld c, $02 +.won + ld b, $00 + ld hl, ChallengeHallAfterDuelTable + add hl, bc + ld c, [hl] + inc hl + ld b, [hl] + ld a, HOST + ld [wTempNPC], a + jp SetNextNPCAndOWSequence + +ChallengeHallAfterDuelTable: + dw WonAtChallengeHall + dw LostAtChallengeHall + +ChallengeHallLoadMap: ; f258 (3:7258) + get_flag_value EVENT_FLAG_47 + or a + ret z + ld a, HOST + ld [wTempNPC], a + call FindLoadedNPC + ld bc, OWSequence_f433 + jp SetNextNPCAndOWSequence + +OWSequence_Clerk13: ; f26c (3:726c) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0525 + +Preload_Guide: ; f270 (3:7270) + get_flag_value EVENT_FLAG_42 + or a + jr z, .asm_f281 + ld a, $1c + ld [wLoadNPCXPos], a + ld a, $02 + ld [wLoadNPCYPos], a +.asm_f281 + scf + ret +; 0xf283 + + INCROM $f283, $f34c + +NPCMovement_f34c: ; f34c (3:734c) + db WEST | NO_MOVE + db $ff +; f34e + + INCROM $f34e, $f37d + +NPCMovement_f37d: ; f37d (3:737d) + db EAST | NO_MOVE + db $ff + +NPCMovement_f37f: ; f37f (3:737f) + db EAST + db EAST + db SOUTH + db $ff + +NPCMovement_f383: ; f383 (3:7383) + db NORTH + db WEST + db WEST + db SOUTH | NO_MOVE + db $ff +; f388 + + INCROM $f388, $f38b + +NPCMovement_f38b: ; f38b (3:738b) + db WEST + db SOUTH + db $ff + +NPCMovement_f38e: ; f38e (3:738e) + db NORTH + db EAST +; fallthrough + +NPCMovement_f390: ; f390 (3:7390) + db SOUTH | NO_MOVE + db $ff + +LostAtChallengeHall: ; f392 (3:7392) + start_script + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37d + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f390 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw OWJump_f410 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $03 + dw OWJump_f410.ows_f41a + run_script Func_d16b + db $00 + run_script Func_d16b + db $01 + run_script OWScript_PrintTextString + tx Text0536 +.ows_f3ae + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f38b + run_script OWScript_PrintTextString + tx Text0537 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f38e + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f3ce + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f3d9 + run_script OWScript_SetFlagValue + db EVENT_FLAG_3F + db $03 + run_script OWScript_SetFlagValue + db EVENT_FLAG_48 + db $03 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_51 + run_script OWScript_Jump + dw .ows_f3e2 +.ows_f3ce + run_script OWScript_SetFlagValue + db EVENT_FLAG_40 + db $03 + run_script OWScript_SetFlagValue + db EVENT_FLAG_49 + db $03 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_55 + run_script OWScript_Jump + dw .ows_f3e2 +.ows_f3d9 + run_script OWScript_SetFlagValue + db EVENT_FLAG_41 + db $03 + run_script OWScript_SetFlagValue + db EVENT_FLAG_4A + db $03 + run_script OWScript_Jump + dw .ows_f3e2 +.ows_f3e2 + run_script OWScript_CloseAdvancedTextBox + run_script OWScript_SetNextNPCandOWSequence + db CLERK12 + dw OWSequence_f3e9 + run_script OWScript_EndScriptLoop1 + ret + +OWSequence_f3e9: ; f3e9 (3:73e9) + start_script + run_script OWScript_MoveActiveNPC + dw NPCMovement_f40a + run_script OWScript_SetPlayerDirection + db WEST + run_script OWScript_MovePlayer + db WEST + db $01 + run_script OWScript_SetPlayerDirection + db SOUTH + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f40d + run_script OWScript_QuitScriptFully + +NPCMovement_f40a: ; f40a (3:740a) + db WEST + db EAST | NO_MOVE + db $ff + +NPCMovement_f40d: ; f40d (3:740d) + db EAST + db SOUTH | NO_MOVE + db $ff + +OWJump_f410: ; f410 (4:7410) + run_script Func_d16b + db $00 + run_script Func_d16b + db $01 + run_script OWScript_PrintTextString + tx Text0538 + run_script OWScript_Jump + dw LostAtChallengeHall.ows_f3ae + +.ows_f41a + run_script OWScript_PrintTextString + tx Text0539 + run_script OWScript_SetDialogName + db RONALD1 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f42e + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text053a + tx Text053b +.ows_f42e + run_script OWScript_SetDialogName + db HOST + run_script OWScript_Jump + dw LostAtChallengeHall.ows_f3ae + +OWSequence_f433: ; f433 (3:7433) + start_script + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37d + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f390 + run_script OWScript_Jump + dw WonAtChallengeHall.ows_f4a4 + +WonAtChallengeHall; f441 (3:7441) + start_script + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37d + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f390 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $03 + dw OWJump_f4db + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw .ows_f456 +.ows_f456 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text053c + tx Text053d + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37f + run_script Func_d16b + db $00 + run_script OWScript_PrintTextString + tx Text053e + run_script OWScript_CloseTextBox + run_script OWScript_MoveWramNPC + dw NPCMovement_f4c8 + run_script Func_cdd8 + run_script OWScript_PrintTextString + tx Text053f + run_script OWScript_CloseTextBox + run_script Func_d195 + run_script Func_cdf5 + db $14 + db $14 + run_script OWScript_MoveWramNPC + dw NPCMovement_f4d0 + run_script Func_d16b + db $00 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0540 + tx Text0541 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f383 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw .ows_f4a4 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f4a1 + run_script OWScript_CloseTextBox + run_script OWScript_SetDialogName + db $02 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0542 + tx Text0543 + run_script OWScript_SetDialogName + db HOST + run_script OWScript_CloseTextBox +.ows_f4a1 + run_script OWScript_PrintTextString + tx Text0544 +.ows_f4a4 + run_script OWScript_ZeroOutFlagValue + db EVENT_FLAG_47 + run_script OWScript_PrintTextString + tx Text0545 + run_script OWScript_AskQuestionJumpDefaultYes + tx Text0546 + dw .ows_f4bd + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text0547 + tx Text0548 + run_script Func_cd4f + db $04 + db $00 + db $00 + run_script OWScript_QuitScriptFully +.ows_f4bd + run_script OWScript_PrintTextString + tx Text0549 + run_script OWScript_CloseTextBox + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_47 + run_script Func_d1ad + run_script OWScript_CloseTextBox + run_script OWScript_Jump + dw .ows_f4a4 + +NPCMovement_f4c8: ; f4c8 (3:74c8) + db EAST +NPCMovement_f4c9: ; f4c9 (3:74c9) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff + +NPCMovement_f4d0: ; f4d0 (3:74d0) + db NORTH + db NORTH + db NORTH + db NORTH + db NORTH + db NORTH + db WEST + db $ff + +NPCMovement_f4d8: ; f4d8 (3:74d8) + db EAST + db SOUTH | NO_MOVE + db $ff + +OWJump_f4db: ; f4db (3:74db) + run_script OWScript_PrintTextString + tx Text054a + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37f + run_script Func_d16b + db $00 + run_script OWScript_PrintTextString + tx Text054b + run_script OWScript_CloseTextBox + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f513 + run_script OWScript_SetDialogName + db $02 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text054c + tx Text054d + run_script OWScript_MoveWramNPC + dw NPCMovement_f4d8 + run_script OWScript_DoFrames + db 40 + run_script OWScript_MoveWramNPC + dw NPCMovement_f34c + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_script OWScript_PrintVariableText + tx Text054e + tx Text054f + run_script OWScript_SetDialogName + db HOST + run_script OWScript_CloseTextBox + run_script OWScript_MoveWramNPC + dw NPCMovement_f4c9 + run_script OWScript_Jump + dw .ows_f516 +.ows_f513 + run_script OWScript_MoveWramNPC + dw NPCMovement_f4c8 +.ows_f516 + run_script Func_cdd8 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f383 + run_script OWScript_PrintTextString + tx Text0550 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f38b + run_script Func_d1b3 + run_script OWScript_PrintTextString + tx Text0551 + run_script OWScript_GiveCard + db $00 + run_script OWScript_ShowCardReceivedScreen + db $00 + run_script OWScript_PrintTextString + tx Text0552 + run_script OWScript_CloseTextBox + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f540 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f549 + run_script OWScript_SetFlagValue + db EVENT_FLAG_3F + db $02 + run_script OWScript_SetFlagValue + db EVENT_FLAG_48 + db $02 + run_script OWScript_Jump + dw .ows_f552 +.ows_f540 + run_script OWScript_SetFlagValue + db EVENT_FLAG_40 + db $02 + run_script OWScript_SetFlagValue + db EVENT_FLAG_49 + db $02 + run_script OWScript_Jump + dw .ows_f552 +.ows_f549 + run_script OWScript_SetFlagValue + db EVENT_FLAG_41 + db $02 + run_script OWScript_SetFlagValue + db EVENT_FLAG_4A + db $02 + run_script OWScript_Jump + dw .ows_f552 +.ows_f552 + run_script OWScript_CloseAdvancedTextBox + run_script OWScript_SetNextNPCandOWSequence + db CLERK12 + dw OWSequence_f3e9 + run_script OWScript_EndScriptLoop1 + ret +; f559 + + INCROM $f559, $f580 Func_f580: ; f580 (3:7580) get_flag_value EVENT_FLAG_44 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 76b7c0a..1eeffab 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1016,7 +1016,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d16b dw Func_cd4f dw Func_cd94 - dw Func_ce52 + dw OWScript_MoveWramNPC dw Func_cdd8 dw Func_cdf5 dw Func_d195 diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index d74db03..e21845b 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -61,7 +61,7 @@ ENDM const Func_d16b_index ; $2c const Func_cd4f_index ; $2d const Func_cd94_index ; $2e - const Func_ce52_index ; $2f + const OWScript_MoveWramNPC_index ; $2f const Func_cdd8_index ; $30 const Func_cdf5_index ; $31 const Func_d195_index ; $32 -- cgit v1.2.3 From adc5a467eeccb0e44f4fcd2ed14d2b185ca1c14c Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Tue, 29 Oct 2019 16:35:04 -0400 Subject: Finished extracting Challenge Hall scripts --- src/data/map_scripts.asm | 2 +- src/data/npc_map_data.asm | 24 +- src/data/npcs.asm | 40 ++-- src/engine/bank03.asm | 593 +++++++++++++++++++++++++++++++++++++++++++++- src/macros/code.asm | 14 +- 5 files changed, 627 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index f75d963..f969d45 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -307,7 +307,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw ChallengeHallLobbyObjects dw $0000 - dw $7088 + dw ChallengeHallLobbyLoadMap dw $0000 dw $0000 dw $0000 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index a66c149..05663c3 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -347,24 +347,24 @@ FireClubNPCS: ; 7a43 (4:13a43) ChallengeHallEntranceNPCS: ; 7a5c (4:13a5c) db CLERK9, $06, $02, SOUTH - dw $6f96 + dw Preload_Clerk9 db $00 ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) db PAPPY3, $06, $0e, EAST - dw $707a + dw Preload_ChallengeHallNPCs1 db CHAMP, $10, $12, WEST - dw $707a + dw Preload_ChallengeHallNPCs1 db HOOD2, $14, $08, SOUTH - dw $707a + dw Preload_ChallengeHallNPCs1 db LASS5, $16, $10, WEST - dw $707a + dw Preload_ChallengeHallNPCs1 db GAL4, $0c, $0e, EAST - dw $7075 + dw Preload_ChallengeHallNPCs2 db CHAP5, $10, $08, WEST - dw $7075 + dw Preload_ChallengeHallNPCs2 db RONALD1, $08, $0c, SOUTH - dw $70b4 + dw Preload_ChallengeHallLobbyRonald1 db CLERK10, $06, $04, SOUTH dw $0000 db GIFT_CENTER_CLERK, $0a, $04, SOUTH @@ -373,15 +373,15 @@ ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) ChallengeHallNPCS: ; 7a9a (4:13a9a) db CLERK12, $0a, $12, SOUTH - dw $707a + dw Preload_ChallengeHallNPCs1 db CLERK13, $14, $12, SOUTH - dw $707a + dw Preload_ChallengeHallNPCs1 db GUIDE, $0e, $14, SOUTH dw Preload_Guide db HOST, $0e, $04, SOUTH - dw $707a + dw Preload_ChallengeHallNPCs1 db $ff, $12, $08, WEST ; pre-load function chooses NPC to load - dw $7559 + dw Preload_ChallengeHallOpponent db $00 PokemonDomeEntranceNPCS: ; 7ab9 (4:13ab9) diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 1ef61e9..4e5ffe7 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -376,7 +376,7 @@ Clerk9Data: db $0a db $30 db $00 - dw $7025 ; Pointer to OWScript + dw OWSequence_Clerk9 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -832,7 +832,7 @@ Clerk10Data: db $0a db $30 db $00 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript tx Text03b0 db $00 db $00 @@ -844,7 +844,7 @@ GiftCenterClerkData: db $0a db $30 db $00 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript tx Text03b0 db $00 db $00 @@ -988,7 +988,7 @@ Clerk12Data: db $00 db $16 db $00 - dw $7295 ; Pointer to OWScript + dw OWSequence_Clerk12 ; Pointer to OWScript tx Text03b3 db $00 db $00 @@ -1012,7 +1012,7 @@ HostData: db $00 db $16 db $00 - dw $7352 ; Pointer to OWScript + dw OWSequence_HostStubbed ; Pointer to OWScript tx Text03df db $00 db $00 @@ -1216,7 +1216,7 @@ Woman2Data: db $04 db $1e db $00 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript tx Text03d9 db $00 db $00 @@ -1240,7 +1240,7 @@ Pappy3Data: db $00 db $22 db $00 - dw $709c ; Pointer to OWScript + dw OWSequence_Pappy3 ; Pointer to OWScript tx Text03dd db $00 db $00 @@ -1252,7 +1252,7 @@ Gal4Data: db $00 db $16 db $00 - dw $70a0 ; Pointer to OWScript + dw OWSequence_Gal4 ; Pointer to OWScript tx Text03db db $00 db $00 @@ -1264,7 +1264,7 @@ ChampData: db $00 db $26 db $00 - dw $70a4 ; Pointer to OWScript + dw OWSequence_Champ ; Pointer to OWScript tx Text03e3 db $00 db $00 @@ -1276,7 +1276,7 @@ Hood2Data: db $04 db $1e db $00 - dw $70a8 ; Pointer to OWScript + dw OWSequence_Hood2 ; Pointer to OWScript tx Text03e2 db $00 db $00 @@ -1288,7 +1288,7 @@ Lass5Data: db $04 db $1a db $00 - dw $70ac ; Pointer to OWScript + dw OWSequence_Lass5 ; Pointer to OWScript tx Text03dc db $00 db $00 @@ -1300,7 +1300,7 @@ Chap5Data: db $00 db $1a db $00 - dw $70b0 ; Pointer to OWScript + dw OWSequence_Chap5 ; Pointer to OWScript tx Text03da db $00 db $00 @@ -1324,7 +1324,7 @@ GuideData: db $00 db $16 db $00 - dw $7283 ; Pointer to OWScript + dw OWSequence_Guide ; Pointer to OWScript tx Text03e6 db $00 db $00 @@ -1360,49 +1360,49 @@ Data_11f18: db $3a db $3a db $10 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f1f: db $68 db $27 db $3b db $41 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f26: db $69 db $27 db $3c db $42 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f2d: db $6a db $27 db $3d db $43 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f34: db $6b db $27 db $3e db $44 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f3b: db $6c db $27 db $3f db $45 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f42: db $6d db $27 db $40 db $46 db $50 - dw $4c3e ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to OWScript Data_11f49: db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index b36371d..4ee4626 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1435,7 +1435,13 @@ GetEventFlagValue: ; ca6c (3:4a6c) ret ; 0xca84 - INCROM $ca84, $ca8f +ZeroStackFlagValue2: ; ca84 (3:4a84) + call GetByteAfterCall + push bc + ld c, $00 + call SetEventFlagValue + pop bc + ret ; Use macro set_flag_value. The byte db'd after this func is called ; is used at the flag argument for SetEventFlagValue @@ -1487,7 +1493,9 @@ GetByteAfterCall: ; cab3 (3:4ab3) ret ; 0xcac2 - INCROM $cac2, $cac5 +MaxStackFlagValue: ; cac2 (3:4ac2) + call GetByteAfterCall +; fallthrough MaxOutEventFlag: ; cac5 (3:4ac5) push bc @@ -1724,7 +1732,9 @@ Func_cc32: ; cc32 (3:4c32) call Func_c8ba ret -Func_cc3e: ; cc3e (3:4c3e) +; Used for things that are represented as NPCs but don't have an OWSequence +; EX: Clerks and legendary cards that interact through Level Objects +NoOverworldSequence: ; cc3e (3:4c3e) call CloseAdvancedDialogueBox ret @@ -3110,7 +3120,7 @@ LoadOverworld: ; d4ec (3:54ec) jp SetNextOWSequence Func_d4fb: ; d4fb (3:54fb) - zero_out_flag EVENT_FLAG_59 + zero_flag_value EVENT_FLAG_59 call Func_f602 get_flag_value EVENT_FLAG_3F cp $02 @@ -5164,7 +5174,296 @@ OWSequence_ee76: ; ee76 (3:6e76) run_script OWScript_QuitScriptFully ; 0xee88 - INCROM $ee88, $f239 + INCROM $ee88, $ef96 + +Preload_Clerk9: ; ef96 (3:6f96) + call TryGiveMedalPCPacks + get_flag_value EVENT_MEDAL_COUNT + ld hl, .jumpTable + cp $09 + jp c, JumpToFunctionInTable + debug_ret + jr .asm_efe4 + +.jumpTable + dw .asm_efe4 + dw .asm_efe4 + dw .asm_efe4 + dw .asm_efba + dw .asm_efde + dw .asm_efc9 + dw .asm_efd8 + dw .asm_efd8 + dw .asm_efd8 + +.asm_efba + get_flag_value EVENT_FLAG_3F + or a + jr nz, .asm_efe4 + ld c, $01 + set_flag_value EVENT_FLAG_3F + jr .asm_efe4 + +.asm_efc9 + get_flag_value EVENT_FLAG_40 + or a + jr nz, .asm_efde + ld c, $01 + set_flag_value EVENT_FLAG_40 + jr .asm_efde + +.asm_efd8 + ld c, $07 + set_flag_value EVENT_FLAG_40 +.asm_efde + ld c, $07 + set_flag_value EVENT_FLAG_3F +.asm_efe4 + zero_flag_value EVENT_FLAG_42 + get_flag_value EVENT_FLAG_3F + cp $00 + jr z, .asm_eff8 + cp $07 + jr z, .asm_eff8 + ld c, $01 + jr .asm_f016 + +.asm_eff8 + get_flag_value EVENT_FLAG_40 + cp $00 + jr z, .asm_f008 + cp $07 + jr z, .asm_f008 + ld c, $02 + jr .asm_f016 + +.asm_f008 + get_flag_value EVENT_FLAG_41 + cp $00 + jr z, .asm_f023 + cp $07 + jr z, .asm_f023 + ld c, $03 +.asm_f016 + set_flag_value EVENT_FLAG_44 + max_flag_value EVENT_FLAG_42 + ld a, $0b + ld [wd111], a +.asm_f023 + scf + ret + +OWSequence_Clerk9: ; f025 (3:7025) + start_script + run_script OWScript_JumpIfFlagZero1 + db EVENT_FLAG_3F + dw .ows_f066 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $07 + dw .ows_f069 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $03 + dw .ows_f06f + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $02 + dw .ows_f072 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $01 + dw .ows_f06c + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $07 + dw .ows_f069 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $03 + dw .ows_f06f + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $02 + dw .ows_f072 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $01 + dw .ows_f06c + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $07 + dw .ows_f069 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $03 + dw .ows_f06f + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $02 + dw .ows_f072 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $01 + dw .ows_f06c +.ows_f066 + run_script OWScript_PrintTextQuitFully + tx Text050a + +.ows_f069 + run_script OWScript_PrintTextQuitFully + tx Text050b + +.ows_f06c + run_script OWScript_PrintTextQuitFully + tx Text050c + +.ows_f06f + run_script OWScript_PrintTextQuitFully + tx Text050d + +.ows_f072 + run_script OWScript_PrintTextQuitFully + tx Text050e + +Preload_ChallengeHallNPCs2: ; f075 (3:7075) + call Preload_ChallengeHallNPCs1 + ccf + ret + +Preload_ChallengeHallNPCs1: ; f07a (3:707a) + get_flag_value EVENT_FLAG_42 + or a + jr z, .quit + ld a, $0b + ld [wd111], a + scf +.quit + ret + +ChallengeHallLobbyLoadMap: ; f088 (3:7088) + get_flag_value EVENT_FLAG_58 + or a + ret z + ld a, $02 + ld [wTempNPC], a + call FindLoadedNPC + ld bc, $7166 + jp SetNextNPCAndOWSequence + +OWSequence_Pappy3: ; f09c (3:709c) + start_script + run_script OWScript_PrintTextQuitFully + tx Text050f + +OWSequence_Gal4: ; f0a0 (3:70a0) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0510 + +OWSequence_Champ: ; f0a4 (3:70a4) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0511 + +OWSequence_Hood2: ; f0a8 (3:70a8) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0512 + +OWSequence_Lass5: ; f0ac (3:70ac) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0513 + +OWSequence_Chap5: ; f0b0 (3:70b0) + start_script + run_script OWScript_PrintTextQuitFully + tx Text0514 + +Preload_ChallengeHallLobbyRonald1: ; f0b4 (3:70b4) + zero_flag_value2 EVENT_FLAG_58 + get_flag_value EVENT_RECEIVED_LEGEND_CARDS + or a + jr nz, .asm_f0ff + get_flag_value EVENT_FLAG_59 + or a + jr nz, .asm_f11f + get_flag_value EVENT_FLAG_40 + cp $00 + jr z, .asm_f0e5 + call .asm_710f + get_flag_value EVENT_FLAG_40 + ld e, a + get_flag_value EVENT_FLAG_49 + ld d, a + ld hl, Unknown_f156 + call Func_f121 + jr nc, .asm_f11f + jr .asm_f0f7 +.asm_f0e5 + get_flag_value EVENT_FLAG_3F + ld e, a + get_flag_value EVENT_FLAG_48 + ld d, a + ld hl, Unknown_f146 + call Func_f121 + jr nc, .asm_f11f +.asm_f0f7 + ld a, [wPlayerYCoord] + ld [wLoadNPCYPos], a + scf + ret +.asm_f0ff + max_flag_value EVENT_FLAG_54 + max_flag_value EVENT_FLAG_55 + max_flag_value EVENT_FLAG_56 + max_flag_value EVENT_FLAG_57 +.asm_710f + max_flag_value EVENT_FLAG_50 + max_flag_value EVENT_FLAG_51 + max_flag_value EVENT_FLAG_52 + max_flag_value EVENT_FLAG_53 +.asm_f11f + or a + ret + +Func_f121: ; f121 (3:7121) + ld c, $04 +.asm_f123 + ld a, [hli] + cp e + jr nz, .asm_f13e + ld a, [hli] + cp d + jr nz, .asm_f13f + ld a, [hl] + call GetEventFlagValue + or a + jr nz, .asm_f13f + ld a, [hl] + call MaxOutEventFlag + inc hl + ld c, [hl] + set_flag_value EVENT_FLAG_58 + scf + ret +.asm_f13e + inc hl +.asm_f13f + inc hl + inc hl + dec c + jr nz, .asm_f123 + or a + ret +; 0xf146 + +Unknown_f146: ; f146 (3:7146) + INCROM $f146, $f156 + +Unknown_f156: ; f156 (3:7156) + INCROM $f156, $f239 ChallengeHallAfterDuel: ; f239 (3:7239) ld c, $00 @@ -5215,14 +5514,251 @@ Preload_Guide: ; f270 (3:7270) ret ; 0xf283 - INCROM $f283, $f34c +OWSequence_Guide: ; f283 (3:7283) + start_script + run_script OWScript_JumpIfFlagZero2 + db EVENT_FLAG_42 + dw .ows_f28b + run_script OWScript_PrintTextQuitFully + tx Text0526 + +.ows_f28b + run_script OWScript_JumpIfFlagZero1 + db $3f + dw .ows_f292 + run_script OWScript_PrintTextQuitFully + tx Text0527 + +.ows_f292 + run_script OWScript_PrintTextQuitFully + tx Text0528 + +OWSequence_Clerk12: ; f295 (3:7295) + start_script + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $03 + dw .ows_f2c4 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_41 + db $02 + dw .ows_f2c1 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $03 + dw .ows_f2c4 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_40 + db $02 + dw .ows_f2c1 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $03 + dw .ows_f2c4 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_3F + db $02 + dw .ows_f2c1 + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f2cd + run_script OWScript_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f2d3 + run_script OWScript_Jump + dw .ows_f2c7 + +.ows_f2c1 + run_script OWScript_PrintTextQuitFully + tx Text0529 + +.ows_f2c4 + run_script OWScript_PrintTextQuitFully + tx Text052a + +.ows_f2c7 + run_script OWScript_PrintTextString + tx Text052b + run_script OWScript_Jump + dw .ows_f2d6 + +.ows_f2cd + run_script OWScript_PrintTextString + tx Text052c + run_script OWScript_Jump + dw .ows_f2d6 + +.ows_f2d3 + run_script OWScript_PrintTextString + tx Text052d +.ows_f2d6 + run_script OWScript_PrintTextString + tx Text052e + run_script OWScript_AskQuestionJump + tx Text052f + dw .ows_f2e1 + run_script OWScript_PrintTextQuitFully + tx Text0530 + +.ows_f2e1 + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_59 + run_script OWScript_PrintTextString + tx Text0531 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f349 + run_script OWScript_JumpIfPlayerCoordMatches + db 8 + db 18 + dw .ows_f2fa + run_script OWScript_JumpIfPlayerCoordMatches + db 12 + db 18 + dw .ows_f302 + run_script OWScript_MovePlayer + db NORTH + db $02 + run_script OWScript_Jump + dw .ows_f307 + +.ows_f2fa + run_script OWScript_SetPlayerDirection + db EAST + run_script OWScript_MovePlayer + db EAST + db $02 + run_script OWScript_Jump + dw .ows_f307 + +.ows_f302 + run_script OWScript_SetPlayerDirection + db WEST + run_script OWScript_MovePlayer + db WEST + db $02 +.ows_f307 + run_script OWScript_SetPlayerDirection + db NORTH + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_JumpIfFlagNonzero2 + db EVENT_FLAG_43 + dw .ows_f33a + run_script OWScript_MaxOutFlagValue + db EVENT_FLAG_43 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_MovePlayer + db NORTH + db $01 + run_script OWScript_SetPlayerDirection + db EAST + run_script OWScript_DoFrames + db 30 + run_script OWScript_SetPlayerDirection + db SOUTH + run_script OWScript_DoFrames + db 20 + run_script OWScript_SetPlayerDirection + db EAST + run_script OWScript_DoFrames + db 20 + run_script OWScript_SetPlayerDirection + db SOUTH + run_script OWScript_DoFrames + db 30 + run_script OWScript_MovePlayer + db SOUTH + db $01 + run_script OWScript_MovePlayer + db SOUTH + db $01 +.ows_f33a + run_script OWScript_SetPlayerDirection + db EAST + run_script OWScript_MovePlayer + db EAST + db $01 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f34e + run_script OWScript_CloseAdvancedTextBox + run_script OWScript_SetNextNPCandOWSequence + db $4a + dw OWSequence_f353 + run_script OWScript_EndScriptLoop1 + ret +; f349 + +NPCMovement_f349: ; f349 (3:7349) + db NORTH + db NORTH + db EAST +; fallthrough NPCMovement_f34c: ; f34c (3:734c) db WEST | NO_MOVE db $ff -; f34e - INCROM $f34e, $f37d +NPCMovement_f34e: ; f34e (3:734e) + db WEST + db SOUTH + db SOUTH + db $ff + +OWSequence_HostStubbed: ; f352 (3:7352) + ret + +OWSequence_f353: ; f353 (3:7353) + start_script + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37d + run_script OWScript_DoFrames + db 20 + run_script OWScript_MoveActiveNPC + dw NPCMovement_f390 + run_script Func_d16b + db $00 + run_script OWScript_PrintTextString + tx Text0532 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f37f + run_script OWScript_PrintTextString + tx Text0533 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f388 + run_script OWScript_PrintTextString + tx Text0534 + run_script OWScript_CloseTextBox + run_script OWScript_MoveActiveNPC + dw NPCMovement_f38e + run_script OWScript_PrintTextString + tx Text0535 + run_script Func_cd4f + db $04 + db $00 + db $00 + run_script OWScript_QuitScriptFully NPCMovement_f37d: ; f37d (3:737d) db EAST | NO_MOVE @@ -5240,9 +5776,12 @@ NPCMovement_f383: ; f383 (3:7383) db WEST db SOUTH | NO_MOVE db $ff -; f388 - INCROM $f388, $f38b +NPCMovement_f388: ; f388 (3:7388) + db NORTH + db WEST + db WEST +; fallthrough NPCMovement_f38b: ; f38b (3:738b) db WEST @@ -5670,7 +6209,26 @@ OWJump_f4db: ; f4db (3:74db) ret ; f559 - INCROM $f559, $f580 +; Loads the NPC to fight at the challenge hall +Preload_ChallengeHallOpponent: ; f559 (3:7559) + get_flag_value EVENT_FLAG_42 + or a + ret z + get_flag_value EVENT_FLAG_46 + or a + jr z, .asm_f56e + ld a, [wd696] + ld [wTempNPC], a + scf + ret +.asm_f56e + call Func_f5db + ld c, $01 + set_flag_value EVENT_FLAG_45 + call Func_f580 + max_flag_value EVENT_FLAG_46 + scf + ret Func_f580: ; f580 (3:7580) get_flag_value EVENT_FLAG_44 @@ -5704,7 +6262,18 @@ Func_f580: ; f580 (3:7580) ret ; 0xf5b3 - INCROM $f5b3, $f602 + INCROM $f5b3, $f5db + +Func_f5db: ; f5db (3:75db) + xor a + ld [$d698], a + ld [$d699], a + ld [$d69a], a + ld [$d69b], a + ret +; 0xf5e9 + + INCROM $f5e9, $f602 Func_f602: ; f602 (3:7602) INCROM $f602, $f631 diff --git a/src/macros/code.asm b/src/macros/code.asm index 3441ec3..8921a04 100644 --- a/src/macros/code.asm +++ b/src/macros/code.asm @@ -33,11 +33,23 @@ set_flag_value: MACRO ENDM ; runs ZeroOutEventFlag with the next value as the flag -zero_out_flag: MACRO +zero_flag_value: MACRO call ZeroStackFlagValue db \1 ENDM +; a second version of the above with no real differences +zero_flag_value2: MACRO + call ZeroStackFlagValue2 + db \1 +ENDM + +; runs MaxOutEventFlag with the next value as the flag +max_flag_value: MACRO + call MaxStackFlagValue + db \1 +ENDM + ; runs GetEventFlagValue with the next value as the flag. returns value in a get_flag_value: MACRO call GetStackFlagValue -- cgit v1.2.3 From e38d9f1de3abe1cdb54e7292ead677151348bd4e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 25 Apr 2020 17:45:32 +0100 Subject: Terror Strike effect command and related routines --- src/data/effect_commands.asm | 6 +- src/engine/effect_functions.asm | 147 +++++++++++++++++++++++++++++++++++++++- src/engine/home.asm | 22 ++++-- src/text/text1.asm | 2 +- src/text/text_offsets.asm | 2 +- 5 files changed, 165 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index 0e1886e..171c241 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -42,9 +42,9 @@ EkansWrapEffectCommands: db $00 ArbokTerrorStrikeEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4726 - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $470a - dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $470a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, TerrorStrike_SwitchDefendingPokemon + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, TerrorStrike_50PercentSelectSwitchPokemon + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, TerrorStrike_50PercentSelectSwitchPokemon db $00 ArbokPoisonFangEffectCommands: diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 116d545..8832134 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -301,7 +301,111 @@ Func_2c166: ; 2c166 (b:4166) ret ; 0x2c174 - INCROM $2c174, $2c6f0 + INCROM $2c174, $2c1ec + +HandleSwitchDefendingPokemonEffect: ; 2c1ec (b:41ec) + ld e, a + cp $ff + ret z + +; check Defending Pokemon's HP + ld a, DUELVARS_ARENA_CARD_HP + call GetNonTurnDuelistVariable + or a + jr nz, .switch + +; if 0, handle Destiny Bond first + push de + bank1call HandleDestinyBondSubstatus + pop de + +.switch + call .HandleNoDamageOrEffect + ret c + +; attack was successful, switch Defending Pokemon + call SwapTurn + call SwapArenaWithBenchPokemon + call SwapTurn + + xor a + ld [wccc5], a + ld [wDuelDisplayedScreen], a + inc a + ld [wccef], a + ret +; 0x2c216 + +; returns carry if Defending has No Damage or Effect +; if so, print its appropriate text. +.HandleNoDamageOrEffect: ; 2c216 (b:4216) + call CheckNoDamageOrEffect + ret nc + ld a, l + or h + call nz, DrawWideTextBox_PrintText + scf + ret +; 0x2c221 + + INCROM $2c221, $2c487 + +; handles the selection of a forced switch +; by link/AI opponent or by the player. +; outputs the Play Area location of the chosen +; bench card in hTempPlayAreaLocation_ff9d. +DuelistSelectForcedSwitch: ; 2c487 (b:4487) + ld a, DUELVARS_DUELIST_TYPE + call GetNonTurnDuelistVariable + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opp + + cp DUELIST_TYPE_PLAYER + jr z, .player + +; AI opponent + call SwapTurn + bank1call Func_2bc7 + call SwapTurn + + ld a, [wPlayerAttackingMoveIndex] + ld e, a + ld a, [wPlayerAttackingCardIndex] + ld d, a + ld a, [wPlayerAttackingCardID] + call CopyMoveDataAndDamage_FromCardID + call Func_16f6 + ret + +.player + ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText + call DrawWideTextBox_WaitForInput + call SwapTurn + bank1call HasAlivePokemonInBench + ld a, $01 + ld [wcbd4], a +.asm_2c4c0 + bank1call OpenPlayAreaScreenForSelection + jr c, .asm_2c4c0 + call SwapTurn + ret + +.link_opp +; get selection from link opponent + ld a, OPPACTION_FORCE_SWITCH_ACTIVE + call SetOppAction_SerialSendDuelData +.loop + call SerialRecvByte + jr nc, .received + halt + nop + jr .loop +.received + ldh [hTempPlayAreaLocation_ff9d], a + ret +; 0x2c4da + + INCROM $2c4da, $2c6f0 SpitPoison_AIEffect: ; 2c6f0 (b:46f0) ld a, 5 @@ -320,7 +424,44 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) ret ; 0x2c70a - INCROM $2c70a, $2c730 +; outputs in hTemp_ffa0 the result of the coin toss +; (0 = tails, 1 = heads) and, in case it was heads, +; stores in hTempPlayAreaLocation_ffa1 the location +; of the Bench Pokemon that was selected for switch. +TerrorStrike_50PercentSelectSwitchPokemon: ; 2c70a (b:470a) + xor a + ldh [hTemp_ffa0], a + +; return failure if no Pokemon to switch to + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetNonTurnDuelistVariable + cp 2 + ret c + +; toss coin and store whether it was tails (0) +; or heads (1) in hTemp_ffa0 +; return if it was tails. + ldtx de, IfHeadsChangeOpponentsActivePokemonText + call Func_2c08a + ldh [hTemp_ffa0], a + ret nc + + call DuelistSelectForcedSwitch + ldh a, [hTempPlayAreaLocation_ff9d] + ldh [hTempPlayAreaLocation_ffa1], a + ret +; 0x2c726 + +; if coin toss was heads and it's possible, +; switch Defending Pokemon +TerrorStrike_SwitchDefendingPokemon: ; 2c726 (b:4726) + ldh a, [hTemp_ffa0] + or a + ret z + ldh a, [hTempPlayAreaLocation_ffa1] + call HandleSwitchDefendingPokemonEffect + ret +; 0x2c730 PoisonFang_AIEffect: ; 2c730 (b:4730) ld a, 10 @@ -538,4 +679,4 @@ Toxic_DoublePoisonEffect: ; 2c994 (b:4994) ret ; 0x2c998 - INCROM $2c998, $30000 + INCROM $2c998, $30000 \ No newline at end of file diff --git a/src/engine/home.asm b/src/engine/home.asm index 545995a..4f9fc31 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -8301,34 +8301,44 @@ Func_2bcf: ; 2bcf (0:2bcf) Func_2bd7: ; 2bd7 (0:2bd7) ld a, $5 - jr Func_2bdb + jr Func_2bdb ; this line is not needed Func_2bdb: ; 2bdb (0:2bdb) ld c, a + +; load bank for Opponent Deck pointer table ldh a, [hBankROM] push af ld a, BANK(PointerTable_14000) call BankswitchROM + +; load hl with the corresponding pointer ld a, [wOpponentDeckID] ld l, a ld h, $0 - add hl, hl + add hl, hl ; two bytes per deck ld de, PointerTable_14000 add hl, de ld a, [hli] ld h, [hl] ld l, a + ld a, c or a - jr nz, .asm_2bfe + jr nz, .not_zero + +; if input was 0, copy deck data of turn player ld e, [hl] inc hl ld d, [hl] call CopyDeckData - jr .asm_2c01 -.asm_2bfe + jr .done + +; jump to corresponding AI routine related to input +.not_zero call JumpToFunctionInTable -.asm_2c01 + +.done ld c, a pop af call BankswitchROM diff --git a/src/text/text1.asm b/src/text/text1.asm index 69f44f6..07d7a7a 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -1103,7 +1103,7 @@ Text00ea: ; 37e03 (d:7e03) line "Heads, damage to yours if Tails." done -Text00eb: ; 37e46 (d:7e46) +IfHeadsChangeOpponentsActivePokemonText: ; 37e46 (d:7e46) text "If Heads, change opponent's" line "Active Pokémon." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 3149307..d027768 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -236,7 +236,7 @@ TextOffsets:: ; 34000 (d:40 textpointer Text00e8 ; 0x00e8 textpointer IfHeadPlus10IfTails10ToYourselfText ; 0x00e9 textpointer Text00ea ; 0x00ea - textpointer Text00eb ; 0x00eb + textpointer IfHeadsChangeOpponentsActivePokemonText ; 0x00eb textpointer Text00ec ; 0x00ec textpointer Text00ed ; 0x00ed textpointer Text00ee ; 0x00ee -- cgit v1.2.3 From 7d9ea8a30d19fae6a39bb36981e27db6edbea5e7 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Tue, 28 Apr 2020 20:20:20 +0100 Subject: AI routines and Energy Trans logic --- src/constants/duel_constants.asm | 41 ++- src/engine/bank01.asm | 1 + src/engine/bank05.asm | 589 +++++++++++++++++++++++++++------------ src/engine/bank08.asm | 447 ++++++++++++++++++++++++++++- src/engine/effect_functions.asm | 92 +++++- src/engine/home.asm | 2 +- src/hram.asm | 14 + src/wram.asm | 39 ++- 8 files changed, 1013 insertions(+), 212 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 65f58e3..b667c50 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -232,21 +232,32 @@ AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 AI_FLAG_MODIFIED_HAND EQU 1 << 3 AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 +; used as input for AIProcessEnergyCards to determine what to check +; and whether to play card after the routine is over. +; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine +; not to actually play the energy card after it's finished, +; but AIProcessEnergyCards checks whether ANY flag is set in order +; to decide not to play it, so it's redundant in the presence of another flag. +AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) +AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions +AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy + ; used to determine which Trainer cards for AI ; to process in AIProcessHandTrainerCards. ; aside from a few exceptions, these go in chronological order. -AI_TRAINER_CARD_PHASE_01 EQU $1 -AI_TRAINER_CARD_PHASE_02 EQU $2 -AI_TRAINER_CARD_PHASE_03 EQU $3 -AI_TRAINER_CARD_PHASE_04 EQU $4 -AI_TRAINER_CARD_PHASE_05 EQU $5 -AI_TRAINER_CARD_PHASE_06 EQU $6 -AI_TRAINER_CARD_PHASE_07 EQU $7 -AI_TRAINER_CARD_PHASE_08 EQU $8 -AI_TRAINER_CARD_PHASE_09 EQU $9 -AI_TRAINER_CARD_PHASE_10 EQU $a -AI_TRAINER_CARD_PHASE_11 EQU $b -AI_TRAINER_CARD_PHASE_12 EQU $c -AI_TRAINER_CARD_PHASE_13 EQU $d -AI_TRAINER_CARD_PHASE_14 EQU $e -AI_TRAINER_CARD_PHASE_15 EQU $f + const_def 1 + const AI_TRAINER_CARD_PHASE_01 ; $1 + const AI_TRAINER_CARD_PHASE_02 ; $2 + const AI_TRAINER_CARD_PHASE_03 ; $3 + const AI_TRAINER_CARD_PHASE_04 ; $4 + const AI_TRAINER_CARD_PHASE_05 ; $5 + const AI_TRAINER_CARD_PHASE_06 ; $6 + const AI_TRAINER_CARD_PHASE_07 ; $7 + const AI_TRAINER_CARD_PHASE_08 ; $8 + const AI_TRAINER_CARD_PHASE_09 ; $9 + const AI_TRAINER_CARD_PHASE_10 ; $a + const AI_TRAINER_CARD_PHASE_11 ; $b + const AI_TRAINER_CARD_PHASE_12 ; $c + const AI_TRAINER_CARD_PHASE_13 ; $d + const AI_TRAINER_CARD_PHASE_14 ; $e + const AI_TRAINER_CARD_PHASE_15 ; $f diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index b73b47c..7668903 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6835,6 +6835,7 @@ OppAction_ExecutePokemonPowerEffect: ; 6b07 (1:6b07) ret ; 0x6b15 +; execute the EFFECTCMDTYPE_AFTER_DAMAGE command of the used Pokemon Power OppAction_6b15: ; 6b15 (1:6b15) ld a, EFFECTCMDTYPE_AFTER_DAMAGE call TryExecuteEffectCommandFunction diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index ee45de4..ba0a565 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -74,8 +74,8 @@ Func_14078: ; 14078 (5:4078) call AIDecideBenchPokemonToSwitchTo call AIChooseEnergyToDiscardForRetreatCost .asm_14091 - call AIDecidePlayEnergyCardFromHand - call Func_169f8 + call AIProcessAndTryToPlayEnergy + call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision @@ -220,8 +220,44 @@ LoadDefendingPokemonColorWRAndPrizeCards: ; 1411d (5:411d) ret ; 0x14145 -Func_14145: ; 14145 (5:4145) - INCROM $14145, $14184 +; called when AI has chosen its attack. +; executes all effects and damage. +; handles AI choosing parameters for certain attacks as well. +AITryUseAttack: ; 14145 (5:4145) + ld a, [wSelectedAttack] + ldh [hTemp_ffa0], a + ld e, a + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ldh [hTempCardIndex_ff9f], a + ld d, a + call CopyMoveDataAndDamage_FromDeckIndex + ld a, OPPACTION_BEGIN_ATTACK + bank1call AIMakeDecision + ret c + + call AISelectSpecialAttackParameters + jr c, .use_attack + ld a, OPPACTION_BEGIN_ATTACK + call TryExecuteEffectCommandFunction + +.use_attack + ld a, [wSelectedAttack] + ld e, a + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ld d, a + call CopyMoveDataAndDamage_FromDeckIndex + ld a, OPPACTION_USE_ATTACK + bank1call AIMakeDecision + ret c + + ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE + call TryExecuteEffectCommandFunction + ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE + bank1call AIMakeDecision + ret +; 0x14184 ; return carry if any of the following is satisfied: ; - deck index in a corresponds to a double colorless energy card; @@ -1145,7 +1181,7 @@ PointerTable_14668: ; 14668 (05:4668) dw Func_14674 ; not used dw Func_14674 ; general AI for battles dw Func_14678 ; basic pokemon placement / cheater shuffling on better AI - dw Func_1467f + dw Func_1467f ; deciding which Bench Pokemon to switch to dw Func_14683 dw Func_14687 @@ -1160,11 +1196,11 @@ Func_14678: ; 14678 (5:4678) ret Func_1467f: ; 1467f (5:467f) - call $5b72 + call AIDecideBenchPokemonToSwitchTo ret Func_14683: ; 14683 (5:4683) - call $5b72 + call AIDecideBenchPokemonToSwitchTo ret Func_14687: ; 14687 (5:4687) @@ -1174,105 +1210,108 @@ Func_14687: ; 14687 (5:4687) ; AI for general decks i think Func_1468b: ; 1468b (5:468b) call Func_15649 - ld a, $1 + + ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - farcall $8, $67d3 - jp nc, $4776 - farcall $8, $6790 - farcall $8, $66a3 - farcall $8, $637f + farcall Func_227d3 + jp nc, .asm_14776 + + farcall Func_22790 + farcall Func_226a3 + farcall Func_2237f ret c - farcall $8, $662d - ld a, $2 + + farcall Func_2262d + + ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards - ld a, $3 + ld a, AI_TRAINER_CARD_PHASE_03 call AIProcessHandTrainerCards - ld a, $4 + ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards - call $5eae + call AIDecidePlayPokemonCard ret c - ld a, $5 + + ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards - ld a, $6 + ld a, AI_TRAINER_CARD_PHASE_06 call AIProcessHandTrainerCards - ld a, $7 + ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - ld a, $8 + ld a, AI_TRAINER_CARD_PHASE_08 call AIProcessHandTrainerCards - call $4786 - ld a, $a + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards - ld a, $b + ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards - ld a, $c + ld a, AI_TRAINER_CARD_PHASE_12 call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a jr nz, .asm_146ed - call $64e8 - + call AIProcessAndTryToPlayEnergy .asm_146ed - call $5eae - farcall $8, $66a3 - farcall $8, $637f + call AIDecidePlayPokemonCard + farcall Func_226a3 + farcall Func_2237f ret c - farcall $8, $6790 - ld a, $d - farcall $8, $619b - ld a, $d + farcall Func_22790 + ld a, $0d + farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards - ld a, $f + ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK + and $04 jr z, .asm_14776 - ld a, $1 + ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - ld a, $2 + ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards - ld a, $3 + ld a, AI_TRAINER_CARD_PHASE_03 call AIProcessHandTrainerCards - ld a, $4 + ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards - call $5eae + call AIDecidePlayPokemonCard ret c - ld a, $5 + ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards - ld a, $6 + ld a, AI_TRAINER_CARD_PHASE_06 call AIProcessHandTrainerCards - ld a, $7 + ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - ld a, $8 + ld a, AI_TRAINER_CARD_PHASE_08 call AIProcessHandTrainerCards - call $4786 - ld a, $a + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards - ld a, $b + ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards - ld a, $c + ld a, AI_TRAINER_CARD_PHASE_12 call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a jr nz, .asm_1475b - call $64e8 - + call AIProcessAndTryToPlayEnergy .asm_1475b - call $5eae - farcall $8, $66a3 - farcall $8, $637f + call AIDecidePlayPokemonCard + farcall Func_226a3 + farcall Func_2237f ret c - farcall $8, $6790 - ld a, $d - farcall $8, $619b - ld a, $d + farcall Func_22790 + ld a, $0d + farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards .asm_14776 - ld a, $e - farcall $8, $619b - call $69f8 + ld a, $0e + farcall HandleAIEnergyTrans + call AIProcessAndTryToUseAttack ret c - ld a, $5 + ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x14786 @@ -1735,6 +1774,8 @@ CountNumberOfEnergyCardsAttached: ; 15787 (5:5787) ; input: ; a = card location to look in; ; e = card ID to look for. +; output: +; a = deck index of card found, if any CheckIfAnyCardIDinLocation: ; 157a3 (5:57a3) ld b, a ld c, e @@ -2207,7 +2248,7 @@ AIDecideWhetherToRetreat: ; 158b2 (5:58b2) .one_or_none call CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondMove jr c, .check_defending_can_ko - call CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove + call CountNumberOfSetUpBenchPokemon cp 2 jr c, .check_defending_can_ko call AddToAIScore @@ -2324,7 +2365,8 @@ Func_15b54: ; 15b54 (5:5b54) ; calculates AI score for bench Pokémon ; returns in hTempPlayAreaLocation_ff9d the -; Play Area location of best card to switch to +; Play Area location of best card to switch to. +; returns carry if no Bench Pokemon. AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) xor a ldh [hTempPlayAreaLocation_ff9d], a @@ -2376,17 +2418,17 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) xor a ld [wSelectedAttack], a call CheckIfSelectedMoveIsUnusable - call nc, .calculate_damage + call nc, .HandleAttackDamageScore ld a, $01 ld [wSelectedAttack], a call CheckIfSelectedMoveIsUnusable - call nc, .calculate_damage + call nc, .HandleAttackDamageScore jr .check_energy_card ; adds to AI score depending on amount of damage ; it can inflict to the defending Pokémon ; AI score += floor(Damage / 10) + 1 -.calculate_damage +.HandleAttackDamageScore ld a, [wSelectedAttack] call EstimateDamage_VersusDefendingCard ld a, [wDamage] @@ -4006,47 +4048,58 @@ CheckForEvolutionInDeck: ; 16451 (5:6451) Func_16488 ; 16488 (5:6488) INCROM $16488, $164a1 -; copies wPlayAreaAIScore to wTempPlayAreaAIScore. -; copies AIScore to wcde3. -; decides which card to get energy card. -Func_164a1: ; 164a1 (5:64a1) - ld a, $03 - ld [wcdd8], a +; have AI choose an energy card to play, but do not play it. +; does not consider whether the cards have evolutions to be played. +; return carry if an energy card is chosen to use in any Play Area card, +; and if so, return its Play Area location in hTempPlayAreaLocation_ff9d. +AIProcessButDontPlayEnergy_SkipEvolution: ; 164a1 (5:64a1) + ld a, AI_ENERGY_FLAG_DONT_PLAY | AI_ENERGY_FLAG_SKIP_EVOLUTION + ld [wAIEnergyAttachLogicFlags], a + +; backup wPlayAreaAIScore in wTempPlayAreaAIScore. ld de, wTempPlayAreaAIScore ld hl, wPlayAreaAIScore ld b, MAX_PLAY_AREA_POKEMON -.loop_play_area +.loop ld a, [hli] ld [de], a inc de dec b - jr nz, .loop_play_area + jr nz, .loop ld a, [wAIScore] ld [de], a - jr AIDecideWhichCardToAttachEnergy -Func_164ba: ; 164ba (5:64ba) - ld a, $83 - ld [wcdd8], a + jr AIProcessEnergyCards + +; have AI choose an energy card to play, but do not play it. +; does not consider whether the cards have evolutions to be played. +; return carry if an energy card is chosen to use in any Bench card, +; and if so, return its Play Area location in hTempPlayAreaLocation_ff9d. +AIProcessButDontPlayEnergy_SkipEvolutionAndArena: ; 164ba (5:64ba) + ld a, AI_ENERGY_FLAG_DONT_PLAY | AI_ENERGY_FLAG_SKIP_EVOLUTION | AI_ENERGY_FLAG_SKIP_ARENA_CARD + ld [wAIEnergyAttachLogicFlags], a + +; backup wPlayAreaAIScore in wTempPlayAreaAIScore. ld de, wTempPlayAreaAIScore ld hl, wPlayAreaAIScore ld b, MAX_PLAY_AREA_POKEMON -.asm_164c7 +.loop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_164c7 + jr nz, .loop ld a, [wAIScore] ld [de], a - jr AIDecideWhichCardToAttachEnergy + + jr AIProcessEnergyCards ; copies wTempPlayAreaAIScore to wPlayAreaAIScore -; and loads wAIscore with value in wcde3. -; identical to Func_169e3. -Func_164d3: ; 164d3 (5:64d3) +; and loads wAIscore with value in wTempAIScore. +; identical to RetrievePlayAreaAIScoreFromBackup2. +RetrievePlayAreaAIScoreFromBackup1: ; 164d3 (5:64d3) push af ld de, wPlayAreaAIScore ld hl, wTempPlayAreaAIScore @@ -4065,34 +4118,37 @@ Func_164d3: ; 164d3 (5:64d3) ; have AI decide whether to play energy card from hand ; and determine which card is best to attach it. -AIDecidePlayEnergyCardFromHand: ; 164e8 (5:64e8) +AIProcessAndTryToPlayEnergy: ; 164e8 (5:64e8) xor a - ld [wcdd8], a + ld [wAIEnergyAttachLogicFlags], a call CreateEnergyCardListFromHand - jr nc, AIDecideWhichCardToAttachEnergy + jr nc, AIProcessEnergyCards ; no energy - ld a, [wcdd8] + ld a, [wAIEnergyAttachLogicFlags] or a jr z, .exit - jp Func_164d3 + jp RetrievePlayAreaAIScoreFromBackup1 .exit or a ret ; have AI decide whether to play energy card ; and determine which card is best to attach it. -AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) +AIProcessEnergyCards: ; 164fc (5:64fc) +; initialize Play Area AI score ld a, $80 ld b, MAX_PLAY_AREA_POKEMON - ld hl, wcde4 + ld hl, wPlayAreaEnergyAIScore .loop ld [hli], a dec b jr nz, .loop +; Legendary Articuno Deck has its own energy card logic call HandleLegendaryArticunoEnergyScoring +; start the main Play Area loop ld b, PLAY_AREA_ARENA ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable @@ -4106,8 +4162,8 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) ld [wAIScore], a ld a, $ff ld [wTempAI], a - ld a, [wcdd8] - and $02 + ld a, [wAIEnergyAttachLogicFlags] + and AI_ENERGY_FLAG_SKIP_EVOLUTION jr nz, .check_venusaur ; check if energy needed is found in hand @@ -4125,7 +4181,7 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) ld a, [wCurCardCanAttack] call CheckForEvolutionInList jr nc, .no_evolution_in_hand - ld [wTempAI], a + ld [wTempAI], a ; store evolution card found ld a, 2 call AddToAIScore jr .check_venusaur @@ -4137,8 +4193,9 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) ld a, 1 call AddToAIScore -; if there's no Muk in Play Area -; and there's Venusaur2, add to AI score +; if there's no Muk in any Play Area +; and there's Venusaur2 in own Play Area, +; add to AI score .check_venusaur ld a, MUK call CountPokemonIDInBothPlayAreas @@ -4157,27 +4214,27 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) ; arena ld a, [wcda7] bit 7, a - jr z, .check_arena_hp + jr z, .skip_subtracting_score ld a, 5 call SubFromAIScore jr .check_defending_can_ko -; lower AI score if poison/double poison -; will KO Pokémon between turns -; or if the defending Pokémon can KO -.check_arena_hp +.skip_subtracting_score ld a, 4 call AddToAIScore +; lower AI score if poison/double poison +; will KO Pokémon between turns +; or if the defending Pokémon can KO ld a, DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable call CalculateByteTensDigit cp 3 jr nc, .check_defending_can_ko -; hp < 30 + ; hp < 30 cp 2 jr z, .has_20_hp -; hp = 10 + ; hp = 10 ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and POISONED @@ -4288,11 +4345,12 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) .check_boss_deck call CheckIfNotABossDeckID jr c, .skip_boss_deck + call Func_174f2 ldh a, [hTempPlayAreaLocation_ff9d] ld c, a ld b, $00 - ld hl, wcde4 + ld hl, wPlayAreaEnergyAIScore add hl, bc ld a, [hl] cp $80 @@ -4336,24 +4394,24 @@ AIDecideWhichCardToAttachEnergy: ; 164fc (5:64fc) ; for each card has been calculated. ; now to determine the highest score. call FindPlayAreaCardWithHighestAIScore - jp nc, .asm_1668a + jp nc, .not_found - ld a, [wcdd8] + ld a, [wAIEnergyAttachLogicFlags] or a jr z, .play_card scf - jp Func_164d3 + jp RetrievePlayAreaAIScoreFromBackup1 .play_card call CreateEnergyCardListFromHand jp AITryToPlayEnergyCard -.asm_1668a: ; 1668a (5:668a) - ld a, [wcdd8] +.not_found: ; 1668a (5:668a) + ld a, [wAIEnergyAttachLogicFlags] or a - jr z, .asm_16693 - jp Func_164d3 -.asm_16693 + jr z, .no_carry + jp RetrievePlayAreaAIScoreFromBackup1 +.no_carry or a ret ; 0x16695 @@ -4562,15 +4620,17 @@ DetermineAIScoreOfMoveEnergyRequirement: ; 16695 (5:6695) ; of the card with the highest Play Area AI score, unless ; the highest score is below $85. ; if it succeeds in return a card location, set carry. +; if AI_ENERGY_FLAG_SKIP_ARENA_CARD is set in wAIEnergyAttachLogicFlags +; doesn't include the Arena card and there's no minimum score. FindPlayAreaCardWithHighestAIScore: ; 167b5 (5:67b5) - ld a, [wcdd8] - and $80 - jr nz, .asm_167e1 + ld a, [wAIEnergyAttachLogicFlags] + and AI_ENERGY_FLAG_SKIP_ARENA_CARD + jr nz, .only_bench ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable ld b, a - ld c, 0 ; PLAY_AREA_ARENA + ld c, PLAY_AREA_ARENA ld e, c ld d, c ld hl, wPlayAreaAIScore @@ -4601,7 +4661,7 @@ FindPlayAreaCardWithHighestAIScore: ; 167b5 (5:67b5) ret ; same as above but only check bench Pokémon scores. -.asm_167e1 +.only_bench ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable dec a @@ -4624,6 +4684,7 @@ FindPlayAreaCardWithHighestAIScore: ; 167b5 (5:67b5) dec b jr nz, .loop_2 +; in this case, there is no minimum threshold AI score. ld a, d ldh [hTempPlayAreaLocation_ff9d], a scf @@ -4694,16 +4755,16 @@ GetEnergyCardForDiscardOrEnergyBoostAttack: ; 1683b (5:683b) jr z, .first_attack ; check if second attack is Zapdos2's Thunderbolt, -; Charizard's Fire Spin or Exeggcutor's Big Eggsplosion, +; Charizard's Fire Spin or Exeggutor's Big Eggsplosion, ; for these to be treated differently. ; for both attacks, load its energy cost. ld a, b cp ZAPDOS2 jr z, .zapdos2 cp CHARIZARD - jr z, .charizard_or_exeggcutor + jr z, .charizard_or_exeggutor cp EXEGGUTOR - jr z, .charizard_or_exeggcutor + jr z, .charizard_or_exeggutor ld hl, wLoadedCard2Move2EnergyCost jr .fire .first_attack @@ -4758,9 +4819,9 @@ GetEnergyCardForDiscardOrEnergyBoostAttack: ; 1683b (5:683b) or a ret -; Charizard's Fire Spin and Exeggcutor's Big Eggsplosion, +; Charizard's Fire Spin and Exeggutor's Big Eggsplosion, ; return carry. -.charizard_or_exeggcutor +.charizard_or_exeggutor lb bc, $00, $01 scf ret @@ -5019,11 +5080,13 @@ CheckSpecificDecksToAttachDoubleColorless: ; 1696e (5:696e) ret ; 0x169ca -Func_169ca: ; 169ca (5:69ca) +; have AI choose an attack to use, but do not execute it. +; return carry if an attack is chosen. +AIProcessButDontUseAttack: ; 169ca (5:69ca) ld a, $01 - ld [wcdd9], a + ld [wAIExecuteProcessedAttack], a -; copy wPlayAreaAIScore to wTempPlayAreaAIScore. +; backup wPlayAreaAIScore in wTempPlayAreaAIScore. ld de, wTempPlayAreaAIScore ld hl, wPlayAreaAIScore ld b, MAX_PLAY_AREA_POKEMON @@ -5034,15 +5097,15 @@ Func_169ca: ; 169ca (5:69ca) dec b jr nz, .loop -; copies wAIScore to wcde3 +; copies wAIScore to wTempAIScore ld a, [wAIScore] ld [de], a - jr Func_169fc + jr AIProcessAttacks ; copies wTempPlayAreaAIScore to wPlayAreaAIScore -; and loads wAIscore with value in wcde3. -; identical to Func_164d3. -Func_169e3: ; 169e3 (5:69e3) +; and loads wAIscore with value in wTempAIScore. +; identical to RetrievePlayAreaAIScoreFromBackup1. +RetrievePlayAreaAIScoreFromBackup2: ; 169e3 (5:69e3) push af ld de, wPlayAreaAIScore ld hl, wTempPlayAreaAIScore @@ -5060,12 +5123,18 @@ Func_169e3: ; 169e3 (5:69e3) ret ; 0x169f8 -Func_169f8: ; 169f8 (5:69f8) +; have AI choose and execute an attack. +; return carry if an attack was chosen and attempted. +AIProcessAndTryToUseAttack: ; 169f8 (5:69f8) xor a - ld [wcdd9], a + ld [wAIExecuteProcessedAttack], a ; fallthrough -Func_169fc: ; 169fc (5:69fc) +; checks which of the Active card's attacks for AI to use. +; If any of the attacks has enough AI score to be used, +; AI will use it if wAIExecuteProcessedAttack is 0. +; in either case, return carry if an attack is chosen to be used. +AIProcessAttacks: ; 169fc (5:69fc) ; if AI used Pluspower, load its attack index ld a, [wPreviousAIFlags] and AI_FLAG_USED_PLUSPOWER @@ -5077,23 +5146,23 @@ Func_169fc: ; 169fc (5:69fc) .no_pluspower ld a, [wcda7] cp $80 - jp z, .asm_16a77 + jp z, .dont_attack ; determine AI score of both attacks. xor a ; FIRST_ATTACK_OR_PKMN_POWER call GetAIScoreOfAttack ld a, [wAIScore] - ld [wPlayAreaAIScore], a + ld [wFirstAttackAIScore], a ld a, SECOND_ATTACK call GetAIScoreOfAttack ; compare both attack scores ld c, SECOND_ATTACK - ld a, [wPlayAreaAIScore] + ld a, [wFirstAttackAIScore] ld b, a ld a, [wAIScore] cp b - jr nc, .asm_16a30 + jr nc, .check_score ; first attack has higher score dec c ld a, b @@ -5103,9 +5172,9 @@ Func_169fc: ; 169fc (5:69fc) ; first check if chosen attack has at least minimum score. ; then check if first attack is better than second attack ; in case the second one was chosen. -.asm_16a30 +.check_score cp $50 ; minimum score to use attack - jr c, .asm_16a77 + jr c, .dont_attack ; enough score, proceed ld a, c @@ -5115,14 +5184,18 @@ Func_169fc: ; 169fc (5:69fc) call CheckWhetherToSwitchToFirstAttack .attack_chosen - ld a, [wcdd9] +; check whether to execute the attack chosen + ld a, [wAIExecuteProcessedAttack] or a - jr z, .asm_16a48 + jr z, .execute + +; set carry and reset Play Area AI score +; to the previous values. scf - jp Func_169e3 + jp RetrievePlayAreaAIScoreFromBackup2 -.asm_16a48 - ld a, $0e +.execute + ld a, AI_TRAINER_CARD_PHASE_14 call AIProcessHandTrainerCards ; load this attack's damage output against @@ -5134,39 +5207,52 @@ Func_169fc: ; 169fc (5:69fc) ld a, [wDamage] or a - jr z, .asm_16a62 - ; if damage is 0, fallthrough + jr z, .check_damage_bench + ; if damage is not 0, fallthrough -.cannot_damage +.can_damage xor a ld [wcdb4], a - jr .asm_16a6d + jr .use_attack -.asm_16a62 +.check_damage_bench +; check if it can otherwise damage player's bench ld a, MOVE_FLAG1_ADDRESS | DAMAGE_TO_OPPONENT_BENCH_F call CheckLoadedMoveFlag - jr c, .cannot_damage + jr c, .can_damage + +; cannot damage either Defending Pokemon or Bench ld hl, wcdb4 inc [hl] -.asm_16a6d + +; return carry if attack is chosen +; and AI tries to use it. +.use_attack ld a, $01 ld [wcddb], a - call Func_14145 + call AITryUseAttack scf ret -.asm_16a77 - ld a, [wcdd9] + +.dont_attack + ld a, [wAIExecuteProcessedAttack] or a - jr z, .asm_16a80 - jp Func_169e3 -.asm_16a80 + jr z, .failed_to_use + +; reset Play Area AI score +; to the previous values. + jp RetrievePlayAreaAIScoreFromBackup2 + +; return no carry if no viable attack. +.failed_to_use ld hl, wcdb4 inc [hl] or a ret ; 0x16a86 -; determines the AI score of attack index in a. +; determines the AI score of attack index in a +; of card in Play Area location hTempPlayAreaLocation_ff9d. GetAIScoreOfAttack: ; 16a86 (5:6a86) ; initialize AI score. ld [wSelectedAttack], a @@ -5737,7 +5823,7 @@ HandleSpecialAIMoves: ; 16dcd (5:6dcd) cp BELLSPROUT jr z, HandleCallForFamily cp EXEGGUTOR - jp z, HandleExeggcutorTeleport + jp z, HandleExeggutorTeleport cp SCYTHER jp z, HandleSwordsDanceAndFocusEnergy cp KRABBY @@ -5864,7 +5950,7 @@ HandleJigglypuff2FriendshipSong: ; 16ead (5:6ead) ret ; if AI decides to retreat, return a score of $80 + 10. -HandleExeggcutorTeleport: ; 16ec2 (5:6ec2) +HandleExeggutorTeleport: ; 16ec2 (5:6ec2) call AIDecideWhetherToRetreat jp nc, HandleSpecialAIMoves.zero ld a, $8a @@ -5942,14 +6028,14 @@ HandlePorygonConversion: ; 16f18 (5:6f18) jr nz, .conversion_2 ; conversion 1 - call CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove + call CountNumberOfSetUpBenchPokemon cp 2 jr c, .low_score ld a, $82 ret .conversion_2 - call CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove + call CountNumberOfSetUpBenchPokemon cp 2 jr nc, .low_score ld a, $82 @@ -6097,7 +6183,7 @@ HandleElectrode1EnergySpike: ; 16ff2 (5:6ff2) ld e, LIGHTNING_ENERGY call CheckIfAnyCardIDinLocation jp nc, HandleSpecialAIMoves.zero - call Func_164a1 + call AIProcessButDontPlayEnergy_SkipEvolution jp nc, HandleSpecialAIMoves.zero ld a, $83 ret @@ -6125,7 +6211,7 @@ HandleHyperBeam: ; 17005 (5:7005) CheckWhetherToSwitchToFirstAttack: ; 17019 (5:7019) ; this checks whether the first attack is also viable ; (has more than minimum score to be used) - ld a, [wPlayAreaAIScore] + ld a, [wFirstAttackAIScore] cp $50 jr c, .keep_second_attack @@ -6209,7 +6295,7 @@ CheckIfAnyBasicPokemonInDeck: ; 17057 (5:7057) ; return carry and that card's Play Area location in a. ; output: ; a = card location of Pokémon card, if found; -; cerry set if such a card is found. +; carry set if such a card is found. LookForCardThatIsKnockedOutOnDevolution: ; 17080 (5:7080) ldh a, [hTempPlayAreaLocation_ff9d] push af @@ -6307,15 +6393,16 @@ CheckIfArenaCardIsAtHalfHPCanEvolveAndUseSecondMove: ; 170c9 (5:70c9) ret ; 0x17101 -; returns carry if at least one Pokémon in bench -; meets the following conditions: -; - card HP >= half max HP +; count Pokemon in the Bench that +; meet the following conditions: +; - card HP > half max HP ; - card Unknown2's 4 bit is not set or ; is set but there's no evolution of card in hand/deck ; - card can use second move -; Also outputs the number of Pokémon in bench +; Outputs the number of Pokémon in bench ; that meet these requirements in a -CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove: ; 17101 (5:7101) +; and returns carry if at least one is found +CountNumberOfSetUpBenchPokemon: ; 17101 (5:7101) ldh a, [hTempPlayAreaLocation_ff9d] ld d, a ld a, [wSelectedAttack] @@ -6333,17 +6420,24 @@ CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove: ; 17101 (5:7101) push hl cp $ff jr z, .done + ld d, a push de push bc call LoadCardDataToBuffer1_FromDeckIndex pop bc + +; compares card's current HP with max HP ld a, c add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable ld d, a ld a, [wLoadedCard1HP] rrca + +; a = max HP / 2 +; d = current HP +; jumps if (current HP) <= (max HP / 2) cp d pop de jr nc, .next @@ -6386,8 +6480,138 @@ CheckIfBenchCardsAreAtHalfHPCanEvolveAndUseSecondMove: ; 17101 (5:7101) ret ; 0x17161 -Func_17161 ; 17161 (5:7161) - INCROM $17161, $171fb +; handles AI logic to determine some selections regarding certain attacks, +; if any of these attacks were chosen to be used. +; returns carry if selection was successful, +; and no carry if unable to make one. +; outputs in hTempPlayAreaLocation_ffa1 the chosen parameter. +AISelectSpecialAttackParameters: ; 17161 (5:7161) + ld a, [wSelectedAttack] + push af + call .SelectAttackParameters + pop bc + ld a, b + ld [wSelectedAttack], a + ret +; 0x1716e + +.SelectAttackParameters: ; 1716e (5:716e) + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, e + cp MEW3 + jr z, .devolution_beam + cp MEWTWO3 + jr z, .energy_absorption + cp MEWTWO2 + jr z, .energy_absorption + cp EXEGGUTOR + jr z, .teleport + cp ELECTRODE1 + jr z, .energy_spike + ; fallthrough + +.no_carry + or a + ret + +.devolution_beam +; in case selected attack is Devolution Beam +; store in hTempPlayAreaLocation_ffa1 +; the location of card to select to devolve + ld a, [wSelectedAttack] + or a + jp z, .no_carry ; can be jr + + ld a, $01 + ldh [hTemp_ffa0], a + call LookForCardThatIsKnockedOutOnDevolution + ldh [hTempPlayAreaLocation_ffa1], a + +.set_carry_1 + scf + ret + +.energy_absorption +; in case selected attack is Energy Absorption +; make list from energy cards in Discard Pile + ld a, [wSelectedAttack] + or a + jp nz, .no_carry ; can be jr + + ld a, $ff + ldh [hTempPlayAreaLocation_ffa1], a + ldh [hTempRetreatCostCards], a + +; search for Psychic energy cards in Discard Pile + ld e, PSYCHIC_ENERGY + ld a, CARD_LOCATION_DISCARD_PILE + call CheckIfAnyCardIDinLocation + ldh [hTemp_ffa0], a + farcall CreateEnergyCardListFromOpponentDiscardPile + +; find any energy card different from +; the one found by CheckIfAnyCardIDinLocation. +; since using this move requires a Psychic energy card, +; and another one is in hTemp_ffa0, +; then any other energy card would account +; for the Energy Cost of Psyburn. + ld hl, wDuelTempList +.loop_energy_cards + ld a, [hli] + cp $ff + jr z, .set_carry_2 + ld b, a + ldh a, [hTemp_ffa0] + cp b + jr z, .loop_energy_cards ; same card, keep looking + +; store the deck index of energy card found + ld a, b + ldh [hTempPlayAreaLocation_ffa1], a + ; fallthrough + +.set_carry_2 + scf + ret + +.teleport +; in case selected attack is Teleport +; decide Bench card to switch to. + ld a, [wSelectedAttack] + or a + jp nz, .no_carry ; can be jr + call AIDecideBenchPokemonToSwitchTo + jr c, .no_carry + ldh [hTemp_ffa0], a + scf + ret + +.energy_spike +; in case selected attack is Energy Spike +; decide basic energy card to fetch from Deck. + ld a, [wSelectedAttack] + or a + jp z, .no_carry ; can be jr + + ld a, CARD_LOCATION_DECK + ld e, LIGHTNING_ENERGY + +; if none were found in Deck, return carry... + call CheckIfAnyCardIDinLocation + ldh [hTemp_ffa0], a + jp nc, .no_carry ; can be jr + +; ...else find a suitable Play Area Pokemon to +; attach the energy card to. + call AIProcessButDontPlayEnergy_SkipEvolution + jp nc, .no_carry ; can be jr + ldh a, [hTempPlayAreaLocation_ff9d] + ldh [hTempPlayAreaLocation_ffa1], a + scf + ret +; 0x171fb ; return carry if Pokémon at play area location ; in hTempPlayAreaLocation_ff9d does not have @@ -6591,7 +6815,7 @@ CheckIfCanDamageDefendingPokemon: ; 17383 (5:7383) ; sets carry if any on the moves knocks out ; also outputs the largest damage dealt in a ; input: -; [hTempPlayAreaLocation_ff9d] = locaion of card to check +; [hTempPlayAreaLocation_ff9d] = location of card to check ; output: ; a = largest damage of both moves ; carry set if can knock out @@ -6825,7 +7049,7 @@ CheckForBenchIDAtHalfHPAndCanUseSecondMove: ; 17474 (5:7474) ret ; 0x174cd -; add 5 to wcde4 AI score corresponding to all cards +; add 5 to wPlayAreaEnergyAIScore AI score corresponding to all cards ; in bench that have same ID as register a ; input: ; a = card ID to look for @@ -6848,7 +7072,7 @@ RaiseAIScoreToAllMatchingIDsInBench: ; 174cd (5:74cd) ld c, e ld b, $00 push hl - ld hl, wcde4 + ld hl, wPlayAreaEnergyAIScore add hl, bc ld a, 5 add [hl] @@ -6860,8 +7084,8 @@ RaiseAIScoreToAllMatchingIDsInBench: ; 174cd (5:74cd) ; goes through each play area Pokémon, and ; for all cards of the same ID, determine which ; card has highest value calculated from Func_17583 -; the card with highest value gets increased wcde4 -; while all others get decreased wcde4 +; the card with highest value gets increased wPlayAreaEnergyAIScore +; while all others get decreased wPlayAreaEnergyAIScore Func_174f2: ; 174f2 (5:74f2) ld a, MAX_PLAY_AREA_POKEMON ld hl, wcdfa @@ -6880,6 +7104,7 @@ Func_174f2: ; 174f2 (5:74f2) ld a, [hli] cp $ff ret z + ld [wcdf9], a push de push hl @@ -6945,11 +7170,11 @@ Func_174f2: ; 174f2 (5:74f2) jr .loop_2 ; c = play area location of highest score -; decrease wcde4 score for all cards with same ID +; decrease wPlayAreaEnergyAIScore score for all cards with same ID ; except for the one with highest score -; increase wcde4 score for card with highest ID +; increase wPlayAreaEnergyAIScore score for card with highest ID .asm_17560 - ld hl, wcde4 + ld hl, wPlayAreaEnergyAIScore ld de, wcdea ld b, PLAY_AREA_ARENA .loop_3 diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 5a0f535..6850b82 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -6219,8 +6219,449 @@ AIDecide_PokemonTrader_Flamethrower: ; 22133 (8:6133) ret ; 0x2219b -Func_2219b: ; 2219b (8:219b) - INCROM $2219b, $227f6 +; handle AI routines for Energy Trans. +; depending on input, AI can use Energy Trans to +; give Arena or Bench cards some Grass energy cards, +; depending whether it's for attack, retreat, etc. +HandleAIEnergyTrans: ; 2219b (8:619b) + ld [wce06], a + +; choose to randomly return + farcall ChooseRandomlyNotToPlayTrainerCard + ret c + + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + dec a + ret z ; return if no Bench cards + + ld a, VENUSAUR2 + call CountPokemonIDInPlayArea + ret nc ; return if no Venusaur2 found in own Play Area + + ld a, MUK + call CountPokemonIDInBothPlayAreas + ret c ; return if Muk found in any Play Area + + ld a, [wce06] + cp $09 + jr z, .check_retreat + + cp $0e + jp z, .TransferEnergyToBench + + call .CheckEnoughGrassEnergyCardsForAttack + ret nc + jr .TransferEnergyToArena + +.check_retreat + call .CheckEnoughGrassEnergyCardsForRetreatCost + ret nc + +; use Energy Trans to transfer number of Grass energy cards +; equal to input a from the Bench to the Arena card. +.TransferEnergyToArena + ld [wAINumberOfEnergyTransCards], a + +; look for Venusaur2 in Play Area +; so that its PKMN Power can be used. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + dec a + ld b, a +.loop_play_area_1 + ld a, DUELVARS_ARENA_CARD + add b + call GetTurnDuelistVariable + ldh [hTempCardIndex_ff9f], a + call GetCardIDFromDeckIndex + ld a, e + cp VENUSAUR2 + jr z, .use_pkmn_power_1 + + ld a, b + or a + ret z ; return when finished Play Area loop + + dec b + jr .loop_play_area_1 + +; use Energy Trans Pkmn Power +.use_pkmn_power_1 + ld a, b + ldh [hTemp_ffa0], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + + xor a ; PLAY_AREA_ARENA + ldh [hAIEnergyTransPlayAreaLocation], a + ld a, [wAINumberOfEnergyTransCards] + ld d, a + +; look for Grass energy cards that +; are currently attached to a Bench card. + ld e, 0 +.loop_deck_locations_1 + ld a, DUELVARS_CARD_LOCATIONS + add e + call GetTurnDuelistVariable + and %00011111 + cp CARD_LOCATION_BENCH_1 + jr c, .next_card_1 + + and %00001111 + ldh [hTempPlayAreaLocation_ffa1], a + + ld a, e + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + cp GRASS_ENERGY + jr nz, .next_card_1 + + ; store the deck index of energy card + ld a, e + ldh [hAIEnergyTransEnergyCard], a + + push de + ld d, 30 +.small_delay_1 + call DoFrame + dec d + jr nz, .small_delay_1 + + ld a, OPPACTION_6B15 + bank1call AIMakeDecision + pop de + dec d + jr z, .done_transfer_1 + +.next_card_1 + inc e + ld a, DECK_SIZE + cp e + jr nz, .loop_deck_locations_1 + +; transfer is done, perform delay +; and return to main scene. +.done_transfer_1 + ld d, 60 +.big_delay_1 + call DoFrame + dec d + jr nz, .big_delay_1 + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x22246 + +; checks if the Arena card has not enough energy for second attack, +; and if not, return carry if transferring Grass energy from Bench +; would be enough to use it and outputs number of energy cards needed in a. +.CheckEnoughGrassEnergyCardsForAttack ; 22246 (8:6246) + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, e + cp EXEGGUTOR + jr z, .is_exeggutor + + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + ld a, SECOND_ATTACK + ld [wSelectedAttack], a + farcall CheckEnergyNeededForAttack + jr nc, .attack_false ; return if no energy needed + +; check if colorless energy is needed... + ld a, c + or a + jr nz, .count_if_enough + +; ...otherwise check if basic energy card is needed +; and it's grass energy. + ld a, b + or a + jr z, .attack_false + ld a, e + cp GRASS_ENERGY + jr nz, .attack_false + ld c, b + jr .count_if_enough + +.attack_false + or a + ret + +.count_if_enough +; if there's enough Grass energy cards in Bench +; to satisfy the attack energy cost, return carry. + push bc + call .CountGrassEnergyInBench + pop bc + cp c + jr c, .attack_false + ld a, c + scf + ret + +.is_exeggutor +; in case it's Exeggutor in Arena, return carry +; if there are any Grass energy cards in Bench. + call .CountGrassEnergyInBench + or a + jr z, .attack_false + + scf + ret +; 0x22286 + +; outputs in a the number of Grass energy cards +; currently attached to Bench cards. +.CountGrassEnergyInBench ; 22286 (8:6286) + lb de, 0, 0 +.count_loop + ld a, DUELVARS_CARD_LOCATIONS + add e + call GetTurnDuelistVariable + and %00011111 + cp CARD_LOCATION_BENCH_1 + jr c, .count_next + +; is in bench + ld a, e + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + cp GRASS_ENERGY + jr nz, .count_next + inc d +.count_next + inc e + ld a, DECK_SIZE + cp e + jr nz, .count_loop + ld a, d + ret +; 0x222a9 + +; returns carry if there are enough Grass energy cards in Bench +; to satisfy the retreat cost of the Arena card. +; if so, output the number of energy cards still needed in a. +.CheckEnoughGrassEnergyCardsForRetreatCost ; 222a9 (8:62a9) + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call GetPlayAreaCardRetreatCost + ld b, a + ld e, PLAY_AREA_ARENA + farcall CountNumberOfEnergyCardsAttached + cp b + jr nc, .retreat_false ; return if enough to retreat + +; see if there's enough Grass energy cards +; in the Bench to satisfy retreat cost + ld c, a + ld a, b + sub c + ld c, a + push bc + call .CountGrassEnergyInBench + pop bc + cp c + jr c, .retreat_false ; return if less cards than needed + +; output number of cards needed to retreat + ld a, c + scf + ret +.retreat_false + or a + ret +; 0x222ca + +; AI logic to determine whether to use Energy Trans Pkmn Power +; to transfer energy cards attached from the Arena Pokemon to +; some card in the Bench. +.TransferEnergyToBench ; 222ca (8:62ca) + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + farcall CheckIfDefendingPokemonCanKnockOut + ret nc ; return if Defending can't KO + +; processes attacks and see if any attack would be used by AI. +; if so, return. + farcall AIProcessButDontUseAttack + ret c + +; return if Arena card has no Grass energy cards attached. + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + GRASS] + or a + ret z + +; if no energy card attachment is needed, return. + farcall AIProcessButDontPlayEnergy_SkipEvolutionAndArena + ret nc + +; AI decided that an energy card is needed +; so look for Venusaur2 in Play Area +; so that its PKMN Power can be used. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + dec a + ld b, a +.loop_play_area_2 + ld a, DUELVARS_ARENA_CARD + add b + call GetTurnDuelistVariable + ldh [hTempCardIndex_ff9f], a + ld [wAIVenusaur2DeckIndex], a + call GetCardIDFromDeckIndex + ld a, e + cp VENUSAUR2 + jr z, .use_pkmn_power_2 + + ld a, b + or a + ret z ; return when Play Area loop is ended + + dec b + jr .loop_play_area_2 + +; use Energy Trans Pkmn Power +.use_pkmn_power_2 + ld a, b + ldh [hTemp_ffa0], a + ld [wAIVenusaur2PlayAreaLocation], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + +; loop for each energy cards that are going to be transferred. +.loop_energy + xor a + ldh [hTempPlayAreaLocation_ffa1], a + ld a, [wAIVenusaur2PlayAreaLocation] + ldh [hTemp_ffa0], a + + ; returns when Arena card has no Grass energy cards attached. + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + GRASS] + or a + jr z, .done_transfer_2 + +; look for Grass energy cards that +; are currently attached to Arena card. + ld e, 0 +.loop_deck_locations_2 + ld a, DUELVARS_CARD_LOCATIONS + add e + call GetTurnDuelistVariable + cp CARD_LOCATION_ARENA + jr nz, .next_card_2 + + ld a, e + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + cp GRASS_ENERGY + jr nz, .next_card_2 + + ; store the deck index of energy card + ld a, e + ldh [hAIEnergyTransEnergyCard], a + jr .transfer + +.next_card_2 + inc e + ld a, DECK_SIZE + cp e + jr nz, .loop_deck_locations_2 + jr .done_transfer_2 + +.transfer +; get the Bench card location to transfer Grass energy card to. + farcall AIProcessButDontPlayEnergy_SkipEvolutionAndArena + jr nc, .done_transfer_2 + ldh a, [hTempPlayAreaLocation_ff9d] + ldh [hAIEnergyTransPlayAreaLocation], a + + ld d, 30 +.small_delay_2 + call DoFrame + dec d + jr nz, .small_delay_2 + + ld a, [wAIVenusaur2DeckIndex] + ldh [hTempCardIndex_ff9f], a + ld d, a + ld e, FIRST_ATTACK_OR_PKMN_POWER + call CopyMoveDataAndDamage_FromDeckIndex + ld a, OPPACTION_6B15 + bank1call AIMakeDecision + jr .loop_energy + +; transfer is done, perform delay +; and return to main scene. +.done_transfer_2 + ld d, 60 +.big_delay_2 + call DoFrame + dec d + jr nz, .big_delay_2 + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x2237f + +Func_2237f: ; 2237f (8:237f) + INCROM $2237f, $2262d + +Func_2262d: ; 2262d (8:262d) + INCROM $2262d, $226a3 + +Func_226a3: ; 226a3 (8:26a3) + INCROM $226a3, $22790 + +Func_22790: ; 22790 (8:2790) + INCROM $22790, $227d3 + +; checks wcda7 and Pokemon in Play Area that are set up. +; if there's at least 4, goes to AI_TRAINER_CARD_PHASE_05. +; else, returns carry. +Func_227d3: ; 227d3 (8:67d3) + ld a, [wcda7] + bit 7, a + jr z, .set_carry + cp %10000010 + jr c, .asm_227e4 + + xor a + ld [wcda7], a + jr .set_carry + +.asm_227e4 + farcall CountNumberOfSetUpBenchPokemon + cp 4 + jr c, .set_carry + + ld a, AI_TRAINER_CARD_PHASE_05 + farcall AIProcessHandTrainerCards + or a + ret + +.set_carry + scf + ret +; 0x227f6 ; lists in wDuelTempList all the basic energy cards ; in card location of a. @@ -7128,7 +7569,7 @@ FindDuplicatePokemonCards: ; 22b6f (8:6b6f) ; return carry flag if move is not high recoil. Func_22bad: ; 22bad (8:6bad) - farcall Func_169ca + farcall AIProcessButDontUseAttack ret nc ld a, [wSelectedAttack] ld e, a diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 8832134..dbda9ad 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -292,7 +292,9 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149) ret ; 0x2c166 -Func_2c166: ; 2c166 (b:4166) +; overwrites in wDamage, wAIMinDamage and wAIMaxDamage +; with the value in a. +StoreDamageInfo: ; 2c166 (b:4166) ld [wDamage], a ld [wAIMinDamage], a ld [wAIMaxDamage], a @@ -348,7 +350,77 @@ HandleSwitchDefendingPokemonEffect: ; 2c1ec (b:41ec) ret ; 0x2c221 - INCROM $2c221, $2c487 + INCROM $2c221, $2c2a4 + +; makes a list in wDuelTempList with the deck indices +; of all the energy cards found in opponent's Discard Pile. +; if (c == 0), all energy cards are allowed; +; if (c != 0), double colorless energy cards are not counted. +; returns carry if no energy cards were found. +CreateEnergyCardListFromOpponentDiscardPile: ; 2c2a4 (b:42a4) + ld c, $00 + +; get number of cards in Discard Pile +; and have hl point to the end of the +; Discard Pile list in wOpponentDeckCards. + ld a, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE + call GetTurnDuelistVariable + ld b, a + add DUELVARS_DECK_CARDS + ld l, a + + ld de, wDuelTempList + inc b + jr .next_card + +.check_energy + ld a, [hl] + call LoadCardDataToBuffer2_FromDeckIndex + ld a, [wLoadedCard2Type] + and TYPE_ENERGY + jr z, .next_card + +; if (c != $00), then we dismiss Double Colorless +; energy cards found. + ld a, c + or a + jr z, .copy + ld a, [wLoadedCard2Type] + cp TYPE_ENERGY_DOUBLE_COLORLESS + jr nc, .next_card + +.copy + ld a, [hl] + ld [de], a + inc de + +; goes through Discard Pile list +; in wOpponentDeckCards in descending order. +.next_card + dec l + dec b + jr nz, .check_energy + +; terminating byte on wDuelTempList + ld a, $ff + ld [de], a + +; check if any energy card was found +; by checking whether the first byte +; in wDuelTempList is $ff. +; if none were found, return carry. + ld a, [wDuelTempList] + cp $ff + jr z, .set_carry + or a + ret + +.set_carry + scf + ret +; 0x2c2e0 + + INCROM $2c2e0, $2c487 ; handles the selection of a forced switch ; by link/AI opponent or by the player. @@ -558,7 +630,7 @@ Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) add a add e call ATimes10 - call Func_2c166 + call StoreDamageInfo ret ; 0x2c80d @@ -679,4 +751,16 @@ Toxic_DoublePoisonEffect: ; 2c994 (b:4994) ret ; 0x2c998 - INCROM $2c998, $30000 \ No newline at end of file + INCROM $2c998, $2cbfb + +Func_2cbfb: ; 2cbfb (b:4bfb) + ldh a, [hAIEnergyTransPlayAreaLocation] + ld e, a + ldh a, [hAIEnergyTransEnergyCard] + call AddCardToHand + call PutHandCardInPlayArea + bank1call PrintPlayAreaCardList_EnableLCD + ret +; 0x2cc0a + + INCROM $2cc0a, $30000 \ No newline at end of file diff --git a/src/engine/home.asm b/src/engine/home.asm index 4f9fc31..338dbb0 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -5218,7 +5218,7 @@ Func_1bca: ; 1bca (0:1bca) ret ; 0x1c05 -; return in a the retreat cost of the turn holder's arena or benchx Pokemon +; return in a the retreat cost of the turn holder's arena or bench Pokemon ; given the PLAY_AREA_* value in hTempPlayAreaLocation_ff9d GetPlayAreaCardRetreatCost: ; 1c05 (0:1c05) ldh a, [hTempPlayAreaLocation_ff9d] diff --git a/src/hram.asm b/src/hram.asm index 9cdba06..2b4fbc9 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -85,10 +85,24 @@ hTemp_ffa0:: ; ffa0 hTempPlayAreaLocation_ffa1:: ; ffa1 ds $1 +UNION + ; $ff-terminated list of cards to be discarded upon retreat hTempRetreatCostCards:: ; ffa2 ds $6 +NEXTU + +; parameters chosen by AI in Energy Trans routine. +; the deck index (0-59) of the energy card to transfer +; and the Play Area location (PLAY_AREA_*) of card to receive that energy card. +hAIEnergyTransEnergyCard:: ; ffa2 + ds $1 +hAIEnergyTransPlayAreaLocation:: ; ffa3 + ds $1 + +ENDU + ; hffa8 through hffb0 belong to the text engine hffa8:: ; ffa8 ds $1 diff --git a/src/wram.asm b/src/wram.asm index e5fc9c6..2a10fe2 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1230,11 +1230,21 @@ wTempCardType:: ; cdba wAIScore:: ; cdbe ds $1 +UNION + ; used for AI decisions that involve ; each card in the Play Area. wPlayAreaAIScore:: ; cdbf ds MAX_PLAY_AREA_POKEMON +NEXTU + +; stores the score determined by AI for first attack +wFirstAttackAIScore:: ; cdbf + ds $1 + +ENDU + ds $0a ; information about the defending Pokémon and @@ -1274,10 +1284,16 @@ wAIPluspowerAttack:: ; cdd6 wAIPlayEnergyCardForRetreat:: ; cdd7 ds $1 -wcdd8:: ; cdd8 +; flags defined by AI_ENERGY_FLAG_* constants +; used as input for AIProcessEnergyCards +; to determine what to check in the routine. +wAIEnergyAttachLogicFlags:: ; cdd8 ds $1 -wcdd9:: ; cdd9 +; used as input to AIProcessAttacks. +; if 0, execute the attack chosen by the AI. +; if not 0, return without executing attack. +wAIExecuteProcessedAttack:: ; cdd9 ds $1 wcdda:: ; cdda @@ -1289,15 +1305,17 @@ wcddb:: ; cddb wcddc:: ; cddc ds $1 -; used to compliment wPlayAreaAIScore, -; to temporarily do calculations and store results. +; used to temporarily backup wPlayAreaAIScore values. wTempPlayAreaAIScore:: ; cddd ds MAX_PLAY_AREA_POKEMON -wcde3:: ; cde3 +wTempAIScore:: ; cde3 ds $1 -wcde4:: ; cde4 +; used for AI decisions that involve +; each card in the Play Area involving +; attaching Energy cards. +wPlayAreaEnergyAIScore:: ; cde4 ds MAX_PLAY_AREA_POKEMON wcdea:: ; cdea @@ -1355,8 +1373,15 @@ wAIMoveIsNonDamaging:: ; ce02 wce03:: ; ce03 ds $1 - ds $2 +; used by AI to store information of Venusaur2 +; while handling Energy Trans logic. +wAIVenusaur2DeckIndex:: ; ce04 + ds $1 +wAIVenusaur2PlayAreaLocation:: ; ce05 + ds $1 +; number of cards to be transferred by AI using Energy Trans. +wAINumberOfEnergyTransCards:: wce06:: ; ce06 ds $1 -- cgit v1.2.3 From ee139f3840b69878ca57acb2a2ecbd72a4375fc8 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 29 Apr 2020 09:47:16 +0100 Subject: Disassemble AI Pkmn Power routine --- src/engine/bank05.asm | 50 ++++--- src/engine/bank08.asm | 363 +++++++++++++++++++++++++++++++++++++++++++++++--- src/wram.asm | 2 +- 3 files changed, 376 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index ba0a565..1118699 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1216,8 +1216,8 @@ Func_1468b: ; 1468b (5:468b) farcall Func_227d3 jp nc, .asm_14776 - farcall Func_22790 - farcall Func_226a3 + farcall HandleAIGoGoRainDanceEnergy + farcall HandleAIDamageSwap farcall Func_2237f ret c @@ -1253,10 +1253,10 @@ Func_1468b: ; 1468b (5:468b) call AIProcessAndTryToPlayEnergy .asm_146ed call AIDecidePlayPokemonCard - farcall Func_226a3 + farcall HandleAIDamageSwap farcall Func_2237f ret c - farcall Func_22790 + farcall HandleAIGoGoRainDanceEnergy ld a, $0d farcall HandleAIEnergyTrans ld a, AI_TRAINER_CARD_PHASE_13 @@ -1297,10 +1297,10 @@ Func_1468b: ; 1468b (5:468b) call AIProcessAndTryToPlayEnergy .asm_1475b call AIDecidePlayPokemonCard - farcall Func_226a3 + farcall HandleAIDamageSwap farcall Func_2237f ret c - farcall Func_22790 + farcall HandleAIGoGoRainDanceEnergy ld a, $0d farcall HandleAIEnergyTrans ld a, AI_TRAINER_CARD_PHASE_13 @@ -1496,15 +1496,19 @@ Func_15636: ; 15636 (5:5636) ld [wcda5], a ret +; initializes some variables and +; sets value of wcda7. Func_15649: ; 15649 (5:5649) ld a, [wcda6] inc a ld [wcda6], a + xor a ld [wPreviousAIFlags], a ld [wcddb], a ld [wcddc], a ld [wce03], a + ld a, [wPlayerAttackingMoveIndex] cp $ff jr z, .asm_156b1 @@ -1513,19 +1517,22 @@ Func_15649: ; 15649 (5:5649) ld a, [wPlayerAttackingCardIndex] cp $ff jr z, .asm_156b1 + call SwapTurn call GetCardIDFromDeckIndex call SwapTurn ld a, e - cp MEWTWO1 ; I believe this is a check for Mewtwo1's Barrier move + cp MEWTWO1 jr nz, .asm_156b1 + +; handle Mewtwo1-only deck ld a, [wcda7] bit 7, a jr nz, .asm_156aa inc a ld [wcda7], a - cp $3 - jr c, .asm_156c2 + cp $03 + jr c, .done ld a, DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable call SwapTurn @@ -1534,18 +1541,17 @@ Func_15649: ; 15649 (5:5649) ld a, e cp MEWTWO1 jr nz, .asm_156a4 - farcall $8, $67a9 + farcall CheckIfPlayerHasPokemonOtherThanMewtwo1 jr nc, .asm_156aa - .asm_156a4 +; reset wcda7 xor a ld [wcda7], a - jr .asm_156c2 - + jr .done .asm_156aa ld a, $80 ld [wcda7], a - jr .asm_156c2 + jr .done .asm_156b1 ld a, [wcda7] @@ -1553,13 +1559,13 @@ Func_15649: ; 15649 (5:5649) jr z, .asm_156be inc a ld [wcda7], a - jr .asm_156c2 + jr .done .asm_156be +; reset wcda7 xor a ld [wcda7], a - -.asm_156c2 +.done ret ; 0x156c3 @@ -4214,12 +4220,14 @@ AIProcessEnergyCards: ; 164fc (5:64fc) ; arena ld a, [wcda7] bit 7, a - jr z, .skip_subtracting_score + jr z, .add_to_score + +; subtract from score ld a, 5 call SubFromAIScore jr .check_defending_can_ko -.skip_subtracting_score +.add_to_score ld a, 4 call AddToAIScore @@ -6937,8 +6945,8 @@ CheckIfNotABossDeckID: ; 17426 (5:7426) ; - 25% for all other decks; ; - 0% for boss decks. ; used for certain decks to randomly choose -; not to play Trainer card in hand. -ChooseRandomlyNotToPlayTrainerCard: ; 1743b (5:743b) +; not to play Trainer card or use PKMN Power +AIChooseRandomlyNotToDoAction: ; 1743b (5:743b) ; boss decks always use Trainer cards. push hl push de diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 6850b82..9ef590b 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -114,7 +114,7 @@ _AIProcessHandTrainerCards: ; 200e5 (8:40e5) jp c, .next_in_data ; AI can randomly choose not to play card. - farcall ChooseRandomlyNotToPlayTrainerCard + farcall AIChooseRandomlyNotToDoAction jr c, .next_in_data ; call routine to decide whether to play Trainer card @@ -6227,7 +6227,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ld [wce06], a ; choose to randomly return - farcall ChooseRandomlyNotToPlayTrainerCard + farcall AIChooseRandomlyNotToDoAction ret c ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -6328,10 +6328,10 @@ HandleAIEnergyTrans: ; 2219b (8:619b) push de ld d, 30 -.small_delay_1 +.small_delay_loop_1 call DoFrame dec d - jr nz, .small_delay_1 + jr nz, .small_delay_loop_1 ld a, OPPACTION_6B15 bank1call AIMakeDecision @@ -6349,10 +6349,10 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; and return to main scene. .done_transfer_1 ld d, 60 -.big_delay_1 +.big_delay_loop_1 call DoFrame dec d - jr nz, .big_delay_1 + jr nz, .big_delay_loop_1 ld a, OPPACTION_DUEL_MAIN_SCENE bank1call AIMakeDecision ret @@ -6595,10 +6595,10 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ldh [hAIEnergyTransPlayAreaLocation], a ld d, 30 -.small_delay_2 +.small_delay_loop_2 call DoFrame dec d - jr nz, .small_delay_2 + jr nz, .small_delay_loop_2 ld a, [wAIVenusaur2DeckIndex] ldh [hTempCardIndex_ff9f], a @@ -6613,26 +6613,354 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; and return to main scene. .done_transfer_2 ld d, 60 -.big_delay_2 +.big_delay_loop_2 call DoFrame dec d - jr nz, .big_delay_2 + jr nz, .big_delay_loop_2 ld a, OPPACTION_DUEL_MAIN_SCENE bank1call AIMakeDecision ret ; 0x2237f -Func_2237f: ; 2237f (8:237f) - INCROM $2237f, $2262d +Func_2237f: ; 2237f (8:637f) + ld a, MUK + call CountPokemonIDInBothPlayAreas + ccf + ret nc ; return no carry if Muk is in play + + farcall AIChooseRandomlyNotToDoAction + ccf + ret nc ; return no carry if AI randomly decides to + + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld b, a + ld c, PLAY_AREA_ARENA + ld a, DUELVARS_ARENA_CARD_STATUS + call GetTurnDuelistVariable + and CNF_SLP_PRZ + jr nz, .next_2 + +.loop_play_area + ld a, DUELVARS_ARENA_CARD + add c + call GetTurnDuelistVariable + ld [wce08], a + + push af + push bc + ld d, a + ld a, c + ldh [hTempPlayAreaLocation_ff9d], a + ld e, FIRST_ATTACK_OR_PKMN_POWER + call CopyMoveDataAndDamage_FromDeckIndex + ld a, [wLoadedMoveCategory] + cp POKEMON_POWER + jr z, .execute_effect + pop bc + jr .next_3 + +.execute_effect + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 + bank1call TryExecuteEffectCommandFunction + pop bc + jr c, .next_3 + +; TryExecuteEffectCommandFunction was successful, +; so check what Pkmn Power this is through card's ID. + pop af + call GetCardIDFromDeckIndex + ld a, e + push bc + +; check heal + cp VILEPLUME + jr nz, .check_shift + call Func_22402 + jr .next_1 +.check_shift + cp VENOMOTH + jr nz, .check_peek + call Func_22476 + jr .next_1 +.check_peek + cp MANKEY + jr nz, .check_strange_behavior + call Func_224e6 + jr .next_1 +.check_strange_behavior + cp SLOWBRO + jr nz, .check_curse + call Func_2255d + jr .next_1 +.check_curse + cp GENGAR + jr nz, .next_1 + call z, Func_225b5 + jr c, .done + +.next_1 + pop bc +.next_2 + inc c + ld a, c + cp b + jr nz, .loop_play_area + ret + +.next_3 + pop af + jr .next_2 -Func_2262d: ; 2262d (8:262d) +.done + pop bc + ret +; 0x22402 + +Func_22402: ; 22402 (8:6402) + INCROM $22402, $22476 + +Func_22476: ; 22476 (8:6476) + INCROM $22476, $224e6 + +Func_224e6: ; 224e6 (8:64e6) + INCROM $224e6, $2255d + +Func_2255d: ; 2255d (8:655d) + INCROM $2255d, $225b5 + +Func_225b5: ; 225b5 (8:65b5) + INCROM $225b5, $2262d + +Func_2262d: ; 2262d (8:662d) INCROM $2262d, $226a3 -Func_226a3: ; 226a3 (8:26a3) - INCROM $226a3, $22790 +; AI logic for Damage Swap to transfer damage from Arena card +; to a card in Bench with more than 10 HP remaining +; and with no energy cards attached. +HandleAIDamageSwap: ; 226a3 (8:66a3) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + dec a + ret z ; return if no Bench Pokemon + + farcall AIChooseRandomlyNotToDoAction + ret c + + ld a, ALAKAZAM + call CountPokemonIDInPlayArea + ret nc ; return if no Alakazam + ld a, MUK + call CountPokemonIDInBothPlayAreas + ret c ; return if there's Muk in play + +; only take damage off certain cards in Arena + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, e + cp ALAKAZAM + jr z, .ok + cp KADABRA + jr z, .ok + cp ABRA + jr z, .ok + cp MR_MIME + ret nz + +.ok + ld e, PLAY_AREA_ARENA + call GetCardDamage + or a + ret z ; return if no damage + + call ConvertHPToCounters + ld [wce06], a + ld a, ALAKAZAM + ld b, PLAY_AREA_BENCH_1 + farcall LookForCardIDInPlayArea_Bank5 + jr c, .is_in_bench + +; Alakazam is Arena card + xor a +.is_in_bench + ld [wce08], a + call .CheckForDamageSwapTargetInBench + ret c ; return if not found + +; use Damage Swap + ld a, [wce08] + add DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ldh [hTempCardIndex_ff9f], a + ld a, [wce08] + ldh [hTemp_ffa0], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision -Func_22790: ; 22790 (8:2790) - INCROM $22790, $227d3 + ld a, [wce06] + ld e, a +.loop_damage + ld d, 30 +.small_delay_loop + call DoFrame + dec d + jr nz, .small_delay_loop + + push de + call .CheckForDamageSwapTargetInBench + jr c, .no_more_target + + ldh [hTempRetreatCostCards], a + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ffa1], a + ld a, OPPACTION_6B15 + bank1call AIMakeDecision + pop de + dec e + jr nz, .loop_damage + +.done + ld d, 60 +.big_delay_loop + call DoFrame + dec d + jr nz, .big_delay_loop + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret + +.no_more_target + pop de + jr .done +; 0x2273c + +; looks for a target in the bench to receive damage counters. +; returns carry if one is found, and outputs remaining HP in a. +.CheckForDamageSwapTargetInBench ; 2273c (8:673c) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld b, a + ld c, PLAY_AREA_BENCH_1 + lb de, $ff, $ff + +; look for candidates in bench to get the damage counters +; only target specific card IDs. +.loop_bench + ld a, c + add DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + cp CHANSEY + jr z, .found_candidate + cp KANGASKHAN + jr z, .found_candidate + cp SNORLAX + jr z, .found_candidate + cp MR_MIME + jr z, .found_candidate + +.next_play_area + inc c + ld a, c + cp b + jr nz, .loop_bench + +; done + ld a, e + cp $ff + jr nz, .no_carry + ld a, d + cp $ff + jr z, .set_carry +.no_carry + or a + ret + +.found_candidate +; found a potential candidate to receive damage counters + ld a, DUELVARS_ARENA_CARD_HP + add c + call GetTurnDuelistVariable + cp 20 + jr c, .next_play_area ; ignore cards with only 10 HP left + + ld d, c ; store damage + push de + push bc + ld e, c + farcall CountNumberOfEnergyCardsAttached + pop bc + pop de + or a + jr nz, .next_play_area ; ignore cards with attached energy + ld e, c ; store deck index + jr .next_play_area + +.set_carry + scf + ret +; 0x22790 + +; handles AI logic for attaching energy cards +; in Go Go Rain Dance deck. +HandleAIGoGoRainDanceEnergy: ; 22790 (8:6790) + ld a, [wOpponentDeckID] + cp GO_GO_RAIN_DANCE_DECK_ID + ret nz ; return if not Go Go Rain Dance deck + + ld a, BLASTOISE + call CountPokemonIDInPlayArea + ret nc ; return if no Blastoise + ld a, MUK + call CountPokemonIDInBothPlayAreas + ret c ; return if there's Muk in play + +; play all the energy cards that is needed. +.loop + farcall AIProcessAndTryToPlayEnergy + jr c, .loop + ret +; 0x227a9 + +; runs through Player's whole deck and +; sets carry if there's any Pokemon other +; than Mewtwo1. +CheckIfPlayerHasPokemonOtherThanMewtwo1: ; 227a9 (8:67a9) + call SwapTurn + ld e, 0 +.loop_deck + ld a, e + push de + call LoadCardDataToBuffer2_FromDeckIndex + pop de + ld a, [wLoadedCard2Type] + cp TYPE_ENERGY + jp nc, .next ; can be a jr + ld a, [wLoadedCard2ID] + cp MEWTWO1 + jr nz, .not_mewtwo1 +.next + inc e + ld a, DECK_SIZE + cp e + jr nz, .loop_deck + +; no carry + call SwapTurn + or a + ret + +.not_mewtwo1 + call SwapTurn + scf + ret +; 0x227d3 ; checks wcda7 and Pokemon in Play Area that are set up. ; if there's at least 4, goes to AI_TRAINER_CARD_PHASE_05. @@ -6644,6 +6972,7 @@ Func_227d3: ; 227d3 (8:67d3) cp %10000010 jr c, .asm_227e4 +; reset wcda7 xor a ld [wcda7], a jr .set_carry diff --git a/src/wram.asm b/src/wram.asm index 2a10fe2..9c20732 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1380,9 +1380,9 @@ wAIVenusaur2DeckIndex:: ; ce04 wAIVenusaur2PlayAreaLocation:: ; ce05 ds $1 +wce06:: ; ce06 ; number of cards to be transferred by AI using Energy Trans. wAINumberOfEnergyTransCards:: -wce06:: ; ce06 ds $1 wce07:: ; ce07 -- cgit v1.2.3 From d53e2db59a1562abf1b198602123672becfccda8 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 29 Apr 2020 16:43:44 +0100 Subject: Disassemble AI Pkmn Power routines --- src/engine/bank05.asm | 6 +- src/engine/bank08.asm | 472 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/engine/home.asm | 1 + src/hram.asm | 9 + src/wram.asm | 3 + 5 files changed, 471 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 1118699..349e7d3 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1218,7 +1218,7 @@ Func_1468b: ; 1468b (5:468b) farcall HandleAIGoGoRainDanceEnergy farcall HandleAIDamageSwap - farcall Func_2237f + farcall HandleAIPkmnPowers ret c farcall Func_2262d @@ -1254,7 +1254,7 @@ Func_1468b: ; 1468b (5:468b) .asm_146ed call AIDecidePlayPokemonCard farcall HandleAIDamageSwap - farcall Func_2237f + farcall HandleAIPkmnPowers ret c farcall HandleAIGoGoRainDanceEnergy ld a, $0d @@ -1298,7 +1298,7 @@ Func_1468b: ; 1468b (5:468b) .asm_1475b call AIDecidePlayPokemonCard farcall HandleAIDamageSwap - farcall Func_2237f + farcall HandleAIPkmnPowers ret c farcall HandleAIGoGoRainDanceEnergy ld a, $0d diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 9ef590b..b5a794b 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -6622,7 +6622,14 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ret ; 0x2237f -Func_2237f: ; 2237f (8:637f) +; handles AI logic for using some Pkmn Powers. +; Pkmn Powers handled here are: +; - Heal; +; - Shift; +; - Peek; +; - Strange Behavior; +; - Curse. +HandleAIPkmnPowers: ; 2237f (8:637f) ld a, MUK call CountPokemonIDInBothPlayAreas ccf @@ -6676,27 +6683,27 @@ Func_2237f: ; 2237f (8:637f) ; check heal cp VILEPLUME jr nz, .check_shift - call Func_22402 + call HandleAIHeal jr .next_1 .check_shift cp VENOMOTH jr nz, .check_peek - call Func_22476 + call HandleAIShift jr .next_1 .check_peek cp MANKEY jr nz, .check_strange_behavior - call Func_224e6 + call HandleAIPeek jr .next_1 .check_strange_behavior cp SLOWBRO jr nz, .check_curse - call Func_2255d + call HandleAIStrangeBehavior jr .next_1 .check_curse cp GENGAR jr nz, .next_1 - call z, Func_225b5 + call z, HandleAICurse jr c, .done .next_1 @@ -6717,20 +6724,450 @@ Func_2237f: ; 2237f (8:637f) ret ; 0x22402 -Func_22402: ; 22402 (8:6402) - INCROM $22402, $22476 +; checks whether AI uses Heal on Pokemon in Play Area. +; input: +; c = Play Area location (PLAY_AREA_*) of Vileplume. +HandleAIHeal: ; 22402 (8:6402) + ld a, c + ldh [hTemp_ffa0], a + call .CheckHealTarget + ret nc ; return if no target to heal + push af + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + pop af + ldh [hAIHealCard], a + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x22422 + +; finds a target suitable for AI to use Heal on. +; only heals Arena card if the Defending Pokemon +; cannot KO it after Heal is used. +; returns carry if target was found and outputs +; in a the Play Area location of that card. +.CheckHealTarget ; 22422 (8:6422) +; check if Arena card has any damage counters, +; if not, check Bench instead. + ld e, PLAY_AREA_ARENA + call GetCardDamage + or a + jr z, .check_bench + + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + farcall CheckIfDefendingPokemonCanKnockOut + jr nc, .set_carry ; return carry if can't KO + ld d, a + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + ld h, a + ld e, PLAY_AREA_ARENA + call GetCardDamage + ; this seems useless since it was already + ; checked that Arena card has damage, + ; so card damage is at least 10. + cp 10 + 1 + jr c, .check_remaining + ld a, 10 + ; a = min(10, CardDamage) + +; checks if Defending Pokemon can still KO +; if Heal is used on this card. +; if Heal prevents KO, return carry. +.check_remaining + ld l, a + ld a, h ; load remaining HP + add l ; add 1 counter to account for heal + sub d ; subtract damage of strongest opponent attack + jr c, .check_bench + jr z, .check_bench + +.set_carry + xor a ; PLAY_AREA_ARENA + scf + ret + +; check Bench for Pokemon with damage counters +; and find the one with the most damage. +.check_bench + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld d, a + lb bc, 0, 0 + ld e, PLAY_AREA_BENCH_1 +.loop_bench + ld a, e + cp d + jr z, .done + push bc + call GetCardDamage + pop bc + cp b + jr c, .next_bench + jr z, .next_bench + ld b, a ; store this damage + ld c, e ; store this Play Area location +.next_bench + inc e + jr .loop_bench + +; check if a Pokemon with damage counters was found +; in the Bench and, if so, return carry. +.done + ld a, c + or a + jr z, .not_found +; found + scf + ret +.not_found + or a + ret +; 0x22476 + +; checks whether AI uses Shift. +; input: +; c = Play Area location (PLAY_AREA_*) of Venomoth +HandleAIShift: ; 22476 (8:6476) + ld a, c + or a + ret nz ; return if Venomoth is not Arena card + + ldh [hTemp_ffa0], a + call GetArenaCardColor + call TranslateColorToWR + ld b, a + call SwapTurn + call GetArenaCardWeakness + ld [wAIDefendingPokemonWeakness], a + call SwapTurn + or a + ret z ; return if Defending Pokemon has no weakness + and b + ret nz ; return if Venomoth is already Defending card's weakness type + +; check whether there's a card in play with +; the same color as the Player's card weakness + call .CheckWhetherTurnDuelistHasColor + jr c, .found + call SwapTurn + call .CheckWhetherTurnDuelistHasColor + call SwapTurn + ret nc ; return if no color found + +.found + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + +; converts WR_* to apropriate color + ld a, [wAIDefendingPokemonWeakness] + ld b, 0 +.loop_color + bit 7, a + jr nz, .done + inc b + rlca + jr .loop_color + +; use Pkmn Power effect +.done + ld a, b + ldh [hAIPkmnPowerEffectParam], a + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x224c6 + +; returns carry if turn Duelist has a Pokemon +; with same color as wAIDefendingPokemonWeakness. +.CheckWhetherTurnDuelistHasColor ; 224c6 (8:64c6) + ld a, [wAIDefendingPokemonWeakness] + ld b, a + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable +.loop_play_area + ld a, [hli] + cp $ff + jr z, .false + push bc + call GetCardIDFromDeckIndex + call GetCardType + call TranslateColorToWR + pop bc + and b + jr z, .loop_play_area +; true + scf + ret +.false + or a + ret +; 0x224e6 + +; checks whether AI uses Peek. +; input: +; c = Play Area location (PLAY_AREA_*) of Mankey. +HandleAIPeek: ; 224e6 (8:64e6) + ld a, c + ldh [hTemp_ffa0], a + ld a, 50 + call Random + cp 3 + ret nc ; return 47 out of 50 times + +; check what to use Peek on at random + ld a, 3 + call Random + or a + jr z, .check_player_prizes + cp 2 + jr c, .check_player_hand + +; check Player's Deck + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetNonTurnDuelistVariable + cp DECK_SIZE - 1 + ret nc ; return if Player has one or no cards in Deck + ld a, $ff + jr .use_peek + +.check_player_prizes + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + ld hl, wcda5 + and [hl] + ld [hl], a + or a + ret z ; return if no prizes (should never happen) + + ld c, a + ld b, $1 + ld d, 0 +.loop_prizes + ld a, c + and b + jr nz, .found_prize + sla b + inc d + jr .loop_prizes +.found_prize +; remove this prize's flag from the prize list +; and use Peek on first one in list (lowest bit set) + ld a, c + sub b + ld [hl], a + ld a, $40 + add d + jr .use_peek + +.check_player_hand + call SwapTurn + call CreateHandCardList + call SwapTurn + or a + ret z ; return if no cards in Hand +; shuffle list and pick the first entry to Peek + ld hl, wDuelTempList + call CountCardsInDuelTempList + call ShuffleCards + ld a, [wDuelTempList] + or $80 + +.use_peek + push af + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + pop af + ldh [hAIPkmnPowerEffectParam], a + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x2255d + +; checks whether AI uses Strange Behavior. +; input: +; c = Play Area location (PLAY_AREA_*) of Slowbro. +HandleAIStrangeBehavior: ; 2255d (8:655d) + ld a, c + or a + ret z ; return if Slowbro is Arena card + + ldh [hTemp_ffa0], a + ld e, PLAY_AREA_ARENA + call GetCardDamage + or a + ret z ; return if Arena card has no damage counters + + ld [wce06], a + ldh a, [hTemp_ffa0] + add DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + sub 10 + ret z ; return if Slowbro has only 10 HP remaining + +; if Slowbro can't receive all damage counters, +; only transfer remaining HP - 10 damage + ld hl, wce06 + cp [hl] + jr c, .use_strange_behavior + ld a, [hl] ; can receive all damage counters + +.use_strange_behavior + push af + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + xor a + ldh [hAIPkmnPowerEffectParam], a + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + pop af + +; loop counters chosen to transfer and use Pkmn Power + call ConvertHPToCounters + ld e, a +.loop_counters + ld d, 30 +.small_delay_loop + call DoFrame + dec d + jr nz, .small_delay_loop + push de + ld a, OPPACTION_6B15 + bank1call AIMakeDecision + pop de + dec e + jr nz, .loop_counters + +; return to main scene + ld d, 60 +.big_delay_loop + call DoFrame + dec d + jr nz, .big_delay_loop + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x225b5 + +; checks whether AI uses Curse. +; input: +; c = Play Area location (PLAY_AREA_*) of Gengar. +HandleAICurse: ; 225b5 (8:65b5) + ld a, c + ldh [hTemp_ffa0], a + +; loop Player's Play Area and checks their damage. +; finds the card with lowest remaining HP and +; stores its HP and its Play Area location + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetNonTurnDuelistVariable + ld d, a + ld e, PLAY_AREA_ARENA + lb bc, 0, $ff + ld h, PLAY_AREA_ARENA + call SwapTurn +.loop_play_area_1 + push bc + call GetCardDamage + pop bc + or a + jr z, .next_1 + + inc b + ld a, e + add DUELVARS_ARENA_CARD_HP + push hl + call GetTurnDuelistVariable + pop hl + cp c + jr nc, .next_1 + ; lower HP than one stored + ld c, a ; store this HP + ld h, e ; store this Play Area location + +.next_1 + inc e + ld a, e + cp d + jr nz, .loop_play_area_1 ; reached end of Play Area + + ld a, 1 + cp b + jr nc, .failed ; return if less than 2 cards with damage + +; card in Play Area with lowest HP remaining was found. +; look for another card to take damage counter from. + ld a, h + ldh [hTempRetreatCostCards], a + ld b, a + ld a, 10 + cp c + jr z, .hp_10_remaining + ; if has more than 10 HP remaining, + ; skip Arena card in choosing which + ; card to take damage counter from. + ld e, PLAY_AREA_BENCH_1 + jr .second_card -Func_22476: ; 22476 (8:6476) - INCROM $22476, $224e6 +.hp_10_remaining + ; if Curse can KO, then include + ; Player's Arena card to take + ; damage counter from. + ld e, PLAY_AREA_ARENA -Func_224e6: ; 224e6 (8:64e6) - INCROM $224e6, $2255d +.second_card + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld d, a +.loop_play_area_2 + ld a, e + cp b + jr z, .next_2 ; skip same Pokemon card + push bc + call GetCardDamage + pop bc + jr nz, .use_curse ; has damage counters, choose this card +.next_2 + inc e + ld a, e + cp d + jr nz, .loop_play_area_2 -Func_2255d: ; 2255d (8:655d) - INCROM $2255d, $225b5 +.failed + call SwapTurn + or a + ret -Func_225b5: ; 225b5 (8:65b5) - INCROM $225b5, $2262d +.use_curse + ld a, e + ldh [hAIPkmnPowerEffectParam], a + call SwapTurn + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + ret +; 0x2262d Func_2262d: ; 2262d (8:662d) INCROM $2262d, $226a3 @@ -6815,7 +7252,7 @@ HandleAIDamageSwap: ; 226a3 (8:66a3) ldh [hTempRetreatCostCards], a xor a ; PLAY_AREA_ARENA - ldh [hTempPlayAreaLocation_ffa1], a + ldh [hAIPkmnPowerEffectParam], a ld a, OPPACTION_6B15 bank1call AIMakeDecision pop de @@ -6823,6 +7260,7 @@ HandleAIDamageSwap: ; 226a3 (8:66a3) jr nz, .loop_damage .done +; return to main scene ld d, 60 .big_delay_loop call DoFrame diff --git a/src/engine/home.asm b/src/engine/home.asm index 338dbb0..c56e0c6 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -3419,6 +3419,7 @@ CreateArenaOrBenchEnergyCardList: ; 120a (0:120a) ; fill wDuelTempList with the turn holder's hand cards (their 0-59 deck indexes) ; return carry if the turn holder has no cards in hand +; and outputs in a number of cards. CreateHandCardList: ; 123b (0:123b) call FindLastCardInHand inc b diff --git a/src/hram.asm b/src/hram.asm index 2b4fbc9..f22b172 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -83,6 +83,8 @@ hTemp_ffa0:: ; ffa0 ; a PLAY_AREA_* constant (0: arena card, 1-5: bench card) hTempPlayAreaLocation_ffa1:: ; ffa1 +; parameter to be used by the AI's Pkmn Power effect +hAIPkmnPowerEffectParam:: ; ffa1 ds $1 UNION @@ -101,6 +103,13 @@ hAIEnergyTransEnergyCard:: ; ffa2 hAIEnergyTransPlayAreaLocation:: ; ffa3 ds $1 +NEXTU + +; Play Area location (PLAY_AREA_*) of card +; chosen by AI to use Heal Pkmn Power on. +hAIHealCard:: ; ffa2 + ds $1 + ENDU ; hffa8 through hffb0 belong to the text engine diff --git a/src/wram.asm b/src/wram.asm index 9c20732..c4536f6 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1383,6 +1383,9 @@ wAIVenusaur2PlayAreaLocation:: ; ce05 wce06:: ; ce06 ; number of cards to be transferred by AI using Energy Trans. wAINumberOfEnergyTransCards:: +; used for storing weakness of Player's Arena card +; in AI routine dealing with Shift Pkmn Power. +wAIDefendingPokemonWeakness:: ds $1 wce07:: ; ce07 -- cgit v1.2.3 From ed0543d3d31c879a5f331c23384971f7d316b93e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 29 Apr 2020 18:13:57 +0100 Subject: AI Cowardice routines --- src/engine/bank05.asm | 89 ++++++++++++++++++++++++++++++++++++++----------- src/engine/bank08.asm | 91 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/wram.asm | 1 + 3 files changed, 160 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 349e7d3..d6a99b9 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -137,7 +137,7 @@ CheckIfAnyDefendingPokemonAttackDealsSameDamageAsHP: ; 140c5 (5:40c5) ; checks AI scores for all benched Pokémon ; returns the location of the card with highest score -; in hTempPlayAreaLocation_ff9d +; in a and [hTempPlayAreaLocation_ff9d] FindHighestBenchScore: ; 140df (5:40df) ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable @@ -1214,14 +1214,14 @@ Func_1468b: ; 1468b (5:468b) ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards farcall Func_227d3 - jp nc, .asm_14776 + jp nc, .try_attack farcall HandleAIGoGoRainDanceEnergy farcall HandleAIDamageSwap farcall HandleAIPkmnPowers ret c - farcall Func_2262d + farcall HandleAICowardice ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards @@ -1247,25 +1247,32 @@ Func_1468b: ; 1468b (5:468b) call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_12 call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_146ed + jr nz, .already_played_energy_1 call AIProcessAndTryToPlayEnergy -.asm_146ed + +.already_played_energy_1 call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap farcall HandleAIPkmnPowers ret c farcall HandleAIGoGoRainDanceEnergy - ld a, $0d + ld a, $0d ; attack farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] - and $04 - jr z, .asm_14776 + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + +; used Professor Oak ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -1276,6 +1283,7 @@ Func_1468b: ; 1468b (5:468b) call AIProcessHandTrainerCards call AIDecidePlayPokemonCard ret c + ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_06 @@ -1290,34 +1298,72 @@ Func_1468b: ; 1468b (5:468b) ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_1475b + jr nz, .already_played_energy_2 call AIProcessAndTryToPlayEnergy -.asm_1475b +.already_played_energy_2 call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap farcall HandleAIPkmnPowers ret c farcall HandleAIGoGoRainDanceEnergy - ld a, $0d + ld a, $0d ; attack farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards -.asm_14776 +.try_attack ld a, $0e farcall HandleAIEnergyTrans + call AIProcessAndTryToUseAttack - ret c + ret c ; return if AI attacked ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x14786 +; handles retreating Func_14786: ; 14786 (5:4786) - INCROM $14786, $14c91 + ld a, [wce03] + or a + ret nz + + call AIDecideWhetherToRetreat + ret nc ; return if not retreating + + call AIDecideBenchPokemonToSwitchTo + ret c ; return if no Bench Pokemon + + ld [wcdd5], a + ld a, $01 + ld [wce03], a + + ld a, AI_TRAINER_CARD_PHASE_09 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_SWITCH + jr nz, .used_switch + ld a, [wcdd5] + call AIChooseEnergyToDiscardForRetreatCost + ret + +.used_switch + ld a, [wPreviousAIFlags] + and ~AI_FLAG_USED_SWITCH ; clear Switch flag + ld [wPreviousAIFlags], a + ld a, $09 ; retreat + farcall HandleAIEnergyTrans + ret +; 0x147bd + +Func_147bd: ; 147bd (5:47bd) + INCROM $147bd, $14c91 ; this routine handles how Legendary Articuno ; prioritises playing energy cards to each Pokémon. @@ -2370,7 +2416,7 @@ Func_15b54: ; 15b54 (5:5b54) ; 0x15b72 ; calculates AI score for bench Pokémon -; returns in hTempPlayAreaLocation_ff9d the +; returns in a and [hTempPlayAreaLocation_ff9d] the ; Play Area location of best card to switch to. ; returns carry if no Bench Pokemon. AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) @@ -2626,11 +2672,11 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) .asm_15d0c ld b, a - ld a, [$cdb1] + ld a, [wcdb0 + 1] or a jr z, .store_score ld h, a - ld a, [$cdb0] + ld a, [wcdb0] ld l, a .loop @@ -2675,7 +2721,12 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) ; handles AI action of retreating Arena Pokémon ; and chooses which energy cards to discard -; if card can't discard, return carry +; if card can't discard, return carry. +; in case it's Clefairy Doll or Mysterious Fossil, +; handle its effect to discard itself instead of retreating. +; input: +; - a = Play Area location (PLAY_AREA_*) of card to retreat to +; in case Clefairy Doll/Mysterious Fossil effect is used. AIChooseEnergyToDiscardForRetreatCost: ; 15d4f (5:5d4f) push af ld a, [wAIPlayEnergyCardForRetreat] @@ -2907,7 +2958,7 @@ AIChooseEnergyToDiscardForRetreatCost: ; 15d4f (5:5d4f) ld a, OPPACTION_USE_PKMN_POWER bank1call AIMakeDecision pop af - ldh [hTempPlayAreaLocation_ffa1], a + ldh [hAIPkmnPowerEffectParam], a ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT bank1call AIMakeDecision ld a, OPPACTION_DUEL_MAIN_SCENE diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index b5a794b..1113dc9 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -6629,6 +6629,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; - Peek; ; - Strange Behavior; ; - Curse. +; returns carry if turn ended. HandleAIPkmnPowers: ; 2237f (8:637f) ld a, MUK call CountPokemonIDInBothPlayAreas @@ -7169,8 +7170,94 @@ HandleAICurse: ; 225b5 (8:65b5) ret ; 0x2262d -Func_2262d: ; 2262d (8:662d) - INCROM $2262d, $226a3 +; handles AI logic for Cowardice +HandleAICowardice: ; 2262d (8:662d) + ld a, MUK + call CountPokemonIDInBothPlayAreas + ret c ; return if there's Muk in play + + farcall AIChooseRandomlyNotToDoAction + ret c ; randomly return + + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp 1 + ret z ; return if only one Pokemon in Play Area + + ld b, a + ld c, PLAY_AREA_ARENA + ld a, DUELVARS_ARENA_CARD_STATUS + call GetTurnDuelistVariable + and CNF_SLP_PRZ + jr nz, .next +.loop + ld a, DUELVARS_ARENA_CARD + add c + call GetTurnDuelistVariable + ld [wce08], a + call GetCardIDFromDeckIndex + ld a, e + push bc + cp TENTACOOL + call z, .CheckWhetherToUseCowardice + pop bc + jr nc, .next + + dec b ; subtract 1 from number of Pokemon in Play Area + ld a, 1 + cp b + ret z ; return if no longer has Bench Pokemon + ld c, PLAY_AREA_ARENA ; reset back to Arena + jr .loop + +.next + inc c + ld a, c + cp b + jr nz, .loop + ret +; 0x22671 + +; checks whether AI uses Cowardice. +; return carry if Pkmn Power was used. +; input: +; c = Play Area location (PLAY_AREA_*) of Tentacool. +.CheckWhetherToUseCowardice ; 22671 (8:6671) + ld a, c + ldh [hTemp_ffa0], a + ld e, a + call GetCardDamage +.asm_22678 + or a + ret z ; return if has no damage counters + + ldh a, [hTemp_ffa0] + or a + jr nz, .is_benched + farcall AIDecideBenchPokemonToSwitchTo +; in case this routine is called with no Bench Pokemon, +; this introduces a bug. +; since it's only called in HandleAICowardice in case +; there's more than 1 Pokemon in Play Area, this never sets carry. + jr c, .asm_22678 + jr .use_cowardice +.is_benched + ld a, $ff +.use_cowardice + push af + ld a, [wce08] + ldh [hTempCardIndex_ff9f], a + ld a, OPPACTION_USE_PKMN_POWER + bank1call AIMakeDecision + pop af + ldh [hAIPkmnPowerEffectParam], a + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + bank1call AIMakeDecision + ld a, OPPACTION_DUEL_MAIN_SCENE + bank1call AIMakeDecision + scf + ret +; 0x226a3 ; AI logic for Damage Swap to transfer damage from Arena card ; to a card in Bench with more than 10 HP remaining diff --git a/src/wram.asm b/src/wram.asm index c4536f6..cb97ddc 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1194,6 +1194,7 @@ wcda7:: ; cda7 wcdae:: ; cdae ds $2 +wcdb0:: ; cdb0 ds $2 ; these seem to hold pointer to some kind of -- cgit v1.2.3 From 75678c46233e53c4508c811a80923216b36c61bb Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 29 Apr 2020 20:42:00 +0100 Subject: AI init duel and turn logic --- src/engine/bank01.asm | 10 ++--- src/engine/bank05.asm | 122 ++++++++++++++++++++++++++++++++++++++------------ src/engine/bank08.asm | 12 ++--- src/wram.asm | 11 ++++- 4 files changed, 114 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 7668903..7eb7340 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -3720,7 +3720,7 @@ Func_57df: ; 57df (1:57df) Func_5805: ; 5805 (1:5805) call Func_3b31 - ld a, [wccc8] + ld a, [wNumberPrizeCardsToTake] ld l, a ld h, $00 call LoadTxRam3 @@ -3731,7 +3731,7 @@ Func_5805: ; 5805 (1:5805) ldtx hl, WillDrawNPrizesText call DrawWideTextBox_WaitForInput - ld a, [wccc8] + ld a, [wNumberPrizeCardsToTake] call Func_310a ld hl, hTemp_ffa0 ld d, [hl] @@ -3775,7 +3775,7 @@ Func_5805: ; 5805 (1:5805) call nz, AddCardToHand .asm_586f ld a, [wcbfc] - ld hl, wccc8 + ld hl, wNumberPrizeCardsToTake cp [hl] jr nc, .asm_587e ld l, a @@ -7525,7 +7525,7 @@ Func_6fa5: ; 6fa5 (1:6fa5) ret ; 0x6fc7 -; return in wccc8 the amount of Pokemon in the turn holder's +; return in wNumberPrizeCardsToTake the amount of Pokemon in the turn holder's ; play area that are still there despite having 0 HP. ; that is, the number of Pokemon that have just been knocked out. ; Clefairy Doll and Mysterious Fossil don't count. @@ -7558,7 +7558,7 @@ CountKnockedOutPokemon: ; 6fc7 (1:6fc7) dec c jr nz, .loop ld a, b - ld [wccc8], a + ld [wNumberPrizeCardsToTake], a or a ret z scf diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index d6a99b9..d8a0a31 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -333,24 +333,90 @@ CheckIfEnergyIsUseful: ; 14184 (5:4184) ; 0x141da Func_141da: ; 141da (5:41da) - INCROM $141da, $14226 + INCROM $141da, $141e5 -Func_14226: ; 14226 (5:4226) +_AIPickPrizeCards: ; 141e5 (5:41e5) + ld a, [wNumberPrizeCardsToTake] + ld b, a +.loop + call .PickPrizeCard + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + or a + jr z, .done + dec b + jr nz, .loop +.done + ret +; 0x141f8 + +; picks a prize card at random +; and adds it to the hand. +.PickPrizeCard: ; 141f8 (5:41f8) + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + push hl + ld c, a + +; choose a random prize card until +; one is found that isn't taken already. +.loop_pick_prize + ld a, 6 + call Random + ld e, a + ld d, $00 + ld hl, .prize_flags + add hl, de + ld a, [hl] + and c + jr z, .loop_pick_prize ; no prize + +; prize card was found +; remove this prize from wOpponentPrizes + ld a, [hl] + pop hl + cpl + and [hl] + ld [hl], a + +; add this prize card to the hand + ld a, e + add DUELVARS_PRIZE_CARDS + call GetTurnDuelistVariable + call AddCardToHand + ret + +.prize_flags ; 1421e (5:421e) + db $1 << 0 + db $1 << 1 + db $1 << 2 + db $1 << 3 + db $1 << 4 + db $1 << 5 + db $1 << 6 + db $1 << 7 +; 0x14226 + +; routine for AI to play all Basic cards from its hand +; in the beginning of the Duel. +AIPlayInitialBasicCards: ; 14226 (5:4226) call CreateHandCardList ld hl, wDuelTempList .check_for_next_card ld a, [hli] ldh [hTempCardIndex_ff98], a cp $ff - ret z + ret z ; return when done call LoadCardDataToBuffer1_FromDeckIndex ld a, [wLoadedCard1Type] cp TYPE_ENERGY - jr nc, .check_for_next_card + jr nc, .check_for_next_card ; skip if not Pokemon card ld a, [wLoadedCard1Stage] or a - jr nz, .check_for_next_card + jr nz, .check_for_next_card ; skip if not Basic Stage + +; play Basic card from hand push hl ldh a, [hTempCardIndex_ff98] call PutHandPokemonCardInPlayArea @@ -1178,24 +1244,23 @@ AIProcessHandTrainerCards: ; 14663 (5:4663) ; GENERAL DECK POINTER LIST - Not sure on all of these. ; This is an example of an AI pointer table, there's one for each AI type. PointerTable_14668: ; 14668 (05:4668) - dw Func_14674 ; not used - dw Func_14674 ; general AI for battles - dw Func_14678 ; basic pokemon placement / cheater shuffling on better AI - dw Func_1467f ; deciding which Bench Pokemon to switch to + dw AIMainTurnLogic ; not used + dw AIMainTurnLogic ; general AI for battles + dw AIDuelStart ; basic pokemon placement / cheater shuffling on better AI + dw AIRetreatLogic ; deciding which Bench Pokemon to switch to dw Func_14683 - dw Func_14687 + dw AIPickPrizeCards -; when battle AI gets called -Func_14674: ; 14674 (5:4674) - call Func_1468b +AIMainTurnLogic: ; 14674 (5:4674) + call _AIMainTurnLogic ret -Func_14678: ; 14678 (5:4678) - call Func_15636 - call $4226 +AIDuelStart: ; 14678 (5:4678) + call InitAIDuelVars + call AIPlayInitialBasicCards ret -Func_1467f: ; 1467f (5:467f) +AIRetreatLogic: ; 1467f (5:467f) call AIDecideBenchPokemonToSwitchTo ret @@ -1203,13 +1268,13 @@ Func_14683: ; 14683 (5:4683) call AIDecideBenchPokemonToSwitchTo ret -Func_14687: ; 14687 (5:4687) - call $41e5 +AIPickPrizeCards: ; 14687 (5:4687) + call _AIPickPrizeCards ret -; AI for general decks i think -Func_1468b: ; 1468b (5:468b) - call Func_15649 +; handle AI routines for a whole turn +_AIMainTurnLogic: ; 1468b (5:468b) + call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards @@ -1532,22 +1597,23 @@ LookForCardIDInPlayArea_Bank5: ; 155ef (5:55ef) Func_15612: ; 15612 (5:5612) INCROM $15612, $15636 -Func_15636: ; 15636 (5:5636) +InitAIDuelVars: ; 15636 (5:5636) ld a, $10 ld hl, wcda5 call ClearMemory_Bank5 - ld a, $5 - ld [wcda6], a + ld a, 5 + ld [wAIPokedexCounter], a ld a, $ff ld [wcda5], a ret ; initializes some variables and ; sets value of wcda7. -Func_15649: ; 15649 (5:5649) - ld a, [wcda6] +InitAITurnVars: ; 15649 (5:5649) +; increase Pokedex counter by one + ld a, [wAIPokedexCounter] inc a - ld [wcda6], a + ld [wAIPokedexCounter], a xor a ld [wPreviousAIFlags], a diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 1113dc9..1c6f82a 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -3589,9 +3589,9 @@ AIPlay_Pokedex: ; 212b4 (8:52b4) ; 0x212dc AIDecide_Pokedex: ; 212dc (8:52dc) - ld a, [wcda6] - cp $06 - jr c, .no_carry + ld a, [wAIPokedexCounter] + cp 5 + 1 + jr c, .no_carry ; return if counter hasn't reached 6 yet ; return no carry if number of cards in deck <= 4 ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK @@ -3624,7 +3624,7 @@ AIDecide_Pokedex: ; 212dc (8:52dc) PickPokedexCards_Unreferenced: ; 212ff (8:52ff) ; unreferenced xor a - ld [wcda6], a + ld [wAIPokedexCounter], a ; reset counter ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable @@ -3756,7 +3756,7 @@ PickPokedexCards_Unreferenced: ; 212ff (8:52ff) ; stores the resulting order in wce1a. PickPokedexCards: ; 2138e (8:538e) xor a - ld [wcda6], a + ld [wAIPokedexCounter], a ; reset counter ; reset counter ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable @@ -6949,7 +6949,7 @@ HandleAIPeek: ; 224e6 (8:64e6) and [hl] ld [hl], a or a - ret z ; return if no prizes (should never happen) + ret z ; return if no prizes ld c, a ld b, $1 diff --git a/src/wram.asm b/src/wram.asm index cb97ddc..534297e 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -967,7 +967,7 @@ wNoDamageOrEffect:: ; ccc7 ; used by CountKnockedOutPokemon and Func_5805 to store the amount ; of prizes to take (equal to the number of Pokemon knocked out) -wccc8:: ; ccc8 +wNumberPrizeCardsToTake:: ; ccc8 ds $1 ; set to 1 if the coin toss in the confusion check is heads (CheckSelfConfusionDamage) @@ -1182,7 +1182,14 @@ wcd9f:: ; cd9f wcda5:: ; cda5 ds $1 -wcda6:: ; cda6 +; this is used by AI in order to determine whether +; it should use Pokedex Trainer card. +; duel starts at 5 and counts up by one every turn. +; only when it's higher than 5 is AI allowed to use Pokedex, +; in which case it set the counter to 0. +; this stops the AI from using Pokedex right after using another one +; while still drawing cards that were ordered. +wAIPokedexCounter:: ; cda6 ds $1 wcda7:: ; cda7 -- cgit v1.2.3 From 47736d7c415ea5b38f5d9df83e7fb1e9b12a9e9e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 11:20:19 +0100 Subject: Disassemble Sam duel scripts --- src/engine/bank05.asm | 283 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 273 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index d8a0a31..bb77536 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1,5 +1,5 @@ PointerTable_14000: ; 14000 (05:4000) - dw $47bd ; SAMS_PRACTICE_DECK + dw PointerTable_147bd ; SAMS_PRACTICE_DECK dw PointerTable_14668 ; PRACTICE_PLAYER_DECK dw PointerTable_14668 ; SAMS_NORMAL_DECK dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK @@ -332,8 +332,17 @@ CheckIfEnergyIsUseful: ; 14184 (5:4184) ret ; 0x141da -Func_141da: ; 141da (5:41da) - INCROM $141da, $141e5 +; pick a random Pokemon in the bench. +; output: +; - a = PLAY_AREA_* of Bench Pokemon picked. +PickRandomBenchPokemon: ; 141da (5:41da) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + dec a + call Random + inc a + ret +; 0x141e5 _AIPickPrizeCards: ; 141e5 (5:41e5) ld a, [wNumberPrizeCardsToTake] @@ -1427,8 +1436,229 @@ Func_14786: ; 14786 (5:4786) ret ; 0x147bd -Func_147bd: ; 147bd (5:47bd) - INCROM $147bd, $14c91 +PointerTable_147bd: ; 147bd (05:47bd) + dw Func_147c9 + dw Func_147c9 + dw Func_147d6 + dw Func_147da + dw Func_147e7 + dw Func_147f4 + +Func_147c9: ; 147c9 (5:47c9) + call IsAIPracticeScriptedTurn + jr nc, .scripted +; not scripted, use AI main turn logic + call _AIMainTurnLogic + ret +.scripted ; use scripted actions instead + call AIPerformSciptedTurn + ret +; 0x147d6 + +Func_147d6: ; 147d6 (5:47d6) + call Func_14801 + ret +; 0x147da + +Func_147da: ; 147da (5:47da) + call IsAIPracticeScriptedTurn + jr nc, .scripted + call AIDecideBenchPokemonToSwitchTo + ret +.scripted + call PickRandomBenchPokemon + ret +; 0x147e7 + +Func_147e7: ; 147e7 (5:47e7) + call IsAIPracticeScriptedTurn + jr nc, .scripted + call AIDecideBenchPokemonToSwitchTo + ret +.scripted + call GetPlayAreaLocationOfRaticateOrRattata + ret +; 0x147f4 + +Func_147f4: ; 147f4 (5:47f4) + call _AIPickPrizeCards + ret +; 0x147f8 + +; returns carry if number of turns +; the AI has taken >= 7. +; used to know whether AI Sam is still +; doing scripted turns. +IsAIPracticeScriptedTurn: ; 147f8 (5:47f8) + ld a, [wDuelTurns] + srl a + cp 7 + ccf + ret +; 0x14801 + +; places one Machop from the hand to the Play Area +; and sets the number of prizes to 2. +Func_14801: ; 14801 (5:4801) + call CreateHandCardList + ld hl, wDuelTempList +.loop_hand + ld a, [hli] + ldh [hTempCardIndex_ff98], a + cp $ff + ret z + call LoadCardDataToBuffer1_FromDeckIndex + cp MACHOP + jr nz, .loop_hand + ldh a, [hTempCardIndex_ff98] + call PutHandPokemonCardInPlayArea + ld a, 2 + ld [wDuelInitialPrizes], a + ret +; 0x1481f + +; outputs in a Play Area location of Raticate or Rattata +; in the Bench. If neither is found, just output PLAY_AREA_BENCH_1. +GetPlayAreaLocationOfRaticateOrRattata: ; 1481f (5:481f) + ld a, RATICATE + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + cp $ff + jr nz, .found + ld a, RATTATA + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + cp $ff + jr nz, .found + ld a, PLAY_AREA_BENCH_1 +.found + ldh [hTempPlayAreaLocation_ff9d], a + ret +; 0x1483a + +; has AI execute some scripted actions depending on Duel turn. +AIPerformSciptedTurn: ; 1483a (5:483a) + ld a, [wDuelTurns] + srl a + ld hl, .scripted_actions_list + call JumpToFunctionInTable + +; always attack with Arena card's first attack. +; if it's unusable end turn without attacking. + xor a + ldh [hTempPlayAreaLocation_ff9d], a + ld [wSelectedAttack], a + call CheckIfSelectedMoveIsUnusable + jr c, .unusable + call AITryUseAttack + ret + +.unusable + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x1485a + +.scripted_actions_list ; 1485a (05:485a) + dw .turn_1 + dw .turn_2 + dw .turn_3 + dw .turn_4 + dw .turn_5 + dw .turn_6 + dw .turn_7 +; 0x14868 + +.turn_1 ; 14868 (5:4868) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x14870 + +.turn_2 ; 14870 (5:4870) + ld a, RATTATA + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + ld d, RATTATA + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x14884 + +.turn_3 ; 14884 (5:4884) + ld a, RATTATA + ld b, PLAY_AREA_ARENA + call LookForCardIDInPlayArea_Bank5 + ldh [hTempPlayAreaLocation_ffa1], a + ld a, RATICATE + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_EVOLVE_PKMN + bank1call AIMakeDecision + ld d, RATICATE + ld e, LIGHTNING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148a1 + +.turn_4 ; 148a1 (5:48a1) + ld d, RATICATE + ld e, LIGHTNING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148a9 + +.turn_5 ; 148a9 (5:48a9) + ld a, MACHOP + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInBench + +; this is a bug, it's attempting to compare a card ID with a deck index. +; the intention was to change the card to switch to depending on whether +; the first Machop was KO'd at this point in the Duel or not. +; because of the buggy comparison, this will always jump the +; 'inc a' instruction and switch to PLAY_AREA_BENCH_1. +; in a normal Practice Duel following Dr. Mason's instructions, +; this will always lead to the AI correctly switching Raticate with Machop, +; but in case of a "Free" Duel where the first Machop is not KO'd, +; the intention was to switch to PLAY_AREA_BENCH_2 instead. +; but due to 'inc a' always being skipped, it will switch to Raticate. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + cp MACHOP ; wrong + ld a, PLAY_AREA_BENCH_1 + jr nz, .retreat + inc a ; PLAY_AREA_BENCH_2 + +.retreat + call AIChooseEnergyToDiscardForRetreatCost + ret +; 0x148cc + +.turn_6 ; 148cc (5:48cc) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148d4 + +.turn_7 ; 148d4 (5:48d4) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148dc + +Func_148dc: ; 148dc (5:48dc) + INCROM $148dc, $14c91 ; this routine handles how Legendary Articuno ; prioritises playing energy cards to each Pokémon. @@ -1594,8 +1824,42 @@ LookForCardIDInPlayArea_Bank5: ; 155ef (5:55ef) ret ; 0x15612 -Func_15612: ; 15612 (5:5612) - INCROM $15612, $15636 +; check if energy card ID in e is in AI hand and, +; if so, attaches it to card ID in d in Play Area. +; input: +; e = Energy card ID +; d = Pokemon card ID +AIAttachEnergyInHandToCardInPlayArea: ; 15612 (5:5612) + ld a, e + push de + call LookForCardIDInHandList_Bank5 + pop de + ret nc ; not in hand + ld b, PLAY_AREA_ARENA + +.attach + ld e, a + ld a, d + call LookForCardIDInPlayArea_Bank5 + ldh [hTempPlayAreaLocation_ffa1], a + ld a, e + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_ENERGY + bank1call AIMakeDecision + ret +; 0x1562b + +; same as AIAttachEnergyInHandToCardInPlayArea but +; only look for card ID in the Bench. +AIAttachEnergyInHandToCardInBench: ; 1562b (5:562b) + ld a, e + push de + call LookForCardIDInHandList_Bank5 + pop de + ret nc + ld b, PLAY_AREA_BENCH_1 + jr AIAttachEnergyInHandToCardInPlayArea.attach +; 0x15636 InitAIDuelVars: ; 15636 (5:5636) ld a, $10 @@ -2786,13 +3050,12 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) ; 0x15d4f ; handles AI action of retreating Arena Pokémon -; and chooses which energy cards to discard +; and chooses which energy cards to discard. ; if card can't discard, return carry. ; in case it's Clefairy Doll or Mysterious Fossil, ; handle its effect to discard itself instead of retreating. ; input: -; - a = Play Area location (PLAY_AREA_*) of card to retreat to -; in case Clefairy Doll/Mysterious Fossil effect is used. +; - a = Play Area location (PLAY_AREA_*) of card to retreat to. AIChooseEnergyToDiscardForRetreatCost: ; 15d4f (5:5d4f) push af ld a, [wAIPlayEnergyCardForRetreat] -- cgit v1.2.3 From cf9a3c313b63c78ebcb4077e827eeff9a5940ba0 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 16:04:07 +0100 Subject: Unpack Legendary Moltres AI --- src/constants/duel_constants.asm | 2 + src/engine/bank05.asm | 513 +++++++++++++++++++++++++++++++++++++-- src/wram.asm | 9 +- 3 files changed, 507 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index b667c50..9cdc73b 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -3,6 +3,8 @@ MAX_PLAY_AREA_POKEMON EQU 6 ; arena + bench MAX_HP EQU 120 HP_BAR_LENGTH EQU MAX_HP / 10 +STARTING_HAND_SIZE EQU 7 + ; hWhoseTurn constants PLAYER_TURN EQUS "HIGH(wPlayerDuelVariables)" OPPONENT_TURN EQUS "HIGH(wOpponentDuelVariables)" diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index bb77536..92fc0aa 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -11,7 +11,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK - dw $49e8 ; LEGENDARY_MOLTRES_DECK + dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK dw $4b0f ; LEGENDARY_ZAPDOS_DECK dw $4c0b ; LEGENDARY_ARTICUNO_DECK dw $4d60 ; LEGENDARY_DRAGONITE_DECK @@ -1658,7 +1658,245 @@ AIPerformSciptedTurn: ; 1483a (5:483a) ; 0x148dc Func_148dc: ; 148dc (5:48dc) - INCROM $148dc, $14c91 + INCROM $148dc, $149e8 + +PointerTable_149e8: ; 149e8 (05:49e8) + dw Func_149f4 + dw Func_149f4 + dw Func_149f8 + dw Func_14a09 + dw Func_14a0d + dw Func_14a11 + +Func_149f4: ; 149f4 (5:49f4) + call Func_14a81 + ret +; 0x149f8 + +Func_149f8: ; 149f8 (5:49f8) + call InitAIDuelVars + call Func_14a4a + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc ; Play Area set up was successful + call AIPlayInitialBasicCards + ret +; 0x14a09 + +Func_14a09: ; 14a09 (5:4a09) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a0d + +Func_14a0d: ; 14a0d (5:4a0d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a11 + +Func_14a11: ; 14a11 (5:4a11) + call _AIPickPrizeCards + ret +; 0x14a15 + +Data_14a15: ; 14a15 (5:4a15) + db MAGMAR2 + db GROWLITHE + db VULPIX + db MAGMAR1 + db MOLTRES1 + db MOLTRES2 + db $00 + +Data_14a1c: ; 14a1c (5:4a1c) + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +Data_14a22: ; 14a22 (5:4a22) + db MOLTRES2 + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +Data_14a29: ; 14a29 (5:4a29) + db GROWLITHE + db $80 - 5 + db VULPIX + db $80 - 5 + db $00 + +Data_14a2e: ; 14a2e (5:4a2e) + db VULPIX + db 3 + db $80 + 0 + + db NINETAILS2 + db 3 + db $80 + 1 + + db GROWLITHE + db 3 + db $80 + 1 + + db ARCANINE2 + db 4 + db $80 + 1 + + db MAGMAR1 + db 4 + db $80 - 1 + + db MAGMAR2 + db 1 + db $80 - 1 + + db MOLTRES2 + db 3 + db $80 + 2 + + db MOLTRES1 + db 4 + db $80 + 2 + + db $00 + +Data_14a47: ; 14a47 (5:4a47) + db ENERGY_REMOVAL + db MOLTRES2 + db $00 + +Func_14a4a: ; 14a4a (5:4a4a) + ld hl, wcda8 + ld de, Data_14a47 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14a15 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14a1c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14a22 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb0 + ld de, Data_14a29 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_14a2e + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14a81 + +Func_14a81: ; 14a81 (5:4a81) + call InitAITurnVars + farcall Func_227d3 + jp nc, .try_attack + + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + +; check if AI can play Moltres2 from hand +; if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + cp DECK_SIZE - 9 + jr nc, .skip_moltres ; skip if cards in deck <= 9 + ld a, MUK + call CountPokemonIDInBothPlayAreas + jr c, .skip_moltres ; skip if Muk in play + ld a, MOLTRES2 + call LookForCardIDInHandList_Bank5 + jr nc, .skip_moltres ; skip if no Moltres2 in hand + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + +.skip_moltres + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + +; handle attaching energy from hand + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_attach_energy + +; if Magmar2 is the Arena card and has no energy attached, +; try attaching an energy card to it from the hand. +; otherwise, run normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, MAGMAR2 + cp e + jr nz, .attach_normally + ; Magmar2 is the Arena card + call CreateEnergyCardListFromHand + jr c, .skip_attach_energy + ld e, PLAY_AREA_ARENA + call CountNumberOfEnergyCardsAttached + or a + jr nz, .attach_normally + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .skip_attach_energy + +.attach_normally + call AIProcessAndTryToPlayEnergy + +.skip_attach_energy +; try playing Pokemon cards from hand again + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + +.try_attack + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14b0f + +Func_14b0f: ; 14b0f (5:4b0f) + INCROM $14b0f, $14c91 ; this routine handles how Legendary Articuno ; prioritises playing energy cards to each Pokémon. @@ -2279,8 +2517,82 @@ RemoveCardIDInList: ; 157f3 (5:57f3) ret ; 0x1581b -Func_1581b: ; 1581b (5:581b) - INCROM $1581b, $158b2 +; play Pokemon cards from the hand to set the starting +; Play Area of Boss decks. +; each Boss deck has two ID lists in order of preference. +; one list is for the Arena card is the other is for the Bench cards. +; if Arena card could not be set (due to hand not having any card in its list) +; or if list is null, return carry and do not play any cards. +TrySetUpBossStartingPlayArea: ; 1581b (5:581b) + ld de, wcdaa + ld a, d + or a + jr z, .set_carry ; return if null + +; pick Arena card + call CreateHandCardList + ld hl, wDuelTempList + ld de, wcdaa + call .PlayPokemonCardInOrder + ret c + +; play Pokemon cards to Bench until there are +; a maximum of 3 cards in Play Area. +.loop + ld de, wcdac + call .PlayPokemonCardInOrder + jr c, .done + cp 3 + jr c, .loop + +.done + or a + ret +.set_carry + scf + ret +; 0x1583f + +; runs through input card ID list in de. +; plays to Play Area first card that is found in hand. +; returns carry if none of the cards in the list are found. +; returns number of Pokemon in Play Area in a. +.PlayPokemonCardInOrder ; 1583f (5:583f) + ld a, [de] + ld c, a + inc de + ld a, [de] + ld d, a + ld e, c + +; go in order of the list in de and +; add first card that matches ID. +; returns carry if hand doesn't have any card in list. +.loop_id_list + ld a, [de] + inc de + or a + jr z, .not_found + push de + ld e, a + call RemoveCardIDInList + pop de + jr nc, .loop_id_list + + ; play this card to Play Area and return + push hl + call PutHandPokemonCardInPlayArea + pop hl + or a + ret + +.not_found + scf + ret +; 0x1585b + +Func_1585b: ; 1585b (5:585b) + INCROM $1585b, $158b2 ; determine AI score for retreating ; return carry if AI decides to retreat @@ -3009,26 +3321,26 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) ld a, [wcdb0] ld l, a -.loop +.loop_ids ld a, [hli] or a - jr z, .store_score + jr z, .store_score ; list is over cp b - jr nz, .asm_15d32 + jr nz, .next_id ld a, [hl] cp $80 jr c, .asm_15d2b sub $80 call AddToAIScore - jr .asm_15d32 + jr .next_id .asm_15d2b ld c, a ld a, $80 sub c call SubFromAIScore -.asm_15d32 +.next_id inc hl - jr .loop + jr .loop_ids .store_score ldh a, [hTempPlayAreaLocation_ff9d] @@ -4126,19 +4438,19 @@ LookForEnergyNeededForMoveInHand: ; 16311 (5:6311) SortTempHandByIDList: ; 1633f (5:633f) ld a, [wcdae+1] or a - ret z + ret z ; return if list is empty ; start going down the ID list ld d, a ld a, [wcdae] ld e, a ld c, 0 -.next_list_id +.loop_list_id ; get this item's ID ; if $00, list has ended ld a, [de] or a - ret z + ret z ; return when list is over inc de ld hl, wDuelTempList ld b, 0 @@ -4150,7 +4462,7 @@ SortTempHandByIDList: ; 1633f (5:633f) ld a, [hl] ldh [hTempCardIndex_ff98], a cp -1 - jr z, .next_list_id + jr z, .loop_list_id push bc push de call GetCardIDFromDeckIndex @@ -4703,6 +5015,7 @@ AIProcessEnergyCards: ; 164fc (5:64fc) pop de cp d jr c, .check_id_score + ; already reached target number of energy cards ld a, 10 call SubFromAIScore jr .store_score @@ -7159,8 +7472,176 @@ CheckCardEvolutionInHandOrDeck: ; 17274 (5:7274) ret ; 0x172af -Func_172af ; 172af (5:72af) - INCROM $172af, $17383 +; sets up the inital hand of boss deck. +; always draws at least 2 Basic Pokemon cards and 2 Energy cards. +; also sets up so that the next cards to be drawn have +; some minimum number of Basic Pokemon and Energy cards +; and avoids deck-specific list of cards. +SetUpBossStartingHandAndDeck: ; 172af (5:72af) +; shuffle all hand cards in deck + ld a, DUELVARS_HAND + call GetTurnDuelistVariable + ld b, STARTING_HAND_SIZE +.asm_172b6 + ld a, [hl] + call RemoveCardFromHand + call ReturnCardToDeck + dec b + jr nz, .asm_172b6 + jr .count_energy_basic + +.shuffle_deck + call ShuffleDeck + +; count number of Energy and basic Pokemon cards +; in the first STARTING_HAND_SIZE in deck. +.count_energy_basic + xor a + ld [wce06], a + ld [wce08], a + + ld a, DUELVARS_DECK_CARDS + call GetTurnDuelistVariable + ld b, STARTING_HAND_SIZE +.loop_deck_1 + ld a, [hli] + push bc + call LoadCardDataToBuffer1_FromDeckIndex + pop bc + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr c, .pokemon_card_1 + cp TYPE_TRAINER + jr z, .next_card_deck_1 + +; energy card + ld a, [wce08] + inc a + ld [wce08], a + jr .next_card_deck_1 + +.pokemon_card_1 + ld a, [wLoadedCard1Stage] + or a + jr nz, .next_card_deck_1 ; not basic + ld a, [wce06] + inc a + ld [wce06], a + +.next_card_deck_1 + dec b + jr nz, .loop_deck_1 + +; tally the number of Energy and basic Pokemon cards +; and if any of them is smaller than 2, re-shuffle deck. + ld a, [wce06] + cp 2 + jr c, .shuffle_deck + ld a, [wce08] + cp 2 + jr c, .shuffle_deck + +; now check the following 6 cards. +; re-shuffle deck if any of these cards is listed in wcda8. + ld b, 6 +.check_card_ids + ld a, [hli] + push bc + call .CheckIfIDIsInList + pop bc + jr c, .shuffle_deck + dec b + jr nz, .check_card_ids + +; finally, check 6 cards after that. +; if Energy or Basic Pokemon counter is below 4 +; (counting with the ones found in the initial hand) +; then re-shuffle deck. + ld b, 6 +.loop_deck_2 + ld a, [hli] + push bc + call LoadCardDataToBuffer1_FromDeckIndex + pop bc + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr c, .pokemon_card_2 + cp TYPE_TRAINER + jr z, .next_card_deck_2 + +; energy card + ld a, [wce08] + inc a + ld [wce08], a + jr .next_card_deck_2 + +.pokemon_card_2 + ld a, [wLoadedCard1Stage] + or a + jr nz, .next_card_deck_2 + ld a, [wce06] + inc a + ld [wce06], a + +.next_card_deck_2 + dec b + jr nz, .loop_deck_2 + + ld a, [wce06] + cp 4 + jp c, .shuffle_deck + ld a, [wce08] + cp 4 + jp c, .shuffle_deck + +; draw new set of hand cards + ld a, DUELVARS_DECK_CARDS + call GetTurnDuelistVariable + ld b, STARTING_HAND_SIZE +.draw_loop + ld a, [hli] + call SearchCardInDeckAndAddToHand + call AddCardToHand + dec b + jr nz, .draw_loop + ret +; 0x17366 + +; expectation: return carry if card ID corresponding +; to the input deck index is listed in wcda8; +; reality: always returns no carry because when checking terminating +; byte in wcda8 ($00), it wrongfully uses 'cp a' instead of 'or a', +; so it always ends up returning in the first item in list. +; input: +; - a = deck index of card to check +.CheckIfIDIsInList ; 17366 (5:7366) + ld b, a + ld a, [wcda8 + 1] + or a + ret z ; null + push hl + ld h, a + ld a, [wcda8] + ld l, a + + ld a, b + call GetCardIDFromDeckIndex +.loop_id_list + ld a, [hli] + cp a ; bug, should be 'or a' + jr z, .false + cp e + jr nz, .loop_id_list + +; true + pop hl + scf + ret +.false + pop hl + or a + ret +; 0x17383 ; returns carry if Pokemon at PLAY_AREA* in a ; can damage defending Pokémon with any of its moves diff --git a/src/wram.asm b/src/wram.asm index 534297e..cae7f88 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1195,7 +1195,14 @@ wAIPokedexCounter:: ; cda6 wcda7:: ; cda7 ds $1 - ds $6 +wcda8:: ; cda8 + ds $2 + +wcdaa:: ; cdaa + ds $2 + +wcdac:: ; cdac + ds $2 ; pointer to a list of card IDs for sorting AI hand wcdae:: ; cdae -- cgit v1.2.3 From 034658ba2b623cce0d1b8626ff41c0cdf9dfd6cb Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 17:01:35 +0100 Subject: Unpack Legendary Zapdos AI --- src/engine/bank05.asm | 146 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 142 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 92fc0aa..df1fa5d 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -12,7 +12,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK - dw $4b0f ; LEGENDARY_ZAPDOS_DECK + dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK dw $4c0b ; LEGENDARY_ARTICUNO_DECK dw $4d60 ; LEGENDARY_DRAGONITE_DECK dw $4e89 ; FIRST_STRIKE_DECK @@ -1895,8 +1895,146 @@ Func_14a81: ; 14a81 (5:4a81) ret ; 0x14b0f -Func_14b0f: ; 14b0f (5:4b0f) - INCROM $14b0f, $14c91 +PointerTable_14b0f: ; 14b0f (05:4b0f) + dw Func_14b1b + dw Func_14b1b + dw Func_14b1f + dw Func_14b30 + dw Func_14b34 + dw Func_14b38 + +Func_14b1b: ; 14b1b (5:4b1b) + INCROM $14b1b, $14b1f + +Func_14b1f: ; 14b1f (5:4b1f) + call InitAIDuelVars + call Func_14b6c + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14b30 + +Func_14b30: ; 14b30 (5:4b30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b34 + +Func_14b34: ; 14b34 (5:4b34) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b38 + +Func_14b38: ; 14b38 (5:4b38) + call _AIPickPrizeCards + ret +; 0x14b3c + +Data_14b3c: ; 14b3c (5:4b3c) + db ELECTABUZZ2 + db VOLTORB + db EEVEE + db ZAPDOS1 + db ZAPDOS2 + db ZAPDOS3 + db $00 + +Data_14b43: ; 14b43 (5:4b43) + db ZAPDOS2 + db ZAPDOS1 + db EEVEE + db VOLTORB + db ELECTABUZZ2 + db $00 + +Data_14b49: ; 14b49 (5:4b49) + db EEVEE + db $80 - 5 + db VOLTORB + db $80 - 5 + db ELECTABUZZ2 + db $80 - 5 + db $00 + +Data_14b50: ; 14b50 (5:4b50) + db VOLTORB + db 1 + db $80 - 1 + + db ELECTRODE1 + db 3 + db $80 + 0 + + db ELECTABUZZ2 + db 2 + db $80 - 1 + + db JOLTEON2 + db 3 + db $80 + 1 + + db ZAPDOS1 + db 4 + db $80 + 2 + + db ZAPDOS2 + db 4 + db $80 + 2 + + db ZAPDOS3 + db 3 + db $80 + 1 + + db EEVEE + db 3 + db $80 + 0 + + db $00 + +Data_14b69: ; 14b69 (5:4b69) + db GAMBLER + db ZAPDOS3 + db $00 + +Func_14b6c: ; 14b6c (5:4b6c) + ld hl, wcda8 + ld de, Data_14b69 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14b3c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14b43 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14b43 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14b50 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14b9a + +Func_14b9a: ; 14b9a (5:4b9a) + INCROM $14b9a, $14c91 ; this routine handles how Legendary Articuno ; prioritises playing energy cards to each Pokémon. @@ -2002,7 +2140,7 @@ Data_1514f: ; 1514f (5:514f) ; input: ; a = card ID ; output: -; a = card deck index, if found +; a = card deck index, if found ; carry set if found LookForCardIDInHandList_Bank5: ; 155d2 (5:55d2) ld [wTempCardIDToLook], a -- cgit v1.2.3 From ca8bac48dc6870062ff6cf546d908643f3b6fbca Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 17:58:11 +0100 Subject: Unpack Legendary Articuno AI --- src/engine/bank05.asm | 136 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index df1fa5d..b2f8c47 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -13,7 +13,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK - dw $4c0b ; LEGENDARY_ARTICUNO_DECK + dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK dw $4d60 ; LEGENDARY_DRAGONITE_DECK dw $4e89 ; FIRST_STRIKE_DECK dw $4f0e ; ROCK_CRUSHER_DECK @@ -2034,7 +2034,139 @@ Func_14b6c: ; 14b6c (5:4b6c) ; 0x14b9a Func_14b9a: ; 14b9a (5:4b9a) - INCROM $14b9a, $14c91 + INCROM $14b9a, $14c0b + +PointerTable_14c0b: ; 14c0b (5:4c0b) + dw Func_14c17 + dw Func_14c17 + dw Func_14c1b + dw Func_14c2c + dw Func_14c30 + dw Func_14c34 + +Func_14c17: ; 14c17 (5:4c17) + INCROM $14c17, $14c1b + +Func_14c1b: ; 14c1b (5:4c1b) + call InitAIDuelVars + call Func_14c63 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14c2c + +Func_14c2c: ; 14c2c (5:4c2c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c30 + +Func_14c30: ; 14c30 (5:4c30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c34 + +Func_14c34: ; 14c34 (5:4c34) + call _AIPickPrizeCards + ret +; 0x14c38 + +Data_14c38: ; 14c38 (5:4c38) + db CHANSEY + db LAPRAS + db DITTO + db SEEL + db ARTICUNO1 + db ARTICUNO2 + db $00 + +Data_14c3f: ; 14c3f (5:4c3f) + db ARTICUNO1 + db SEEL + db LAPRAS + db CHANSEY + db DITTO + db $00 + +Data_14c45: ; 14c45 (5:4c45) + db SEEL + db $80 - 3 + db DITTO + db $80 - 3 + db $00 + +Data_14c4a: ; 14c4a (5:4c4a) + db SEEL + db 3 + db $80 + 1 + + db DEWGONG + db 4 + db $80 + 0 + + db LAPRAS + db 3 + db $80 + 0 + + db ARTICUNO1 + db 4 + db $80 + 1 + + db ARTICUNO2 + db 3 + db $80 + 0 + + db CHANSEY + db 0 + db $80 - 8 + + db DITTO + db 3 + db $80 + 0 + + db $00 + +Data_14c60: ; 14c60 (5:4c60) + db GAMBLER + db ARTICUNO2 + db $00 + +Func_14c63: ; 14c63 (5:4c63) + ld hl, wcda8 + ld de, Data_14c60 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14c38 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14c3f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14c3f + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14c4a + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14c91 ; this routine handles how Legendary Articuno ; prioritises playing energy cards to each Pokémon. -- cgit v1.2.3 From 6cf73da905c32beeb8e1abc63b503e12871b775d Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 18:51:41 +0100 Subject: Unpack Legendary Dragonite AI --- src/engine/bank05.asm | 151 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index b2f8c47..2e57173 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -14,7 +14,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK - dw $4d60 ; LEGENDARY_DRAGONITE_DECK + dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK dw $4e89 ; FIRST_STRIKE_DECK dw $4f0e ; ROCK_CRUSHER_DECK dw $4f8f ; GO_GO_RAIN_DANCE_DECK @@ -2244,7 +2244,154 @@ ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) ; 0x14cf7 Func_14cf7: ; 14cf7 (5:4cf7) - INCROM $14cf7, $1514f + INCROM $14cf7, $14d60 + +PointerTable_14d60: ; 14d60 (05:4d60) + dw Func_14d6c + dw Func_14d6c + dw Func_14d70 + dw Func_14d81 + dw Func_14d85 + dw Func_14d89 + +Func_14d6c: ; 14d6c (5:4d6c) + INCROM $14d6c, $14d70 + +Func_14d70: ; 14d70 (5:4d70) + call InitAIDuelVars + call Func_14dc1 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14d81 + +Func_14d81: ; 14d81 (5:4d81) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d85 + +Func_14d85: ; 14d85 (5:4d85) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d89 + +Func_14d89: ; 14d89 (5:4d89) + call _AIPickPrizeCards + ret +; 0x14d8d + +Data_14d8d: ; 14d8d (5:4d8d) + db KANGASKHAN + db LAPRAS + db CHARMANDER + db DRATINI + db MAGIKARP + db $00 + +Data_14d93: ; 14d93 (5:4d93) + db CHARMANDER + db MAGIKARP + db DRATINI + db LAPRAS + db KANGASKHAN + db $00 + +Data_14d99: ; 14d99 (5:4d99) + db CHARMANDER + db $80 - 1 + db MAGIKARP + db $80 - 5 + db $00 + +Data_14d9e: ; 14d9e (5:4d9e) + db CHARMANDER + db 3 + db $80 + 1 + + db CHARMELEON + db 4 + db $80 + 1 + + db CHARIZARD + db 5 + db $80 + 0 + + db MAGIKARP + db 3 + db $80 + 1 + + db GYARADOS + db 4 + db $80 - 1 + + db DRATINI + db 2 + db $80 + 0 + + db DRAGONAIR + db 4 + db $80 + 0 + + db DRAGONITE1 + db 3 + db $80 - 1 + + db KANGASKHAN + db 2 + db $80 - 2 + + db LAPRAS + db 3 + db $80 + 0 + + db $00 + +Data_14dbd: ; 14dbd (5:4dbd) + db GAMBLER + db DRAGONITE1 + db KANGASKHAN + db $00 + +Func_14dc1: ; 14dc1 (5:4dc1) + ld hl, wcda8 + ld de, Data_14dbd + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14d8d + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14d93 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14d93 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14d9e + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14def + +Func_14def: ; 14def (5:4def) + INCROM $14def, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From 2e1c7a1934382df139e2c396e58c10516186d349 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 19:18:33 +0100 Subject: Unpack First Strike AI --- src/engine/bank05.asm | 138 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 2e57173..002c670 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -15,7 +15,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK - dw $4e89 ; FIRST_STRIKE_DECK + dw PointerTable_14e89 ; FIRST_STRIKE_DECK dw $4f0e ; ROCK_CRUSHER_DECK dw $4f8f ; GO_GO_RAIN_DANCE_DECK dw $5019 ; ZAPPING_SELFDESTRUCT_DECK @@ -2391,7 +2391,141 @@ Func_14dc1: ; 14dc1 (5:4dc1) ; 0x14def Func_14def: ; 14def (5:4def) - INCROM $14def, $1514f + INCROM $14def, $14e89 + +PointerTable_14e89: ; 14e89 (5:4e89) + dw Func_14e95 + dw Func_14e95 + dw Func_14e99 + dw Func_14eaa + dw Func_14eae + dw Func_14eb2 + +Func_14e95: ; 14e95 (5:4e95) + INCROM $14e95, $14e99 + +Func_14e99: ; 14e99 (5:4e99) + call InitAIDuelVars + call Func_14ee0 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14eaa + +Func_14eaa: ; 14eaa (5:4eaa) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eae + +Func_14eae: ; 14eae (5:4eae) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eb2 + +Func_14eb2: ; 14eb2 (5:4eb2) + call _AIPickPrizeCards + ret +; 0x14eb6 + +Data_14eb6: ; 14eb6 (5:1eb6) + db HITMONCHAN + db MACHOP + db HITMONLEE + db MANKEY + db $00 + +Data_14ebb: ; 14ebb (5:1ebb) + db MACHOP + db HITMONLEE + db HITMONCHAN + db MANKEY + db $00 + +Data_14ec0: ; 14ec0 (5:1ec0) + db MACHOP + db $80 - 1 + db MACHOKE + db $80 - 1 + db MANKEY + db $80 - 2 + db $00 + +Data_14ec7: ; 14ec7 (5:1ec7) + db MACHOP + db 3 + db $80 + + db MACHOKE + db 4 + db $80 + + db MACHAMP + db 4 + db $80 - 1 + + db HITMONCHAN + db 3 + db $80 + + db HITMONLEE + db 3 + db $80 + + db MANKEY + db 2 + db $80 - 1 + + db PRIMEAPE + db 3 + db $80 - 1 + + db $00 + +Data_14edd: ; 14edd (5:1edd) + db HITMONLEE + db HITMONCHAN + db $00 + +Func_14ee0: ; 14ee0 (5:4ee0) + ld hl, wcda8 + ld de, Data_14edd + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14eb6 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14ebb + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14ebb + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14ec7 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14f0e + +Func_14f0e: ; 14f0e (5:4f0e) + INCROM $14f0e, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From 242195b1b96e7abba4f561be00431a3d5ec222fd Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 19:32:51 +0100 Subject: Unpack Rock Crusher AI --- src/engine/bank05.asm | 133 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 002c670..c430880 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -16,7 +16,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK dw PointerTable_14e89 ; FIRST_STRIKE_DECK - dw $4f0e ; ROCK_CRUSHER_DECK + dw PointerTable_14f0e ; ROCK_CRUSHER_DECK dw $4f8f ; GO_GO_RAIN_DANCE_DECK dw $5019 ; ZAPPING_SELFDESTRUCT_DECK dw $509b ; FLOWER_POWER_DECK @@ -2524,8 +2524,135 @@ Func_14ee0: ; 14ee0 (5:4ee0) ret ; 0x14f0e -Func_14f0e: ; 14f0e (5:4f0e) - INCROM $14f0e, $1514f +PointerTable_14f0e: ; 14f0e (5:4f0e) + dw Func_14f1a + dw Func_14f1a + dw Func_14f1e + dw Func_14f2f + dw Func_14f33 + dw Func_14f37 + +Func_14f1a: ; 14f1a (5:4f1a) + INCROM $14f1a, $14f1e + +Func_14f1e: ; 14f1e (5:4f1e) + call InitAIDuelVars + call Func_14f61 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14f2f + +Func_14f2f: ; 14f2f (5:4f2f) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f33 + +Func_14f33: ; 14f33 (5:4f33) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f37 + +Func_14f37: ; 14f37 (5:4f37) + call _AIPickPrizeCards + ret +; 0x14f3b + +Data_14f3b: ; 14f3b (5:4f3b) + db RHYHORN + db ONIX + db GEODUDE + db DIGLETT + db $00 + +Data_14f40: ; 14f40 (5:4f40) + db DIGLETT + db GEODUDE + db RHYHORN + db ONIX + db $00 + +Data_14f45: ; 14f45 (5:4f45) + db DIGLETT + db $80 - 1 + db $00 + +Data_14f48: ; 14f48 (5:4f48) + db DIGLETT + db 3 + db $80 + 1 + + db DUGTRIO + db 4 + db $80 + 0 + + db GEODUDE + db 2 + db $80 + 1 + + db GRAVELER + db 3 + db $80 + 0 + + db GOLEM + db 4 + db $80 + 0 + + db ONIX + db 2 + db $80 - 1 + + db RHYHORN + db 3 + db $80 + 0 + + db $00 + +Data_14f5e: ; 14f5e (5:4f5e) + db ENERGY_REMOVAL + db RHYHORN + db $00 + +Func_14f61: ; 14f61 (5:4f61) + ld hl, wcda8 + ld de, Data_14f5e + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14f3b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14f40 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14f40 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14f48 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14f8f + +Func_14f8f: ; 14f8f (5:4f8f) + INCROM $14f8f, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From a75b2f973a9a16cd8e2d4886e8bf7532492ba86c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 19:49:44 +0100 Subject: Unpack Go Go Rain Dance AI --- src/engine/bank05.asm | 143 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index c430880..ad2d6b4 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -17,7 +17,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK dw PointerTable_14e89 ; FIRST_STRIKE_DECK dw PointerTable_14f0e ; ROCK_CRUSHER_DECK - dw $4f8f ; GO_GO_RAIN_DANCE_DECK + dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK dw $5019 ; ZAPPING_SELFDESTRUCT_DECK dw $509b ; FLOWER_POWER_DECK dw $5122 ; STRANGE_PSYSHOCK_DECK @@ -2651,8 +2651,145 @@ Func_14f61: ; 14f61 (5:4f61) ret ; 0x14f8f -Func_14f8f: ; 14f8f (5:4f8f) - INCROM $14f8f, $1514f +PointerTable_14f8f: ; 14f8f (5:4f8f) + dw Func_14f9b + dw Func_14f9b + dw Func_14f9f + dw Func_14fb0 + dw Func_14fb4 + dw Func_14fb8 + +Func_14f9b: ; 14f9b (5:4f9b) + INCROM $14f9b, $14f9f + +Func_14f9f: ; 14f9f (5:4f9f) + call InitAIDuelVars + call Func_14feb + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14fb0 + +Func_14fb0: ; 14fb0 (5:4fb0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb4 + +Func_14fb4: ; 14fb4 (5:4fb4) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb8 + +Func_14fb8: ; 14fb8 (5:4fb8) + call _AIPickPrizeCards + ret +; 0x14fbc + +Data_14fbc: ; 14fbc (5:4fbc) + db LAPRAS + db HORSEA + db GOLDEEN + db SQUIRTLE + db $00 + +Data_14fc1: ; 14fc1 (5:4fc1) + db SQUIRTLE + db HORSEA + db GOLDEEN + db LAPRAS + db $00 + +Data_14fc6: ; 14fc6 (5:4fc6) + db SQUIRTLE + db $80 - 3 + db WARTORTLE + db $80 - 2 + db HORSEA + db $80 - 1 + db $00 + +Data_14fcd: ; 14fcd (5:4fcd) + db SQUIRTLE + db 2 + db $80 + 0 + + db WARTORTLE + db 3 + db $80 + 0 + + db BLASTOISE + db 5 + db $80 + 0 + + db GOLDEEN + db 1 + db $80 + 0 + + db SEAKING + db 2 + db $80 + 0 + + db HORSEA + db 2 + db $80 + 0 + + db SEADRA + db 3 + db $80 + 0 + + db LAPRAS + db 3 + db $80 + 0 + + db $00 + +Data_14fe6: ; 14fe6 (5:4fe6) + db GAMBLER + db ENERGY_RETRIEVAL + db SUPER_ENERGY_RETRIEVAL + db BLASTOISE + db $00 + +Func_14feb: ; 14feb (5:4feb) + ld hl, wcda8 + ld de, Data_14fe6 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14fbc + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14fc1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14fc1 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14fcd + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15019 + +Func_15019: ; 15019 (5:5019) + INCROM $15019, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From d162e1bda676fb51a656472960bb63f354919b37 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 20:01:20 +0100 Subject: Unpack Zapping Selfdestruct AI --- src/engine/bank05.asm | 132 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 129 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index ad2d6b4..a5abcd8 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -18,7 +18,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14e89 ; FIRST_STRIKE_DECK dw PointerTable_14f0e ; ROCK_CRUSHER_DECK dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK - dw $5019 ; ZAPPING_SELFDESTRUCT_DECK + dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK dw $509b ; FLOWER_POWER_DECK dw $5122 ; STRANGE_PSYSHOCK_DECK dw $51ad ; WONDERS_OF_SCIENCE_DECK @@ -2788,8 +2788,134 @@ Func_14feb: ; 14feb (5:4feb) ret ; 0x15019 -Func_15019: ; 15019 (5:5019) - INCROM $15019, $1514f +PointerTable_15019: ; 15019 (5:5019) + dw Func_15025 + dw Func_15025 + dw Func_15029 + dw Func_1503a + dw Func_1503e + dw Func_15042 + +Func_15025: ; 15025 (5:5025) + INCROM $15025, $15029 + +Func_15029: ; 15029 (5:5029) + call InitAIDuelVars + call Func_1506d + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1503a + +Func_1503a: ; 1503a (5:503a) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1503e + +Func_1503e: ; 1503e (5:503e) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15042 + +Func_15042: ; 15042 (5:5042) + call _AIPickPrizeCards + ret +; 0x15046 + +Data_15046: ; 15046 (5:5046) + db KANGASKHAN + db ELECTABUZZ2 + db TAUROS + db MAGNEMITE1 + db VOLTORB + db $00 + +Data_1504c: ; 1504c (5:504c) + db MAGNEMITE1 + db VOLTORB + db ELECTABUZZ2 + db TAUROS + db KANGASKHAN + db $00 + +Data_15052: ; 15052 (5:5052) + db VOLTORB + db $80 - 1 + db $00 + +Data_15055: ; 15055 (5:5055) + db MAGNEMITE1 + db 3 + db $80 + 1 + + db MAGNETON1 + db 4 + db $80 + 0 + + db VOLTORB + db 3 + db $80 + 1 + + db ELECTRODE1 + db 3 + db $80 + 0 + + db ELECTABUZZ2 + db 1 + db $80 + 0 + + db KANGASKHAN + db 2 + db $80 - 2 + + db TAUROS + db 3 + db $80 + 0 + + db $00 + +Data_1506b: ; 1506b (5:506b) + db KANGASKHAN + db $00 + +Func_1506d: ; 1506d (5:506d) + ld hl, wcda8 + ld de, Data_1506b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15046 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_1504c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_1504c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_15055 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1509b + +Func_1509b: ; 1509b (5:509b) + INCROM $1509b, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From cd81fb59453cb8306c93a8ec9d4f05113f3a2b48 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 20:22:06 +0100 Subject: Unpack Flower Power AI --- src/engine/bank05.asm | 140 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index a5abcd8..2d5d8cc 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -19,7 +19,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14f0e ; ROCK_CRUSHER_DECK dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK - dw $509b ; FLOWER_POWER_DECK + dw PointerTable_1509b ; FLOWER_POWER_DECK dw $5122 ; STRANGE_PSYSHOCK_DECK dw $51ad ; WONDERS_OF_SCIENCE_DECK dw $5232 ; FIRE_CHARGE_DECK @@ -2914,8 +2914,142 @@ Func_1506d: ; 1506d (5:506d) ret ; 0x1509b -Func_1509b: ; 1509b (5:509b) - INCROM $1509b, $1514f +PointerTable_1509b: ; 1509b (5:509b) + dw Func_150a7 + dw Func_150a7 + dw Func_150ab + dw Func_150bc + dw Func_150c0 + dw Func_150c4 + +Func_150a7: ; 150a7 (5:50a7) + INCROM $150a7, $150ab + +Func_150ab: ; 150ab (5:50ab) + call InitAIDuelVars + call Func_150f4 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x150bc + +Func_150bc: ; 150bc (5:50bc) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c0 + +Func_150c0: ; 150c0 (5:50c0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c4 + +Func_150c4: ; 150c4 (5:50c4) + call _AIPickPrizeCards + ret +; 0x150c8 + +Data_150c8 ; 150c8 (5:50c8) + db ODDISH + db EXEGGCUTE + db BULBASAUR + db $00 + +Data_150cc ; 150cc (5:50cc) + db BULBASAUR + db EXEGGCUTE + db ODDISH + db $00 + +Data_150cf ; 150cf (5:50cf) + db GLOOM + db $80 - 2 + db VILEPLUME + db $80 - 2 + db BULBASAUR + db $80 - 2 + db IVYSAUR + db $80 - 2 + db $00 + +Data_150d9 ; 150d9 (5:50d9) + db BULBASAUR + db 3 + db $80 + 0 + + db IVYSAUR + db 4 + db $80 + 0 + + db VENUSAUR2 + db 4 + db $80 + 0 + + db ODDISH + db 2 + db $80 + 0 + + db GLOOM + db 3 + db $80 - 1 + + db VILEPLUME + db 3 + db $80 - 1 + + db EXEGGCUTE + db 3 + db $80 + 0 + + db EXEGGUTOR + db 22 + db $80 + 0 + + db $00 + +Data_150f2 ; 150f2 (5:50f2) + db VENUSAUR2 + db $00 + +Func_150f4: ; 150f4 (5:50f4) + ld hl, wcda8 + ld de, Data_150f2 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_150c8 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_150cc + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_150cc + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_150d9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15122 + +Func_15122: ; 15122 (5:5122) + INCROM $15122, $1514f ; these seem to be lists of card IDs ; for the AI to look up in their hand -- cgit v1.2.3 From ba22f3fa6b065bd84f5f8605ffd46b9e9fe91d1c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 20:39:15 +0100 Subject: Unpack Strange Psyshock AI --- src/engine/bank05.asm | 128 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 2d5d8cc..6ee57ae 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -20,7 +20,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK dw PointerTable_1509b ; FLOWER_POWER_DECK - dw $5122 ; STRANGE_PSYSHOCK_DECK + dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK dw $51ad ; WONDERS_OF_SCIENCE_DECK dw $5232 ; FIRE_CHARGE_DECK dw $52bd ; IM_RONALD_DECK @@ -3048,11 +3048,42 @@ Func_150f4: ; 150f4 (5:50f4) ret ; 0x15122 -Func_15122: ; 15122 (5:5122) - INCROM $15122, $1514f +PointerTable_15122: ; 15122 (5:5122) + dw Func_1512e + dw Func_1512e + dw Func_15132 + dw Func_15143 + dw Func_15147 + dw Func_1514b + +Func_1512e: ; 1512e (5:512e) + INCROM $1512e, $15132 + +Func_15132: ; 15132 (5:5132) + call InitAIDuelVars + call Func_1517f + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15143 + +Func_15143: ; 15143 (5:5143) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15147 + +Func_15147: ; 15147 (5:5147) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1514b + +Func_1514b: ; 1514b (5:514b) + call _AIPickPrizeCards + ret +; 0x1514f -; these seem to be lists of card IDs -; for the AI to look up in their hand Data_1514f: ; 1514f (5:514f) db KANGASKHAN db CHANSEY @@ -3061,6 +3092,7 @@ Data_1514f: ; 1514f (5:514f) db ABRA db $00 +Data_15155: ; 15155 (5:5155) db ABRA db MR_MIME db KANGASKHAN @@ -3068,7 +3100,91 @@ Data_1514f: ; 1514f (5:514f) db CHANSEY db $00 - INCROM $1515b, $155d2 +Data_1515b: ; 1515b (5:515b) + db ABRA + db $80 - 3 + db SNORLAX + db $80 - 3 + db KANGASKHAN + db $80 - 1 + db CHANSEY + db $80 - 1 + db $00 + +Data_15164 ; 15164 (5:5164) + db ABRA + db 3 + db $80 + 1 + + db KADABRA + db 3 + db $80 + 0 + + db ALAKAZAM + db 3 + db $80 + 0 + + db MR_MIME + db 2 + db $80 + 0 + + db CHANSEY + db 2 + db $80 - 2 + + db KANGASKHAN + db 4 + db $80 - 2 + + db SNORLAX + db 0 + db $80 - 8 + + db $00 + +Data_1517a ; 1517a (5:517a) + db GAMBLER + db MR_MIME + db ALAKAZAM + db SWITCH + db $00 + +Func_1517f: ; 1517f (5:517f) + ld hl, wcda8 + ld de, Data_1517a + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1514f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15155 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15155 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_15164 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x151ad + +Func_151ad: ; 151ad (5:51ad) + INCROM $151ad, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From 1d3fb18c67c686ea666d570de76314f2821a8f14 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 20:52:18 +0100 Subject: Unpack Wonders of Science AI --- src/engine/bank05.asm | 136 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 133 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 6ee57ae..58eb240 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -21,7 +21,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK dw PointerTable_1509b ; FLOWER_POWER_DECK dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK - dw $51ad ; WONDERS_OF_SCIENCE_DECK + dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK dw $5232 ; FIRE_CHARGE_DECK dw $52bd ; IM_RONALD_DECK dw $534b ; POWERFUL_RONALD_DECK @@ -3183,8 +3183,138 @@ Func_1517f: ; 1517f (5:517f) ret ; 0x151ad -Func_151ad: ; 151ad (5:51ad) - INCROM $151ad, $155d2 +PointerTable_151ad: ; 151ad (5:51ad) + dw Func_151b9 + dw Func_151b9 + dw Func_151bd + dw Func_151ce + dw Func_151d2 + dw Func_151d6 + +Func_151b9: ; 151b9 (5:51b9) + INCROM $151b9, $151bd + +Func_151bd: ; 151bd (5:51bd) + call InitAIDuelVars + call Func_15204 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x151ce + +Func_151ce: ; 151ce (5:51ce) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d2 + +Func_151d2: ; 151d2 (5:51d2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d6 + +Func_151d6: ; 151d6 (5:51d6) + call _AIPickPrizeCards + ret +; 0x151da + +Data_151da: ; 151da (5:51da) + db MEWTWO1 + db MEWTWO3 + db MEWTWO2 + db GRIMER + db KOFFING + db PORYGON + db $00 + +Data_151e1: ; 151e1 (5:51e1) + db GRIMER + db KOFFING + db MEWTWO3 + db MEWTWO2 + db MEWTWO1 + db PORYGON + db $00 + +Data_151e8: ; 151e8 (5:51e8) + db $00 + +Data_151e9: ; 151e9 (5:51e9) + db GRIMER + db 3 + db $80 + 0 + + db MUK + db 4 + db $80 + 0 + + db KOFFING + db 2 + db $80 + 0 + + db WEEZING + db 3 + db $80 + 0 + + db MEWTWO1 + db 2 + db $80 - 1 + + db MEWTWO3 + db 2 + db $80 - 1 + + db MEWTWO2 + db 2 + db $80 - 1 + + db PORYGON + db 2 + db $80 - 1 + + db $00 + +Data_15202: ; 15202 (5:5202) + db MUK + db $00 + +Func_15204: ; 15204 (5:5204) + ld hl, wcda8 + ld de, Data_15202 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_151da + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_151e1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_151e1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_151e9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15232 + +Func_15232: ; 15232 (5:5232) + INCROM $15232, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From e123bd3c3f54ad74143b19ef1497d25eb61cf72c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 21:15:26 +0100 Subject: Unpack Fire Charge AI --- src/engine/bank05.asm | 142 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 58eb240..973f753 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -22,7 +22,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_1509b ; FLOWER_POWER_DECK dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK - dw $5232 ; FIRE_CHARGE_DECK + dw PointerTable_15232 ; FIRE_CHARGE_DECK dw $52bd ; IM_RONALD_DECK dw $534b ; POWERFUL_RONALD_DECK dw $53e8 ; INVINCIBLE_RONALD_DECK @@ -3313,8 +3313,144 @@ Func_15204: ; 15204 (5:5204) ret ; 0x15232 -Func_15232: ; 15232 (5:5232) - INCROM $15232, $155d2 +PointerTable_15232: ; 15232 (5:5232) + dw Func_1523e + dw Func_1523e + dw Func_15242 + dw Func_15253 + dw Func_15257 + dw Func_1525b + +Func_1523e: ; 1523e (5:523e) + INCROM $1523e, $15242 + +Func_15242: ; 15242 (5:5242) + call InitAIDuelVars + call Func_1528f + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15253 + +Func_15253: ; 15253 (5:5253) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15257 + +Func_15257: ; 15257 (5:5257) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1525b + +Func_1525b: ; 1525b (5:525b) + call _AIPickPrizeCards + ret +; 0x1525f + +Data_1525f: ; 1525f (5:525f) + db JIGGLYPUFF3 + db CHANSEY + db TAUROS + db MAGMAR1 + db JIGGLYPUFF1 + db GROWLITHE + db $00 + +Data_15266: ; 15266 (5:5266) + db JIGGLYPUFF3 + db CHANSEY + db GROWLITHE + db MAGMAR1 + db JIGGLYPUFF1 + db TAUROS + db $00 + +Data_1526e: ; 1526e (5:526e) + db JIGGLYPUFF1 + db $80 - 1 + db CHANSEY + db $80 - 1 + db GROWLITHE + db $80 - 1 + db $00 + +Data_15274: ; 15274 (5:5274) + db GROWLITHE + db 3 + db $80 + 0 + + db ARCANINE2 + db 4 + db $80 + 0 + + db MAGMAR1 + db 3 + db $80 + 0 + + db JIGGLYPUFF1 + db 3 + db $80 + 0 + + db JIGGLYPUFF3 + db 2 + db $80 + 0 + + db WIGGLYTUFF + db 3 + db $80 + 0 + + db CHANSEY + db 4 + db $80 + 0 + + db TAUROS + db 3 + db $80 + 0 + + db $00 + +Data_1528d: ; 1528d (5:528d) + db GAMBLER + db $00 + +Func_1528f: ; 1528f (5:528f) + ld hl, wcda8 + ld de, Data_1528d + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1525f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15266 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15266 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_15274 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x152bd + +Func_152bd: ; 152bd (5:52bd) + INCROM $152bd, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From 6669dbb15e57a350eba01d54964192223c9df234 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 21:35:43 +0100 Subject: Unpack Im Ronald AI --- src/engine/bank05.asm | 151 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 147 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 973f753..1521c27 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -23,7 +23,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK dw PointerTable_15232 ; FIRE_CHARGE_DECK - dw $52bd ; IM_RONALD_DECK + dw PointerTable_152bd ; IM_RONALD_DECK dw $534b ; POWERFUL_RONALD_DECK dw $53e8 ; INVINCIBLE_RONALD_DECK dw $546f ; LEGENDARY_RONALD_DECK @@ -3313,7 +3313,7 @@ Func_15204: ; 15204 (5:5204) ret ; 0x15232 -PointerTable_15232: ; 15232 (5:5232) +PointerTable_15232: ; 15232 (5:52PointerTable_12) dw Func_1523e dw Func_1523e dw Func_15242 @@ -3449,8 +3449,151 @@ Func_1528f: ; 1528f (5:528f) ret ; 0x152bd -Func_152bd: ; 152bd (5:52bd) - INCROM $152bd, $155d2 + +PointerTable_152bd: ; 152bd (5:52bd) + dw Func_152c9 + dw Func_152c9 + dw Func_152cd + dw Func_152de + dw Func_152e2 + dw Func_152e6 + +Func_152c9: ; 152c9 (5:52c9) + INCROM $152c9, $152cd + +Func_152cd: ; 152cd (5:52cd) + call InitAIDuelVars + call Func_1531d + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x152de + +Func_152de: ; 152de (5:52de) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e2 + +Func_152e2: ; 152e2 (5:52e2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e6 + +Func_152e6: ; 152e6 (5:52e6) + call _AIPickPrizeCards + ret +; 0x152ea + +Data_152ea: ; 152ea (5:52ea) + db LAPRAS + db SEEL + db CHARMANDER + db CUBONE + db SQUIRTLE + db GROWLITHE + db $00 + +Data_152f1: ; 152f1 (5:52f1) + db CHARMANDER + db SQUIRTLE + db SEEL + db CUBONE + db GROWLITHE + db LAPRAS + db $00 + +Data_152f8: ; 152f8 (5:52f8) + db $00 + +Data_152f9: ; 152f9 (5:52f9) + db CHARMANDER + db 3 + db $80 + 0 + + db CHARMELEON + db 5 + db $80 + 0 + + db GROWLITHE + db 2 + db $80 + 0 + + db ARCANINE2 + db 4 + db $80 + 0 + + db SQUIRTLE + db 2 + db $80 + 0 + + db WARTORTLE + db 3 + db $80 + 0 + + db SEEL + db 3 + db $80 + 0 + + db DEWGONG + db 4 + db $80 + 0 + + db LAPRAS + db 3 + db $80 + 0 + + db CUBONE + db 3 + db $80 + 0 + + db MAROWAK1 + db 3 + db $80 + 0 + + db $00 + +Data_1531b: ; 1531b (5:531b) + db LAPRAS + db $00 + +Func_1531d: ; 1531d (5:531d) + ld hl, wcda8 + ld de, Data_1531b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_152ea + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_152f1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_152f1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_152f9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1534b + +Func_1534b: ; 1534b (5:534b) + INCROM $1534b, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From 6018422a4fc24799a24ef72fb58404fb4f3b9a7c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 22:00:05 +0100 Subject: Unpack Powerful Ronald AI --- src/engine/bank05.asm | 164 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 1521c27..74635c8 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -24,7 +24,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK dw PointerTable_15232 ; FIRE_CHARGE_DECK dw PointerTable_152bd ; IM_RONALD_DECK - dw $534b ; POWERFUL_RONALD_DECK + dw PointerTable_1534b ; POWERFUL_RONALD_DECK dw $53e8 ; INVINCIBLE_RONALD_DECK dw $546f ; LEGENDARY_RONALD_DECK dw $48dc ; MUSCLES_FOR_BRAINS_DECK @@ -3449,7 +3449,6 @@ Func_1528f: ; 1528f (5:528f) ret ; 0x152bd - PointerTable_152bd: ; 152bd (5:52bd) dw Func_152c9 dw Func_152c9 @@ -3592,8 +3591,165 @@ Func_1531d: ; 1531d (5:531d) ret ; 0x1534b -Func_1534b: ; 1534b (5:534b) - INCROM $1534b, $155d2 +PointerTable_1534b: ; 1534b (5:534b) + dw Func_15357 + dw Func_15357 + dw Func_1535b + dw Func_1536c + dw Func_15370 + dw Func_15374 + +Func_15357: ; 15357 (5:5357) + INCROM $15357, $1535b + +Func_1535b: ; 1535b (5:535b) + call InitAIDuelVars + call Func_153ba + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1536c + +Func_1536c: ; 1536c (5:536c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15370 + +Func_15370: ; 15370 (5:5370) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15374 + +Func_15374: ; 15374 (5:5374) + call _AIPickPrizeCards + ret +; 0x15378 + +Data_15378: ; 15378 (5:5378) + db KANGASKHAN + db ELECTABUZZ2 + db HITMONCHAN + db MR_MIME + db LICKITUNG + db HITMONLEE + db TAUROS + db JYNX + db MEWTWO1 + db DODUO + db $00 + +Data_15383: ; 15383 (5:5383) + db KANGASKHAN + db HITMONLEE + db HITMONCHAN + db TAUROS + db DODUO + db JYNX + db MEWTWO1 + db ELECTABUZZ2 + db MR_MIME + db LICKITUNG + db $00 + +Data_1538e: ; 1538e (5:538e) + db KANGASKHAN + db $80 - 1 + db DODUO + db $80 - 1 + db DODRIO + db $80 - 1 + db $00 + +Data_15395: ; 15395 (5:5395) + db ELECTABUZZ2 + db 2 + db $80 + 1 + + db HITMONLEE + db 3 + db $80 + 1 + + db HITMONCHAN + db 3 + db $80 + 1 + + db MR_MIME + db 2 + db $80 + 0 + + db JYNX + db 3 + db $80 + 0 + + db MEWTWO1 + db 2 + db $80 + 0 + + db DODUO + db 3 + db $80 - 1 + + db DODRIO + db 3 + db $80 - 1 + + db LICKITUNG + db 2 + db $80 + 0 + + db KANGASKHAN + db 4 + db $80 - 1 + + db TAUROS + db 3 + db $80 + 0 + + db $00 + +Data_153b7: ; 153b7 (5:53b7) + db GAMBLER + db ENERGY_REMOVAL + db $00 + +Func_153ba: ; 153ba (5:53ba) + ld hl, wcda8 + ld de, Data_153b7 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15378 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15383 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15383 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_15395 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x153e8 + +Func_153e8: ; 153e8 (5:53e8) + INCROM $153e8, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From 0097fcd47d38496f8118667c900463e4a958322b Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 22:12:08 +0100 Subject: Unpack Invincible Ronald AI --- src/engine/bank05.asm | 138 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 135 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 74635c8..ea8543d 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -25,7 +25,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_15232 ; FIRE_CHARGE_DECK dw PointerTable_152bd ; IM_RONALD_DECK dw PointerTable_1534b ; POWERFUL_RONALD_DECK - dw $53e8 ; INVINCIBLE_RONALD_DECK + dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK dw $546f ; LEGENDARY_RONALD_DECK dw $48dc ; MUSCLES_FOR_BRAINS_DECK dw PointerTable_14668 ; HEATED_BATTLE_DECK @@ -3748,8 +3748,140 @@ Func_153ba: ; 153ba (5:53ba) ret ; 0x153e8 -Func_153e8: ; 153e8 (5:53e8) - INCROM $153e8, $155d2 +PointerTable_153e8: ; 153e8 (5:53e8) + dw Func_153f4 + dw Func_153f4 + dw Func_153f8 + dw Func_15409 + dw Func_1540d + dw Func_15411 + +Func_153f4: ; 153f4 (5:53f4) + INCROM $153f4, $153f8 + +Func_153f8: ; 153f8 (5:53f8) + call InitAIDuelVars + call Func_15441 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15409 + +Func_15409: ; 15409 (5:5409) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1540d + +Func_1540d: ; 1540d (5:540d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15411 + +Func_15411: ; 15411 (5:5411) + call _AIPickPrizeCards + ret +; 0x15415 + +Data_15415: ; 15415 (5:5415) + db KANGASKHAN + db MAGMAR2 + db CHANSEY + db GEODUDE + db SCYTHER + db GRIMER + db $00 + +Data_1541c: ; 1541c (5:541c) + db GRIMER + db SCYTHER + db GEODUDE + db CHANSEY + db MAGMAR2 + db KANGASKHAN + db $00 + +Data_15423: ; 15423 (5:5423) + db GRIMER + db $80 - 1 + db $00 + +Data_15426: ; 15426 (5:5426) + db GRIMER + db 1 + db $80 - 1 + + db MUK + db 3 + db $80 - 1 + + db SCYTHER + db 4 + db $80 + 1 + + db MAGMAR2 + db 2 + db $80 + 0 + + db GEODUDE + db 2 + db $80 + 0 + + db GRAVELER + db 3 + db $80 + 0 + + db CHANSEY + db 4 + db $80 + 0 + + db KANGASKHAN + db 4 + db $80 - 1 + + db $00 + +Data_1543f: ; 1543f (5:543f) + db GAMBLER + db $00 + +Func_15441: ; 15441 (5:5441) + ld hl, wcda8 + ld de, Data_1543f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15415 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_1541c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_1541c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_15426 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1546f + +Func_1546f: ; 1546f (5:546f) + INCROM $1546f, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From d128e3c263654b20455f00fbd73d046758754789 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 22:22:47 +0100 Subject: Unpack Legendary Ronald AI --- src/engine/bank05.asm | 160 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index ea8543d..44ab4df 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -26,7 +26,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_152bd ; IM_RONALD_DECK dw PointerTable_1534b ; POWERFUL_RONALD_DECK dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK - dw $546f ; LEGENDARY_RONALD_DECK + dw PointerTable_1546f ; LEGENDARY_RONALD_DECK dw $48dc ; MUSCLES_FOR_BRAINS_DECK dw PointerTable_14668 ; HEATED_BATTLE_DECK dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK @@ -3880,8 +3880,162 @@ Func_15441: ; 15441 (5:5441) ret ; 0x1546f -Func_1546f: ; 1546f (5:546f) - INCROM $1546f, $155d2 +PointerTable_1546f: ; 1546f (5:546f) + dw Func_1547b + dw Func_1547b + dw Func_1547f + dw Func_15490 + dw Func_15494 + dw Func_15498 + +Func_1547b: ; 1547b (5:547b) + INCROM $1547b, $1547f + +Func_1547f: ; 1547f (5:547f) + call InitAIDuelVars + call Func_154d9 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15490 + +Func_15490: ; 15490 (5:5490) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15494 + +Func_15494: ; 15494 (5:5494) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15498 + +Func_15498: ; 15498 (5:5498) + call _AIPickPrizeCards + ret +; 0x1549c + +Data_1549c: ; 1549c (5:549c) + db KANGASKHAN + db DRATINI + db EEVEE + db ZAPDOS3 + db ARTICUNO2 + db MOLTRES2 + db $00 + +Data_154a3: ; 154a3 (5:54a3) + db KANGASKHAN + db DRATINI + db EEVEE + db $00 + +Data_154a7: ; 154a7 (5:54a7) + db MOLTRES2 + db ZAPDOS3 + db KANGASKHAN + db DRATINI + db EEVEE + db ARTICUNO2 + db $00 + +Data_154ae: ; 154ae (5:54ae) + db EEVEE + db $80 - 2 + db $00 + +Data_154b1: ; 154b1 (5:54b1) + db FLAREON1 + db 3 + db $80 + + db MOLTRES2 + db 3 + db $80 + + db VAPOREON1 + db 3 + db $80 + + db ARTICUNO2 + db 0 + db $78 + + db JOLTEON1 + db 4 + db $80 + + db ZAPDOS3 + db 0 + db $78 + + db KANGASKHAN + db 4 + db $7f + + db EEVEE + db 3 + db $80 + + db DRATINI + db 3 + db $80 + + db DRAGONAIR + db 4 + db $80 + + db DRAGONITE1 + db 3 + db $80 + + db $00 + +Data_154d3: ; 154d3 (5:54d3) + db MOLTRES2 + db ARTICUNO2 + db ZAPDOS3 + db DRAGONITE1 + db GAMBLER + db $00 + +Func_154d9: ; 154d9 (5:54d9) + ld hl, wcda8 + ld de, Data_154d3 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1549c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_154a3 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_154a7 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_154b1 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15507 + +Func_15507: ; 15507 (5:5507) + INCROM $15507, $155d2 ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card -- cgit v1.2.3 From a8aa9e3ce480725646534ea4a2c13049c72a0770 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 22:28:33 +0100 Subject: Unpack Muscle For Brains AI --- src/engine/bank05.asm | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 44ab4df..2b2b3f8 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -27,7 +27,7 @@ PointerTable_14000: ; 14000 (05:4000) dw PointerTable_1534b ; POWERFUL_RONALD_DECK dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK dw PointerTable_1546f ; LEGENDARY_RONALD_DECK - dw $48dc ; MUSCLES_FOR_BRAINS_DECK + dw PointerTable_148dc ; MUSCLES_FOR_BRAINS_DECK dw PointerTable_14668 ; HEATED_BATTLE_DECK dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK dw PointerTable_14668 ; EXCAVATION_DECK @@ -1657,8 +1657,40 @@ AIPerformSciptedTurn: ; 1483a (5:483a) ret ; 0x148dc -Func_148dc: ; 148dc (5:48dc) - INCROM $148dc, $149e8 +PointerTable_148dc: ; 148dc (5:48dc) + dw Func_148e8 + dw Func_148e8 + dw Func_148ec + dw Func_148f3 + dw Func_148f7 + dw Func_148fb + +Func_148e8: ; 148e8 (5:48e8) + INCROM $148e8, $148ec + +Func_148ec: ; 148ec (5:48ec) + call InitAIDuelVars + call AIPlayInitialBasicCards + ret +; 0x148f3 + +Func_148f3: ; 148f3 (5:48f3) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148f7 + +Func_148f7: ; 148f7 (5:48f7) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148fb + +Func_148fb: ; 148fb (5:48fb) + call _AIPickPrizeCards + ret +; 0x148ff + +Func_148ff: ; 148ff (5:48ff) + INCROM $148ff, $149e8 PointerTable_149e8: ; 149e8 (05:49e8) dw Func_149f4 -- cgit v1.2.3 From 3f7b71184a621c9238ebd24908f78d8618de1b76 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 1 May 2020 10:53:20 +0100 Subject: Re-structure deck AI routines and macros --- src/data/deck_ai_pointers.asm | 55 + src/engine/bank05.asm | 2465 +---------------------------------------- src/engine/deck_ai.asm | 2011 +++++++++++++++++++++++++++++++++ 3 files changed, 2068 insertions(+), 2463 deletions(-) create mode 100644 src/data/deck_ai_pointers.asm create mode 100644 src/engine/deck_ai.asm (limited to 'src') diff --git a/src/data/deck_ai_pointers.asm b/src/data/deck_ai_pointers.asm new file mode 100644 index 0000000..13f148b --- /dev/null +++ b/src/data/deck_ai_pointers.asm @@ -0,0 +1,55 @@ +PointerTable_14000: ; 14000 (05:4000) + dw PointerTable_147bd ; SAMS_PRACTICE_DECK + dw PointerTable_14668 ; PRACTICE_PLAYER_DECK + dw PointerTable_14668 ; SAMS_NORMAL_DECK + dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK + dw PointerTable_14668 ; CHARMANDER_EXTRA_DECK + dw PointerTable_14668 ; SQUIRTLE_AND_FRIENDS_DECK + dw PointerTable_14668 ; SQUIRTLE_EXTRA_DECK + dw PointerTable_14668 ; BULBASAUR_AND_FRIENDS_DECK + dw PointerTable_14668 ; BULBASAUR_EXTRA_DECK + dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK + dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK + dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK + dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK + dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK + dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK + dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK + dw PointerTable_14e89 ; FIRST_STRIKE_DECK + dw PointerTable_14f0e ; ROCK_CRUSHER_DECK + dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK + dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK + dw PointerTable_1509b ; FLOWER_POWER_DECK + dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK + dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK + dw PointerTable_15232 ; FIRE_CHARGE_DECK + dw PointerTable_152bd ; IM_RONALD_DECK + dw PointerTable_1534b ; POWERFUL_RONALD_DECK + dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK + dw PointerTable_1546f ; LEGENDARY_RONALD_DECK + dw PointerTable_148dc ; MUSCLES_FOR_BRAINS_DECK + dw PointerTable_14668 ; HEATED_BATTLE_DECK + dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK + dw PointerTable_14668 ; EXCAVATION_DECK + dw PointerTable_14668 ; BLISTERING_POKEMON_DECK + dw PointerTable_14668 ; HARD_POKEMON_DECK + dw PointerTable_14668 ; WATERFRONT_POKEMON_DECK + dw PointerTable_14668 ; LONELY_FRIENDS_DECK + dw PointerTable_14668 ; SOUND_OF_THE_WAVES_DECK + dw PointerTable_14668 ; PIKACHU_DECK + dw PointerTable_14668 ; BOOM_BOOM_SELFDESTRUCT_DECK + dw PointerTable_14668 ; POWER_GENERATOR_DECK + dw PointerTable_14668 ; ETCETERA_DECK + dw PointerTable_14668 ; FLOWER_GARDEN_DECK + dw PointerTable_14668 ; KALEIDOSCOPE_DECK + dw PointerTable_14668 ; GHOST_DECK + dw PointerTable_14668 ; NAP_TIME_DECK + dw PointerTable_14668 ; STRANGE_POWER_DECK + dw PointerTable_14668 ; FLYIN_POKEMON_DECK + dw PointerTable_14668 ; LOVELY_NIDORAN_DECK + dw PointerTable_14668 ; POISON_DECK + dw PointerTable_14668 ; ANGER_DECK + dw PointerTable_14668 ; FLAMETHROWER_DECK + dw PointerTable_14668 ; RESHUFFLE_DECK + dw PointerTable_148dc ; IMAKUNI_DECK +; 1406a diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 2b2b3f8..96ebe50 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1,58 +1,4 @@ -PointerTable_14000: ; 14000 (05:4000) - dw PointerTable_147bd ; SAMS_PRACTICE_DECK - dw PointerTable_14668 ; PRACTICE_PLAYER_DECK - dw PointerTable_14668 ; SAMS_NORMAL_DECK - dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK - dw PointerTable_14668 ; CHARMANDER_EXTRA_DECK - dw PointerTable_14668 ; SQUIRTLE_AND_FRIENDS_DECK - dw PointerTable_14668 ; SQUIRTLE_EXTRA_DECK - dw PointerTable_14668 ; BULBASAUR_AND_FRIENDS_DECK - dw PointerTable_14668 ; BULBASAUR_EXTRA_DECK - dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK - dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK - dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK - dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK - dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK - dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK - dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK - dw PointerTable_14e89 ; FIRST_STRIKE_DECK - dw PointerTable_14f0e ; ROCK_CRUSHER_DECK - dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK - dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK - dw PointerTable_1509b ; FLOWER_POWER_DECK - dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK - dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK - dw PointerTable_15232 ; FIRE_CHARGE_DECK - dw PointerTable_152bd ; IM_RONALD_DECK - dw PointerTable_1534b ; POWERFUL_RONALD_DECK - dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK - dw PointerTable_1546f ; LEGENDARY_RONALD_DECK - dw PointerTable_148dc ; MUSCLES_FOR_BRAINS_DECK - dw PointerTable_14668 ; HEATED_BATTLE_DECK - dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK - dw PointerTable_14668 ; EXCAVATION_DECK - dw PointerTable_14668 ; BLISTERING_POKEMON_DECK - dw PointerTable_14668 ; HARD_POKEMON_DECK - dw PointerTable_14668 ; WATERFRONT_POKEMON_DECK - dw PointerTable_14668 ; LONELY_FRIENDS_DECK - dw PointerTable_14668 ; SOUND_OF_THE_WAVES_DECK - dw PointerTable_14668 ; PIKACHU_DECK - dw PointerTable_14668 ; BOOM_BOOM_SELFDESTRUCT_DECK - dw PointerTable_14668 ; POWER_GENERATOR_DECK - dw PointerTable_14668 ; ETCETERA_DECK - dw PointerTable_14668 ; FLOWER_GARDEN_DECK - dw PointerTable_14668 ; KALEIDOSCOPE_DECK - dw PointerTable_14668 ; GHOST_DECK - dw PointerTable_14668 ; NAP_TIME_DECK - dw PointerTable_14668 ; STRANGE_POWER_DECK - dw PointerTable_14668 ; FLYIN_POKEMON_DECK - dw PointerTable_14668 ; LOVELY_NIDORAN_DECK - dw PointerTable_14668 ; POISON_DECK - dw PointerTable_14668 ; ANGER_DECK - dw PointerTable_14668 ; FLAMETHROWER_DECK - dw PointerTable_14668 ; RESHUFFLE_DECK - dw $48dc ; IMAKUNI_DECK -; 1406a +INCLUDE "data/deck_ai_pointers.asm" PointerTable_1406a: ; 1406a (5:406a) dw $406c @@ -1657,2414 +1603,7 @@ AIPerformSciptedTurn: ; 1483a (5:483a) ret ; 0x148dc -PointerTable_148dc: ; 148dc (5:48dc) - dw Func_148e8 - dw Func_148e8 - dw Func_148ec - dw Func_148f3 - dw Func_148f7 - dw Func_148fb - -Func_148e8: ; 148e8 (5:48e8) - INCROM $148e8, $148ec - -Func_148ec: ; 148ec (5:48ec) - call InitAIDuelVars - call AIPlayInitialBasicCards - ret -; 0x148f3 - -Func_148f3: ; 148f3 (5:48f3) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x148f7 - -Func_148f7: ; 148f7 (5:48f7) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x148fb - -Func_148fb: ; 148fb (5:48fb) - call _AIPickPrizeCards - ret -; 0x148ff - -Func_148ff: ; 148ff (5:48ff) - INCROM $148ff, $149e8 - -PointerTable_149e8: ; 149e8 (05:49e8) - dw Func_149f4 - dw Func_149f4 - dw Func_149f8 - dw Func_14a09 - dw Func_14a0d - dw Func_14a11 - -Func_149f4: ; 149f4 (5:49f4) - call Func_14a81 - ret -; 0x149f8 - -Func_149f8: ; 149f8 (5:49f8) - call InitAIDuelVars - call Func_14a4a - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc ; Play Area set up was successful - call AIPlayInitialBasicCards - ret -; 0x14a09 - -Func_14a09: ; 14a09 (5:4a09) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14a0d - -Func_14a0d: ; 14a0d (5:4a0d) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14a11 - -Func_14a11: ; 14a11 (5:4a11) - call _AIPickPrizeCards - ret -; 0x14a15 - -Data_14a15: ; 14a15 (5:4a15) - db MAGMAR2 - db GROWLITHE - db VULPIX - db MAGMAR1 - db MOLTRES1 - db MOLTRES2 - db $00 - -Data_14a1c: ; 14a1c (5:4a1c) - db MOLTRES1 - db VULPIX - db GROWLITHE - db MAGMAR2 - db MAGMAR1 - db $00 - -Data_14a22: ; 14a22 (5:4a22) - db MOLTRES2 - db MOLTRES1 - db VULPIX - db GROWLITHE - db MAGMAR2 - db MAGMAR1 - db $00 - -Data_14a29: ; 14a29 (5:4a29) - db GROWLITHE - db $80 - 5 - db VULPIX - db $80 - 5 - db $00 - -Data_14a2e: ; 14a2e (5:4a2e) - db VULPIX - db 3 - db $80 + 0 - - db NINETAILS2 - db 3 - db $80 + 1 - - db GROWLITHE - db 3 - db $80 + 1 - - db ARCANINE2 - db 4 - db $80 + 1 - - db MAGMAR1 - db 4 - db $80 - 1 - - db MAGMAR2 - db 1 - db $80 - 1 - - db MOLTRES2 - db 3 - db $80 + 2 - - db MOLTRES1 - db 4 - db $80 + 2 - - db $00 - -Data_14a47: ; 14a47 (5:4a47) - db ENERGY_REMOVAL - db MOLTRES2 - db $00 - -Func_14a4a: ; 14a4a (5:4a4a) - ld hl, wcda8 - ld de, Data_14a47 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14a15 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14a1c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14a22 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb0 - ld de, Data_14a29 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_14a2e - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14a81 - -Func_14a81: ; 14a81 (5:4a81) - call InitAITurnVars - farcall Func_227d3 - jp nc, .try_attack - - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - -; check if AI can play Moltres2 from hand -; if so, play it. - ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA - call GetTurnDuelistVariable - cp MAX_PLAY_AREA_POKEMON - jr nc, .skip_moltres ; skip if bench is full - ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK - call GetTurnDuelistVariable - cp DECK_SIZE - 9 - jr nc, .skip_moltres ; skip if cards in deck <= 9 - ld a, MUK - call CountPokemonIDInBothPlayAreas - jr c, .skip_moltres ; skip if Muk in play - ld a, MOLTRES2 - call LookForCardIDInHandList_Bank5 - jr nc, .skip_moltres ; skip if no Moltres2 in hand - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - -.skip_moltres - call AIDecidePlayPokemonCard - ret c - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - call Func_14786 - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - -; handle attaching energy from hand - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_attach_energy - -; if Magmar2 is the Arena card and has no energy attached, -; try attaching an energy card to it from the hand. -; otherwise, run normal AI energy attach routine. - ld a, DUELVARS_ARENA_CARD - call GetTurnDuelistVariable - call GetCardIDFromDeckIndex - ld a, MAGMAR2 - cp e - jr nz, .attach_normally - ; Magmar2 is the Arena card - call CreateEnergyCardListFromHand - jr c, .skip_attach_energy - ld e, PLAY_AREA_ARENA - call CountNumberOfEnergyCardsAttached - or a - jr nz, .attach_normally - xor a ; PLAY_AREA_ARENA - ldh [hTempPlayAreaLocation_ff9d], a - call AITryToPlayEnergyCard - jr c, .skip_attach_energy - -.attach_normally - call AIProcessAndTryToPlayEnergy - -.skip_attach_energy -; try playing Pokemon cards from hand again - call AIDecidePlayPokemonCard - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - -.try_attack - call AIProcessAndTryToUseAttack - ret c - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14b0f - -PointerTable_14b0f: ; 14b0f (05:4b0f) - dw Func_14b1b - dw Func_14b1b - dw Func_14b1f - dw Func_14b30 - dw Func_14b34 - dw Func_14b38 - -Func_14b1b: ; 14b1b (5:4b1b) - INCROM $14b1b, $14b1f - -Func_14b1f: ; 14b1f (5:4b1f) - call InitAIDuelVars - call Func_14b6c - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14b30 - -Func_14b30: ; 14b30 (5:4b30) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14b34 - -Func_14b34: ; 14b34 (5:4b34) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14b38 - -Func_14b38: ; 14b38 (5:4b38) - call _AIPickPrizeCards - ret -; 0x14b3c - -Data_14b3c: ; 14b3c (5:4b3c) - db ELECTABUZZ2 - db VOLTORB - db EEVEE - db ZAPDOS1 - db ZAPDOS2 - db ZAPDOS3 - db $00 - -Data_14b43: ; 14b43 (5:4b43) - db ZAPDOS2 - db ZAPDOS1 - db EEVEE - db VOLTORB - db ELECTABUZZ2 - db $00 - -Data_14b49: ; 14b49 (5:4b49) - db EEVEE - db $80 - 5 - db VOLTORB - db $80 - 5 - db ELECTABUZZ2 - db $80 - 5 - db $00 - -Data_14b50: ; 14b50 (5:4b50) - db VOLTORB - db 1 - db $80 - 1 - - db ELECTRODE1 - db 3 - db $80 + 0 - - db ELECTABUZZ2 - db 2 - db $80 - 1 - - db JOLTEON2 - db 3 - db $80 + 1 - - db ZAPDOS1 - db 4 - db $80 + 2 - - db ZAPDOS2 - db 4 - db $80 + 2 - - db ZAPDOS3 - db 3 - db $80 + 1 - - db EEVEE - db 3 - db $80 + 0 - - db $00 - -Data_14b69: ; 14b69 (5:4b69) - db GAMBLER - db ZAPDOS3 - db $00 - -Func_14b6c: ; 14b6c (5:4b6c) - ld hl, wcda8 - ld de, Data_14b69 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14b3c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14b43 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14b43 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14b50 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14b9a - -Func_14b9a: ; 14b9a (5:4b9a) - INCROM $14b9a, $14c0b - -PointerTable_14c0b: ; 14c0b (5:4c0b) - dw Func_14c17 - dw Func_14c17 - dw Func_14c1b - dw Func_14c2c - dw Func_14c30 - dw Func_14c34 - -Func_14c17: ; 14c17 (5:4c17) - INCROM $14c17, $14c1b - -Func_14c1b: ; 14c1b (5:4c1b) - call InitAIDuelVars - call Func_14c63 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14c2c - -Func_14c2c: ; 14c2c (5:4c2c) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14c30 - -Func_14c30: ; 14c30 (5:4c30) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14c34 - -Func_14c34: ; 14c34 (5:4c34) - call _AIPickPrizeCards - ret -; 0x14c38 - -Data_14c38: ; 14c38 (5:4c38) - db CHANSEY - db LAPRAS - db DITTO - db SEEL - db ARTICUNO1 - db ARTICUNO2 - db $00 - -Data_14c3f: ; 14c3f (5:4c3f) - db ARTICUNO1 - db SEEL - db LAPRAS - db CHANSEY - db DITTO - db $00 - -Data_14c45: ; 14c45 (5:4c45) - db SEEL - db $80 - 3 - db DITTO - db $80 - 3 - db $00 - -Data_14c4a: ; 14c4a (5:4c4a) - db SEEL - db 3 - db $80 + 1 - - db DEWGONG - db 4 - db $80 + 0 - - db LAPRAS - db 3 - db $80 + 0 - - db ARTICUNO1 - db 4 - db $80 + 1 - - db ARTICUNO2 - db 3 - db $80 + 0 - - db CHANSEY - db 0 - db $80 - 8 - - db DITTO - db 3 - db $80 + 0 - - db $00 - -Data_14c60: ; 14c60 (5:4c60) - db GAMBLER - db ARTICUNO2 - db $00 - -Func_14c63: ; 14c63 (5:4c63) - ld hl, wcda8 - ld de, Data_14c60 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14c38 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14c3f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14c3f - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14c4a - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14c91 - -; this routine handles how Legendary Articuno -; prioritises playing energy cards to each Pokémon. -; first, it makes sure that all Lapras have at least -; 3 energy cards before moving on to Articuno, -; and then to Dewgong and Seel -ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) - call SwapTurn - call CountPrizes - call SwapTurn - cp 3 - ret c - -; player prizes >= 3 -; if Lapras has more than half HP and -; can use second move, check next for Articuno -; otherwise, check if Articuno or Dewgong -; have more than half HP and can use second move -; and if so, the next Pokémon to check is Lapras - ld a, LAPRAS - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .articuno - ld a, ARTICUNO1 - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .lapras - ld a, DEWGONG - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .lapras - jr .articuno - -; the following routines check for certain card IDs in bench -; and call RaiseAIScoreToAllMatchingIDsInBench if these are found. -; for Lapras, an additional check is made to its -; attached energy count, which skips calling the routine -; if this count is >= 3 -.lapras - ld a, LAPRAS - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .articuno - ld e, a - call CountNumberOfEnergyCardsAttached - cp 3 - jr nc, .articuno - ld a, LAPRAS - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.articuno - ld a, ARTICUNO1 - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .dewgong - ld a, ARTICUNO1 - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.dewgong - ld a, DEWGONG - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .seel - ld a, DEWGONG - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.seel - ld a, SEEL - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - ret nc - ld a, SEEL - call RaiseAIScoreToAllMatchingIDsInBench - ret -; 0x14cf7 - -Func_14cf7: ; 14cf7 (5:4cf7) - INCROM $14cf7, $14d60 - -PointerTable_14d60: ; 14d60 (05:4d60) - dw Func_14d6c - dw Func_14d6c - dw Func_14d70 - dw Func_14d81 - dw Func_14d85 - dw Func_14d89 - -Func_14d6c: ; 14d6c (5:4d6c) - INCROM $14d6c, $14d70 - -Func_14d70: ; 14d70 (5:4d70) - call InitAIDuelVars - call Func_14dc1 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14d81 - -Func_14d81: ; 14d81 (5:4d81) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14d85 - -Func_14d85: ; 14d85 (5:4d85) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14d89 - -Func_14d89: ; 14d89 (5:4d89) - call _AIPickPrizeCards - ret -; 0x14d8d - -Data_14d8d: ; 14d8d (5:4d8d) - db KANGASKHAN - db LAPRAS - db CHARMANDER - db DRATINI - db MAGIKARP - db $00 - -Data_14d93: ; 14d93 (5:4d93) - db CHARMANDER - db MAGIKARP - db DRATINI - db LAPRAS - db KANGASKHAN - db $00 - -Data_14d99: ; 14d99 (5:4d99) - db CHARMANDER - db $80 - 1 - db MAGIKARP - db $80 - 5 - db $00 - -Data_14d9e: ; 14d9e (5:4d9e) - db CHARMANDER - db 3 - db $80 + 1 - - db CHARMELEON - db 4 - db $80 + 1 - - db CHARIZARD - db 5 - db $80 + 0 - - db MAGIKARP - db 3 - db $80 + 1 - - db GYARADOS - db 4 - db $80 - 1 - - db DRATINI - db 2 - db $80 + 0 - - db DRAGONAIR - db 4 - db $80 + 0 - - db DRAGONITE1 - db 3 - db $80 - 1 - - db KANGASKHAN - db 2 - db $80 - 2 - - db LAPRAS - db 3 - db $80 + 0 - - db $00 - -Data_14dbd: ; 14dbd (5:4dbd) - db GAMBLER - db DRAGONITE1 - db KANGASKHAN - db $00 - -Func_14dc1: ; 14dc1 (5:4dc1) - ld hl, wcda8 - ld de, Data_14dbd - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14d8d - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14d93 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14d93 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14d9e - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14def - -Func_14def: ; 14def (5:4def) - INCROM $14def, $14e89 - -PointerTable_14e89: ; 14e89 (5:4e89) - dw Func_14e95 - dw Func_14e95 - dw Func_14e99 - dw Func_14eaa - dw Func_14eae - dw Func_14eb2 - -Func_14e95: ; 14e95 (5:4e95) - INCROM $14e95, $14e99 - -Func_14e99: ; 14e99 (5:4e99) - call InitAIDuelVars - call Func_14ee0 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14eaa - -Func_14eaa: ; 14eaa (5:4eaa) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14eae - -Func_14eae: ; 14eae (5:4eae) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14eb2 - -Func_14eb2: ; 14eb2 (5:4eb2) - call _AIPickPrizeCards - ret -; 0x14eb6 - -Data_14eb6: ; 14eb6 (5:1eb6) - db HITMONCHAN - db MACHOP - db HITMONLEE - db MANKEY - db $00 - -Data_14ebb: ; 14ebb (5:1ebb) - db MACHOP - db HITMONLEE - db HITMONCHAN - db MANKEY - db $00 - -Data_14ec0: ; 14ec0 (5:1ec0) - db MACHOP - db $80 - 1 - db MACHOKE - db $80 - 1 - db MANKEY - db $80 - 2 - db $00 - -Data_14ec7: ; 14ec7 (5:1ec7) - db MACHOP - db 3 - db $80 - - db MACHOKE - db 4 - db $80 - - db MACHAMP - db 4 - db $80 - 1 - - db HITMONCHAN - db 3 - db $80 - - db HITMONLEE - db 3 - db $80 - - db MANKEY - db 2 - db $80 - 1 - - db PRIMEAPE - db 3 - db $80 - 1 - - db $00 - -Data_14edd: ; 14edd (5:1edd) - db HITMONLEE - db HITMONCHAN - db $00 - -Func_14ee0: ; 14ee0 (5:4ee0) - ld hl, wcda8 - ld de, Data_14edd - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14eb6 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14ebb - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14ebb - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14ec7 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14f0e - -PointerTable_14f0e: ; 14f0e (5:4f0e) - dw Func_14f1a - dw Func_14f1a - dw Func_14f1e - dw Func_14f2f - dw Func_14f33 - dw Func_14f37 - -Func_14f1a: ; 14f1a (5:4f1a) - INCROM $14f1a, $14f1e - -Func_14f1e: ; 14f1e (5:4f1e) - call InitAIDuelVars - call Func_14f61 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14f2f - -Func_14f2f: ; 14f2f (5:4f2f) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14f33 - -Func_14f33: ; 14f33 (5:4f33) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14f37 - -Func_14f37: ; 14f37 (5:4f37) - call _AIPickPrizeCards - ret -; 0x14f3b - -Data_14f3b: ; 14f3b (5:4f3b) - db RHYHORN - db ONIX - db GEODUDE - db DIGLETT - db $00 - -Data_14f40: ; 14f40 (5:4f40) - db DIGLETT - db GEODUDE - db RHYHORN - db ONIX - db $00 - -Data_14f45: ; 14f45 (5:4f45) - db DIGLETT - db $80 - 1 - db $00 - -Data_14f48: ; 14f48 (5:4f48) - db DIGLETT - db 3 - db $80 + 1 - - db DUGTRIO - db 4 - db $80 + 0 - - db GEODUDE - db 2 - db $80 + 1 - - db GRAVELER - db 3 - db $80 + 0 - - db GOLEM - db 4 - db $80 + 0 - - db ONIX - db 2 - db $80 - 1 - - db RHYHORN - db 3 - db $80 + 0 - - db $00 - -Data_14f5e: ; 14f5e (5:4f5e) - db ENERGY_REMOVAL - db RHYHORN - db $00 - -Func_14f61: ; 14f61 (5:4f61) - ld hl, wcda8 - ld de, Data_14f5e - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14f3b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14f40 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14f40 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14f48 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x14f8f - -PointerTable_14f8f: ; 14f8f (5:4f8f) - dw Func_14f9b - dw Func_14f9b - dw Func_14f9f - dw Func_14fb0 - dw Func_14fb4 - dw Func_14fb8 - -Func_14f9b: ; 14f9b (5:4f9b) - INCROM $14f9b, $14f9f - -Func_14f9f: ; 14f9f (5:4f9f) - call InitAIDuelVars - call Func_14feb - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14fb0 - -Func_14fb0: ; 14fb0 (5:4fb0) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14fb4 - -Func_14fb4: ; 14fb4 (5:4fb4) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14fb8 - -Func_14fb8: ; 14fb8 (5:4fb8) - call _AIPickPrizeCards - ret -; 0x14fbc - -Data_14fbc: ; 14fbc (5:4fbc) - db LAPRAS - db HORSEA - db GOLDEEN - db SQUIRTLE - db $00 - -Data_14fc1: ; 14fc1 (5:4fc1) - db SQUIRTLE - db HORSEA - db GOLDEEN - db LAPRAS - db $00 - -Data_14fc6: ; 14fc6 (5:4fc6) - db SQUIRTLE - db $80 - 3 - db WARTORTLE - db $80 - 2 - db HORSEA - db $80 - 1 - db $00 - -Data_14fcd: ; 14fcd (5:4fcd) - db SQUIRTLE - db 2 - db $80 + 0 - - db WARTORTLE - db 3 - db $80 + 0 - - db BLASTOISE - db 5 - db $80 + 0 - - db GOLDEEN - db 1 - db $80 + 0 - - db SEAKING - db 2 - db $80 + 0 - - db HORSEA - db 2 - db $80 + 0 - - db SEADRA - db 3 - db $80 + 0 - - db LAPRAS - db 3 - db $80 + 0 - - db $00 - -Data_14fe6: ; 14fe6 (5:4fe6) - db GAMBLER - db ENERGY_RETRIEVAL - db SUPER_ENERGY_RETRIEVAL - db BLASTOISE - db $00 - -Func_14feb: ; 14feb (5:4feb) - ld hl, wcda8 - ld de, Data_14fe6 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14fbc - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14fc1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14fc1 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14fcd - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x15019 - -PointerTable_15019: ; 15019 (5:5019) - dw Func_15025 - dw Func_15025 - dw Func_15029 - dw Func_1503a - dw Func_1503e - dw Func_15042 - -Func_15025: ; 15025 (5:5025) - INCROM $15025, $15029 - -Func_15029: ; 15029 (5:5029) - call InitAIDuelVars - call Func_1506d - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x1503a - -Func_1503a: ; 1503a (5:503a) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1503e - -Func_1503e: ; 1503e (5:503e) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15042 - -Func_15042: ; 15042 (5:5042) - call _AIPickPrizeCards - ret -; 0x15046 - -Data_15046: ; 15046 (5:5046) - db KANGASKHAN - db ELECTABUZZ2 - db TAUROS - db MAGNEMITE1 - db VOLTORB - db $00 - -Data_1504c: ; 1504c (5:504c) - db MAGNEMITE1 - db VOLTORB - db ELECTABUZZ2 - db TAUROS - db KANGASKHAN - db $00 - -Data_15052: ; 15052 (5:5052) - db VOLTORB - db $80 - 1 - db $00 - -Data_15055: ; 15055 (5:5055) - db MAGNEMITE1 - db 3 - db $80 + 1 - - db MAGNETON1 - db 4 - db $80 + 0 - - db VOLTORB - db 3 - db $80 + 1 - - db ELECTRODE1 - db 3 - db $80 + 0 - - db ELECTABUZZ2 - db 1 - db $80 + 0 - - db KANGASKHAN - db 2 - db $80 - 2 - - db TAUROS - db 3 - db $80 + 0 - - db $00 - -Data_1506b: ; 1506b (5:506b) - db KANGASKHAN - db $00 - -Func_1506d: ; 1506d (5:506d) - ld hl, wcda8 - ld de, Data_1506b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15046 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_1504c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_1504c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_15055 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x1509b - -PointerTable_1509b: ; 1509b (5:509b) - dw Func_150a7 - dw Func_150a7 - dw Func_150ab - dw Func_150bc - dw Func_150c0 - dw Func_150c4 - -Func_150a7: ; 150a7 (5:50a7) - INCROM $150a7, $150ab - -Func_150ab: ; 150ab (5:50ab) - call InitAIDuelVars - call Func_150f4 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x150bc - -Func_150bc: ; 150bc (5:50bc) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x150c0 - -Func_150c0: ; 150c0 (5:50c0) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x150c4 - -Func_150c4: ; 150c4 (5:50c4) - call _AIPickPrizeCards - ret -; 0x150c8 - -Data_150c8 ; 150c8 (5:50c8) - db ODDISH - db EXEGGCUTE - db BULBASAUR - db $00 - -Data_150cc ; 150cc (5:50cc) - db BULBASAUR - db EXEGGCUTE - db ODDISH - db $00 - -Data_150cf ; 150cf (5:50cf) - db GLOOM - db $80 - 2 - db VILEPLUME - db $80 - 2 - db BULBASAUR - db $80 - 2 - db IVYSAUR - db $80 - 2 - db $00 - -Data_150d9 ; 150d9 (5:50d9) - db BULBASAUR - db 3 - db $80 + 0 - - db IVYSAUR - db 4 - db $80 + 0 - - db VENUSAUR2 - db 4 - db $80 + 0 - - db ODDISH - db 2 - db $80 + 0 - - db GLOOM - db 3 - db $80 - 1 - - db VILEPLUME - db 3 - db $80 - 1 - - db EXEGGCUTE - db 3 - db $80 + 0 - - db EXEGGUTOR - db 22 - db $80 + 0 - - db $00 - -Data_150f2 ; 150f2 (5:50f2) - db VENUSAUR2 - db $00 - -Func_150f4: ; 150f4 (5:50f4) - ld hl, wcda8 - ld de, Data_150f2 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_150c8 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_150cc - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_150cc - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_150d9 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x15122 - -PointerTable_15122: ; 15122 (5:5122) - dw Func_1512e - dw Func_1512e - dw Func_15132 - dw Func_15143 - dw Func_15147 - dw Func_1514b - -Func_1512e: ; 1512e (5:512e) - INCROM $1512e, $15132 - -Func_15132: ; 15132 (5:5132) - call InitAIDuelVars - call Func_1517f - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15143 - -Func_15143: ; 15143 (5:5143) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15147 - -Func_15147: ; 15147 (5:5147) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1514b - -Func_1514b: ; 1514b (5:514b) - call _AIPickPrizeCards - ret -; 0x1514f - -Data_1514f: ; 1514f (5:514f) - db KANGASKHAN - db CHANSEY - db SNORLAX - db MR_MIME - db ABRA - db $00 - -Data_15155: ; 15155 (5:5155) - db ABRA - db MR_MIME - db KANGASKHAN - db SNORLAX - db CHANSEY - db $00 - -Data_1515b: ; 1515b (5:515b) - db ABRA - db $80 - 3 - db SNORLAX - db $80 - 3 - db KANGASKHAN - db $80 - 1 - db CHANSEY - db $80 - 1 - db $00 - -Data_15164 ; 15164 (5:5164) - db ABRA - db 3 - db $80 + 1 - - db KADABRA - db 3 - db $80 + 0 - - db ALAKAZAM - db 3 - db $80 + 0 - - db MR_MIME - db 2 - db $80 + 0 - - db CHANSEY - db 2 - db $80 - 2 - - db KANGASKHAN - db 4 - db $80 - 2 - - db SNORLAX - db 0 - db $80 - 8 - - db $00 - -Data_1517a ; 1517a (5:517a) - db GAMBLER - db MR_MIME - db ALAKAZAM - db SWITCH - db $00 - -Func_1517f: ; 1517f (5:517f) - ld hl, wcda8 - ld de, Data_1517a - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1514f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15155 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15155 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_15164 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x151ad - -PointerTable_151ad: ; 151ad (5:51ad) - dw Func_151b9 - dw Func_151b9 - dw Func_151bd - dw Func_151ce - dw Func_151d2 - dw Func_151d6 - -Func_151b9: ; 151b9 (5:51b9) - INCROM $151b9, $151bd - -Func_151bd: ; 151bd (5:51bd) - call InitAIDuelVars - call Func_15204 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x151ce - -Func_151ce: ; 151ce (5:51ce) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x151d2 - -Func_151d2: ; 151d2 (5:51d2) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x151d6 - -Func_151d6: ; 151d6 (5:51d6) - call _AIPickPrizeCards - ret -; 0x151da - -Data_151da: ; 151da (5:51da) - db MEWTWO1 - db MEWTWO3 - db MEWTWO2 - db GRIMER - db KOFFING - db PORYGON - db $00 - -Data_151e1: ; 151e1 (5:51e1) - db GRIMER - db KOFFING - db MEWTWO3 - db MEWTWO2 - db MEWTWO1 - db PORYGON - db $00 - -Data_151e8: ; 151e8 (5:51e8) - db $00 - -Data_151e9: ; 151e9 (5:51e9) - db GRIMER - db 3 - db $80 + 0 - - db MUK - db 4 - db $80 + 0 - - db KOFFING - db 2 - db $80 + 0 - - db WEEZING - db 3 - db $80 + 0 - - db MEWTWO1 - db 2 - db $80 - 1 - - db MEWTWO3 - db 2 - db $80 - 1 - - db MEWTWO2 - db 2 - db $80 - 1 - - db PORYGON - db 2 - db $80 - 1 - - db $00 - -Data_15202: ; 15202 (5:5202) - db MUK - db $00 - -Func_15204: ; 15204 (5:5204) - ld hl, wcda8 - ld de, Data_15202 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_151da - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_151e1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_151e1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_151e9 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x15232 - -PointerTable_15232: ; 15232 (5:52PointerTable_12) - dw Func_1523e - dw Func_1523e - dw Func_15242 - dw Func_15253 - dw Func_15257 - dw Func_1525b - -Func_1523e: ; 1523e (5:523e) - INCROM $1523e, $15242 - -Func_15242: ; 15242 (5:5242) - call InitAIDuelVars - call Func_1528f - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15253 - -Func_15253: ; 15253 (5:5253) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15257 - -Func_15257: ; 15257 (5:5257) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1525b - -Func_1525b: ; 1525b (5:525b) - call _AIPickPrizeCards - ret -; 0x1525f - -Data_1525f: ; 1525f (5:525f) - db JIGGLYPUFF3 - db CHANSEY - db TAUROS - db MAGMAR1 - db JIGGLYPUFF1 - db GROWLITHE - db $00 - -Data_15266: ; 15266 (5:5266) - db JIGGLYPUFF3 - db CHANSEY - db GROWLITHE - db MAGMAR1 - db JIGGLYPUFF1 - db TAUROS - db $00 - -Data_1526e: ; 1526e (5:526e) - db JIGGLYPUFF1 - db $80 - 1 - db CHANSEY - db $80 - 1 - db GROWLITHE - db $80 - 1 - db $00 - -Data_15274: ; 15274 (5:5274) - db GROWLITHE - db 3 - db $80 + 0 - - db ARCANINE2 - db 4 - db $80 + 0 - - db MAGMAR1 - db 3 - db $80 + 0 - - db JIGGLYPUFF1 - db 3 - db $80 + 0 - - db JIGGLYPUFF3 - db 2 - db $80 + 0 - - db WIGGLYTUFF - db 3 - db $80 + 0 - - db CHANSEY - db 4 - db $80 + 0 - - db TAUROS - db 3 - db $80 + 0 - - db $00 - -Data_1528d: ; 1528d (5:528d) - db GAMBLER - db $00 - -Func_1528f: ; 1528f (5:528f) - ld hl, wcda8 - ld de, Data_1528d - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1525f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15266 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15266 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_15274 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x152bd - -PointerTable_152bd: ; 152bd (5:52bd) - dw Func_152c9 - dw Func_152c9 - dw Func_152cd - dw Func_152de - dw Func_152e2 - dw Func_152e6 - -Func_152c9: ; 152c9 (5:52c9) - INCROM $152c9, $152cd - -Func_152cd: ; 152cd (5:52cd) - call InitAIDuelVars - call Func_1531d - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x152de - -Func_152de: ; 152de (5:52de) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x152e2 - -Func_152e2: ; 152e2 (5:52e2) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x152e6 - -Func_152e6: ; 152e6 (5:52e6) - call _AIPickPrizeCards - ret -; 0x152ea - -Data_152ea: ; 152ea (5:52ea) - db LAPRAS - db SEEL - db CHARMANDER - db CUBONE - db SQUIRTLE - db GROWLITHE - db $00 - -Data_152f1: ; 152f1 (5:52f1) - db CHARMANDER - db SQUIRTLE - db SEEL - db CUBONE - db GROWLITHE - db LAPRAS - db $00 - -Data_152f8: ; 152f8 (5:52f8) - db $00 - -Data_152f9: ; 152f9 (5:52f9) - db CHARMANDER - db 3 - db $80 + 0 - - db CHARMELEON - db 5 - db $80 + 0 - - db GROWLITHE - db 2 - db $80 + 0 - - db ARCANINE2 - db 4 - db $80 + 0 - - db SQUIRTLE - db 2 - db $80 + 0 - - db WARTORTLE - db 3 - db $80 + 0 - - db SEEL - db 3 - db $80 + 0 - - db DEWGONG - db 4 - db $80 + 0 - - db LAPRAS - db 3 - db $80 + 0 - - db CUBONE - db 3 - db $80 + 0 - - db MAROWAK1 - db 3 - db $80 + 0 - - db $00 - -Data_1531b: ; 1531b (5:531b) - db LAPRAS - db $00 - -Func_1531d: ; 1531d (5:531d) - ld hl, wcda8 - ld de, Data_1531b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_152ea - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_152f1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_152f1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_152f9 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x1534b - -PointerTable_1534b: ; 1534b (5:534b) - dw Func_15357 - dw Func_15357 - dw Func_1535b - dw Func_1536c - dw Func_15370 - dw Func_15374 - -Func_15357: ; 15357 (5:5357) - INCROM $15357, $1535b - -Func_1535b: ; 1535b (5:535b) - call InitAIDuelVars - call Func_153ba - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x1536c - -Func_1536c: ; 1536c (5:536c) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15370 - -Func_15370: ; 15370 (5:5370) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15374 - -Func_15374: ; 15374 (5:5374) - call _AIPickPrizeCards - ret -; 0x15378 - -Data_15378: ; 15378 (5:5378) - db KANGASKHAN - db ELECTABUZZ2 - db HITMONCHAN - db MR_MIME - db LICKITUNG - db HITMONLEE - db TAUROS - db JYNX - db MEWTWO1 - db DODUO - db $00 - -Data_15383: ; 15383 (5:5383) - db KANGASKHAN - db HITMONLEE - db HITMONCHAN - db TAUROS - db DODUO - db JYNX - db MEWTWO1 - db ELECTABUZZ2 - db MR_MIME - db LICKITUNG - db $00 - -Data_1538e: ; 1538e (5:538e) - db KANGASKHAN - db $80 - 1 - db DODUO - db $80 - 1 - db DODRIO - db $80 - 1 - db $00 - -Data_15395: ; 15395 (5:5395) - db ELECTABUZZ2 - db 2 - db $80 + 1 - - db HITMONLEE - db 3 - db $80 + 1 - - db HITMONCHAN - db 3 - db $80 + 1 - - db MR_MIME - db 2 - db $80 + 0 - - db JYNX - db 3 - db $80 + 0 - - db MEWTWO1 - db 2 - db $80 + 0 - - db DODUO - db 3 - db $80 - 1 - - db DODRIO - db 3 - db $80 - 1 - - db LICKITUNG - db 2 - db $80 + 0 - - db KANGASKHAN - db 4 - db $80 - 1 - - db TAUROS - db 3 - db $80 + 0 - - db $00 - -Data_153b7: ; 153b7 (5:53b7) - db GAMBLER - db ENERGY_REMOVAL - db $00 - -Func_153ba: ; 153ba (5:53ba) - ld hl, wcda8 - ld de, Data_153b7 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15378 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15383 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15383 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_15395 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x153e8 - -PointerTable_153e8: ; 153e8 (5:53e8) - dw Func_153f4 - dw Func_153f4 - dw Func_153f8 - dw Func_15409 - dw Func_1540d - dw Func_15411 - -Func_153f4: ; 153f4 (5:53f4) - INCROM $153f4, $153f8 - -Func_153f8: ; 153f8 (5:53f8) - call InitAIDuelVars - call Func_15441 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15409 - -Func_15409: ; 15409 (5:5409) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1540d - -Func_1540d: ; 1540d (5:540d) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15411 - -Func_15411: ; 15411 (5:5411) - call _AIPickPrizeCards - ret -; 0x15415 - -Data_15415: ; 15415 (5:5415) - db KANGASKHAN - db MAGMAR2 - db CHANSEY - db GEODUDE - db SCYTHER - db GRIMER - db $00 - -Data_1541c: ; 1541c (5:541c) - db GRIMER - db SCYTHER - db GEODUDE - db CHANSEY - db MAGMAR2 - db KANGASKHAN - db $00 - -Data_15423: ; 15423 (5:5423) - db GRIMER - db $80 - 1 - db $00 - -Data_15426: ; 15426 (5:5426) - db GRIMER - db 1 - db $80 - 1 - - db MUK - db 3 - db $80 - 1 - - db SCYTHER - db 4 - db $80 + 1 - - db MAGMAR2 - db 2 - db $80 + 0 - - db GEODUDE - db 2 - db $80 + 0 - - db GRAVELER - db 3 - db $80 + 0 - - db CHANSEY - db 4 - db $80 + 0 - - db KANGASKHAN - db 4 - db $80 - 1 - - db $00 - -Data_1543f: ; 1543f (5:543f) - db GAMBLER - db $00 - -Func_15441: ; 15441 (5:5441) - ld hl, wcda8 - ld de, Data_1543f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15415 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_1541c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_1541c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_15426 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x1546f - -PointerTable_1546f: ; 1546f (5:546f) - dw Func_1547b - dw Func_1547b - dw Func_1547f - dw Func_15490 - dw Func_15494 - dw Func_15498 - -Func_1547b: ; 1547b (5:547b) - INCROM $1547b, $1547f - -Func_1547f: ; 1547f (5:547f) - call InitAIDuelVars - call Func_154d9 - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15490 - -Func_15490: ; 15490 (5:5490) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15494 - -Func_15494: ; 15494 (5:5494) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15498 - -Func_15498: ; 15498 (5:5498) - call _AIPickPrizeCards - ret -; 0x1549c - -Data_1549c: ; 1549c (5:549c) - db KANGASKHAN - db DRATINI - db EEVEE - db ZAPDOS3 - db ARTICUNO2 - db MOLTRES2 - db $00 - -Data_154a3: ; 154a3 (5:54a3) - db KANGASKHAN - db DRATINI - db EEVEE - db $00 - -Data_154a7: ; 154a7 (5:54a7) - db MOLTRES2 - db ZAPDOS3 - db KANGASKHAN - db DRATINI - db EEVEE - db ARTICUNO2 - db $00 - -Data_154ae: ; 154ae (5:54ae) - db EEVEE - db $80 - 2 - db $00 - -Data_154b1: ; 154b1 (5:54b1) - db FLAREON1 - db 3 - db $80 - - db MOLTRES2 - db 3 - db $80 - - db VAPOREON1 - db 3 - db $80 - - db ARTICUNO2 - db 0 - db $78 - - db JOLTEON1 - db 4 - db $80 - - db ZAPDOS3 - db 0 - db $78 - - db KANGASKHAN - db 4 - db $7f - - db EEVEE - db 3 - db $80 - - db DRATINI - db 3 - db $80 - - db DRAGONAIR - db 4 - db $80 - - db DRAGONITE1 - db 3 - db $80 - - db $00 - -Data_154d3: ; 154d3 (5:54d3) - db MOLTRES2 - db ARTICUNO2 - db ZAPDOS3 - db DRAGONITE1 - db GAMBLER - db $00 - -Func_154d9: ; 154d9 (5:54d9) - ld hl, wcda8 - ld de, Data_154d3 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1549c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_154a3 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_154a7 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_154b1 - ld [hl], e - inc hl - ld [hl], d - - ret -; 0x15507 +INCLUDE "engine/deck_ai.asm" Func_15507: ; 15507 (5:5507) INCROM $15507, $155d2 diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm new file mode 100644 index 0000000..f62239e --- /dev/null +++ b/src/engine/deck_ai.asm @@ -0,0 +1,2011 @@ +; AI card retreat score bonus +; when the AI retreat routine runs through the Bench to choose +; a Pokemon to switch to, it looks up in this list and if +; a card ID matches, applies a retreat score bonus to this card. +; positive (negative) means more (less) likely to switch to this card. +airetreat: MACRO + db \1 ; card ID + db $80 + \2 ; retreat score (ranges between -128 and 127) +ENDM + +; AI card energy attach score bonus +; when the AI energy attachment run through the Play Area to choose +; a Pokemon to attach an energy card, it looks up in this list and if +; a card ID matches, skips this card if the maximum number of energy +; cards attached has been reached. If it hasn't been reached, additionally +; applies a positive (or negative) AI score to attach energy to this card. +aienergy: MACRO + db \1 ; card ID + db \2 ; maximum number of attached cards + db $80 + \3 ; energy score (ranges between -128 and 127) +ENDM + +PointerTable_148dc: ; 148dc (5:48dc) + dw Func_148e8 + dw Func_148e8 + dw Func_148ec + dw Func_148f3 + dw Func_148f7 + dw Func_148fb + +Func_148e8: ; 148e8 (5:48e8) + INCROM $148e8, $148ec + +Func_148ec: ; 148ec (5:48ec) + call InitAIDuelVars + call AIPlayInitialBasicCards + ret +; 0x148f3 + +Func_148f3: ; 148f3 (5:48f3) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148f7 + +Func_148f7: ; 148f7 (5:48f7) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148fb + +Func_148fb: ; 148fb (5:48fb) + call _AIPickPrizeCards + ret +; 0x148ff + +Func_148ff: ; 148ff (5:48ff) + INCROM $148ff, $149e8 + +PointerTable_149e8: ; 149e8 (05:49e8) + dw Func_149f4 + dw Func_149f4 + dw Func_149f8 + dw Func_14a09 + dw Func_14a0d + dw Func_14a11 + +Func_149f4: ; 149f4 (5:49f4) + call Func_14a81 + ret +; 0x149f8 + +Func_149f8: ; 149f8 (5:49f8) + call InitAIDuelVars + call Func_14a4a + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc ; Play Area set up was successful + call AIPlayInitialBasicCards + ret +; 0x14a09 + +Func_14a09: ; 14a09 (5:4a09) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a0d + +Func_14a0d: ; 14a0d (5:4a0d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a11 + +Func_14a11: ; 14a11 (5:4a11) + call _AIPickPrizeCards + ret +; 0x14a15 + +Data_14a15: ; 14a15 (5:4a15) + db MAGMAR2 + db GROWLITHE + db VULPIX + db MAGMAR1 + db MOLTRES1 + db MOLTRES2 + db $00 + +Data_14a1c: ; 14a1c (5:4a1c) + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +Data_14a22: ; 14a22 (5:4a22) + db MOLTRES2 + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +Data_14a29: ; 14a29 (5:4a29) + airetreat GROWLITHE, -5 + airetreat VULPIX, -5 + db $00 + +Data_14a2e: ; 14a2e (5:4a2e) + aienergy VULPIX, 3, +0 + aienergy NINETAILS2, 3, +1 + aienergy GROWLITHE, 3, +1 + aienergy ARCANINE2, 4, +1 + aienergy MAGMAR1, 4, -1 + aienergy MAGMAR2, 1, -1 + aienergy MOLTRES2, 3, +2 + aienergy MOLTRES1, 4, +2 + db $00 + +Data_14a47: ; 14a47 (5:4a47) + db ENERGY_REMOVAL + db MOLTRES2 + db $00 + +Func_14a4a: ; 14a4a (5:4a4a) + ld hl, wcda8 + ld de, Data_14a47 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14a15 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14a1c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14a22 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb0 + ld de, Data_14a29 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdb2 + ld de, Data_14a2e + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14a81 + +Func_14a81: ; 14a81 (5:4a81) + call InitAITurnVars + farcall Func_227d3 + jp nc, .try_attack + + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + +; check if AI can play Moltres2 from hand +; if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + cp DECK_SIZE - 9 + jr nc, .skip_moltres ; skip if cards in deck <= 9 + ld a, MUK + call CountPokemonIDInBothPlayAreas + jr c, .skip_moltres ; skip if Muk in play + ld a, MOLTRES2 + call LookForCardIDInHandList_Bank5 + jr nc, .skip_moltres ; skip if no Moltres2 in hand + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + +.skip_moltres + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + +; handle attaching energy from hand + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_attach_energy + +; if Magmar2 is the Arena card and has no energy attached, +; try attaching an energy card to it from the hand. +; otherwise, run normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, MAGMAR2 + cp e + jr nz, .attach_normally + ; Magmar2 is the Arena card + call CreateEnergyCardListFromHand + jr c, .skip_attach_energy + ld e, PLAY_AREA_ARENA + call CountNumberOfEnergyCardsAttached + or a + jr nz, .attach_normally + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .skip_attach_energy + +.attach_normally + call AIProcessAndTryToPlayEnergy + +.skip_attach_energy +; try playing Pokemon cards from hand again + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + +.try_attack + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14b0f + +PointerTable_14b0f: ; 14b0f (05:4b0f) + dw Func_14b1b + dw Func_14b1b + dw Func_14b1f + dw Func_14b30 + dw Func_14b34 + dw Func_14b38 + +Func_14b1b: ; 14b1b (5:4b1b) + INCROM $14b1b, $14b1f + +Func_14b1f: ; 14b1f (5:4b1f) + call InitAIDuelVars + call Func_14b6c + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14b30 + +Func_14b30: ; 14b30 (5:4b30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b34 + +Func_14b34: ; 14b34 (5:4b34) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b38 + +Func_14b38: ; 14b38 (5:4b38) + call _AIPickPrizeCards + ret +; 0x14b3c + +Data_14b3c: ; 14b3c (5:4b3c) + db ELECTABUZZ2 + db VOLTORB + db EEVEE + db ZAPDOS1 + db ZAPDOS2 + db ZAPDOS3 + db $00 + +Data_14b43: ; 14b43 (5:4b43) + db ZAPDOS2 + db ZAPDOS1 + db EEVEE + db VOLTORB + db ELECTABUZZ2 + db $00 + +Data_14b49: ; 14b49 (5:4b49) + airetreat EEVEE, -5 + airetreat VOLTORB, -5 + airetreat ELECTABUZZ2, -5 + db $00 + +Data_14b50: ; 14b50 (5:4b50) + aienergy VOLTORB, 1, -1 + aienergy ELECTRODE1, 3, +0 + aienergy ELECTABUZZ2, 2, -1 + aienergy JOLTEON2, 3, +1 + aienergy ZAPDOS1, 4, +2 + aienergy ZAPDOS2, 4, +2 + aienergy ZAPDOS3, 3, +1 + aienergy EEVEE, 3, +0 + db $00 + +Data_14b69: ; 14b69 (5:4b69) + db GAMBLER + db ZAPDOS3 + db $00 + +Func_14b6c: ; 14b6c (5:4b6c) + ld hl, wcda8 + ld de, Data_14b69 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14b3c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14b43 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14b43 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14b50 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14b9a + +Func_14b9a: ; 14b9a (5:4b9a) + INCROM $14b9a, $14c0b + +PointerTable_14c0b: ; 14c0b (5:4c0b) + dw Func_14c17 + dw Func_14c17 + dw Func_14c1b + dw Func_14c2c + dw Func_14c30 + dw Func_14c34 + +Func_14c17: ; 14c17 (5:4c17) + INCROM $14c17, $14c1b + +Func_14c1b: ; 14c1b (5:4c1b) + call InitAIDuelVars + call Func_14c63 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14c2c + +Func_14c2c: ; 14c2c (5:4c2c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c30 + +Func_14c30: ; 14c30 (5:4c30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c34 + +Func_14c34: ; 14c34 (5:4c34) + call _AIPickPrizeCards + ret +; 0x14c38 + +Data_14c38: ; 14c38 (5:4c38) + db CHANSEY + db LAPRAS + db DITTO + db SEEL + db ARTICUNO1 + db ARTICUNO2 + db $00 + +Data_14c3f: ; 14c3f (5:4c3f) + db ARTICUNO1 + db SEEL + db LAPRAS + db CHANSEY + db DITTO + db $00 + +Data_14c45: ; 14c45 (5:4c45) + airetreat SEEL, -3 + airetreat DITTO, -3 + db $00 + +Data_14c4a: ; 14c4a (5:4c4a) + aienergy SEEL, 3, +1 + aienergy DEWGONG, 4, +0 + aienergy LAPRAS, 3, +0 + aienergy ARTICUNO1, 4, +1 + aienergy ARTICUNO2, 3, +0 + aienergy CHANSEY, 0, -8 + aienergy DITTO, 3, +0 + db $00 + +Data_14c60: ; 14c60 (5:4c60) + db GAMBLER + db ARTICUNO2 + db $00 + +Func_14c63: ; 14c63 (5:4c63) + ld hl, wcda8 + ld de, Data_14c60 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14c38 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14c3f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14c3f + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14c4a + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14c91 + +; this routine handles how Legendary Articuno +; prioritises playing energy cards to each Pokémon. +; first, it makes sure that all Lapras have at least +; 3 energy cards before moving on to Articuno, +; and then to Dewgong and Seel +ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) + call SwapTurn + call CountPrizes + call SwapTurn + cp 3 + ret c + +; player prizes >= 3 +; if Lapras has more than half HP and +; can use second move, check next for Articuno +; otherwise, check if Articuno or Dewgong +; have more than half HP and can use second move +; and if so, the next Pokémon to check is Lapras + ld a, LAPRAS + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .articuno + ld a, ARTICUNO1 + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .lapras + ld a, DEWGONG + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .lapras + jr .articuno + +; the following routines check for certain card IDs in bench +; and call RaiseAIScoreToAllMatchingIDsInBench if these are found. +; for Lapras, an additional check is made to its +; attached energy count, which skips calling the routine +; if this count is >= 3 +.lapras + ld a, LAPRAS + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .articuno + ld e, a + call CountNumberOfEnergyCardsAttached + cp 3 + jr nc, .articuno + ld a, LAPRAS + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.articuno + ld a, ARTICUNO1 + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .dewgong + ld a, ARTICUNO1 + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.dewgong + ld a, DEWGONG + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .seel + ld a, DEWGONG + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.seel + ld a, SEEL + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + ret nc + ld a, SEEL + call RaiseAIScoreToAllMatchingIDsInBench + ret +; 0x14cf7 + +Func_14cf7: ; 14cf7 (5:4cf7) + INCROM $14cf7, $14d60 + +PointerTable_14d60: ; 14d60 (05:4d60) + dw Func_14d6c + dw Func_14d6c + dw Func_14d70 + dw Func_14d81 + dw Func_14d85 + dw Func_14d89 + +Func_14d6c: ; 14d6c (5:4d6c) + INCROM $14d6c, $14d70 + +Func_14d70: ; 14d70 (5:4d70) + call InitAIDuelVars + call Func_14dc1 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14d81 + +Func_14d81: ; 14d81 (5:4d81) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d85 + +Func_14d85: ; 14d85 (5:4d85) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d89 + +Func_14d89: ; 14d89 (5:4d89) + call _AIPickPrizeCards + ret +; 0x14d8d + +Data_14d8d: ; 14d8d (5:4d8d) + db KANGASKHAN + db LAPRAS + db CHARMANDER + db DRATINI + db MAGIKARP + db $00 + +Data_14d93: ; 14d93 (5:4d93) + db CHARMANDER + db MAGIKARP + db DRATINI + db LAPRAS + db KANGASKHAN + db $00 + +Data_14d99: ; 14d99 (5:4d99) + airetreat CHARMANDER, -1 + airetreat MAGIKARP, -5 + db $00 + +Data_14d9e: ; 14d9e (5:4d9e) + aienergy CHARMANDER, 3, +1 + aienergy CHARMELEON, 4, +1 + aienergy CHARIZARD, 5, +0 + aienergy MAGIKARP, 3, +1 + aienergy GYARADOS, 4, -1 + aienergy DRATINI, 2, +0 + aienergy DRAGONAIR, 4, +0 + aienergy DRAGONITE1, 3, -1 + aienergy KANGASKHAN, 2, -2 + aienergy LAPRAS, 3, +0 + db $00 + +Data_14dbd: ; 14dbd (5:4dbd) + db GAMBLER + db DRAGONITE1 + db KANGASKHAN + db $00 + +Func_14dc1: ; 14dc1 (5:4dc1) + ld hl, wcda8 + ld de, Data_14dbd + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14d8d + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14d93 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14d93 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14d9e + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14def + +Func_14def: ; 14def (5:4def) + INCROM $14def, $14e89 + +PointerTable_14e89: ; 14e89 (5:4e89) + dw Func_14e95 + dw Func_14e95 + dw Func_14e99 + dw Func_14eaa + dw Func_14eae + dw Func_14eb2 + +Func_14e95: ; 14e95 (5:4e95) + INCROM $14e95, $14e99 + +Func_14e99: ; 14e99 (5:4e99) + call InitAIDuelVars + call Func_14ee0 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14eaa + +Func_14eaa: ; 14eaa (5:4eaa) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eae + +Func_14eae: ; 14eae (5:4eae) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eb2 + +Func_14eb2: ; 14eb2 (5:4eb2) + call _AIPickPrizeCards + ret +; 0x14eb6 + +Data_14eb6: ; 14eb6 (5:1eb6) + db HITMONCHAN + db MACHOP + db HITMONLEE + db MANKEY + db $00 + +Data_14ebb: ; 14ebb (5:1ebb) + db MACHOP + db HITMONLEE + db HITMONCHAN + db MANKEY + db $00 + +Data_14ec0: ; 14ec0 (5:1ec0) + airetreat MACHOP, - 1 + airetreat MACHOKE, - 1 + airetreat MANKEY, - 2 + db $00 + +Data_14ec7: ; 14ec7 (5:1ec7) + aienergy MACHOP, 3, +0 + aienergy MACHOKE, 4, +0 + aienergy MACHAMP, 4, -1 + aienergy HITMONCHAN, 3, +0 + aienergy HITMONLEE, 3, +0 + aienergy MANKEY, 2, -1 + aienergy PRIMEAPE, 3, -1 + db $00 + +Data_14edd: ; 14edd (5:1edd) + db HITMONLEE + db HITMONCHAN + db $00 + +Func_14ee0: ; 14ee0 (5:4ee0) + ld hl, wcda8 + ld de, Data_14edd + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14eb6 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14ebb + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14ebb + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14ec7 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14f0e + +PointerTable_14f0e: ; 14f0e (5:4f0e) + dw Func_14f1a + dw Func_14f1a + dw Func_14f1e + dw Func_14f2f + dw Func_14f33 + dw Func_14f37 + +Func_14f1a: ; 14f1a (5:4f1a) + INCROM $14f1a, $14f1e + +Func_14f1e: ; 14f1e (5:4f1e) + call InitAIDuelVars + call Func_14f61 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14f2f + +Func_14f2f: ; 14f2f (5:4f2f) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f33 + +Func_14f33: ; 14f33 (5:4f33) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f37 + +Func_14f37: ; 14f37 (5:4f37) + call _AIPickPrizeCards + ret +; 0x14f3b + +Data_14f3b: ; 14f3b (5:4f3b) + db RHYHORN + db ONIX + db GEODUDE + db DIGLETT + db $00 + +Data_14f40: ; 14f40 (5:4f40) + db DIGLETT + db GEODUDE + db RHYHORN + db ONIX + db $00 + +Data_14f45: ; 14f45 (5:4f45) + airetreat DIGLETT, -1 + db $00 + +Data_14f48: ; 14f48 (5:4f48) + aienergy DIGLETT, 3, +1 + aienergy DUGTRIO, 4, +0 + aienergy GEODUDE, 2, +1 + aienergy GRAVELER, 3, +0 + aienergy GOLEM, 4, +0 + aienergy ONIX, 2, -1 + aienergy RHYHORN, 3, +0 + db $00 + +Data_14f5e: ; 14f5e (5:4f5e) + db ENERGY_REMOVAL + db RHYHORN + db $00 + +Func_14f61: ; 14f61 (5:4f61) + ld hl, wcda8 + ld de, Data_14f5e + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14f3b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14f40 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14f40 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14f48 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x14f8f + +PointerTable_14f8f: ; 14f8f (5:4f8f) + dw Func_14f9b + dw Func_14f9b + dw Func_14f9f + dw Func_14fb0 + dw Func_14fb4 + dw Func_14fb8 + +Func_14f9b: ; 14f9b (5:4f9b) + INCROM $14f9b, $14f9f + +Func_14f9f: ; 14f9f (5:4f9f) + call InitAIDuelVars + call Func_14feb + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14fb0 + +Func_14fb0: ; 14fb0 (5:4fb0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb4 + +Func_14fb4: ; 14fb4 (5:4fb4) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb8 + +Func_14fb8: ; 14fb8 (5:4fb8) + call _AIPickPrizeCards + ret +; 0x14fbc + +Data_14fbc: ; 14fbc (5:4fbc) + db LAPRAS + db HORSEA + db GOLDEEN + db SQUIRTLE + db $00 + +Data_14fc1: ; 14fc1 (5:4fc1) + db SQUIRTLE + db HORSEA + db GOLDEEN + db LAPRAS + db $00 + +Data_14fc6: ; 14fc6 (5:4fc6) + airetreat SQUIRTLE, -3 + airetreat WARTORTLE, -2 + airetreat HORSEA, -1 + db $00 + +Data_14fcd: ; 14fcd (5:4fcd) + aienergy SQUIRTLE, 2, +0 + aienergy WARTORTLE, 3, +0 + aienergy BLASTOISE, 5, +0 + aienergy GOLDEEN, 1, +0 + aienergy SEAKING, 2, +0 + aienergy HORSEA, 2, +0 + aienergy SEADRA, 3, +0 + aienergy LAPRAS, 3, +0 + db $00 + +Data_14fe6: ; 14fe6 (5:4fe6) + db GAMBLER + db ENERGY_RETRIEVAL + db SUPER_ENERGY_RETRIEVAL + db BLASTOISE + db $00 + +Func_14feb: ; 14feb (5:4feb) + ld hl, wcda8 + ld de, Data_14fe6 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_14fbc + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_14fc1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_14fc1 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_14fcd + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15019 + +PointerTable_15019: ; 15019 (5:5019) + dw Func_15025 + dw Func_15025 + dw Func_15029 + dw Func_1503a + dw Func_1503e + dw Func_15042 + +Func_15025: ; 15025 (5:5025) + INCROM $15025, $15029 + +Func_15029: ; 15029 (5:5029) + call InitAIDuelVars + call Func_1506d + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1503a + +Func_1503a: ; 1503a (5:503a) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1503e + +Func_1503e: ; 1503e (5:503e) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15042 + +Func_15042: ; 15042 (5:5042) + call _AIPickPrizeCards + ret +; 0x15046 + +Data_15046: ; 15046 (5:5046) + db KANGASKHAN + db ELECTABUZZ2 + db TAUROS + db MAGNEMITE1 + db VOLTORB + db $00 + +Data_1504c: ; 1504c (5:504c) + db MAGNEMITE1 + db VOLTORB + db ELECTABUZZ2 + db TAUROS + db KANGASKHAN + db $00 + +Data_15052: ; 15052 (5:5052) + airetreat VOLTORB, -1 + db $00 + +Data_15055: ; 15055 (5:5055) + aienergy MAGNEMITE1, 3, +1 + aienergy MAGNETON1, 4, +0 + aienergy VOLTORB, 3, +1 + aienergy ELECTRODE1, 3, +0 + aienergy ELECTABUZZ2, 1, +0 + aienergy KANGASKHAN, 2, -2 + aienergy TAUROS, 3, +0 + db $00 + +Data_1506b: ; 1506b (5:506b) + db KANGASKHAN + db $00 + +Func_1506d: ; 1506d (5:506d) + ld hl, wcda8 + ld de, Data_1506b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15046 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_1504c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_1504c + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_15055 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1509b + +PointerTable_1509b: ; 1509b (5:509b) + dw Func_150a7 + dw Func_150a7 + dw Func_150ab + dw Func_150bc + dw Func_150c0 + dw Func_150c4 + +Func_150a7: ; 150a7 (5:50a7) + INCROM $150a7, $150ab + +Func_150ab: ; 150ab (5:50ab) + call InitAIDuelVars + call Func_150f4 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x150bc + +Func_150bc: ; 150bc (5:50bc) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c0 + +Func_150c0: ; 150c0 (5:50c0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c4 + +Func_150c4: ; 150c4 (5:50c4) + call _AIPickPrizeCards + ret +; 0x150c8 + +Data_150c8 ; 150c8 (5:50c8) + db ODDISH + db EXEGGCUTE + db BULBASAUR + db $00 + +Data_150cc ; 150cc (5:50cc) + db BULBASAUR + db EXEGGCUTE + db ODDISH + db $00 + +Data_150cf ; 150cf (5:50cf) + airetreat GLOOM, -2 + airetreat VILEPLUME, -2 + airetreat BULBASAUR, -2 + airetreat IVYSAUR, -2 + db $00 + +Data_150d9 ; 150d9 (5:50d9) + aienergy BULBASAUR, 3, +0 + aienergy IVYSAUR, 4, +0 + aienergy VENUSAUR2, 4, +0 + aienergy ODDISH, 2, +0 + aienergy GLOOM, 3, -1 + aienergy VILEPLUME, 3, -1 + aienergy EXEGGCUTE, 3, +0 + aienergy EXEGGUTOR, 22, +0 + db $00 + +Data_150f2 ; 150f2 (5:50f2) + db VENUSAUR2 + db $00 + +Func_150f4: ; 150f4 (5:50f4) + ld hl, wcda8 + ld de, Data_150f2 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_150c8 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_150cc + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_150cc + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_150d9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15122 + +PointerTable_15122: ; 15122 (5:5122) + dw Func_1512e + dw Func_1512e + dw Func_15132 + dw Func_15143 + dw Func_15147 + dw Func_1514b + +Func_1512e: ; 1512e (5:512e) + INCROM $1512e, $15132 + +Func_15132: ; 15132 (5:5132) + call InitAIDuelVars + call Func_1517f + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15143 + +Func_15143: ; 15143 (5:5143) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15147 + +Func_15147: ; 15147 (5:5147) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1514b + +Func_1514b: ; 1514b (5:514b) + call _AIPickPrizeCards + ret +; 0x1514f + +Data_1514f: ; 1514f (5:514f) + db KANGASKHAN + db CHANSEY + db SNORLAX + db MR_MIME + db ABRA + db $00 + +Data_15155: ; 15155 (5:5155) + db ABRA + db MR_MIME + db KANGASKHAN + db SNORLAX + db CHANSEY + db $00 + +Data_1515b: ; 1515b (5:515b) + airetreat ABRA, -3 + airetreat SNORLAX, -3 + airetreat KANGASKHAN, -1 + airetreat CHANSEY, -1 + db $00 + +Data_15164 ; 15164 (5:5164) + aienergy ABRA, 3, +1 + aienergy KADABRA, 3, +0 + aienergy ALAKAZAM, 3, +0 + aienergy MR_MIME, 2, +0 + aienergy CHANSEY, 2, -2 + aienergy KANGASKHAN, 4, -2 + aienergy SNORLAX, 0, -8 + db $00 + +Data_1517a ; 1517a (5:517a) + db GAMBLER + db MR_MIME + db ALAKAZAM + db SWITCH + db $00 + +Func_1517f: ; 1517f (5:517f) + ld hl, wcda8 + ld de, Data_1517a + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1514f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15155 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15155 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_15164 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x151ad + +PointerTable_151ad: ; 151ad (5:51ad) + dw Func_151b9 + dw Func_151b9 + dw Func_151bd + dw Func_151ce + dw Func_151d2 + dw Func_151d6 + +Func_151b9: ; 151b9 (5:51b9) + INCROM $151b9, $151bd + +Func_151bd: ; 151bd (5:51bd) + call InitAIDuelVars + call Func_15204 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x151ce + +Func_151ce: ; 151ce (5:51ce) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d2 + +Func_151d2: ; 151d2 (5:51d2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d6 + +Func_151d6: ; 151d6 (5:51d6) + call _AIPickPrizeCards + ret +; 0x151da + +Data_151da: ; 151da (5:51da) + db MEWTWO1 + db MEWTWO3 + db MEWTWO2 + db GRIMER + db KOFFING + db PORYGON + db $00 + +Data_151e1: ; 151e1 (5:51e1) + db GRIMER + db KOFFING + db MEWTWO3 + db MEWTWO2 + db MEWTWO1 + db PORYGON + db $00 + +Data_151e8: ; 151e8 (5:51e8) + db $00 + +Data_151e9: ; 151e9 (5:51e9) + aienergy GRIMER, 3, +0 + aienergy MUK, 4, +0 + aienergy KOFFING, 2, +0 + aienergy WEEZING, 3, +0 + aienergy MEWTWO1, 2, -1 + aienergy MEWTWO3, 2, -1 + aienergy MEWTWO2, 2, -1 + aienergy PORYGON, 2, -1 + db $00 + +Data_15202: ; 15202 (5:5202) + db MUK + db $00 + +Func_15204: ; 15204 (5:5204) + ld hl, wcda8 + ld de, Data_15202 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_151da + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_151e1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_151e1 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_151e9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15232 + +PointerTable_15232: ; 15232 (5:52PointerTable_12) + dw Func_1523e + dw Func_1523e + dw Func_15242 + dw Func_15253 + dw Func_15257 + dw Func_1525b + +Func_1523e: ; 1523e (5:523e) + INCROM $1523e, $15242 + +Func_15242: ; 15242 (5:5242) + call InitAIDuelVars + call Func_1528f + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15253 + +Func_15253: ; 15253 (5:5253) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15257 + +Func_15257: ; 15257 (5:5257) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1525b + +Func_1525b: ; 1525b (5:525b) + call _AIPickPrizeCards + ret +; 0x1525f + +Data_1525f: ; 1525f (5:525f) + db JIGGLYPUFF3 + db CHANSEY + db TAUROS + db MAGMAR1 + db JIGGLYPUFF1 + db GROWLITHE + db $00 + +Data_15266: ; 15266 (5:5266) + db JIGGLYPUFF3 + db CHANSEY + db GROWLITHE + db MAGMAR1 + db JIGGLYPUFF1 + db TAUROS + db $00 + +Data_1526e: ; 1526e (5:526e) + airetreat JIGGLYPUFF1, -1 + airetreat CHANSEY, -1 + airetreat GROWLITHE, -1 + db $00 + +Data_15274: ; 15274 (5:5274) + aienergy GROWLITHE, 3, +0 + aienergy ARCANINE2, 4, +0 + aienergy MAGMAR1, 3, +0 + aienergy JIGGLYPUFF1, 3, +0 + aienergy JIGGLYPUFF3, 2, +0 + aienergy WIGGLYTUFF, 3, +0 + aienergy CHANSEY, 4, +0 + aienergy TAUROS, 3, +0 + db $00 + +Data_1528d: ; 1528d (5:528d) + db GAMBLER + db $00 + +Func_1528f: ; 1528f (5:528f) + ld hl, wcda8 + ld de, Data_1528d + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1525f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15266 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15266 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_15274 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x152bd + +PointerTable_152bd: ; 152bd (5:52bd) + dw Func_152c9 + dw Func_152c9 + dw Func_152cd + dw Func_152de + dw Func_152e2 + dw Func_152e6 + +Func_152c9: ; 152c9 (5:52c9) + INCROM $152c9, $152cd + +Func_152cd: ; 152cd (5:52cd) + call InitAIDuelVars + call Func_1531d + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x152de + +Func_152de: ; 152de (5:52de) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e2 + +Func_152e2: ; 152e2 (5:52e2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e6 + +Func_152e6: ; 152e6 (5:52e6) + call _AIPickPrizeCards + ret +; 0x152ea + +Data_152ea: ; 152ea (5:52ea) + db LAPRAS + db SEEL + db CHARMANDER + db CUBONE + db SQUIRTLE + db GROWLITHE + db $00 + +Data_152f1: ; 152f1 (5:52f1) + db CHARMANDER + db SQUIRTLE + db SEEL + db CUBONE + db GROWLITHE + db LAPRAS + db $00 + +Data_152f8: ; 152f8 (5:52f8) + db $00 + +Data_152f9: ; 152f9 (5:52f9) + aienergy CHARMANDER, 3, +0 + aienergy CHARMELEON, 5, +0 + aienergy GROWLITHE, 2, +0 + aienergy ARCANINE2, 4, +0 + aienergy SQUIRTLE, 2, +0 + aienergy WARTORTLE, 3, +0 + aienergy SEEL, 3, +0 + aienergy DEWGONG, 4, +0 + aienergy LAPRAS, 3, +0 + aienergy CUBONE, 3, +0 + aienergy MAROWAK1, 3, +0 + db $00 + +Data_1531b: ; 1531b (5:531b) + db LAPRAS + db $00 + +Func_1531d: ; 1531d (5:531d) + ld hl, wcda8 + ld de, Data_1531b + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_152ea + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_152f1 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_152f1 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_152f9 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1534b + +PointerTable_1534b: ; 1534b (5:534b) + dw Func_15357 + dw Func_15357 + dw Func_1535b + dw Func_1536c + dw Func_15370 + dw Func_15374 + +Func_15357: ; 15357 (5:5357) + INCROM $15357, $1535b + +Func_1535b: ; 1535b (5:535b) + call InitAIDuelVars + call Func_153ba + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1536c + +Func_1536c: ; 1536c (5:536c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15370 + +Func_15370: ; 15370 (5:5370) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15374 + +Func_15374: ; 15374 (5:5374) + call _AIPickPrizeCards + ret +; 0x15378 + +Data_15378: ; 15378 (5:5378) + db KANGASKHAN + db ELECTABUZZ2 + db HITMONCHAN + db MR_MIME + db LICKITUNG + db HITMONLEE + db TAUROS + db JYNX + db MEWTWO1 + db DODUO + db $00 + +Data_15383: ; 15383 (5:5383) + db KANGASKHAN + db HITMONLEE + db HITMONCHAN + db TAUROS + db DODUO + db JYNX + db MEWTWO1 + db ELECTABUZZ2 + db MR_MIME + db LICKITUNG + db $00 + +Data_1538e: ; 1538e (5:538e) + airetreat KANGASKHAN, -1 + airetreat DODUO, -1 + airetreat DODRIO, -1 + db $00 + +Data_15395: ; 15395 (5:5395) + aienergy ELECTABUZZ2, 2, +1 + aienergy HITMONLEE, 3, +1 + aienergy HITMONCHAN, 3, +1 + aienergy MR_MIME, 2, +0 + aienergy JYNX, 3, +0 + aienergy MEWTWO1, 2, +0 + aienergy DODUO, 3, -1 + aienergy DODRIO, 3, -1 + aienergy LICKITUNG, 2, +0 + aienergy KANGASKHAN, 4, -1 + aienergy TAUROS, 3, +0 + db $00 + +Data_153b7: ; 153b7 (5:53b7) + db GAMBLER + db ENERGY_REMOVAL + db $00 + +Func_153ba: ; 153ba (5:53ba) + ld hl, wcda8 + ld de, Data_153b7 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15378 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_15383 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_15383 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_15395 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x153e8 + +PointerTable_153e8: ; 153e8 (5:53e8) + dw Func_153f4 + dw Func_153f4 + dw Func_153f8 + dw Func_15409 + dw Func_1540d + dw Func_15411 + +Func_153f4: ; 153f4 (5:53f4) + INCROM $153f4, $153f8 + +Func_153f8: ; 153f8 (5:53f8) + call InitAIDuelVars + call Func_15441 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15409 + +Func_15409: ; 15409 (5:5409) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1540d + +Func_1540d: ; 1540d (5:540d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15411 + +Func_15411: ; 15411 (5:5411) + call _AIPickPrizeCards + ret +; 0x15415 + +Data_15415: ; 15415 (5:5415) + db KANGASKHAN + db MAGMAR2 + db CHANSEY + db GEODUDE + db SCYTHER + db GRIMER + db $00 + +Data_1541c: ; 1541c (5:541c) + db GRIMER + db SCYTHER + db GEODUDE + db CHANSEY + db MAGMAR2 + db KANGASKHAN + db $00 + +Data_15423: ; 15423 (5:5423) + airetreat GRIMER, -1 + db $00 + +Data_15426: ; 15426 (5:5426) + aienergy GRIMER, 1, -1 + aienergy MUK, 3, -1 + aienergy SCYTHER, 4, +1 + aienergy MAGMAR2, 2, +0 + aienergy GEODUDE, 2, +0 + aienergy GRAVELER, 3, +0 + aienergy CHANSEY, 4, +0 + aienergy KANGASKHAN, 4, -1 + db $00 + +Data_1543f: ; 1543f (5:543f) + db GAMBLER + db $00 + +Func_15441: ; 15441 (5:5441) + ld hl, wcda8 + ld de, Data_1543f + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_15415 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_1541c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_1541c + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_15426 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x1546f + +PointerTable_1546f: ; 1546f (5:546f) + dw Func_1547b + dw Func_1547b + dw Func_1547f + dw Func_15490 + dw Func_15494 + dw Func_15498 + +Func_1547b: ; 1547b (5:547b) + INCROM $1547b, $1547f + +Func_1547f: ; 1547f (5:547f) + call InitAIDuelVars + call Func_154d9 + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15490 + +Func_15490: ; 15490 (5:5490) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15494 + +Func_15494: ; 15494 (5:5494) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15498 + +Func_15498: ; 15498 (5:5498) + call _AIPickPrizeCards + ret +; 0x1549c + +Data_1549c: ; 1549c (5:549c) + db KANGASKHAN + db DRATINI + db EEVEE + db ZAPDOS3 + db ARTICUNO2 + db MOLTRES2 + db $00 + +Data_154a3: ; 154a3 (5:54a3) + db KANGASKHAN + db DRATINI + db EEVEE + db $00 + +Data_154a7: ; 154a7 (5:54a7) + db MOLTRES2 + db ZAPDOS3 + db KANGASKHAN + db DRATINI + db EEVEE + db ARTICUNO2 + db $00 + +Data_154ae: ; 154ae (5:54ae) + airetreat EEVEE, -2 + db $00 + +Data_154b1: ; 154b1 (5:54b1) + aienergy FLAREON1, 3, +0 + aienergy MOLTRES2, 3, +0 + aienergy VAPOREON1, 3, +0 + aienergy ARTICUNO2, 0, -8 + aienergy JOLTEON1, 4, +0 + aienergy ZAPDOS3, 0, -8 + aienergy KANGASKHAN, 4, -1 + aienergy EEVEE, 3, +0 + aienergy DRATINI, 3, +0 + aienergy DRAGONAIR, 4, +0 + aienergy DRAGONITE1, 3, +0 + db $00 + +Data_154d3: ; 154d3 (5:54d3) + db MOLTRES2 + db ARTICUNO2 + db ZAPDOS3 + db DRAGONITE1 + db GAMBLER + db $00 + +Func_154d9: ; 154d9 (5:54d9) + ld hl, wcda8 + ld de, Data_154d3 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdaa + ld de, Data_1549c + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdac + ld de, Data_154a3 + ld [hl], e + inc hl + ld [hl], d + + ld hl, wcdae + ld de, Data_154a7 + ld [hl], e + inc hl + ld [hl], d + +; missing wcdb0 + + ld hl, wcdb2 + ld de, Data_154b1 + ld [hl], e + inc hl + ld [hl], d + + ret +; 0x15507 -- cgit v1.2.3 From 8c1acff885f6c0292a50efecb966f52732836cb9 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 1 May 2020 11:29:17 +0100 Subject: Unpack common turn routines --- src/engine/bank05.asm | 3 - src/engine/deck_ai.asm | 430 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 410 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 96ebe50..989225e 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1605,9 +1605,6 @@ AIPerformSciptedTurn: ; 1483a (5:483a) INCLUDE "engine/deck_ai.asm" -Func_15507: ; 15507 (5:5507) - INCROM $15507, $155d2 - ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card ; as opposed to LookForCardIDInHand, this function diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index f62239e..e4edfdf 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -29,7 +29,9 @@ PointerTable_148dc: ; 148dc (5:48dc) dw Func_148fb Func_148e8: ; 148e8 (5:48e8) - INCROM $148e8, $148ec + call Func_148ff + ret +; 0x148ec Func_148ec: ; 148ec (5:48ec) call InitAIDuelVars @@ -53,7 +55,100 @@ Func_148fb: ; 148fb (5:48fb) ; 0x148ff Func_148ff: ; 148ff (5:48ff) - INCROM $148ff, $149e8 + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall Func_227d3 + jp nc, .asm_149de + farcall HandleAIGoGoRainDanceEnergy + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c + farcall HandleAICowardice + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_1495e + call AIProcessAndTryToPlayEnergy +.asm_1495e + call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c + farcall HandleAIGoGoRainDanceEnergy + ld a, $0d + farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .asm_149de + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_149c9 + call AIProcessAndTryToPlayEnergy +.asm_149c9 + call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c + farcall HandleAIGoGoRainDanceEnergy + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards +.asm_149de + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x149e8 PointerTable_149e8: ; 149e8 (05:49e8) dw Func_149f4 @@ -273,7 +368,9 @@ PointerTable_14b0f: ; 14b0f (05:4b0f) dw Func_14b38 Func_14b1b: ; 14b1b (5:4b1b) - INCROM $14b1b, $14b1f + call Func_14b9a + ret +; 0x14b1f Func_14b1f: ; 14b1f (5:4b1f) call InitAIDuelVars @@ -376,7 +473,62 @@ Func_14b6c: ; 14b6c (5:4b6c) ; 0x14b9a Func_14b9a: ; 14b9a (5:4b9a) - INCROM $14b9a, $14c0b + call InitAITurnVars + farcall Func_227d3 + jp nc, .asm_14c01 + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_14bf8 + ld a, $bb + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, $6d + cp e + jr nz, .asm_14bdb + ld a, $6e + call LookForCardIDInHandList_Bank5 + jr nc, .asm_14bf5 + jr .asm_14be0 +.asm_14bdb + ld a, $71 + cp e + jr nz, .asm_14bf5 +.asm_14be0 + call CreateEnergyCardListFromHand + jr c, .asm_14bf8 + ld e, $00 + call CountNumberOfEnergyCardsAttached + or a + jr nz, .asm_14bf5 + xor a + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .asm_14bf8 +.asm_14bf5 + call AIProcessAndTryToPlayEnergy +.asm_14bf8 + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards +.asm_14c01 + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14c0b PointerTable_14c0b: ; 14c0b (5:4c0b) dw Func_14c17 @@ -387,7 +539,9 @@ PointerTable_14c0b: ; 14c0b (5:4c0b) dw Func_14c34 Func_14c17: ; 14c17 (5:4c17) - INCROM $14c17, $14c1b + call Func_14cf7 + ret +; 0x14c1b Func_14c1b: ; 14c1b (5:4c1b) call InitAIDuelVars @@ -563,7 +717,53 @@ ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) ; 0x14cf7 Func_14cf7: ; 14cf7 (5:4cf7) - INCROM $14cf7, $14d60 + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall Func_227d3 + jp nc, .asm_14d56 + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_14d20 + call AIProcessAndTryToPlayEnergy +.asm_14d20 + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .asm_14d56 + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_14d53 + call AIProcessAndTryToPlayEnergy +.asm_14d53 + call AIDecidePlayPokemonCard +.asm_14d56 + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14d60 PointerTable_14d60: ; 14d60 (05:4d60) dw Func_14d6c @@ -574,7 +774,9 @@ PointerTable_14d60: ; 14d60 (05:4d60) dw Func_14d89 Func_14d6c: ; 14d6c (5:4d6c) - INCROM $14d6c, $14d70 + call Func_14def + ret +; 0x14d70 Func_14d70: ; 14d70 (5:4d70) call InitAIDuelVars @@ -678,7 +880,76 @@ Func_14dc1: ; 14dc1 (5:4dc1) ; 0x14def Func_14def: ; 14def (5:4def) - INCROM $14def, $14e89 + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall Func_227d3 + jp nc, .asm_14e7f + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_14e44 + ld a, $bb + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, $b9 + cp e + jr nz, .asm_14e41 + call CreateEnergyCardListFromHand + jr c, .asm_14e44 + ld e, $00 + call CountNumberOfEnergyCardsAttached + or a + jr nz, .asm_14e41 + xor a + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .asm_14e44 +.asm_14e41 + call AIProcessAndTryToPlayEnergy +.asm_14e44 + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .asm_14e7f + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_14e7c + call AIProcessAndTryToPlayEnergy +.asm_14e7c + call AIDecidePlayPokemonCard +.asm_14e7f + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14e89 PointerTable_14e89: ; 14e89 (5:4e89) dw Func_14e95 @@ -689,7 +960,9 @@ PointerTable_14e89: ; 14e89 (5:4e89) dw Func_14eb2 Func_14e95: ; 14e95 (5:4e95) - INCROM $14e95, $14e99 + call _AIMainTurnLogic + ret +; 0x14e99 Func_14e99: ; 14e99 (5:4e99) call InitAIDuelVars @@ -796,7 +1069,9 @@ PointerTable_14f0e: ; 14f0e (5:4f0e) dw Func_14f37 Func_14f1a: ; 14f1a (5:4f1a) - INCROM $14f1a, $14f1e + call _AIMainTurnLogic + ret +; 0x14f1e Func_14f1e: ; 14f1e (5:4f1e) call InitAIDuelVars @@ -901,7 +1176,9 @@ PointerTable_14f8f: ; 14f8f (5:4f8f) dw Func_14fb8 Func_14f9b: ; 14f9b (5:4f9b) - INCROM $14f9b, $14f9f + call _AIMainTurnLogic + ret +; 0x14f9f Func_14f9f: ; 14f9f (5:4f9f) call InitAIDuelVars @@ -1011,7 +1288,9 @@ PointerTable_15019: ; 15019 (5:5019) dw Func_15042 Func_15025: ; 15025 (5:5025) - INCROM $15025, $15029 + call _AIMainTurnLogic + ret +; 0x15029 Func_15029: ; 15029 (5:5029) call InitAIDuelVars @@ -1117,7 +1396,9 @@ PointerTable_1509b: ; 1509b (5:509b) dw Func_150c4 Func_150a7: ; 150a7 (5:50a7) - INCROM $150a7, $150ab + call _AIMainTurnLogic + ret +; 0x150ab Func_150ab: ; 150ab (5:50ab) call InitAIDuelVars @@ -1223,7 +1504,9 @@ PointerTable_15122: ; 15122 (5:5122) dw Func_1514b Func_1512e: ; 1512e (5:512e) - INCROM $1512e, $15132 + call _AIMainTurnLogic + ret +; 0x15132 Func_15132: ; 15132 (5:5132) call InitAIDuelVars @@ -1335,7 +1618,9 @@ PointerTable_151ad: ; 151ad (5:51ad) dw Func_151d6 Func_151b9: ; 151b9 (5:51b9) - INCROM $151b9, $151bd + call _AIMainTurnLogic + ret +; 0x151bd Func_151bd: ; 151bd (5:51bd) call InitAIDuelVars @@ -1443,7 +1728,9 @@ PointerTable_15232: ; 15232 (5:52PointerTable_12) dw Func_1525b Func_1523e: ; 1523e (5:523e) - INCROM $1523e, $15242 + call _AIMainTurnLogic + ret +; 0x15242 Func_15242: ; 15242 (5:5242) call InitAIDuelVars @@ -1554,7 +1841,9 @@ PointerTable_152bd: ; 152bd (5:52bd) dw Func_152e6 Func_152c9: ; 152c9 (5:52c9) - INCROM $152c9, $152cd + call _AIMainTurnLogic + ret +; 0x152cd Func_152cd: ; 152cd (5:52cd) call InitAIDuelVars @@ -1665,7 +1954,9 @@ PointerTable_1534b: ; 1534b (5:534b) dw Func_15374 Func_15357: ; 15357 (5:5357) - INCROM $15357, $1535b + call _AIMainTurnLogic + ret +; 0x1535b Func_1535b: ; 1535b (5:535b) call InitAIDuelVars @@ -1788,7 +2079,9 @@ PointerTable_153e8: ; 153e8 (5:53e8) dw Func_15411 Func_153f4: ; 153f4 (5:53f4) - INCROM $153f4, $153f8 + call _AIMainTurnLogic + ret +; 0x153f8 Func_153f8: ; 153f8 (5:53f8) call InitAIDuelVars @@ -1897,7 +2190,9 @@ PointerTable_1546f: ; 1546f (5:546f) dw Func_15498 Func_1547b: ; 1547b (5:547b) - INCROM $1547b, $1547f + call Func_15507 + ret +; 0x1547f Func_1547f: ; 1547f (5:547f) call InitAIDuelVars @@ -2009,3 +2304,98 @@ Func_154d9: ; 154d9 (5:54d9) ret ; 0x15507 + +Func_15507: ; 15507 (5:5507) + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + ld a, $ef + call GetTurnDuelistVariable + cp $06 + jr nc, .asm_15540 + ld a, $ba + call GetTurnDuelistVariable + cp $33 + jr nc, .asm_15540 + ld a, $27 + call CountPokemonIDInBothPlayAreas + jr c, .asm_15540 + ld a, $40 + call LookForCardIDInHandList_Bank5 + jr nc, .asm_15540 + ldh [hTemp_ffa0], a + ld a, $01 + bank1call AIMakeDecision +.asm_15540 + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_1555f + call AIProcessAndTryToPlayEnergy +.asm_1555f + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .asm_155c8 + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + ld a, $ef + call GetTurnDuelistVariable + cp $06 + jr nc, .asm_155a5 + ld a, $ba + call GetTurnDuelistVariable + cp $33 + jr nc, .asm_155a5 + ld a, $27 + call CountPokemonIDInBothPlayAreas + jr c, .asm_155a5 + ld a, $40 + call LookForCardIDInHandList_Bank5 + jr nc, .asm_155a5 + ldh [hTemp_ffa0], a + ld a, $01 + bank1call AIMakeDecision +.asm_155a5 + call AIDecidePlayPokemonCard + ret c + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call Func_14786 + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_155c4 + call AIProcessAndTryToPlayEnergy +.asm_155c4 + call AIDecidePlayPokemonCard + ret c +.asm_155c8 + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x155d2 -- cgit v1.2.3 From 17b8a2fdc29ff221b18533f06966b02ad0883fb2 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 1 May 2020 17:28:57 +0100 Subject: Document AI Anti Mill strategy --- src/constants/duel_constants.asm | 5 +++ src/engine/bank05.asm | 83 ++++++++++++++++++++++++---------------- src/engine/bank08.asm | 44 +++++++++++++-------- src/engine/deck_ai.asm | 40 +++++++++---------- src/wram.asm | 8 +++- 5 files changed, 112 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 9cdc73b..47ca1ad 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -263,3 +263,8 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det const AI_TRAINER_CARD_PHASE_13 ; $d const AI_TRAINER_CARD_PHASE_14 ; $e const AI_TRAINER_CARD_PHASE_15 ; $f + +; used by wAIBarrierFlagCounter to determine +; whether Player is running Mewtwo1 mill deck. +; flag set means true, flag not set means false. +AI_FLAG_MEWTWO_MILL EQU 1 << 7 diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 989225e..7162983 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1233,7 +1233,7 @@ _AIMainTurnLogic: ; 1468b (5:468b) ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - farcall Func_227d3 + farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack farcall HandleAIGoGoRainDanceEnergy @@ -1719,10 +1719,11 @@ InitAIDuelVars: ; 15636 (5:5636) ld [wcda5], a ret -; initializes some variables and -; sets value of wcda7. +; initializes some variables and sets value of wAIBarrierFlagCounter. +; if Player uses Barrier 3 times in a row, AI checks if Player's deck +; has only Mewtwo1 Pokemon cards (running a Mewtwo1 mill deck). InitAITurnVars: ; 15649 (5:5649) -; increase Pokedex counter by one +; increase Pokedex counter by 1 ld a, [wAIPokedexCounter] inc a ld [wAIPokedexCounter], a @@ -1733,30 +1734,43 @@ InitAITurnVars: ; 15649 (5:5649) ld [wcddc], a ld [wce03], a +; checks if the Player used an attack last turn +; and if it was the second attack of their card. ld a, [wPlayerAttackingMoveIndex] cp $ff - jr z, .asm_156b1 + jr z, .check_flag or a - jr z, .asm_156b1 + jr z, .check_flag ld a, [wPlayerAttackingCardIndex] cp $ff - jr z, .asm_156b1 + jr z, .check_flag +; if the card is Mewtwo1, it means the Player +; used its second attack, Barrier. call SwapTurn call GetCardIDFromDeckIndex call SwapTurn ld a, e cp MEWTWO1 - jr nz, .asm_156b1 + jr nz, .check_flag + ; Player used Barrier last turn -; handle Mewtwo1-only deck - ld a, [wcda7] +; check if flag was already set, if so, +; reset wAIBarrierFlagCounter to $80. + ld a, [wAIBarrierFlagCounter] bit 7, a - jr nz, .asm_156aa + jr nz, .set_flag + +; if not, increase it by 1 and check if it exceeds 2. inc a - ld [wcda7], a - cp $03 + ld [wAIBarrierFlagCounter], a + cp 3 jr c, .done + +; this means that the Player used Barrier +; at least 3 turns in a row. +; check if Player is running Mewtwo1-only deck, +; if so, set wAIBarrierFlagCounter flag. ld a, DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable call SwapTurn @@ -1764,31 +1778,33 @@ InitAITurnVars: ; 15649 (5:5649) call SwapTurn ld a, e cp MEWTWO1 - jr nz, .asm_156a4 + jr nz, .reset_1 farcall CheckIfPlayerHasPokemonOtherThanMewtwo1 - jr nc, .asm_156aa -.asm_156a4 -; reset wcda7 + jr nc, .set_flag +.reset_1 +; reset wAIBarrierFlagCounter xor a - ld [wcda7], a + ld [wAIBarrierFlagCounter], a jr .done -.asm_156aa - ld a, $80 - ld [wcda7], a + +.set_flag + ld a, AI_FLAG_MEWTWO_MILL + 0 + ld [wAIBarrierFlagCounter], a jr .done -.asm_156b1 - ld a, [wcda7] +.check_flag +; increase counter by 1 if flag is set + ld a, [wAIBarrierFlagCounter] bit 7, a - jr z, .asm_156be + jr z, .reset_2 inc a - ld [wcda7], a + ld [wAIBarrierFlagCounter], a jr .done -.asm_156be -; reset wcda7 +.reset_2 +; reset wAIBarrierFlagCounter xor a - ld [wcda7], a + ld [wAIBarrierFlagCounter], a .done ret ; 0x156c3 @@ -4520,11 +4536,12 @@ AIProcessEnergyCards: ; 164fc (5:64fc) jr nz, .bench ; arena - ld a, [wcda7] + ld a, [wAIBarrierFlagCounter] bit 7, a jr z, .add_to_score -; subtract from score +; subtract from score instead +; if Player is running Mewtwo1 mill deck. ld a, 5 call SubFromAIScore jr .check_defending_can_ko @@ -5455,8 +5472,10 @@ AIProcessAttacks: ; 169fc (5:69fc) jr .attack_chosen .no_pluspower - ld a, [wcda7] - cp $80 +; if Player is running Mewtwo1 mill deck, +; skip attack if Barrier counter is 0. + ld a, [wAIBarrierFlagCounter] + cp AI_FLAG_MEWTWO_MILL + 0 jp z, .dont_attack ; determine AI score of both attacks. diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 1c6f82a..8d6d462 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -4698,19 +4698,22 @@ AIPlay_Gambler: ; 2182d (8:582d) ; 0x21875 ; checks whether to play Gambler. -; aside from Imakuni, all other opponents only -; play if there's less than 4 cards in the deck. +; aside from Imakuni?, all other opponents only +; play this card if Player is running Mewtwo1-only deck. AIDecide_Gambler: ; 21875 (8:5875) ; Imakuni? has his own routine ld a, [wOpponentDeckID] cp IMAKUNI_DECK_ID jr z, .imakuni - ld a, [wcda7] - and $80 +; check if flag is set for Player using Mewtwo1 only deck + ld a, [wAIBarrierFlagCounter] + and AI_FLAG_MEWTWO_MILL jr z, .no_carry -; set carry if number of cards in deck <= 4 +; set carry if number of cards in deck <= 4. +; this is done to counteract the deck out strategy +; of Mewtwo1 deck, by replenishing the deck with hand cards. ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable cp DECK_SIZE - 4 @@ -7487,26 +7490,37 @@ CheckIfPlayerHasPokemonOtherThanMewtwo1: ; 227a9 (8:67a9) ret ; 0x227d3 -; checks wcda7 and Pokemon in Play Area that are set up. -; if there's at least 4, goes to AI_TRAINER_CARD_PHASE_05. -; else, returns carry. -Func_227d3: ; 227d3 (8:67d3) - ld a, [wcda7] +; returns no carry if, given the Player is using a Mewtwo1 mill deck, +; the AI already has a Bench fully set up, in which case it +; will process some Trainer cards in hand (namely Energy Removals). +; this is used to check whether to skip some normal AI routines +; this turn and jump right to the attacking phase. +HandleAIAntiMewtwoDeckStrategy: ; 227d3 (8:67d3) +; return carry if Player is not playing Mewtwo1 mill deck + ld a, [wAIBarrierFlagCounter] bit 7, a jr z, .set_carry - cp %10000010 - jr c, .asm_227e4 -; reset wcda7 +; else, check if there's been less than 2 turns +; without the Player using Barrier. + cp AI_FLAG_MEWTWO_MILL + 2 + jr c, .count_bench + +; if there has been, reset wAIBarrierFlagCounter +; and return carry. xor a - ld [wcda7], a + ld [wAIBarrierFlagCounter], a jr .set_carry -.asm_227e4 +; else, check number of Pokemon that are set up in Bench +; if less than 4, return carry. +.count_bench farcall CountNumberOfSetUpBenchPokemon cp 4 jr c, .set_carry +; if there's at least 4 Pokemon in the Bench set up, +; process Trainer hand cards of AI_TRAINER_CARD_PHASE_05 ld a, AI_TRAINER_CARD_PHASE_05 farcall AIProcessHandTrainerCards or a diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index e4edfdf..c93b8ce 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -58,8 +58,8 @@ Func_148ff: ; 148ff (5:48ff) call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - farcall Func_227d3 - jp nc, .asm_149de + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack farcall HandleAIGoGoRainDanceEnergy farcall HandleAIDamageSwap farcall HandleAIPkmnPowers @@ -105,7 +105,7 @@ Func_148ff: ; 148ff (5:48ff) call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK - jr z, .asm_149de + jr z, .try_attack ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -142,7 +142,7 @@ Func_148ff: ; 148ff (5:48ff) farcall HandleAIGoGoRainDanceEnergy ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards -.asm_149de +.try_attack call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK @@ -277,7 +277,7 @@ Func_14a4a: ; 14a4a (5:4a4a) Func_14a81: ; 14a81 (5:4a81) call InitAITurnVars - farcall Func_227d3 + farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack ld a, AI_TRAINER_CARD_PHASE_02 @@ -474,8 +474,8 @@ Func_14b6c: ; 14b6c (5:4b6c) Func_14b9a: ; 14b9a (5:4b9a) call InitAITurnVars - farcall Func_227d3 - jp nc, .asm_14c01 + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 @@ -522,7 +522,7 @@ Func_14b9a: ; 14b9a (5:4b9a) ret c ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards -.asm_14c01 +.try_attack call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK @@ -720,8 +720,8 @@ Func_14cf7: ; 14cf7 (5:4cf7) call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - farcall Func_227d3 - jp nc, .asm_14d56 + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard @@ -741,7 +741,7 @@ Func_14cf7: ; 14cf7 (5:4cf7) call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK - jr z, .asm_14d56 + jr z, .try_attack ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -757,7 +757,7 @@ Func_14cf7: ; 14cf7 (5:4cf7) call AIProcessAndTryToPlayEnergy .asm_14d53 call AIDecidePlayPokemonCard -.asm_14d56 +.try_attack call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK @@ -883,8 +883,8 @@ Func_14def: ; 14def (5:4def) call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards - farcall Func_227d3 - jp nc, .asm_14e7f + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard @@ -923,7 +923,7 @@ Func_14def: ; 14def (5:4def) call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK - jr z, .asm_14e7f + jr z, .try_attack ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -943,7 +943,7 @@ Func_14def: ; 14def (5:4def) call AIProcessAndTryToPlayEnergy .asm_14e7c call AIDecidePlayPokemonCard -.asm_14e7f +.try_attack call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK @@ -2328,7 +2328,7 @@ Func_15507: ; 15507 (5:5507) call LookForCardIDInHandList_Bank5 jr nc, .asm_15540 ldh [hTemp_ffa0], a - ld a, $01 + ld a, OPPACTION_PLAY_BASIC_PKMN bank1call AIMakeDecision .asm_15540 call AIDecidePlayPokemonCard @@ -2351,7 +2351,7 @@ Func_15507: ; 15507 (5:5507) call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK - jr z, .asm_155c8 + jr z, .try_attack ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -2373,7 +2373,7 @@ Func_15507: ; 15507 (5:5507) call LookForCardIDInHandList_Bank5 jr nc, .asm_155a5 ldh [hTemp_ffa0], a - ld a, $01 + ld a, OPPACTION_PLAY_BASIC_PKMN bank1call AIMakeDecision .asm_155a5 call AIDecidePlayPokemonCard @@ -2392,7 +2392,7 @@ Func_15507: ; 15507 (5:5507) .asm_155c4 call AIDecidePlayPokemonCard ret c -.asm_155c8 +.try_attack call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK diff --git a/src/wram.asm b/src/wram.asm index cae7f88..5614b54 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1192,7 +1192,13 @@ wcda5:: ; cda5 wAIPokedexCounter:: ; cda6 ds $1 -wcda7:: ; cda7 +; variable to keep track of Mewtwo1's Barrier usage during Player' turn. +; AI_FLAG_MEWTWO_MILL set means Player is running Mewtwo1 mill deck. +; - when flag is not set, this counts how many turns in a row +; Player used Mewtwo1's Barrier attack; +; - when flag is set, this counts how many turns in a row +; Player has NOT used Barrier attack. +wAIBarrierFlagCounter:: ; cda7 ds $1 wcda8:: ; cda8 -- cgit v1.2.3 From b7f47ca621716938cfc6df7d4eea90b2be909eaf Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sun, 3 May 2020 12:06:02 -0400 Subject: add challenge machine --- src/engine/bank03.asm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 4ee4626..31d8846 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -3196,13 +3196,19 @@ MasonLabPressedA: ; d565 (3:5565) ChallengeMachineObjectTable: ; d572 (3:5572) db 10, 4, NORTH - dw OWSequence_d57d + dw OWSequence_ChallengeMachine db 12, 4, NORTH - dw OWSequence_d57d + dw OWSequence_ChallengeMachine db $00 -OWSequence_d57d: ; d57d (3:557d) - INCROM $d57d, $d753 +OWSequence_ChallengeMachine: ; d57d (3:557d) + start_script + run_script Func_ccdc + tx Text05bd + run_script Func_d43d + run_script OWScript_QuitScriptFully + + INCROM $d583, $d753 OWSequence_EnterLabFirstTime: ; d753 (3:5753) start_script -- cgit v1.2.3 From 085660d0799a85e18fa6a25f251875ce7c0db5d4 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Tue, 5 May 2020 21:29:47 -0400 Subject: Added NPC_ Prefix, Changed Level to Map in some places --- src/constants/map_constants.asm | 4 +- src/constants/npc_constants.asm | 232 +++++++-------- src/data/level_objects.asm | 610 ---------------------------------------- src/data/map_objects.asm | 610 ++++++++++++++++++++++++++++++++++++++++ src/data/npc_map_data.asm | 314 ++++++++++----------- src/data/npcs.asm | 220 +++++++-------- src/engine/bank03.asm | 94 +++---- src/engine/bank04.asm | 2 +- src/engine/bank07.asm | 6 +- src/engine/home.asm | 2 +- 10 files changed, 1047 insertions(+), 1047 deletions(-) delete mode 100644 src/data/level_objects.asm create mode 100644 src/data/map_objects.asm (limited to 'src') diff --git a/src/constants/map_constants.asm b/src/constants/map_constants.asm index 92eaf4c..d8637d6 100644 --- a/src/constants/map_constants.asm +++ b/src/constants/map_constants.asm @@ -35,10 +35,10 @@ const HALL_OF_HONOR ; $21 -; Size of map data. See data/npc_map_data.asm and data/level_objects.asm +; Size of map data. See data/npc_map_data.asm and data/map_objects.asm ; for more info on what these represent NPC_MAP_SIZE EQU $06 -LEVEL_OBJECT_SIZE EQU $09 +MAP_OBJECT_SIZE EQU $09 ; Most of these aren't fully understood so the names aren't great MAP_SCRIPT_SIZE EQU $0f diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index 5ae8f99..e51dfb9 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -19,9 +19,9 @@ LOADED_NPC_LENGTH EQU const_value ; npc_struct constants const_def const NPC_TRAINER_ID - const NPC_DATA_FIELD_01 ; Sprite - const NPC_DATA_FIELD_02 ; DMG/SGB pal - const NPC_DATA_FIELD_03 ; CGB pal + const NPC_DATA_FIELD_01 ; 01-03 Seem to relate to sprites + const NPC_DATA_FIELD_02 + const NPC_DATA_FIELD_03 const NPC_DATA_FIELD_04 const NPC_DATA_OWSEQUENCE_PTR const_value = const_value+1 @@ -77,119 +77,119 @@ NPC_DATA_LENGTH EQU const_value const AARON_PIC ; $29 const_def 1 - const DRMASON ; $01 - const RONALD1 ; $02 - const ISHIHARA ; $03 - const IMAKUNI ; $04 + const NPC_DRMASON ; $01 + const NPC_RONALD1 ; $02 + const NPC_ISHIHARA ; $03 + const NPC_IMAKUNI ; $04 const_value = const_value+1 ; DRMASON duplicate const_value = const_value+1 ; DRMASON duplicate - const SAM ; $07 - const TECH1 ; $08 - const TECH2 ; $09 - const TECH3 ; $0a - const TECH4 ; $0b - const TECH5 ; $0c - const TECH6 ; $0d - const CLERK1 ; $0e - const CLERK2 ; $0f - const CLERK3 ; $10 - const CLERK4 ; $11 - const CLERK5 ; $12 - const CLERK6 ; $13 - const CLERK7 ; $14 - const CLERK8 ; $15 - const CLERK9 ; $16 - const CHRIS ; $17 - const MICHAEL ; $18 - const JESSICA ; $19 - const MITCH ; $1a - const MATTHEW ; $1b - const RYAN ; $1c - const ANDREW ; $1d - const GENE ; $1e - const SARA ; $1f - const AMANDA ; $20 - const JOSHUA ; $21 - const AMY ; $22 - const JENNIFER ; $23 - const NICHOLAS ; $24 - const BRANDON ; $25 - const ISAAC ; $26 - const BRITTANY ; $27 - const KRISTIN ; $28 - const HEATHER ; $29 - const NIKKI ; $2a - const ROBERT ; $2b - const DANIEL ; $2c - const STEPHANIE ; $2d - const MURRAY1 ; $2e - const JOSEPH ; $2f - const DAVID ; $30 - const ERIK ; $31 - const RICK ; $32 - const JOHN ; $33 - const ADAM ; $34 - const JONATHAN ; $35 - const KEN ; $36 - const COURTNEY ; $37 - const STEVE ; $38 - const JACK ; $39 - const ROD ; $3a - const CLERK10 ; $3b - const GIFT_CENTER_CLERK ; $3c - const MAN1 ; $3d - const WOMAN1 ; $3e - const CHAP1 ; $3f - const GAL1 ; $40 - const LASS1 ; $41 - const CHAP2 ; $42 - const LASS2 ; $43 - const PAPPY1 ; $44 - const LAD1 ; $45 - const LAD2 ; $46 - const CHAP3 ; $47 - const CLERK12 ; $48 - const CLERK13 ; $49 - const HOST ; $4a - const SPECS1 ; $4b - const BUTCH ; $4c - const GRANNY1 ; $4d - const LASS3 ; $4e - const MAN2 ; $4f - const PAPPY2 ; $50 - const LASS4 ; $51 - const HOOD1 ; $52 - const GRANNY2 ; $53 - const GAL2 ; $54 - const LAD3 ; $55 - const GAL3 ; $56 - const CHAP4 ; $57 - const MAN3 ; $58 - const SPECS2 ; $59 - const SPECS3 ; $5a - const WOMAN2 ; $5b - const MANIA ; $5c - const PAPPY3 ; $5d - const GAL4 ; $5e - const CHAMP ; $5f - const HOOD2 ; $60 - const LASS5 ; $61 - const CHAP5 ; $62 - const AARON ; $63 - const GUIDE ; $64 - const TECH7 ; $65 - const TECH8 ; $66 - const _11F18 ; $67 - const LEGEND_CARDS_TOP_LEFT ; $68 - const LEGEND_CARDS_TOP_RIGHT ; $69 - const LEGEND_CARDS_LEFT_SPARK ; $6a - const LEGEND_CARDS_BOTTOM_LEFT ; $6b - const LEGEND_CARDS_BOTTOM_RIGHT ; $6c - const LEGEND_CARDS_RIGHT_SPARK ; $6d - const _11F49 ; $6e -const_value = const_value+1 ; _11F49 duplicate - const MURRAY2 ; $70 - const RONALD2 ; $71 - const RONALD3 ; $72 -const_value = const_value+1 ; _11f49 duplicate + const NPC_SAM ; $07 + const NPC_TECH1 ; $08 + const NPC_TECH2 ; $09 + const NPC_TECH3 ; $0a + const NPC_TECH4 ; $0b + const NPC_TECH5 ; $0c + const NPC_TECH6 ; $0d + const NPC_CLERK1 ; $0e + const NPC_CLERK2 ; $0f + const NPC_CLERK3 ; $10 + const NPC_CLERK4 ; $11 + const NPC_CLERK5 ; $12 + const NPC_CLERK6 ; $13 + const NPC_CLERK7 ; $14 + const NPC_CLERK8 ; $15 + const NPC_CLERK9 ; $16 + const NPC_CHRIS ; $17 + const NPC_MICHAEL ; $18 + const NPC_JESSICA ; $19 + const NPC_MITCH ; $1a + const NPC_MATTHEW ; $1b + const NPC_RYAN ; $1c + const NPC_ANDREW ; $1d + const NPC_GENE ; $1e + const NPC_SARA ; $1f + const NPC_AMANDA ; $20 + const NPC_JOSHUA ; $21 + const NPC_AMY ; $22 + const NPC_JENNIFER ; $23 + const NPC_NICHOLAS ; $24 + const NPC_BRANDON ; $25 + const NPC_ISAAC ; $26 + const NPC_BRITTANY ; $27 + const NPC_KRISTIN ; $28 + const NPC_HEATHER ; $29 + const NPC_NIKKI ; $2a + const NPC_ROBERT ; $2b + const NPC_DANIEL ; $2c + const NPC_STEPHANIE ; $2d + const NPC_MURRAY1 ; $2e + const NPC_JOSEPH ; $2f + const NPC_DAVID ; $30 + const NPC_ERIK ; $31 + const NPC_RICK ; $32 + const NPC_JOHN ; $33 + const NPC_ADAM ; $34 + const NPC_JONATHAN ; $35 + const NPC_KEN ; $36 + const NPC_COURTNEY ; $37 + const NPC_STEVE ; $38 + const NPC_JACK ; $39 + const NPC_ROD ; $3a + const NPC_CLERK10 ; $3b + const NPC_GIFT_CENTER_CLERK ; $3c + const NPC_MAN1 ; $3d + const NPC_WOMAN1 ; $3e + const NPC_CHAP1 ; $3f + const NPC_GAL1 ; $40 + const NPC_LASS1 ; $41 + const NPC_CHAP2 ; $42 + const NPC_LASS2 ; $43 + const NPC_PAPPY1 ; $44 + const NPC_LAD1 ; $45 + const NPC_LAD2 ; $46 + const NPC_CHAP3 ; $47 + const NPC_CLERK12 ; $48 + const NPC_CLERK13 ; $49 + const NPC_HOST ; $4a + const NPC_SPECS1 ; $4b + const NPC_BUTCH ; $4c + const NPC_GRANNY1 ; $4d + const NPC_LASS3 ; $4e + const NPC_MAN2 ; $4f + const NPC_PAPPY2 ; $50 + const NPC_LASS4 ; $51 + const NPC_HOOD1 ; $52 + const NPC_GRANNY2 ; $53 + const NPC_GAL2 ; $54 + const NPC_LAD3 ; $55 + const NPC_GAL3 ; $56 + const NPC_CHAP4 ; $57 + const NPC_MAN3 ; $58 + const NPC_SPECS2 ; $59 + const NPC_SPECS3 ; $5a + const NPC_WOMAN2 ; $5b + const NPC_MANIA ; $5c + const NPC_PAPPY3 ; $5d + const NPC_GAL4 ; $5e + const NPC_CHAMP ; $5f + const NPC_HOOD2 ; $60 + const NPC_LASS5 ; $61 + const NPC_CHAP5 ; $62 + const NPC_AARON ; $63 + const NPC_GUIDE ; $64 + const NPC_TECH7 ; $65 + const NPC_TECH8 ; $66 + const NPC_11F18 ; $67 + const NPC_LEGEND_CARDS_TOP_LEFT ; $68 + const NPC_LEGEND_CARDS_TOP_RIGHT ; $69 + const NPC_LEGEND_CARDS_LEFT_SPARK ; $6a + const NPC_LEGEND_CARDS_BOTTOM_LEFT ; $6b + const NPC_LEGEND_CARDS_BOTTOM_RIGHT ; $6c + const NPC_LEGEND_CARDS_RIGHT_SPARK ; $6d + const NPC_11F49 ; $6e +const_value = const_value+1 ; NPC_11F49 duplicate + const NPC_MURRAY2 ; $70 + const NPC_RONALD2 ; $71 + const NPC_RONALD3 ; $72 +const_value = const_value+1 ; NPC_11f49 duplicate diff --git a/src/data/level_objects.asm b/src/data/level_objects.asm deleted file mode 100644 index 0756f7f..0000000 --- a/src/data/level_objects.asm +++ /dev/null @@ -1,610 +0,0 @@ -; Objects around maps that can be interacted with but are not represented -; by NPCs. Things like Deck Machines and the PCs. -; Format: -; Direction you need to face, X coord, Y coord -; Routine that gets called when you hit A in front of it -; Object Name, and Object default Text -MasonLabObjects: ; 13b04 (3:7b04) - db NORTH, 18, 2 - dw PrintInteractableObjectText - tx Text04a0 - tx Text049f - - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04a2 - tx Text04a1 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04a4 - tx Text04a3 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04a6 - tx Text04a5 - - db NORTH, 20, 14 - dw PrintInteractableObjectText - tx Text04a8 - tx Text04a7 - - db NORTH, 22, 14 - dw PrintInteractableObjectText - tx Text04aa - tx Text04a9 - - db NORTH, 24, 14 - dw PrintInteractableObjectText - tx Text04ac - tx Text04ab - - db NORTH, 2, 2 - dw PC_c7ea - tx Text041b - tx Text041a - - db $ff - - -DeckMachineRoomObjects: ; 13b4d (3:7b4d) - db NORTH, 2, 2 - dw OWSequence_d932 - tx Text041b - tx Text041a - - db NORTH, 4, 2 - dw OWSequence_d932 - tx Text041b - tx Text041a - - db NORTH, 6, 2 - dw $593f - tx Text041b - tx Text041a - - db NORTH, 8, 2 - dw $593f - tx Text041b - tx Text041a - - db NORTH, 10, 2 - dw $5995 - tx Text041b - tx Text041a - - db NORTH, 12, 2 - dw $5995 - tx Text041b - tx Text041a - - db NORTH, 14, 2 - dw $59c2 - tx Text041b - tx Text041a - - db NORTH, 16, 2 - dw $59c2 - tx Text041b - tx Text041a - - db NORTH, 18, 2 - dw $59ef - tx Text041b - tx Text041a - - db NORTH, 20, 2 - dw $59ef - tx Text041b - tx Text041a - - db NORTH, 14, 10 - dw $5a1c - tx Text041b - tx Text041a - - db NORTH, 16, 10 - dw $5a1c - tx Text041b - tx Text041a - - db NORTH, 18, 10 - dw $5a49 - tx Text041b - tx Text041a - - db NORTH, 20, 10 - dw $5a49 - tx Text041b - tx Text041a - - db NORTH, 14, 18 - dw $5a76 - tx Text041b - tx Text041a - - db NORTH, 16, 18 - dw $5a76 - tx Text041b - tx Text041a - - db NORTH, 18, 18 - dw $5aa3 - tx Text041b - tx Text041a - - db NORTH, 20, 18 - dw $5aa3 - tx Text041b - tx Text041a - - db NORTH, 2, 18 - dw $5ad0 - tx Text041b - tx Text041a - - db NORTH, 4, 18 - dw $5ad0 - tx Text041b - tx Text041a - - db $ff - - -IshiharasHouseObjects: ; 13c02 (3:7c02) - db NORTH, 6, 2 - dw PrintInteractableObjectText - tx Text04ae - tx Text04ad - - db NORTH, 8, 2 - dw PrintInteractableObjectText - tx Text04b0 - tx Text04af - - db NORTH, 10, 2 - dw PrintInteractableObjectText - tx Text04b2 - tx Text04b1 - - db NORTH, 12, 2 - dw PrintInteractableObjectText - tx Text04b4 - tx Text04b3 - - db NORTH, 14, 2 - dw PrintInteractableObjectText - tx Text04b6 - tx Text04b5 - - db NORTH, 16, 2 - dw PrintInteractableObjectText - tx Text04b8 - tx Text04b7 - - db NORTH, 2, 12 - dw PrintInteractableObjectText - tx Text04ba - tx Text04b9 - - db NORTH, 4, 12 - dw PrintInteractableObjectText - tx Text04bc - tx Text04bb - - db NORTH, 6, 12 - dw PrintInteractableObjectText - tx Text04be - tx Text04bd - - db NORTH, 12, 12 - dw PrintInteractableObjectText - tx Text04c0 - tx Text04bf - - db NORTH, 14, 12 - dw PrintInteractableObjectText - tx Text04c2 - tx Text04c1 - - db NORTH, 16, 12 - dw PrintInteractableObjectText - tx Text04c4 - tx Text04c3 - - db $ff - - -FightingClubLobbyObjects: ; 13c6f (3:7c6f) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04c6 - tx Text04c5 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04c8 - tx Text04c7 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04ca - tx Text04c9 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -RockClubLobbyObjects: ; 13ca6 (3:7ca6) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04cc - tx Text04cb - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04ce - tx Text04cd - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04d0 - tx Text04cf - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -WaterClubLobbyObjects: ; 13cdd (3:7cdd) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04d2 - tx Text04d1 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04d4 - tx Text04d3 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04d6 - tx Text04d5 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -LightningClubLobbyObjects: ; 13d14 (3:7d14) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04d8 - tx Text04d7 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04da - tx Text04d9 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04dc - tx Text04db - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -GrassClubLobbyObjects: ; 13d4b (3:7d4b) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04de - tx Text04dd - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04e0 - tx Text04df - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04e2 - tx Text04e1 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -PsychicClubLobbyObjects: ; 13d82 (3:7d82) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04e4 - tx Text04e3 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04e6 - tx Text04e5 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04e8 - tx Text04e7 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -ScienceClubLobbyObjects: ; 13db9 (3:7db9) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04ea - tx Text04e9 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04ec - tx Text04eb - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04ee - tx Text04ed - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -FireClubLobbyObjects: ; 13df0 (3:7df0) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04f0 - tx Text04ef - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04f2 - tx Text04f1 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04f4 - tx Text04f3 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -ChallengeHallLobbyObjects: ; 13e27 (3:7e27) - db NORTH, 20, 2 - dw PrintInteractableObjectText - tx Text04f6 - tx Text04f5 - - db NORTH, 22, 2 - dw PrintInteractableObjectText - tx Text04f8 - tx Text04f7 - - db NORTH, 24, 2 - dw PrintInteractableObjectText - tx Text04fa - tx Text04f9 - - db NORTH, 2, 8 - dw PC_c7ea - tx Text041b - tx Text041a - - db NORTH, 6, 6 - dw OWSequence_fc52 - tx Text041b - tx Text03b0 - - db NORTH, 10, 6 - dw Func_fc7a - tx Text041b - tx Text03b0 - - db $ff - - -PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) - db NORTH, 2, 2 - dw PrintInteractableObjectText - tx Text04fc - tx Text04fb - - db NORTH, 4, 2 - dw PrintInteractableObjectText - tx Text04fe - tx Text04fd - - db NORTH, 6, 2 - dw PrintInteractableObjectText - tx Text0500 - tx Text04ff - - - db NORTH, 2, 8 - dw PrintInteractableObjectText - tx Text0502 - tx Text0501 - - db NORTH, 4, 8 - dw PrintInteractableObjectText - tx Text0504 - tx Text0503 - - db NORTH, 6, 8 - dw PrintInteractableObjectText - tx Text0506 - tx Text0505 - - db NORTH, 18, 0 - dw OWSequence_f631 - tx Text0508 - tx Text0507 - - db NORTH, 20, 0 - dw OWSequence_f631 - tx Text0508 - tx Text0507 - - db NORTH, 22, 0 - dw $76af - tx Text0558 - tx Text0509 - - db NORTH, 24, 0 - dw $76af - tx Text0558 - tx Text0509 - - db NORTH, 28, 2 - dw PC_c7ea - tx Text041b - tx Text041a - - db $ff - - -HallOfHonorObjects: ; 13ec2 (3:7ec2) - ; Legendary Cards - db NORTH, 10, 10 - dw OWSequence_fbf1 - dw $0000 - dw $0000 - - ; Legendary Cards - db NORTH, 12, 10 - dw OWSequence_fbf1 - dw $0000 - dw $0000 - - db NORTH, 10, 2 - dw $7be1 - tx Text041b - tx Text041a - - db NORTH, 12, 2 - dw $7be1 - tx Text041b - tx Text041a - - db $ff - - diff --git a/src/data/map_objects.asm b/src/data/map_objects.asm new file mode 100644 index 0000000..0756f7f --- /dev/null +++ b/src/data/map_objects.asm @@ -0,0 +1,610 @@ +; Objects around maps that can be interacted with but are not represented +; by NPCs. Things like Deck Machines and the PCs. +; Format: +; Direction you need to face, X coord, Y coord +; Routine that gets called when you hit A in front of it +; Object Name, and Object default Text +MasonLabObjects: ; 13b04 (3:7b04) + db NORTH, 18, 2 + dw PrintInteractableObjectText + tx Text04a0 + tx Text049f + + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04a2 + tx Text04a1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04a4 + tx Text04a3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04a6 + tx Text04a5 + + db NORTH, 20, 14 + dw PrintInteractableObjectText + tx Text04a8 + tx Text04a7 + + db NORTH, 22, 14 + dw PrintInteractableObjectText + tx Text04aa + tx Text04a9 + + db NORTH, 24, 14 + dw PrintInteractableObjectText + tx Text04ac + tx Text04ab + + db NORTH, 2, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +DeckMachineRoomObjects: ; 13b4d (3:7b4d) + db NORTH, 2, 2 + dw OWSequence_d932 + tx Text041b + tx Text041a + + db NORTH, 4, 2 + dw OWSequence_d932 + tx Text041b + tx Text041a + + db NORTH, 6, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 8, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 10, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 14, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 16, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 18, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 20, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 14, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 16, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 18, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 20, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 14, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 16, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 18, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 20, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 2, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db NORTH, 4, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db $ff + + +IshiharasHouseObjects: ; 13c02 (3:7c02) + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text04ae + tx Text04ad + + db NORTH, 8, 2 + dw PrintInteractableObjectText + tx Text04b0 + tx Text04af + + db NORTH, 10, 2 + dw PrintInteractableObjectText + tx Text04b2 + tx Text04b1 + + db NORTH, 12, 2 + dw PrintInteractableObjectText + tx Text04b4 + tx Text04b3 + + db NORTH, 14, 2 + dw PrintInteractableObjectText + tx Text04b6 + tx Text04b5 + + db NORTH, 16, 2 + dw PrintInteractableObjectText + tx Text04b8 + tx Text04b7 + + db NORTH, 2, 12 + dw PrintInteractableObjectText + tx Text04ba + tx Text04b9 + + db NORTH, 4, 12 + dw PrintInteractableObjectText + tx Text04bc + tx Text04bb + + db NORTH, 6, 12 + dw PrintInteractableObjectText + tx Text04be + tx Text04bd + + db NORTH, 12, 12 + dw PrintInteractableObjectText + tx Text04c0 + tx Text04bf + + db NORTH, 14, 12 + dw PrintInteractableObjectText + tx Text04c2 + tx Text04c1 + + db NORTH, 16, 12 + dw PrintInteractableObjectText + tx Text04c4 + tx Text04c3 + + db $ff + + +FightingClubLobbyObjects: ; 13c6f (3:7c6f) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04c6 + tx Text04c5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04c8 + tx Text04c7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ca + tx Text04c9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +RockClubLobbyObjects: ; 13ca6 (3:7ca6) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04cc + tx Text04cb + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ce + tx Text04cd + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d0 + tx Text04cf + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +WaterClubLobbyObjects: ; 13cdd (3:7cdd) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d2 + tx Text04d1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04d4 + tx Text04d3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d6 + tx Text04d5 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LightningClubLobbyObjects: ; 13d14 (3:7d14) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d8 + tx Text04d7 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04da + tx Text04d9 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04dc + tx Text04db + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +GrassClubLobbyObjects: ; 13d4b (3:7d4b) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04de + tx Text04dd + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e0 + tx Text04df + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e2 + tx Text04e1 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +PsychicClubLobbyObjects: ; 13d82 (3:7d82) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04e4 + tx Text04e3 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e6 + tx Text04e5 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e8 + tx Text04e7 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +ScienceClubLobbyObjects: ; 13db9 (3:7db9) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04ea + tx Text04e9 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ec + tx Text04eb + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ee + tx Text04ed + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +FireClubLobbyObjects: ; 13df0 (3:7df0) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f0 + tx Text04ef + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f2 + tx Text04f1 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04f4 + tx Text04f3 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +ChallengeHallLobbyObjects: ; 13e27 (3:7e27) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f6 + tx Text04f5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f8 + tx Text04f7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04fa + tx Text04f9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw OWSequence_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) + db NORTH, 2, 2 + dw PrintInteractableObjectText + tx Text04fc + tx Text04fb + + db NORTH, 4, 2 + dw PrintInteractableObjectText + tx Text04fe + tx Text04fd + + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text0500 + tx Text04ff + + + db NORTH, 2, 8 + dw PrintInteractableObjectText + tx Text0502 + tx Text0501 + + db NORTH, 4, 8 + dw PrintInteractableObjectText + tx Text0504 + tx Text0503 + + db NORTH, 6, 8 + dw PrintInteractableObjectText + tx Text0506 + tx Text0505 + + db NORTH, 18, 0 + dw OWSequence_f631 + tx Text0508 + tx Text0507 + + db NORTH, 20, 0 + dw OWSequence_f631 + tx Text0508 + tx Text0507 + + db NORTH, 22, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 24, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 28, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +HallOfHonorObjects: ; 13ec2 (3:7ec2) + ; Legendary Cards + db NORTH, 10, 10 + dw OWSequence_fbf1 + dw $0000 + dw $0000 + + ; Legendary Cards + db NORTH, 12, 10 + dw OWSequence_fbf1 + dw $0000 + dw $0000 + + db NORTH, 10, 2 + dw $7be1 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $7be1 + tx Text041b + tx Text041a + + db $ff + + diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index 05663c3..701171e 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -3,417 +3,417 @@ ; NPC, X position, Y Position, Direction, ; pre-load function. (Resets c flag if NPC should not be loaded) MasonLabNPCS: ; 772f (4:1372f) - db DRMASON, $0e, $06, SOUTH + db NPC_DRMASON, $0e, $06, SOUTH dw $5710 - db SAM, $04, $0e, EAST + db NPC_SAM, $04, $0e, EAST dw $5604 - db TECH1, $16, $08, WEST + db NPC_TECH1, $16, $08, WEST dw $0000 - db TECH2, $16, $14, SOUTH + db NPC_TECH2, $16, $14, SOUTH dw $0000 - db TECH3, $16, $16, WEST + db NPC_TECH3, $16, $16, WEST dw $0000 - db TECH4, $0a, $16, EAST + db NPC_TECH4, $0a, $16, EAST dw $0000 - db TECH5, $06, $04, SOUTH + db NPC_TECH5, $06, $04, SOUTH dw $55eb db $00 DeckMachineRoomNPCS: ; 775a (4:1375a) - db TECH6, $06, $08, SOUTH + db NPC_TECH6, $06, $08, SOUTH dw $0000 - db TECH7, $06, $16, WEST + db NPC_TECH7, $06, $16, WEST dw $0000 - db TECH8, $0a, $12, WEST + db NPC_TECH8, $0a, $12, WEST dw $0000 - db AARON, $0c, $0c, WEST + db NPC_AARON, $0c, $0c, WEST dw $0000 db $00 IshiharasHouseNPCS: ; 7773 (4:13773) - db NIKKI, $04, $04, NORTH + db NPC_NIKKI, $04, $04, NORTH dw Preload_NikkiInIshiharasHouse - db ISHIHARA, $08, $08, SOUTH + db NPC_ISHIHARA, $08, $08, SOUTH dw Preload_IshiharaInIshiharasHouse - db RONALD1, $02, $04, WEST + db NPC_RONALD1, $02, $04, WEST dw Preload_Ronald1InIshiharasHouse db $00 FightingClubEntranceNPCS: ; 7786 (4:13786) - db CLERK1, $06, $02, SOUTH + db NPC_CLERK1, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 FightingClubLobbyNPCS: ; 779f (4:1379f) - db MAN1, $0c, $0e, WEST + db NPC_MAN1, $0c, $0e, WEST dw $0000 - db IMAKUNI, $12, $02, NORTH + db NPC_IMAKUNI, $12, $02, NORTH dw $5ceb - db SPECS1, $12, $10, EAST + db NPC_SPECS1, $12, $10, EAST dw $0000 - db BUTCH, $14, $10, WEST + db NPC_BUTCH, $14, $10, WEST dw $0000 - db GRANNY1, $04, $10, WEST + db NPC_GRANNY1, $04, $10, WEST dw $5d98 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 FightingClubNPCS: ; 77ca (4:137ca) - db CHRIS, $04, $08, SOUTH + db NPC_CHRIS, $04, $08, SOUTH dw $5e43 - db MICHAEL, $0e, $0a, SOUTH + db NPC_MICHAEL, $0e, $0a, SOUTH dw $5e79 - db JESSICA, $12, $06, EAST + db NPC_JESSICA, $12, $06, EAST dw $5ea5 - db MITCH, $0a, $04, SOUTH + db NPC_MITCH, $0a, $04, SOUTH dw $0000 db $00 RockClubEntranceNPCS: ; 77e3 (4:137e3) - db CLERK2, $06, $02, SOUTH + db NPC_CLERK2, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 RockClubLobbyNPCS: ; 77fc (4:137fc) - db CHRIS, $12, $08, WEST + db NPC_CHRIS, $12, $08, WEST dw $5ee9 - db MATTHEW, $06, $0e, EAST + db NPC_MATTHEW, $06, $0e, EAST dw $0000 - db WOMAN1, $14, $12, NORTH + db NPC_WOMAN1, $14, $12, NORTH dw $0000 - db CHAP1, $0e, $10, EAST + db NPC_CHAP1, $0e, $10, EAST dw $0000 - db LASS3, $10, $04, SOUTH + db NPC_LASS3, $10, $04, SOUTH dw $5fcb - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 RockClubNPCS: ; 7827 (4:13827) - db RYAN, $14, $0e, EAST + db NPC_RYAN, $14, $0e, EAST dw $0000 - db ANDREW, $06, $14, NORTH + db NPC_ANDREW, $06, $14, NORTH dw $0000 - db GENE, $0c, $06, NORTH + db NPC_GENE, $0c, $06, NORTH dw $0000 db $00 WaterClubEntranceNPCS: ; 783a (4:1383a) - db CLERK3, $06, $02, SOUTH + db NPC_CLERK3, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 WaterClubLobbyNPCS: ; 7853 (4:13853) - db GAL1, $06, $0e, SOUTH + db NPC_GAL1, $06, $0e, SOUTH dw $0000 - db LASS1, $10, $0a, SOUTH + db NPC_LASS1, $10, $0a, SOUTH dw $0000 - db IMAKUNI, $12, $02, NORTH + db NPC_IMAKUNI, $12, $02, NORTH dw Preload_ImakuniInWaterClubLobby - db MAN2, $04, $12, EAST + db NPC_MAN2, $04, $12, EAST dw Preload_Man2InWaterClubLobby - db PAPPY2, $16, $10, NORTH + db NPC_PAPPY2, $16, $10, NORTH dw $0000 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 WaterClubNPCS: ; 787e (4:1387e) - db SARA, $06, $12, EAST + db NPC_SARA, $06, $12, EAST dw $0000 - db AMANDA, $16, $14, WEST + db NPC_AMANDA, $16, $14, WEST dw $0000 - db JOSHUA, $16, $08, SOUTH + db NPC_JOSHUA, $16, $08, SOUTH dw $0000 - db AMY, $16, $04, SOUTH + db NPC_AMY, $16, $04, SOUTH dw Preload_Amy db $00 LightningClubEntranceNPCS: ; 7897 (4:13897) - db CLERK4, $06, $02, SOUTH + db NPC_CLERK4, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 LightningClubLobbyNPCS: ; 78b0 (4:138b0) - db CHAP2, $12, $10, WEST + db NPC_CHAP2, $12, $10, WEST dw $0000 - db IMAKUNI, $12, $02, NORTH + db NPC_IMAKUNI, $12, $02, NORTH dw $637b - db LASS4, $08, $0c, SOUTH + db NPC_LASS4, $08, $0c, SOUTH dw $0000 - db HOOD1, $14, $08, SOUTH + db NPC_HOOD1, $14, $08, SOUTH dw $0000 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 LightningClubNPCS: ; 78d5 (4:138d5) - db JENNIFER, $0e, $12, SOUTH + db NPC_JENNIFER, $0e, $12, SOUTH dw $0000 - db NICHOLAS, $06, $0a, SOUTH + db NPC_NICHOLAS, $06, $0a, SOUTH dw $0000 - db BRANDON, $16, $0c, NORTH + db NPC_BRANDON, $16, $0c, NORTH dw $0000 - db ISAAC, $0c, $04, NORTH + db NPC_ISAAC, $0c, $04, NORTH dw $6494 db $00 GrassClubEntranceNPCS: ; 78ee (4:138ee) - db CLERK5, $06, $02, SOUTH + db NPC_CLERK5, $06, $02, SOUTH dw $0000 - db MICHAEL, $0e, $08, SOUTH + db NPC_MICHAEL, $0e, $08, SOUTH dw $656a - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 GrassClubLobbyNPCS: ; 790d (4:1390d) - db BRITTANY, $0c, $0e, WEST + db NPC_BRITTANY, $0c, $0e, WEST dw $0000 - db LASS2, $12, $08, SOUTH + db NPC_LASS2, $12, $08, SOUTH dw $0000 - db GRANNY2, $04, $10, EAST + db NPC_GRANNY2, $04, $10, EAST dw $0000 - db GAL2, $14, $10, NORTH + db NPC_GAL2, $14, $10, NORTH dw $66dc - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 GrassClubNPCS: ; 7932 (4:13932) - db KRISTIN, $04, $0a, EAST + db NPC_KRISTIN, $04, $0a, EAST dw $0000 - db HEATHER, $0e, $10, SOUTH + db NPC_HEATHER, $0e, $10, SOUTH dw $0000 - db NIKKI, $0c, $04, SOUTH + db NPC_NIKKI, $0c, $04, SOUTH dw $6796 db $00 PsychicClubEntranceNPCS: ; 7945 (4:13945) - db CLERK6, $06, $02, SOUTH + db NPC_CLERK6, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 - db LAD3, $0e, $04, SOUTH + db NPC_LAD3, $0e, $04, SOUTH dw $0000 db $00 PsychicClubLobbyNPCS: ; 7964 (4:13964) - db ROBERT, $14, $08, NORTH + db NPC_ROBERT, $14, $08, NORTH dw $0000 - db PAPPY1, $04, $10, EAST + db NPC_PAPPY1, $04, $10, EAST dw $0000 - db RONALD1, $0c, $0a, EAST + db NPC_RONALD1, $0c, $0a, EAST dw $69f7 - db GAL3, $10, $0e, WEST + db NPC_GAL3, $10, $0e, WEST dw $0000 - db CHAP4, $18, $10, SOUTH + db NPC_CHAP4, $18, $10, SOUTH dw $0000 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 PsychicClubNPCS: ; 798f (4:1398f) - db DANIEL, $08, $08, NORTH + db NPC_DANIEL, $08, $08, NORTH dw $0000 - db STEPHANIE, $16, $0c, EAST + db NPC_STEPHANIE, $16, $0c, EAST dw $0000 - db MURRAY2, $02, $02, WEST + db NPC_MURRAY2, $02, $02, WEST dw $6ad0 - db MURRAY1, $0c, $06, SOUTH + db NPC_MURRAY1, $0c, $06, SOUTH dw $6ada db $00 ScienceClubEntranceNPCS: ; 79a8 (4:139a8) - db CLERK7, $06, $02, SOUTH + db NPC_CLERK7, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 ScienceClubLobbyNPCS: ; 79c1 (4:139c1) - db LAD1, $12, $12, NORTH + db NPC_LAD1, $12, $12, NORTH dw $0000 - db IMAKUNI, $12, $02, NORTH + db NPC_IMAKUNI, $12, $02, NORTH dw $6b65 - db MAN3, $04, $0e, WEST + db NPC_MAN3, $04, $0e, WEST dw $0000 - db SPECS2, $0c, $0e, WEST + db NPC_SPECS2, $0c, $0e, WEST dw $0000 - db SPECS3, $16, $08, SOUTH + db NPC_SPECS3, $16, $08, SOUTH dw $0000 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 ScienceClubNPCS: ; 79ec (4:139ec) - db JOSEPH, $08, $0a, SOUTH + db NPC_JOSEPH, $08, $0a, SOUTH dw $6cc4 - db DAVID, $14, $04, NORTH + db NPC_DAVID, $14, $04, NORTH dw $0000 - db ERIK, $06, $12, SOUTH + db NPC_ERIK, $06, $12, SOUTH dw $0000 - db RICK, $04, $04, NORTH + db NPC_RICK, $04, $04, NORTH dw $0000 db $00 FireClubEntranceNPCS: ; 7a05 (4:13a05) - db CLERK8, $06, $02, SOUTH + db NPC_CLERK8, $06, $02, SOUTH dw $0000 - db RONALD1, $08, $fe, SOUTH + db NPC_RONALD1, $08, $fe, SOUTH dw $685b - db RONALD2, $fe, $08, NORTH + db NPC_RONALD2, $fe, $08, NORTH dw $689a - db RONALD3, $fe, $08, NORTH + db NPC_RONALD3, $fe, $08, NORTH dw $6915 db $00 FireClubLobbyNPCS: ; 7a1e (4:13a1e) - db JESSICA, $0c, $0e, WEST + db NPC_JESSICA, $0c, $0e, WEST dw $6d8d - db LAD2, $12, $06, EAST + db NPC_LAD2, $12, $06, EAST dw $6e25 - db CHAP3, $06, $0a, NORTH + db NPC_CHAP3, $06, $0a, NORTH dw $0000 - db MANIA, $14, $12, NORTH + db NPC_MANIA, $14, $12, NORTH dw $0000 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 FireClubNPCS: ; 7a43 (4:13a43) - db JOHN, $0c, $12, SOUTH + db NPC_JOHN, $0c, $12, SOUTH dw $0000 - db ADAM, $08, $0e, SOUTH + db NPC_ADAM, $08, $0e, SOUTH dw $0000 - db JONATHAN, $12, $0a, SOUTH + db NPC_JONATHAN, $12, $0a, SOUTH dw $0000 - db KEN, $0e, $04, SOUTH + db NPC_KEN, $0e, $04, SOUTH dw $0000 db $00 ChallengeHallEntranceNPCS: ; 7a5c (4:13a5c) - db CLERK9, $06, $02, SOUTH + db NPC_CLERK9, $06, $02, SOUTH dw Preload_Clerk9 db $00 ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) - db PAPPY3, $06, $0e, EAST + db NPC_PAPPY3, $06, $0e, EAST dw Preload_ChallengeHallNPCs1 - db CHAMP, $10, $12, WEST + db NPC_CHAMP, $10, $12, WEST dw Preload_ChallengeHallNPCs1 - db HOOD2, $14, $08, SOUTH + db NPC_HOOD2, $14, $08, SOUTH dw Preload_ChallengeHallNPCs1 - db LASS5, $16, $10, WEST + db NPC_LASS5, $16, $10, WEST dw Preload_ChallengeHallNPCs1 - db GAL4, $0c, $0e, EAST + db NPC_GAL4, $0c, $0e, EAST dw Preload_ChallengeHallNPCs2 - db CHAP5, $10, $08, WEST + db NPC_CHAP5, $10, $08, WEST dw Preload_ChallengeHallNPCs2 - db RONALD1, $08, $0c, SOUTH + db NPC_RONALD1, $08, $0c, SOUTH dw Preload_ChallengeHallLobbyRonald1 - db CLERK10, $06, $04, SOUTH + db NPC_CLERK10, $06, $04, SOUTH dw $0000 - db GIFT_CENTER_CLERK, $0a, $04, SOUTH + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH dw Preload_GiftCenterClerk db $00 ChallengeHallNPCS: ; 7a9a (4:13a9a) - db CLERK12, $0a, $12, SOUTH + db NPC_CLERK12, $0a, $12, SOUTH dw Preload_ChallengeHallNPCs1 - db CLERK13, $14, $12, SOUTH + db NPC_CLERK13, $14, $12, SOUTH dw Preload_ChallengeHallNPCs1 - db GUIDE, $0e, $14, SOUTH + db NPC_GUIDE, $0e, $14, SOUTH dw Preload_Guide - db HOST, $0e, $04, SOUTH + db NPC_HOST, $0e, $04, SOUTH dw Preload_ChallengeHallNPCs1 db $ff, $12, $08, WEST ; pre-load function chooses NPC to load dw Preload_ChallengeHallOpponent db $00 PokemonDomeEntranceNPCS: ; 7ab9 (4:13ab9) - db RONALD1, $0e, $12, SOUTH + db NPC_RONALD1, $0e, $12, SOUTH dw $0000 db $00 PokemonDomeNPCS: ; 7ac0 (4:13ac0) - db COURTNEY, $12, $02, SOUTH + db NPC_COURTNEY, $12, $02, SOUTH dw $774b - db STEVE, $16, $02, SOUTH + db NPC_STEVE, $16, $02, SOUTH dw $778c - db JACK, $08, $02, SOUTH + db NPC_JACK, $08, $02, SOUTH dw $77a3 - db ROD, $0c, $02, SOUTH + db NPC_ROD, $0c, $02, SOUTH dw $77ba - db RONALD1, $1e, $00, SOUTH + db NPC_RONALD1, $1e, $00, SOUTH dw $77d6 db $00 HallOfHonorNPCS: ; 7adf (4:13adf) - db LEGEND_CARDS_TOP_LEFT, $0a, $08, SOUTH + db NPC_LEGEND_CARDS_TOP_LEFT, $0a, $08, SOUTH dw $0000 - db LEGEND_CARDS_TOP_RIGHT, $0c, $08, SOUTH + db NPC_LEGEND_CARDS_TOP_RIGHT, $0c, $08, SOUTH dw $0000 - db LEGEND_CARDS_LEFT_SPARK, $08, $0a, SOUTH + db NPC_LEGEND_CARDS_LEFT_SPARK, $08, $0a, SOUTH dw $0000 - db LEGEND_CARDS_BOTTOM_LEFT, $0a, $0a, SOUTH + db NPC_LEGEND_CARDS_BOTTOM_LEFT, $0a, $0a, SOUTH dw $0000 - db LEGEND_CARDS_BOTTOM_RIGHT, $0c, $0a, SOUTH + db NPC_LEGEND_CARDS_BOTTOM_RIGHT, $0c, $0a, SOUTH dw $0000 - db LEGEND_CARDS_RIGHT_SPARK, $0e, $0a, SOUTH + db NPC_LEGEND_CARDS_RIGHT_SPARK, $0e, $0a, SOUTH dw $0000 db $00 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 4e5ffe7..a8770fd 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -119,7 +119,7 @@ NPCDataTable: dw Ronald3Data dw Data_11f49 DrMasonData: - db DRMASON + db NPC_DRMASON db $02 db $00 db $26 @@ -131,7 +131,7 @@ DrMasonData: db $00 db $00 Ronald1Data: - db RONALD1 + db NPC_RONALD1 db $01 db $04 db $0e @@ -143,7 +143,7 @@ Ronald1Data: db $0f db $16 Ronald2Data: - db RONALD2 + db NPC_RONALD2 db $01 db $04 db $0e @@ -155,7 +155,7 @@ Ronald2Data: db $0f db $16 Ronald3Data: - db RONALD3 + db NPC_RONALD3 db $01 db $04 db $0e @@ -167,7 +167,7 @@ Ronald3Data: db $0f db $16 IshiharaData: - db ISHIHARA + db NPC_ISHIHARA db $03 db $04 db $22 @@ -179,7 +179,7 @@ IshiharaData: db $00 db $00 ImakuniData: - db IMAKUNI + db NPC_IMAKUNI db $04 db $00 db $0e @@ -191,7 +191,7 @@ ImakuniData: db $10 db $15 SamData: - db SAM + db NPC_SAM db $18 db $00 db $0e @@ -203,7 +203,7 @@ SamData: db $02 db $15 Tech1Data: - db TECH1 + db NPC_TECH1 db $18 db $00 db $0e @@ -215,7 +215,7 @@ Tech1Data: db $00 db $00 Tech2Data: - db TECH2 + db NPC_TECH2 db $18 db $00 db $0e @@ -227,7 +227,7 @@ Tech2Data: db $00 db $00 Tech3Data: - db TECH3 + db NPC_TECH3 db $18 db $00 db $0e @@ -239,7 +239,7 @@ Tech3Data: db $00 db $00 Tech4Data: - db TECH4 + db NPC_TECH4 db $18 db $00 db $0e @@ -251,7 +251,7 @@ Tech4Data: db $00 db $00 Tech5Data: - db TECH5 + db NPC_TECH5 db $18 db $00 db $0e @@ -263,7 +263,7 @@ Tech5Data: db $00 db $00 Tech6Data: - db TECH6 + db NPC_TECH6 db $18 db $00 db $0e @@ -275,7 +275,7 @@ Tech6Data: db $00 db $00 Clerk1Data: - db CLERK1 + db NPC_CLERK1 db $21 db $0a db $30 @@ -287,7 +287,7 @@ Clerk1Data: db $00 db $00 Clerk2Data: - db CLERK2 + db NPC_CLERK2 db $21 db $0a db $30 @@ -299,7 +299,7 @@ Clerk2Data: db $00 db $00 Clerk3Data: - db CLERK3 + db NPC_CLERK3 db $21 db $0a db $30 @@ -311,7 +311,7 @@ Clerk3Data: db $00 db $00 Clerk4Data: - db CLERK4 + db NPC_CLERK4 db $21 db $0a db $30 @@ -323,7 +323,7 @@ Clerk4Data: db $00 db $00 Clerk5Data: - db CLERK5 + db NPC_CLERK5 db $21 db $0a db $30 @@ -335,7 +335,7 @@ Clerk5Data: db $00 db $00 Clerk6Data: - db CLERK6 + db NPC_CLERK6 db $21 db $0a db $30 @@ -347,7 +347,7 @@ Clerk6Data: db $00 db $00 Clerk7Data: - db CLERK7 + db NPC_CLERK7 db $21 db $0a db $30 @@ -359,7 +359,7 @@ Clerk7Data: db $00 db $00 Clerk8Data: - db CLERK8 + db NPC_CLERK8 db $21 db $0a db $30 @@ -371,7 +371,7 @@ Clerk8Data: db $00 db $00 Clerk9Data: - db CLERK9 + db NPC_CLERK9 db $21 db $0a db $30 @@ -383,7 +383,7 @@ Clerk9Data: db $00 db $00 ChrisData: - db CHRIS + db NPC_CHRIS db $15 db $00 db $26 @@ -395,7 +395,7 @@ ChrisData: db $03 db $15 MichaelData: - db MICHAEL + db NPC_MICHAEL db $15 db $00 db $26 @@ -407,7 +407,7 @@ MichaelData: db $03 db $15 JessicaData: - db JESSICA + db NPC_JESSICA db $1f db $04 db $1a @@ -419,7 +419,7 @@ JessicaData: db $03 db $15 MitchData: - db MITCH + db NPC_MITCH db $0a db $00 db $0e @@ -431,7 +431,7 @@ MitchData: db $03 db $16 MatthewData: - db MATTHEW + db NPC_MATTHEW db $15 db $00 db $16 @@ -443,7 +443,7 @@ MatthewData: db $03 db $15 RyanData: - db RYAN + db NPC_RYAN db $11 db $00 db $26 @@ -455,7 +455,7 @@ RyanData: db $03 db $15 AndrewData: - db ANDREW + db NPC_ANDREW db $1a db $00 db $16 @@ -467,7 +467,7 @@ AndrewData: db $03 db $15 GeneData: - db GENE + db NPC_GENE db $0b db $04 db $1e @@ -479,7 +479,7 @@ GeneData: db $03 db $16 SaraData: - db SARA + db NPC_SARA db $20 db $00 db $0e @@ -491,7 +491,7 @@ SaraData: db $03 db $15 AmandaData: - db AMANDA + db NPC_AMANDA db $20 db $00 db $16 @@ -503,7 +503,7 @@ AmandaData: db $03 db $15 JoshuaData: - db JOSHUA + db NPC_JOSHUA db $16 db $00 db $26 @@ -515,7 +515,7 @@ JoshuaData: db $03 db $15 AmyData: - db AMY + db NPC_AMY db $08 db $08 db $2e @@ -527,7 +527,7 @@ AmyData: db $03 db $16 JenniferData: - db JENNIFER + db NPC_JENNIFER db $1c db $04 db $0e @@ -539,7 +539,7 @@ JenniferData: db $03 db $15 NicholasData: - db NICHOLAS + db NPC_NICHOLAS db $17 db $04 db $1e @@ -551,7 +551,7 @@ NicholasData: db $03 db $15 BrandonData: - db BRANDON + db NPC_BRANDON db $17 db $04 db $1e @@ -563,7 +563,7 @@ BrandonData: db $03 db $15 IsaacData: - db ISAAC + db NPC_ISAAC db $09 db $00 db $16 @@ -575,7 +575,7 @@ IsaacData: db $03 db $16 BrittanyData: - db BRITTANY + db NPC_BRITTANY db $1c db $04 db $0e @@ -587,7 +587,7 @@ BrittanyData: db $03 db $15 KristinData: - db KRISTIN + db NPC_KRISTIN db $1e db $00 db $1e @@ -599,7 +599,7 @@ KristinData: db $03 db $15 HeatherData: - db HEATHER + db NPC_HEATHER db $1d db $04 db $22 @@ -611,7 +611,7 @@ HeatherData: db $03 db $15 NikkiData: - db NIKKI + db NPC_NIKKI db $05 db $00 db $1a @@ -623,7 +623,7 @@ NikkiData: db $03 db $16 RobertData: - db ROBERT + db NPC_ROBERT db $11 db $04 db $16 @@ -635,7 +635,7 @@ RobertData: db $03 db $15 DanielData: - db DANIEL + db NPC_DANIEL db $12 db $04 db $1a @@ -647,7 +647,7 @@ DanielData: db $03 db $15 StephanieData: - db STEPHANIE + db NPC_STEPHANIE db $1c db $04 db $0e @@ -659,7 +659,7 @@ StephanieData: db $03 db $15 Murray1Data: - db MURRAY1 + db NPC_MURRAY1 db $0c db $00 db $12 @@ -671,7 +671,7 @@ Murray1Data: db $03 db $16 Murray2Data: - db MURRAY2 + db NPC_MURRAY2 db $0c db $03 db $15 @@ -683,7 +683,7 @@ Murray2Data: db $03 db $16 JosephData: - db JOSEPH + db NPC_JOSEPH db $18 db $00 db $0e @@ -695,7 +695,7 @@ JosephData: db $03 db $15 DavidData: - db DAVID + db NPC_DAVID db $18 db $00 db $0e @@ -707,7 +707,7 @@ DavidData: db $03 db $15 ErikData: - db ERIK + db NPC_ERIK db $18 db $00 db $0e @@ -719,7 +719,7 @@ ErikData: db $03 db $15 RickData: - db RICK + db NPC_RICK db $06 db $00 db $0e @@ -731,7 +731,7 @@ RickData: db $03 db $16 JohnData: - db JOHN + db NPC_JOHN db $12 db $04 db $1a @@ -743,7 +743,7 @@ JohnData: db $03 db $15 AdamData: - db ADAM + db NPC_ADAM db $13 db $00 db $22 @@ -755,7 +755,7 @@ AdamData: db $03 db $15 JonathanData: - db JONATHAN + db NPC_JONATHAN db $11 db $04 db $16 @@ -767,7 +767,7 @@ JonathanData: db $03 db $15 KenData: - db KEN + db NPC_KEN db $07 db $04 db $1e @@ -779,7 +779,7 @@ KenData: db $03 db $16 CourtneyData: - db COURTNEY + db NPC_COURTNEY db $0d db $00 db $12 @@ -791,7 +791,7 @@ CourtneyData: db $04 db $17 SteveData: - db STEVE + db NPC_STEVE db $0e db $00 db $2a @@ -803,7 +803,7 @@ SteveData: db $04 db $17 JackData: - db JACK + db NPC_JACK db $0f db $00 db $26 @@ -815,7 +815,7 @@ JackData: db $04 db $17 RodData: - db ROD + db NPC_ROD db $10 db $00 db $0e @@ -827,7 +827,7 @@ RodData: db $04 db $17 Clerk10Data: - db CLERK10 + db NPC_CLERK10 db $21 db $0a db $30 @@ -839,7 +839,7 @@ Clerk10Data: db $00 db $00 GiftCenterClerkData: - db GIFT_CENTER_CLERK + db NPC_GIFT_CENTER_CLERK db $21 db $0a db $30 @@ -851,7 +851,7 @@ GiftCenterClerkData: db $00 db $00 Man1Data: - db MAN1 + db NPC_MAN1 db $1a db $00 db $16 @@ -863,7 +863,7 @@ Man1Data: db $00 db $00 Woman1Data: - db WOMAN1 + db NPC_WOMAN1 db $23 db $04 db $1e @@ -875,7 +875,7 @@ Woman1Data: db $00 db $00 Chap1Data: - db CHAP1 + db NPC_CHAP1 db $19 db $00 db $1a @@ -887,7 +887,7 @@ Chap1Data: db $00 db $00 Gal1Data: - db GAL1 + db NPC_GAL1 db $22 db $00 db $16 @@ -899,7 +899,7 @@ Gal1Data: db $00 db $00 Lass1Data: - db LASS1 + db NPC_LASS1 db $1e db $00 db $1e @@ -911,7 +911,7 @@ Lass1Data: db $00 db $00 Chap2Data: - db CHAP2 + db NPC_CHAP2 db $19 db $00 db $1a @@ -923,7 +923,7 @@ Chap2Data: db $00 db $00 Lass2Data: - db LASS2 + db NPC_LASS2 db $1e db $00 db $1e @@ -935,7 +935,7 @@ Lass2Data: db $00 db $00 Pappy1Data: - db PAPPY1 + db NPC_PAPPY1 db $1b db $00 db $22 @@ -947,7 +947,7 @@ Pappy1Data: db $00 db $00 Lad1Data: - db LAD1 + db NPC_LAD1 db $12 db $04 db $1a @@ -959,7 +959,7 @@ Lad1Data: db $00 db $00 Lad2Data: - db LAD2 + db NPC_LAD2 db $11 db $04 db $16 @@ -971,7 +971,7 @@ Lad2Data: db $00 db $00 Chap3Data: - db CHAP3 + db NPC_CHAP3 db $19 db $00 db $1a @@ -983,7 +983,7 @@ Chap3Data: db $00 db $00 Clerk12Data: - db CLERK12 + db NPC_CLERK12 db $22 db $00 db $16 @@ -995,7 +995,7 @@ Clerk12Data: db $00 db $00 Clerk13Data: - db CLERK13 + db NPC_CLERK13 db $22 db $00 db $16 @@ -1007,7 +1007,7 @@ Clerk13Data: db $00 db $00 HostData: - db HOST + db NPC_HOST db $22 db $00 db $16 @@ -1019,7 +1019,7 @@ HostData: db $00 db $00 Specs1Data: - db SPECS1 + db NPC_SPECS1 db $13 db $00 db $22 @@ -1031,7 +1031,7 @@ Specs1Data: db $00 db $00 ButchData: - db BUTCH + db NPC_BUTCH db $14 db $00 db $16 @@ -1043,7 +1043,7 @@ ButchData: db $00 db $00 Granny1Data: - db GRANNY1 + db NPC_GRANNY1 db $24 db $00 db $16 @@ -1055,7 +1055,7 @@ Granny1Data: db $00 db $00 Lass3Data: - db LASS3 + db NPC_LASS3 db $1d db $04 db $22 @@ -1067,7 +1067,7 @@ Lass3Data: db $00 db $00 Man2Data: - db MAN2 + db NPC_MAN2 db $1a db $00 db $16 @@ -1079,7 +1079,7 @@ Man2Data: db $00 db $00 Pappy2Data: - db PAPPY2 + db NPC_PAPPY2 db $1b db $00 db $22 @@ -1091,7 +1091,7 @@ Pappy2Data: db $00 db $00 Lass4Data: - db LASS4 + db NPC_LASS4 db $1d db $04 db $22 @@ -1103,7 +1103,7 @@ Lass4Data: db $00 db $00 Hood1Data: - db HOOD1 + db NPC_HOOD1 db $17 db $04 db $1e @@ -1115,7 +1115,7 @@ Hood1Data: db $00 db $00 Granny2Data: - db GRANNY2 + db NPC_GRANNY2 db $24 db $00 db $16 @@ -1127,7 +1127,7 @@ Granny2Data: db $00 db $00 Gal2Data: - db GAL2 + db NPC_GAL2 db $22 db $00 db $16 @@ -1139,7 +1139,7 @@ Gal2Data: db $00 db $00 Lad3Data: - db LAD3 + db NPC_LAD3 db $12 db $04 db $1a @@ -1151,7 +1151,7 @@ Lad3Data: db $00 db $00 Gal3Data: - db GAL3 + db NPC_GAL3 db $22 db $00 db $16 @@ -1163,7 +1163,7 @@ Gal3Data: db $00 db $00 Chap4Data: - db CHAP4 + db NPC_CHAP4 db $19 db $00 db $1a @@ -1175,7 +1175,7 @@ Chap4Data: db $00 db $00 Man3Data: - db MAN3 + db NPC_MAN3 db $1a db $00 db $16 @@ -1187,7 +1187,7 @@ Man3Data: db $00 db $00 Specs2Data: - db SPECS2 + db NPC_SPECS2 db $18 db $00 db $0e @@ -1199,7 +1199,7 @@ Specs2Data: db $00 db $00 Specs3Data: - db SPECS3 + db NPC_SPECS3 db $13 db $00 db $22 @@ -1211,7 +1211,7 @@ Specs3Data: db $00 db $00 Woman2Data: - db WOMAN2 + db NPC_WOMAN2 db $23 db $04 db $1e @@ -1223,7 +1223,7 @@ Woman2Data: db $00 db $00 ManiaData: - db MANIA + db NPC_MANIA db $15 db $00 db $26 @@ -1235,7 +1235,7 @@ ManiaData: db $00 db $00 Pappy3Data: - db PAPPY3 + db NPC_PAPPY3 db $1b db $00 db $22 @@ -1247,7 +1247,7 @@ Pappy3Data: db $00 db $00 Gal4Data: - db GAL4 + db NPC_GAL4 db $22 db $00 db $16 @@ -1259,7 +1259,7 @@ Gal4Data: db $00 db $00 ChampData: - db CHAMP + db NPC_CHAMP db $15 db $00 db $26 @@ -1271,7 +1271,7 @@ ChampData: db $00 db $00 Hood2Data: - db HOOD2 + db NPC_HOOD2 db $17 db $04 db $1e @@ -1283,7 +1283,7 @@ Hood2Data: db $00 db $00 Lass5Data: - db LASS5 + db NPC_LASS5 db $1f db $04 db $1a @@ -1295,7 +1295,7 @@ Lass5Data: db $00 db $00 Chap5Data: - db CHAP5 + db NPC_CHAP5 db $19 db $00 db $1a @@ -1307,7 +1307,7 @@ Chap5Data: db $00 db $00 AaronData: - db AARON + db NPC_AARON db $18 db $00 db $0e @@ -1319,7 +1319,7 @@ AaronData: db $02 db $15 GuideData: - db GUIDE + db NPC_GUIDE db $1a db $00 db $16 @@ -1331,7 +1331,7 @@ GuideData: db $00 db $00 Tech7Data: - db TECH7 + db NPC_TECH7 db $18 db $00 db $0e @@ -1343,7 +1343,7 @@ Tech7Data: db $00 db $00 Tech8Data: - db TECH8 + db NPC_TECH8 db $18 db $00 db $0e @@ -1355,49 +1355,49 @@ Tech8Data: db $00 db $00 Data_11f18: - db $67 + db NPC_11F18 db $26 db $3a db $3a db $10 dw NoOverworldSequence ; Pointer to OWScript Data_11f1f: - db $68 + db NPC_LEGEND_CARDS_TOP_LEFT db $27 db $3b db $41 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f26: - db $69 + db NPC_LEGEND_CARDS_TOP_RIGHT db $27 db $3c db $42 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f2d: - db $6a + db NPC_LEGEND_CARDS_LEFT_SPARK db $27 db $3d db $43 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f34: - db $6b + db NPC_LEGEND_CARDS_BOTTOM_LEFT db $27 db $3e db $44 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f3b: - db $6c + db NPC_LEGEND_CARDS_BOTTOM_RIGHT db $27 db $3f db $45 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f42: - db $6d + db NPC_LEGEND_CARDS_RIGHT_SPARK db $27 db $40 db $46 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 31d8846..eef0d46 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -3164,8 +3164,8 @@ MasonLaboratoryAfterDuel: ; d53b (3:553b) ret .after_duel_table - db SAM - db SAM + db NPC_SAM + db NPC_SAM dw $568a dw $569f db $00 @@ -3174,7 +3174,7 @@ MasonLabLoadMap: ; d549 (3:5549) get_flag_value EVENT_FLAG_3E cp $03 ret nc - ld a, DRMASON + ld a, NPC_DRMASON ld [wTempNPC], a call FindLoadedNPC ld bc, OWSequence_EnterLabFirstTime @@ -3243,7 +3243,7 @@ OWSequence_EnterLabFirstTime: ; d753 (3:5753) tx Text05e3 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db SAM + db NPC_SAM dw OWSequence_d779 run_script OWScript_EndScriptLoop1 ret @@ -3255,7 +3255,7 @@ OWSequence_d779: ; d779 (03:5779) run_script OWScript_PrintTextString tx Text05e4 run_script OWScript_SetDialogName - db DRMASON + db NPC_DRMASON run_script OWScript_PrintTextString tx Text05e5 run_script OWScript_CloseTextBox @@ -3267,7 +3267,7 @@ OWSequence_d779: ; d779 (03:5779) db $03 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db DRMASON + db NPC_DRMASON dw OWSequence_d794 run_script OWScript_EndScriptLoop1 ret @@ -3402,7 +3402,7 @@ OWSequence_d794: ; d794 (3:5794) db $01 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db SAM + db NPC_SAM dw OWSequence_d827 run_script OWScript_EndScriptLoop1 ret @@ -3760,8 +3760,8 @@ FightingClubLobbyAfterDuel: ; dc68 (3:5c68) call FindEndOfBattleScript ret .after_duel_table - db IMAKUNI - db IMAKUNI + db NPC_IMAKUNI + db NPC_IMAKUNI dw OWSequence_BeatImakuni dw OWSequence_LostToImakuni db $00 @@ -4023,7 +4023,7 @@ WaterClubMovePlayer: ; e13f (3:613f) get_flag_value EVENT_JOSHUA_STATE cp $2 ret nc - ld a, JOSHUA + ld a, NPC_JOSHUA ld [wTempNPC], a ld bc, OWSequence_NotReadyToSeeAmy jp SetNextNPCAndOWSequence @@ -4034,23 +4034,23 @@ WaterClubAfterDuel: ;e157 (3:6157) ret .after_duel_table - db SARA - db SARA + db NPC_SARA + db NPC_SARA dw OWSequence_BeatSara dw OWSequence_LostToSara - db AMANDA - db AMANDA + db NPC_AMANDA + db NPC_AMANDA dw OWSequence_BeatAmanda dw OWSequence_LostToAmanda - db JOSHUA - db JOSHUA + db NPC_JOSHUA + db NPC_JOSHUA dw OWSequence_BeatJoshua dw OWSequence_LostToJoshua - db AMY - db AMY + db NPC_AMY + db NPC_AMY dw OWSequence_BeatAmy dw OWSequence_LostToAmy db $00 @@ -4339,7 +4339,7 @@ OWSequence_BeatJoshua: ; e26c (3:626c) db $00 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db AMY + db NPC_AMY dw OWSequence_MeetAmy run_script OWScript_EndScriptLoop1 ret @@ -4383,11 +4383,11 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) run_script OWScript_PrintTextString tx Text044b run_script OWScript_SetDialogName - db JOSHUA + db NPC_JOSHUA run_script OWScript_PrintTextString tx Text044c run_script OWScript_SetDialogName - db AMY + db NPC_AMY run_script OWScript_PrintTextString tx Text044d run_script OWScript_CloseTextBox @@ -4418,7 +4418,7 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) db NORTH db $01 run_script OWScript_MoveArbitraryNPC - db JOSHUA + db NPC_JOSHUA dw NPCMovement_e2ab run_script OWScript_PrintTextString tx Text044e @@ -4564,18 +4564,18 @@ FindEndOfBattleScript: ; e52c (3:652c) ; 0xe553 GrassClubEntranceAfterDuelTable: ; e553 (3:6553) - db MICHAEL - db MICHAEL + db NPC_MICHAEL + db NPC_MICHAEL dw $6597 dw $65ab - db RONALD2 - db RONALD2 + db NPC_RONALD2 + db NPC_RONALD2 dw OWSequence_BeatFirstRonaldFight dw OWSequence_LostToFirstRonaldFight - db RONALD3 - db RONALD3 + db NPC_RONALD3 + db NPC_RONALD3 dw OWSequence_BeatSecondRonaldFight dw OWSequence_LostToSecondRonaldFight db $00 @@ -4588,8 +4588,8 @@ GrassClubLobbyAfterDuel: ; e5c4 (3:65c4) ret .after_duel_table - db BRITTANY - db BRITTANY + db NPC_BRITTANY + db NPC_BRITTANY dw OWSequence_BeatBrittany dw OWSequence_LostToBrittany db $00 @@ -4840,13 +4840,13 @@ ClubEntranceAfterDuel: ; e7f6 (3:67f6) jp FindEndOfBattleScript .after_duel_table - db RONALD2 - db RONALD2 + db NPC_RONALD2 + db NPC_RONALD2 dw OWSequence_BeatFirstRonaldFight dw OWSequence_LostToFirstRonaldFight - db RONALD3 - db RONALD3 + db NPC_RONALD3 + db NPC_RONALD3 dw OWSequence_BeatSecondRonaldFight dw OWSequence_LostToSecondRonaldFight db $00 @@ -4860,7 +4860,7 @@ LoadClubEntrance: ; e809 (3:6809) ret TryFirstRonaldEncounter: ; e813 (3:6813) - ld a, RONALD1 + ld a, NPC_RONALD1 ld [wTempNPC], a call FindLoadedNPC ret c @@ -4868,7 +4868,7 @@ TryFirstRonaldEncounter: ; e813 (3:6813) jp SetNextNPCAndOWSequence TryFirstRonaldFight: ; e822 (3:6822) - ld a, RONALD2 + ld a, NPC_RONALD2 ld [$d3ab], a call FindLoadedNPC ret c @@ -4879,7 +4879,7 @@ TryFirstRonaldFight: ; e822 (3:6822) jp SetNextNPCAndOWSequence TrySecondRonaldFight: ; e837 (3:6837) - ld a, RONALD3 + ld a, NPC_RONALD3 ld [$d3ab], a call FindLoadedNPC ret c @@ -5484,7 +5484,7 @@ ChallengeHallAfterDuel: ; f239 (3:7239) ld c, [hl] inc hl ld b, [hl] - ld a, HOST + ld a, NPC_HOST ld [wTempNPC], a jp SetNextNPCAndOWSequence @@ -5496,7 +5496,7 @@ ChallengeHallLoadMap: ; f258 (3:7258) get_flag_value EVENT_FLAG_47 or a ret z - ld a, HOST + ld a, NPC_HOST ld [wTempNPC], a call FindLoadedNPC ld bc, OWSequence_f433 @@ -5877,7 +5877,7 @@ LostAtChallengeHall: ; f392 (3:7392) .ows_f3e2 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db CLERK12 + db NPC_CLERK12 dw OWSequence_f3e9 run_script OWScript_EndScriptLoop1 ret @@ -5939,7 +5939,7 @@ OWJump_f410: ; f410 (4:7410) run_script OWScript_PrintTextString tx Text0539 run_script OWScript_SetDialogName - db RONALD1 + db NPC_RONALD1 run_script OWScript_JumpIfFlagEqual db EVENT_FLAG_44 db $03 @@ -5953,7 +5953,7 @@ OWJump_f410: ; f410 (4:7410) tx Text053b .ows_f42e run_script OWScript_SetDialogName - db HOST + db NPC_HOST run_script OWScript_Jump dw LostAtChallengeHall.ows_f3ae @@ -6045,7 +6045,7 @@ WonAtChallengeHall; f441 (3:7441) tx Text0542 tx Text0543 run_script OWScript_SetDialogName - db HOST + db NPC_HOST run_script OWScript_CloseTextBox .ows_f4a1 run_script OWScript_PrintTextString @@ -6144,7 +6144,7 @@ OWJump_f4db: ; f4db (3:74db) tx Text054e tx Text054f run_script OWScript_SetDialogName - db HOST + db NPC_HOST run_script OWScript_CloseTextBox run_script OWScript_MoveWramNPC dw NPCMovement_f4c9 @@ -6209,7 +6209,7 @@ OWJump_f4db: ; f4db (3:74db) .ows_f552 run_script OWScript_CloseAdvancedTextBox run_script OWScript_SetNextNPCandOWSequence - db CLERK12 + db NPC_CLERK12 dw OWSequence_f3e9 run_script OWScript_EndScriptLoop1 ret @@ -6506,12 +6506,12 @@ Func_fcad: ; fcad (3:7cad) .ows_fcd5 run_script OWScript_MoveArbitraryNPC - db GIFT_CENTER_CLERK + db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce1 run_script OWScript_PrintTextString tx Text06d6 run_script OWScript_MoveArbitraryNPC - db GIFT_CENTER_CLERK + db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce3 run_script OWScript_QuitScriptFully diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 1eeffab..7be9960 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1591,7 +1591,7 @@ Func_13485: ; 13485 (4:7485) INCROM $134b1, $1372f INCLUDE "data/npc_map_data.asm" -INCLUDE "data/level_objects.asm" +INCLUDE "data/map_objects.asm" rept $119 db $ff diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 48d2565..6bad8c9 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -194,11 +194,11 @@ Func_1c485: ; 1c485 (7:4485) ret Func_1c4fa: ; 1c4fa (7:44fa) - cp RONALD1 + cp NPC_RONALD1 jr z, .asm_1c508 - cp RONALD2 + cp NPC_RONALD2 jr z, .asm_1c508 - cp RONALD3 + cp NPC_RONALD3 jr z, .asm_1c508 or a ret diff --git a/src/engine/home.asm b/src/engine/home.asm index 1ec17fb..094127e 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -11106,7 +11106,7 @@ HandleMoveModeAPress: ; 3a5e (0:3a5e) ret .noMatch pop hl - ld bc, LEVEL_OBJECT_SIZE - 1 + ld bc, MAP_OBJECT_SIZE - 1 add hl, bc pop bc jr .findAPressMatchLoop -- cgit v1.2.3 From d1a545a71e996fac826e2e0d299ffa0dd1ef491a Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Tue, 5 May 2020 21:37:55 -0400 Subject: Changed Unnamed NPC to TORCH --- src/constants/npc_constants.asm | 2 +- src/data/npcs.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index e51dfb9..113d790 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -179,7 +179,7 @@ const_value = const_value+1 ; DRMASON duplicate const NPC_GUIDE ; $64 const NPC_TECH7 ; $65 const NPC_TECH8 ; $66 - const NPC_11F18 ; $67 + const NPC_TORCH ; $67 const NPC_LEGEND_CARDS_TOP_LEFT ; $68 const NPC_LEGEND_CARDS_TOP_RIGHT ; $69 const NPC_LEGEND_CARDS_LEFT_SPARK ; $6a diff --git a/src/data/npcs.asm b/src/data/npcs.asm index a8770fd..1db22ef 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1355,7 +1355,7 @@ Tech8Data: db $00 db $00 Data_11f18: - db NPC_11F18 + db NPC_TORCH db $26 db $3a db $3a -- cgit v1.2.3 From a1f9dca9f563e6bc82c533f8e3a82edb954b8842 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Tue, 5 May 2020 22:45:50 -0400 Subject: changed wording when it comes to the legendary card sprite --- src/constants/npc_constants.asm | 12 ++++++------ src/constants/script_constants.asm | 2 +- src/data/npc_map_data.asm | 12 ++++++------ src/data/npcs.asm | 12 ++++++------ src/engine/bank03.asm | 22 +++++++++++----------- src/engine/home.asm | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index 113d790..eb7b75b 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -180,12 +180,12 @@ const_value = const_value+1 ; DRMASON duplicate const NPC_TECH7 ; $65 const NPC_TECH8 ; $66 const NPC_TORCH ; $67 - const NPC_LEGEND_CARDS_TOP_LEFT ; $68 - const NPC_LEGEND_CARDS_TOP_RIGHT ; $69 - const NPC_LEGEND_CARDS_LEFT_SPARK ; $6a - const NPC_LEGEND_CARDS_BOTTOM_LEFT ; $6b - const NPC_LEGEND_CARDS_BOTTOM_RIGHT ; $6c - const NPC_LEGEND_CARDS_RIGHT_SPARK ; $6d + const NPC_LEGENDARY_CARD_TOP_LEFT ; $68 + const NPC_LEGENDARY_CARD_TOP_RIGHT ; $69 + const NPC_LEGENDARY_CARD_LEFT_SPARK ; $6a + const NPC_LEGENDARY_CARD_BOTTOM_LEFT ; $6b + const NPC_LEGENDARY_CARD_BOTTOM_RIGHT ; $6c + const NPC_LEGENDARY_CARD_RIGHT_SPARK ; $6d const NPC_11F49 ; $6e const_value = const_value+1 ; NPC_11F49 duplicate const NPC_MURRAY2 ; $70 diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 05aaf57..9607ba0 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -33,7 +33,7 @@ const EVENT_FLAG_1F ; $1f const EVENT_FLAG_20 ; $20 const EVENT_FLAG_21 ; $21 - const EVENT_RECEIVED_LEGEND_CARDS ; $22 + const EVENT_RECEIVED_LEGENDARY_CARD ; $22 const EVENT_FLAG_23 ; $23 const EVENT_FLAG_24 ; $24 const EVENT_FLAG_25 ; $25 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm index 701171e..bc09d07 100644 --- a/src/data/npc_map_data.asm +++ b/src/data/npc_map_data.asm @@ -403,17 +403,17 @@ PokemonDomeNPCS: ; 7ac0 (4:13ac0) db $00 HallOfHonorNPCS: ; 7adf (4:13adf) - db NPC_LEGEND_CARDS_TOP_LEFT, $0a, $08, SOUTH + db NPC_LEGENDARY_CARD_TOP_LEFT, $0a, $08, SOUTH dw $0000 - db NPC_LEGEND_CARDS_TOP_RIGHT, $0c, $08, SOUTH + db NPC_LEGENDARY_CARD_TOP_RIGHT, $0c, $08, SOUTH dw $0000 - db NPC_LEGEND_CARDS_LEFT_SPARK, $08, $0a, SOUTH + db NPC_LEGENDARY_CARD_LEFT_SPARK, $08, $0a, SOUTH dw $0000 - db NPC_LEGEND_CARDS_BOTTOM_LEFT, $0a, $0a, SOUTH + db NPC_LEGENDARY_CARD_BOTTOM_LEFT, $0a, $0a, SOUTH dw $0000 - db NPC_LEGEND_CARDS_BOTTOM_RIGHT, $0c, $0a, SOUTH + db NPC_LEGENDARY_CARD_BOTTOM_RIGHT, $0c, $0a, SOUTH dw $0000 - db NPC_LEGEND_CARDS_RIGHT_SPARK, $0e, $0a, SOUTH + db NPC_LEGENDARY_CARD_RIGHT_SPARK, $0e, $0a, SOUTH dw $0000 db $00 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 1db22ef..0c184ea 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1362,42 +1362,42 @@ Data_11f18: db $10 dw NoOverworldSequence ; Pointer to OWScript Data_11f1f: - db NPC_LEGEND_CARDS_TOP_LEFT + db NPC_LEGENDARY_CARD_TOP_LEFT db $27 db $3b db $41 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f26: - db NPC_LEGEND_CARDS_TOP_RIGHT + db NPC_LEGENDARY_CARD_TOP_RIGHT db $27 db $3c db $42 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f2d: - db NPC_LEGEND_CARDS_LEFT_SPARK + db NPC_LEGENDARY_CARD_LEFT_SPARK db $27 db $3d db $43 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f34: - db NPC_LEGEND_CARDS_BOTTOM_LEFT + db NPC_LEGENDARY_CARD_BOTTOM_LEFT db $27 db $3e db $44 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f3b: - db NPC_LEGEND_CARDS_BOTTOM_RIGHT + db NPC_LEGENDARY_CARD_BOTTOM_RIGHT db $27 db $3f db $45 db $50 dw NoOverworldSequence ; Pointer to OWScript Data_11f42: - db NPC_LEGEND_CARDS_RIGHT_SPARK + db NPC_LEGENDARY_CARD_RIGHT_SPARK db $27 db $40 db $46 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index eef0d46..80722f7 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1366,7 +1366,7 @@ Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] cp $b jr z, .asm_ca68 - get_flag_value EVENT_RECEIVED_LEGEND_CARDS + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD or a jr nz, .asm_ca4a get_flag_value EVENT_FLAG_40 @@ -1626,7 +1626,7 @@ EventFlagMods: ; cb37 (3:4b37) flag_def $05, %00001111 ; EVENT_FLAG_1F flag_def $06, %11110000 ; EVENT_FLAG_20 flag_def $06, %00001100 ; EVENT_FLAG_21 - flag_def $06, %00000010 ; EVENT_RECEIVED_LEGEND_CARDS + flag_def $06, %00000010 ; EVENT_RECEIVED_LEGENDARY_CARD flag_def $06, %00000001 ; EVENT_FLAG_23 flag_def $07, %11000000 ; EVENT_FLAG_24 flag_def $07, %00100000 ; EVENT_FLAG_25 @@ -2683,11 +2683,11 @@ Func_d209: ; d209 (3:5209) ld a, [hl] call MaxOutEventFlag pop bc - ld hl, LegendCards + ld hl, LegendaryCards ld a, c jr asm_d1c6 -LegendCards: ; d234 (3:5234) +LegendaryCards: ; d234 (3:5234) db ZAPDOS3 tx Text03f0 db MOLTRES2 @@ -3187,7 +3187,7 @@ MasonLabCloseTextBox: ; d55e (3:555e) ; Lets you access the Challenge Machine if available MasonLabPressedA: ; d565 (3:5565) - get_flag_value EVENT_RECEIVED_LEGEND_CARDS + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD or a ret z ld hl, ChallengeMachineObjectTable @@ -3500,7 +3500,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) db EVENT_FLAG_39 dw .ows_db5a run_script OWScript_JumpIfFlagNonzero2 - db EVENT_RECEIVED_LEGEND_CARDS + db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_dc3e .ows_db5a run_script OWScript_JumpIfFlagNonzero2 @@ -3542,7 +3542,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) run_script OWScript_ZeroOutFlagValue db EVENT_FLAG_38 run_script OWScript_JumpIfFlagZero2 - db EVENT_RECEIVED_LEGEND_CARDS + db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_db8d run_script OWScript_MaxOutFlagValue db EVENT_FLAG_39 @@ -3717,7 +3717,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a) tx Text073e Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) - get_flag_value EVENT_RECEIVED_LEGEND_CARDS + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD cp $01 ccf ret @@ -5389,7 +5389,7 @@ OWSequence_Chap5: ; f0b0 (3:70b0) Preload_ChallengeHallLobbyRonald1: ; f0b4 (3:70b4) zero_flag_value2 EVENT_FLAG_58 - get_flag_value EVENT_RECEIVED_LEGEND_CARDS + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD or a jr nz, .asm_f0ff get_flag_value EVENT_FLAG_59 @@ -6310,10 +6310,10 @@ HallOfHonorLoadMap: ; fbdb (3:7bdb) OWSequence_fbf1: ; fbf1 (3:7bf1) start_script run_script OWScript_JumpIfFlagNonzero2 - db EVENT_RECEIVED_LEGEND_CARDS + db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_fc10 run_script OWScript_MaxOutFlagValue - db EVENT_RECEIVED_LEGEND_CARDS + db EVENT_RECEIVED_LEGENDARY_CARD run_script Func_ccdc tx Text05b8 run_script OWScript_GiveCard diff --git a/src/engine/home.asm b/src/engine/home.asm index 094127e..24cb61d 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -10800,7 +10800,7 @@ GameEvent_Credits: ; 3911 (0:3911) ret Func_3917: ; 3917 (0:3917) - ld a, EVENT_RECEIVED_LEGEND_CARDS + ld a, EVENT_RECEIVED_LEGENDARY_CARD farcall GetEventFlagValue call EnableSRAM ld [s0a00a], a -- cgit v1.2.3 From c4183f69cd8cb0fe1482cac8487efaf68160a411 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 7 May 2020 15:42:13 +0100 Subject: Deck AI macros and tidying --- src/constants/duel_constants.asm | 17 +- src/data/deck_ai_pointers.asm | 106 +-- src/engine/bank05.asm | 238 ++--- src/engine/bank08.asm | 15 +- src/engine/deck_ai.asm | 1956 ++++++++++++++++---------------------- src/wram.asm | 9 +- 6 files changed, 1028 insertions(+), 1313 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 47ca1ad..dd692d0 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -246,7 +246,11 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det ; used to determine which Trainer cards for AI ; to process in AIProcessHandTrainerCards. -; aside from a few exceptions, these go in chronological order. +; these go in chronological order, except for +; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. +; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. +; if Professor Oak is played, all other Trainer card phases +; are processed again except AI_TRAINER_CARD_PHASE_15. const_def 1 const AI_TRAINER_CARD_PHASE_01 ; $1 const AI_TRAINER_CARD_PHASE_02 ; $2 @@ -261,10 +265,17 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det const AI_TRAINER_CARD_PHASE_11 ; $b const AI_TRAINER_CARD_PHASE_12 ; $c const AI_TRAINER_CARD_PHASE_13 ; $d - const AI_TRAINER_CARD_PHASE_14 ; $e - const AI_TRAINER_CARD_PHASE_15 ; $f + const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack + const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak ; used by wAIBarrierFlagCounter to determine ; whether Player is running Mewtwo1 mill deck. ; flag set means true, flag not set means false. AI_FLAG_MEWTWO_MILL EQU 1 << 7 + +; defines the behaviour of HandleAIEnergyTrans, for determining +; whether to move energy cards from the Bench to the Arena or vice-versa +; and the number of energy cards needed for achieving that. +AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost +AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack +AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card diff --git a/src/data/deck_ai_pointers.asm b/src/data/deck_ai_pointers.asm index 13f148b..72cbfb0 100644 --- a/src/data/deck_ai_pointers.asm +++ b/src/data/deck_ai_pointers.asm @@ -1,55 +1,55 @@ PointerTable_14000: ; 14000 (05:4000) - dw PointerTable_147bd ; SAMS_PRACTICE_DECK - dw PointerTable_14668 ; PRACTICE_PLAYER_DECK - dw PointerTable_14668 ; SAMS_NORMAL_DECK - dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK - dw PointerTable_14668 ; CHARMANDER_EXTRA_DECK - dw PointerTable_14668 ; SQUIRTLE_AND_FRIENDS_DECK - dw PointerTable_14668 ; SQUIRTLE_EXTRA_DECK - dw PointerTable_14668 ; BULBASAUR_AND_FRIENDS_DECK - dw PointerTable_14668 ; BULBASAUR_EXTRA_DECK - dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK - dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK - dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK - dw PointerTable_149e8 ; LEGENDARY_MOLTRES_DECK - dw PointerTable_14b0f ; LEGENDARY_ZAPDOS_DECK - dw PointerTable_14c0b ; LEGENDARY_ARTICUNO_DECK - dw PointerTable_14d60 ; LEGENDARY_DRAGONITE_DECK - dw PointerTable_14e89 ; FIRST_STRIKE_DECK - dw PointerTable_14f0e ; ROCK_CRUSHER_DECK - dw PointerTable_14f8f ; GO_GO_RAIN_DANCE_DECK - dw PointerTable_15019 ; ZAPPING_SELFDESTRUCT_DECK - dw PointerTable_1509b ; FLOWER_POWER_DECK - dw PointerTable_15122 ; STRANGE_PSYSHOCK_DECK - dw PointerTable_151ad ; WONDERS_OF_SCIENCE_DECK - dw PointerTable_15232 ; FIRE_CHARGE_DECK - dw PointerTable_152bd ; IM_RONALD_DECK - dw PointerTable_1534b ; POWERFUL_RONALD_DECK - dw PointerTable_153e8 ; INVINCIBLE_RONALD_DECK - dw PointerTable_1546f ; LEGENDARY_RONALD_DECK - dw PointerTable_148dc ; MUSCLES_FOR_BRAINS_DECK - dw PointerTable_14668 ; HEATED_BATTLE_DECK - dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK - dw PointerTable_14668 ; EXCAVATION_DECK - dw PointerTable_14668 ; BLISTERING_POKEMON_DECK - dw PointerTable_14668 ; HARD_POKEMON_DECK - dw PointerTable_14668 ; WATERFRONT_POKEMON_DECK - dw PointerTable_14668 ; LONELY_FRIENDS_DECK - dw PointerTable_14668 ; SOUND_OF_THE_WAVES_DECK - dw PointerTable_14668 ; PIKACHU_DECK - dw PointerTable_14668 ; BOOM_BOOM_SELFDESTRUCT_DECK - dw PointerTable_14668 ; POWER_GENERATOR_DECK - dw PointerTable_14668 ; ETCETERA_DECK - dw PointerTable_14668 ; FLOWER_GARDEN_DECK - dw PointerTable_14668 ; KALEIDOSCOPE_DECK - dw PointerTable_14668 ; GHOST_DECK - dw PointerTable_14668 ; NAP_TIME_DECK - dw PointerTable_14668 ; STRANGE_POWER_DECK - dw PointerTable_14668 ; FLYIN_POKEMON_DECK - dw PointerTable_14668 ; LOVELY_NIDORAN_DECK - dw PointerTable_14668 ; POISON_DECK - dw PointerTable_14668 ; ANGER_DECK - dw PointerTable_14668 ; FLAMETHROWER_DECK - dw PointerTable_14668 ; RESHUFFLE_DECK - dw PointerTable_148dc ; IMAKUNI_DECK + dw AIActionTable_SamPractice ; SAMS_PRACTICE_DECK + dw AIActionTable_GeneralDecks ; PRACTICE_PLAYER_DECK + dw AIActionTable_GeneralDecks ; SAMS_NORMAL_DECK + dw AIActionTable_GeneralDecks ; CHARMANDER_AND_FRIENDS_DECK + dw AIActionTable_GeneralDecks ; CHARMANDER_EXTRA_DECK + dw AIActionTable_GeneralDecks ; SQUIRTLE_AND_FRIENDS_DECK + dw AIActionTable_GeneralDecks ; SQUIRTLE_EXTRA_DECK + dw AIActionTable_GeneralDecks ; BULBASAUR_AND_FRIENDS_DECK + dw AIActionTable_GeneralDecks ; BULBASAUR_EXTRA_DECK + dw AIActionTable_GeneralDecks ; LIGHTNING_AND_FIRE_DECK + dw AIActionTable_GeneralDecks ; WATER_AND_FIGHTING_DECK + dw AIActionTable_GeneralDecks ; GRASS_AND_PSYCHIC_DECK + dw AIActionTable_LegendaryMoltres ; LEGENDARY_MOLTRES_DECK + dw AIActionTable_LegendaryZapdos ; LEGENDARY_ZAPDOS_DECK + dw AIActionTable_LegendaryArticuno ; LEGENDARY_ARTICUNO_DECK + dw AIActionTable_LegendaryDragonite ; LEGENDARY_DRAGONITE_DECK + dw AIActionTable_FirstStrike ; FIRST_STRIKE_DECK + dw AIActionTable_RockCrusher ; ROCK_CRUSHER_DECK + dw AIActionTable_GoGoRainDance ; GO_GO_RAIN_DANCE_DECK + dw AIActionTable_ZappingSelfdestruct ; ZAPPING_SELFDESTRUCT_DECK + dw AIActionTable_FlowerPower ; FLOWER_POWER_DECK + dw AIActionTable_StrangePsyshock ; STRANGE_PSYSHOCK_DECK + dw AIActionTable_WondersOfScience ; WONDERS_OF_SCIENCE_DECK + dw AIActionTable_FireCharge ; FIRE_CHARGE_DECK + dw AIActionTable_ImRonald ; IM_RONALD_DECK + dw AIActionTable_PowerfulRonald ; POWERFUL_RONALD_DECK + dw AIActionTable_InvincibleRonald ; INVINCIBLE_RONALD_DECK + dw AIActionTable_LegendaryRonald ; LEGENDARY_RONALD_DECK + dw AIActionTable_GeneralNoRetreat ; MUSCLES_FOR_BRAINS_DECK + dw AIActionTable_GeneralDecks ; HEATED_BATTLE_DECK + dw AIActionTable_GeneralDecks ; LOVE_TO_BATTLE_DECK + dw AIActionTable_GeneralDecks ; EXCAVATION_DECK + dw AIActionTable_GeneralDecks ; BLISTERING_POKEMON_DECK + dw AIActionTable_GeneralDecks ; HARD_POKEMON_DECK + dw AIActionTable_GeneralDecks ; WATERFRONT_POKEMON_DECK + dw AIActionTable_GeneralDecks ; LONELY_FRIENDS_DECK + dw AIActionTable_GeneralDecks ; SOUND_OF_THE_WAVES_DECK + dw AIActionTable_GeneralDecks ; PIKACHU_DECK + dw AIActionTable_GeneralDecks ; BOOM_BOOM_SELFDESTRUCT_DECK + dw AIActionTable_GeneralDecks ; POWER_GENERATOR_DECK + dw AIActionTable_GeneralDecks ; ETCETERA_DECK + dw AIActionTable_GeneralDecks ; FLOWER_GARDEN_DECK + dw AIActionTable_GeneralDecks ; KALEIDOSCOPE_DECK + dw AIActionTable_GeneralDecks ; GHOST_DECK + dw AIActionTable_GeneralDecks ; NAP_TIME_DECK + dw AIActionTable_GeneralDecks ; STRANGE_POWER_DECK + dw AIActionTable_GeneralDecks ; FLYIN_POKEMON_DECK + dw AIActionTable_GeneralDecks ; LOVELY_NIDORAN_DECK + dw AIActionTable_GeneralDecks ; POISON_DECK + dw AIActionTable_GeneralDecks ; ANGER_DECK + dw AIActionTable_GeneralDecks ; FLAMETHROWER_DECK + dw AIActionTable_GeneralDecks ; RESHUFFLE_DECK + dw AIActionTable_GeneralNoRetreat ; IMAKUNI_DECK ; 1406a diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 7162983..8943187 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1,25 +1,25 @@ INCLUDE "data/deck_ai_pointers.asm" -PointerTable_1406a: ; 1406a (5:406a) +AIActionTable_Unreferenced: ; 1406a (5:406a) dw $406c - dw Func_14078 - dw Func_14078 - dw Func_1409e - dw $40a2 - dw $40a6 - dw $40aa - -Func_14078: ; 14078 (5:4078) + dw .do_turn + dw .do_turn + dw .star_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14078 (5:4078) call AIDecidePlayPokemonCard call AIDecideWhetherToRetreat - jr nc, .asm_14091 + jr nc, .try_attack call AIDecideBenchPokemonToSwitchTo - call AIChooseEnergyToDiscardForRetreatCost + call AITryToRetreat call AIDecideWhetherToRetreat - jr nc, .asm_14091 + jr nc, .try_attack call AIDecideBenchPokemonToSwitchTo - call AIChooseEnergyToDiscardForRetreatCost -.asm_14091 + call AITryToRetreat +.try_attack call AIProcessAndTryToPlayEnergy call AIProcessAndTryToUseAttack ret c @@ -28,8 +28,25 @@ Func_14078: ; 14078 (5:4078) ret ; 0x1409e -Func_1409e: ; 1409e (5:409e) - INCROM $1409e, $140ae +.star_duel ; 1409e (5:409e) + call AIPlayInitialBasicCards + ret +; 0x140a2 + +.forced_switch ; 140a2 (5:40a2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x140a6 + +.ko_switch ; 140a6 (5:40a6) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x140aa + +.take_prize ; 140aa (5:40aa) + call AIPickPrizeCards + ret +; 0x140ae ; returns carry if damage dealt from any of ; a card's moves KOs defending Pokémon @@ -290,7 +307,7 @@ PickRandomBenchPokemon: ; 141da (5:41da) ret ; 0x141e5 -_AIPickPrizeCards: ; 141e5 (5:41e5) +AIPickPrizeCards: ; 141e5 (5:41e5) ld a, [wNumberPrizeCardsToTake] ld b, a .loop @@ -578,7 +595,7 @@ ConvertColorToEnergyCardID: ; 1430f (5:430f) db FIGHTING_ENERGY db PSYCHIC_ENERGY db DOUBLE_COLORLESS_ENERGY - + Func_14323: ; 14323 (5:4323) INCROM $14323, $1433d @@ -1060,13 +1077,13 @@ EstimateDamage_FromDefendingPokemon: ; 1450b (5:450b) ; damage as the receiver CalculateDamage_FromDefendingPokemon: ; 1458c (5:458c) ld hl, wAIMinDamage - call _CalculateDamage_FromDefendingPokemon + call .CalculateDamage ld hl, wAIMaxDamage - call _CalculateDamage_FromDefendingPokemon + call .CalculateDamage ld hl, wDamage -; fallthrough + ; fallthrough -_CalculateDamage_FromDefendingPokemon: ; 1459b (5:459b) +.CalculateDamage ; 1459b (5:459b) ld e, [hl] ld d, $00 push hl @@ -1196,62 +1213,62 @@ AIProcessHandTrainerCards: ; 14663 (5:4663) farcall _AIProcessHandTrainerCards ret -; GENERAL DECK POINTER LIST - Not sure on all of these. -; This is an example of an AI pointer table, there's one for each AI type. -PointerTable_14668: ; 14668 (05:4668) - dw AIMainTurnLogic ; not used - dw AIMainTurnLogic ; general AI for battles - dw AIDuelStart ; basic pokemon placement / cheater shuffling on better AI - dw AIRetreatLogic ; deciding which Bench Pokemon to switch to - dw Func_14683 - dw AIPickPrizeCards +AIActionTable_GeneralDecks: ; 14668 (05:4668) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -AIMainTurnLogic: ; 14674 (5:4674) - call _AIMainTurnLogic +.do_turn ; 14674 (5:4674) + call AIMainTurnLogic ret -AIDuelStart: ; 14678 (5:4678) +.start_duel ; 14678 (5:4678) call InitAIDuelVars call AIPlayInitialBasicCards ret -AIRetreatLogic: ; 1467f (5:467f) +.forced_switch ; 1467f (5:467f) call AIDecideBenchPokemonToSwitchTo ret -Func_14683: ; 14683 (5:4683) +.ko_switch ; 14683 (5:4683) call AIDecideBenchPokemonToSwitchTo ret -AIPickPrizeCards: ; 14687 (5:4687) - call _AIPickPrizeCards +.take_prize: ; 14687 (5:4687) + call AIPickPrizeCards ret ; handle AI routines for a whole turn -_AIMainTurnLogic: ; 1468b (5:468b) +AIMainTurnLogic: ; 1468b (5:468b) +; initialize variables call InitAITurnVars - ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack - +; handle Pkmn Powers farcall HandleAIGoGoRainDanceEnergy farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c - + ret c ; return if turn ended farcall HandleAICowardice - +; process Trainer cards +; phase 2 through 4. ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_03 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c - + ret c ; return if turn ended +; process Trainer cards +; phase 5 through 12. ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_06 @@ -1260,39 +1277,38 @@ _AIMainTurnLogic: ; 1468b (5:468b) call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_08 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_12 call AIProcessHandTrainerCards - +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a - jr nz, .already_played_energy_1 + jr nz, .skip_energy_attach_1 call AIProcessAndTryToPlayEnergy - -.already_played_energy_1 +.skip_energy_attach_1 +; play Pokemon from hand again call AIDecidePlayPokemonCard - +; handle Pkmn Powers again farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c + ret c ; return if turn ended farcall HandleAIGoGoRainDanceEnergy - ld a, $0d ; attack + ld a, AI_ENERGY_TRANS_ATTACK farcall HandleAIEnergyTrans - +; process Trainer cards phases 13 and 15 ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards - +; if used Professor Oak, process new hand +; if not, then proceed to attack. ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK jr z, .try_attack - -; used Professor Oak ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 @@ -1302,8 +1318,7 @@ _AIMainTurnLogic: ; 1468b (5:468b) ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard - ret c - + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_06 @@ -1312,35 +1327,33 @@ _AIMainTurnLogic: ; 1468b (5:468b) call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_08 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_12 - call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .already_played_energy_2 + jr nz, .skip_energy_attach_2 call AIProcessAndTryToPlayEnergy -.already_played_energy_2 +.skip_energy_attach_2 call AIDecidePlayPokemonCard - farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c + ret c ; return if turn ended farcall HandleAIGoGoRainDanceEnergy - ld a, $0d ; attack + ld a, AI_ENERGY_TRANS_ATTACK farcall HandleAIEnergyTrans - ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards - + ; skip AI_TRAINER_CARD_PHASE_15 .try_attack - ld a, $0e + ld a, AI_ENERGY_TRANS_TO_BENCH farcall HandleAIEnergyTrans - +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack ret c ; return if AI attacked ld a, OPPACTION_FINISH_NO_ATTACK @@ -1348,11 +1361,11 @@ _AIMainTurnLogic: ; 1468b (5:468b) ret ; 0x14786 -; handles retreating -Func_14786: ; 14786 (5:4786) - ld a, [wce03] +; handles AI retreating logic +AIProcessRetreat: ; 14786 (5:4786) + ld a, [wAIRetreatedThisTurn] or a - ret nz + ret nz ; return, already retreated this turn call AIDecideWhetherToRetreat ret nc ; return if not retreating @@ -1360,74 +1373,88 @@ Func_14786: ; 14786 (5:4786) call AIDecideBenchPokemonToSwitchTo ret c ; return if no Bench Pokemon - ld [wcdd5], a +; store Play Area to retreat to and +; set wAIRetreatedThisTurn to true + ld [wAIPlayAreaCardToSwitch], a ld a, $01 - ld [wce03], a + ld [wAIRetreatedThisTurn], a +; if AI can use Switch from hand, use it instead... ld a, AI_TRAINER_CARD_PHASE_09 call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_SWITCH jr nz, .used_switch - ld a, [wcdd5] - call AIChooseEnergyToDiscardForRetreatCost +; ... else try retreating normally. + ld a, [wAIPlayAreaCardToSwitch] + call AITryToRetreat ret .used_switch +; if AI used switch, unset its AI flag ld a, [wPreviousAIFlags] and ~AI_FLAG_USED_SWITCH ; clear Switch flag ld [wPreviousAIFlags], a - ld a, $09 ; retreat + +; bug, this doesn't make sense being here, since at this point +; Switch Trainer card was already used to retreat the Pokemon. +; what the routine will do is just transfer Energy cards to +; the Arena Pokemon for the purpose of retreating, and +; then not actually retreat, resulting in unusual behaviour. +; this would only work placed right after the AI checks whether +; they have Switch card in hand to use and doesn't have one. +; (and probably that was the original intention.) + ld a, AI_ENERGY_TRANS_RETREAT ; retreat farcall HandleAIEnergyTrans ret ; 0x147bd -PointerTable_147bd: ; 147bd (05:47bd) - dw Func_147c9 - dw Func_147c9 - dw Func_147d6 - dw Func_147da - dw Func_147e7 - dw Func_147f4 +AIActionTable_SamPractice: ; 147bd (05:47bd) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_147c9: ; 147c9 (5:47c9) +.do_turn ; 147c9 (5:47c9) call IsAIPracticeScriptedTurn - jr nc, .scripted + jr nc, .scripted_1 ; not scripted, use AI main turn logic - call _AIMainTurnLogic + call AIMainTurnLogic ret -.scripted ; use scripted actions instead +.scripted_1 ; use scripted actions instead call AIPerformSciptedTurn ret ; 0x147d6 -Func_147d6: ; 147d6 (5:47d6) +.start_duel ; 147d6 (5:47d6) call Func_14801 ret ; 0x147da -Func_147da: ; 147da (5:47da) +.forced_switch ; 147da (5:47da) call IsAIPracticeScriptedTurn - jr nc, .scripted + jr nc, .scripted_2 call AIDecideBenchPokemonToSwitchTo ret -.scripted +.scripted_2 call PickRandomBenchPokemon ret ; 0x147e7 -Func_147e7: ; 147e7 (5:47e7) +.ko_switch: ; 147e7 (5:47e7) call IsAIPracticeScriptedTurn - jr nc, .scripted + jr nc, .scripted_3 call AIDecideBenchPokemonToSwitchTo ret -.scripted +.scripted_3 call GetPlayAreaLocationOfRaticateOrRattata ret ; 0x147f4 -Func_147f4: ; 147f4 (5:47f4) - call _AIPickPrizeCards +.take_prize: ; 147f4 (5:47f4) + call AIPickPrizeCards ret ; 0x147f8 @@ -1585,7 +1612,7 @@ AIPerformSciptedTurn: ; 1483a (5:483a) inc a ; PLAY_AREA_BENCH_2 .retreat - call AIChooseEnergyToDiscardForRetreatCost + call AITryToRetreat ret ; 0x148cc @@ -1732,7 +1759,7 @@ InitAITurnVars: ; 15649 (5:5649) ld [wPreviousAIFlags], a ld [wcddb], a ld [wcddc], a - ld [wce03], a + ld [wAIRetreatedThisTurn], a ; checks if the Player used an attack last turn ; and if it was the second attack of their card. @@ -2994,7 +3021,7 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) ; handle its effect to discard itself instead of retreating. ; input: ; - a = Play Area location (PLAY_AREA_*) of card to retreat to. -AIChooseEnergyToDiscardForRetreatCost: ; 15d4f (5:5d4f) +AITryToRetreat: ; 15d4f (5:5d4f) push af ld a, [wAIPlayEnergyCardForRetreat] or a @@ -7104,8 +7131,7 @@ CheckCardEvolutionInHandOrDeck: ; 17274 (5:7274) ; sets up the inital hand of boss deck. ; always draws at least 2 Basic Pokemon cards and 2 Energy cards. ; also sets up so that the next cards to be drawn have -; some minimum number of Basic Pokemon and Energy cards -; and avoids deck-specific list of cards. +; some minimum number of Basic Pokemon and Energy cards. SetUpBossStartingHandAndDeck: ; 172af (5:72af) ; shuffle all hand cards in deck ld a, DUELVARS_HAND @@ -7170,7 +7196,7 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af) cp 2 jr c, .shuffle_deck -; now check the following 6 cards. +; now check the following 6 cards (prize cards). ; re-shuffle deck if any of these cards is listed in wcda8. ld b, 6 .check_card_ids diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index 8d6d462..df8d7c5 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -6223,9 +6223,13 @@ AIDecide_PokemonTrader_Flamethrower: ; 22133 (8:6133) ; 0x2219b ; handle AI routines for Energy Trans. -; depending on input, AI can use Energy Trans to -; give Arena or Bench cards some Grass energy cards, -; depending whether it's for attack, retreat, etc. +; uses AI_ENERGY_TRANS_* constants as input: +; - AI_ENERGY_TRANS_RETREAT: transfers enough Grass Energy cards to +; Arena Pokemon for it to be able to pay the Retreat Cost; +; - AI_ENERGY_TRANS_ATTACK: transfers enough Grass Energy cards to +; Arena Pokemon for it to be able to use its second attack; +; - AI_ENERGY_TRANS_TO_BENCH: transfers all Grass Energy cards from +; Arena Pokemon to Bench in case Arena card will be KO'd. HandleAIEnergyTrans: ; 2219b (8:619b) ld [wce06], a @@ -6247,12 +6251,13 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ret c ; return if Muk found in any Play Area ld a, [wce06] - cp $09 + cp AI_ENERGY_TRANS_RETREAT jr z, .check_retreat - cp $0e + cp AI_ENERGY_TRANS_TO_BENCH jp z, .TransferEnergyToBench + ; AI_ENERGY_TRANS_ATTACK call .CheckEnoughGrassEnergyCardsForAttack ret nc jr .TransferEnergyToArena diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index c93b8ce..2a78848 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -3,76 +3,93 @@ ; a Pokemon to switch to, it looks up in this list and if ; a card ID matches, applies a retreat score bonus to this card. ; positive (negative) means more (less) likely to switch to this card. -airetreat: MACRO +ai_retreat: MACRO db \1 ; card ID db $80 + \2 ; retreat score (ranges between -128 and 127) ENDM ; AI card energy attach score bonus -; when the AI energy attachment run through the Play Area to choose +; when the AI energy attachment routine runs through the Play Area to choose ; a Pokemon to attach an energy card, it looks up in this list and if ; a card ID matches, skips this card if the maximum number of energy ; cards attached has been reached. If it hasn't been reached, additionally ; applies a positive (or negative) AI score to attach energy to this card. -aienergy: MACRO +ai_energy: MACRO db \1 ; card ID db \2 ; maximum number of attached cards db $80 + \3 ; energy score (ranges between -128 and 127) ENDM -PointerTable_148dc: ; 148dc (5:48dc) - dw Func_148e8 - dw Func_148e8 - dw Func_148ec - dw Func_148f3 - dw Func_148f7 - dw Func_148fb +; stores in WRAM pointer to data in argument +; e.g. store_list_pointer wSomeListPointer, SomeData +store_list_pointer: MACRO + ld hl, \1 + ld de, \2 + ld [hl], e + inc hl + ld [hl], d +ENDM -Func_148e8: ; 148e8 (5:48e8) - call Func_148ff +AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 148e8 (5:48e8) + call AIDoTurn_GeneralNoRetreat ret ; 0x148ec -Func_148ec: ; 148ec (5:48ec) +.start_duel ; 148ec (5:48ec) call InitAIDuelVars call AIPlayInitialBasicCards ret ; 0x148f3 -Func_148f3: ; 148f3 (5:48f3) +.forced_switch ; 148f3 (5:48f3) call AIDecideBenchPokemonToSwitchTo ret ; 0x148f7 -Func_148f7: ; 148f7 (5:48f7) +.ko_switch ; 148f7 (5:48f7) call AIDecideBenchPokemonToSwitchTo ret ; 0x148fb -Func_148fb: ; 148fb (5:48fb) - call _AIPickPrizeCards +.take_prize ; 148fb (5:48fb) + call AIPickPrizeCards ret ; 0x148ff -Func_148ff: ; 148ff (5:48ff) +AIDoTurn_GeneralNoRetreat: ; 148ff (5:48ff) +; initialize variables call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack +; handle Pkmn Powers farcall HandleAIGoGoRainDanceEnergy farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c + ret c ; return if turn ended farcall HandleAICowardice +; process Trainer cards +; phase 2 through 4. ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_03 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended +; process Trainer cards +; phase 5 through 12. ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_06 @@ -87,22 +104,28 @@ Func_148ff: ; 148ff (5:48ff) call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_12 call AIProcessHandTrainerCards +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_1495e + jr nz, .skip_energy_attach_1 call AIProcessAndTryToPlayEnergy -.asm_1495e +.skip_energy_attach_1 +; play Pokemon from hand again call AIDecidePlayPokemonCard +; handle Pkmn Powers again farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c + ret c ; return if turn ended farcall HandleAIGoGoRainDanceEnergy - ld a, $0d + ld a, AI_ENERGY_TRANS_ATTACK farcall HandleAIEnergyTrans +; process Trainer cards phases 13 and 15 ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards +; if used Professor Oak, process new hand +; if not, then proceed to attack. ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK jr z, .try_attack @@ -115,7 +138,7 @@ Func_148ff: ; 148ff (5:48ff) ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_06 @@ -132,40 +155,43 @@ Func_148ff: ; 148ff (5:48ff) call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_149c9 + jr nz, .skip_energy_attach_2 call AIProcessAndTryToPlayEnergy -.asm_149c9 +.skip_energy_attach_2 call AIDecidePlayPokemonCard farcall HandleAIDamageSwap farcall HandleAIPkmnPowers - ret c + ret c ; return if turn ended farcall HandleAIGoGoRainDanceEnergy ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards + ; skip AI_TRAINER_CARD_PHASE_15 .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack - ret c + ret c ; return if turn ended ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x149e8 -PointerTable_149e8: ; 149e8 (05:49e8) - dw Func_149f4 - dw Func_149f4 - dw Func_149f8 - dw Func_14a09 - dw Func_14a0d - dw Func_14a11 +AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_149f4: ; 149f4 (5:49f4) - call Func_14a81 +.do_turn ; 149f4 (5:49f4) + call AIDoTurn_LegendaryMoltres ret ; 0x149f8 -Func_149f8: ; 149f8 (5:49f8) +.start_duel ; 149f8 (5:49f8) call InitAIDuelVars - call Func_14a4a + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc ; Play Area set up was successful @@ -173,22 +199,22 @@ Func_149f8: ; 149f8 (5:49f8) ret ; 0x14a09 -Func_14a09: ; 14a09 (5:4a09) +.forced_switch ; 14a09 (5:4a09) call AIDecideBenchPokemonToSwitchTo ret ; 0x14a0d -Func_14a0d: ; 14a0d (5:4a0d) +.ko_switch ; 14a0d (5:4a0d) call AIDecideBenchPokemonToSwitchTo ret ; 0x14a11 -Func_14a11: ; 14a11 (5:4a11) - call _AIPickPrizeCards +.take_prize ; 14a11 (5:4a11) + call AIPickPrizeCards ret ; 0x14a15 -Data_14a15: ; 14a15 (5:4a15) +.list_arena ; 14a15 (5:4a15) db MAGMAR2 db GROWLITHE db VULPIX @@ -197,7 +223,7 @@ Data_14a15: ; 14a15 (5:4a15) db MOLTRES2 db $00 -Data_14a1c: ; 14a1c (5:4a1c) +.list_bench ; 14a1c (5:4a1c) db MOLTRES1 db VULPIX db GROWLITHE @@ -205,7 +231,7 @@ Data_14a1c: ; 14a1c (5:4a1c) db MAGMAR1 db $00 -Data_14a22: ; 14a22 (5:4a22) +.list_play_hand ; 14a22 (5:4a22) db MOLTRES2 db MOLTRES1 db VULPIX @@ -214,79 +240,51 @@ Data_14a22: ; 14a22 (5:4a22) db MAGMAR1 db $00 -Data_14a29: ; 14a29 (5:4a29) - airetreat GROWLITHE, -5 - airetreat VULPIX, -5 +.list_retreat ; 14a29 (5:4a29) + ai_retreat GROWLITHE, -5 + ai_retreat VULPIX, -5 db $00 -Data_14a2e: ; 14a2e (5:4a2e) - aienergy VULPIX, 3, +0 - aienergy NINETAILS2, 3, +1 - aienergy GROWLITHE, 3, +1 - aienergy ARCANINE2, 4, +1 - aienergy MAGMAR1, 4, -1 - aienergy MAGMAR2, 1, -1 - aienergy MOLTRES2, 3, +2 - aienergy MOLTRES1, 4, +2 +.list_energy ; 14a2e (5:4a2e) + ai_energy VULPIX, 3, +0 + ai_energy NINETAILS2, 3, +1 + ai_energy GROWLITHE, 3, +1 + ai_energy ARCANINE2, 4, +1 + ai_energy MAGMAR1, 4, -1 + ai_energy MAGMAR2, 1, -1 + ai_energy MOLTRES2, 3, +2 + ai_energy MOLTRES1, 4, +2 db $00 -Data_14a47: ; 14a47 (5:4a47) +.list_prize ; 14a47 (5:4a47) db ENERGY_REMOVAL db MOLTRES2 db $00 -Func_14a4a: ; 14a4a (5:4a4a) - ld hl, wcda8 - ld de, Data_14a47 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14a15 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14a1c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14a22 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb0 - ld de, Data_14a29 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdb2 - ld de, Data_14a2e - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14a4a (5:4a4a) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_play_hand + store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14a81 -Func_14a81: ; 14a81 (5:4a81) +AIDoTurn_LegendaryMoltres: ; 14a81 (5:4a81) +; initialize variables call InitAITurnVars farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack - +; process Trainer cards +; phase 2 through 4. ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards -; check if AI can play Moltres2 from hand -; if so, play it. +; check if AI can play Moltres2 +; from hand and if so, play it. ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable cp MAX_PLAY_AREA_POKEMON @@ -306,17 +304,18 @@ Func_14a81: ; 14a81 (5:4a81) bank1call AIMakeDecision .skip_moltres +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards - -; handle attaching energy from hand +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a jr nz, .skip_attach_energy @@ -343,8 +342,8 @@ Func_14a81: ; 14a81 (5:4a81) jr c, .skip_attach_energy .attach_normally +; play Energy card if possible call AIProcessAndTryToPlayEnergy - .skip_attach_energy ; try playing Pokemon cards from hand again call AIDecidePlayPokemonCard @@ -352,6 +351,8 @@ Func_14a81: ; 14a81 (5:4a81) call AIProcessHandTrainerCards .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack ret c ld a, OPPACTION_FINISH_NO_ATTACK @@ -359,22 +360,22 @@ Func_14a81: ; 14a81 (5:4a81) ret ; 0x14b0f -PointerTable_14b0f: ; 14b0f (05:4b0f) - dw Func_14b1b - dw Func_14b1b - dw Func_14b1f - dw Func_14b30 - dw Func_14b34 - dw Func_14b38 +AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14b1b: ; 14b1b (5:4b1b) - call Func_14b9a +.do_turn ; 14b1b (5:4b1b) + call AIDoTurn_LegendaryZapdos ret ; 0x14b1f -Func_14b1f: ; 14b1f (5:4b1f) +.start_duel ; 14b1f (5:4b1f) call InitAIDuelVars - call Func_14b6c + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -382,22 +383,22 @@ Func_14b1f: ; 14b1f (5:4b1f) ret ; 0x14b30 -Func_14b30: ; 14b30 (5:4b30) +.forced_switch ; 14b30 (5:4b30) call AIDecideBenchPokemonToSwitchTo ret ; 0x14b34 -Func_14b34: ; 14b34 (5:4b34) +.ko_switch ; 14b34 (5:4b34) call AIDecideBenchPokemonToSwitchTo ret ; 0x14b38 -Func_14b38: ; 14b38 (5:4b38) - call _AIPickPrizeCards +.take_prize ; 14b38 (5:4b38) + call AIPickPrizeCards ret ; 0x14b3c -Data_14b3c: ; 14b3c (5:4b3c) +.list_arena ; 14b3c (5:4b3c) db ELECTABUZZ2 db VOLTORB db EEVEE @@ -406,7 +407,7 @@ Data_14b3c: ; 14b3c (5:4b3c) db ZAPDOS3 db $00 -Data_14b43: ; 14b43 (5:4b43) +.list_bench ; 14b43 (5:4b43) db ZAPDOS2 db ZAPDOS1 db EEVEE @@ -414,138 +415,128 @@ Data_14b43: ; 14b43 (5:4b43) db ELECTABUZZ2 db $00 -Data_14b49: ; 14b49 (5:4b49) - airetreat EEVEE, -5 - airetreat VOLTORB, -5 - airetreat ELECTABUZZ2, -5 +.list_retreat ; 14b49 (5:4b49) + ai_retreat EEVEE, -5 + ai_retreat VOLTORB, -5 + ai_retreat ELECTABUZZ2, -5 db $00 -Data_14b50: ; 14b50 (5:4b50) - aienergy VOLTORB, 1, -1 - aienergy ELECTRODE1, 3, +0 - aienergy ELECTABUZZ2, 2, -1 - aienergy JOLTEON2, 3, +1 - aienergy ZAPDOS1, 4, +2 - aienergy ZAPDOS2, 4, +2 - aienergy ZAPDOS3, 3, +1 - aienergy EEVEE, 3, +0 +.list_energy ; 14b50 (5:4b50) + ai_energy VOLTORB, 1, -1 + ai_energy ELECTRODE1, 3, +0 + ai_energy ELECTABUZZ2, 2, -1 + ai_energy JOLTEON2, 3, +1 + ai_energy ZAPDOS1, 4, +2 + ai_energy ZAPDOS2, 4, +2 + ai_energy ZAPDOS3, 3, +1 + ai_energy EEVEE, 3, +0 db $00 -Data_14b69: ; 14b69 (5:4b69) +.list_prize ; 14b69 (5:4b69) db GAMBLER db ZAPDOS3 db $00 -Func_14b6c: ; 14b6c (5:4b6c) - ld hl, wcda8 - ld de, Data_14b69 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14b3c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14b43 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14b43 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14b50 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14b6c (5:4b6c) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14b9a -Func_14b9a: ; 14b9a (5:4b9a) +AIDoTurn_LegendaryZapdos: ; 14b9a (5:4b9a) +; initialize variables call InitAITurnVars farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards +; play Energy card if possible. ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_14bf8 - ld a, $bb + jr nz, .skip_energy_attach + +; if Arena card is Voltorb and there's Electrode1 in hand, +; or if it's Electabuzz, try attaching Energy card +; to the Arena card if it doesn't have any energy attached. +; Otherwise if Energy card is not needed, +; go through normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call GetCardIDFromDeckIndex - ld a, $6d + ld a, VOLTORB cp e - jr nz, .asm_14bdb - ld a, $6e + jr nz, .check_electabuzz + ld a, ELECTRODE1 call LookForCardIDInHandList_Bank5 - jr nc, .asm_14bf5 - jr .asm_14be0 -.asm_14bdb - ld a, $71 + jr nc, .attach_normally + jr .voltorb_or_electabuzz +.check_electabuzz + ld a, ELECTABUZZ2 cp e - jr nz, .asm_14bf5 -.asm_14be0 + jr nz, .attach_normally + +.voltorb_or_electabuzz call CreateEnergyCardListFromHand - jr c, .asm_14bf8 - ld e, $00 + jr c, .skip_energy_attach + ld e, PLAY_AREA_ARENA call CountNumberOfEnergyCardsAttached or a - jr nz, .asm_14bf5 - xor a + jr nz, .attach_normally + xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a call AITryToPlayEnergyCard - jr c, .asm_14bf8 -.asm_14bf5 + jr c, .skip_energy_attach + +.attach_normally call AIProcessAndTryToPlayEnergy -.asm_14bf8 + +.skip_energy_attach +; play Pokemon from hand again call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack - ret c + ret c ; return if turn ended ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x14c0b -PointerTable_14c0b: ; 14c0b (5:4c0b) - dw Func_14c17 - dw Func_14c17 - dw Func_14c1b - dw Func_14c2c - dw Func_14c30 - dw Func_14c34 +AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14c17: ; 14c17 (5:4c17) - call Func_14cf7 +.do_turn ; 14c17 (5:4c17) + call AIDoTurn_LegendaryArticuno ret ; 0x14c1b -Func_14c1b: ; 14c1b (5:4c1b) +.start_duel ; 14c1b (5:4c1b) call InitAIDuelVars - call Func_14c63 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -553,22 +544,22 @@ Func_14c1b: ; 14c1b (5:4c1b) ret ; 0x14c2c -Func_14c2c: ; 14c2c (5:4c2c) +.forced_switch ; 14c2c (5:4c2c) call AIDecideBenchPokemonToSwitchTo ret ; 0x14c30 -Func_14c30: ; 14c30 (5:4c30) +.ko_switch ; 14c30 (5:4c30) call AIDecideBenchPokemonToSwitchTo ret ; 0x14c34 -Func_14c34: ; 14c34 (5:4c34) - call _AIPickPrizeCards +.take_prize ; 14c34 (5:4c34) + call AIPickPrizeCards ret ; 0x14c38 -Data_14c38: ; 14c38 (5:4c38) +.list_arena ; 14c38 (5:4c38) db CHANSEY db LAPRAS db DITTO @@ -577,7 +568,7 @@ Data_14c38: ; 14c38 (5:4c38) db ARTICUNO2 db $00 -Data_14c3f: ; 14c3f (5:4c3f) +.list_bench ; 14c3f (5:4c3f) db ARTICUNO1 db SEEL db LAPRAS @@ -585,59 +576,33 @@ Data_14c3f: ; 14c3f (5:4c3f) db DITTO db $00 -Data_14c45: ; 14c45 (5:4c45) - airetreat SEEL, -3 - airetreat DITTO, -3 +.list_retreat ; 14c45 (5:4c45) + ai_retreat SEEL, -3 + ai_retreat DITTO, -3 db $00 -Data_14c4a: ; 14c4a (5:4c4a) - aienergy SEEL, 3, +1 - aienergy DEWGONG, 4, +0 - aienergy LAPRAS, 3, +0 - aienergy ARTICUNO1, 4, +1 - aienergy ARTICUNO2, 3, +0 - aienergy CHANSEY, 0, -8 - aienergy DITTO, 3, +0 +.list_energy ; 14c4a (5:4c4a) + ai_energy SEEL, 3, +1 + ai_energy DEWGONG, 4, +0 + ai_energy LAPRAS, 3, +0 + ai_energy ARTICUNO1, 4, +1 + ai_energy ARTICUNO2, 3, +0 + ai_energy CHANSEY, 0, -8 + ai_energy DITTO, 3, +0 db $00 -Data_14c60: ; 14c60 (5:4c60) +.list_prize ; 14c60 (5:4c60) db GAMBLER db ARTICUNO2 db $00 -Func_14c63: ; 14c63 (5:4c63) - ld hl, wcda8 - ld de, Data_14c60 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14c38 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14c3f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14c3f - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14c4a - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14c63 (5:4c63) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14c91 @@ -716,29 +681,36 @@ ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) ret ; 0x14cf7 -Func_14cf7: ; 14cf7 (5:4cf7) +AIDoTurn_LegendaryArticuno: ; 14cf7 (5:4cf7) +; initialize variables call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c - call Func_14786 + ret c ; return if turn ended + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_14d20 + jr nz, .skip_energy_attach_1 call AIProcessAndTryToPlayEnergy -.asm_14d20 +.skip_energy_attach_1 +; play Pokemon from hand again call AIDecidePlayPokemonCard +; process Trainer cards phases 13 and 15 ld a, AI_TRAINER_CARD_PHASE_13 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards +; if used Professor Oak, process new hand ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK jr z, .try_attack @@ -747,40 +719,42 @@ Func_14cf7: ; 14cf7 (5:4cf7) ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard - ret c - call Func_14786 + ret c ; return if turn ended + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_14d53 + jr nz, .skip_energy_attach_2 call AIProcessAndTryToPlayEnergy -.asm_14d53 +.skip_energy_attach_2 call AIDecidePlayPokemonCard .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack - ret c + ret c ; return if turn ended ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x14d60 -PointerTable_14d60: ; 14d60 (05:4d60) - dw Func_14d6c - dw Func_14d6c - dw Func_14d70 - dw Func_14d81 - dw Func_14d85 - dw Func_14d89 +AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14d6c: ; 14d6c (5:4d6c) - call Func_14def +.do_turn ; 14d6c (5:4d6c) + call AIDoTurn_LegendaryDragonite ret ; 0x14d70 -Func_14d70: ; 14d70 (5:4d70) +.start_duel ; 14d70 (5:4d70) call InitAIDuelVars - call Func_14dc1 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -788,22 +762,22 @@ Func_14d70: ; 14d70 (5:4d70) ret ; 0x14d81 -Func_14d81: ; 14d81 (5:4d81) +.forced_switch ; 14d81 (5:4d81) call AIDecideBenchPokemonToSwitchTo ret ; 0x14d85 -Func_14d85: ; 14d85 (5:4d85) +.ko_switch ; 14d85 (5:4d85) call AIDecideBenchPokemonToSwitchTo ret ; 0x14d89 -Func_14d89: ; 14d89 (5:4d89) - call _AIPickPrizeCards +.take_prize ; 14d89 (5:4d89) + call AIPickPrizeCards ret ; 0x14d8d -Data_14d8d: ; 14d8d (5:4d8d) +.list_arena ; 14d8d (5:4d8d) db KANGASKHAN db LAPRAS db CHARMANDER @@ -811,7 +785,7 @@ Data_14d8d: ; 14d8d (5:4d8d) db MAGIKARP db $00 -Data_14d93: ; 14d93 (5:4d93) +.list_bench ; 14d93 (5:4d93) db CHARMANDER db MAGIKARP db DRATINI @@ -819,108 +793,94 @@ Data_14d93: ; 14d93 (5:4d93) db KANGASKHAN db $00 -Data_14d99: ; 14d99 (5:4d99) - airetreat CHARMANDER, -1 - airetreat MAGIKARP, -5 +.list_retreat ; 14d99 (5:4d99) + ai_retreat CHARMANDER, -1 + ai_retreat MAGIKARP, -5 db $00 -Data_14d9e: ; 14d9e (5:4d9e) - aienergy CHARMANDER, 3, +1 - aienergy CHARMELEON, 4, +1 - aienergy CHARIZARD, 5, +0 - aienergy MAGIKARP, 3, +1 - aienergy GYARADOS, 4, -1 - aienergy DRATINI, 2, +0 - aienergy DRAGONAIR, 4, +0 - aienergy DRAGONITE1, 3, -1 - aienergy KANGASKHAN, 2, -2 - aienergy LAPRAS, 3, +0 +.list_energy ; 14d9e (5:4d9e) + ai_energy CHARMANDER, 3, +1 + ai_energy CHARMELEON, 4, +1 + ai_energy CHARIZARD, 5, +0 + ai_energy MAGIKARP, 3, +1 + ai_energy GYARADOS, 4, -1 + ai_energy DRATINI, 2, +0 + ai_energy DRAGONAIR, 4, +0 + ai_energy DRAGONITE1, 3, -1 + ai_energy KANGASKHAN, 2, -2 + ai_energy LAPRAS, 3, +0 db $00 -Data_14dbd: ; 14dbd (5:4dbd) +.list_prize ; 14dbd (5:4dbd) db GAMBLER db DRAGONITE1 db KANGASKHAN db $00 -Func_14dc1: ; 14dc1 (5:4dc1) - ld hl, wcda8 - ld de, Data_14dbd - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14d8d - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14d93 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14d93 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14d9e - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14dc1 (5:4dc1) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14def -Func_14def: ; 14def (5:4def) +AIDoTurn_LegendaryDragonite: ; 14def (5:4def) +; initialize variables call InitAITurnVars ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards farcall HandleAIAntiMewtwoDeckStrategy jp nc, .try_attack +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_14e44 - ld a, $bb + jr nz, .skip_energy_attach_1 + +; if Arena card is Kangaskhan and doens't +; have Energy cards attached, try attaching from hand. +; otherwise run normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call GetCardIDFromDeckIndex - ld a, $b9 + ld a, KANGASKHAN cp e - jr nz, .asm_14e41 + jr nz, .attach_normally call CreateEnergyCardListFromHand - jr c, .asm_14e44 - ld e, $00 + jr c, .skip_energy_attach_1 + ld e, PLAY_AREA_ARENA call CountNumberOfEnergyCardsAttached or a - jr nz, .asm_14e41 + jr nz, .attach_normally xor a ldh [hTempPlayAreaLocation_ff9d], a call AITryToPlayEnergyCard - jr c, .asm_14e44 -.asm_14e41 + jr c, .skip_energy_attach_1 +.attach_normally call AIProcessAndTryToPlayEnergy -.asm_14e44 + +.skip_energy_attach_1 +; play Pokemon from hand again call AIDecidePlayPokemonCard ld a, AI_TRAINER_CARD_PHASE_15 call AIProcessHandTrainerCards +; if used Professor Oak, process new hand +; if not, then proceed to attack. ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK jr z, .try_attack @@ -929,44 +889,46 @@ Func_14def: ; 14def (5:4def) ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_11 call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_14e7c + jr nz, .skip_energy_attach_2 call AIProcessAndTryToPlayEnergy -.asm_14e7c +.skip_energy_attach_2 call AIDecidePlayPokemonCard .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack - ret c + ret c ; return if turn ended ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret ; 0x14e89 -PointerTable_14e89: ; 14e89 (5:4e89) - dw Func_14e95 - dw Func_14e95 - dw Func_14e99 - dw Func_14eaa - dw Func_14eae - dw Func_14eb2 +AIActionTable_FirstStrike: ; 14e89 (5:4e89) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14e95: ; 14e95 (5:4e95) - call _AIMainTurnLogic +.do_turn ; 14e95 (5:4e95) + call AIMainTurnLogic ret ; 0x14e99 -Func_14e99: ; 14e99 (5:4e99) +.start_duel ; 14e99 (5:4e99) call InitAIDuelVars - call Func_14ee0 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -974,108 +936,82 @@ Func_14e99: ; 14e99 (5:4e99) ret ; 0x14eaa -Func_14eaa: ; 14eaa (5:4eaa) +.forced_switch ; 14eaa (5:4eaa) call AIDecideBenchPokemonToSwitchTo ret ; 0x14eae -Func_14eae: ; 14eae (5:4eae) +.ko_switch ; 14eae (5:4eae) call AIDecideBenchPokemonToSwitchTo ret ; 0x14eb2 -Func_14eb2: ; 14eb2 (5:4eb2) - call _AIPickPrizeCards +.take_prize ; 14eb2 (5:4eb2) + call AIPickPrizeCards ret ; 0x14eb6 -Data_14eb6: ; 14eb6 (5:1eb6) +.list_arena ; 14eb6 (5:1eb6) db HITMONCHAN db MACHOP db HITMONLEE db MANKEY db $00 -Data_14ebb: ; 14ebb (5:1ebb) +.list_bench ; 14ebb (5:1ebb) db MACHOP db HITMONLEE db HITMONCHAN db MANKEY db $00 -Data_14ec0: ; 14ec0 (5:1ec0) - airetreat MACHOP, - 1 - airetreat MACHOKE, - 1 - airetreat MANKEY, - 2 +.list_retreat ; 14ec0 (5:1ec0) + ai_retreat MACHOP, - 1 + ai_retreat MACHOKE, - 1 + ai_retreat MANKEY, - 2 db $00 -Data_14ec7: ; 14ec7 (5:1ec7) - aienergy MACHOP, 3, +0 - aienergy MACHOKE, 4, +0 - aienergy MACHAMP, 4, -1 - aienergy HITMONCHAN, 3, +0 - aienergy HITMONLEE, 3, +0 - aienergy MANKEY, 2, -1 - aienergy PRIMEAPE, 3, -1 +.list_energy ; 14ec7 (5:1ec7) + ai_energy MACHOP, 3, +0 + ai_energy MACHOKE, 4, +0 + ai_energy MACHAMP, 4, -1 + ai_energy HITMONCHAN, 3, +0 + ai_energy HITMONLEE, 3, +0 + ai_energy MANKEY, 2, -1 + ai_energy PRIMEAPE, 3, -1 db $00 -Data_14edd: ; 14edd (5:1edd) +.list_prize ; 14edd (5:1edd) db HITMONLEE db HITMONCHAN db $00 -Func_14ee0: ; 14ee0 (5:4ee0) - ld hl, wcda8 - ld de, Data_14edd - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14eb6 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14ebb - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14ebb - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14ec7 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14ee0 (5:4ee0) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14f0e -PointerTable_14f0e: ; 14f0e (5:4f0e) - dw Func_14f1a - dw Func_14f1a - dw Func_14f1e - dw Func_14f2f - dw Func_14f33 - dw Func_14f37 +AIActionTable_RockCrusher: ; 14f0e (5:4f0e) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14f1a: ; 14f1a (5:4f1a) - call _AIMainTurnLogic +.do_turn ; 14f1a (5:4f1a) + call AIMainTurnLogic ret ; 0x14f1e -Func_14f1e: ; 14f1e (5:4f1e) +.start_duel ; 14f1e (5:4f1e) call InitAIDuelVars - call Func_14f61 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1083,106 +1019,80 @@ Func_14f1e: ; 14f1e (5:4f1e) ret ; 0x14f2f -Func_14f2f: ; 14f2f (5:4f2f) +.forced_switch ; 14f2f (5:4f2f) call AIDecideBenchPokemonToSwitchTo ret ; 0x14f33 -Func_14f33: ; 14f33 (5:4f33) +.ko_switch ; 14f33 (5:4f33) call AIDecideBenchPokemonToSwitchTo ret ; 0x14f37 -Func_14f37: ; 14f37 (5:4f37) - call _AIPickPrizeCards +.take_prize ; 14f37 (5:4f37) + call AIPickPrizeCards ret ; 0x14f3b -Data_14f3b: ; 14f3b (5:4f3b) +.list_arena ; 14f3b (5:4f3b) db RHYHORN db ONIX db GEODUDE db DIGLETT db $00 -Data_14f40: ; 14f40 (5:4f40) +.list_bench ; 14f40 (5:4f40) db DIGLETT db GEODUDE db RHYHORN db ONIX db $00 -Data_14f45: ; 14f45 (5:4f45) - airetreat DIGLETT, -1 +.list_retreat ; 14f45 (5:4f45) + ai_retreat DIGLETT, -1 db $00 -Data_14f48: ; 14f48 (5:4f48) - aienergy DIGLETT, 3, +1 - aienergy DUGTRIO, 4, +0 - aienergy GEODUDE, 2, +1 - aienergy GRAVELER, 3, +0 - aienergy GOLEM, 4, +0 - aienergy ONIX, 2, -1 - aienergy RHYHORN, 3, +0 +.list_energy ; 14f48 (5:4f48) + ai_energy DIGLETT, 3, +1 + ai_energy DUGTRIO, 4, +0 + ai_energy GEODUDE, 2, +1 + ai_energy GRAVELER, 3, +0 + ai_energy GOLEM, 4, +0 + ai_energy ONIX, 2, -1 + ai_energy RHYHORN, 3, +0 db $00 -Data_14f5e: ; 14f5e (5:4f5e) +.list_prize ; 14f5e (5:4f5e) db ENERGY_REMOVAL db RHYHORN db $00 -Func_14f61: ; 14f61 (5:4f61) - ld hl, wcda8 - ld de, Data_14f5e - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14f3b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14f40 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14f40 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14f48 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14f61 (5:4f61) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x14f8f -PointerTable_14f8f: ; 14f8f (5:4f8f) - dw Func_14f9b - dw Func_14f9b - dw Func_14f9f - dw Func_14fb0 - dw Func_14fb4 - dw Func_14fb8 +AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_14f9b: ; 14f9b (5:4f9b) - call _AIMainTurnLogic +.do_turn ; 14f9b (5:4f9b) + call AIMainTurnLogic ret ; 0x14f9f -Func_14f9f: ; 14f9f (5:4f9f) +.start_duel ; 14f9f (5:4f9f) call InitAIDuelVars - call Func_14feb + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1190,111 +1100,85 @@ Func_14f9f: ; 14f9f (5:4f9f) ret ; 0x14fb0 -Func_14fb0: ; 14fb0 (5:4fb0) +.forced_switch ; 14fb0 (5:4fb0) call AIDecideBenchPokemonToSwitchTo ret ; 0x14fb4 -Func_14fb4: ; 14fb4 (5:4fb4) +.ko_switch ; 14fb4 (5:4fb4) call AIDecideBenchPokemonToSwitchTo ret ; 0x14fb8 -Func_14fb8: ; 14fb8 (5:4fb8) - call _AIPickPrizeCards +.take_prize ; 14fb8 (5:4fb8) + call AIPickPrizeCards ret ; 0x14fbc -Data_14fbc: ; 14fbc (5:4fbc) +.list_arena ; 14fbc (5:4fbc) db LAPRAS db HORSEA db GOLDEEN db SQUIRTLE db $00 -Data_14fc1: ; 14fc1 (5:4fc1) +.list_bench ; 14fc1 (5:4fc1) db SQUIRTLE db HORSEA db GOLDEEN db LAPRAS db $00 -Data_14fc6: ; 14fc6 (5:4fc6) - airetreat SQUIRTLE, -3 - airetreat WARTORTLE, -2 - airetreat HORSEA, -1 +.list_retreat ; 14fc6 (5:4fc6) + ai_retreat SQUIRTLE, -3 + ai_retreat WARTORTLE, -2 + ai_retreat HORSEA, -1 db $00 -Data_14fcd: ; 14fcd (5:4fcd) - aienergy SQUIRTLE, 2, +0 - aienergy WARTORTLE, 3, +0 - aienergy BLASTOISE, 5, +0 - aienergy GOLDEEN, 1, +0 - aienergy SEAKING, 2, +0 - aienergy HORSEA, 2, +0 - aienergy SEADRA, 3, +0 - aienergy LAPRAS, 3, +0 +.list_energy ; 14fcd (5:4fcd) + ai_energy SQUIRTLE, 2, +0 + ai_energy WARTORTLE, 3, +0 + ai_energy BLASTOISE, 5, +0 + ai_energy GOLDEEN, 1, +0 + ai_energy SEAKING, 2, +0 + ai_energy HORSEA, 2, +0 + ai_energy SEADRA, 3, +0 + ai_energy LAPRAS, 3, +0 db $00 -Data_14fe6: ; 14fe6 (5:4fe6) +.list_prize ; 14fe6 (5:4fe6) db GAMBLER db ENERGY_RETRIEVAL db SUPER_ENERGY_RETRIEVAL db BLASTOISE db $00 -Func_14feb: ; 14feb (5:4feb) - ld hl, wcda8 - ld de, Data_14fe6 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_14fbc - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_14fc1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_14fc1 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_14fcd - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 14feb (5:4feb) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x15019 -PointerTable_15019: ; 15019 (5:5019) - dw Func_15025 - dw Func_15025 - dw Func_15029 - dw Func_1503a - dw Func_1503e - dw Func_15042 +AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_15025: ; 15025 (5:5025) - call _AIMainTurnLogic +.do_turn ; 15025 (5:5025) + call AIMainTurnLogic ret ; 0x15029 -Func_15029: ; 15029 (5:5029) +.start_duel ; 15029 (5:5029) call InitAIDuelVars - call Func_1506d + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1302,22 +1186,22 @@ Func_15029: ; 15029 (5:5029) ret ; 0x1503a -Func_1503a: ; 1503a (5:503a) +.forced_switch ; 1503a (5:503a) call AIDecideBenchPokemonToSwitchTo ret ; 0x1503e -Func_1503e: ; 1503e (5:503e) +.ko_switch ; 1503e (5:503e) call AIDecideBenchPokemonToSwitchTo ret ; 0x15042 -Func_15042: ; 15042 (5:5042) - call _AIPickPrizeCards +.take_prize ; 15042 (5:5042) + call AIPickPrizeCards ret ; 0x15046 -Data_15046: ; 15046 (5:5046) +.list_arena ; 15046 (5:5046) db KANGASKHAN db ELECTABUZZ2 db TAUROS @@ -1325,7 +1209,7 @@ Data_15046: ; 15046 (5:5046) db VOLTORB db $00 -Data_1504c: ; 1504c (5:504c) +.list_bench ; 1504c (5:504c) db MAGNEMITE1 db VOLTORB db ELECTABUZZ2 @@ -1333,76 +1217,50 @@ Data_1504c: ; 1504c (5:504c) db KANGASKHAN db $00 -Data_15052: ; 15052 (5:5052) - airetreat VOLTORB, -1 +.list_retreat ; 15052 (5:5052) + ai_retreat VOLTORB, -1 db $00 -Data_15055: ; 15055 (5:5055) - aienergy MAGNEMITE1, 3, +1 - aienergy MAGNETON1, 4, +0 - aienergy VOLTORB, 3, +1 - aienergy ELECTRODE1, 3, +0 - aienergy ELECTABUZZ2, 1, +0 - aienergy KANGASKHAN, 2, -2 - aienergy TAUROS, 3, +0 +.list_energy ; 15055 (5:5055) + ai_energy MAGNEMITE1, 3, +1 + ai_energy MAGNETON1, 4, +0 + ai_energy VOLTORB, 3, +1 + ai_energy ELECTRODE1, 3, +0 + ai_energy ELECTABUZZ2, 1, +0 + ai_energy KANGASKHAN, 2, -2 + ai_energy TAUROS, 3, +0 db $00 -Data_1506b: ; 1506b (5:506b) +.list_prize ; 1506b (5:506b) db KANGASKHAN db $00 -Func_1506d: ; 1506d (5:506d) - ld hl, wcda8 - ld de, Data_1506b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15046 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_1504c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_1504c - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_15055 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 1506d (5:506d) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x1509b -PointerTable_1509b: ; 1509b (5:509b) - dw Func_150a7 - dw Func_150a7 - dw Func_150ab - dw Func_150bc - dw Func_150c0 - dw Func_150c4 +AIActionTable_FlowerPower: ; 1509b (5:509b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_150a7: ; 150a7 (5:50a7) - call _AIMainTurnLogic +.do_turn ; 150a7 (5:50a7) + call AIMainTurnLogic ret ; 0x150ab -Func_150ab: ; 150ab (5:50ab) +.start_duel ; 150ab (5:50ab) call InitAIDuelVars - call Func_150f4 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1410,107 +1268,81 @@ Func_150ab: ; 150ab (5:50ab) ret ; 0x150bc -Func_150bc: ; 150bc (5:50bc) +.forced_switch ; 150bc (5:50bc) call AIDecideBenchPokemonToSwitchTo ret ; 0x150c0 -Func_150c0: ; 150c0 (5:50c0) +.ko_switch ; 150c0 (5:50c0) call AIDecideBenchPokemonToSwitchTo ret ; 0x150c4 -Func_150c4: ; 150c4 (5:50c4) - call _AIPickPrizeCards +.take_prize ; 150c4 (5:50c4) + call AIPickPrizeCards ret ; 0x150c8 -Data_150c8 ; 150c8 (5:50c8) +.list_arena ; 150c8 (5:50c8) db ODDISH db EXEGGCUTE db BULBASAUR db $00 -Data_150cc ; 150cc (5:50cc) +.list_bench ; 150cc (5:50cc) db BULBASAUR db EXEGGCUTE db ODDISH db $00 -Data_150cf ; 150cf (5:50cf) - airetreat GLOOM, -2 - airetreat VILEPLUME, -2 - airetreat BULBASAUR, -2 - airetreat IVYSAUR, -2 +.list_retreat ; 150cf (5:50cf) + ai_retreat GLOOM, -2 + ai_retreat VILEPLUME, -2 + ai_retreat BULBASAUR, -2 + ai_retreat IVYSAUR, -2 db $00 -Data_150d9 ; 150d9 (5:50d9) - aienergy BULBASAUR, 3, +0 - aienergy IVYSAUR, 4, +0 - aienergy VENUSAUR2, 4, +0 - aienergy ODDISH, 2, +0 - aienergy GLOOM, 3, -1 - aienergy VILEPLUME, 3, -1 - aienergy EXEGGCUTE, 3, +0 - aienergy EXEGGUTOR, 22, +0 +.list_energy ; 150d9 (5:50d9) + ai_energy BULBASAUR, 3, +0 + ai_energy IVYSAUR, 4, +0 + ai_energy VENUSAUR2, 4, +0 + ai_energy ODDISH, 2, +0 + ai_energy GLOOM, 3, -1 + ai_energy VILEPLUME, 3, -1 + ai_energy EXEGGCUTE, 3, +0 + ai_energy EXEGGUTOR, 22, +0 db $00 -Data_150f2 ; 150f2 (5:50f2) +.list_prize ; 150f2 (5:50f2) db VENUSAUR2 db $00 -Func_150f4: ; 150f4 (5:50f4) - ld hl, wcda8 - ld de, Data_150f2 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_150c8 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_150cc - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_150cc - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_150d9 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 150f4 (5:50f4) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x15122 -PointerTable_15122: ; 15122 (5:5122) - dw Func_1512e - dw Func_1512e - dw Func_15132 - dw Func_15143 - dw Func_15147 - dw Func_1514b +AIActionTable_StrangePsyshock: ; 15122 (5:5122) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_1512e: ; 1512e (5:512e) - call _AIMainTurnLogic +.do_turn ; 1512e (5:512e) + call AIMainTurnLogic ret ; 0x15132 -Func_15132: ; 15132 (5:5132) +.start_duel ; 15132 (5:5132) call InitAIDuelVars - call Func_1517f + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1518,22 +1350,22 @@ Func_15132: ; 15132 (5:5132) ret ; 0x15143 -Func_15143: ; 15143 (5:5143) +.forced_switch ; 15143 (5:5143) call AIDecideBenchPokemonToSwitchTo ret ; 0x15147 -Func_15147: ; 15147 (5:5147) +.ko_switch ; 15147 (5:5147) call AIDecideBenchPokemonToSwitchTo ret ; 0x1514b -Func_1514b: ; 1514b (5:514b) - call _AIPickPrizeCards +.take_prize ; 1514b (5:514b) + call AIPickPrizeCards ret ; 0x1514f -Data_1514f: ; 1514f (5:514f) +.list_arena ; 1514f (5:514f) db KANGASKHAN db CHANSEY db SNORLAX @@ -1541,7 +1373,7 @@ Data_1514f: ; 1514f (5:514f) db ABRA db $00 -Data_15155: ; 15155 (5:5155) +.list_bench ; 15155 (5:5155) db ABRA db MR_MIME db KANGASKHAN @@ -1549,82 +1381,56 @@ Data_15155: ; 15155 (5:5155) db CHANSEY db $00 -Data_1515b: ; 1515b (5:515b) - airetreat ABRA, -3 - airetreat SNORLAX, -3 - airetreat KANGASKHAN, -1 - airetreat CHANSEY, -1 +.list_retreat ; 1515b (5:515b) + ai_retreat ABRA, -3 + ai_retreat SNORLAX, -3 + ai_retreat KANGASKHAN, -1 + ai_retreat CHANSEY, -1 db $00 -Data_15164 ; 15164 (5:5164) - aienergy ABRA, 3, +1 - aienergy KADABRA, 3, +0 - aienergy ALAKAZAM, 3, +0 - aienergy MR_MIME, 2, +0 - aienergy CHANSEY, 2, -2 - aienergy KANGASKHAN, 4, -2 - aienergy SNORLAX, 0, -8 +.list_energy ; 15164 (5:5164) + ai_energy ABRA, 3, +1 + ai_energy KADABRA, 3, +0 + ai_energy ALAKAZAM, 3, +0 + ai_energy MR_MIME, 2, +0 + ai_energy CHANSEY, 2, -2 + ai_energy KANGASKHAN, 4, -2 + ai_energy SNORLAX, 0, -8 db $00 -Data_1517a ; 1517a (5:517a) +.list_prize ; 1517a (5:517a) db GAMBLER db MR_MIME db ALAKAZAM db SWITCH db $00 -Func_1517f: ; 1517f (5:517f) - ld hl, wcda8 - ld de, Data_1517a - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1514f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15155 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15155 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_15164 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 1517f (5:517f) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x151ad -PointerTable_151ad: ; 151ad (5:51ad) - dw Func_151b9 - dw Func_151b9 - dw Func_151bd - dw Func_151ce - dw Func_151d2 - dw Func_151d6 +AIActionTable_WondersOfScience: ; 151ad (5:51ad) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_151b9: ; 151b9 (5:51b9) - call _AIMainTurnLogic +.do_turn ; 151b9 (5:51b9) + call AIMainTurnLogic ret ; 0x151bd -Func_151bd: ; 151bd (5:51bd) +.start_duel ; 151bd (5:51bd) call InitAIDuelVars - call Func_15204 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1632,22 +1438,22 @@ Func_151bd: ; 151bd (5:51bd) ret ; 0x151ce -Func_151ce: ; 151ce (5:51ce) +.forced_switch ; 151ce (5:51ce) call AIDecideBenchPokemonToSwitchTo ret ; 0x151d2 -Func_151d2: ; 151d2 (5:51d2) +.ko_switch ; 151d2 (5:51d2) call AIDecideBenchPokemonToSwitchTo ret ; 0x151d6 -Func_151d6: ; 151d6 (5:51d6) - call _AIPickPrizeCards +.take_prize ; 151d6 (5:51d6) + call AIPickPrizeCards ret ; 0x151da -Data_151da: ; 151da (5:51da) +.list_arena ; 151da (5:51da) db MEWTWO1 db MEWTWO3 db MEWTWO2 @@ -1656,7 +1462,7 @@ Data_151da: ; 151da (5:51da) db PORYGON db $00 -Data_151e1: ; 151e1 (5:51e1) +.list_bench ; 151e1 (5:51e1) db GRIMER db KOFFING db MEWTWO3 @@ -1665,76 +1471,50 @@ Data_151e1: ; 151e1 (5:51e1) db PORYGON db $00 -Data_151e8: ; 151e8 (5:51e8) +.list_retreat ; 151e8 (5:51e8) db $00 -Data_151e9: ; 151e9 (5:51e9) - aienergy GRIMER, 3, +0 - aienergy MUK, 4, +0 - aienergy KOFFING, 2, +0 - aienergy WEEZING, 3, +0 - aienergy MEWTWO1, 2, -1 - aienergy MEWTWO3, 2, -1 - aienergy MEWTWO2, 2, -1 - aienergy PORYGON, 2, -1 +.list_energy ; 151e9 (5:51e9) + ai_energy GRIMER, 3, +0 + ai_energy MUK, 4, +0 + ai_energy KOFFING, 2, +0 + ai_energy WEEZING, 3, +0 + ai_energy MEWTWO1, 2, -1 + ai_energy MEWTWO3, 2, -1 + ai_energy MEWTWO2, 2, -1 + ai_energy PORYGON, 2, -1 db $00 -Data_15202: ; 15202 (5:5202) +.list_prize ; 15202 (5:5202) db MUK db $00 -Func_15204: ; 15204 (5:5204) - ld hl, wcda8 - ld de, Data_15202 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_151da - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_151e1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_151e1 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_151e9 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 15204 (5:5204) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x15232 -PointerTable_15232: ; 15232 (5:52PointerTable_12) - dw Func_1523e - dw Func_1523e - dw Func_15242 - dw Func_15253 - dw Func_15257 - dw Func_1525b +AIActionTable_FireCharge: ; 15232 (5:5232) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_1523e: ; 1523e (5:523e) - call _AIMainTurnLogic +.do_turn ; 1523e (5:523e) + call AIMainTurnLogic ret ; 0x15242 -Func_15242: ; 15242 (5:5242) +.start_duel ; 15242 (5:5242) call InitAIDuelVars - call Func_1528f + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1742,22 +1522,22 @@ Func_15242: ; 15242 (5:5242) ret ; 0x15253 -Func_15253: ; 15253 (5:5253) +.forced_switch ; 15253 (5:5253) call AIDecideBenchPokemonToSwitchTo ret ; 0x15257 -Func_15257: ; 15257 (5:5257) +.ko_switch ; 15257 (5:5257) call AIDecideBenchPokemonToSwitchTo ret ; 0x1525b -Func_1525b: ; 1525b (5:525b) - call _AIPickPrizeCards +.take_prize ; 1525b (5:525b) + call AIPickPrizeCards ret ; 0x1525f -Data_1525f: ; 1525f (5:525f) +.list_arena ; 1525f (5:525f) db JIGGLYPUFF3 db CHANSEY db TAUROS @@ -1766,7 +1546,7 @@ Data_1525f: ; 1525f (5:525f) db GROWLITHE db $00 -Data_15266: ; 15266 (5:5266) +.list_bench ; 15266 (5:5266) db JIGGLYPUFF3 db CHANSEY db GROWLITHE @@ -1775,79 +1555,53 @@ Data_15266: ; 15266 (5:5266) db TAUROS db $00 -Data_1526e: ; 1526e (5:526e) - airetreat JIGGLYPUFF1, -1 - airetreat CHANSEY, -1 - airetreat GROWLITHE, -1 +.list_retreat ; 1526e (5:526e) + ai_retreat JIGGLYPUFF1, -1 + ai_retreat CHANSEY, -1 + ai_retreat GROWLITHE, -1 db $00 -Data_15274: ; 15274 (5:5274) - aienergy GROWLITHE, 3, +0 - aienergy ARCANINE2, 4, +0 - aienergy MAGMAR1, 3, +0 - aienergy JIGGLYPUFF1, 3, +0 - aienergy JIGGLYPUFF3, 2, +0 - aienergy WIGGLYTUFF, 3, +0 - aienergy CHANSEY, 4, +0 - aienergy TAUROS, 3, +0 +.list_energy ; 15274 (5:5274) + ai_energy GROWLITHE, 3, +0 + ai_energy ARCANINE2, 4, +0 + ai_energy MAGMAR1, 3, +0 + ai_energy JIGGLYPUFF1, 3, +0 + ai_energy JIGGLYPUFF3, 2, +0 + ai_energy WIGGLYTUFF, 3, +0 + ai_energy CHANSEY, 4, +0 + ai_energy TAUROS, 3, +0 db $00 -Data_1528d: ; 1528d (5:528d) +.list_prize ; 1528d (5:528d) db GAMBLER db $00 -Func_1528f: ; 1528f (5:528f) - ld hl, wcda8 - ld de, Data_1528d - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1525f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15266 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15266 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_15274 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 1528f (5:528f) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x152bd -PointerTable_152bd: ; 152bd (5:52bd) - dw Func_152c9 - dw Func_152c9 - dw Func_152cd - dw Func_152de - dw Func_152e2 - dw Func_152e6 +AIActionTable_ImRonald: ; 152bd (5:52bd) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_152c9: ; 152c9 (5:52c9) - call _AIMainTurnLogic +.do_turn ; 152c9 (5:52c9) + call AIMainTurnLogic ret ; 0x152cd -Func_152cd: ; 152cd (5:52cd) +.start_duel ; 152cd (5:52cd) call InitAIDuelVars - call Func_1531d + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1855,22 +1609,22 @@ Func_152cd: ; 152cd (5:52cd) ret ; 0x152de -Func_152de: ; 152de (5:52de) +.forced_switch ; 152de (5:52de) call AIDecideBenchPokemonToSwitchTo ret ; 0x152e2 -Func_152e2: ; 152e2 (5:52e2) +.ko_switch ; 152e2 (5:52e2) call AIDecideBenchPokemonToSwitchTo ret ; 0x152e6 -Func_152e6: ; 152e6 (5:52e6) - call _AIPickPrizeCards +.take_prize ; 152e6 (5:52e6) + call AIPickPrizeCards ret ; 0x152ea -Data_152ea: ; 152ea (5:52ea) +.list_arena ; 152ea (5:52ea) db LAPRAS db SEEL db CHARMANDER @@ -1879,7 +1633,7 @@ Data_152ea: ; 152ea (5:52ea) db GROWLITHE db $00 -Data_152f1: ; 152f1 (5:52f1) +.list_bench ; 152f1 (5:52f1) db CHARMANDER db SQUIRTLE db SEEL @@ -1888,79 +1642,53 @@ Data_152f1: ; 152f1 (5:52f1) db LAPRAS db $00 -Data_152f8: ; 152f8 (5:52f8) +.list_retreat ; 152f8 (5:52f8) db $00 -Data_152f9: ; 152f9 (5:52f9) - aienergy CHARMANDER, 3, +0 - aienergy CHARMELEON, 5, +0 - aienergy GROWLITHE, 2, +0 - aienergy ARCANINE2, 4, +0 - aienergy SQUIRTLE, 2, +0 - aienergy WARTORTLE, 3, +0 - aienergy SEEL, 3, +0 - aienergy DEWGONG, 4, +0 - aienergy LAPRAS, 3, +0 - aienergy CUBONE, 3, +0 - aienergy MAROWAK1, 3, +0 +.list_energy ; 152f9 (5:52f9) + ai_energy CHARMANDER, 3, +0 + ai_energy CHARMELEON, 5, +0 + ai_energy GROWLITHE, 2, +0 + ai_energy ARCANINE2, 4, +0 + ai_energy SQUIRTLE, 2, +0 + ai_energy WARTORTLE, 3, +0 + ai_energy SEEL, 3, +0 + ai_energy DEWGONG, 4, +0 + ai_energy LAPRAS, 3, +0 + ai_energy CUBONE, 3, +0 + ai_energy MAROWAK1, 3, +0 db $00 -Data_1531b: ; 1531b (5:531b) +.list_prize ; 1531b (5:531b) db LAPRAS db $00 -Func_1531d: ; 1531d (5:531d) - ld hl, wcda8 - ld de, Data_1531b - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_152ea - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_152f1 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_152f1 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_152f9 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 1531d (5:531d) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x1534b -PointerTable_1534b: ; 1534b (5:534b) - dw Func_15357 - dw Func_15357 - dw Func_1535b - dw Func_1536c - dw Func_15370 - dw Func_15374 +AIActionTable_PowerfulRonald: ; 1534b (5:534b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_15357: ; 15357 (5:5357) - call _AIMainTurnLogic +.do_turn ; 15357 (5:5357) + call AIMainTurnLogic ret ; 0x1535b -Func_1535b: ; 1535b (5:535b) +.start_duel ; 1535b (5:535b) call InitAIDuelVars - call Func_153ba + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -1968,22 +1696,22 @@ Func_1535b: ; 1535b (5:535b) ret ; 0x1536c -Func_1536c: ; 1536c (5:536c) +.forced_switch ; 1536c (5:536c) call AIDecideBenchPokemonToSwitchTo ret ; 0x15370 -Func_15370: ; 15370 (5:5370) +.ko_switch ; 15370 (5:5370) call AIDecideBenchPokemonToSwitchTo ret ; 0x15374 -Func_15374: ; 15374 (5:5374) - call _AIPickPrizeCards +.take_prize ; 15374 (5:5374) + call AIPickPrizeCards ret ; 0x15378 -Data_15378: ; 15378 (5:5378) +.list_arena ; 15378 (5:5378) db KANGASKHAN db ELECTABUZZ2 db HITMONCHAN @@ -1996,7 +1724,7 @@ Data_15378: ; 15378 (5:5378) db DODUO db $00 -Data_15383: ; 15383 (5:5383) +.list_bench ; 15383 (5:5383) db KANGASKHAN db HITMONLEE db HITMONCHAN @@ -2009,83 +1737,57 @@ Data_15383: ; 15383 (5:5383) db LICKITUNG db $00 -Data_1538e: ; 1538e (5:538e) - airetreat KANGASKHAN, -1 - airetreat DODUO, -1 - airetreat DODRIO, -1 +.list_retreat ; 1538e (5:538e) + ai_retreat KANGASKHAN, -1 + ai_retreat DODUO, -1 + ai_retreat DODRIO, -1 db $00 -Data_15395: ; 15395 (5:5395) - aienergy ELECTABUZZ2, 2, +1 - aienergy HITMONLEE, 3, +1 - aienergy HITMONCHAN, 3, +1 - aienergy MR_MIME, 2, +0 - aienergy JYNX, 3, +0 - aienergy MEWTWO1, 2, +0 - aienergy DODUO, 3, -1 - aienergy DODRIO, 3, -1 - aienergy LICKITUNG, 2, +0 - aienergy KANGASKHAN, 4, -1 - aienergy TAUROS, 3, +0 +.list_energy ; 15395 (5:5395) + ai_energy ELECTABUZZ2, 2, +1 + ai_energy HITMONLEE, 3, +1 + ai_energy HITMONCHAN, 3, +1 + ai_energy MR_MIME, 2, +0 + ai_energy JYNX, 3, +0 + ai_energy MEWTWO1, 2, +0 + ai_energy DODUO, 3, -1 + ai_energy DODRIO, 3, -1 + ai_energy LICKITUNG, 2, +0 + ai_energy KANGASKHAN, 4, -1 + ai_energy TAUROS, 3, +0 db $00 -Data_153b7: ; 153b7 (5:53b7) +.list_prize ; 153b7 (5:53b7) db GAMBLER db ENERGY_REMOVAL db $00 -Func_153ba: ; 153ba (5:53ba) - ld hl, wcda8 - ld de, Data_153b7 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15378 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_15383 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_15383 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_15395 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 153ba (5:53ba) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x153e8 -PointerTable_153e8: ; 153e8 (5:53e8) - dw Func_153f4 - dw Func_153f4 - dw Func_153f8 - dw Func_15409 - dw Func_1540d - dw Func_15411 +AIActionTable_InvincibleRonald: ; 153e8 (5:53e8) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_153f4: ; 153f4 (5:53f4) - call _AIMainTurnLogic +.do_turn ; 153f4 (5:53f4) + call AIMainTurnLogic ret ; 0x153f8 -Func_153f8: ; 153f8 (5:53f8) +.start_duel ; 153f8 (5:53f8) call InitAIDuelVars - call Func_15441 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -2093,22 +1795,22 @@ Func_153f8: ; 153f8 (5:53f8) ret ; 0x15409 -Func_15409: ; 15409 (5:5409) +.forced_switch ; 15409 (5:5409) call AIDecideBenchPokemonToSwitchTo ret ; 0x1540d -Func_1540d: ; 1540d (5:540d) +.ko_switch ; 1540d (5:540d) call AIDecideBenchPokemonToSwitchTo ret ; 0x15411 -Func_15411: ; 15411 (5:5411) - call _AIPickPrizeCards +.take_prize ; 15411 (5:5411) + call AIPickPrizeCards ret ; 0x15415 -Data_15415: ; 15415 (5:5415) +.list_arena ; 15415 (5:5415) db KANGASKHAN db MAGMAR2 db CHANSEY @@ -2117,7 +1819,7 @@ Data_15415: ; 15415 (5:5415) db GRIMER db $00 -Data_1541c: ; 1541c (5:541c) +.list_bench ; 1541c (5:541c) db GRIMER db SCYTHER db GEODUDE @@ -2126,77 +1828,51 @@ Data_1541c: ; 1541c (5:541c) db KANGASKHAN db $00 -Data_15423: ; 15423 (5:5423) - airetreat GRIMER, -1 +.list_retreat ; 15423 (5:5423) + ai_retreat GRIMER, -1 db $00 -Data_15426: ; 15426 (5:5426) - aienergy GRIMER, 1, -1 - aienergy MUK, 3, -1 - aienergy SCYTHER, 4, +1 - aienergy MAGMAR2, 2, +0 - aienergy GEODUDE, 2, +0 - aienergy GRAVELER, 3, +0 - aienergy CHANSEY, 4, +0 - aienergy KANGASKHAN, 4, -1 +.list_energy ; 15426 (5:5426) + ai_energy GRIMER, 1, -1 + ai_energy MUK, 3, -1 + ai_energy SCYTHER, 4, +1 + ai_energy MAGMAR2, 2, +0 + ai_energy GEODUDE, 2, +0 + ai_energy GRAVELER, 3, +0 + ai_energy CHANSEY, 4, +0 + ai_energy KANGASKHAN, 4, -1 db $00 -Data_1543f: ; 1543f (5:543f) +.list_prize ; 1543f (5:543f) db GAMBLER db $00 -Func_15441: ; 15441 (5:5441) - ld hl, wcda8 - ld de, Data_1543f - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_15415 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_1541c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_1541c - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_15426 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 15441 (5:5441) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_bench + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x1546f -PointerTable_1546f: ; 1546f (5:546f) - dw Func_1547b - dw Func_1547b - dw Func_1547f - dw Func_15490 - dw Func_15494 - dw Func_15498 +AIActionTable_LegendaryRonald: ; 1546f (5:546f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize -Func_1547b: ; 1547b (5:547b) - call Func_15507 +.do_turn ; 1547b (5:547b) + call AIDoTurn_LegendaryRonald ret ; 0x1547f -Func_1547f: ; 1547f (5:547f) +.start_duel ; 1547f (5:547f) call InitAIDuelVars - call Func_154d9 + call .store_list_pointers call SetUpBossStartingHandAndDeck call TrySetUpBossStartingPlayArea ret nc @@ -2204,22 +1880,22 @@ Func_1547f: ; 1547f (5:547f) ret ; 0x15490 -Func_15490: ; 15490 (5:5490) +.forced_switch ; 15490 (5:5490) call AIDecideBenchPokemonToSwitchTo ret ; 0x15494 -Func_15494: ; 15494 (5:5494) +.ko_switch ; 15494 (5:5494) call AIDecideBenchPokemonToSwitchTo ret ; 0x15498 -Func_15498: ; 15498 (5:5498) - call _AIPickPrizeCards +.take_prize ; 15498 (5:5498) + call AIPickPrizeCards ret ; 0x1549c -Data_1549c: ; 1549c (5:549c) +.list_arena ; 1549c (5:549c) db KANGASKHAN db DRATINI db EEVEE @@ -2228,13 +1904,13 @@ Data_1549c: ; 1549c (5:549c) db MOLTRES2 db $00 -Data_154a3: ; 154a3 (5:54a3) +.list_bench ; 154a3 (5:54a3) db KANGASKHAN db DRATINI db EEVEE db $00 -Data_154a7: ; 154a7 (5:54a7) +.list_play_hand ; 154a7 (5:54a7) db MOLTRES2 db ZAPDOS3 db KANGASKHAN @@ -2243,25 +1919,25 @@ Data_154a7: ; 154a7 (5:54a7) db ARTICUNO2 db $00 -Data_154ae: ; 154ae (5:54ae) - airetreat EEVEE, -2 +.list_retreat ; 154ae (5:54ae) + ai_retreat EEVEE, -2 db $00 -Data_154b1: ; 154b1 (5:54b1) - aienergy FLAREON1, 3, +0 - aienergy MOLTRES2, 3, +0 - aienergy VAPOREON1, 3, +0 - aienergy ARTICUNO2, 0, -8 - aienergy JOLTEON1, 4, +0 - aienergy ZAPDOS3, 0, -8 - aienergy KANGASKHAN, 4, -1 - aienergy EEVEE, 3, +0 - aienergy DRATINI, 3, +0 - aienergy DRAGONAIR, 4, +0 - aienergy DRAGONITE1, 3, +0 +.list_energy ; 154b1 (5:54b1) + ai_energy FLAREON1, 3, +0 + ai_energy MOLTRES2, 3, +0 + ai_energy VAPOREON1, 3, +0 + ai_energy ARTICUNO2, 0, -8 + ai_energy JOLTEON1, 4, +0 + ai_energy ZAPDOS3, 0, -8 + ai_energy KANGASKHAN, 4, -1 + ai_energy EEVEE, 3, +0 + ai_energy DRATINI, 3, +0 + ai_energy DRAGONAIR, 4, +0 + ai_energy DRAGONITE1, 3, +0 db $00 -Data_154d3: ; 154d3 (5:54d3) +.list_prize ; 154d3 (5:54d3) db MOLTRES2 db ARTICUNO2 db ZAPDOS3 @@ -2269,85 +1945,71 @@ Data_154d3: ; 154d3 (5:54d3) db GAMBLER db $00 -Func_154d9: ; 154d9 (5:54d9) - ld hl, wcda8 - ld de, Data_154d3 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdaa - ld de, Data_1549c - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdac - ld de, Data_154a3 - ld [hl], e - inc hl - ld [hl], d - - ld hl, wcdae - ld de, Data_154a7 - ld [hl], e - inc hl - ld [hl], d - -; missing wcdb0 - - ld hl, wcdb2 - ld de, Data_154b1 - ld [hl], e - inc hl - ld [hl], d - +.store_list_pointers ; 154d9 (5:54d9) + store_list_pointer wcda8, .list_prize + store_list_pointer wcdaa, .list_arena + store_list_pointer wcdac, .list_bench + store_list_pointer wcdae, .list_play_hand + ; missing store_list_pointer wcdb0, .list_retreat + store_list_pointer wcdb2, .list_energy ret ; 0x15507 -Func_15507: ; 15507 (5:5507) +AIDoTurn_LegendaryRonald: ; 15507 (5:5507) +; initialize variables call InitAITurnVars +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_01 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_02 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards - ld a, $ef + +; check if AI can play Moltres2 +; from hand and if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable - cp $06 - jr nc, .asm_15540 - ld a, $ba + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres_1 ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable - cp $33 - jr nc, .asm_15540 - ld a, $27 + cp DECK_SIZE - 9 + jr nc, .skip_moltres_1 ; skip if cards in deck <= 9 + ld a, MUK call CountPokemonIDInBothPlayAreas - jr c, .asm_15540 - ld a, $40 + jr c, .skip_moltres_1 ; skip if Muk in play + ld a, MOLTRES2 call LookForCardIDInHandList_Bank5 - jr nc, .asm_15540 + jr nc, .skip_moltres_1 ; skip if no Moltres2 in hand ldh [hTemp_ffa0], a ld a, OPPACTION_PLAY_BASIC_PKMN bank1call AIMakeDecision -.asm_15540 + +.skip_moltres_1 +; play Pokemon from hand call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended +; process Trainer cards ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards +; play Energy card if possible ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_1555f + jr nz, .skip_attach_energy_1 call AIProcessAndTryToPlayEnergy -.asm_1555f +.skip_attach_energy_1 +; try playing Pokemon cards from hand again call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_15 +; if used Professor Oak, process new hand +; if not, then proceed to attack. call AIProcessHandTrainerCards ld a, [wPreviousAIFlags] and AI_FLAG_USED_PROFESSOR_OAK @@ -2358,43 +2020,49 @@ Func_15507: ; 15507 (5:5507) call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_04 call AIProcessHandTrainerCards - ld a, $ef + +; check if AI can play Moltres2 +; from hand and if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable - cp $06 - jr nc, .asm_155a5 - ld a, $ba + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres_2 ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable - cp $33 - jr nc, .asm_155a5 - ld a, $27 + cp DECK_SIZE - 9 + jr nc, .skip_moltres_2 ; skip if cards in deck <= 9 + ld a, MUK call CountPokemonIDInBothPlayAreas - jr c, .asm_155a5 - ld a, $40 + jr c, .skip_moltres_2 ; skip if Muk in play + ld a, MOLTRES2 call LookForCardIDInHandList_Bank5 - jr nc, .asm_155a5 + jr nc, .skip_moltres_2 ; skip if no Moltres2 in hand ldh [hTemp_ffa0], a ld a, OPPACTION_PLAY_BASIC_PKMN bank1call AIMakeDecision -.asm_155a5 + +.skip_moltres_2 call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended ld a, AI_TRAINER_CARD_PHASE_05 call AIProcessHandTrainerCards ld a, AI_TRAINER_CARD_PHASE_07 call AIProcessHandTrainerCards - call Func_14786 + call AIProcessRetreat ld a, AI_TRAINER_CARD_PHASE_10 call AIProcessHandTrainerCards ld a, [wAlreadyPlayedEnergy] or a - jr nz, .asm_155c4 + jr nz, .skip_attach_energy_2 call AIProcessAndTryToPlayEnergy -.asm_155c4 +.skip_attach_energy_2 call AIDecidePlayPokemonCard - ret c + ret c ; return if turn ended .try_attack +; attack if possible, if not, +; finish turn without attacking. call AIProcessAndTryToUseAttack - ret c + ret c ; return if turn ended ld a, OPPACTION_FINISH_NO_ATTACK bank1call AIMakeDecision ret diff --git a/src/wram.asm b/src/wram.asm index 5614b54..e4bf0b2 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1290,7 +1290,9 @@ wAIOpponentPrizeCount:: ; cdd3 wTempCardIDToLook:: ; cdd4 ds $1 -wcdd5:: ; cdd5 +; when AI decides which Bench Pokemon to switch to +; it stores it Play Area location here. +wAIPlayAreaCardToSwitch:: ; cdd5 ds $1 ; the index of attack chosen by AI @@ -1391,7 +1393,10 @@ wce01:: ; ce01 wAIMoveIsNonDamaging:: ; ce02 ds $1 -wce03:: ; ce03 +; whether AI already retreated this turn or not. +; - $0 has not retreated; +; - $1 has retreated. +wAIRetreatedThisTurn:: ; ce03 ds $1 ; used by AI to store information of Venusaur2 -- cgit v1.2.3 From 81191863b354193fcefbd6cd2919b362c390a5bd Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 7 May 2020 21:32:45 +0100 Subject: Document AI WRAM pointers --- src/engine/bank05.asm | 56 +++++++-------- src/engine/deck_ai.asm | 192 ++++++++++++++++++++++++------------------------- src/wram.asm | 49 +++++++++---- 3 files changed, 158 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 8943187..5417ecc 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -2177,7 +2177,7 @@ RemoveCardIDInList: ; 157f3 (5:57f3) ; if Arena card could not be set (due to hand not having any card in its list) ; or if list is null, return carry and do not play any cards. TrySetUpBossStartingPlayArea: ; 1581b (5:581b) - ld de, wcdaa + ld de, wAICardListArenaPriority ld a, d or a jr z, .set_carry ; return if null @@ -2185,14 +2185,14 @@ TrySetUpBossStartingPlayArea: ; 1581b (5:581b) ; pick Arena card call CreateHandCardList ld hl, wDuelTempList - ld de, wcdaa + ld de, wAICardListArenaPriority call .PlayPokemonCardInOrder ret c ; play Pokemon cards to Bench until there are ; a maximum of 3 cards in Play Area. .loop - ld de, wcdac + ld de, wAICardListBenchPriority call .PlayPokemonCardInOrder jr c, .done cp 3 @@ -2960,18 +2960,18 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) cp MYSTERIOUS_FOSSIL jr z, .lower_score_2 cp CLEFAIRY_DOLL - jr nz, .asm_15d0c + jr nz, .ai_score_bonus .lower_score_2 ld a, 10 call SubFromAIScore -.asm_15d0c +.ai_score_bonus ld b, a - ld a, [wcdb0 + 1] + ld a, [wAICardListRetreatBonus + 1] or a jr z, .store_score ld h, a - ld a, [wcdb0] + ld a, [wAICardListRetreatBonus] ld l, a .loop_ids @@ -2982,11 +2982,11 @@ AIDecideBenchPokemonToSwitchTo: ; 15b72 (5:5b72) jr nz, .next_id ld a, [hl] cp $80 - jr c, .asm_15d2b + jr c, .subtract_score sub $80 call AddToAIScore jr .next_id -.asm_15d2b +.subtract_score ld c, a ld a, $80 sub c @@ -4085,17 +4085,17 @@ LookForEnergyNeededForMoveInHand: ; 16311 (5:6311) ; 0x1633f ; goes through $00 terminated list pointed -; by wcdae and compares it to each card in hand. +; by wAICardListPlayFromHandPriority and compares it to each card in hand. ; Sorts the hand in wDuelTempList so that the found card IDs ; are in the same order as the list pointed by de. SortTempHandByIDList: ; 1633f (5:633f) - ld a, [wcdae+1] + ld a, [wAICardListPlayFromHandPriority+1] or a ret z ; return if list is empty ; start going down the ID list ld d, a - ld a, [wcdae] + ld a, [wAICardListPlayFromHandPriority] ld e, a ld c, 0 .loop_list_id @@ -4605,7 +4605,7 @@ AIProcessEnergyCards: ; 164fc (5:64fc) jr .check_bench .check_defending_can_ko call CheckIfDefendingPokemonCanKnockOut - jr nc, .asm_165e1 + jr nc, .ai_score_bonus ld a, 10 call SubFromAIScore @@ -4616,10 +4616,10 @@ AIProcessEnergyCards: ; 164fc (5:64fc) ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable dec a - jr nz, .asm_165e1 + jr nz, .ai_score_bonus ld a, 6 call AddToAIScore - jr .asm_165e1 + jr .ai_score_bonus ; lower AI score by 3 - (bench HP)/10 ; if bench HP < 30 @@ -4628,20 +4628,20 @@ AIProcessEnergyCards: ; 164fc (5:64fc) call GetTurnDuelistVariable call CalculateByteTensDigit cp 3 - jr nc, .asm_165e1 + jr nc, .ai_score_bonus ; hp < 30 ld b, a ld a, 3 sub b call SubFromAIScore -; check list in wcdb2 -.asm_165e1 - ld a, [wcdb3] +; check list in wAICardListEnergyBonus +.ai_score_bonus + ld a, [wAICardListEnergyBonus + 1] or a - jr z, .check_boss_deck + jr z, .check_boss_deck ; is null ld h, a - ld a, [wcdb2] + ld a, [wAICardListEnergyBonus] ld l, a push hl @@ -7137,12 +7137,12 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af) ld a, DUELVARS_HAND call GetTurnDuelistVariable ld b, STARTING_HAND_SIZE -.asm_172b6 +.loop_hand ld a, [hl] call RemoveCardFromHand call ReturnCardToDeck dec b - jr nz, .asm_172b6 + jr nz, .loop_hand jr .count_energy_basic .shuffle_deck @@ -7197,7 +7197,7 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af) jr c, .shuffle_deck ; now check the following 6 cards (prize cards). -; re-shuffle deck if any of these cards is listed in wcda8. +; re-shuffle deck if any of these cards is listed in wAICardListAvoidPrize. ld b, 6 .check_card_ids ld a, [hli] @@ -7263,20 +7263,20 @@ SetUpBossStartingHandAndDeck: ; 172af (5:72af) ; 0x17366 ; expectation: return carry if card ID corresponding -; to the input deck index is listed in wcda8; +; to the input deck index is listed in wAICardListAvoidPrize; ; reality: always returns no carry because when checking terminating -; byte in wcda8 ($00), it wrongfully uses 'cp a' instead of 'or a', +; byte in wAICardListAvoidPrize ($00), it wrongfully uses 'cp a' instead of 'or a', ; so it always ends up returning in the first item in list. ; input: ; - a = deck index of card to check .CheckIfIDIsInList ; 17366 (5:7366) ld b, a - ld a, [wcda8 + 1] + ld a, [wAICardListAvoidPrize + 1] or a ret z ; null push hl ld h, a - ld a, [wcda8] + ld a, [wAICardListAvoidPrize] ld l, a ld a, b diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index 2a78848..dfa6820 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -262,12 +262,12 @@ AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8) db $00 .store_list_pointers ; 14a4a (5:4a4a) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_play_hand - store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand + store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14a81 @@ -438,12 +438,12 @@ AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f) db $00 .store_list_pointers ; 14b6c (5:4b6c) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14b9a @@ -597,12 +597,12 @@ AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b) db $00 .store_list_pointers ; 14c63 (5:4c63) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14c91 @@ -818,12 +818,12 @@ AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60) db $00 .store_list_pointers ; 14dc1 (5:4dc1) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14def @@ -987,12 +987,12 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89) db $00 .store_list_pointers ; 14ee0 (5:4ee0) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14f0e @@ -1068,12 +1068,12 @@ AIActionTable_RockCrusher: ; 14f0e (5:4f0e) db $00 .store_list_pointers ; 14f61 (5:4f61) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x14f8f @@ -1154,12 +1154,12 @@ AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f) db $00 .store_list_pointers ; 14feb (5:4feb) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x15019 @@ -1236,12 +1236,12 @@ AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019) db $00 .store_list_pointers ; 1506d (5:506d) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x1509b @@ -1318,12 +1318,12 @@ AIActionTable_FlowerPower: ; 1509b (5:509b) db $00 .store_list_pointers ; 150f4 (5:50f4) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x15122 @@ -1406,12 +1406,12 @@ AIActionTable_StrangePsyshock: ; 15122 (5:5122) db $00 .store_list_pointers ; 1517f (5:517f) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x151ad @@ -1490,12 +1490,12 @@ AIActionTable_WondersOfScience: ; 151ad (5:51ad) db $00 .store_list_pointers ; 15204 (5:5204) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x15232 @@ -1577,12 +1577,12 @@ AIActionTable_FireCharge: ; 15232 (5:5232) db $00 .store_list_pointers ; 1528f (5:528f) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x152bd @@ -1664,12 +1664,12 @@ AIActionTable_ImRonald: ; 152bd (5:52bd) db $00 .store_list_pointers ; 1531d (5:531d) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x1534b @@ -1763,12 +1763,12 @@ AIActionTable_PowerfulRonald: ; 1534b (5:534b) db $00 .store_list_pointers ; 153ba (5:53ba) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x153e8 @@ -1848,12 +1848,12 @@ AIActionTable_InvincibleRonald: ; 153e8 (5:53e8) db $00 .store_list_pointers ; 15441 (5:5441) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_bench - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x1546f @@ -1946,12 +1946,12 @@ AIActionTable_LegendaryRonald: ; 1546f (5:546f) db $00 .store_list_pointers ; 154d9 (5:54d9) - store_list_pointer wcda8, .list_prize - store_list_pointer wcdaa, .list_arena - store_list_pointer wcdac, .list_bench - store_list_pointer wcdae, .list_play_hand - ; missing store_list_pointer wcdb0, .list_retreat - store_list_pointer wcdb2, .list_energy + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy ret ; 0x15507 diff --git a/src/wram.asm b/src/wram.asm index e4bf0b2..71830dd 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1184,9 +1184,9 @@ wcda5:: ; cda5 ; this is used by AI in order to determine whether ; it should use Pokedex Trainer card. -; duel starts at 5 and counts up by one every turn. +; starts with 5 when Duel starts and counts up by 1 every turn. ; only when it's higher than 5 is AI allowed to use Pokedex, -; in which case it set the counter to 0. +; in which case it sets the counter to 0. ; this stops the AI from using Pokedex right after using another one ; while still drawing cards that were ordered. wAIPokedexCounter:: ; cda6 @@ -1201,28 +1201,47 @@ wAIPokedexCounter:: ; cda6 wAIBarrierFlagCounter:: ; cda7 ds $1 -wcda8:: ; cda8 +; pointer to $00-terminated list of card IDs +; to avoid being placed as prize cards +; when setting up AI duelist's cards at duel start. +; (see SetUpBossStartingHandAndDeck) +wAICardListAvoidPrize:: ; cda8 ds $2 -wcdaa:: ; cdaa +; pointer to $00-terminated list of card IDs +; sorted by priority of AI placing in the Arena +; at duel start (see TrySetUpBossStartingPlayArea) +wAICardListArenaPriority:: ; cdaa ds $2 -wcdac:: ; cdac +; pointer to $00-terminated list of card IDs +; sorted by priority of AI placing in the Bench +; at duel start (see TrySetUpBossStartingPlayArea) +wAICardListBenchPriority:: ; cdac ds $2 -; pointer to a list of card IDs for sorting AI hand -wcdae:: ; cdae +; pointer to $00-terminated list of card IDs +; sorted by priority of AI playing it from Hand +; to the Bench (see AIDecidePlayPokemonCard) +wAICardListPlayFromHandPriority:: ; cdae ds $2 -wcdb0:: ; cdb0 +; pointer to $00-terminated list of card IDs and AI scores. +; these are for giving certain cards more or less +; likelihood of being picked by AI to switch to. +; (see AIDecideBenchPokemonToSwitchTo) +wAICardListRetreatBonus:: ; cdb0 ds $2 -; these seem to hold pointer to some kind of -; card ID list with attached energy and score -wcdb2:: ; cdb2 - ds $1 -wcdb3:: ; cdb3 - ds $1 +; pointer to $00-terminated list of card IDs, +; number of energy cards and AI score. +; these are for giving certain cards more or less +; likelihood of being picked for AI to attach energy. +; also has the maximum number of energy cards that +; the AI is willing to provide for it. +; (see AIProcessEnergyCards) +wAICardListEnergyBonus:: ; cdb2 + ds $2 wcdb4:: ; cdb4 ds $1 @@ -1266,7 +1285,7 @@ wFirstAttackAIScore:: ; cdbf ENDU - ds $0a + ds $a ; information about the defending Pokémon and ; the prize card count on both sides for AI: -- cgit v1.2.3 From bf4cc80aa71c401f489cee3027fba09e975a64cd Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 8 May 2020 01:09:47 +0100 Subject: Document Deck AI data structures --- src/engine/deck_ai.asm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index dfa6820..15a1025 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -30,6 +30,36 @@ store_list_pointer: MACRO ld [hl], d ENDM +; deck AIs are specialized to work on a given deck ID. +; they decide what happens during a turn, what Pokemon cards +; to pick during the start of the duel, etc. +; each of these have a pointer table with the following structure: +; dw .do_turn : never called; +; +; dw .do_turn : called to handle the main turn logic, from the beginning +; of the turn up to the attack (or lack thereof); +; +; dw .start_duel : called at the start of the duel to initialize some +; variables and optionally set up CPU hand and deck; +; +; dw .forced_switch : logic to determine what Pokemon to pick when there's +; an effect that forces AI to switch to Bench card; +; +; dw .ko_switch : logic for picking which card to use after a KO; +; +; dw .take_prize : logic to decide which prize card to pick. + +; optionally, decks can also declare card lists that will add +; more specialized logic during various generic AI routines, +; and read during the .start_duel routines. +; the pointers to these lists are stored in memory: +; wAICardListAvoidPrize : list of cards to avoid being placed as prize; +; wAICardListArenaPriority : priority list of Arena card at duel start; +; wAICardListBenchPriority : priority list of Bench cards at duel start; +; wAICardListPlayFromHandPriority : priority list of cards to play from hand; +; wAICardListRetreatBonus : scores given to certain cards for retreat; +; wAICardListEnergyBonus : max number of energy cards and card scores. + AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc) dw .do_turn ; unused dw .do_turn -- cgit v1.2.3 From 1a1cff966e82ada49585bbc721247c7c8c8cf3a1 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 8 May 2020 09:28:28 +0100 Subject: Add corrections --- src/engine/bank08.asm | 86 ++++++++++++++++++++--------------------- src/engine/deck_ai.asm | 6 +-- src/engine/effect_functions.asm | 2 +- 3 files changed, 47 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index df8d7c5..1bb06a3 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -6255,7 +6255,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) jr z, .check_retreat cp AI_ENERGY_TRANS_TO_BENCH - jp z, .TransferEnergyToBench + jp z, AIEnergyTransTransferEnergyToBench ; AI_ENERGY_TRANS_ATTACK call .CheckEnoughGrassEnergyCardsForAttack @@ -6277,7 +6277,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) call GetTurnDuelistVariable dec a ld b, a -.loop_play_area_1 +.loop_play_area ld a, DUELVARS_ARENA_CARD add b call GetTurnDuelistVariable @@ -6285,17 +6285,17 @@ HandleAIEnergyTrans: ; 2219b (8:619b) call GetCardIDFromDeckIndex ld a, e cp VENUSAUR2 - jr z, .use_pkmn_power_1 + jr z, .use_pkmn_power ld a, b or a ret z ; return when finished Play Area loop dec b - jr .loop_play_area_1 + jr .loop_play_area ; use Energy Trans Pkmn Power -.use_pkmn_power_1 +.use_pkmn_power ld a, b ldh [hTemp_ffa0], a ld a, OPPACTION_USE_PKMN_POWER @@ -6311,13 +6311,13 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; look for Grass energy cards that ; are currently attached to a Bench card. ld e, 0 -.loop_deck_locations_1 +.loop_deck_locations ld a, DUELVARS_CARD_LOCATIONS add e call GetTurnDuelistVariable and %00011111 cp CARD_LOCATION_BENCH_1 - jr c, .next_card_1 + jr c, .next_card and %00001111 ldh [hTempPlayAreaLocation_ffa1], a @@ -6328,7 +6328,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ld a, e pop de cp GRASS_ENERGY - jr nz, .next_card_1 + jr nz, .next_card ; store the deck index of energy card ld a, e @@ -6336,39 +6336,39 @@ HandleAIEnergyTrans: ; 2219b (8:619b) push de ld d, 30 -.small_delay_loop_1 +.small_delay_loop call DoFrame dec d - jr nz, .small_delay_loop_1 + jr nz, .small_delay_loop ld a, OPPACTION_6B15 bank1call AIMakeDecision pop de dec d - jr z, .done_transfer_1 + jr z, .done_transfer -.next_card_1 +.next_card inc e ld a, DECK_SIZE cp e - jr nz, .loop_deck_locations_1 + jr nz, .loop_deck_locations ; transfer is done, perform delay ; and return to main scene. -.done_transfer_1 +.done_transfer ld d, 60 -.big_delay_loop_1 +.big_delay_loop call DoFrame dec d - jr nz, .big_delay_loop_1 + jr nz, .big_delay_loop ld a, OPPACTION_DUEL_MAIN_SCENE bank1call AIMakeDecision ret ; 0x22246 -; checks if the Arena card has not enough energy for second attack, -; and if not, return carry if transferring Grass energy from Bench -; would be enough to use it and outputs number of energy cards needed in a. +; checks if the Arena card needs energy for its second attack, +; and if it does, return carry if transferring Grass energy from Bench +; would be enough to use it. Outputs number of energy cards needed in a. .CheckEnoughGrassEnergyCardsForAttack ; 22246 (8:6246) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -6494,7 +6494,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; AI logic to determine whether to use Energy Trans Pkmn Power ; to transfer energy cards attached from the Arena Pokemon to ; some card in the Bench. -.TransferEnergyToBench ; 222ca (8:62ca) +AIEnergyTransTransferEnergyToBench: ; 222ca (8:62ca) xor a ; PLAY_AREA_ARENA ldh [hTempPlayAreaLocation_ff9d], a farcall CheckIfDefendingPokemonCanKnockOut @@ -6523,7 +6523,7 @@ HandleAIEnergyTrans: ; 2219b (8:619b) call GetTurnDuelistVariable dec a ld b, a -.loop_play_area_2 +.loop_play_area ld a, DUELVARS_ARENA_CARD add b call GetTurnDuelistVariable @@ -6532,17 +6532,17 @@ HandleAIEnergyTrans: ; 2219b (8:619b) call GetCardIDFromDeckIndex ld a, e cp VENUSAUR2 - jr z, .use_pkmn_power_2 + jr z, .use_pkmn_power ld a, b or a ret z ; return when Play Area loop is ended dec b - jr .loop_play_area_2 + jr .loop_play_area ; use Energy Trans Pkmn Power -.use_pkmn_power_2 +.use_pkmn_power ld a, b ldh [hTemp_ffa0], a ld [wAIVenusaur2PlayAreaLocation], a @@ -6563,17 +6563,17 @@ HandleAIEnergyTrans: ; 2219b (8:619b) call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + GRASS] or a - jr z, .done_transfer_2 + jr z, .done_transfer ; look for Grass energy cards that ; are currently attached to Arena card. ld e, 0 -.loop_deck_locations_2 +.loop_deck_locations ld a, DUELVARS_CARD_LOCATIONS add e call GetTurnDuelistVariable cp CARD_LOCATION_ARENA - jr nz, .next_card_2 + jr nz, .next_card ld a, e push de @@ -6581,32 +6581,32 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ld a, e pop de cp GRASS_ENERGY - jr nz, .next_card_2 + jr nz, .next_card ; store the deck index of energy card ld a, e ldh [hAIEnergyTransEnergyCard], a jr .transfer -.next_card_2 +.next_card inc e ld a, DECK_SIZE cp e - jr nz, .loop_deck_locations_2 - jr .done_transfer_2 + jr nz, .loop_deck_locations + jr .done_transfer .transfer ; get the Bench card location to transfer Grass energy card to. farcall AIProcessButDontPlayEnergy_SkipEvolutionAndArena - jr nc, .done_transfer_2 + jr nc, .done_transfer ldh a, [hTempPlayAreaLocation_ff9d] ldh [hAIEnergyTransPlayAreaLocation], a ld d, 30 -.small_delay_loop_2 +.small_delay_loop call DoFrame dec d - jr nz, .small_delay_loop_2 + jr nz, .small_delay_loop ld a, [wAIVenusaur2DeckIndex] ldh [hTempCardIndex_ff9f], a @@ -6619,12 +6619,12 @@ HandleAIEnergyTrans: ; 2219b (8:619b) ; transfer is done, perform delay ; and return to main scene. -.done_transfer_2 +.done_transfer ld d, 60 -.big_delay_loop_2 +.big_delay_loop call DoFrame dec d - jr nz, .big_delay_loop_2 + jr nz, .big_delay_loop ld a, OPPACTION_DUEL_MAIN_SCENE bank1call AIMakeDecision ret @@ -6934,7 +6934,7 @@ HandleAIPeek: ; 224e6 (8:64e6) cp 3 ret nc ; return 47 out of 50 times -; check what to use Peek on at random +; choose what to use Peek on at random ld a, 3 call Random or a @@ -7242,12 +7242,12 @@ HandleAICowardice: ; 2262d (8:662d) ldh a, [hTemp_ffa0] or a jr nz, .is_benched + + ; this part is buggy if AIDecideBenchPokemonToSwitchTo returns carry + ; but since this was already checked beforehand, this never happens. + ; so jr c, .asm_22678 can be safely removed. farcall AIDecideBenchPokemonToSwitchTo -; in case this routine is called with no Bench Pokemon, -; this introduces a bug. -; since it's only called in HandleAICowardice in case -; there's more than 1 Pokemon in Play Area, this never sets carry. - jr c, .asm_22678 + jr c, .asm_22678 ; bug, this jumps in the middle of damage checking jr .use_cowardice .is_benched ld a, $ff diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm index 15a1025..0bdbd5a 100644 --- a/src/engine/deck_ai.asm +++ b/src/engine/deck_ai.asm @@ -996,9 +996,9 @@ AIActionTable_FirstStrike: ; 14e89 (5:4e89) db $00 .list_retreat ; 14ec0 (5:1ec0) - ai_retreat MACHOP, - 1 - ai_retreat MACHOKE, - 1 - ai_retreat MANKEY, - 2 + ai_retreat MACHOP, -1 + ai_retreat MACHOKE, -1 + ai_retreat MANKEY, -2 db $00 .list_energy ; 14ec7 (5:1ec7) diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index dbda9ad..762e82d 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -763,4 +763,4 @@ Func_2cbfb: ; 2cbfb (b:4bfb) ret ; 0x2cc0a - INCROM $2cc0a, $30000 \ No newline at end of file + INCROM $2cc0a, $30000 -- cgit v1.2.3 From d20d490df325c1671357acd894ec14ed36599797 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 9 May 2020 11:47:04 +0100 Subject: Give each deck AI its own file --- src/engine/bank05.asm | 419 +--- src/engine/deck_ai.asm | 2099 --------------------- src/engine/deck_ai/deck_ai.asm | 81 + src/engine/deck_ai/decks/fire_charge.asm | 86 + src/engine/deck_ai/decks/first_strike.asm | 82 + src/engine/deck_ai/decks/flower_power.asm | 81 + src/engine/deck_ai/decks/general.asm | 196 ++ src/engine/deck_ai/decks/general_no_retreat.asm | 146 ++ src/engine/deck_ai/decks/go_go_rain_dance.asm | 85 + src/engine/deck_ai/decks/im_ronald.asm | 86 + src/engine/deck_ai/decks/invincible_ronald.asm | 84 + src/engine/deck_ai/decks/legendary_articuno.asm | 217 +++ src/engine/deck_ai/decks/legendary_dragonite.asm | 173 ++ src/engine/deck_ai/decks/legendary_moltres.asm | 183 ++ src/engine/deck_ai/decks/legendary_ronald.asm | 210 +++ src/engine/deck_ai/decks/legendary_zapdos.asm | 160 ++ src/engine/deck_ai/decks/powerful_ronald.asm | 98 + src/engine/deck_ai/decks/rock_crusher.asm | 80 + src/engine/deck_ai/decks/sams_practice.asm | 222 +++ src/engine/deck_ai/decks/strange_psyshock.asm | 87 + src/engine/deck_ai/decks/wonders_of_science.asm | 83 + src/engine/deck_ai/decks/zapping_selfdestruct.asm | 81 + 22 files changed, 2522 insertions(+), 2517 deletions(-) delete mode 100644 src/engine/deck_ai.asm create mode 100644 src/engine/deck_ai/deck_ai.asm create mode 100644 src/engine/deck_ai/decks/fire_charge.asm create mode 100644 src/engine/deck_ai/decks/first_strike.asm create mode 100644 src/engine/deck_ai/decks/flower_power.asm create mode 100644 src/engine/deck_ai/decks/general.asm create mode 100644 src/engine/deck_ai/decks/general_no_retreat.asm create mode 100644 src/engine/deck_ai/decks/go_go_rain_dance.asm create mode 100644 src/engine/deck_ai/decks/im_ronald.asm create mode 100644 src/engine/deck_ai/decks/invincible_ronald.asm create mode 100644 src/engine/deck_ai/decks/legendary_articuno.asm create mode 100644 src/engine/deck_ai/decks/legendary_dragonite.asm create mode 100644 src/engine/deck_ai/decks/legendary_moltres.asm create mode 100644 src/engine/deck_ai/decks/legendary_ronald.asm create mode 100644 src/engine/deck_ai/decks/legendary_zapdos.asm create mode 100644 src/engine/deck_ai/decks/powerful_ronald.asm create mode 100644 src/engine/deck_ai/decks/rock_crusher.asm create mode 100644 src/engine/deck_ai/decks/sams_practice.asm create mode 100644 src/engine/deck_ai/decks/strange_psyshock.asm create mode 100644 src/engine/deck_ai/decks/wonders_of_science.asm create mode 100644 src/engine/deck_ai/decks/zapping_selfdestruct.asm (limited to 'src') diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 5417ecc..762d5c8 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -1213,424 +1213,7 @@ AIProcessHandTrainerCards: ; 14663 (5:4663) farcall _AIProcessHandTrainerCards ret -AIActionTable_GeneralDecks: ; 14668 (05:4668) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14674 (5:4674) - call AIMainTurnLogic - ret - -.start_duel ; 14678 (5:4678) - call InitAIDuelVars - call AIPlayInitialBasicCards - ret - -.forced_switch ; 1467f (5:467f) - call AIDecideBenchPokemonToSwitchTo - ret - -.ko_switch ; 14683 (5:4683) - call AIDecideBenchPokemonToSwitchTo - ret - -.take_prize: ; 14687 (5:4687) - call AIPickPrizeCards - ret - -; handle AI routines for a whole turn -AIMainTurnLogic: ; 1468b (5:468b) -; initialize variables - call InitAITurnVars - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; handle Pkmn Powers - farcall HandleAIGoGoRainDanceEnergy - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAICowardice -; process Trainer cards -; phase 2 through 4. - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_03 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended -; process Trainer cards -; phase 5 through 12. - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_06 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_08 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_12 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_1 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_1 -; play Pokemon from hand again - call AIDecidePlayPokemonCard -; handle Pkmn Powers again - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAIGoGoRainDanceEnergy - ld a, AI_ENERGY_TRANS_ATTACK - farcall HandleAIEnergyTrans -; process Trainer cards phases 13 and 15 - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_15 - call AIProcessHandTrainerCards -; if used Professor Oak, process new hand -; if not, then proceed to attack. - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK - jr z, .try_attack - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_03 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_06 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_08 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_12 - call AIProcessHandTrainerCards - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_2 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_2 - call AIDecidePlayPokemonCard - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAIGoGoRainDanceEnergy - ld a, AI_ENERGY_TRANS_ATTACK - farcall HandleAIEnergyTrans - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - ; skip AI_TRAINER_CARD_PHASE_15 -.try_attack - ld a, AI_ENERGY_TRANS_TO_BENCH - farcall HandleAIEnergyTrans -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if AI attacked - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14786 - -; handles AI retreating logic -AIProcessRetreat: ; 14786 (5:4786) - ld a, [wAIRetreatedThisTurn] - or a - ret nz ; return, already retreated this turn - - call AIDecideWhetherToRetreat - ret nc ; return if not retreating - - call AIDecideBenchPokemonToSwitchTo - ret c ; return if no Bench Pokemon - -; store Play Area to retreat to and -; set wAIRetreatedThisTurn to true - ld [wAIPlayAreaCardToSwitch], a - ld a, $01 - ld [wAIRetreatedThisTurn], a - -; if AI can use Switch from hand, use it instead... - ld a, AI_TRAINER_CARD_PHASE_09 - call AIProcessHandTrainerCards - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_SWITCH - jr nz, .used_switch -; ... else try retreating normally. - ld a, [wAIPlayAreaCardToSwitch] - call AITryToRetreat - ret - -.used_switch -; if AI used switch, unset its AI flag - ld a, [wPreviousAIFlags] - and ~AI_FLAG_USED_SWITCH ; clear Switch flag - ld [wPreviousAIFlags], a - -; bug, this doesn't make sense being here, since at this point -; Switch Trainer card was already used to retreat the Pokemon. -; what the routine will do is just transfer Energy cards to -; the Arena Pokemon for the purpose of retreating, and -; then not actually retreat, resulting in unusual behaviour. -; this would only work placed right after the AI checks whether -; they have Switch card in hand to use and doesn't have one. -; (and probably that was the original intention.) - ld a, AI_ENERGY_TRANS_RETREAT ; retreat - farcall HandleAIEnergyTrans - ret -; 0x147bd - -AIActionTable_SamPractice: ; 147bd (05:47bd) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 147c9 (5:47c9) - call IsAIPracticeScriptedTurn - jr nc, .scripted_1 -; not scripted, use AI main turn logic - call AIMainTurnLogic - ret -.scripted_1 ; use scripted actions instead - call AIPerformSciptedTurn - ret -; 0x147d6 - -.start_duel ; 147d6 (5:47d6) - call Func_14801 - ret -; 0x147da - -.forced_switch ; 147da (5:47da) - call IsAIPracticeScriptedTurn - jr nc, .scripted_2 - call AIDecideBenchPokemonToSwitchTo - ret -.scripted_2 - call PickRandomBenchPokemon - ret -; 0x147e7 - -.ko_switch: ; 147e7 (5:47e7) - call IsAIPracticeScriptedTurn - jr nc, .scripted_3 - call AIDecideBenchPokemonToSwitchTo - ret -.scripted_3 - call GetPlayAreaLocationOfRaticateOrRattata - ret -; 0x147f4 - -.take_prize: ; 147f4 (5:47f4) - call AIPickPrizeCards - ret -; 0x147f8 - -; returns carry if number of turns -; the AI has taken >= 7. -; used to know whether AI Sam is still -; doing scripted turns. -IsAIPracticeScriptedTurn: ; 147f8 (5:47f8) - ld a, [wDuelTurns] - srl a - cp 7 - ccf - ret -; 0x14801 - -; places one Machop from the hand to the Play Area -; and sets the number of prizes to 2. -Func_14801: ; 14801 (5:4801) - call CreateHandCardList - ld hl, wDuelTempList -.loop_hand - ld a, [hli] - ldh [hTempCardIndex_ff98], a - cp $ff - ret z - call LoadCardDataToBuffer1_FromDeckIndex - cp MACHOP - jr nz, .loop_hand - ldh a, [hTempCardIndex_ff98] - call PutHandPokemonCardInPlayArea - ld a, 2 - ld [wDuelInitialPrizes], a - ret -; 0x1481f - -; outputs in a Play Area location of Raticate or Rattata -; in the Bench. If neither is found, just output PLAY_AREA_BENCH_1. -GetPlayAreaLocationOfRaticateOrRattata: ; 1481f (5:481f) - ld a, RATICATE - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - cp $ff - jr nz, .found - ld a, RATTATA - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - cp $ff - jr nz, .found - ld a, PLAY_AREA_BENCH_1 -.found - ldh [hTempPlayAreaLocation_ff9d], a - ret -; 0x1483a - -; has AI execute some scripted actions depending on Duel turn. -AIPerformSciptedTurn: ; 1483a (5:483a) - ld a, [wDuelTurns] - srl a - ld hl, .scripted_actions_list - call JumpToFunctionInTable - -; always attack with Arena card's first attack. -; if it's unusable end turn without attacking. - xor a - ldh [hTempPlayAreaLocation_ff9d], a - ld [wSelectedAttack], a - call CheckIfSelectedMoveIsUnusable - jr c, .unusable - call AITryUseAttack - ret - -.unusable - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x1485a - -.scripted_actions_list ; 1485a (05:485a) - dw .turn_1 - dw .turn_2 - dw .turn_3 - dw .turn_4 - dw .turn_5 - dw .turn_6 - dw .turn_7 -; 0x14868 - -.turn_1 ; 14868 (5:4868) - ld d, MACHOP - ld e, FIGHTING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x14870 - -.turn_2 ; 14870 (5:4870) - ld a, RATTATA - call LookForCardIDInHandList_Bank5 - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - ld d, RATTATA - ld e, FIGHTING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x14884 - -.turn_3 ; 14884 (5:4884) - ld a, RATTATA - ld b, PLAY_AREA_ARENA - call LookForCardIDInPlayArea_Bank5 - ldh [hTempPlayAreaLocation_ffa1], a - ld a, RATICATE - call LookForCardIDInHandList_Bank5 - ldh [hTemp_ffa0], a - ld a, OPPACTION_EVOLVE_PKMN - bank1call AIMakeDecision - ld d, RATICATE - ld e, LIGHTNING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x148a1 - -.turn_4 ; 148a1 (5:48a1) - ld d, RATICATE - ld e, LIGHTNING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x148a9 - -.turn_5 ; 148a9 (5:48a9) - ld a, MACHOP - call LookForCardIDInHandList_Bank5 - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - ld d, MACHOP - ld e, FIGHTING_ENERGY - call AIAttachEnergyInHandToCardInBench - -; this is a bug, it's attempting to compare a card ID with a deck index. -; the intention was to change the card to switch to depending on whether -; the first Machop was KO'd at this point in the Duel or not. -; because of the buggy comparison, this will always jump the -; 'inc a' instruction and switch to PLAY_AREA_BENCH_1. -; in a normal Practice Duel following Dr. Mason's instructions, -; this will always lead to the AI correctly switching Raticate with Machop, -; but in case of a "Free" Duel where the first Machop is not KO'd, -; the intention was to switch to PLAY_AREA_BENCH_2 instead. -; but due to 'inc a' always being skipped, it will switch to Raticate. - ld a, DUELVARS_ARENA_CARD - call GetTurnDuelistVariable - cp MACHOP ; wrong - ld a, PLAY_AREA_BENCH_1 - jr nz, .retreat - inc a ; PLAY_AREA_BENCH_2 - -.retreat - call AITryToRetreat - ret -; 0x148cc - -.turn_6 ; 148cc (5:48cc) - ld d, MACHOP - ld e, FIGHTING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x148d4 - -.turn_7 ; 148d4 (5:48d4) - ld d, MACHOP - ld e, FIGHTING_ENERGY - call AIAttachEnergyInHandToCardInPlayArea - ret -; 0x148dc - -INCLUDE "engine/deck_ai.asm" +INCLUDE "engine/deck_ai/deck_ai.asm" ; return carry if card ID loaded in a is found in hand ; and outputs in a the deck index of that card diff --git a/src/engine/deck_ai.asm b/src/engine/deck_ai.asm deleted file mode 100644 index 0bdbd5a..0000000 --- a/src/engine/deck_ai.asm +++ /dev/null @@ -1,2099 +0,0 @@ -; AI card retreat score bonus -; when the AI retreat routine runs through the Bench to choose -; a Pokemon to switch to, it looks up in this list and if -; a card ID matches, applies a retreat score bonus to this card. -; positive (negative) means more (less) likely to switch to this card. -ai_retreat: MACRO - db \1 ; card ID - db $80 + \2 ; retreat score (ranges between -128 and 127) -ENDM - -; AI card energy attach score bonus -; when the AI energy attachment routine runs through the Play Area to choose -; a Pokemon to attach an energy card, it looks up in this list and if -; a card ID matches, skips this card if the maximum number of energy -; cards attached has been reached. If it hasn't been reached, additionally -; applies a positive (or negative) AI score to attach energy to this card. -ai_energy: MACRO - db \1 ; card ID - db \2 ; maximum number of attached cards - db $80 + \3 ; energy score (ranges between -128 and 127) -ENDM - -; stores in WRAM pointer to data in argument -; e.g. store_list_pointer wSomeListPointer, SomeData -store_list_pointer: MACRO - ld hl, \1 - ld de, \2 - ld [hl], e - inc hl - ld [hl], d -ENDM - -; deck AIs are specialized to work on a given deck ID. -; they decide what happens during a turn, what Pokemon cards -; to pick during the start of the duel, etc. -; each of these have a pointer table with the following structure: -; dw .do_turn : never called; -; -; dw .do_turn : called to handle the main turn logic, from the beginning -; of the turn up to the attack (or lack thereof); -; -; dw .start_duel : called at the start of the duel to initialize some -; variables and optionally set up CPU hand and deck; -; -; dw .forced_switch : logic to determine what Pokemon to pick when there's -; an effect that forces AI to switch to Bench card; -; -; dw .ko_switch : logic for picking which card to use after a KO; -; -; dw .take_prize : logic to decide which prize card to pick. - -; optionally, decks can also declare card lists that will add -; more specialized logic during various generic AI routines, -; and read during the .start_duel routines. -; the pointers to these lists are stored in memory: -; wAICardListAvoidPrize : list of cards to avoid being placed as prize; -; wAICardListArenaPriority : priority list of Arena card at duel start; -; wAICardListBenchPriority : priority list of Bench cards at duel start; -; wAICardListPlayFromHandPriority : priority list of cards to play from hand; -; wAICardListRetreatBonus : scores given to certain cards for retreat; -; wAICardListEnergyBonus : max number of energy cards and card scores. - -AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 148e8 (5:48e8) - call AIDoTurn_GeneralNoRetreat - ret -; 0x148ec - -.start_duel ; 148ec (5:48ec) - call InitAIDuelVars - call AIPlayInitialBasicCards - ret -; 0x148f3 - -.forced_switch ; 148f3 (5:48f3) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x148f7 - -.ko_switch ; 148f7 (5:48f7) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x148fb - -.take_prize ; 148fb (5:48fb) - call AIPickPrizeCards - ret -; 0x148ff - -AIDoTurn_GeneralNoRetreat: ; 148ff (5:48ff) -; initialize variables - call InitAITurnVars - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; handle Pkmn Powers - farcall HandleAIGoGoRainDanceEnergy - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAICowardice -; process Trainer cards -; phase 2 through 4. - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_03 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended -; process Trainer cards -; phase 5 through 12. - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_06 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_08 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_12 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_1 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_1 -; play Pokemon from hand again - call AIDecidePlayPokemonCard -; handle Pkmn Powers again - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAIGoGoRainDanceEnergy - ld a, AI_ENERGY_TRANS_ATTACK - farcall HandleAIEnergyTrans -; process Trainer cards phases 13 and 15 - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_15 - call AIProcessHandTrainerCards -; if used Professor Oak, process new hand -; if not, then proceed to attack. - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK - jr z, .try_attack - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_03 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_06 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_08 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_12 - call AIProcessHandTrainerCards - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_2 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_2 - call AIDecidePlayPokemonCard - farcall HandleAIDamageSwap - farcall HandleAIPkmnPowers - ret c ; return if turn ended - farcall HandleAIGoGoRainDanceEnergy - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - ; skip AI_TRAINER_CARD_PHASE_15 -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if turn ended - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x149e8 - -AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 149f4 (5:49f4) - call AIDoTurn_LegendaryMoltres - ret -; 0x149f8 - -.start_duel ; 149f8 (5:49f8) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc ; Play Area set up was successful - call AIPlayInitialBasicCards - ret -; 0x14a09 - -.forced_switch ; 14a09 (5:4a09) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14a0d - -.ko_switch ; 14a0d (5:4a0d) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14a11 - -.take_prize ; 14a11 (5:4a11) - call AIPickPrizeCards - ret -; 0x14a15 - -.list_arena ; 14a15 (5:4a15) - db MAGMAR2 - db GROWLITHE - db VULPIX - db MAGMAR1 - db MOLTRES1 - db MOLTRES2 - db $00 - -.list_bench ; 14a1c (5:4a1c) - db MOLTRES1 - db VULPIX - db GROWLITHE - db MAGMAR2 - db MAGMAR1 - db $00 - -.list_play_hand ; 14a22 (5:4a22) - db MOLTRES2 - db MOLTRES1 - db VULPIX - db GROWLITHE - db MAGMAR2 - db MAGMAR1 - db $00 - -.list_retreat ; 14a29 (5:4a29) - ai_retreat GROWLITHE, -5 - ai_retreat VULPIX, -5 - db $00 - -.list_energy ; 14a2e (5:4a2e) - ai_energy VULPIX, 3, +0 - ai_energy NINETAILS2, 3, +1 - ai_energy GROWLITHE, 3, +1 - ai_energy ARCANINE2, 4, +1 - ai_energy MAGMAR1, 4, -1 - ai_energy MAGMAR2, 1, -1 - ai_energy MOLTRES2, 3, +2 - ai_energy MOLTRES1, 4, +2 - db $00 - -.list_prize ; 14a47 (5:4a47) - db ENERGY_REMOVAL - db MOLTRES2 - db $00 - -.store_list_pointers ; 14a4a (5:4a4a) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand - store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14a81 - -AIDoTurn_LegendaryMoltres: ; 14a81 (5:4a81) -; initialize variables - call InitAITurnVars - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; process Trainer cards -; phase 2 through 4. - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - -; check if AI can play Moltres2 -; from hand and if so, play it. - ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA - call GetTurnDuelistVariable - cp MAX_PLAY_AREA_POKEMON - jr nc, .skip_moltres ; skip if bench is full - ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK - call GetTurnDuelistVariable - cp DECK_SIZE - 9 - jr nc, .skip_moltres ; skip if cards in deck <= 9 - ld a, MUK - call CountPokemonIDInBothPlayAreas - jr c, .skip_moltres ; skip if Muk in play - ld a, MOLTRES2 - call LookForCardIDInHandList_Bank5 - jr nc, .skip_moltres ; skip if no Moltres2 in hand - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - -.skip_moltres -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_attach_energy - -; if Magmar2 is the Arena card and has no energy attached, -; try attaching an energy card to it from the hand. -; otherwise, run normal AI energy attach routine. - ld a, DUELVARS_ARENA_CARD - call GetTurnDuelistVariable - call GetCardIDFromDeckIndex - ld a, MAGMAR2 - cp e - jr nz, .attach_normally - ; Magmar2 is the Arena card - call CreateEnergyCardListFromHand - jr c, .skip_attach_energy - ld e, PLAY_AREA_ARENA - call CountNumberOfEnergyCardsAttached - or a - jr nz, .attach_normally - xor a ; PLAY_AREA_ARENA - ldh [hTempPlayAreaLocation_ff9d], a - call AITryToPlayEnergyCard - jr c, .skip_attach_energy - -.attach_normally -; play Energy card if possible - call AIProcessAndTryToPlayEnergy -.skip_attach_energy -; try playing Pokemon cards from hand again - call AIDecidePlayPokemonCard - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14b0f - -AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14b1b (5:4b1b) - call AIDoTurn_LegendaryZapdos - ret -; 0x14b1f - -.start_duel ; 14b1f (5:4b1f) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14b30 - -.forced_switch ; 14b30 (5:4b30) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14b34 - -.ko_switch ; 14b34 (5:4b34) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14b38 - -.take_prize ; 14b38 (5:4b38) - call AIPickPrizeCards - ret -; 0x14b3c - -.list_arena ; 14b3c (5:4b3c) - db ELECTABUZZ2 - db VOLTORB - db EEVEE - db ZAPDOS1 - db ZAPDOS2 - db ZAPDOS3 - db $00 - -.list_bench ; 14b43 (5:4b43) - db ZAPDOS2 - db ZAPDOS1 - db EEVEE - db VOLTORB - db ELECTABUZZ2 - db $00 - -.list_retreat ; 14b49 (5:4b49) - ai_retreat EEVEE, -5 - ai_retreat VOLTORB, -5 - ai_retreat ELECTABUZZ2, -5 - db $00 - -.list_energy ; 14b50 (5:4b50) - ai_energy VOLTORB, 1, -1 - ai_energy ELECTRODE1, 3, +0 - ai_energy ELECTABUZZ2, 2, -1 - ai_energy JOLTEON2, 3, +1 - ai_energy ZAPDOS1, 4, +2 - ai_energy ZAPDOS2, 4, +2 - ai_energy ZAPDOS3, 3, +1 - ai_energy EEVEE, 3, +0 - db $00 - -.list_prize ; 14b69 (5:4b69) - db GAMBLER - db ZAPDOS3 - db $00 - -.store_list_pointers ; 14b6c (5:4b6c) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14b9a - -AIDoTurn_LegendaryZapdos: ; 14b9a (5:4b9a) -; initialize variables - call InitAITurnVars - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards -; play Energy card if possible. - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach - -; if Arena card is Voltorb and there's Electrode1 in hand, -; or if it's Electabuzz, try attaching Energy card -; to the Arena card if it doesn't have any energy attached. -; Otherwise if Energy card is not needed, -; go through normal AI energy attach routine. - ld a, DUELVARS_ARENA_CARD - call GetTurnDuelistVariable - call GetCardIDFromDeckIndex - ld a, VOLTORB - cp e - jr nz, .check_electabuzz - ld a, ELECTRODE1 - call LookForCardIDInHandList_Bank5 - jr nc, .attach_normally - jr .voltorb_or_electabuzz -.check_electabuzz - ld a, ELECTABUZZ2 - cp e - jr nz, .attach_normally - -.voltorb_or_electabuzz - call CreateEnergyCardListFromHand - jr c, .skip_energy_attach - ld e, PLAY_AREA_ARENA - call CountNumberOfEnergyCardsAttached - or a - jr nz, .attach_normally - xor a ; PLAY_AREA_ARENA - ldh [hTempPlayAreaLocation_ff9d], a - call AITryToPlayEnergyCard - jr c, .skip_energy_attach - -.attach_normally - call AIProcessAndTryToPlayEnergy - -.skip_energy_attach -; play Pokemon from hand again - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if turn ended - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14c0b - -AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14c17 (5:4c17) - call AIDoTurn_LegendaryArticuno - ret -; 0x14c1b - -.start_duel ; 14c1b (5:4c1b) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14c2c - -.forced_switch ; 14c2c (5:4c2c) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14c30 - -.ko_switch ; 14c30 (5:4c30) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14c34 - -.take_prize ; 14c34 (5:4c34) - call AIPickPrizeCards - ret -; 0x14c38 - -.list_arena ; 14c38 (5:4c38) - db CHANSEY - db LAPRAS - db DITTO - db SEEL - db ARTICUNO1 - db ARTICUNO2 - db $00 - -.list_bench ; 14c3f (5:4c3f) - db ARTICUNO1 - db SEEL - db LAPRAS - db CHANSEY - db DITTO - db $00 - -.list_retreat ; 14c45 (5:4c45) - ai_retreat SEEL, -3 - ai_retreat DITTO, -3 - db $00 - -.list_energy ; 14c4a (5:4c4a) - ai_energy SEEL, 3, +1 - ai_energy DEWGONG, 4, +0 - ai_energy LAPRAS, 3, +0 - ai_energy ARTICUNO1, 4, +1 - ai_energy ARTICUNO2, 3, +0 - ai_energy CHANSEY, 0, -8 - ai_energy DITTO, 3, +0 - db $00 - -.list_prize ; 14c60 (5:4c60) - db GAMBLER - db ARTICUNO2 - db $00 - -.store_list_pointers ; 14c63 (5:4c63) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14c91 - -; this routine handles how Legendary Articuno -; prioritises playing energy cards to each Pokémon. -; first, it makes sure that all Lapras have at least -; 3 energy cards before moving on to Articuno, -; and then to Dewgong and Seel -ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) - call SwapTurn - call CountPrizes - call SwapTurn - cp 3 - ret c - -; player prizes >= 3 -; if Lapras has more than half HP and -; can use second move, check next for Articuno -; otherwise, check if Articuno or Dewgong -; have more than half HP and can use second move -; and if so, the next Pokémon to check is Lapras - ld a, LAPRAS - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .articuno - ld a, ARTICUNO1 - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .lapras - ld a, DEWGONG - call CheckForBenchIDAtHalfHPAndCanUseSecondMove - jr c, .lapras - jr .articuno - -; the following routines check for certain card IDs in bench -; and call RaiseAIScoreToAllMatchingIDsInBench if these are found. -; for Lapras, an additional check is made to its -; attached energy count, which skips calling the routine -; if this count is >= 3 -.lapras - ld a, LAPRAS - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .articuno - ld e, a - call CountNumberOfEnergyCardsAttached - cp 3 - jr nc, .articuno - ld a, LAPRAS - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.articuno - ld a, ARTICUNO1 - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .dewgong - ld a, ARTICUNO1 - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.dewgong - ld a, DEWGONG - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - jr nc, .seel - ld a, DEWGONG - call RaiseAIScoreToAllMatchingIDsInBench - ret - -.seel - ld a, SEEL - ld b, PLAY_AREA_BENCH_1 - call LookForCardIDInPlayArea_Bank5 - ret nc - ld a, SEEL - call RaiseAIScoreToAllMatchingIDsInBench - ret -; 0x14cf7 - -AIDoTurn_LegendaryArticuno: ; 14cf7 (5:4cf7) -; initialize variables - call InitAITurnVars - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_1 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_1 -; play Pokemon from hand again - call AIDecidePlayPokemonCard -; process Trainer cards phases 13 and 15 - ld a, AI_TRAINER_CARD_PHASE_13 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_15 - call AIProcessHandTrainerCards -; if used Professor Oak, process new hand - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK - jr z, .try_attack - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - call AIDecidePlayPokemonCard - ret c ; return if turn ended - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_2 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_2 - call AIDecidePlayPokemonCard -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if turn ended - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14d60 - -AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14d6c (5:4d6c) - call AIDoTurn_LegendaryDragonite - ret -; 0x14d70 - -.start_duel ; 14d70 (5:4d70) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14d81 - -.forced_switch ; 14d81 (5:4d81) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14d85 - -.ko_switch ; 14d85 (5:4d85) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14d89 - -.take_prize ; 14d89 (5:4d89) - call AIPickPrizeCards - ret -; 0x14d8d - -.list_arena ; 14d8d (5:4d8d) - db KANGASKHAN - db LAPRAS - db CHARMANDER - db DRATINI - db MAGIKARP - db $00 - -.list_bench ; 14d93 (5:4d93) - db CHARMANDER - db MAGIKARP - db DRATINI - db LAPRAS - db KANGASKHAN - db $00 - -.list_retreat ; 14d99 (5:4d99) - ai_retreat CHARMANDER, -1 - ai_retreat MAGIKARP, -5 - db $00 - -.list_energy ; 14d9e (5:4d9e) - ai_energy CHARMANDER, 3, +1 - ai_energy CHARMELEON, 4, +1 - ai_energy CHARIZARD, 5, +0 - ai_energy MAGIKARP, 3, +1 - ai_energy GYARADOS, 4, -1 - ai_energy DRATINI, 2, +0 - ai_energy DRAGONAIR, 4, +0 - ai_energy DRAGONITE1, 3, -1 - ai_energy KANGASKHAN, 2, -2 - ai_energy LAPRAS, 3, +0 - db $00 - -.list_prize ; 14dbd (5:4dbd) - db GAMBLER - db DRAGONITE1 - db KANGASKHAN - db $00 - -.store_list_pointers ; 14dc1 (5:4dc1) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14def - -AIDoTurn_LegendaryDragonite: ; 14def (5:4def) -; initialize variables - call InitAITurnVars - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - farcall HandleAIAntiMewtwoDeckStrategy - jp nc, .try_attack -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_1 - -; if Arena card is Kangaskhan and doens't -; have Energy cards attached, try attaching from hand. -; otherwise run normal AI energy attach routine. - ld a, DUELVARS_ARENA_CARD - call GetTurnDuelistVariable - call GetCardIDFromDeckIndex - ld a, KANGASKHAN - cp e - jr nz, .attach_normally - call CreateEnergyCardListFromHand - jr c, .skip_energy_attach_1 - ld e, PLAY_AREA_ARENA - call CountNumberOfEnergyCardsAttached - or a - jr nz, .attach_normally - xor a - ldh [hTempPlayAreaLocation_ff9d], a - call AITryToPlayEnergyCard - jr c, .skip_energy_attach_1 -.attach_normally - call AIProcessAndTryToPlayEnergy - -.skip_energy_attach_1 -; play Pokemon from hand again - call AIDecidePlayPokemonCard - ld a, AI_TRAINER_CARD_PHASE_15 - call AIProcessHandTrainerCards -; if used Professor Oak, process new hand -; if not, then proceed to attack. - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK - jr z, .try_attack - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_11 - call AIProcessHandTrainerCards - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_energy_attach_2 - call AIProcessAndTryToPlayEnergy -.skip_energy_attach_2 - call AIDecidePlayPokemonCard -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if turn ended - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x14e89 - -AIActionTable_FirstStrike: ; 14e89 (5:4e89) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14e95 (5:4e95) - call AIMainTurnLogic - ret -; 0x14e99 - -.start_duel ; 14e99 (5:4e99) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14eaa - -.forced_switch ; 14eaa (5:4eaa) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14eae - -.ko_switch ; 14eae (5:4eae) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14eb2 - -.take_prize ; 14eb2 (5:4eb2) - call AIPickPrizeCards - ret -; 0x14eb6 - -.list_arena ; 14eb6 (5:1eb6) - db HITMONCHAN - db MACHOP - db HITMONLEE - db MANKEY - db $00 - -.list_bench ; 14ebb (5:1ebb) - db MACHOP - db HITMONLEE - db HITMONCHAN - db MANKEY - db $00 - -.list_retreat ; 14ec0 (5:1ec0) - ai_retreat MACHOP, -1 - ai_retreat MACHOKE, -1 - ai_retreat MANKEY, -2 - db $00 - -.list_energy ; 14ec7 (5:1ec7) - ai_energy MACHOP, 3, +0 - ai_energy MACHOKE, 4, +0 - ai_energy MACHAMP, 4, -1 - ai_energy HITMONCHAN, 3, +0 - ai_energy HITMONLEE, 3, +0 - ai_energy MANKEY, 2, -1 - ai_energy PRIMEAPE, 3, -1 - db $00 - -.list_prize ; 14edd (5:1edd) - db HITMONLEE - db HITMONCHAN - db $00 - -.store_list_pointers ; 14ee0 (5:4ee0) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14f0e - -AIActionTable_RockCrusher: ; 14f0e (5:4f0e) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14f1a (5:4f1a) - call AIMainTurnLogic - ret -; 0x14f1e - -.start_duel ; 14f1e (5:4f1e) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14f2f - -.forced_switch ; 14f2f (5:4f2f) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14f33 - -.ko_switch ; 14f33 (5:4f33) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14f37 - -.take_prize ; 14f37 (5:4f37) - call AIPickPrizeCards - ret -; 0x14f3b - -.list_arena ; 14f3b (5:4f3b) - db RHYHORN - db ONIX - db GEODUDE - db DIGLETT - db $00 - -.list_bench ; 14f40 (5:4f40) - db DIGLETT - db GEODUDE - db RHYHORN - db ONIX - db $00 - -.list_retreat ; 14f45 (5:4f45) - ai_retreat DIGLETT, -1 - db $00 - -.list_energy ; 14f48 (5:4f48) - ai_energy DIGLETT, 3, +1 - ai_energy DUGTRIO, 4, +0 - ai_energy GEODUDE, 2, +1 - ai_energy GRAVELER, 3, +0 - ai_energy GOLEM, 4, +0 - ai_energy ONIX, 2, -1 - ai_energy RHYHORN, 3, +0 - db $00 - -.list_prize ; 14f5e (5:4f5e) - db ENERGY_REMOVAL - db RHYHORN - db $00 - -.store_list_pointers ; 14f61 (5:4f61) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x14f8f - -AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 14f9b (5:4f9b) - call AIMainTurnLogic - ret -; 0x14f9f - -.start_duel ; 14f9f (5:4f9f) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x14fb0 - -.forced_switch ; 14fb0 (5:4fb0) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14fb4 - -.ko_switch ; 14fb4 (5:4fb4) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x14fb8 - -.take_prize ; 14fb8 (5:4fb8) - call AIPickPrizeCards - ret -; 0x14fbc - -.list_arena ; 14fbc (5:4fbc) - db LAPRAS - db HORSEA - db GOLDEEN - db SQUIRTLE - db $00 - -.list_bench ; 14fc1 (5:4fc1) - db SQUIRTLE - db HORSEA - db GOLDEEN - db LAPRAS - db $00 - -.list_retreat ; 14fc6 (5:4fc6) - ai_retreat SQUIRTLE, -3 - ai_retreat WARTORTLE, -2 - ai_retreat HORSEA, -1 - db $00 - -.list_energy ; 14fcd (5:4fcd) - ai_energy SQUIRTLE, 2, +0 - ai_energy WARTORTLE, 3, +0 - ai_energy BLASTOISE, 5, +0 - ai_energy GOLDEEN, 1, +0 - ai_energy SEAKING, 2, +0 - ai_energy HORSEA, 2, +0 - ai_energy SEADRA, 3, +0 - ai_energy LAPRAS, 3, +0 - db $00 - -.list_prize ; 14fe6 (5:4fe6) - db GAMBLER - db ENERGY_RETRIEVAL - db SUPER_ENERGY_RETRIEVAL - db BLASTOISE - db $00 - -.store_list_pointers ; 14feb (5:4feb) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x15019 - -AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 15025 (5:5025) - call AIMainTurnLogic - ret -; 0x15029 - -.start_duel ; 15029 (5:5029) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x1503a - -.forced_switch ; 1503a (5:503a) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1503e - -.ko_switch ; 1503e (5:503e) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15042 - -.take_prize ; 15042 (5:5042) - call AIPickPrizeCards - ret -; 0x15046 - -.list_arena ; 15046 (5:5046) - db KANGASKHAN - db ELECTABUZZ2 - db TAUROS - db MAGNEMITE1 - db VOLTORB - db $00 - -.list_bench ; 1504c (5:504c) - db MAGNEMITE1 - db VOLTORB - db ELECTABUZZ2 - db TAUROS - db KANGASKHAN - db $00 - -.list_retreat ; 15052 (5:5052) - ai_retreat VOLTORB, -1 - db $00 - -.list_energy ; 15055 (5:5055) - ai_energy MAGNEMITE1, 3, +1 - ai_energy MAGNETON1, 4, +0 - ai_energy VOLTORB, 3, +1 - ai_energy ELECTRODE1, 3, +0 - ai_energy ELECTABUZZ2, 1, +0 - ai_energy KANGASKHAN, 2, -2 - ai_energy TAUROS, 3, +0 - db $00 - -.list_prize ; 1506b (5:506b) - db KANGASKHAN - db $00 - -.store_list_pointers ; 1506d (5:506d) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x1509b - -AIActionTable_FlowerPower: ; 1509b (5:509b) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 150a7 (5:50a7) - call AIMainTurnLogic - ret -; 0x150ab - -.start_duel ; 150ab (5:50ab) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x150bc - -.forced_switch ; 150bc (5:50bc) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x150c0 - -.ko_switch ; 150c0 (5:50c0) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x150c4 - -.take_prize ; 150c4 (5:50c4) - call AIPickPrizeCards - ret -; 0x150c8 - -.list_arena ; 150c8 (5:50c8) - db ODDISH - db EXEGGCUTE - db BULBASAUR - db $00 - -.list_bench ; 150cc (5:50cc) - db BULBASAUR - db EXEGGCUTE - db ODDISH - db $00 - -.list_retreat ; 150cf (5:50cf) - ai_retreat GLOOM, -2 - ai_retreat VILEPLUME, -2 - ai_retreat BULBASAUR, -2 - ai_retreat IVYSAUR, -2 - db $00 - -.list_energy ; 150d9 (5:50d9) - ai_energy BULBASAUR, 3, +0 - ai_energy IVYSAUR, 4, +0 - ai_energy VENUSAUR2, 4, +0 - ai_energy ODDISH, 2, +0 - ai_energy GLOOM, 3, -1 - ai_energy VILEPLUME, 3, -1 - ai_energy EXEGGCUTE, 3, +0 - ai_energy EXEGGUTOR, 22, +0 - db $00 - -.list_prize ; 150f2 (5:50f2) - db VENUSAUR2 - db $00 - -.store_list_pointers ; 150f4 (5:50f4) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x15122 - -AIActionTable_StrangePsyshock: ; 15122 (5:5122) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 1512e (5:512e) - call AIMainTurnLogic - ret -; 0x15132 - -.start_duel ; 15132 (5:5132) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15143 - -.forced_switch ; 15143 (5:5143) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15147 - -.ko_switch ; 15147 (5:5147) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1514b - -.take_prize ; 1514b (5:514b) - call AIPickPrizeCards - ret -; 0x1514f - -.list_arena ; 1514f (5:514f) - db KANGASKHAN - db CHANSEY - db SNORLAX - db MR_MIME - db ABRA - db $00 - -.list_bench ; 15155 (5:5155) - db ABRA - db MR_MIME - db KANGASKHAN - db SNORLAX - db CHANSEY - db $00 - -.list_retreat ; 1515b (5:515b) - ai_retreat ABRA, -3 - ai_retreat SNORLAX, -3 - ai_retreat KANGASKHAN, -1 - ai_retreat CHANSEY, -1 - db $00 - -.list_energy ; 15164 (5:5164) - ai_energy ABRA, 3, +1 - ai_energy KADABRA, 3, +0 - ai_energy ALAKAZAM, 3, +0 - ai_energy MR_MIME, 2, +0 - ai_energy CHANSEY, 2, -2 - ai_energy KANGASKHAN, 4, -2 - ai_energy SNORLAX, 0, -8 - db $00 - -.list_prize ; 1517a (5:517a) - db GAMBLER - db MR_MIME - db ALAKAZAM - db SWITCH - db $00 - -.store_list_pointers ; 1517f (5:517f) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x151ad - -AIActionTable_WondersOfScience: ; 151ad (5:51ad) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 151b9 (5:51b9) - call AIMainTurnLogic - ret -; 0x151bd - -.start_duel ; 151bd (5:51bd) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x151ce - -.forced_switch ; 151ce (5:51ce) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x151d2 - -.ko_switch ; 151d2 (5:51d2) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x151d6 - -.take_prize ; 151d6 (5:51d6) - call AIPickPrizeCards - ret -; 0x151da - -.list_arena ; 151da (5:51da) - db MEWTWO1 - db MEWTWO3 - db MEWTWO2 - db GRIMER - db KOFFING - db PORYGON - db $00 - -.list_bench ; 151e1 (5:51e1) - db GRIMER - db KOFFING - db MEWTWO3 - db MEWTWO2 - db MEWTWO1 - db PORYGON - db $00 - -.list_retreat ; 151e8 (5:51e8) - db $00 - -.list_energy ; 151e9 (5:51e9) - ai_energy GRIMER, 3, +0 - ai_energy MUK, 4, +0 - ai_energy KOFFING, 2, +0 - ai_energy WEEZING, 3, +0 - ai_energy MEWTWO1, 2, -1 - ai_energy MEWTWO3, 2, -1 - ai_energy MEWTWO2, 2, -1 - ai_energy PORYGON, 2, -1 - db $00 - -.list_prize ; 15202 (5:5202) - db MUK - db $00 - -.store_list_pointers ; 15204 (5:5204) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x15232 - -AIActionTable_FireCharge: ; 15232 (5:5232) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 1523e (5:523e) - call AIMainTurnLogic - ret -; 0x15242 - -.start_duel ; 15242 (5:5242) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15253 - -.forced_switch ; 15253 (5:5253) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15257 - -.ko_switch ; 15257 (5:5257) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1525b - -.take_prize ; 1525b (5:525b) - call AIPickPrizeCards - ret -; 0x1525f - -.list_arena ; 1525f (5:525f) - db JIGGLYPUFF3 - db CHANSEY - db TAUROS - db MAGMAR1 - db JIGGLYPUFF1 - db GROWLITHE - db $00 - -.list_bench ; 15266 (5:5266) - db JIGGLYPUFF3 - db CHANSEY - db GROWLITHE - db MAGMAR1 - db JIGGLYPUFF1 - db TAUROS - db $00 - -.list_retreat ; 1526e (5:526e) - ai_retreat JIGGLYPUFF1, -1 - ai_retreat CHANSEY, -1 - ai_retreat GROWLITHE, -1 - db $00 - -.list_energy ; 15274 (5:5274) - ai_energy GROWLITHE, 3, +0 - ai_energy ARCANINE2, 4, +0 - ai_energy MAGMAR1, 3, +0 - ai_energy JIGGLYPUFF1, 3, +0 - ai_energy JIGGLYPUFF3, 2, +0 - ai_energy WIGGLYTUFF, 3, +0 - ai_energy CHANSEY, 4, +0 - ai_energy TAUROS, 3, +0 - db $00 - -.list_prize ; 1528d (5:528d) - db GAMBLER - db $00 - -.store_list_pointers ; 1528f (5:528f) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x152bd - -AIActionTable_ImRonald: ; 152bd (5:52bd) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 152c9 (5:52c9) - call AIMainTurnLogic - ret -; 0x152cd - -.start_duel ; 152cd (5:52cd) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x152de - -.forced_switch ; 152de (5:52de) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x152e2 - -.ko_switch ; 152e2 (5:52e2) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x152e6 - -.take_prize ; 152e6 (5:52e6) - call AIPickPrizeCards - ret -; 0x152ea - -.list_arena ; 152ea (5:52ea) - db LAPRAS - db SEEL - db CHARMANDER - db CUBONE - db SQUIRTLE - db GROWLITHE - db $00 - -.list_bench ; 152f1 (5:52f1) - db CHARMANDER - db SQUIRTLE - db SEEL - db CUBONE - db GROWLITHE - db LAPRAS - db $00 - -.list_retreat ; 152f8 (5:52f8) - db $00 - -.list_energy ; 152f9 (5:52f9) - ai_energy CHARMANDER, 3, +0 - ai_energy CHARMELEON, 5, +0 - ai_energy GROWLITHE, 2, +0 - ai_energy ARCANINE2, 4, +0 - ai_energy SQUIRTLE, 2, +0 - ai_energy WARTORTLE, 3, +0 - ai_energy SEEL, 3, +0 - ai_energy DEWGONG, 4, +0 - ai_energy LAPRAS, 3, +0 - ai_energy CUBONE, 3, +0 - ai_energy MAROWAK1, 3, +0 - db $00 - -.list_prize ; 1531b (5:531b) - db LAPRAS - db $00 - -.store_list_pointers ; 1531d (5:531d) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x1534b - -AIActionTable_PowerfulRonald: ; 1534b (5:534b) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 15357 (5:5357) - call AIMainTurnLogic - ret -; 0x1535b - -.start_duel ; 1535b (5:535b) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x1536c - -.forced_switch ; 1536c (5:536c) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15370 - -.ko_switch ; 15370 (5:5370) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15374 - -.take_prize ; 15374 (5:5374) - call AIPickPrizeCards - ret -; 0x15378 - -.list_arena ; 15378 (5:5378) - db KANGASKHAN - db ELECTABUZZ2 - db HITMONCHAN - db MR_MIME - db LICKITUNG - db HITMONLEE - db TAUROS - db JYNX - db MEWTWO1 - db DODUO - db $00 - -.list_bench ; 15383 (5:5383) - db KANGASKHAN - db HITMONLEE - db HITMONCHAN - db TAUROS - db DODUO - db JYNX - db MEWTWO1 - db ELECTABUZZ2 - db MR_MIME - db LICKITUNG - db $00 - -.list_retreat ; 1538e (5:538e) - ai_retreat KANGASKHAN, -1 - ai_retreat DODUO, -1 - ai_retreat DODRIO, -1 - db $00 - -.list_energy ; 15395 (5:5395) - ai_energy ELECTABUZZ2, 2, +1 - ai_energy HITMONLEE, 3, +1 - ai_energy HITMONCHAN, 3, +1 - ai_energy MR_MIME, 2, +0 - ai_energy JYNX, 3, +0 - ai_energy MEWTWO1, 2, +0 - ai_energy DODUO, 3, -1 - ai_energy DODRIO, 3, -1 - ai_energy LICKITUNG, 2, +0 - ai_energy KANGASKHAN, 4, -1 - ai_energy TAUROS, 3, +0 - db $00 - -.list_prize ; 153b7 (5:53b7) - db GAMBLER - db ENERGY_REMOVAL - db $00 - -.store_list_pointers ; 153ba (5:53ba) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x153e8 - -AIActionTable_InvincibleRonald: ; 153e8 (5:53e8) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 153f4 (5:53f4) - call AIMainTurnLogic - ret -; 0x153f8 - -.start_duel ; 153f8 (5:53f8) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15409 - -.forced_switch ; 15409 (5:5409) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x1540d - -.ko_switch ; 1540d (5:540d) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15411 - -.take_prize ; 15411 (5:5411) - call AIPickPrizeCards - ret -; 0x15415 - -.list_arena ; 15415 (5:5415) - db KANGASKHAN - db MAGMAR2 - db CHANSEY - db GEODUDE - db SCYTHER - db GRIMER - db $00 - -.list_bench ; 1541c (5:541c) - db GRIMER - db SCYTHER - db GEODUDE - db CHANSEY - db MAGMAR2 - db KANGASKHAN - db $00 - -.list_retreat ; 15423 (5:5423) - ai_retreat GRIMER, -1 - db $00 - -.list_energy ; 15426 (5:5426) - ai_energy GRIMER, 1, -1 - ai_energy MUK, 3, -1 - ai_energy SCYTHER, 4, +1 - ai_energy MAGMAR2, 2, +0 - ai_energy GEODUDE, 2, +0 - ai_energy GRAVELER, 3, +0 - ai_energy CHANSEY, 4, +0 - ai_energy KANGASKHAN, 4, -1 - db $00 - -.list_prize ; 1543f (5:543f) - db GAMBLER - db $00 - -.store_list_pointers ; 15441 (5:5441) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_bench - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x1546f - -AIActionTable_LegendaryRonald: ; 1546f (5:546f) - dw .do_turn ; unused - dw .do_turn - dw .start_duel - dw .forced_switch - dw .ko_switch - dw .take_prize - -.do_turn ; 1547b (5:547b) - call AIDoTurn_LegendaryRonald - ret -; 0x1547f - -.start_duel ; 1547f (5:547f) - call InitAIDuelVars - call .store_list_pointers - call SetUpBossStartingHandAndDeck - call TrySetUpBossStartingPlayArea - ret nc - call AIPlayInitialBasicCards - ret -; 0x15490 - -.forced_switch ; 15490 (5:5490) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15494 - -.ko_switch ; 15494 (5:5494) - call AIDecideBenchPokemonToSwitchTo - ret -; 0x15498 - -.take_prize ; 15498 (5:5498) - call AIPickPrizeCards - ret -; 0x1549c - -.list_arena ; 1549c (5:549c) - db KANGASKHAN - db DRATINI - db EEVEE - db ZAPDOS3 - db ARTICUNO2 - db MOLTRES2 - db $00 - -.list_bench ; 154a3 (5:54a3) - db KANGASKHAN - db DRATINI - db EEVEE - db $00 - -.list_play_hand ; 154a7 (5:54a7) - db MOLTRES2 - db ZAPDOS3 - db KANGASKHAN - db DRATINI - db EEVEE - db ARTICUNO2 - db $00 - -.list_retreat ; 154ae (5:54ae) - ai_retreat EEVEE, -2 - db $00 - -.list_energy ; 154b1 (5:54b1) - ai_energy FLAREON1, 3, +0 - ai_energy MOLTRES2, 3, +0 - ai_energy VAPOREON1, 3, +0 - ai_energy ARTICUNO2, 0, -8 - ai_energy JOLTEON1, 4, +0 - ai_energy ZAPDOS3, 0, -8 - ai_energy KANGASKHAN, 4, -1 - ai_energy EEVEE, 3, +0 - ai_energy DRATINI, 3, +0 - ai_energy DRAGONAIR, 4, +0 - ai_energy DRAGONITE1, 3, +0 - db $00 - -.list_prize ; 154d3 (5:54d3) - db MOLTRES2 - db ARTICUNO2 - db ZAPDOS3 - db DRAGONITE1 - db GAMBLER - db $00 - -.store_list_pointers ; 154d9 (5:54d9) - store_list_pointer wAICardListAvoidPrize, .list_prize - store_list_pointer wAICardListArenaPriority, .list_arena - store_list_pointer wAICardListBenchPriority, .list_bench - store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand - ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat - store_list_pointer wAICardListEnergyBonus, .list_energy - ret -; 0x15507 - -AIDoTurn_LegendaryRonald: ; 15507 (5:5507) -; initialize variables - call InitAITurnVars -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - -; check if AI can play Moltres2 -; from hand and if so, play it. - ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA - call GetTurnDuelistVariable - cp MAX_PLAY_AREA_POKEMON - jr nc, .skip_moltres_1 ; skip if bench is full - ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK - call GetTurnDuelistVariable - cp DECK_SIZE - 9 - jr nc, .skip_moltres_1 ; skip if cards in deck <= 9 - ld a, MUK - call CountPokemonIDInBothPlayAreas - jr c, .skip_moltres_1 ; skip if Muk in play - ld a, MOLTRES2 - call LookForCardIDInHandList_Bank5 - jr nc, .skip_moltres_1 ; skip if no Moltres2 in hand - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - -.skip_moltres_1 -; play Pokemon from hand - call AIDecidePlayPokemonCard - ret c ; return if turn ended -; process Trainer cards - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards -; play Energy card if possible - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_attach_energy_1 - call AIProcessAndTryToPlayEnergy -.skip_attach_energy_1 -; try playing Pokemon cards from hand again - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_15 -; if used Professor Oak, process new hand -; if not, then proceed to attack. - call AIProcessHandTrainerCards - ld a, [wPreviousAIFlags] - and AI_FLAG_USED_PROFESSOR_OAK - jr z, .try_attack - ld a, AI_TRAINER_CARD_PHASE_01 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_02 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_04 - call AIProcessHandTrainerCards - -; check if AI can play Moltres2 -; from hand and if so, play it. - ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA - call GetTurnDuelistVariable - cp MAX_PLAY_AREA_POKEMON - jr nc, .skip_moltres_2 ; skip if bench is full - ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK - call GetTurnDuelistVariable - cp DECK_SIZE - 9 - jr nc, .skip_moltres_2 ; skip if cards in deck <= 9 - ld a, MUK - call CountPokemonIDInBothPlayAreas - jr c, .skip_moltres_2 ; skip if Muk in play - ld a, MOLTRES2 - call LookForCardIDInHandList_Bank5 - jr nc, .skip_moltres_2 ; skip if no Moltres2 in hand - ldh [hTemp_ffa0], a - ld a, OPPACTION_PLAY_BASIC_PKMN - bank1call AIMakeDecision - -.skip_moltres_2 - call AIDecidePlayPokemonCard - ret c ; return if turn ended - ld a, AI_TRAINER_CARD_PHASE_05 - call AIProcessHandTrainerCards - ld a, AI_TRAINER_CARD_PHASE_07 - call AIProcessHandTrainerCards - call AIProcessRetreat - ld a, AI_TRAINER_CARD_PHASE_10 - call AIProcessHandTrainerCards - ld a, [wAlreadyPlayedEnergy] - or a - jr nz, .skip_attach_energy_2 - call AIProcessAndTryToPlayEnergy -.skip_attach_energy_2 - call AIDecidePlayPokemonCard - ret c ; return if turn ended -.try_attack -; attack if possible, if not, -; finish turn without attacking. - call AIProcessAndTryToUseAttack - ret c ; return if turn ended - ld a, OPPACTION_FINISH_NO_ATTACK - bank1call AIMakeDecision - ret -; 0x155d2 diff --git a/src/engine/deck_ai/deck_ai.asm b/src/engine/deck_ai/deck_ai.asm new file mode 100644 index 0000000..a906472 --- /dev/null +++ b/src/engine/deck_ai/deck_ai.asm @@ -0,0 +1,81 @@ +; AI card retreat score bonus +; when the AI retreat routine runs through the Bench to choose +; a Pokemon to switch to, it looks up in this list and if +; a card ID matches, applies a retreat score bonus to this card. +; positive (negative) means more (less) likely to switch to this card. +ai_retreat: MACRO + db \1 ; card ID + db $80 + \2 ; retreat score (ranges between -128 and 127) +ENDM + +; AI card energy attach score bonus +; when the AI energy attachment routine runs through the Play Area to choose +; a Pokemon to attach an energy card, it looks up in this list and if +; a card ID matches, skips this card if the maximum number of energy +; cards attached has been reached. If it hasn't been reached, additionally +; applies a positive (or negative) AI score to attach energy to this card. +ai_energy: MACRO + db \1 ; card ID + db \2 ; maximum number of attached cards + db $80 + \3 ; energy score (ranges between -128 and 127) +ENDM + +; stores in WRAM pointer to data in argument +; e.g. store_list_pointer wSomeListPointer, SomeData +store_list_pointer: MACRO + ld hl, \1 + ld de, \2 + ld [hl], e + inc hl + ld [hl], d +ENDM + +; deck AIs are specialized to work on a given deck ID. +; they decide what happens during a turn, what Pokemon cards +; to pick during the start of the duel, etc. +; each of these have a pointer table with the following structure: +; dw .do_turn : never called; +; +; dw .do_turn : called to handle the main turn logic, from the beginning +; of the turn up to the attack (or lack thereof); +; +; dw .start_duel : called at the start of the duel to initialize some +; variables and optionally set up CPU hand and deck; +; +; dw .forced_switch : logic to determine what Pokemon to pick when there's +; an effect that forces AI to switch to Bench card; +; +; dw .ko_switch : logic for picking which card to use after a KO; +; +; dw .take_prize : logic to decide which prize card to pick. + +; optionally, decks can also declare card lists that will add +; more specialized logic during various generic AI routines, +; and read during the .start_duel routines. +; the pointers to these lists are stored in memory: +; wAICardListAvoidPrize : list of cards to avoid being placed as prize; +; wAICardListArenaPriority : priority list of Arena card at duel start; +; wAICardListBenchPriority : priority list of Bench cards at duel start; +; wAICardListPlayFromHandPriority : priority list of cards to play from hand; +; wAICardListRetreatBonus : scores given to certain cards for retreat; +; wAICardListEnergyBonus : max number of energy cards and card scores. + +INCLUDE "engine/deck_ai/decks/general.asm" +INCLUDE "engine/deck_ai/decks/sams_practice.asm" +INCLUDE "engine/deck_ai/decks/general_no_retreat.asm" +INCLUDE "engine/deck_ai/decks/legendary_moltres.asm" +INCLUDE "engine/deck_ai/decks/legendary_zapdos.asm" +INCLUDE "engine/deck_ai/decks/legendary_articuno.asm" +INCLUDE "engine/deck_ai/decks/legendary_dragonite.asm" +INCLUDE "engine/deck_ai/decks/first_strike.asm" +INCLUDE "engine/deck_ai/decks/rock_crusher.asm" +INCLUDE "engine/deck_ai/decks/go_go_rain_dance.asm" +INCLUDE "engine/deck_ai/decks/zapping_selfdestruct.asm" +INCLUDE "engine/deck_ai/decks/flower_power.asm" +INCLUDE "engine/deck_ai/decks/strange_psyshock.asm" +INCLUDE "engine/deck_ai/decks/wonders_of_science.asm" +INCLUDE "engine/deck_ai/decks/fire_charge.asm" +INCLUDE "engine/deck_ai/decks/im_ronald.asm" +INCLUDE "engine/deck_ai/decks/powerful_ronald.asm" +INCLUDE "engine/deck_ai/decks/invincible_ronald.asm" +INCLUDE "engine/deck_ai/decks/legendary_ronald.asm" diff --git a/src/engine/deck_ai/decks/fire_charge.asm b/src/engine/deck_ai/decks/fire_charge.asm new file mode 100644 index 0000000..454f731 --- /dev/null +++ b/src/engine/deck_ai/decks/fire_charge.asm @@ -0,0 +1,86 @@ +AIActionTable_FireCharge: ; 15232 (5:5232) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 1523e (5:523e) + call AIMainTurnLogic + ret +; 0x15242 + +.start_duel ; 15242 (5:5242) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15253 + +.forced_switch ; 15253 (5:5253) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15257 + +.ko_switch ; 15257 (5:5257) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1525b + +.take_prize ; 1525b (5:525b) + call AIPickPrizeCards + ret +; 0x1525f + +.list_arena ; 1525f (5:525f) + db JIGGLYPUFF3 + db CHANSEY + db TAUROS + db MAGMAR1 + db JIGGLYPUFF1 + db GROWLITHE + db $00 + +.list_bench ; 15266 (5:5266) + db JIGGLYPUFF3 + db CHANSEY + db GROWLITHE + db MAGMAR1 + db JIGGLYPUFF1 + db TAUROS + db $00 + +.list_retreat ; 1526e (5:526e) + ai_retreat JIGGLYPUFF1, -1 + ai_retreat CHANSEY, -1 + ai_retreat GROWLITHE, -1 + db $00 + +.list_energy ; 15274 (5:5274) + ai_energy GROWLITHE, 3, +0 + ai_energy ARCANINE2, 4, +0 + ai_energy MAGMAR1, 3, +0 + ai_energy JIGGLYPUFF1, 3, +0 + ai_energy JIGGLYPUFF3, 2, +0 + ai_energy WIGGLYTUFF, 3, +0 + ai_energy CHANSEY, 4, +0 + ai_energy TAUROS, 3, +0 + db $00 + +.list_prize ; 1528d (5:528d) + db GAMBLER + db $00 + +.store_list_pointers ; 1528f (5:528f) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x152bd diff --git a/src/engine/deck_ai/decks/first_strike.asm b/src/engine/deck_ai/decks/first_strike.asm new file mode 100644 index 0000000..6d2906c --- /dev/null +++ b/src/engine/deck_ai/decks/first_strike.asm @@ -0,0 +1,82 @@ +AIActionTable_FirstStrike: ; 14e89 (5:4e89) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14e95 (5:4e95) + call AIMainTurnLogic + ret +; 0x14e99 + +.start_duel ; 14e99 (5:4e99) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14eaa + +.forced_switch ; 14eaa (5:4eaa) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eae + +.ko_switch ; 14eae (5:4eae) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14eb2 + +.take_prize ; 14eb2 (5:4eb2) + call AIPickPrizeCards + ret +; 0x14eb6 + +.list_arena ; 14eb6 (5:1eb6) + db HITMONCHAN + db MACHOP + db HITMONLEE + db MANKEY + db $00 + +.list_bench ; 14ebb (5:1ebb) + db MACHOP + db HITMONLEE + db HITMONCHAN + db MANKEY + db $00 + +.list_retreat ; 14ec0 (5:1ec0) + ai_retreat MACHOP, -1 + ai_retreat MACHOKE, -1 + ai_retreat MANKEY, -2 + db $00 + +.list_energy ; 14ec7 (5:1ec7) + ai_energy MACHOP, 3, +0 + ai_energy MACHOKE, 4, +0 + ai_energy MACHAMP, 4, -1 + ai_energy HITMONCHAN, 3, +0 + ai_energy HITMONLEE, 3, +0 + ai_energy MANKEY, 2, -1 + ai_energy PRIMEAPE, 3, -1 + db $00 + +.list_prize ; 14edd (5:1edd) + db HITMONLEE + db HITMONCHAN + db $00 + +.store_list_pointers ; 14ee0 (5:4ee0) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14f0e diff --git a/src/engine/deck_ai/decks/flower_power.asm b/src/engine/deck_ai/decks/flower_power.asm new file mode 100644 index 0000000..566d064 --- /dev/null +++ b/src/engine/deck_ai/decks/flower_power.asm @@ -0,0 +1,81 @@ +AIActionTable_FlowerPower: ; 1509b (5:509b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 150a7 (5:50a7) + call AIMainTurnLogic + ret +; 0x150ab + +.start_duel ; 150ab (5:50ab) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x150bc + +.forced_switch ; 150bc (5:50bc) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c0 + +.ko_switch ; 150c0 (5:50c0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x150c4 + +.take_prize ; 150c4 (5:50c4) + call AIPickPrizeCards + ret +; 0x150c8 + +.list_arena ; 150c8 (5:50c8) + db ODDISH + db EXEGGCUTE + db BULBASAUR + db $00 + +.list_bench ; 150cc (5:50cc) + db BULBASAUR + db EXEGGCUTE + db ODDISH + db $00 + +.list_retreat ; 150cf (5:50cf) + ai_retreat GLOOM, -2 + ai_retreat VILEPLUME, -2 + ai_retreat BULBASAUR, -2 + ai_retreat IVYSAUR, -2 + db $00 + +.list_energy ; 150d9 (5:50d9) + ai_energy BULBASAUR, 3, +0 + ai_energy IVYSAUR, 4, +0 + ai_energy VENUSAUR2, 4, +0 + ai_energy ODDISH, 2, +0 + ai_energy GLOOM, 3, -1 + ai_energy VILEPLUME, 3, -1 + ai_energy EXEGGCUTE, 3, +0 + ai_energy EXEGGUTOR, 22, +0 + db $00 + +.list_prize ; 150f2 (5:50f2) + db VENUSAUR2 + db $00 + +.store_list_pointers ; 150f4 (5:50f4) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x15122 diff --git a/src/engine/deck_ai/decks/general.asm b/src/engine/deck_ai/decks/general.asm new file mode 100644 index 0000000..1bfc3e0 --- /dev/null +++ b/src/engine/deck_ai/decks/general.asm @@ -0,0 +1,196 @@ +; AI logic used by general decks +AIActionTable_GeneralDecks: ; 14668 (05:4668) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14674 (5:4674) + call AIMainTurnLogic + ret + +.start_duel ; 14678 (5:4678) + call InitAIDuelVars + call AIPlayInitialBasicCards + ret + +.forced_switch ; 1467f (5:467f) + call AIDecideBenchPokemonToSwitchTo + ret + +.ko_switch ; 14683 (5:4683) + call AIDecideBenchPokemonToSwitchTo + ret + +.take_prize: ; 14687 (5:4687) + call AIPickPrizeCards + ret + +; handle AI routines for a whole turn +AIMainTurnLogic: ; 1468b (5:468b) +; initialize variables + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; handle Pkmn Powers + farcall HandleAIGoGoRainDanceEnergy + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAICowardice +; process Trainer cards +; phase 2 through 4. + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended +; process Trainer cards +; phase 5 through 12. + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_1 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_1 +; play Pokemon from hand again + call AIDecidePlayPokemonCard +; handle Pkmn Powers again + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAIGoGoRainDanceEnergy + ld a, AI_ENERGY_TRANS_ATTACK + farcall HandleAIEnergyTrans +; process Trainer cards phases 13 and 15 + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards +; if used Professor Oak, process new hand +; if not, then proceed to attack. + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_2 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_2 + call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAIGoGoRainDanceEnergy + ld a, AI_ENERGY_TRANS_ATTACK + farcall HandleAIEnergyTrans + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ; skip AI_TRAINER_CARD_PHASE_15 +.try_attack + ld a, AI_ENERGY_TRANS_TO_BENCH + farcall HandleAIEnergyTrans +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if AI attacked + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14786 + +; handles AI retreating logic +AIProcessRetreat: ; 14786 (5:4786) + ld a, [wAIRetreatedThisTurn] + or a + ret nz ; return, already retreated this turn + + call AIDecideWhetherToRetreat + ret nc ; return if not retreating + + call AIDecideBenchPokemonToSwitchTo + ret c ; return if no Bench Pokemon + +; store Play Area to retreat to and +; set wAIRetreatedThisTurn to true + ld [wAIPlayAreaCardToSwitch], a + ld a, $01 + ld [wAIRetreatedThisTurn], a + +; if AI can use Switch from hand, use it instead... + ld a, AI_TRAINER_CARD_PHASE_09 + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_SWITCH + jr nz, .used_switch +; ... else try retreating normally. + ld a, [wAIPlayAreaCardToSwitch] + call AITryToRetreat + ret + +.used_switch +; if AI used switch, unset its AI flag + ld a, [wPreviousAIFlags] + and ~AI_FLAG_USED_SWITCH ; clear Switch flag + ld [wPreviousAIFlags], a + +; bug, this doesn't make sense being here, since at this point +; Switch Trainer card was already used to retreat the Pokemon. +; what the routine will do is just transfer Energy cards to +; the Arena Pokemon for the purpose of retreating, and +; then not actually retreat, resulting in unusual behaviour. +; this would only work placed right after the AI checks whether +; they have Switch card in hand to use and doesn't have one. +; (and probably that was the original intention.) + ld a, AI_ENERGY_TRANS_RETREAT ; retreat + farcall HandleAIEnergyTrans + ret +; 0x147bd diff --git a/src/engine/deck_ai/decks/general_no_retreat.asm b/src/engine/deck_ai/decks/general_no_retreat.asm new file mode 100644 index 0000000..e735076 --- /dev/null +++ b/src/engine/deck_ai/decks/general_no_retreat.asm @@ -0,0 +1,146 @@ +; acts just like a general deck AI except never retreats +AIActionTable_GeneralNoRetreat: ; 148dc (5:48dc) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 148e8 (5:48e8) + call AIDoTurn_GeneralNoRetreat + ret +; 0x148ec + +.start_duel ; 148ec (5:48ec) + call InitAIDuelVars + call AIPlayInitialBasicCards + ret +; 0x148f3 + +.forced_switch ; 148f3 (5:48f3) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148f7 + +.ko_switch ; 148f7 (5:48f7) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x148fb + +.take_prize ; 148fb (5:48fb) + call AIPickPrizeCards + ret +; 0x148ff + +AIDoTurn_GeneralNoRetreat: ; 148ff (5:48ff) +; initialize variables + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; handle Pkmn Powers + farcall HandleAIGoGoRainDanceEnergy + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAICowardice +; process Trainer cards +; phase 2 through 4. + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended +; process Trainer cards +; phase 5 through 12. + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_1 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_1 +; play Pokemon from hand again + call AIDecidePlayPokemonCard +; handle Pkmn Powers again + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAIGoGoRainDanceEnergy + ld a, AI_ENERGY_TRANS_ATTACK + farcall HandleAIEnergyTrans +; process Trainer cards phases 13 and 15 + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards +; if used Professor Oak, process new hand +; if not, then proceed to attack. + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_03 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_06 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_08 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_12 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_2 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_2 + call AIDecidePlayPokemonCard + farcall HandleAIDamageSwap + farcall HandleAIPkmnPowers + ret c ; return if turn ended + farcall HandleAIGoGoRainDanceEnergy + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ; skip AI_TRAINER_CARD_PHASE_15 +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if turn ended + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x149e8 diff --git a/src/engine/deck_ai/decks/go_go_rain_dance.asm b/src/engine/deck_ai/decks/go_go_rain_dance.asm new file mode 100644 index 0000000..006bbdc --- /dev/null +++ b/src/engine/deck_ai/decks/go_go_rain_dance.asm @@ -0,0 +1,85 @@ +AIActionTable_GoGoRainDance: ; 14f8f (5:4f8f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14f9b (5:4f9b) + call AIMainTurnLogic + ret +; 0x14f9f + +.start_duel ; 14f9f (5:4f9f) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14fb0 + +.forced_switch ; 14fb0 (5:4fb0) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb4 + +.ko_switch ; 14fb4 (5:4fb4) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14fb8 + +.take_prize ; 14fb8 (5:4fb8) + call AIPickPrizeCards + ret +; 0x14fbc + +.list_arena ; 14fbc (5:4fbc) + db LAPRAS + db HORSEA + db GOLDEEN + db SQUIRTLE + db $00 + +.list_bench ; 14fc1 (5:4fc1) + db SQUIRTLE + db HORSEA + db GOLDEEN + db LAPRAS + db $00 + +.list_retreat ; 14fc6 (5:4fc6) + ai_retreat SQUIRTLE, -3 + ai_retreat WARTORTLE, -2 + ai_retreat HORSEA, -1 + db $00 + +.list_energy ; 14fcd (5:4fcd) + ai_energy SQUIRTLE, 2, +0 + ai_energy WARTORTLE, 3, +0 + ai_energy BLASTOISE, 5, +0 + ai_energy GOLDEEN, 1, +0 + ai_energy SEAKING, 2, +0 + ai_energy HORSEA, 2, +0 + ai_energy SEADRA, 3, +0 + ai_energy LAPRAS, 3, +0 + db $00 + +.list_prize ; 14fe6 (5:4fe6) + db GAMBLER + db ENERGY_RETRIEVAL + db SUPER_ENERGY_RETRIEVAL + db BLASTOISE + db $00 + +.store_list_pointers ; 14feb (5:4feb) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x15019 diff --git a/src/engine/deck_ai/decks/im_ronald.asm b/src/engine/deck_ai/decks/im_ronald.asm new file mode 100644 index 0000000..c140f1d --- /dev/null +++ b/src/engine/deck_ai/decks/im_ronald.asm @@ -0,0 +1,86 @@ +AIActionTable_ImRonald: ; 152bd (5:52bd) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 152c9 (5:52c9) + call AIMainTurnLogic + ret +; 0x152cd + +.start_duel ; 152cd (5:52cd) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x152de + +.forced_switch ; 152de (5:52de) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e2 + +.ko_switch ; 152e2 (5:52e2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x152e6 + +.take_prize ; 152e6 (5:52e6) + call AIPickPrizeCards + ret +; 0x152ea + +.list_arena ; 152ea (5:52ea) + db LAPRAS + db SEEL + db CHARMANDER + db CUBONE + db SQUIRTLE + db GROWLITHE + db $00 + +.list_bench ; 152f1 (5:52f1) + db CHARMANDER + db SQUIRTLE + db SEEL + db CUBONE + db GROWLITHE + db LAPRAS + db $00 + +.list_retreat ; 152f8 (5:52f8) + db $00 + +.list_energy ; 152f9 (5:52f9) + ai_energy CHARMANDER, 3, +0 + ai_energy CHARMELEON, 5, +0 + ai_energy GROWLITHE, 2, +0 + ai_energy ARCANINE2, 4, +0 + ai_energy SQUIRTLE, 2, +0 + ai_energy WARTORTLE, 3, +0 + ai_energy SEEL, 3, +0 + ai_energy DEWGONG, 4, +0 + ai_energy LAPRAS, 3, +0 + ai_energy CUBONE, 3, +0 + ai_energy MAROWAK1, 3, +0 + db $00 + +.list_prize ; 1531b (5:531b) + db LAPRAS + db $00 + +.store_list_pointers ; 1531d (5:531d) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x1534b diff --git a/src/engine/deck_ai/decks/invincible_ronald.asm b/src/engine/deck_ai/decks/invincible_ronald.asm new file mode 100644 index 0000000..0a55461 --- /dev/null +++ b/src/engine/deck_ai/decks/invincible_ronald.asm @@ -0,0 +1,84 @@ +AIActionTable_InvincibleRonald: ; 153e8 (5:53e8) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 153f4 (5:53f4) + call AIMainTurnLogic + ret +; 0x153f8 + +.start_duel ; 153f8 (5:53f8) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15409 + +.forced_switch ; 15409 (5:5409) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1540d + +.ko_switch ; 1540d (5:540d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15411 + +.take_prize ; 15411 (5:5411) + call AIPickPrizeCards + ret +; 0x15415 + +.list_arena ; 15415 (5:5415) + db KANGASKHAN + db MAGMAR2 + db CHANSEY + db GEODUDE + db SCYTHER + db GRIMER + db $00 + +.list_bench ; 1541c (5:541c) + db GRIMER + db SCYTHER + db GEODUDE + db CHANSEY + db MAGMAR2 + db KANGASKHAN + db $00 + +.list_retreat ; 15423 (5:5423) + ai_retreat GRIMER, -1 + db $00 + +.list_energy ; 15426 (5:5426) + ai_energy GRIMER, 1, -1 + ai_energy MUK, 3, -1 + ai_energy SCYTHER, 4, +1 + ai_energy MAGMAR2, 2, +0 + ai_energy GEODUDE, 2, +0 + ai_energy GRAVELER, 3, +0 + ai_energy CHANSEY, 4, +0 + ai_energy KANGASKHAN, 4, -1 + db $00 + +.list_prize ; 1543f (5:543f) + db GAMBLER + db $00 + +.store_list_pointers ; 15441 (5:5441) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x1546f diff --git a/src/engine/deck_ai/decks/legendary_articuno.asm b/src/engine/deck_ai/decks/legendary_articuno.asm new file mode 100644 index 0000000..183ab62 --- /dev/null +++ b/src/engine/deck_ai/decks/legendary_articuno.asm @@ -0,0 +1,217 @@ +AIActionTable_LegendaryArticuno: ; 14c0b (5:4c0b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14c17 (5:4c17) + call AIDoTurn_LegendaryArticuno + ret +; 0x14c1b + +.start_duel ; 14c1b (5:4c1b) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14c2c + +.forced_switch ; 14c2c (5:4c2c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c30 + +.ko_switch ; 14c30 (5:4c30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14c34 + +.take_prize ; 14c34 (5:4c34) + call AIPickPrizeCards + ret +; 0x14c38 + +.list_arena ; 14c38 (5:4c38) + db CHANSEY + db LAPRAS + db DITTO + db SEEL + db ARTICUNO1 + db ARTICUNO2 + db $00 + +.list_bench ; 14c3f (5:4c3f) + db ARTICUNO1 + db SEEL + db LAPRAS + db CHANSEY + db DITTO + db $00 + +.list_retreat ; 14c45 (5:4c45) + ai_retreat SEEL, -3 + ai_retreat DITTO, -3 + db $00 + +.list_energy ; 14c4a (5:4c4a) + ai_energy SEEL, 3, +1 + ai_energy DEWGONG, 4, +0 + ai_energy LAPRAS, 3, +0 + ai_energy ARTICUNO1, 4, +1 + ai_energy ARTICUNO2, 3, +0 + ai_energy CHANSEY, 0, -8 + ai_energy DITTO, 3, +0 + db $00 + +.list_prize ; 14c60 (5:4c60) + db GAMBLER + db ARTICUNO2 + db $00 + +.store_list_pointers ; 14c63 (5:4c63) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14c91 + +; this routine handles how Legendary Articuno +; prioritises playing energy cards to each Pokémon. +; first, it makes sure that all Lapras have at least +; 3 energy cards before moving on to Articuno, +; and then to Dewgong and Seel +ScoreLegendaryArticunoCards: ; 14c91 (5:4c91) + call SwapTurn + call CountPrizes + call SwapTurn + cp 3 + ret c + +; player prizes >= 3 +; if Lapras has more than half HP and +; can use second move, check next for Articuno +; otherwise, check if Articuno or Dewgong +; have more than half HP and can use second move +; and if so, the next Pokémon to check is Lapras + ld a, LAPRAS + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .articuno + ld a, ARTICUNO1 + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .lapras + ld a, DEWGONG + call CheckForBenchIDAtHalfHPAndCanUseSecondMove + jr c, .lapras + jr .articuno + +; the following routines check for certain card IDs in bench +; and call RaiseAIScoreToAllMatchingIDsInBench if these are found. +; for Lapras, an additional check is made to its +; attached energy count, which skips calling the routine +; if this count is >= 3 +.lapras + ld a, LAPRAS + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .articuno + ld e, a + call CountNumberOfEnergyCardsAttached + cp 3 + jr nc, .articuno + ld a, LAPRAS + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.articuno + ld a, ARTICUNO1 + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .dewgong + ld a, ARTICUNO1 + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.dewgong + ld a, DEWGONG + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + jr nc, .seel + ld a, DEWGONG + call RaiseAIScoreToAllMatchingIDsInBench + ret + +.seel + ld a, SEEL + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + ret nc + ld a, SEEL + call RaiseAIScoreToAllMatchingIDsInBench + ret +; 0x14cf7 + +AIDoTurn_LegendaryArticuno: ; 14cf7 (5:4cf7) +; initialize variables + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_1 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_1 +; play Pokemon from hand again + call AIDecidePlayPokemonCard +; process Trainer cards phases 13 and 15 + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards +; if used Professor Oak, process new hand + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c ; return if turn ended + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_2 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_2 + call AIDecidePlayPokemonCard +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if turn ended + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14d60 diff --git a/src/engine/deck_ai/decks/legendary_dragonite.asm b/src/engine/deck_ai/decks/legendary_dragonite.asm new file mode 100644 index 0000000..d320440 --- /dev/null +++ b/src/engine/deck_ai/decks/legendary_dragonite.asm @@ -0,0 +1,173 @@ +AIActionTable_LegendaryDragonite: ; 14d60 (05:4d60) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14d6c (5:4d6c) + call AIDoTurn_LegendaryDragonite + ret +; 0x14d70 + +.start_duel ; 14d70 (5:4d70) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14d81 + +.forced_switch ; 14d81 (5:4d81) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d85 + +.ko_switch ; 14d85 (5:4d85) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14d89 + +.take_prize ; 14d89 (5:4d89) + call AIPickPrizeCards + ret +; 0x14d8d + +.list_arena ; 14d8d (5:4d8d) + db KANGASKHAN + db LAPRAS + db CHARMANDER + db DRATINI + db MAGIKARP + db $00 + +.list_bench ; 14d93 (5:4d93) + db CHARMANDER + db MAGIKARP + db DRATINI + db LAPRAS + db KANGASKHAN + db $00 + +.list_retreat ; 14d99 (5:4d99) + ai_retreat CHARMANDER, -1 + ai_retreat MAGIKARP, -5 + db $00 + +.list_energy ; 14d9e (5:4d9e) + ai_energy CHARMANDER, 3, +1 + ai_energy CHARMELEON, 4, +1 + ai_energy CHARIZARD, 5, +0 + ai_energy MAGIKARP, 3, +1 + ai_energy GYARADOS, 4, -1 + ai_energy DRATINI, 2, +0 + ai_energy DRAGONAIR, 4, +0 + ai_energy DRAGONITE1, 3, -1 + ai_energy KANGASKHAN, 2, -2 + ai_energy LAPRAS, 3, +0 + db $00 + +.list_prize ; 14dbd (5:4dbd) + db GAMBLER + db DRAGONITE1 + db KANGASKHAN + db $00 + +.store_list_pointers ; 14dc1 (5:4dc1) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14def + +AIDoTurn_LegendaryDragonite: ; 14def (5:4def) +; initialize variables + call InitAITurnVars + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_1 + +; if Arena card is Kangaskhan and doens't +; have Energy cards attached, try attaching from hand. +; otherwise run normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, KANGASKHAN + cp e + jr nz, .attach_normally + call CreateEnergyCardListFromHand + jr c, .skip_energy_attach_1 + ld e, PLAY_AREA_ARENA + call CountNumberOfEnergyCardsAttached + or a + jr nz, .attach_normally + xor a + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .skip_energy_attach_1 +.attach_normally + call AIProcessAndTryToPlayEnergy + +.skip_energy_attach_1 +; play Pokemon from hand again + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_15 + call AIProcessHandTrainerCards +; if used Professor Oak, process new hand +; if not, then proceed to attack. + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach_2 + call AIProcessAndTryToPlayEnergy +.skip_energy_attach_2 + call AIDecidePlayPokemonCard +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if turn ended + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14e89 diff --git a/src/engine/deck_ai/decks/legendary_moltres.asm b/src/engine/deck_ai/decks/legendary_moltres.asm new file mode 100644 index 0000000..cb38668 --- /dev/null +++ b/src/engine/deck_ai/decks/legendary_moltres.asm @@ -0,0 +1,183 @@ +AIActionTable_LegendaryMoltres: ; 149e8 (05:49e8) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 149f4 (5:49f4) + call AIDoTurn_LegendaryMoltres + ret +; 0x149f8 + +.start_duel ; 149f8 (5:49f8) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc ; Play Area set up was successful + call AIPlayInitialBasicCards + ret +; 0x14a09 + +.forced_switch ; 14a09 (5:4a09) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a0d + +.ko_switch ; 14a0d (5:4a0d) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14a11 + +.take_prize ; 14a11 (5:4a11) + call AIPickPrizeCards + ret +; 0x14a15 + +.list_arena ; 14a15 (5:4a15) + db MAGMAR2 + db GROWLITHE + db VULPIX + db MAGMAR1 + db MOLTRES1 + db MOLTRES2 + db $00 + +.list_bench ; 14a1c (5:4a1c) + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +.list_play_hand ; 14a22 (5:4a22) + db MOLTRES2 + db MOLTRES1 + db VULPIX + db GROWLITHE + db MAGMAR2 + db MAGMAR1 + db $00 + +.list_retreat ; 14a29 (5:4a29) + ai_retreat GROWLITHE, -5 + ai_retreat VULPIX, -5 + db $00 + +.list_energy ; 14a2e (5:4a2e) + ai_energy VULPIX, 3, +0 + ai_energy NINETAILS2, 3, +1 + ai_energy GROWLITHE, 3, +1 + ai_energy ARCANINE2, 4, +1 + ai_energy MAGMAR1, 4, -1 + ai_energy MAGMAR2, 1, -1 + ai_energy MOLTRES2, 3, +2 + ai_energy MOLTRES1, 4, +2 + db $00 + +.list_prize ; 14a47 (5:4a47) + db ENERGY_REMOVAL + db MOLTRES2 + db $00 + +.store_list_pointers ; 14a4a (5:4a4a) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand + store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14a81 + +AIDoTurn_LegendaryMoltres: ; 14a81 (5:4a81) +; initialize variables + call InitAITurnVars + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; process Trainer cards +; phase 2 through 4. + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + +; check if AI can play Moltres2 +; from hand and if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + cp DECK_SIZE - 9 + jr nc, .skip_moltres ; skip if cards in deck <= 9 + ld a, MUK + call CountPokemonIDInBothPlayAreas + jr c, .skip_moltres ; skip if Muk in play + ld a, MOLTRES2 + call LookForCardIDInHandList_Bank5 + jr nc, .skip_moltres ; skip if no Moltres2 in hand + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + +.skip_moltres +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_11 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_attach_energy + +; if Magmar2 is the Arena card and has no energy attached, +; try attaching an energy card to it from the hand. +; otherwise, run normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, MAGMAR2 + cp e + jr nz, .attach_normally + ; Magmar2 is the Arena card + call CreateEnergyCardListFromHand + jr c, .skip_attach_energy + ld e, PLAY_AREA_ARENA + call CountNumberOfEnergyCardsAttached + or a + jr nz, .attach_normally + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .skip_attach_energy + +.attach_normally +; play Energy card if possible + call AIProcessAndTryToPlayEnergy +.skip_attach_energy +; try playing Pokemon cards from hand again + call AIDecidePlayPokemonCard + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards + +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14b0f diff --git a/src/engine/deck_ai/decks/legendary_ronald.asm b/src/engine/deck_ai/decks/legendary_ronald.asm new file mode 100644 index 0000000..2721ba9 --- /dev/null +++ b/src/engine/deck_ai/decks/legendary_ronald.asm @@ -0,0 +1,210 @@ +AIActionTable_LegendaryRonald: ; 1546f (5:546f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 1547b (5:547b) + call AIDoTurn_LegendaryRonald + ret +; 0x1547f + +.start_duel ; 1547f (5:547f) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15490 + +.forced_switch ; 15490 (5:5490) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15494 + +.ko_switch ; 15494 (5:5494) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15498 + +.take_prize ; 15498 (5:5498) + call AIPickPrizeCards + ret +; 0x1549c + +.list_arena ; 1549c (5:549c) + db KANGASKHAN + db DRATINI + db EEVEE + db ZAPDOS3 + db ARTICUNO2 + db MOLTRES2 + db $00 + +.list_bench ; 154a3 (5:54a3) + db KANGASKHAN + db DRATINI + db EEVEE + db $00 + +.list_play_hand ; 154a7 (5:54a7) + db MOLTRES2 + db ZAPDOS3 + db KANGASKHAN + db DRATINI + db EEVEE + db ARTICUNO2 + db $00 + +.list_retreat ; 154ae (5:54ae) + ai_retreat EEVEE, -2 + db $00 + +.list_energy ; 154b1 (5:54b1) + ai_energy FLAREON1, 3, +0 + ai_energy MOLTRES2, 3, +0 + ai_energy VAPOREON1, 3, +0 + ai_energy ARTICUNO2, 0, -8 + ai_energy JOLTEON1, 4, +0 + ai_energy ZAPDOS3, 0, -8 + ai_energy KANGASKHAN, 4, -1 + ai_energy EEVEE, 3, +0 + ai_energy DRATINI, 3, +0 + ai_energy DRAGONAIR, 4, +0 + ai_energy DRAGONITE1, 3, +0 + db $00 + +.list_prize ; 154d3 (5:54d3) + db MOLTRES2 + db ARTICUNO2 + db ZAPDOS3 + db DRAGONITE1 + db GAMBLER + db $00 + +.store_list_pointers ; 154d9 (5:54d9) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_play_hand + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x15507 + +AIDoTurn_LegendaryRonald: ; 15507 (5:5507) +; initialize variables + call InitAITurnVars +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + +; check if AI can play Moltres2 +; from hand and if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres_1 ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + cp DECK_SIZE - 9 + jr nc, .skip_moltres_1 ; skip if cards in deck <= 9 + ld a, MUK + call CountPokemonIDInBothPlayAreas + jr c, .skip_moltres_1 ; skip if Muk in play + ld a, MOLTRES2 + call LookForCardIDInHandList_Bank5 + jr nc, .skip_moltres_1 ; skip if no Moltres2 in hand + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + +.skip_moltres_1 +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards +; play Energy card if possible + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_attach_energy_1 + call AIProcessAndTryToPlayEnergy +.skip_attach_energy_1 +; try playing Pokemon cards from hand again + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_15 +; if used Professor Oak, process new hand +; if not, then proceed to attack. + call AIProcessHandTrainerCards + ld a, [wPreviousAIFlags] + and AI_FLAG_USED_PROFESSOR_OAK + jr z, .try_attack + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_02 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards + +; check if AI can play Moltres2 +; from hand and if so, play it. + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + cp MAX_PLAY_AREA_POKEMON + jr nc, .skip_moltres_2 ; skip if bench is full + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + cp DECK_SIZE - 9 + jr nc, .skip_moltres_2 ; skip if cards in deck <= 9 + ld a, MUK + call CountPokemonIDInBothPlayAreas + jr c, .skip_moltres_2 ; skip if Muk in play + ld a, MOLTRES2 + call LookForCardIDInHandList_Bank5 + jr nc, .skip_moltres_2 ; skip if no Moltres2 in hand + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + +.skip_moltres_2 + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_05 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_attach_energy_2 + call AIProcessAndTryToPlayEnergy +.skip_attach_energy_2 + call AIDecidePlayPokemonCard + ret c ; return if turn ended +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if turn ended + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x155d2 diff --git a/src/engine/deck_ai/decks/legendary_zapdos.asm b/src/engine/deck_ai/decks/legendary_zapdos.asm new file mode 100644 index 0000000..cfa60be --- /dev/null +++ b/src/engine/deck_ai/decks/legendary_zapdos.asm @@ -0,0 +1,160 @@ +AIActionTable_LegendaryZapdos: ; 14b0f (05:4b0f) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14b1b (5:4b1b) + call AIDoTurn_LegendaryZapdos + ret +; 0x14b1f + +.start_duel ; 14b1f (5:4b1f) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14b30 + +.forced_switch ; 14b30 (5:4b30) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b34 + +.ko_switch ; 14b34 (5:4b34) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14b38 + +.take_prize ; 14b38 (5:4b38) + call AIPickPrizeCards + ret +; 0x14b3c + +.list_arena ; 14b3c (5:4b3c) + db ELECTABUZZ2 + db VOLTORB + db EEVEE + db ZAPDOS1 + db ZAPDOS2 + db ZAPDOS3 + db $00 + +.list_bench ; 14b43 (5:4b43) + db ZAPDOS2 + db ZAPDOS1 + db EEVEE + db VOLTORB + db ELECTABUZZ2 + db $00 + +.list_retreat ; 14b49 (5:4b49) + ai_retreat EEVEE, -5 + ai_retreat VOLTORB, -5 + ai_retreat ELECTABUZZ2, -5 + db $00 + +.list_energy ; 14b50 (5:4b50) + ai_energy VOLTORB, 1, -1 + ai_energy ELECTRODE1, 3, +0 + ai_energy ELECTABUZZ2, 2, -1 + ai_energy JOLTEON2, 3, +1 + ai_energy ZAPDOS1, 4, +2 + ai_energy ZAPDOS2, 4, +2 + ai_energy ZAPDOS3, 3, +1 + ai_energy EEVEE, 3, +0 + db $00 + +.list_prize ; 14b69 (5:4b69) + db GAMBLER + db ZAPDOS3 + db $00 + +.store_list_pointers ; 14b6c (5:4b6c) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14b9a + +AIDoTurn_LegendaryZapdos: ; 14b9a (5:4b9a) +; initialize variables + call InitAITurnVars + farcall HandleAIAntiMewtwoDeckStrategy + jp nc, .try_attack +; process Trainer cards + ld a, AI_TRAINER_CARD_PHASE_01 + call AIProcessHandTrainerCards + ld a, AI_TRAINER_CARD_PHASE_04 + call AIProcessHandTrainerCards +; play Pokemon from hand + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_07 + call AIProcessHandTrainerCards + call AIProcessRetreat + ld a, AI_TRAINER_CARD_PHASE_10 + call AIProcessHandTrainerCards +; play Energy card if possible. + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .skip_energy_attach + +; if Arena card is Voltorb and there's Electrode1 in hand, +; or if it's Electabuzz, try attaching Energy card +; to the Arena card if it doesn't have any energy attached. +; Otherwise if Energy card is not needed, +; go through normal AI energy attach routine. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call GetCardIDFromDeckIndex + ld a, VOLTORB + cp e + jr nz, .check_electabuzz + ld a, ELECTRODE1 + call LookForCardIDInHandList_Bank5 + jr nc, .attach_normally + jr .voltorb_or_electabuzz +.check_electabuzz + ld a, ELECTABUZZ2 + cp e + jr nz, .attach_normally + +.voltorb_or_electabuzz + call CreateEnergyCardListFromHand + jr c, .skip_energy_attach + ld e, PLAY_AREA_ARENA + call CountNumberOfEnergyCardsAttached + or a + jr nz, .attach_normally + xor a ; PLAY_AREA_ARENA + ldh [hTempPlayAreaLocation_ff9d], a + call AITryToPlayEnergyCard + jr c, .skip_energy_attach + +.attach_normally + call AIProcessAndTryToPlayEnergy + +.skip_energy_attach +; play Pokemon from hand again + call AIDecidePlayPokemonCard + ret c ; return if turn ended + ld a, AI_TRAINER_CARD_PHASE_13 + call AIProcessHandTrainerCards +.try_attack +; attack if possible, if not, +; finish turn without attacking. + call AIProcessAndTryToUseAttack + ret c ; return if turn ended + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x14c0b diff --git a/src/engine/deck_ai/decks/powerful_ronald.asm b/src/engine/deck_ai/decks/powerful_ronald.asm new file mode 100644 index 0000000..d99f87f --- /dev/null +++ b/src/engine/deck_ai/decks/powerful_ronald.asm @@ -0,0 +1,98 @@ +AIActionTable_PowerfulRonald: ; 1534b (5:534b) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 15357 (5:5357) + call AIMainTurnLogic + ret +; 0x1535b + +.start_duel ; 1535b (5:535b) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1536c + +.forced_switch ; 1536c (5:536c) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15370 + +.ko_switch ; 15370 (5:5370) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15374 + +.take_prize ; 15374 (5:5374) + call AIPickPrizeCards + ret +; 0x15378 + +.list_arena ; 15378 (5:5378) + db KANGASKHAN + db ELECTABUZZ2 + db HITMONCHAN + db MR_MIME + db LICKITUNG + db HITMONLEE + db TAUROS + db JYNX + db MEWTWO1 + db DODUO + db $00 + +.list_bench ; 15383 (5:5383) + db KANGASKHAN + db HITMONLEE + db HITMONCHAN + db TAUROS + db DODUO + db JYNX + db MEWTWO1 + db ELECTABUZZ2 + db MR_MIME + db LICKITUNG + db $00 + +.list_retreat ; 1538e (5:538e) + ai_retreat KANGASKHAN, -1 + ai_retreat DODUO, -1 + ai_retreat DODRIO, -1 + db $00 + +.list_energy ; 15395 (5:5395) + ai_energy ELECTABUZZ2, 2, +1 + ai_energy HITMONLEE, 3, +1 + ai_energy HITMONCHAN, 3, +1 + ai_energy MR_MIME, 2, +0 + ai_energy JYNX, 3, +0 + ai_energy MEWTWO1, 2, +0 + ai_energy DODUO, 3, -1 + ai_energy DODRIO, 3, -1 + ai_energy LICKITUNG, 2, +0 + ai_energy KANGASKHAN, 4, -1 + ai_energy TAUROS, 3, +0 + db $00 + +.list_prize ; 153b7 (5:53b7) + db GAMBLER + db ENERGY_REMOVAL + db $00 + +.store_list_pointers ; 153ba (5:53ba) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x153e8 diff --git a/src/engine/deck_ai/decks/rock_crusher.asm b/src/engine/deck_ai/decks/rock_crusher.asm new file mode 100644 index 0000000..f4e79d8 --- /dev/null +++ b/src/engine/deck_ai/decks/rock_crusher.asm @@ -0,0 +1,80 @@ +AIActionTable_RockCrusher: ; 14f0e (5:4f0e) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 14f1a (5:4f1a) + call AIMainTurnLogic + ret +; 0x14f1e + +.start_duel ; 14f1e (5:4f1e) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x14f2f + +.forced_switch ; 14f2f (5:4f2f) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f33 + +.ko_switch ; 14f33 (5:4f33) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x14f37 + +.take_prize ; 14f37 (5:4f37) + call AIPickPrizeCards + ret +; 0x14f3b + +.list_arena ; 14f3b (5:4f3b) + db RHYHORN + db ONIX + db GEODUDE + db DIGLETT + db $00 + +.list_bench ; 14f40 (5:4f40) + db DIGLETT + db GEODUDE + db RHYHORN + db ONIX + db $00 + +.list_retreat ; 14f45 (5:4f45) + ai_retreat DIGLETT, -1 + db $00 + +.list_energy ; 14f48 (5:4f48) + ai_energy DIGLETT, 3, +1 + ai_energy DUGTRIO, 4, +0 + ai_energy GEODUDE, 2, +1 + ai_energy GRAVELER, 3, +0 + ai_energy GOLEM, 4, +0 + ai_energy ONIX, 2, -1 + ai_energy RHYHORN, 3, +0 + db $00 + +.list_prize ; 14f5e (5:4f5e) + db ENERGY_REMOVAL + db RHYHORN + db $00 + +.store_list_pointers ; 14f61 (5:4f61) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x14f8f diff --git a/src/engine/deck_ai/decks/sams_practice.asm b/src/engine/deck_ai/decks/sams_practice.asm new file mode 100644 index 0000000..2ce0060 --- /dev/null +++ b/src/engine/deck_ai/decks/sams_practice.asm @@ -0,0 +1,222 @@ +; AI for Sam's practice duel, which handles his scripted actions. +; will act as a normal duelist AI after turn 7. +AIActionTable_SamPractice: ; 147bd (05:47bd) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 147c9 (5:47c9) + call IsAIPracticeScriptedTurn + jr nc, .scripted_1 +; not scripted, use AI main turn logic + call AIMainTurnLogic + ret +.scripted_1 ; use scripted actions instead + call AIPerformSciptedTurn + ret +; 0x147d6 + +.start_duel ; 147d6 (5:47d6) + call SetSamsStartingPlayArea + ret +; 0x147da + +.forced_switch ; 147da (5:47da) + call IsAIPracticeScriptedTurn + jr nc, .scripted_2 + call AIDecideBenchPokemonToSwitchTo + ret +.scripted_2 + call PickRandomBenchPokemon + ret +; 0x147e7 + +.ko_switch: ; 147e7 (5:47e7) + call IsAIPracticeScriptedTurn + jr nc, .scripted_3 + call AIDecideBenchPokemonToSwitchTo + ret +.scripted_3 + call GetPlayAreaLocationOfRaticateOrRattata + ret +; 0x147f4 + +.take_prize: ; 147f4 (5:47f4) + call AIPickPrizeCards + ret +; 0x147f8 + +; returns carry if number of turns +; the AI has taken >= 7. +; used to know whether AI Sam is still +; doing scripted turns. +IsAIPracticeScriptedTurn: ; 147f8 (5:47f8) + ld a, [wDuelTurns] + srl a + cp 7 + ccf + ret +; 0x14801 + +; places one Machop from the hand to the Play Area +; and sets the number of prizes to 2. +SetSamsStartingPlayArea: ; 14801 (5:4801) + call CreateHandCardList + ld hl, wDuelTempList +.loop_hand + ld a, [hli] + ldh [hTempCardIndex_ff98], a + cp $ff + ret z + call LoadCardDataToBuffer1_FromDeckIndex + cp MACHOP + jr nz, .loop_hand + ldh a, [hTempCardIndex_ff98] + call PutHandPokemonCardInPlayArea + ld a, 2 + ld [wDuelInitialPrizes], a + ret +; 0x1481f + +; outputs in a Play Area location of Raticate or Rattata +; in the Bench. If neither is found, just output PLAY_AREA_BENCH_1. +GetPlayAreaLocationOfRaticateOrRattata: ; 1481f (5:481f) + ld a, RATICATE + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + cp $ff + jr nz, .found + ld a, RATTATA + ld b, PLAY_AREA_BENCH_1 + call LookForCardIDInPlayArea_Bank5 + cp $ff + jr nz, .found + ld a, PLAY_AREA_BENCH_1 +.found + ldh [hTempPlayAreaLocation_ff9d], a + ret +; 0x1483a + +; has AI execute some scripted actions depending on Duel turn. +AIPerformSciptedTurn: ; 1483a (5:483a) + ld a, [wDuelTurns] + srl a + ld hl, .scripted_actions_list + call JumpToFunctionInTable + +; always attack with Arena card's first attack. +; if it's unusable end turn without attacking. + xor a + ldh [hTempPlayAreaLocation_ff9d], a + ld [wSelectedAttack], a + call CheckIfSelectedMoveIsUnusable + jr c, .unusable + call AITryUseAttack + ret + +.unusable + ld a, OPPACTION_FINISH_NO_ATTACK + bank1call AIMakeDecision + ret +; 0x1485a + +.scripted_actions_list ; 1485a (05:485a) + dw .turn_1 + dw .turn_2 + dw .turn_3 + dw .turn_4 + dw .turn_5 + dw .turn_6 + dw .turn_7 +; 0x14868 + +.turn_1 ; 14868 (5:4868) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x14870 + +.turn_2 ; 14870 (5:4870) + ld a, RATTATA + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + ld d, RATTATA + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x14884 + +.turn_3 ; 14884 (5:4884) + ld a, RATTATA + ld b, PLAY_AREA_ARENA + call LookForCardIDInPlayArea_Bank5 + ldh [hTempPlayAreaLocation_ffa1], a + ld a, RATICATE + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_EVOLVE_PKMN + bank1call AIMakeDecision + ld d, RATICATE + ld e, LIGHTNING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148a1 + +.turn_4 ; 148a1 (5:48a1) + ld d, RATICATE + ld e, LIGHTNING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148a9 + +.turn_5 ; 148a9 (5:48a9) + ld a, MACHOP + call LookForCardIDInHandList_Bank5 + ldh [hTemp_ffa0], a + ld a, OPPACTION_PLAY_BASIC_PKMN + bank1call AIMakeDecision + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInBench + +; this is a bug, it's attempting to compare a card ID with a deck index. +; the intention was to change the card to switch to depending on whether +; the first Machop was KO'd at this point in the Duel or not. +; because of the buggy comparison, this will always jump the +; 'inc a' instruction and switch to PLAY_AREA_BENCH_1. +; in a normal Practice Duel following Dr. Mason's instructions, +; this will always lead to the AI correctly switching Raticate with Machop, +; but in case of a "Free" Duel where the first Machop is not KO'd, +; the intention was to switch to PLAY_AREA_BENCH_2 instead. +; but due to 'inc a' always being skipped, it will switch to Raticate. + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + cp MACHOP ; wrong + ld a, PLAY_AREA_BENCH_1 + jr nz, .retreat + inc a ; PLAY_AREA_BENCH_2 + +.retreat + call AITryToRetreat + ret +; 0x148cc + +.turn_6 ; 148cc (5:48cc) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148d4 + +.turn_7 ; 148d4 (5:48d4) + ld d, MACHOP + ld e, FIGHTING_ENERGY + call AIAttachEnergyInHandToCardInPlayArea + ret +; 0x148dc diff --git a/src/engine/deck_ai/decks/strange_psyshock.asm b/src/engine/deck_ai/decks/strange_psyshock.asm new file mode 100644 index 0000000..309ef11 --- /dev/null +++ b/src/engine/deck_ai/decks/strange_psyshock.asm @@ -0,0 +1,87 @@ +AIActionTable_StrangePsyshock: ; 15122 (5:5122) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 1512e (5:512e) + call AIMainTurnLogic + ret +; 0x15132 + +.start_duel ; 15132 (5:5132) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x15143 + +.forced_switch ; 15143 (5:5143) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15147 + +.ko_switch ; 15147 (5:5147) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1514b + +.take_prize ; 1514b (5:514b) + call AIPickPrizeCards + ret +; 0x1514f + +.list_arena ; 1514f (5:514f) + db KANGASKHAN + db CHANSEY + db SNORLAX + db MR_MIME + db ABRA + db $00 + +.list_bench ; 15155 (5:5155) + db ABRA + db MR_MIME + db KANGASKHAN + db SNORLAX + db CHANSEY + db $00 + +.list_retreat ; 1515b (5:515b) + ai_retreat ABRA, -3 + ai_retreat SNORLAX, -3 + ai_retreat KANGASKHAN, -1 + ai_retreat CHANSEY, -1 + db $00 + +.list_energy ; 15164 (5:5164) + ai_energy ABRA, 3, +1 + ai_energy KADABRA, 3, +0 + ai_energy ALAKAZAM, 3, +0 + ai_energy MR_MIME, 2, +0 + ai_energy CHANSEY, 2, -2 + ai_energy KANGASKHAN, 4, -2 + ai_energy SNORLAX, 0, -8 + db $00 + +.list_prize ; 1517a (5:517a) + db GAMBLER + db MR_MIME + db ALAKAZAM + db SWITCH + db $00 + +.store_list_pointers ; 1517f (5:517f) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x151ad diff --git a/src/engine/deck_ai/decks/wonders_of_science.asm b/src/engine/deck_ai/decks/wonders_of_science.asm new file mode 100644 index 0000000..e11a829 --- /dev/null +++ b/src/engine/deck_ai/decks/wonders_of_science.asm @@ -0,0 +1,83 @@ +AIActionTable_WondersOfScience: ; 151ad (5:51ad) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 151b9 (5:51b9) + call AIMainTurnLogic + ret +; 0x151bd + +.start_duel ; 151bd (5:51bd) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x151ce + +.forced_switch ; 151ce (5:51ce) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d2 + +.ko_switch ; 151d2 (5:51d2) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x151d6 + +.take_prize ; 151d6 (5:51d6) + call AIPickPrizeCards + ret +; 0x151da + +.list_arena ; 151da (5:51da) + db MEWTWO1 + db MEWTWO3 + db MEWTWO2 + db GRIMER + db KOFFING + db PORYGON + db $00 + +.list_bench ; 151e1 (5:51e1) + db GRIMER + db KOFFING + db MEWTWO3 + db MEWTWO2 + db MEWTWO1 + db PORYGON + db $00 + +.list_retreat ; 151e8 (5:51e8) + db $00 + +.list_energy ; 151e9 (5:51e9) + ai_energy GRIMER, 3, +0 + ai_energy MUK, 4, +0 + ai_energy KOFFING, 2, +0 + ai_energy WEEZING, 3, +0 + ai_energy MEWTWO1, 2, -1 + ai_energy MEWTWO3, 2, -1 + ai_energy MEWTWO2, 2, -1 + ai_energy PORYGON, 2, -1 + db $00 + +.list_prize ; 15202 (5:5202) + db MUK + db $00 + +.store_list_pointers ; 15204 (5:5204) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x15232 diff --git a/src/engine/deck_ai/decks/zapping_selfdestruct.asm b/src/engine/deck_ai/decks/zapping_selfdestruct.asm new file mode 100644 index 0000000..6675c52 --- /dev/null +++ b/src/engine/deck_ai/decks/zapping_selfdestruct.asm @@ -0,0 +1,81 @@ +AIActionTable_ZappingSelfdestruct: ; 15019 (5:5019) + dw .do_turn ; unused + dw .do_turn + dw .start_duel + dw .forced_switch + dw .ko_switch + dw .take_prize + +.do_turn ; 15025 (5:5025) + call AIMainTurnLogic + ret +; 0x15029 + +.start_duel ; 15029 (5:5029) + call InitAIDuelVars + call .store_list_pointers + call SetUpBossStartingHandAndDeck + call TrySetUpBossStartingPlayArea + ret nc + call AIPlayInitialBasicCards + ret +; 0x1503a + +.forced_switch ; 1503a (5:503a) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x1503e + +.ko_switch ; 1503e (5:503e) + call AIDecideBenchPokemonToSwitchTo + ret +; 0x15042 + +.take_prize ; 15042 (5:5042) + call AIPickPrizeCards + ret +; 0x15046 + +.list_arena ; 15046 (5:5046) + db KANGASKHAN + db ELECTABUZZ2 + db TAUROS + db MAGNEMITE1 + db VOLTORB + db $00 + +.list_bench ; 1504c (5:504c) + db MAGNEMITE1 + db VOLTORB + db ELECTABUZZ2 + db TAUROS + db KANGASKHAN + db $00 + +.list_retreat ; 15052 (5:5052) + ai_retreat VOLTORB, -1 + db $00 + +.list_energy ; 15055 (5:5055) + ai_energy MAGNEMITE1, 3, +1 + ai_energy MAGNETON1, 4, +0 + ai_energy VOLTORB, 3, +1 + ai_energy ELECTRODE1, 3, +0 + ai_energy ELECTABUZZ2, 1, +0 + ai_energy KANGASKHAN, 2, -2 + ai_energy TAUROS, 3, +0 + db $00 + +.list_prize ; 1506b (5:506b) + db KANGASKHAN + db $00 + +.store_list_pointers ; 1506d (5:506d) + store_list_pointer wAICardListAvoidPrize, .list_prize + store_list_pointer wAICardListArenaPriority, .list_arena + store_list_pointer wAICardListBenchPriority, .list_bench + store_list_pointer wAICardListPlayFromHandPriority, .list_bench + ; missing store_list_pointer wAICardListRetreatBonus, .list_retreat + store_list_pointer wAICardListEnergyBonus, .list_energy + ret +; 0x1509b -- cgit v1.2.3 From 86d8cfb0fd86326e4534fc33c7bb384d515bbe0e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 9 May 2020 12:11:05 +0100 Subject: Separate AI constants and new AIACTION_* --- src/constants.asm | 1 + src/constants/deck_ai_constants.asm | 61 +++++++++++++++++++++++++++++++++++++ src/constants/duel_constants.asm | 53 -------------------------------- src/data/deck_ai_pointers.asm | 2 +- src/engine/bank01.asm | 8 ++--- src/engine/deck_ai/deck_ai.asm | 1 + src/engine/effect_functions.asm | 2 +- src/engine/home.asm | 40 +++++++++++++----------- 8 files changed, 91 insertions(+), 77 deletions(-) create mode 100644 src/constants/deck_ai_constants.asm (limited to 'src') diff --git a/src/constants.asm b/src/constants.asm index 4e6f410..6e6f0b3 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -1,6 +1,7 @@ INCLUDE "constants/booster_constants.asm" INCLUDE "constants/card_constants.asm" INCLUDE "constants/card_data_constants.asm" +INCLUDE "constants/deck_ai_constants.asm" INCLUDE "constants/deck_constants.asm" INCLUDE "constants/duel_constants.asm" INCLUDE "constants/duel_interface_constants.asm" diff --git a/src/constants/deck_ai_constants.asm b/src/constants/deck_ai_constants.asm new file mode 100644 index 0000000..ceae8ed --- /dev/null +++ b/src/constants/deck_ai_constants.asm @@ -0,0 +1,61 @@ +; wPreviousAIFlags and wCurrentAIFlags constants +AI_FLAG_USED_PLUSPOWER EQU 1 << 0 +AI_FLAG_USED_SWITCH EQU 1 << 1 +AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 +AI_FLAG_MODIFIED_HAND EQU 1 << 3 +AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 + +; used as input for AIProcessEnergyCards to determine what to check +; and whether to play card after the routine is over. +; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine +; not to actually play the energy card after it's finished, +; but AIProcessEnergyCards checks whether ANY flag is set in order +; to decide not to play it, so it's redundant in the presence of another flag. +AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) +AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions +AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy + +; used to determine which Trainer cards for AI +; to process in AIProcessHandTrainerCards. +; these go in chronological order, except for +; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. +; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. +; if Professor Oak is played, all other Trainer card phases +; are processed again except AI_TRAINER_CARD_PHASE_15. + const_def 1 + const AI_TRAINER_CARD_PHASE_01 ; $1 + const AI_TRAINER_CARD_PHASE_02 ; $2 + const AI_TRAINER_CARD_PHASE_03 ; $3 + const AI_TRAINER_CARD_PHASE_04 ; $4 + const AI_TRAINER_CARD_PHASE_05 ; $5 + const AI_TRAINER_CARD_PHASE_06 ; $6 + const AI_TRAINER_CARD_PHASE_07 ; $7 + const AI_TRAINER_CARD_PHASE_08 ; $8 + const AI_TRAINER_CARD_PHASE_09 ; $9 + const AI_TRAINER_CARD_PHASE_10 ; $a + const AI_TRAINER_CARD_PHASE_11 ; $b + const AI_TRAINER_CARD_PHASE_12 ; $c + const AI_TRAINER_CARD_PHASE_13 ; $d + const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack + const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak + +; used by wAIBarrierFlagCounter to determine +; whether Player is running Mewtwo1 mill deck. +; flag set means true, flag not set means false. +AI_FLAG_MEWTWO_MILL EQU 1 << 7 + +; defines the behaviour of HandleAIEnergyTrans, for determining +; whether to move energy cards from the Bench to the Arena or vice-versa +; and the number of energy cards needed for achieving that. +AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost +AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack +AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card + +; used to know which AI routine to call in +; the AIAction pointer tables in AIDoAction + const_def 1 + const AIACTION_DO_TURN ; $1 + const AIACTION_START_DUEL ; $2 + const AIACTION_FORCED_SWITCH ; $3 + const AIACTION_KO_SWITCH ; $4 + const AIACTION_TAKE_PRIZE ; $5 diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index dd692d0..d461d24 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -226,56 +226,3 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 - -; wPreviousAIFlags and wCurrentAIFlags constants -AI_FLAG_USED_PLUSPOWER EQU 1 << 0 -AI_FLAG_USED_SWITCH EQU 1 << 1 -AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 -AI_FLAG_MODIFIED_HAND EQU 1 << 3 -AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 - -; used as input for AIProcessEnergyCards to determine what to check -; and whether to play card after the routine is over. -; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine -; not to actually play the energy card after it's finished, -; but AIProcessEnergyCards checks whether ANY flag is set in order -; to decide not to play it, so it's redundant in the presence of another flag. -AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) -AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions -AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy - -; used to determine which Trainer cards for AI -; to process in AIProcessHandTrainerCards. -; these go in chronological order, except for -; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. -; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. -; if Professor Oak is played, all other Trainer card phases -; are processed again except AI_TRAINER_CARD_PHASE_15. - const_def 1 - const AI_TRAINER_CARD_PHASE_01 ; $1 - const AI_TRAINER_CARD_PHASE_02 ; $2 - const AI_TRAINER_CARD_PHASE_03 ; $3 - const AI_TRAINER_CARD_PHASE_04 ; $4 - const AI_TRAINER_CARD_PHASE_05 ; $5 - const AI_TRAINER_CARD_PHASE_06 ; $6 - const AI_TRAINER_CARD_PHASE_07 ; $7 - const AI_TRAINER_CARD_PHASE_08 ; $8 - const AI_TRAINER_CARD_PHASE_09 ; $9 - const AI_TRAINER_CARD_PHASE_10 ; $a - const AI_TRAINER_CARD_PHASE_11 ; $b - const AI_TRAINER_CARD_PHASE_12 ; $c - const AI_TRAINER_CARD_PHASE_13 ; $d - const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack - const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak - -; used by wAIBarrierFlagCounter to determine -; whether Player is running Mewtwo1 mill deck. -; flag set means true, flag not set means false. -AI_FLAG_MEWTWO_MILL EQU 1 << 7 - -; defines the behaviour of HandleAIEnergyTrans, for determining -; whether to move energy cards from the Bench to the Arena or vice-versa -; and the number of energy cards needed for achieving that. -AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost -AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack -AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card diff --git a/src/data/deck_ai_pointers.asm b/src/data/deck_ai_pointers.asm index 72cbfb0..4f00299 100644 --- a/src/data/deck_ai_pointers.asm +++ b/src/data/deck_ai_pointers.asm @@ -1,4 +1,4 @@ -PointerTable_14000: ; 14000 (05:4000) +DeckAIPointerTable: ; 14000 (05:4000) dw AIActionTable_SamPractice ; SAMS_PRACTICE_DECK dw AIActionTable_GeneralDecks ; PRACTICE_PLAYER_DECK dw AIActionTable_GeneralDecks ; SAMS_NORMAL_DECK diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 7eb7340..8f780eb 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -353,7 +353,7 @@ DuelMainInterface: ; 426d (1:426d) ld [wSkipDuelistIsThinkingDelay], a ldtx hl, DuelistIsThinkingText call DrawWideTextBox_PrintTextNoDelay - call Func_2bbf + call AIDoAction_Turn ld a, $ff ld [wPlayerAttackingCardIndex], a ld [wPlayerAttackingMoveIndex], a @@ -1967,7 +1967,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) ; AI opponent's turn push af push hl - call Func_2bc3 + call AIDoAction_StartDuel pop hl pop af ld [hl], a @@ -3757,7 +3757,7 @@ Func_5805: ; 5805 (1:5805) call GetTurnDuelistVariable cp DUELIST_TYPE_LINK_OPP jr z, .link_opponent - call Func_2bd7 + call AIDoAction_TakePrize ld c, DECK_SIZE .asm_5858 call DoFrame @@ -7492,7 +7492,7 @@ ReplaceKnockedOutPokemon: ; 6f23 (1:6f23) .opponent cp DUELIST_TYPE_LINK_OPP jr z, .link_opponent - call Func_2bcf + call AIDoAction_KOSwitch ldh a, [hTemp_ffa0] ldh [hTempPlayAreaLocation_ff9d], a jr .replace_pokemon diff --git a/src/engine/deck_ai/deck_ai.asm b/src/engine/deck_ai/deck_ai.asm index a906472..c8b73f3 100644 --- a/src/engine/deck_ai/deck_ai.asm +++ b/src/engine/deck_ai/deck_ai.asm @@ -33,6 +33,7 @@ ENDM ; deck AIs are specialized to work on a given deck ID. ; they decide what happens during a turn, what Pokemon cards ; to pick during the start of the duel, etc. +; the different scenarios these are used are listed in AIACTION_* constants. ; each of these have a pointer table with the following structure: ; dw .do_turn : never called; ; diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 762e82d..75b0f76 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -437,7 +437,7 @@ DuelistSelectForcedSwitch: ; 2c487 (b:4487) ; AI opponent call SwapTurn - bank1call Func_2bc7 + bank1call AIDoAction_ForcedSwitch call SwapTurn ld a, [wPlayerAttackingMoveIndex] diff --git a/src/engine/home.asm b/src/engine/home.asm index c56e0c6..a9d28d6 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -8280,37 +8280,41 @@ LoadOpponentDeck: ; 2b78 (0:2b78) ld [hl], a ret -Func_2bbf: ; 2bbf (0:2bbf) - ld a, $1 - jr Func_2bdb +AIDoAction_Turn: ; 2bbf (0:2bbf) + ld a, AIACTION_DO_TURN + jr AIDoAction -Func_2bc3: ; 2bc3 (0:2bc3) - ld a, $2 - jr Func_2bdb +AIDoAction_StartDuel: ; 2bc3 (0:2bc3) + ld a, AIACTION_START_DUEL + jr AIDoAction -Func_2bc7: ; 2bc7 (0:2bc7) - ld a, $3 - call Func_2bdb +AIDoAction_ForcedSwitch: ; 2bc7 (0:2bc7) + ld a, AIACTION_FORCED_SWITCH + call AIDoAction ldh [hTempPlayAreaLocation_ff9d], a ret -Func_2bcf: ; 2bcf (0:2bcf) - ld a, $4 - call Func_2bdb +AIDoAction_KOSwitch: ; 2bcf (0:2bcf) + ld a, AIACTION_KO_SWITCH + call AIDoAction ldh [hTemp_ffa0], a ret -Func_2bd7: ; 2bd7 (0:2bd7) - ld a, $5 - jr Func_2bdb ; this line is not needed +AIDoAction_TakePrize: ; 2bd7 (0:2bd7) + ld a, AIACTION_TAKE_PRIZE + jr AIDoAction ; this line is not needed -Func_2bdb: ; 2bdb (0:2bdb) +; calls the appropriate AI routine to handle action, +; depending on the deck ID (see engine/deck_ai/deck_ai.asm) +; input: +; - a = AIACTION_* constant +AIDoAction: ; 2bdb (0:2bdb) ld c, a ; load bank for Opponent Deck pointer table ldh a, [hBankROM] push af - ld a, BANK(PointerTable_14000) + ld a, BANK(DeckAIPointerTable) call BankswitchROM ; load hl with the corresponding pointer @@ -8318,7 +8322,7 @@ Func_2bdb: ; 2bdb (0:2bdb) ld l, a ld h, $0 add hl, hl ; two bytes per deck - ld de, PointerTable_14000 + ld de, DeckAIPointerTable add hl, de ld a, [hli] ld h, [hl] -- cgit v1.2.3 From e02184fbcd4426fd0774d0dd80268c515d8aadd1 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sat, 9 May 2020 15:36:16 -0400 Subject: changed OWScript to ScriptCommand and OWSequence to Script --- src/data/map_objects.asm | 30 +- src/data/npcs.asm | 220 ++--- src/engine/bank03.asm | 2240 +++++++++++++++++++++++----------------------- src/engine/bank04.asm | 116 +-- src/engine/bank07.asm | 6 +- src/engine/home.asm | 8 +- src/macros/scripts.asm | 114 +-- src/wram.asm | 8 +- 8 files changed, 1371 insertions(+), 1371 deletions(-) (limited to 'src') diff --git a/src/data/map_objects.asm b/src/data/map_objects.asm index 0756f7f..1ac73fa 100644 --- a/src/data/map_objects.asm +++ b/src/data/map_objects.asm @@ -50,12 +50,12 @@ MasonLabObjects: ; 13b04 (3:7b04) DeckMachineRoomObjects: ; 13b4d (3:7b4d) db NORTH, 2, 2 - dw OWSequence_d932 + dw Script_d932 tx Text041b tx Text041a db NORTH, 4, 2 - dw OWSequence_d932 + dw Script_d932 tx Text041b tx Text041a @@ -238,7 +238,7 @@ FightingClubLobbyObjects: ; 13c6f (3:7c6f) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -272,7 +272,7 @@ RockClubLobbyObjects: ; 13ca6 (3:7ca6) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -306,7 +306,7 @@ WaterClubLobbyObjects: ; 13cdd (3:7cdd) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -340,7 +340,7 @@ LightningClubLobbyObjects: ; 13d14 (3:7d14) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -374,7 +374,7 @@ GrassClubLobbyObjects: ; 13d4b (3:7d4b) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -408,7 +408,7 @@ PsychicClubLobbyObjects: ; 13d82 (3:7d82) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -442,7 +442,7 @@ ScienceClubLobbyObjects: ; 13db9 (3:7db9) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -476,7 +476,7 @@ FireClubLobbyObjects: ; 13df0 (3:7df0) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -510,7 +510,7 @@ ChallengeHallLobbyObjects: ; 13e27 (3:7e27) tx Text041a db NORTH, 6, 6 - dw OWSequence_fc52 + dw Script_fc52 tx Text041b tx Text03b0 @@ -555,12 +555,12 @@ PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) tx Text0505 db NORTH, 18, 0 - dw OWSequence_f631 + dw Script_f631 tx Text0508 tx Text0507 db NORTH, 20, 0 - dw OWSequence_f631 + dw Script_f631 tx Text0508 tx Text0507 @@ -585,13 +585,13 @@ PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) HallOfHonorObjects: ; 13ec2 (3:7ec2) ; Legendary Cards db NORTH, 10, 10 - dw OWSequence_fbf1 + dw Script_fbf1 dw $0000 dw $0000 ; Legendary Cards db NORTH, 12, 10 - dw OWSequence_fbf1 + dw Script_fbf1 dw $0000 dw $0000 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index 0c184ea..99979ce 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -124,7 +124,7 @@ DrMasonData: db $00 db $26 db $00 - dw $5727 ; Pointer to OWScript + dw $5727 ; Pointer to Script tx Text03ac db $00 db $00 @@ -136,7 +136,7 @@ Ronald1Data: db $04 db $0e db $00 - dw OWSequence_Ronald ; Pointer to OWScript + dw Script_Ronald ; Pointer to Script tx Text03ad db RONALD_PIC db INVINCIBLE_RONALD_DECK_ID @@ -148,7 +148,7 @@ Ronald2Data: db $04 db $0e db $00 - dw OWSequence_Ronald ; Pointer to OWScript + dw Script_Ronald ; Pointer to Script tx Text03ad db RONALD_PIC db INVINCIBLE_RONALD_DECK_ID @@ -160,7 +160,7 @@ Ronald3Data: db $04 db $0e db $00 - dw OWSequence_Ronald ; Pointer to OWScript + dw Script_Ronald ; Pointer to Script tx Text03ad db RONALD_PIC db INVINCIBLE_RONALD_DECK_ID @@ -172,7 +172,7 @@ IshiharaData: db $04 db $22 db $00 - dw OWSequence_Ishihara ; Pointer to OWScript + dw Script_Ishihara ; Pointer to Script tx Text03ae db $00 db $00 @@ -184,7 +184,7 @@ ImakuniData: db $00 db $0e db $00 - dw OWSequence_Imakuni ; Pointer to OWScript + dw Script_Imakuni ; Pointer to Script tx Text03af db IMAKUNI_PIC db IMAKUNI_DECK_ID @@ -196,7 +196,7 @@ SamData: db $00 db $0e db $00 - dw $561d ; Pointer to OWScript + dw $561d ; Pointer to Script tx Text03b1 db SAM_PIC db SAMS_NORMAL_DECK_ID @@ -208,7 +208,7 @@ Tech1Data: db $00 db $0e db $00 - dw $5583 ; Pointer to OWScript + dw $5583 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -220,7 +220,7 @@ Tech2Data: db $00 db $0e db $00 - dw $55ca ; Pointer to OWScript + dw $55ca ; Pointer to Script tx Text03b2 db $00 db $00 @@ -232,7 +232,7 @@ Tech3Data: db $00 db $0e db $00 - dw $55d5 ; Pointer to OWScript + dw $55d5 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -244,7 +244,7 @@ Tech4Data: db $00 db $0e db $00 - dw $55e0 ; Pointer to OWScript + dw $55e0 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -256,7 +256,7 @@ Tech5Data: db $00 db $0e db $00 - dw $55f9 ; Pointer to OWScript + dw $55f9 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -268,7 +268,7 @@ Tech6Data: db $00 db $0e db $00 - dw $58bb ; Pointer to OWScript + dw $58bb ; Pointer to Script tx Text03b2 db $00 db $00 @@ -280,7 +280,7 @@ Clerk1Data: db $0a db $30 db $00 - dw OWSequence_Clerk1 ; Pointer to OWScript + dw Script_Clerk1 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -292,7 +292,7 @@ Clerk2Data: db $0a db $30 db $00 - dw $5ed1 ; Pointer to OWScript + dw $5ed1 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -304,7 +304,7 @@ Clerk3Data: db $0a db $30 db $00 - dw $609e ; Pointer to OWScript + dw $609e ; Pointer to Script tx Text03b3 db $00 db $00 @@ -316,7 +316,7 @@ Clerk4Data: db $0a db $30 db $00 - dw $6369 ; Pointer to OWScript + dw $6369 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -328,7 +328,7 @@ Clerk5Data: db $0a db $30 db $00 - dw $6566 ; Pointer to OWScript + dw $6566 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -340,7 +340,7 @@ Clerk6Data: db $0a db $30 db $00 - dw $684c ; Pointer to OWScript + dw $684c ; Pointer to Script tx Text03b3 db $00 db $00 @@ -352,7 +352,7 @@ Clerk7Data: db $0a db $30 db $00 - dw $6b53 ; Pointer to OWScript + dw $6b53 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -364,7 +364,7 @@ Clerk8Data: db $0a db $30 db $00 - dw $6d45 ; Pointer to OWScript + dw $6d45 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -376,7 +376,7 @@ Clerk9Data: db $0a db $30 db $00 - dw OWSequence_Clerk9 ; Pointer to OWScript + dw Script_Clerk9 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -388,7 +388,7 @@ ChrisData: db $00 db $26 db $00 - dw $5ef2 ; Pointer to OWScript + dw $5ef2 ; Pointer to Script tx Text03b4 db CHRIS_PIC db MUSCLES_FOR_BRAINS_DECK_ID @@ -400,7 +400,7 @@ MichaelData: db $00 db $26 db $00 - dw $6573 ; Pointer to OWScript + dw $6573 ; Pointer to Script tx Text03b5 db MICHAEL_PIC db HEATED_BATTLE_DECK_ID @@ -412,7 +412,7 @@ JessicaData: db $04 db $1a db $00 - dw $6d96 ; Pointer to OWScript + dw $6d96 ; Pointer to Script tx Text03b6 db JESSICA_PIC db LOVE_TO_BATTLE_DECK_ID @@ -424,7 +424,7 @@ MitchData: db $00 db $0e db $00 - dw $5dc3 ; Pointer to OWScript + dw $5dc3 ; Pointer to Script tx Text03b7 db MITCH_PIC db FIRST_STRIKE_DECK_ID @@ -436,7 +436,7 @@ MatthewData: db $00 db $16 db $00 - dw $5f39 ; Pointer to OWScript + dw $5f39 ; Pointer to Script tx Text03b8 db MATTHEW_PIC db HARD_POKEMON_DECK_ID @@ -448,7 +448,7 @@ RyanData: db $00 db $26 db $00 - dw $5ff0 ; Pointer to OWScript + dw $5ff0 ; Pointer to Script tx Text03b9 db RYAN_PIC db EXCAVATION_DECK_ID @@ -460,7 +460,7 @@ AndrewData: db $00 db $16 db $00 - dw $6017 ; Pointer to OWScript + dw $6017 ; Pointer to Script tx Text03ba db ANDREW_PIC db BLISTERING_POKEMON_DECK_ID @@ -472,7 +472,7 @@ GeneData: db $04 db $1e db $00 - dw $603e ; Pointer to OWScript + dw $603e ; Pointer to Script tx Text03bb db GENE_PIC db ROCK_CRUSHER_DECK_ID @@ -484,7 +484,7 @@ SaraData: db $00 db $0e db $00 - dw OWSequence_Sara ; Pointer to OWScript + dw Script_Sara ; Pointer to Script tx Text03bc db SARA_PIC db WATERFRONT_POKEMON_DECK_ID @@ -496,7 +496,7 @@ AmandaData: db $00 db $16 db $00 - dw OWSequence_Amanda ; Pointer to OWScript + dw Script_Amanda ; Pointer to Script tx Text03bd db AMANDA_PIC ; battle profile picture db LONELY_FRIENDS_DECK_ID @@ -508,7 +508,7 @@ JoshuaData: db $00 db $26 db $00 - dw OWSequence_Joshua ; Pointer to OWScript + dw Script_Joshua ; Pointer to Script tx Text03be db JOSHUA_PIC db SOUND_OF_THE_WAVES_DECK_ID @@ -520,7 +520,7 @@ AmyData: db $08 db $2e db $10 - dw OWSequence_Amy ; Pointer to OWScript + dw Script_Amy ; Pointer to Script tx Text03bf db AMY_PIC db GO_GO_RAIN_DANCE_DECK_ID @@ -532,7 +532,7 @@ JenniferData: db $04 db $0e db $00 - dw $6408 ; Pointer to OWScript + dw $6408 ; Pointer to Script tx Text03c0 db JENNIFER_PIC db PIKACHU_DECK_ID @@ -544,7 +544,7 @@ NicholasData: db $04 db $1e db $00 - dw $642f ; Pointer to OWScript + dw $642f ; Pointer to Script tx Text03c1 db NICHOLAS_PIC db BOOM_BOOM_SELFDESTRUCT_DECK_ID @@ -556,7 +556,7 @@ BrandonData: db $04 db $1e db $00 - dw $6456 ; Pointer to OWScript + dw $6456 ; Pointer to Script tx Text03c2 db BRANDON_PIC db POWER_GENERATOR_DECK_ID @@ -568,7 +568,7 @@ IsaacData: db $00 db $16 db $00 - dw $64ad ; Pointer to OWScript + dw $64ad ; Pointer to Script tx Text03c3 db ISAAC_PIC db ZAPPING_SELFDESTRUCT_DECK_ID @@ -580,7 +580,7 @@ BrittanyData: db $04 db $0e db $00 - dw OWSequence_Brittany ; Pointer to OWScript + dw Script_Brittany ; Pointer to Script tx Text03c4 db BRITTANY_PIC db ETCETERA_DECK_ID @@ -592,7 +592,7 @@ KristinData: db $00 db $1e db $00 - dw $6701 ; Pointer to OWScript + dw $6701 ; Pointer to Script tx Text03c5 db KRISTIN_PIC db FLOWER_GARDEN_DECK_ID @@ -604,7 +604,7 @@ HeatherData: db $04 db $22 db $00 - dw $6745 ; Pointer to OWScript + dw $6745 ; Pointer to Script tx Text03c6 db HEATHER_PIC db KALEIDOSCOPE_DECK_ID @@ -616,7 +616,7 @@ NikkiData: db $00 db $1a db $00 - dw $679e ; Pointer to OWScript + dw $679e ; Pointer to Script tx Text03c7 db NIKKI_PIC db FLOWER_POWER_DECK_ID @@ -628,7 +628,7 @@ RobertData: db $04 db $16 db $00 - dw $6980 ; Pointer to OWScript + dw $6980 ; Pointer to Script tx Text03c8 db ROBERT_PIC db GHOST_DECK_ID @@ -640,7 +640,7 @@ DanielData: db $04 db $1a db $00 - dw $6a60 ; Pointer to OWScript + dw $6a60 ; Pointer to Script tx Text03c9 db DANIEL_PIC db NAP_TIME_DECK_ID @@ -652,7 +652,7 @@ StephanieData: db $04 db $0e db $00 - dw $6aa2 ; Pointer to OWScript + dw $6aa2 ; Pointer to Script tx Text03ca db STEPHANIE_PIC db STRANGE_POWER_DECK_ID @@ -664,7 +664,7 @@ Murray1Data: db $00 db $12 db $00 - dw $6adf ; Pointer to OWScript + dw $6adf ; Pointer to Script tx Text03cb db MURRAY_PIC db STRANGE_PSYSHOCK_DECK_ID @@ -676,7 +676,7 @@ Murray2Data: db $03 db $15 db $10 - dw $6adf ; Pointer to OWScript + dw $6adf ; Pointer to Script tx Text03cb db MURRAY_PIC db STRANGE_PSYSHOCK_DECK_ID @@ -688,7 +688,7 @@ JosephData: db $00 db $0e db $00 - dw $6cdb ; Pointer to OWScript + dw $6cdb ; Pointer to Script tx Text03cc db JOSEPH_PIC db FLYIN_POKEMON_DECK_ID @@ -700,7 +700,7 @@ DavidData: db $00 db $0e db $00 - dw $6c11 ; Pointer to OWScript + dw $6c11 ; Pointer to Script tx Text03cd db DAVID_PIC db LOVELY_NIDORAN_DECK_ID @@ -712,7 +712,7 @@ ErikData: db $00 db $0e db $00 - dw $6c42 ; Pointer to OWScript + dw $6c42 ; Pointer to Script tx Text03ce db ERIK_PIC db POISON_DECK_ID @@ -724,7 +724,7 @@ RickData: db $00 db $0e db $00 - dw $6c67 ; Pointer to OWScript + dw $6c67 ; Pointer to Script tx Text03cf db RICK_PIC db WONDERS_OF_SCIENCE_DECK_ID @@ -736,7 +736,7 @@ JohnData: db $04 db $1a db $00 - dw $6eb3 ; Pointer to OWScript + dw $6eb3 ; Pointer to Script tx Text03d0 db JOHN_PIC db ANGER_DECK_ID @@ -748,7 +748,7 @@ AdamData: db $00 db $22 db $00 - dw $6ed8 ; Pointer to OWScript + dw $6ed8 ; Pointer to Script tx Text03d1 db ADAM_PIC db FLAMETHROWER_DECK_ID @@ -760,7 +760,7 @@ JonathanData: db $04 db $16 db $00 - dw $6efd ; Pointer to OWScript + dw $6efd ; Pointer to Script tx Text03d2 db JONATHAN_PIC db RESHUFFLE_DECK_ID @@ -772,7 +772,7 @@ KenData: db $04 db $1e db $00 - dw $6f22 ; Pointer to OWScript + dw $6f22 ; Pointer to Script tx Text03d3 db KEN_PIC db FIRE_CHARGE_DECK_ID @@ -784,7 +784,7 @@ CourtneyData: db $00 db $12 db $00 - dw $771f ; Pointer to OWScript + dw $771f ; Pointer to Script tx Text03d4 db COURTNEY_PIC db LEGENDARY_MOLTRES_DECK_ID @@ -796,7 +796,7 @@ SteveData: db $00 db $2a db $00 - dw $772a ; Pointer to OWScript + dw $772a ; Pointer to Script tx Text03d5 db STEVE_PIC db LEGENDARY_ZAPDOS_DECK_ID @@ -808,7 +808,7 @@ JackData: db $00 db $26 db $00 - dw $7735 ; Pointer to OWScript + dw $7735 ; Pointer to Script tx Text03d6 db JACK_PIC db LEGENDARY_ARTICUNO_DECK_ID @@ -820,7 +820,7 @@ RodData: db $00 db $0e db $00 - dw $7740 ; Pointer to OWScript + dw $7740 ; Pointer to Script tx Text03d7 db ROD_PIC db LEGENDARY_DRAGONITE_DECK_ID @@ -832,7 +832,7 @@ Clerk10Data: db $0a db $30 db $00 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script tx Text03b0 db $00 db $00 @@ -844,7 +844,7 @@ GiftCenterClerkData: db $0a db $30 db $00 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script tx Text03b0 db $00 db $00 @@ -856,7 +856,7 @@ Man1Data: db $00 db $16 db $00 - dw $5c76 ; Pointer to OWScript + dw $5c76 ; Pointer to Script tx Text03d8 db $00 db $00 @@ -868,7 +868,7 @@ Woman1Data: db $04 db $1e db $00 - dw $5f83 ; Pointer to OWScript + dw $5f83 ; Pointer to Script tx Text03d9 db $00 db $00 @@ -880,7 +880,7 @@ Chap1Data: db $00 db $1a db $00 - dw $5fc0 ; Pointer to OWScript + dw $5fc0 ; Pointer to Script tx Text03da db $00 db $00 @@ -892,7 +892,7 @@ Gal1Data: db $00 db $16 db $00 - dw OWSequence_Gal1 ; Pointer to OWScript + dw Script_Gal1 ; Pointer to Script tx Text03db db $00 db $00 @@ -904,7 +904,7 @@ Lass1Data: db $00 db $1e db $00 - dw OWSequence_Lass1 ; Pointer to OWScript + dw Script_Lass1 ; Pointer to Script tx Text03dc db $00 db $00 @@ -916,7 +916,7 @@ Chap2Data: db $00 db $1a db $00 - dw $639a ; Pointer to OWScript + dw $639a ; Pointer to Script tx Text03da db $00 db $00 @@ -928,7 +928,7 @@ Lass2Data: db $00 db $1e db $00 - dw OWSequence_e61f ; Pointer to OWScript + dw Script_e61f ; Pointer to Script tx Text03dc db $00 db $00 @@ -940,7 +940,7 @@ Pappy1Data: db $00 db $22 db $00 - dw $69a5 ; Pointer to OWScript + dw $69a5 ; Pointer to Script tx Text03dd db $00 db $00 @@ -952,7 +952,7 @@ Lad1Data: db $04 db $1a db $00 - dw $6b84 ; Pointer to OWScript + dw $6b84 ; Pointer to Script tx Text03de db $00 db $00 @@ -964,7 +964,7 @@ Lad2Data: db $04 db $16 db $00 - dw $6e2c ; Pointer to OWScript + dw $6e2c ; Pointer to Script tx Text03de db $00 db $00 @@ -976,7 +976,7 @@ Chap3Data: db $00 db $1a db $00 - dw $6de8 ; Pointer to OWScript + dw $6de8 ; Pointer to Script tx Text03da db $00 db $00 @@ -988,7 +988,7 @@ Clerk12Data: db $00 db $16 db $00 - dw OWSequence_Clerk12 ; Pointer to OWScript + dw Script_Clerk12 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -1000,7 +1000,7 @@ Clerk13Data: db $00 db $16 db $00 - dw OWSequence_Clerk13 ; Pointer to OWScript + dw Script_Clerk13 ; Pointer to Script tx Text03b3 db $00 db $00 @@ -1012,7 +1012,7 @@ HostData: db $00 db $16 db $00 - dw OWSequence_HostStubbed ; Pointer to OWScript + dw Script_HostStubbed ; Pointer to Script tx Text03df db $00 db $00 @@ -1024,7 +1024,7 @@ Specs1Data: db $00 db $22 db $00 - dw $5d82 ; Pointer to OWScript + dw $5d82 ; Pointer to Script tx Text03e0 db $00 db $00 @@ -1036,7 +1036,7 @@ ButchData: db $00 db $16 db $00 - dw $5d8d ; Pointer to OWScript + dw $5d8d ; Pointer to Script tx Text03e1 db $00 db $00 @@ -1048,7 +1048,7 @@ Granny1Data: db $00 db $16 db $00 - dw $5d9f ; Pointer to OWScript + dw $5d9f ; Pointer to Script tx Text03e5 db $00 db $00 @@ -1060,7 +1060,7 @@ Lass3Data: db $04 db $22 db $00 - dw $5fd2 ; Pointer to OWScript + dw $5fd2 ; Pointer to Script tx Text03dc db $00 db $00 @@ -1072,7 +1072,7 @@ Man2Data: db $00 db $16 db $00 - dw OWSequence_Man2 ; Pointer to OWScript + dw Script_Man2 ; Pointer to Script tx Text03d8 db $00 db $00 @@ -1084,7 +1084,7 @@ Pappy2Data: db $00 db $22 db $00 - dw OWSequence_Pappy2 ; Pointer to OWScript + dw Script_Pappy2 ; Pointer to Script tx Text03dd db $00 db $00 @@ -1096,7 +1096,7 @@ Lass4Data: db $04 db $22 db $00 - dw $63d9 ; Pointer to OWScript + dw $63d9 ; Pointer to Script tx Text03dc db $00 db $00 @@ -1108,7 +1108,7 @@ Hood1Data: db $04 db $1e db $00 - dw $63dd ; Pointer to OWScript + dw $63dd ; Pointer to Script tx Text03e2 db $00 db $00 @@ -1120,7 +1120,7 @@ Granny2Data: db $00 db $16 db $00 - dw $66d8 ; Pointer to OWScript + dw $66d8 ; Pointer to Script tx Text03e5 db $00 db $00 @@ -1132,7 +1132,7 @@ Gal2Data: db $00 db $16 db $00 - dw $66e3 ; Pointer to OWScript + dw $66e3 ; Pointer to Script tx Text03db db $00 db $00 @@ -1144,7 +1144,7 @@ Lad3Data: db $04 db $1a db $00 - dw $6850 ; Pointer to OWScript + dw $6850 ; Pointer to Script tx Text03de db $00 db $00 @@ -1156,7 +1156,7 @@ Gal3Data: db $00 db $16 db $00 - dw $6a30 ; Pointer to OWScript + dw $6a30 ; Pointer to Script tx Text03db db $00 db $00 @@ -1168,7 +1168,7 @@ Chap4Data: db $00 db $1a db $00 - dw $6a3b ; Pointer to OWScript + dw $6a3b ; Pointer to Script tx Text03da db $00 db $00 @@ -1180,7 +1180,7 @@ Man3Data: db $00 db $16 db $00 - dw $6bc1 ; Pointer to OWScript + dw $6bc1 ; Pointer to Script tx Text03d8 db $00 db $00 @@ -1192,7 +1192,7 @@ Specs2Data: db $00 db $0e db $00 - dw $6bc5 ; Pointer to OWScript + dw $6bc5 ; Pointer to Script tx Text03e0 db $00 db $00 @@ -1204,7 +1204,7 @@ Specs3Data: db $00 db $22 db $00 - dw $6bed ; Pointer to OWScript + dw $6bed ; Pointer to Script tx Text03e0 db $00 db $00 @@ -1216,7 +1216,7 @@ Woman2Data: db $04 db $1e db $00 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script tx Text03d9 db $00 db $00 @@ -1228,7 +1228,7 @@ ManiaData: db $00 db $26 db $00 - dw $6e88 ; Pointer to OWScript + dw $6e88 ; Pointer to Script tx Text03e4 db $00 db $00 @@ -1240,7 +1240,7 @@ Pappy3Data: db $00 db $22 db $00 - dw OWSequence_Pappy3 ; Pointer to OWScript + dw Script_Pappy3 ; Pointer to Script tx Text03dd db $00 db $00 @@ -1252,7 +1252,7 @@ Gal4Data: db $00 db $16 db $00 - dw OWSequence_Gal4 ; Pointer to OWScript + dw Script_Gal4 ; Pointer to Script tx Text03db db $00 db $00 @@ -1264,7 +1264,7 @@ ChampData: db $00 db $26 db $00 - dw OWSequence_Champ ; Pointer to OWScript + dw Script_Champ ; Pointer to Script tx Text03e3 db $00 db $00 @@ -1276,7 +1276,7 @@ Hood2Data: db $04 db $1e db $00 - dw OWSequence_Hood2 ; Pointer to OWScript + dw Script_Hood2 ; Pointer to Script tx Text03e2 db $00 db $00 @@ -1288,7 +1288,7 @@ Lass5Data: db $04 db $1a db $00 - dw OWSequence_Lass5 ; Pointer to OWScript + dw Script_Lass5 ; Pointer to Script tx Text03dc db $00 db $00 @@ -1300,7 +1300,7 @@ Chap5Data: db $00 db $1a db $00 - dw OWSequence_Chap5 ; Pointer to OWScript + dw Script_Chap5 ; Pointer to Script tx Text03da db $00 db $00 @@ -1312,7 +1312,7 @@ AaronData: db $00 db $0e db $00 - dw $58dd ; Pointer to OWScript + dw $58dd ; Pointer to Script tx Text03e7 db AARON_PIC db LIGHTNING_AND_FIRE_DECK_ID @@ -1324,7 +1324,7 @@ GuideData: db $00 db $16 db $00 - dw OWSequence_Guide ; Pointer to OWScript + dw Script_Guide ; Pointer to Script tx Text03e6 db $00 db $00 @@ -1336,7 +1336,7 @@ Tech7Data: db $00 db $0e db $00 - dw $58c6 ; Pointer to OWScript + dw $58c6 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -1348,7 +1348,7 @@ Tech8Data: db $00 db $0e db $00 - dw $58d1 ; Pointer to OWScript + dw $58d1 ; Pointer to Script tx Text03b2 db $00 db $00 @@ -1360,49 +1360,49 @@ Data_11f18: db $3a db $3a db $10 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f1f: db NPC_LEGENDARY_CARD_TOP_LEFT db $27 db $3b db $41 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f26: db NPC_LEGENDARY_CARD_TOP_RIGHT db $27 db $3c db $42 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f2d: db NPC_LEGENDARY_CARD_LEFT_SPARK db $27 db $3d db $43 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f34: db NPC_LEGENDARY_CARD_BOTTOM_LEFT db $27 db $3e db $44 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f3b: db NPC_LEGENDARY_CARD_BOTTOM_RIGHT db $27 db $3f db $45 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f42: db NPC_LEGENDARY_CARD_RIGHT_SPARK db $27 db $40 db $46 db $50 - dw NoOverworldSequence ; Pointer to OWScript + dw NoOverworldSequence ; Pointer to Script Data_11f49: db $00 db $00 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 80722f7..7fb9ee9 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -96,8 +96,8 @@ HandleOverworldMode: ; c0ce (3:40ce) OverworldModePointers: ; c0e0 (3:40e0) dw Func_c0e8 ; on map dw CallHandlePlayerMoveMode - dw SetOWSequenceData - dw EnterOWSequence + dw SetScriptData + dw EnterScript Func_c0e8: ; c0e8 (3:40e8) farcall Func_10e55 @@ -107,20 +107,20 @@ CallHandlePlayerMoveMode: ; c0ed (3:40ed) call HandlePlayerMoveMode ret -SetOWSequenceData: ; c0f1 (3:40f1) +SetScriptData: ; c0f1 (3:40f1) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a - farcall SetNewOWSequenceNPC + farcall SetNewScriptNPC ld a, c - ld [wNextOWSequence], a + ld [wNextScript], a ld a, b - ld [wNextOWSequence+1], a + ld [wNextScript+1], a ld a, $3 ld [wOverworldMode], a - jr EnterOWSequence + jr EnterScript -EnterOWSequence: ; c10a (3:410a) - ld hl, wNextOWSequence +EnterScript: ; c10a (3:410a) + ld hl, wNextScript ld a, [hli] ld h, [hl] ld l, a @@ -758,7 +758,7 @@ AttemptPlayerMovementFromDirection: ; c5fe (3:45fe) pop bc ret -StartScriptedMovement: ; c607 (3:4607) +StartScript_dMovement: ; c607 (3:4607) push bc ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a @@ -1204,18 +1204,18 @@ Func_c915: ; c915 (3:4915) pop bc ret -SetNextNPCAndOWSequence: ; c926 (3:4926) +SetNextNPCAndScript: ; c926 (3:4926) push bc call FindLoadedNPC ld a, [wLoadedNPCTempIndex] ld [wScriptNPC], a - farcall SetNewOWSequenceNPC + farcall SetNewScriptNPC pop bc ; fallthrough -SetNextOWSequence: ; c935 (3:4935) +SetNextScript: ; c935 (3:4935) push hl - ld hl, wNextOWSequence + ld hl, wNextScript ld [hl], c inc hl ld [hl], b @@ -1732,67 +1732,67 @@ Func_cc32: ; cc32 (3:4c32) call Func_c8ba ret -; Used for things that are represented as NPCs but don't have an OWSequence +; Used for things that are represented as NPCs but don't have a Script ; EX: Clerks and legendary cards that interact through Level Objects NoOverworldSequence: ; cc3e (3:4c3e) call CloseAdvancedDialogueBox ret -; Enters into the script loop, continuing until wBreakOWScriptLoop > 0 +; Enters into the script loop, continuing until wBreakScriptLoop > 0 ; When the loop is broken, it resumes normal code execution where script ended ; Note: Some scripts "double return" and skip this. RST20: ; cc42 (3:4c42) pop hl ld a, l - ld [wOWScriptPointer], a + ld [wScriptPointer], a ld a, h - ld [wOWScriptPointer+1], a + ld [wScriptPointer+1], a xor a - ld [wBreakOWScriptLoop], a + ld [wBreakScriptLoop], a .continueScriptLoop call RunOverworldScript - ld a, [wBreakOWScriptLoop] ; if you break out, it jumps + ld a, [wBreakScriptLoop] ; if you break out, it jumps or a jr z, .continueScriptLoop - ld hl, wOWScriptPointer + ld hl, wScriptPointer ld a, [hli] ld c, a ld b, [hl] retbc -IncreaseOWScriptPointerBy1: ; cc60 (3:4c60) +IncreaseScriptPointerBy1: ; cc60 (3:4c60) ld a, 1 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy2: ; cc64 (3:4c64) + jr IncreaseScriptPointer +IncreaseScriptPointerBy2: ; cc64 (3:4c64) ld a, 2 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy4: ; cc68 (3:4c68) + jr IncreaseScriptPointer +IncreaseScriptPointerBy4: ; cc68 (3:4c68) ld a, 4 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy5: ; cc6c (3:4c6c) + jr IncreaseScriptPointer +IncreaseScriptPointerBy5: ; cc6c (3:4c6c) ld a, 5 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy6: ; cc70 (3:4c70) + jr IncreaseScriptPointer +IncreaseScriptPointerBy6: ; cc70 (3:4c70) ld a, 6 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy7: ; cc74 (3:4c74) + jr IncreaseScriptPointer +IncreaseScriptPointerBy7: ; cc74 (3:4c74) ld a, 7 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy3: ; cc78 (3:4c78) + jr IncreaseScriptPointer +IncreaseScriptPointerBy3: ; cc78 (3:4c78) ld a, 3 -IncreaseOWScriptPointer: ; cc7a (3:4c7a) +IncreaseScriptPointer: ; cc7a (3:4c7a) ld c, a - ld a, [wOWScriptPointer] + ld a, [wScriptPointer] add c - ld [wOWScriptPointer], a - ld a, [wOWScriptPointer+1] + ld [wScriptPointer], a + ld a, [wScriptPointer+1] adc 0 - ld [wOWScriptPointer+1], a + ld [wScriptPointer+1], a ret -SetOWScriptPointer: ; cc8b (3:4c8b) - ld hl, wOWScriptPointer +SetScriptPointer: ; cc8b (3:4c8b) + ld hl, wScriptPointer ld [hl], c inc hl ld [hl], b @@ -1801,23 +1801,23 @@ SetOWScriptPointer: ; cc8b (3:4c8b) INCROM $cc92, $cc96 -GetOWSArgs1AfterPointer: ; cc96 (3:4c96) +GetScriptArgs1AfterPointer: ; cc96 (3:4c96) ld a, $1 - jr GetOWSArgsAfterPointer + jr GetScriptArgsAfterPointer -GetOWSArgs2AfterPointer: ; cc9a (3:4c9a) +GetScriptArgs2AfterPointer: ; cc9a (3:4c9a) ld a, $2 - jr GetOWSArgsAfterPointer -GetOWSArgs3AfterPointer: ; cc9e (3:4c9e) + jr GetScriptArgsAfterPointer +GetScriptArgs3AfterPointer: ; cc9e (3:4c9e) ld a, $3 -GetOWSArgsAfterPointer: ; cca0 (3:4ca0) +GetScriptArgsAfterPointer: ; cca0 (3:4ca0) push hl ld l, a - ld a, [wOWScriptPointer] + ld a, [wScriptPointer] add l ld l, a - ld a, [wOWScriptPointer+1] + ld a, [wScriptPointer+1] adc $0 ld h, a ld a, [hli] @@ -1838,67 +1838,67 @@ SetScriptControlByteFail: ; ccb9 (3:4cb9) ret ; Exits Script mode and runs the next instruction like normal -OWScript_EndScriptLoop1: ; ccbe (3:4cbe) -OWScript_EndScriptLoop2: ; ccbe (3:4cbe) -OWScript_EndScriptLoop3: ; ccbe (3:4cbe) -OWScript_EndScriptLoop4: ; ccbe (3:4cbe) -OWScript_EndScriptLoop5: ; ccbe (3:4cbe) -OWScript_EndScriptLoop6: ; ccbe (3:4cbe) -OWScript_EndScriptLoop7: ; ccbe (3:4cbe) -OWScript_EndScriptLoop8: ; ccbe (3:4cbe) -OWScript_EndScriptLoop9: ; ccbe (3:4cbe) -OWScript_EndScriptLoop10: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop1: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop2: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop3: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop4: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop5: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop6: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop7: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop8: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop9: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop10: ; ccbe (3:4cbe) ld a, $01 - ld [wBreakOWScriptLoop], a - jp IncreaseOWScriptPointerBy1 + ld [wBreakScriptLoop], a + jp IncreaseScriptPointerBy1 -OWScript_CloseAdvancedTextBox: ; ccc6 (3:4cc6) +ScriptCommand_CloseAdvancedTextBox: ; ccc6 (3:4cc6) call CloseAdvancedDialogueBox - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_QuitScriptFully: ; cccc (3:4ccc) - call OWScript_CloseAdvancedTextBox - call OWScript_EndScriptLoop1 +ScriptCommand_QuitScriptFully: ; cccc (3:4ccc) + call ScriptCommand_CloseAdvancedTextBox + call ScriptCommand_EndScriptLoop1 pop hl ret ; args: 2-Text String Index -OWScript_PrintTextString: ; ccd4 (3:4cd4) +ScriptCommand_PrintTextString: ; ccd4 (3:4cd4) ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 Func_ccdc: ; ccdc (3:4cdc) ld l, c ld h, b call Func_c891 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -OWScript_AskQuestionJumpDefaultYes: ; cce4 (3:4ce4) +ScriptCommand_AskQuestionJumpDefaultYes: ; cce4 (3:4ce4) ld a, $1 ld [wDefaultYesOrNo], a ; fallthrough ; Asks the player a question then jumps if they answer yes. Seem to be able to ; take a text of 0000 to overwrite last with (yes no) prompt at the bottom -OWScript_AskQuestionJump: ; cce9 (3:4ce9) +ScriptCommand_AskQuestionJump: ; cce9 (3:4ce9) ld l, c ld h, b call Func_c8ed ld a, [hCurMenuItem] ld [wScriptControlByte], a jr c, .asm_ccfe - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer jr z, .asm_ccfe - jp SetOWScriptPointer + jp SetScriptPointer .asm_ccfe - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 ; args - prize cards, deck id, duel theme index ; sets a battle up, doesn't start until we break out of the script system. -OWScript_StartBattle: ; cd01 (3:4d01) +ScriptCommand_StartBattle: ; cd01 (3:4d01) call Func_cd66 ld a, [wScriptNPC] ld l, LOADED_NPC_ID @@ -1932,7 +1932,7 @@ asm_cd2f ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_cd4f: ; cd4f (3:4d4f) call Func_cd66 @@ -1953,7 +1953,7 @@ Func_cd66: ; cd66 (3:4d66) ld [wcc18], a ld a, b ld [wcc19], a - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer ld a, c ld [wDuelTheme], a ret @@ -1963,19 +1963,19 @@ Func_cd76: ; cd76 (3:4d76) ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; prints text arg 1 or arg 2 depending on wScriptControlByte. -OWScript_PrintVariableText: ; cd83 (3:4d83) +ScriptCommand_PrintVariableText: ; cd83 (3:4d83) ld a, [wScriptControlByte] or a jr nz, .printText - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer .printText ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 Func_cd94: ; cd94 (3:4d94) get_flag_value EVENT_FLAG_44 @@ -1984,32 +1984,32 @@ Unknown_cd98: and $3 add a inc a - call GetOWSArgsAfterPointer + call GetScriptArgsAfterPointer ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy7 + jp IncreaseScriptPointerBy7 Func_cda8: ; cda8 (3:4da8) ld a, [wScriptControlByte] or a jr nz, .asm_cdb1 - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer .asm_cdb1 ld l, c ld h, b call Func_c891 - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 ; Does not return to RST20 - pops an extra time to skip that. -OWScript_PrintTextQuitFully: ; cdb9 (3:4db9) +ScriptCommand_PrintTextQuitFully: ; cdb9 (3:4db9) ld l, c ld h, b call Func_cc32 call CloseAdvancedDialogueBox ld a, $1 - ld [wBreakOWScriptLoop], a - call IncreaseOWScriptPointerBy3 + ld [wBreakScriptLoop], a + call IncreaseScriptPointerBy3 pop hl ret @@ -2018,7 +2018,7 @@ Func_cdcb: ; cdcb (3:4dcb) ld [wLoadedNPCTempIndex], a Func_cdd1: ; cdd1 (3:4dd1) farcall Func_1c50a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_cdd8: ; cdd8 (3:4dd8) ld a, [wLoadedNPCTempIndex] @@ -2055,11 +2055,11 @@ Func_cdf5: ; cdf5 (3:4df5) ld [wTempNPC], a pop af ld [wLoadedNPCTempIndex], a - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 ; Finds and executes an NPCMovement script in the table provided in bc ; based on the active NPC's current direction -OWScript_MoveActiveNPCByDirection: ; ce26 (3:4e26) +ScriptCommand_MoveActiveNPCByDirection: ; ce26 (3:4e26) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a farcall GetNPCDirection @@ -2082,18 +2082,18 @@ ExecuteNPCMovement: ; ce3a (3:4e3a) call DoFrameIfLCDEnabled farcall Func_1c7de jr nz, .asm_ce3e - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 ; Begin a series of NPC movements on the currently talking NPC ; based on the series of directions pointed to by bc -OWScript_MoveActiveNPC: ; ce4a (3:4e4a) +ScriptCommand_MoveActiveNPC: ; ce4a (3:4e4a) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a jr ExecuteNPCMovement ; Begin a series of NPC movements on an arbitrary NPC ; based on the series of directions pointed to by bc -OWScript_MoveWramNPC: ; ce52 (3:4e52) +ScriptCommand_MoveWramNPC: ; ce52 (3:4e52) ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] @@ -2113,26 +2113,26 @@ ExecuteArbitraryNPCMovementFromStack ld [wLoadedNPCTempIndex], a ret -OWScript_MoveArbitraryNPC: ; ce6f (3:4e6f) +ScriptCommand_MoveArbitraryNPC: ; ce6f (3:4e6f) ld a, [wLoadedNPCTempIndex] push af ld a, [wTempNPC] push af ld a, c push af - call GetOWSArgs2AfterPointer + call GetScriptArgs2AfterPointer push bc - call IncreaseOWScriptPointerBy1 + call IncreaseScriptPointerBy1 pop bc pop af jr ExecuteArbitraryNPCMovementFromStack -OWScript_CloseTextBox: ; ce84 (3:4e84) +ScriptCommand_CloseTextBox: ; ce84 (3:4e84) call CloseTextBox - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; args: booster pack index, booster pack index, booster pack index -OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) +ScriptCommand_GiveBoosterPacks: ; ce8a (3:4e8a) xor a ld [wd117], a push bc @@ -2148,16 +2148,16 @@ OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer ld a, c cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b .asm_ceb4 call Func_c2d4 - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 -OWScript_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) +ScriptCommand_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) xor a ld [wd117], a call Func_c2a3 @@ -2175,7 +2175,7 @@ OWScript_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) jr .giveBoosterLoop .done call Func_c2d4 - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 .booster_type_table db BOOSTER_COLOSSEUM_TRAINER @@ -2186,7 +2186,7 @@ OWScript_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) ; Shows the card received screen for a given promotional card ; arg can either be the card, $00 for a wram card, or $ff for the 4 legends -OWScript_ShowCardReceivedScreen: ; cee2 (3:4ee2) +ScriptCommand_ShowCardReceivedScreen: ; cee2 (3:4ee2) call Func_c2a3 ld a, c cp $ff @@ -2204,7 +2204,7 @@ OWScript_ShowCardReceivedScreen: ; cee2 (3:4ee2) call WhiteOutDMGPals call DoFrameIfLCDEnabled call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 .asm_cf09 xor a @@ -2225,20 +2225,20 @@ asm_cf16 asm_cf19 call SetScriptControlByteFail - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 asm_cf1f call SetScriptControlBytePass - call GetOWSArgs2AfterPointer + call GetScriptArgs2AfterPointer jr z, asm_cf2a - jp SetOWScriptPointer + jp SetScriptPointer asm_cf2a - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_cf2d: ; cf2d (3:4f2d) push bc - call IncreaseOWScriptPointerBy1 + call IncreaseScriptPointerBy1 pop bc call GetRawAmountOfCardsOwned ld a, h @@ -2252,7 +2252,7 @@ Func_cf2d: ; cf2d (3:4f2d) jr asm_cf19 ; Gives the first arg as a card. If that's 0 pulls from wd697 -OWScript_GiveCard: ; cf3f (3:4f3f) +ScriptCommand_GiveCard: ; cf3f (3:4f3f) ld a, c or a jr nz, .giveCard @@ -2260,12 +2260,12 @@ OWScript_GiveCard: ; cf3f (3:4f3f) .giveCard call AddCardToCollection - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_TakeCard: ; cf4c (3:4f4c) +ScriptCommand_TakeCard: ; cf4c (3:4f4c) ld a, c call RemoveCardFromCollection - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_cf53: ; cf53 (3:4f53) ld c, $1 @@ -2284,16 +2284,16 @@ Func_cf53: ; cf53 (3:4f53) jr nz, Func_cf6d Func_cf67: ; cf67 (3:4f67) call SetScriptControlByteFail - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 Func_cf6d: ; cf6d (3:4f6d) call SetScriptControlBytePass - call GetOWSArgs1AfterPointer + call GetScriptArgs1AfterPointer jr z, .asm_cf78 - jp SetOWScriptPointer + jp SetScriptPointer .asm_cf78 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 Func_cf7b: ; cf7b (3:4f7b) ld c, $1 @@ -2315,7 +2315,7 @@ Func_cf7b: ; cf7b (3:4f7b) ld a, c cp $8 jr c, .asm_cf7d - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_cf96: ; cf96 (3:4f96) ld c, $0 @@ -2341,19 +2341,19 @@ Func_cf96: ; cf96 (3:4f96) ld a, c rlca add $3 - call GetOWSArgsAfterPointer - jp SetOWScriptPointer + call GetScriptArgsAfterPointer + jp SetScriptPointer Func_cfc0: ; cfc0 (3:4fc0) - call GetOWSArgs1AfterPointer - jp SetOWScriptPointer + call GetScriptArgs1AfterPointer + jp SetScriptPointer Func_cfc6: ; cfc6 (3:4fc6) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a ld a, c farcall Func_1c52e - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_cfd4: ; cfd4 (3:4fd4) get_flag_value EVENT_FLAG_2D @@ -2387,7 +2387,7 @@ Func_cfd4: ; cfd4 (3:4fd4) add hl, bc ld c, [hl] set_flag_value EVENT_FLAG_2B - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Data_d006: ; d006 (3:5006) INCROM $d006, $d00b @@ -2406,7 +2406,7 @@ Func_d00b: ; d00b (3:500b) ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d025: ; d025 (3:5025) get_flag_value EVENT_FLAG_2B @@ -2423,29 +2423,29 @@ Func_d032: ; d032 (3:5032) Func_d03f: ; d03f (3:503f) get_flag_value EVENT_FLAG_2B call RemoveCardFromCollection - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_Jump: ; d049 (3:5049) - call GetOWSArgs1AfterPointer - jp SetOWScriptPointer +ScriptCommand_Jump: ; d049 (3:5049) + call GetScriptArgs1AfterPointer + jp SetScriptPointer -OWScript_TryGiveMedalPCPacks: ; d04f (3:504f) +ScriptCommand_TryGiveMedalPCPacks: ; d04f (3:504f) call TryGiveMedalPCPacks - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_SetPlayerDirection: ; d055 (3:5055) +ScriptCommand_SetPlayerDirection: ; d055 (3:5055) ld a, c call UpdatePlayerDirection - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 ; arg1 - Direction (index in PlayerMovementOffsetTable) ; arg2 - Tiles Moves (Speed) -OWScript_MovePlayer: ; 505c (3:505c) +ScriptCommand_MovePlayer: ; 505c (3:505c) ld a, c ld [wd339], a ld a, b ld [wd33a], a - call StartScriptedMovement + call StartScript_dMovement .asm_d067 call DoFrameIfLCDEnabled call SetScreenScroll @@ -2455,25 +2455,25 @@ OWScript_MovePlayer: ; 505c (3:505c) jr nz, .asm_d067 call DoFrameIfLCDEnabled call SetScreenScroll - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -OWScript_SetDialogName: ; d080 (3:5080) +ScriptCommand_SetDialogName: ; d080 (3:5080) ld a, c farcall SetNPCDialogName - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_SetNextNPCandOWSequence: ; d088 (3:5088) +ScriptCommand_SetNextNPCandScript: ; d088 (3:5088) ld a, c ld [wTempNPC], a - call GetOWSArgs2AfterPointer - call SetNextNPCAndOWSequence - jp IncreaseOWScriptPointerBy4 + call GetScriptArgs2AfterPointer + call SetNextNPCAndScript + jp IncreaseScriptPointerBy4 Func_d095: ; d095 (3:5095) ld a, [wScriptNPC] ld [wLoadedNPCTempIndex], a push bc - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer ld a, [wScriptNPC] ld l, LOADED_NPC_FIELD_05 call GetItemInLoadedNPCIndex @@ -2491,7 +2491,7 @@ Func_d095: ; d095 (3:5095) .asm_d0b6 ld a, e farcall Func_1c57b - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_d0be: ; d0be (3:50be) ld a, [wScriptNPC] @@ -2500,15 +2500,15 @@ Func_d0be: ; d0be (3:50be) ld c, b ld b, a farcall Func_1c461 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -OWScript_DoFrames: ; d0ce (3:50ce) +ScriptCommand_DoFrames: ; d0ce (3:50ce) push bc call DoFrameIfLCDEnabled pop bc dec c - jr nz, OWScript_DoFrames - jp IncreaseOWScriptPointerBy2 + jr nz, ScriptCommand_DoFrames + jp IncreaseScriptPointerBy2 Func_d0d9: ; d0d9 (3:50d9) ld a, [wScriptNPC] @@ -2524,7 +2524,7 @@ Func_d0d9: ; d0d9 (3:50d9) jp nz, ScriptEventFailedNoJump jp ScriptEventPassedTryJump -OWScript_JumpIfPlayerCoordMatches: ; d0f2 (3:50f2) +ScriptCommand_JumpIfPlayerCoordMatches: ; d0f2 (3:50f2) ld a, [wPlayerXCoord] cp c jp nz, ScriptEventFailedNoJump @@ -2562,7 +2562,7 @@ Func_d125: ; d125 (3:5125) pop af farcall Medal_1029e call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d135: ; d135 (3:5135) sla c @@ -2583,7 +2583,7 @@ Func_d135: ; d135 (3:5135) ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 INCROM $d153, $d16b @@ -2610,7 +2610,7 @@ Func_d16b: ; d16b (3:516b) ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d195: ; d195 (3:5195) ld a, [wTempNPC] @@ -2622,11 +2622,11 @@ Func_d195: ; d195 (3:5195) call Func_f580 pop af ld [wTempNPC], a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d1ad: ; d1ad (3:51ad) call MainMenu_c75a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d1b3: ; d1b3 (3:51b3) get_flag_value EVENT_FLAG_44 @@ -2653,7 +2653,7 @@ asm_d1c6 ld [wTxRam2], a ld a, [hl] ld [wTxRam2 + 1], a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 INCROM $d1dc, $d209 @@ -2706,7 +2706,7 @@ Flags_d240: ; d240 (3:5240) Func_d244: ; d244 (3:5244) ld a, c farcall Func_80ba4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d24c: ; d24c (3:524c) ld hl, $525e @@ -2715,7 +2715,7 @@ Func_d24c: ; d24c (3:524c) ld a, [wd695] ld c, a set_flag_value EVENT_FLAG_76 - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 INCROM $d25e, $d271 @@ -2723,7 +2723,7 @@ Func_d271: ; d271 (3:5271) ld hl, $527b xor a call Func_d28c - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; 0xd27b INCROM $d27b, $d28c @@ -2813,7 +2813,7 @@ Func_d2f6: ; d2f6 (3:52f6) set_flag_value EVENT_FLAG_75 xor a ld [wd694], a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; 0xd30c INCROM $d30c, $d317 @@ -2825,12 +2825,12 @@ Func_d317: ; d317 (3:5317) ld a, [wd694] ld c, a set_flag_value EVENT_FLAG_75 - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Unknown_d32b: ; d32b (3:532b) INCROM $d32b, $d336 -OWScript_OpenDeckMachine: ; d336 (3:5336) +ScriptCommand_OpenDeckMachine: ; d336 (3:5336) push bc call Func_c2a3 call PauseSong @@ -2855,13 +2855,13 @@ OWScript_OpenDeckMachine: ; d336 (3:5336) .asm_d364 call ResumeSong call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 ; args: unused, room, new player x, new player y, new player direction -OWScript_EnterMap: ; d36d (3:536d) - ld a, [wOWScriptPointer] +ScriptCommand_EnterMap: ; d36d (3:536d) + ld a, [wScriptPointer] ld l, a - ld a, [wOWScriptPointer+1] + ld a, [wScriptPointer+1] ld h, a inc hl ld a, [hli] @@ -2875,15 +2875,15 @@ OWScript_EnterMap: ; d36d (3:536d) ld [wTempPlayerDirection], a ld hl, wd0b4 set 4, [hl] - jp IncreaseOWScriptPointerBy6 + jp IncreaseScriptPointerBy6 Func_d38f: ; d38f (3:538f) farcall Func_10c96 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d396: ; d396 (3:5396) farcall Func_1157c - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d39d: ; d39d (3:539d) ld a, c @@ -2901,7 +2901,7 @@ Func_d39d: ; d39d (3:539d) set 6, [hl] .asm_d3b6 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d3b9: ; d3b9 (3:53b9) call Func_3917 @@ -2909,20 +2909,20 @@ Func_d3b9: ; d3b9 (3:53b9) ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_TryGivePCPack: ; d3c9 (3:53c9) +ScriptCommand_TryGivePCPack: ; d3c9 (3:53c9) ld a, c farcall TryGivePCPack - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_nop: ; d3d1 (3:53d1) - jp IncreaseOWScriptPointerBy1 +ScriptCommand_nop: ; d3d1 (3:53d1) + jp IncreaseScriptPointerBy1 Func_d3d4: ; d3d4 (3:53d4) ld a, [wd693] bank1call Func_7576 - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 INCROM $d3dd, $d3e0 @@ -2937,65 +2937,65 @@ Func_d3e0: ; d3e0 (3:53e0) cp $2 jr nz, .asm_d3e9 farcall Func_10f2e - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d3fe: ; d3fe (3:53fe) ld a, c ld [wd112], a call PlaySong - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d408: ; d408 (3:5408) ld a, c ld [wd111], a - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d40f: ; d40f (3:540f) ld a, c call CallPlaySong - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_PlaySFX: ; d416 (3:5416) +ScriptCommand_PlaySFX: ; d416 (3:5416) ld a, c call PlaySFX - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d41d: ; d41d (3:541d) call Func_39fc - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_PauseSong: ; d423 (3:5423) +ScriptCommand_PauseSong: ; d423 (3:5423) call PauseSong - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_ResumeSong: ; d429 (3:5429) +ScriptCommand_ResumeSong: ; d429 (3:5429) call ResumeSong - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_WaitForSongToFinish: ; d42f (3:542f) +ScriptCommand_WaitForSongToFinish: ; d42f (3:542f) call WaitForSongToFinish - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d435: ; d435 (3:5435) ld a, c farcall Func_1c83d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d43d: ; d43d (3:543d) ld a, GAME_EVENT_CHALLENGE_MACHINE ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; sets the event flag in arg 1 to the value in arg 2 -OWScript_SetFlagValue: ; d44a (3:544a) +ScriptCommand_SetFlagValue: ; d44a (3:544a) ld a, c ld c, b call SetEventFlagValue - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -OWScript_IncrementFlagValue: ; d452 (3:5452) +ScriptCommand_IncrementFlagValue: ; d452 (3:5452) ld a, c push af call GetEventFlagValue @@ -3003,72 +3003,72 @@ OWScript_IncrementFlagValue: ; d452 (3:5452) ld c, a pop af call SetEventFlagValue - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_JumpIfFlagZero1: ; d460 (3:5460) +ScriptCommand_JumpIfFlagZero1: ; d460 (3:5460) ld a, c call GetEventFlagValue or a - jr z, OWScript_JumpIfFlagZero1.passTryJump + jr z, ScriptCommand_JumpIfFlagZero1.passTryJump .fail call SetScriptControlByteFail - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 .passTryJump call SetScriptControlBytePass - call GetOWSArgs2AfterPointer + call GetScriptArgs2AfterPointer jr z, .noJumpTarget - jp SetOWScriptPointer + jp SetScriptPointer .noJumpTarget - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 -OWScript_JumpIfFlagNonzero1: ; d47b (3:547b) +ScriptCommand_JumpIfFlagNonzero1: ; d47b (3:547b) ld a, c call GetEventFlagValue or a - jr nz, OWScript_JumpIfFlagZero1.passTryJump - jr OWScript_JumpIfFlagZero1.fail + jr nz, ScriptCommand_JumpIfFlagZero1.passTryJump + jr ScriptCommand_JumpIfFlagZero1.fail ; args - event flag, value, jump address -OWScript_JumpIfFlagEqual: ; d484 (3:5484) +ScriptCommand_JumpIfFlagEqual: ; d484 (3:5484) call GetEventFlagValueBC cp c jr z, ScriptEventPassedTryJump ScriptEventFailedNoJump ; d48a (3:548a) call SetScriptControlByteFail - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 ScriptEventPassedTryJump ; d490 (3:5490) call SetScriptControlBytePass - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer jr z, .noJumpAddress - jp SetOWScriptPointer + jp SetScriptPointer .noJumpAddress - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 -OWScript_JumpIfFlagNotEqual: ; d49e (3:549e) +ScriptCommand_JumpIfFlagNotEqual: ; d49e (3:549e) call GetEventFlagValueBC cp c jr nz, ScriptEventPassedTryJump jr ScriptEventFailedNoJump -OWScript_JumpIfFlagNotLessThan: ; d4a6 (3:54a6) +ScriptCommand_JumpIfFlagNotLessThan: ; d4a6 (3:54a6) call GetEventFlagValueBC cp c jr nc, ScriptEventPassedTryJump jr ScriptEventFailedNoJump -OWScript_JumpIfFlagLessThan: ; d4ae (3:54ae) +ScriptCommand_JumpIfFlagLessThan: ; d4ae (3:54ae) call GetEventFlagValueBC cp c jr c, ScriptEventPassedTryJump jr ScriptEventFailedNoJump -; Gets event flag at c (OWScript defaults) +; Gets event flag at c (Script defaults) ; c takes on the value of b as a side effect GetEventFlagValueBC: ; d4b6 (3:54b6) ld a, c @@ -3076,39 +3076,39 @@ GetEventFlagValueBC: ; d4b6 (3:54b6) call GetEventFlagValue ret -OWScript_MaxOutFlagValue: ; d4bc (3:54bc) +ScriptCommand_MaxOutFlagValue: ; d4bc (3:54bc) ld a, c call MaxOutEventFlag - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_ZeroOutFlagValue: ; d4c3 (3:54c3) +ScriptCommand_ZeroOutFlagValue: ; d4c3 (3:54c3) ld a, c call ZeroOutEventFlag - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -OWScript_JumpIfFlagNonzero2: ; d4ca (3:54ca) +ScriptCommand_JumpIfFlagNonzero2: ; d4ca (3:54ca) ld a, c call GetEventFlagValue or a - jr z, OWScript_JumpIfFlagZero2.fail + jr z, ScriptCommand_JumpIfFlagZero2.fail .passTryJump: call SetScriptControlBytePass - call GetOWSArgs2AfterPointer + call GetScriptArgs2AfterPointer jr z, .noJumpArgs - jp SetOWScriptPointer + jp SetScriptPointer .noJumpArgs - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 -OWScript_JumpIfFlagZero2: +ScriptCommand_JumpIfFlagZero2: ld a, c call GetEventFlagValue or a - jr z, OWScript_JumpIfFlagNonzero2.passTryJump + jr z, ScriptCommand_JumpIfFlagNonzero2.passTryJump .fail call SetScriptControlByteFail - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 ; 0xd4ec LoadOverworld: ; d4ec (3:54ec) @@ -3116,8 +3116,8 @@ LoadOverworld: ; d4ec (3:54ec) get_flag_value EVENT_FLAG_3E or a ret nz - ld bc, OWSequence_BeginGame - jp SetNextOWSequence + ld bc, Script_BeginGame + jp SetNextScript Func_d4fb: ; d4fb (3:54fb) zero_flag_value EVENT_FLAG_59 @@ -3143,20 +3143,20 @@ Func_d4fb: ; d4fb (3:54fb) set_flag_value EVENT_FLAG_3F ret -OWSequence_BeginGame: ; d52e (3:552e) +Script_BeginGame: ; d52e (3:552e) start_script - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db $3c run_script Func_d3e0 - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db $78 - run_script OWScript_EnterMap + run_script ScriptCommand_EnterMap db $02 db MASON_LABORATORY db 14 db 26 db NORTH - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully MasonLaboratoryAfterDuel: ; d53b (3:553b) ld hl, .after_duel_table @@ -3177,8 +3177,8 @@ MasonLabLoadMap: ; d549 (3:5549) ld a, NPC_DRMASON ld [wTempNPC], a call FindLoadedNPC - ld bc, OWSequence_EnterLabFirstTime - jp SetNextNPCAndOWSequence + ld bc, Script_EnterLabFirstTime + jp SetNextNPCAndScript MasonLabCloseTextBox: ; d55e (3:555e) ld a, $0a @@ -3196,224 +3196,224 @@ MasonLabPressedA: ; d565 (3:5565) ChallengeMachineObjectTable: ; d572 (3:5572) db 10, 4, NORTH - dw OWSequence_ChallengeMachine + dw Script_ChallengeMachine db 12, 4, NORTH - dw OWSequence_ChallengeMachine + dw Script_ChallengeMachine db $00 -OWSequence_ChallengeMachine: ; d57d (3:557d) +Script_ChallengeMachine: ; d57d (3:557d) start_script run_script Func_ccdc tx Text05bd run_script Func_d43d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully INCROM $d583, $d753 -OWSequence_EnterLabFirstTime: ; d753 (3:5753) +Script_EnterLabFirstTime: ; d753 (3:5753) start_script - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e3 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_SAM - dw OWSequence_d779 - run_script OWScript_EndScriptLoop1 + dw Script_d779 + run_script ScriptCommand_EndScriptLoop1 ret -OWSequence_d779: ; d779 (03:5779) +Script_d779: ; d779 (03:5779) start_script - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_d880 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e4 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_DRMASON - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e5 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_d882 run_script Func_cfc6 db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db $03 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_DRMASON - dw OWSequence_d794 - run_script OWScript_EndScriptLoop1 + dw Script_d794 + run_script ScriptCommand_EndScriptLoop1 ret -OWSequence_d794: ; d794 (3:5794) +Script_d794: ; d794 (3:5794) start_script - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_d88b - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 40 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e6 - run_script OWScript_CloseTextBox - run_script OWScript_MovePlayer + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MovePlayer db WEST db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db WEST - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_d894 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e7 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db $07 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e8 .ows_d7bc - run_script OWScript_CloseTextBox + run_script ScriptCommand_CloseTextBox run_script Func_d317 - run_script OWScript_CloseTextBox - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $07 dw .ows_d80c - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $01 dw .ows_d7e8 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $02 dw .ows_d7ee - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $03 dw .ows_d7f4 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $04 dw .ows_d7fa - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $05 dw .ows_d800 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $06 dw .ows_d806 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05d6 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d7e8 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05d7 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d7ee - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05d8 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d7f4 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05d9 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d7fa - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05da - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d800 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05db - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d806 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05dc - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d80c - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05e9 - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes dw 0000 dw .ows_d817 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_d7bc .ows_d817 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text05ea - run_script OWScript_nop - run_script OWScript_SetFlagValue + run_script ScriptCommand_nop + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_3E db $01 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_SAM - dw OWSequence_d827 - run_script OWScript_EndScriptLoop1 + dw Script_d827 + run_script ScriptCommand_EndScriptLoop1 ret -OWSequence_d827: ; d827 (3:5827) +Script_d827: ; d827 (3:5827) start_script - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_2 db SAMS_PRACTICE_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xd82d INCROM $d82d, $d880 @@ -3450,19 +3450,19 @@ NPCMovement_d894: ; d894 (4:5894) INCROM $d896, $d932 -OWSequence_d932: ; d932 (3:5932) +Script_d932: ; d932 (3:5932) start_script run_script Func_ccdc tx Text0605 - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes tx Text0606 dw .ows_d93c - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_d93c - run_script OWScript_OpenDeckMachine + run_script ScriptCommand_OpenDeckMachine db $09 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xd93f INCROM $d93f, $dadd @@ -3488,232 +3488,232 @@ Preload_IshiharaInIshiharasHouse: ; db3d (3:5b3d) cp $08 ret -OWSequence_Ishihara: ; db4a (3:5b4a) +Script_Ishihara: ; db4a (3:5b4a) start_script - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_1D - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $00 dw .ows_db80 - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_39 dw .ows_db5a - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_dc3e .ows_db5a - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_00 dw .ows_db90 - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_38 dw .ows_db90 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $01 dw .ows_db93 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $02 dw .ows_db93 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $03 dw .ows_dbcc - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $04 dw .ows_dbcc - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $05 dw .ows_dc05 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $06 dw .ows_dc05 .ows_db80 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $01 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_db8d - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_39 .ows_db8d - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0727 .ows_db90 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0728 .ows_db93 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0729 tx Text072a - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $02 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text072b dw .ows_dba8 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text072c .ows_dba8 run_script Func_cf0c db $ac dw .ows_dbaf - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text072d .ows_dbaf run_script Func_cf12 db $ac dw .ows_dbb6 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text072e .ows_dbb6 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $03 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text072f run_script Func_ccdc tx Text0730 - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db CLEFABLE - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db SURFING_PIKACHU1 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db SURFING_PIKACHU1 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0731 .ows_dbcc - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $03 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0732 tx Text0733 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $04 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text072b dw .ows_dbe1 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text072c .ows_dbe1 run_script Func_cf0c db $bb dw .ows_dbe8 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0734 .ows_dbe8 run_script Func_cf12 db $bb dw .ows_dbef - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0735 .ows_dbef - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $05 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text072f run_script Func_ccdc tx Text0736 - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db DITTO - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db FLYING_PIKACHU - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db FLYING_PIKACHU - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0737 .ows_dc05 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $05 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0738 tx Text0739 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $06 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text072b dw .ows_dc1a - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text072c .ows_dc1a run_script Func_cf0c db $b8 dw .ows_dc21 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text073a .ows_dc21 run_script Func_cf12 db $b8 dw .ows_dc28 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text073b .ows_dc28 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $07 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text072f run_script Func_ccdc tx Text073c - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db CHANSEY - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db SURFING_PIKACHU2 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db SURFING_PIKACHU2 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text073d .ows_dc3e - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_39 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text073e Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) @@ -3722,27 +3722,27 @@ Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) ccf ret -OWSequence_Ronald: ; dc4b (3:5c4b) +Script_Ronald: ; dc4b (3:5c4b) start_script - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_4E dw .ows_dc55 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_4E - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text073f .ows_dc55 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0740 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text0741 dw .ows_dc60 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0742 .ows_dc60 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0743 ; 0xdc63 @@ -3750,9 +3750,9 @@ OWSequence_Ronald: ; dc4b (3:5c4b) ; someone thinking that the Ronald script ended with more code execution ret -OWSequence_Clerk1: ; dc64 (3:5c64) +Script_Clerk1: ; dc64 (3:5c64) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text045a FightingClubLobbyAfterDuel: ; dc68 (3:5c68) @@ -3762,118 +3762,118 @@ FightingClubLobbyAfterDuel: ; dc68 (3:5c68) .after_duel_table db NPC_IMAKUNI db NPC_IMAKUNI - dw OWSequence_BeatImakuni - dw OWSequence_LostToImakuni + dw Script_BeatImakuni + dw Script_LostToImakuni db $00 INCROM $dc76, $dd0d -OWSequence_Imakuni: ; dd0d (3:5d0d) +Script_Imakuni: ; dd0d (3:5d0d) start_script - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_IMAKUNI_STATE db IMAKUNI_TALKED - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_TEMP_TALKED_TO_IMAKUNI dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0467 tx Text0468 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_TEMP_TALKED_TO_IMAKUNI - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text0469 dw .declineDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046a - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .declineDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046b - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_6 db IMAKUNI_DECK_ID db MUSIC_IMAKUNI - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xdd2d -OWSequence_BeatImakuni: ; dd2d (3:5d2d) +Script_BeatImakuni: ; dd2d (3:5d2d) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $07 dw .giveBoosters - run_script OWScript_IncrementFlagValue + run_script ScriptCommand_IncrementFlagValue db EVENT_IMAKUNI_WIN_COUNT - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $03 dw .threeWins - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $06 dw .sixWins .giveBoosters - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046c - run_script OWScript_GiveOneOfEachTrainerBooster - run_script OWScript_Jump + run_script ScriptCommand_GiveOneOfEachTrainerBooster + run_script ScriptCommand_Jump dw .done .threeWins - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046d - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .giveImakuniCard .sixWins - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046e .giveImakuniCard - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text046f - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db IMAKUNI_CARD - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db IMAKUNI_CARD .done - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0470 - run_script OWScript_Jump - dw OWJump_ImakuniCommon + run_script ScriptCommand_Jump + dw ScriptJump_ImakuniCommon -OWSequence_LostToImakuni: ; dd5c (3:5d5c) +Script_LostToImakuni: ; dd5c (3:5d5c) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0471 -OWJump_ImakuniCommon: ; dd60 (3:5d60) - run_script OWScript_CloseTextBox - run_script OWScript_JumpIfPlayerCoordMatches +ScriptJump_ImakuniCommon: ; dd60 (3:5d60) + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_JumpIfPlayerCoordMatches db 18 db 4 dw .ows_dd69 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_dd6e .ows_dd69 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db EAST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 .ows_dd6e - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_dd78 run_script Func_cdcb - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_TEMP_BATTLED_IMAKUNI run_script Func_d408 db $09 run_script Func_d41d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xdd78 NPCMovement_dd78 ; dd78 (3:5d78) @@ -3909,96 +3909,96 @@ Preload_ImakuniInWaterClubLobby: ; e0b0 (3:60b0) ret ; 0xe0cf -OWSequence_Gal1: ; e0cf (3:60cf) +Script_Gal1: ; e0cf (3:60cf) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_12 db $02 dw .ows_e10e - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_12 db $00 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text041d tx Text041e - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_12 db $01 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text041f dw .ows_e0eb - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0420 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e0eb run_script Func_cf0c db $59 dw .ows_e0f3 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0421 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e0f3 run_script Func_cf12 db $59 dw .ows_e0fb - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0422 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e0fb - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_12 db $02 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0423 run_script Func_ccdc tx Text0424 - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db LAPRAS - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db ARCANINE1 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db ARCANINE1 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0425 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e10e - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0426 -OWSequence_Lass1: ; e111 (3:6111) +Script_Lass1: ; e111 (3:6111) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_14 db $01 dw .ows_e121 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0427 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_14 db $01 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_IMAKUNI_STATE db IMAKUNI_MENTIONED - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e121 - run_script OWScript_JumpIfFlagNotEqual + run_script ScriptCommand_JumpIfFlagNotEqual db EVENT_IMAKUNI_ROOM db IMAKUNI_WATER_CLUB dw .ows_e12d - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_TEMP_BATTLED_IMAKUNI dw .ows_e12d - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0428 .ows_e12d - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0429 Preload_Man2InWaterClubLobby: ; e130 (3:6130) @@ -4006,14 +4006,14 @@ Preload_Man2InWaterClubLobby: ; e130 (3:6130) cp JOSHUA_BEATEN ret -OWSequence_Man2: ; e137 (3:6137) +Script_Man2: ; e137 (3:6137) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text042a -OWSequence_Pappy2: ; e13b (3:613b) +Script_Pappy2: ; e13b (3:613b) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text042b WaterClubMovePlayer: ; e13f (3:613f) @@ -4025,8 +4025,8 @@ WaterClubMovePlayer: ; e13f (3:613f) ret nc ld a, NPC_JOSHUA ld [wTempNPC], a - ld bc, OWSequence_NotReadyToSeeAmy - jp SetNextNPCAndOWSequence + ld bc, Script_NotReadyToSeeAmy + jp SetNextNPCAndScript WaterClubAfterDuel: ;e157 (3:6157) ld hl, .after_duel_table @@ -4036,159 +4036,159 @@ WaterClubAfterDuel: ;e157 (3:6157) .after_duel_table db NPC_SARA db NPC_SARA - dw OWSequence_BeatSara - dw OWSequence_LostToSara + dw Script_BeatSara + dw Script_LostToSara db NPC_AMANDA db NPC_AMANDA - dw OWSequence_BeatAmanda - dw OWSequence_LostToAmanda + dw Script_BeatAmanda + dw Script_LostToAmanda db NPC_JOSHUA db NPC_JOSHUA - dw OWSequence_BeatJoshua - dw OWSequence_LostToJoshua + dw Script_BeatJoshua + dw Script_LostToJoshua db NPC_AMY db NPC_AMY - dw OWSequence_BeatAmy - dw OWSequence_LostToAmy + dw Script_BeatAmy + dw Script_LostToAmy db $00 -OWSequence_Sara: ; e177 (3:6177) +Script_Sara: ; e177 (3:6177) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text042c - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text042d dw .yes_duel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text042e - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .yes_duel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text042f - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_2 db WATERFRONT_POKEMON_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatSara: ; e18c (3:618c) +Script_BeatSara: ; e18c (3:618c) start_script - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_BEAT_SARA - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0430 - run_script OWScript_GiveBoosterPacks + run_script ScriptCommand_GiveBoosterPacks db BOOSTER_COLOSSEUM_WATER db BOOSTER_COLOSSEUM_WATER db NO_BOOSTER - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0431 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_LostToSara: ; e19a (03:619a) +Script_LostToSara: ; e19a (03:619a) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0432 -OWSequence_Amanda: ; e19e (03:619e) +Script_Amanda: ; e19e (03:619e) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0433 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text0434 dw .yes_duel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0435 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .yes_duel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0436 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_3 db LONELY_FRIENDS_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatAmanda: ; e1b3 (03:61b3) +Script_BeatAmanda: ; e1b3 (03:61b3) start_script - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_BEAT_AMANDA - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0437 - run_script OWScript_GiveBoosterPacks + run_script ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db NO_BOOSTER - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0438 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_LostToAmanda: ; e1c1 (03:61c1) +Script_LostToAmanda: ; e1c1 (03:61c1) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0439 -OWSequence_NotReadyToSeeAmy: ; e1c5 (03:61c5) +Script_NotReadyToSeeAmy: ; e1c5 (03:61c5) start_script - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $12 db $08 dw .ows_e1ec - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $14 db $08 dw .ows_e1f2 - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $18 db $08 dw .ows_e1f8 .ows_e1d5 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $04 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e213 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text043a - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $12 db $0a dw .ows_e1fe - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $14 db $0a dw .ows_e202 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e215 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e1ec - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e206 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_e1d5 .ows_e1f2 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e20b - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_e1d5 .ows_e1f8 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e20f - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_e1d5 .ows_e1fe - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e218 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e202 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e219 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_e206: ; e206 (3:6206) db NORTH @@ -4227,121 +4227,121 @@ NPCMovement_e219: ; e219 (3:6219) db SOUTH | NO_MOVE db $ff -OWSequence_Joshua: ; e21c (3:621c) +Script_Joshua: ; e21c (3:621c) start_script - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_AMANDA dw .sara_and_amanda_not_beaten - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_SARA dw .sara_and_amanda_not_beaten - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .beat_sara_and_amanda .sara_and_amanda_not_beaten - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_TALKED - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text043b - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .beat_sara_and_amanda - run_script OWScript_JumpIfFlagNonzero1 + run_script ScriptCommand_JumpIfFlagNonzero1 db EVENT_JOSHUA_STATE dw .already_talked - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_TALKED - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text043b - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text043c .already_talked - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text043d tx Text043e - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text043f dw .startDuel - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0440 tx Text0441 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .startDuel: - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0442 - run_script OWScript_TryGivePCPack + run_script ScriptCommand_TryGivePCPack db $04 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_4 db SOUND_OF_THE_WAVES_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_LostToJoshua: ; e260 (3:6260) +Script_LostToJoshua: ; e260 (3:6260) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0443 tx Text0444 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatJoshua: ; e26c (3:626c) +Script_BeatJoshua: ; e26c (3:626c) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0445 tx Text0446 - run_script OWScript_GiveBoosterPacks + run_script ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_WATER_COLORLESS db BOOSTER_MYSTERY_WATER_COLORLESS db NO_BOOSTER - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0447 tx Text0448 - run_script OWScript_JumpIfFlagNotEqual + run_script ScriptCommand_JumpIfFlagNotEqual db EVENT_JOSHUA_STATE db JOSHUA_BEATEN dw .firstJoshuaWin - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .firstJoshuaWin: - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_BEATEN - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0449 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPCByDirection + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPCByDirection dw NPCMovementTable_e2a1 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text044a run_script Func_cfc6 db $00 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_AMY - dw OWSequence_MeetAmy - run_script OWScript_EndScriptLoop1 + dw Script_MeetAmy + run_script ScriptCommand_EndScriptLoop1 ret NPCMovementTable_e2a1: ; e2a1 (3:62a1) @@ -4378,24 +4378,24 @@ Preload_Amy: ; e2ad (3:62ad) scf ret -OWSequence_MeetAmy: ; e2d1 (3:62d1) +Script_MeetAmy: ; e2d1 (3:62d1) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text044b - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_JOSHUA - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text044c - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_AMY - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text044d - run_script OWScript_CloseTextBox + run_script ScriptCommand_CloseTextBox run_script Func_d095 db $09 db $2f db $10 - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db $20 run_script Func_d095 db $04 @@ -4404,97 +4404,97 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1) run_script Func_d0be db $14 db $04 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db $03 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db $00 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MoveArbitraryNPC + run_script ScriptCommand_MoveArbitraryNPC db NPC_JOSHUA dw NPCMovement_e2ab - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text044e - run_script OWScript_Jump - dw OWSequence_Amy.askConfirmDuel + run_script ScriptCommand_Jump + dw Script_Amy.askConfirmDuel -OWSequence_Amy: ; e304 (3:6304) +Script_Amy: ; e304 (3:6304) start_script - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_BEAT_AMY - dw OWJump_TalkToAmyAgain - run_script OWScript_PrintTextString + dw ScriptJump_TalkToAmyAgain + run_script ScriptCommand_PrintTextString tx Text044f .askConfirmDuel - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text0450 dw .startDuel .denyDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0451 run_script Func_d0d9 db $14 db $04 - dw OWSequence_LostToAmy.ows_e34e - run_script OWScript_QuitScriptFully + dw Script_LostToAmy.ows_e34e + run_script ScriptCommand_QuitScriptFully .startDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0452 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatAmy: ; e322 (3:6322) +Script_BeatAmy: ; e322 (3:6322) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0453 - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_BEAT_AMY dw .beatAmyCommon - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0454 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_BEAT_AMY - run_script OWScript_TryGiveMedalPCPacks + run_script ScriptCommand_TryGiveMedalPCPacks run_script Func_d125 db EVENT_BEAT_AMY run_script Func_d435 db $03 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0455 .beatAmyCommon - run_script OWScript_GiveBoosterPacks + run_script ScriptCommand_GiveBoosterPacks db BOOSTER_LABORATORY_WATER db BOOSTER_LABORATORY_WATER db NO_BOOSTER - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0456 run_script Func_d0d9 db $14 db $04 - dw OWSequence_LostToAmy.ows_e34e - run_script OWScript_QuitScriptFully + dw Script_LostToAmy.ows_e34e + run_script ScriptCommand_QuitScriptFully -OWSequence_LostToAmy: ; e344 (3:6344) +Script_LostToAmy: ; e344 (3:6344) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0457 run_script Func_d0d9 db $14 db $04 dw .ows_e34e - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_e34e run_script Func_d095 @@ -4504,25 +4504,25 @@ OWSequence_LostToAmy: ; e344 (3:6344) run_script Func_d0be db $16 db $04 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWJump_TalkToAmyAgain: ; e356 (3:6356) - run_script OWScript_PrintTextString +ScriptJump_TalkToAmyAgain: ; e356 (3:6356) + run_script ScriptCommand_PrintTextString tx Text0458 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text0450 dw .startDuel - run_script OWScript_Jump - dw OWSequence_Amy.denyDuel + run_script ScriptCommand_Jump + dw Script_Amy.denyDuel .startDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0459 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xe369 INCROM $e369, $e525 @@ -4560,7 +4560,7 @@ FindEndOfBattleScript: ; e52c (3:652c) ld c, [hl] inc hl ld b, [hl] - jp SetNextNPCAndOWSequence + jp SetNextNPCAndScript ; 0xe553 GrassClubEntranceAfterDuelTable: ; e553 (3:6553) @@ -4571,13 +4571,13 @@ GrassClubEntranceAfterDuelTable: ; e553 (3:6553) db NPC_RONALD2 db NPC_RONALD2 - dw OWSequence_BeatFirstRonaldFight - dw OWSequence_LostToFirstRonaldFight + dw Script_BeatFirstRonaldFight + dw Script_LostToFirstRonaldFight db NPC_RONALD3 db NPC_RONALD3 - dw OWSequence_BeatSecondRonaldFight - dw OWSequence_LostToSecondRonaldFight + dw Script_BeatSecondRonaldFight + dw Script_LostToSecondRonaldFight db $00 INCROM $e566, $e5c4 @@ -4590,246 +4590,246 @@ GrassClubLobbyAfterDuel: ; e5c4 (3:65c4) .after_duel_table db NPC_BRITTANY db NPC_BRITTANY - dw OWSequence_BeatBrittany - dw OWSequence_LostToBrittany + dw Script_BeatBrittany + dw Script_LostToBrittany db $00 -OWSequence_Brittany: ; e5d2 (3:65d2) +Script_Brittany: ; e5d2 (3:65d2) start_script - run_script OWScript_JumpIfFlagLessThan + run_script ScriptCommand_JumpIfFlagLessThan db EVENT_FLAG_35 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text06e0 tx Text06e1 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text06e2 dw .wantToDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06e3 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .wantToDuel - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06e4 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_4 db ETCETERA_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatBrittany: ; e5ee (3:65ee) +Script_BeatBrittany: ; e5ee (3:65ee) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06e5 - run_script OWScript_GiveBoosterPacks + run_script ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_GRASS_COLORLESS db BOOSTER_MYSTERY_GRASS_COLORLESS db NO_BOOSTER - run_script OWScript_JumpIfFlagLessThan + run_script ScriptCommand_JumpIfFlagLessThan db EVENT_FLAG_35 db $02 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text06e6 tx Text06e7 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db FLAG_BEAT_BRITTANY - run_script OWScript_JumpIfFlagNotLessThan + run_script ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_35 db $02 dw .finishSequence - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_3A dw .finishSequence - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_3B dw .finishSequence - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_35 db $01 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_1E - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06e8 .finishSequence - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_LostToBrittany: ; e618 (3:6618) +Script_LostToBrittany: ; e618 (3:6618) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06e9 ; 0xe61c -OWSequence_e61c: ; e61c (3:661c) - run_script OWScript_PrintTextQuitFully +Script_e61c: ; e61c (3:661c) + run_script ScriptCommand_PrintTextQuitFully tx Text06ea -OWSequence_e61f: ; e61f (3:661f) +Script_e61f: ; e61f (3:661f) start_script - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_04 - dw OWSequence_e61c - run_script OWScript_JumpIfFlagNotLessThan + dw Script_e61c + run_script ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $06 - dw OWSequence_e61c - run_script OWScript_JumpIfFlagNotLessThan + dw Script_e61c + run_script ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $04 dw .ows_e6a1 - run_script OWScript_JumpIfFlagNotLessThan + run_script ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $02 dw .ows_e66a - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $00 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text06eb tx Text06ec - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $01 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e648 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06ee .ows_e648 run_script Func_cf0c db $1c dw .ows_e64f - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06ef .ows_e64f run_script Func_cf12 db $1c dw .ows_e656 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f0 .ows_e656 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $02 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06f1 run_script Func_ccdc tx Text06f2 - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db ODDISH - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db VILEPLUME - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db VILEPLUME - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f3 .ows_e66a - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $02 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text06f4 tx Text06f5 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $03 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e67f - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f6 .ows_e67f run_script Func_cf0c db $ab dw .ows_e686 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f7 .ows_e686 run_script Func_cf12 db $ab dw .ows_e68d - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f8 .ows_e68d - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $04 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06f9 run_script Func_ccdc tx Text06fa - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db CLEFAIRY - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db PIKACHU3 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db PIKACHU3 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f3 .ows_e6a1 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $04 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text06fb tx Text06fc - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $05 - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e6b6 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06fd .ows_e6b6 run_script Func_cf0c db $32 dw .ows_e6bd - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06fe .ows_e6bd run_script Func_cf12 db $32 dw .ows_e6c4 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06ff .ows_e6c4 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $06 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0700 run_script Func_ccdc tx Text0701 - run_script OWScript_TakeCard + run_script ScriptCommand_TakeCard db CHARIZARD - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db BLASTOISE - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db BLASTOISE - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06f3 ; 0xe6d8 @@ -4842,13 +4842,13 @@ ClubEntranceAfterDuel: ; e7f6 (3:67f6) .after_duel_table db NPC_RONALD2 db NPC_RONALD2 - dw OWSequence_BeatFirstRonaldFight - dw OWSequence_LostToFirstRonaldFight + dw Script_BeatFirstRonaldFight + dw Script_LostToFirstRonaldFight db NPC_RONALD3 db NPC_RONALD3 - dw OWSequence_BeatSecondRonaldFight - dw OWSequence_LostToSecondRonaldFight + dw Script_BeatSecondRonaldFight + dw Script_LostToSecondRonaldFight db $00 ; A Ronald is already loaded or not loaded depending on Pre-Load scripts @@ -4864,8 +4864,8 @@ TryFirstRonaldEncounter: ; e813 (3:6813) ld [wTempNPC], a call FindLoadedNPC ret c - ld bc, OWSequence_FirstRonaldEncounter - jp SetNextNPCAndOWSequence + ld bc, Script_FirstRonaldEncounter + jp SetNextNPCAndScript TryFirstRonaldFight: ; e822 (3:6822) ld a, NPC_RONALD2 @@ -4875,8 +4875,8 @@ TryFirstRonaldFight: ; e822 (3:6822) get_flag_value EVENT_FLAG_4C or a ret nz - ld bc, OWSequence_FirstRonaldFight - jp SetNextNPCAndOWSequence + ld bc, Script_FirstRonaldFight + jp SetNextNPCAndScript TrySecondRonaldFight: ; e837 (3:6837) ld a, NPC_RONALD3 @@ -4886,56 +4886,56 @@ TrySecondRonaldFight: ; e837 (3:6837) get_flag_value EVENT_FLAG_4D or a ret nz - ld bc, OWSequenceSecondRonaldFight - jp SetNextNPCAndOWSequence + ld bc, ScriptSecondRonaldFight + jp SetNextNPCAndScript ; 0xe84c INCROM $e84c, $e862 -OWSequence_FirstRonaldEncounter: ; e862 (3:6862) +Script_FirstRonaldEncounter: ; e862 (3:6862) start_script - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_4B - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e894 run_script Func_d135 db $00 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0645 - run_script OWScript_CloseTextBox - run_script OWScript_MovePlayer + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0646 - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes dw 0000 dw .ows_e882 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0647 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_e885 .ows_e882 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0648 .ows_e885 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0649 - run_script OWScript_CloseTextBox - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_SetPlayerDirection db $03 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db EAST db $04 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e894 run_script Func_cdcb run_script Func_d41d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_e894: ; e894 (3:6894) db SOUTH @@ -4948,72 +4948,72 @@ NPCMovement_e894: ; e894 (3:6894) INCROM $e89a, $e8c0 -OWSequence_FirstRonaldFight: ; e8c0 (3:68c0) +Script_FirstRonaldFight: ; e8c0 (3:68c0) start_script - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e905 - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db $3c - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e90d - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064a - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $08 db $02 dw $68d6 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db WEST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064b - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db $4c db $01 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_6 db IM_RONALD_DECK_ID db MUSIC_RONALD - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatFirstRonaldFight: ; e8e9 (3:68e9) +Script_BeatFirstRonaldFight: ; e8e9 (3:68e9) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064c - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db JIGGLYPUFF1 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db JIGGLYPUFF1 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064d - run_script OWScript_Jump - dw OWJump_FinishedFirstRonaldFight + run_script ScriptCommand_Jump + dw ScriptJump_FinishedFirstRonaldFight -OWSequence_LostToFirstRonaldFight: ; e8f7 (3:68f7) +Script_LostToFirstRonaldFight: ; e8f7 (3:68f7) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064e -OWJump_FinishedFirstRonaldFight - run_script OWScript_SetFlagValue +ScriptJump_FinishedFirstRonaldFight + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_4C db $02 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e90f run_script Func_cdcb run_script Func_d41d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_e905: ; e905 (3:6905) db EAST @@ -5040,73 +5040,73 @@ NPCMovement_e90f: ; e90f (3:690f) INCROM $e915, $e91e -OWSequenceSecondRonaldFight: ; e91e (3:691e) +ScriptSecondRonaldFight: ; e91e (3:691e) start_script - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e905 - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 60 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e90d - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text064f - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db $08 db $02 dw .ows_6934 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db WEST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 .ows_6934 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0650 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_4D db $01 - run_script OWScript_StartBattle + run_script ScriptCommand_StartBattle db PRIZES_6 db POWERFUL_RONALD_DECK_ID db MUSIC_RONALD - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully -OWSequence_BeatSecondRonaldFight: ; e947 (3:6947) +Script_BeatSecondRonaldFight: ; e947 (3:6947) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0651 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db SUPER_ENERGY_RETRIEVAL - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db SUPER_ENERGY_RETRIEVAL - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0652 - run_script OWScript_Jump - dw OWJump_FinishedSecondRonaldFight + run_script ScriptCommand_Jump + dw ScriptJump_FinishedSecondRonaldFight -OWSequence_LostToSecondRonaldFight: ; e955 (3:6955) +Script_LostToSecondRonaldFight: ; e955 (3:6955) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0653 -OWJump_FinishedSecondRonaldFight ; e959 (3:6959) - run_script OWScript_SetFlagValue +ScriptJump_FinishedSecondRonaldFight ; e959 (3:6959) + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_4D db $02 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_e90f run_script Func_cdcb run_script Func_d41d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xe963 INCROM $e963, $ed57 @@ -5118,12 +5118,12 @@ FireClubPressedA: ; ed57 (3:6d57) SlowpokePaintingObjectTable: ; ed5e (3:6d5e) db 16, 2, NORTH - dw OWSequence_ee76 + dw Script_ee76 db $00 ; Given a table with data of the form: -; X, Y, Dir, OWSequence -; Searches to try to find a match, and starts an OWSequence if possible +; X, Y, Dir, Script +; Searches to try to find a match, and starts a Script if possible FindExtraInteractableObjects: ; ed64 (3:6d64) ld de, $5 .findObjectMatchLoop @@ -5152,32 +5152,32 @@ FindExtraInteractableObjects: ; ed64 (3:6d64) inc hl ld b, [hl] pop hl - call SetNextOWSequence + call SetNextScript scf ret ; 0xed8d INCROM $ed8d, $ee76 -OWSequence_ee76: ; ee76 (3:6e76) +Script_ee76: ; ee76 (3:6e76) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_21 db $01 dw .ows_ee7d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_ee7d - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_21 db $02 run_script Func_ccdc tx Text06a2 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db SLOWPOKE1 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db SLOWPOKE1 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully ; 0xee88 INCROM $ee88, $ef96 @@ -5259,77 +5259,77 @@ Preload_Clerk9: ; ef96 (3:6f96) scf ret -OWSequence_Clerk9: ; f025 (3:7025) +Script_Clerk9: ; f025 (3:7025) start_script - run_script OWScript_JumpIfFlagZero1 + run_script ScriptCommand_JumpIfFlagZero1 db EVENT_FLAG_3F dw .ows_f066 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $07 dw .ows_f069 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $03 dw .ows_f06f - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $02 dw .ows_f072 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $01 dw .ows_f06c - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $07 dw .ows_f069 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $03 dw .ows_f06f - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $02 dw .ows_f072 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $01 dw .ows_f06c - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $07 dw .ows_f069 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $03 dw .ows_f06f - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $02 dw .ows_f072 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $01 dw .ows_f06c .ows_f066 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050a .ows_f069 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050b .ows_f06c - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050c .ows_f06f - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050d .ows_f072 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050e Preload_ChallengeHallNPCs2: ; f075 (3:7075) @@ -5355,36 +5355,36 @@ ChallengeHallLobbyLoadMap: ; f088 (3:7088) ld [wTempNPC], a call FindLoadedNPC ld bc, $7166 - jp SetNextNPCAndOWSequence + jp SetNextNPCAndScript -OWSequence_Pappy3: ; f09c (3:709c) +Script_Pappy3: ; f09c (3:709c) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text050f -OWSequence_Gal4: ; f0a0 (3:70a0) +Script_Gal4: ; f0a0 (3:70a0) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0510 -OWSequence_Champ: ; f0a4 (3:70a4) +Script_Champ: ; f0a4 (3:70a4) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0511 -OWSequence_Hood2: ; f0a8 (3:70a8) +Script_Hood2: ; f0a8 (3:70a8) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0512 -OWSequence_Lass5: ; f0ac (3:70ac) +Script_Lass5: ; f0ac (3:70ac) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0513 -OWSequence_Chap5: ; f0b0 (3:70b0) +Script_Chap5: ; f0b0 (3:70b0) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0514 Preload_ChallengeHallLobbyRonald1: ; f0b4 (3:70b4) @@ -5486,7 +5486,7 @@ ChallengeHallAfterDuel: ; f239 (3:7239) ld b, [hl] ld a, NPC_HOST ld [wTempNPC], a - jp SetNextNPCAndOWSequence + jp SetNextNPCAndScript ChallengeHallAfterDuelTable: dw WonAtChallengeHall @@ -5499,12 +5499,12 @@ ChallengeHallLoadMap: ; f258 (3:7258) ld a, NPC_HOST ld [wTempNPC], a call FindLoadedNPC - ld bc, OWSequence_f433 - jp SetNextNPCAndOWSequence + ld bc, Script_f433 + jp SetNextNPCAndScript -OWSequence_Clerk13: ; f26c (3:726c) +Script_Clerk13: ; f26c (3:726c) start_script - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0525 Preload_Guide: ; f270 (3:7270) @@ -5520,195 +5520,195 @@ Preload_Guide: ; f270 (3:7270) ret ; 0xf283 -OWSequence_Guide: ; f283 (3:7283) +Script_Guide: ; f283 (3:7283) start_script - run_script OWScript_JumpIfFlagZero2 + run_script ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_42 dw .ows_f28b - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0526 .ows_f28b - run_script OWScript_JumpIfFlagZero1 + run_script ScriptCommand_JumpIfFlagZero1 db $3f dw .ows_f292 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0527 .ows_f292 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0528 -OWSequence_Clerk12: ; f295 (3:7295) +Script_Clerk12: ; f295 (3:7295) start_script - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $03 dw .ows_f2c4 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $02 dw .ows_f2c1 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $03 dw .ows_f2c4 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $02 dw .ows_f2c1 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $03 dw .ows_f2c4 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $02 dw .ows_f2c1 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f2cd - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f2d3 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f2c7 .ows_f2c1 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0529 .ows_f2c4 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text052a .ows_f2c7 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text052b - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f2d6 .ows_f2cd - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text052c - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f2d6 .ows_f2d3 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text052d .ows_f2d6 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text052e - run_script OWScript_AskQuestionJump + run_script ScriptCommand_AskQuestionJump tx Text052f dw .ows_f2e1 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text0530 .ows_f2e1 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_59 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0531 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f349 - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db 8 db 18 dw .ows_f2fa - run_script OWScript_JumpIfPlayerCoordMatches + run_script ScriptCommand_JumpIfPlayerCoordMatches db 12 db 18 dw .ows_f302 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $02 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f307 .ows_f2fa - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db EAST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db EAST db $02 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f307 .ows_f302 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db WEST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $02 .ows_f307 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db NORTH - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_43 dw .ows_f33a - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_43 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db NORTH db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db EAST - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 30 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db EAST - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 30 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 .ows_f33a - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db EAST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db EAST db $01 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f34e - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db $4a - dw OWSequence_f353 - run_script OWScript_EndScriptLoop1 + dw Script_f353 + run_script ScriptCommand_EndScriptLoop1 ret ; f349 @@ -5728,43 +5728,43 @@ NPCMovement_f34e: ; f34e (3:734e) db SOUTH db $ff -OWSequence_HostStubbed: ; f352 (3:7352) +Script_HostStubbed: ; f352 (3:7352) ret -OWSequence_f353: ; f353 (3:7353) +Script_f353: ; f353 (3:7353) start_script - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f390 run_script Func_d16b db $00 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0532 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37f - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0533 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f388 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0534 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f38e - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0535 run_script Func_cd4f db $04 db $00 db $00 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_f37d: ; f37d (3:737d) db EAST | NO_MOVE @@ -5805,115 +5805,115 @@ NPCMovement_f390: ; f390 (3:7390) LostAtChallengeHall: ; f392 (3:7392) start_script - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 - dw OWJump_f410 - run_script OWScript_JumpIfFlagEqual + dw ScriptJump_f410 + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $03 - dw OWJump_f410.ows_f41a + dw ScriptJump_f410.ows_f41a run_script Func_d16b db $00 run_script Func_d16b db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0536 .ows_f3ae - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f38b - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0537 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f38e - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f3ce - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f3d9 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_3F db $03 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_48 db $03 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_51 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f3e2 .ows_f3ce - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_40 db $03 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_49 db $03 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_55 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f3e2 .ows_f3d9 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_41 db $03 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_4A db $03 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f3e2 .ows_f3e2 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_CLERK12 - dw OWSequence_f3e9 - run_script OWScript_EndScriptLoop1 + dw Script_f3e9 + run_script ScriptCommand_EndScriptLoop1 ret -OWSequence_f3e9: ; f3e9 (3:73e9) +Script_f3e9: ; f3e9 (3:73e9) start_script - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f40a - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db WEST - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db WEST db $01 - run_script OWScript_SetPlayerDirection + run_script ScriptCommand_SetPlayerDirection db SOUTH - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MovePlayer + run_script ScriptCommand_MovePlayer db SOUTH db $01 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f40d - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_f40a: ; f40a (3:740a) db WEST @@ -5925,160 +5925,160 @@ NPCMovement_f40d: ; f40d (3:740d) db SOUTH | NO_MOVE db $ff -OWJump_f410: ; f410 (4:7410) +ScriptJump_f410: ; f410 (4:7410) run_script Func_d16b db $00 run_script Func_d16b db $01 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0538 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw LostAtChallengeHall.ows_f3ae .ows_f41a - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0539 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_RONALD1 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f42e - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text053a tx Text053b .ows_f42e - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_HOST - run_script OWScript_Jump + run_script ScriptCommand_Jump dw LostAtChallengeHall.ows_f3ae -OWSequence_f433: ; f433 (3:7433) +Script_f433: ; f433 (3:7433) start_script - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw WonAtChallengeHall.ows_f4a4 WonAtChallengeHall; f441 (3:7441) start_script - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 20 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $03 - dw OWJump_f4db - run_script OWScript_JumpIfFlagEqual + dw ScriptJump_f4db + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw .ows_f456 .ows_f456 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text053c tx Text053d - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37f run_script Func_d16b db $00 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text053e - run_script OWScript_CloseTextBox - run_script OWScript_MoveWramNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f4c8 run_script Func_cdd8 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text053f - run_script OWScript_CloseTextBox + run_script ScriptCommand_CloseTextBox run_script Func_d195 run_script Func_cdf5 db $14 db $14 - run_script OWScript_MoveWramNPC + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f4d0 run_script Func_d16b db $00 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0540 tx Text0541 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f383 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw .ows_f4a4 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f4a1 - run_script OWScript_CloseTextBox - run_script OWScript_SetDialogName + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_SetDialogName db $02 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0542 tx Text0543 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_HOST - run_script OWScript_CloseTextBox + run_script ScriptCommand_CloseTextBox .ows_f4a1 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0544 .ows_f4a4 - run_script OWScript_ZeroOutFlagValue + run_script ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_47 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0545 - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes tx Text0546 dw .ows_f4bd - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text0547 tx Text0548 run_script Func_cd4f db $04 db $00 db $00 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_f4bd - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0549 - run_script OWScript_CloseTextBox - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MaxOutFlagValue db EVENT_FLAG_47 run_script Func_d1ad - run_script OWScript_CloseTextBox - run_script OWScript_Jump + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_Jump dw .ows_f4a4 NPCMovement_f4c8: ; f4c8 (3:74c8) @@ -6107,111 +6107,111 @@ NPCMovement_f4d8: ; f4d8 (3:74d8) db SOUTH | NO_MOVE db $ff -OWJump_f4db: ; f4db (3:74db) - run_script OWScript_PrintTextString +ScriptJump_f4db: ; f4db (3:74db) + run_script ScriptCommand_PrintTextString tx Text054a - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f37f run_script Func_d16b db $00 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text054b - run_script OWScript_CloseTextBox - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f513 - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db $02 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text054c tx Text054d - run_script OWScript_MoveWramNPC + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f4d8 - run_script OWScript_DoFrames + run_script ScriptCommand_DoFrames db 40 - run_script OWScript_MoveWramNPC + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f34c - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script OWScript_PrintVariableText + run_script ScriptCommand_PrintVariableText tx Text054e tx Text054f - run_script OWScript_SetDialogName + run_script ScriptCommand_SetDialogName db NPC_HOST - run_script OWScript_CloseTextBox - run_script OWScript_MoveWramNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f4c9 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f516 .ows_f513 - run_script OWScript_MoveWramNPC + run_script ScriptCommand_MoveWramNPC dw NPCMovement_f4c8 .ows_f516 run_script Func_cdd8 - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f383 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0550 - run_script OWScript_CloseTextBox - run_script OWScript_MoveActiveNPC + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_MoveActiveNPC dw NPCMovement_f38b run_script Func_d1b3 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0551 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db $00 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db $00 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0552 - run_script OWScript_CloseTextBox - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_CloseTextBox + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f540 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f549 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_3F db $02 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_48 db $02 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f552 .ows_f540 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_40 db $02 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_49 db $02 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f552 .ows_f549 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_41 db $02 - run_script OWScript_SetFlagValue + run_script ScriptCommand_SetFlagValue db EVENT_FLAG_4A db $02 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_f552 .ows_f552 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db NPC_CLERK12 - dw OWSequence_f3e9 - run_script OWScript_EndScriptLoop1 + dw Script_f3e9 + run_script ScriptCommand_EndScriptLoop1 ret ; f559 @@ -6284,15 +6284,15 @@ Func_f5db: ; f5db (3:75db) Func_f602: ; f602 (3:7602) INCROM $f602, $f631 -OWSequence_f631: ; f631 (3:7631) +Script_f631: ; f631 (3:7631) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text0508 - run_script OWScript_CloseAdvancedTextBox - run_script OWScript_SetNextNPCandOWSequence + run_script ScriptCommand_CloseAdvancedTextBox + run_script ScriptCommand_SetNextNPCandScript db $02 dw $763c - run_script OWScript_EndScriptLoop1 + run_script ScriptCommand_EndScriptLoop1 ret ; 0xf63c @@ -6307,24 +6307,24 @@ HallOfHonorLoadMap: ; fbdb (3:7bdb) INCROM $fbe1, $fbf1 -OWSequence_fbf1: ; fbf1 (3:7bf1) +Script_fbf1: ; fbf1 (3:7bf1) start_script - run_script OWScript_JumpIfFlagNonzero2 + run_script ScriptCommand_JumpIfFlagNonzero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_fc10 - run_script OWScript_MaxOutFlagValue + run_script ScriptCommand_MaxOutFlagValue db EVENT_RECEIVED_LEGENDARY_CARD run_script Func_ccdc tx Text05b8 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db ZAPDOS3 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db MOLTRES2 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db ARTICUNO2 - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db DRAGONITE1 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db $ff .ows_fc05 run_script Func_d38f @@ -6337,21 +6337,21 @@ OWSequence_fbf1: ; fbf1 (3:7bf1) run_script Func_d396 db $01 run_script Func_d3b9 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_fc10 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_71 db $0f dw .ows_fc20 run_script Func_d209 run_script Func_ccdc tx Text05ba - run_script OWScript_GiveCard + run_script ScriptCommand_GiveCard db $00 - run_script OWScript_ShowCardReceivedScreen + run_script ScriptCommand_ShowCardReceivedScreen db $00 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_fc05 .ows_fc20 @@ -6361,7 +6361,7 @@ OWSequence_fbf1: ; fbf1 (3:7bf1) db $00 run_script Func_ccdc tx Text05bc - run_script OWScript_Jump + run_script ScriptCommand_Jump dw .ows_fc0a Func_fc2b: ; fc2b (3:7c2b) @@ -6382,26 +6382,26 @@ Func_fc2b: ; fc2b (3:7c2b) ld [wCurrentNPCNameTx], a ld a, $3 ld [wCurrentNPCNameTx+1], a - jp SetNextOWSequence + jp SetNextScript PointerTable_fc4c: ; fc4c (3:7c4c) dw Unknown_fc64 dw Unknown_fc68 dw Unknown_fc60 -OWSequence_fc52: ; fc52 (3:7c52) +Script_fc52: ; fc52 (3:7c52) start_script - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06c8 - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes dw $0000 dw .ows_fc5e - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06c9 .ows_fc5e run_script Func_cd76 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully Unknown_fc60: ; fc60 (3:7c60) INCROM $fc60, $fc64 @@ -6430,41 +6430,41 @@ Func_fc7a: ; fc7a (3:7c7a) set_flag_value EVENT_FLAG_74 start_script - run_script OWScript_JumpIfFlagNotEqual + run_script ScriptCommand_JumpIfFlagNotEqual db EVENT_FLAG_74 db $02 dw Func_fcad.ows_fcd5 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06cd run_script Func_d39d db $00 - run_script OWScript_JumpIfFlagNotLessThan + run_script ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_72 db $04 dw Func_fc7a.ows_fcaa - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06ce - run_script OWScript_AskQuestionJumpDefaultYes + run_script ScriptCommand_AskQuestionJumpDefaultYes tx Text06cf dw .ows_fca0 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06d0 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw Func_fc7a.ows_fcaa .ows_fca0 run_script Func_d396 db $00 - run_script OWScript_PlaySFX + run_script ScriptCommand_PlaySFX db $56 run_script Func_ccdc tx Text06d1 run_script Func_d39d db $01 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully .ows_fcaa - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06d2 Func_fcad: ; fcad (3:7cad) @@ -6473,47 +6473,47 @@ Func_fcad: ; fcad (3:7cad) set_flag_value EVENT_FLAG_72 start_script - run_script OWScript_PlaySFX + run_script ScriptCommand_PlaySFX db $56 run_script Func_d396 db $00 - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $00 dw .ows_fccc - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $02 dw .ows_fccf - run_script OWScript_JumpIfFlagEqual + run_script ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $03 dw .ows_fcd2 - run_script OWScript_Jump + run_script ScriptCommand_Jump dw Func_fc7a.ows_fcaa .ows_fccc - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06d3 .ows_fccf - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06d4 .ows_fcd2 - run_script OWScript_PrintTextQuitFully + run_script ScriptCommand_PrintTextQuitFully tx Text06d5 .ows_fcd5 - run_script OWScript_MoveArbitraryNPC + run_script ScriptCommand_MoveArbitraryNPC db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce1 - run_script OWScript_PrintTextString + run_script ScriptCommand_PrintTextString tx Text06d6 - run_script OWScript_MoveArbitraryNPC + run_script ScriptCommand_MoveArbitraryNPC db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce3 - run_script OWScript_QuitScriptFully + run_script ScriptCommand_QuitScriptFully NPCMovement_fce1: ; fce1 (3:7ce1) db SOUTH | NO_MOVE diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 7be9960..13df81b 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -878,8 +878,8 @@ LoadNPCSpriteData: ; 11857 (4:5857) pop hl ret -; Loads Name into wCurrentNPCNameTx and gets OWSequence ptr into bc -GetNPCNameAndOWSequence: ; 1187d (4:587d) +; Loads Name into wCurrentNPCNameTx and gets Script ptr into bc +GetNPCNameAndScript: ; 1187d (4:587d) push hl call GetNPCDataPointer ld bc, NPC_DATA_OWSEQUENCE_PTR @@ -969,23 +969,23 @@ Func_11f4e: ; 11f4e (4:5f4e) INCROM $11f4e, $1217b OverworldScriptTable: ; 1217b (4:617b) - dw OWScript_EndScriptLoop1 - dw OWScript_CloseAdvancedTextBox - dw OWScript_PrintTextString + dw ScriptCommand_EndScriptLoop1 + dw ScriptCommand_CloseAdvancedTextBox + dw ScriptCommand_PrintTextString dw Func_ccdc - dw OWScript_AskQuestionJump - dw OWScript_StartBattle - dw OWScript_PrintVariableText + dw ScriptCommand_AskQuestionJump + dw ScriptCommand_StartBattle + dw ScriptCommand_PrintVariableText dw Func_cda8 - dw OWScript_PrintTextQuitFully + dw ScriptCommand_PrintTextQuitFully dw Func_cdcb - dw OWScript_MoveActiveNPCByDirection - dw OWScript_CloseTextBox - dw OWScript_GiveBoosterPacks + dw ScriptCommand_MoveActiveNPCByDirection + dw ScriptCommand_CloseTextBox + dw ScriptCommand_GiveBoosterPacks dw Func_cf0c dw Func_cf12 - dw OWScript_GiveCard - dw OWScript_TakeCard + dw ScriptCommand_GiveCard + dw ScriptCommand_TakeCard dw Func_cf53 dw Func_cf7b dw Func_cf2d @@ -996,83 +996,83 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d025 dw Func_d032 dw Func_d03f - dw OWScript_Jump - dw OWScript_TryGiveMedalPCPacks - dw OWScript_SetPlayerDirection - dw OWScript_MovePlayer - dw OWScript_ShowCardReceivedScreen - dw OWScript_SetDialogName - dw OWScript_SetNextNPCandOWSequence + dw ScriptCommand_Jump + dw ScriptCommand_TryGiveMedalPCPacks + dw ScriptCommand_SetPlayerDirection + dw ScriptCommand_MovePlayer + dw ScriptCommand_ShowCardReceivedScreen + dw ScriptCommand_SetDialogName + dw ScriptCommand_SetNextNPCandScript dw Func_d095 dw Func_d0be - dw OWScript_DoFrames + dw ScriptCommand_DoFrames dw Func_d0d9 - dw OWScript_JumpIfPlayerCoordMatches - dw OWScript_MoveActiveNPC - dw OWScript_GiveOneOfEachTrainerBooster + dw ScriptCommand_JumpIfPlayerCoordMatches + dw ScriptCommand_MoveActiveNPC + dw ScriptCommand_GiveOneOfEachTrainerBooster dw Func_d103 dw Func_d125 dw Func_d135 dw Func_d16b dw Func_cd4f dw Func_cd94 - dw OWScript_MoveWramNPC + dw ScriptCommand_MoveWramNPC dw Func_cdd8 dw Func_cdf5 dw Func_d195 dw Func_d1ad dw Func_d1b3 - dw OWScript_QuitScriptFully + dw ScriptCommand_QuitScriptFully dw Func_d244 dw Func_d24c - dw OWScript_OpenDeckMachine + dw ScriptCommand_OpenDeckMachine dw Func_d271 - dw OWScript_EnterMap - dw OWScript_MoveArbitraryNPC + dw ScriptCommand_EnterMap + dw ScriptCommand_MoveArbitraryNPC dw Func_d209 dw Func_d38f dw Func_d396 dw Func_cd76 dw Func_d39d dw Func_d3b9 - dw OWScript_TryGivePCPack - dw OWScript_nop + dw ScriptCommand_TryGivePCPack + dw ScriptCommand_nop dw Func_d3d4 dw Func_d3e0 dw Func_d3fe dw Func_d408 dw Func_d40f - dw OWScript_PlaySFX - dw OWScript_PauseSong - dw OWScript_ResumeSong + dw ScriptCommand_PlaySFX + dw ScriptCommand_PauseSong + dw ScriptCommand_ResumeSong dw Func_d41d - dw OWScript_WaitForSongToFinish + dw ScriptCommand_WaitForSongToFinish dw Func_d435 - dw OWScript_AskQuestionJumpDefaultYes + dw ScriptCommand_AskQuestionJumpDefaultYes dw Func_d2f6 dw Func_d317 dw Func_d43d - dw OWScript_EndScriptLoop2 - dw OWScript_EndScriptLoop3 - dw OWScript_EndScriptLoop4 - dw OWScript_EndScriptLoop5 - dw OWScript_EndScriptLoop6 - dw OWScript_SetFlagValue - dw OWScript_JumpIfFlagZero1 - dw OWScript_JumpIfFlagNonzero1 - dw OWScript_JumpIfFlagEqual - dw OWScript_JumpIfFlagNotEqual - dw OWScript_JumpIfFlagNotLessThan - dw OWScript_JumpIfFlagLessThan - dw OWScript_MaxOutFlagValue - dw OWScript_ZeroOutFlagValue - dw OWScript_JumpIfFlagNonzero2 - dw OWScript_JumpIfFlagZero2 - dw OWScript_IncrementFlagValue - dw OWScript_EndScriptLoop7 - dw OWScript_EndScriptLoop8 - dw OWScript_EndScriptLoop9 - dw OWScript_EndScriptLoop10 + dw ScriptCommand_EndScriptLoop2 + dw ScriptCommand_EndScriptLoop3 + dw ScriptCommand_EndScriptLoop4 + dw ScriptCommand_EndScriptLoop5 + dw ScriptCommand_EndScriptLoop6 + dw ScriptCommand_SetFlagValue + dw ScriptCommand_JumpIfFlagZero1 + dw ScriptCommand_JumpIfFlagNonzero1 + dw ScriptCommand_JumpIfFlagEqual + dw ScriptCommand_JumpIfFlagNotEqual + dw ScriptCommand_JumpIfFlagNotLessThan + dw ScriptCommand_JumpIfFlagLessThan + dw ScriptCommand_MaxOutFlagValue + dw ScriptCommand_ZeroOutFlagValue + dw ScriptCommand_JumpIfFlagNonzero2 + dw ScriptCommand_JumpIfFlagZero2 + dw ScriptCommand_IncrementFlagValue + dw ScriptCommand_EndScriptLoop7 + dw ScriptCommand_EndScriptLoop8 + dw ScriptCommand_EndScriptLoop9 + dw ScriptCommand_EndScriptLoop10 INCROM $1224b, $1229f diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 6bad8c9..45cc8b1 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -438,9 +438,9 @@ FindNPCAtLocation: ; 1c72e (7:472e) pop hl ret -; Probably needs a new name. Loads data for NPC that the next OWSequence is for +; Probably needs a new name. Loads data for NPC that the next Script is for ; Sets direction, Loads Image data for it, loads name, and more -SetNewOWSequenceNPC: ; 1c768 (7:4768) +SetNewScriptNPC: ; 1c768 (7:4768) push hl ld a, [wLoadedNPCTempIndex] ld l, LOADED_NPC_DIRECTION @@ -454,7 +454,7 @@ SetNewOWSequenceNPC: ; 1c768 (7:4768) ld a, [wLoadedNPCTempIndex] call GetLoadedNPCID ld a, [hl] - farcall GetNPCNameAndOWSequence + farcall GetNPCNameAndScript pop hl ret diff --git a/src/engine/home.asm b/src/engine/home.asm index 24cb61d..478aa39 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -11087,9 +11087,9 @@ HandleMoveModeAPress: ; 3a5e (0:3a5e) cp c jr nz, .noMatch ld a, [hli] - ld [wNextOWSequence], a + ld [wNextScript], a ld a, [hli] - ld [wNextOWSequence+1], a + ld [wNextScript+1], a ld a, [hli] ld [wDefaultObjectText], a ld a, [hli] @@ -11159,9 +11159,9 @@ Func_3ae8: ; 3ae8 (0:3ae8) ret ; 0x3aed -; finds an OWScript from the first byte and puts the next two bytes (usually arguments?) into cb +; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb RunOverworldScript: ; 3aed (0:3aed) - ld hl, wOWScriptPointer + ld hl, wScriptPointer ld a, [hli] ld h, [hl] ld l, a diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index e21845b..0c24463 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -5,7 +5,7 @@ run_script: MACRO ENDM ; TODO: create macros for overworld scripts after their usage and arguments are figured out. -; For example (current OWScript_GiveBoosterPacks_index): +; For example (current ScriptCommand_GiveBoosterPacks_index): ; const SCRIPT_GIVE_BOOSTER_PACKS ; $0c ;give_booster_packs: MACRO @@ -14,23 +14,23 @@ ENDM ;ENDM const_def - const OWScript_EndScriptLoop1_index ; $00 - const OWScript_CloseAdvancedTextBox_index ; $01 - const OWScript_PrintTextString_index ; $02 + const ScriptCommand_EndScriptLoop1_index ; $00 + const ScriptCommand_CloseAdvancedTextBox_index ; $01 + const ScriptCommand_PrintTextString_index ; $02 const Func_ccdc_index ; $03 - const OWScript_AskQuestionJump_index ; $04 - const OWScript_StartBattle_index ; $05 - const OWScript_PrintVariableText_index ; $06 + const ScriptCommand_AskQuestionJump_index ; $04 + const ScriptCommand_StartBattle_index ; $05 + const ScriptCommand_PrintVariableText_index ; $06 const Func_cda8_index ; $07 - const OWScript_PrintTextQuitFully_index ; $08 + const ScriptCommand_PrintTextQuitFully_index ; $08 const Func_cdcb_index ; $09 - const OWScript_MoveActiveNPCByDirection_index ; $0a - const OWScript_CloseTextBox_index ; $0b - const OWScript_GiveBoosterPacks_index ; $0c + const ScriptCommand_MoveActiveNPCByDirection_index ; $0a + const ScriptCommand_CloseTextBox_index ; $0b + const ScriptCommand_GiveBoosterPacks_index ; $0c const Func_cf0c_index ; $0d const Func_cf12_index ; $0e - const OWScript_GiveCard_index ; $0f - const OWScript_TakeCard_index ; $10 + const ScriptCommand_GiveCard_index ; $0f + const ScriptCommand_TakeCard_index ; $10 const Func_cf53_index ; $11 const Func_cf7b_index ; $12 const Func_cf2d_index ; $13 @@ -41,81 +41,81 @@ ENDM const Func_d025_index ; $18 const Func_d032_index ; $19 const Func_d03f_index ; $1a - const OWScript_Jump_index ; $1b - const OWScript_TryGiveMedalPCPacks_index ; $1c - const OWScript_SetPlayerDirection_index ; $1d - const OWScript_MovePlayer_index ; $1e - const OWScript_ShowCardReceivedScreen_index ; $1f - const OWScript_SetDialogName_index ; $20 - const OWScript_SetNextNPCandOWSequence_index ; $21 + const ScriptCommand_Jump_index ; $1b + const ScriptCommand_TryGiveMedalPCPacks_index ; $1c + const ScriptCommand_SetPlayerDirection_index ; $1d + const ScriptCommand_MovePlayer_index ; $1e + const ScriptCommand_ShowCardReceivedScreen_index ; $1f + const ScriptCommand_SetDialogName_index ; $20 + const ScriptCommand_SetNextNPCandScript_index ; $21 const Func_d095_index ; $22 const Func_d0be_index ; $23 - const OWScript_DoFrames_index ; $24 + const ScriptCommand_DoFrames_index ; $24 const Func_d0d9_index ; $25 - const OWScript_JumpIfPlayerCoordMatches_index ; $26 - const OWScript_MoveActiveNPC_index ; $27 - const OWScript_GiveOneOfEachTrainerBooster_index ; $28 + const ScriptCommand_JumpIfPlayerCoordMatches_index ; $26 + const ScriptCommand_MoveActiveNPC_index ; $27 + const ScriptCommand_GiveOneOfEachTrainerBooster_index ; $28 const Func_d103_index ; $29 const Func_d125_index ; $2a const Func_d135_index ; $2b const Func_d16b_index ; $2c const Func_cd4f_index ; $2d const Func_cd94_index ; $2e - const OWScript_MoveWramNPC_index ; $2f + const ScriptCommand_MoveWramNPC_index ; $2f const Func_cdd8_index ; $30 const Func_cdf5_index ; $31 const Func_d195_index ; $32 const Func_d1ad_index ; $33 const Func_d1b3_index ; $34 - const OWScript_QuitScriptFully_index ; $35 + const ScriptCommand_QuitScriptFully_index ; $35 const Func_d244_index ; $36 const Func_d24c_index ; $37 - const OWScript_OpenDeckMachine_index ; $38 + const ScriptCommand_OpenDeckMachine_index ; $38 const Func_d271_index ; $39 - const OWScript_EnterMap_index ; $3a - const OWScript_MoveArbitraryNPC_index ; $3b + const ScriptCommand_EnterMap_index ; $3a + const ScriptCommand_MoveArbitraryNPC_index ; $3b const Func_d209_index ; $3c const Func_d38f_index ; $3d const Func_d396_index ; $3e const Func_cd76_index ; $3f const Func_d39d_index ; $40 const Func_d3b9_index ; $41 - const OWScript_TryGivePCPack_index ; $42 - const OWScript_nop_index ; $43 + const ScriptCommand_TryGivePCPack_index ; $42 + const ScriptCommand_nop_index ; $43 const Func_d3d4_index ; $44 const Func_d3e0_index ; $45 const Func_d3fe_index ; $46 const Func_d408_index ; $47 const Func_d40f_index ; $48 - const OWScript_PlaySFX_index ; $49 - const OWScript_PauseSong_index ; $4a - const OWScript_ResumeSong_index ; $4b + const ScriptCommand_PlaySFX_index ; $49 + const ScriptCommand_PauseSong_index ; $4a + const ScriptCommand_ResumeSong_index ; $4b const Func_d41d_index ; $4c - const OWScript_WaitForSongToFinish_index ; $4d + const ScriptCommand_WaitForSongToFinish_index ; $4d const Func_d435_index ; $4e - const OWScript_AskQuestionJumpDefaultYes_index ; $4f + const ScriptCommand_AskQuestionJumpDefaultYes_index ; $4f const Func_d2f6_index ; $50 const Func_d317_index ; $51 const Func_d43d_index ; $52 - const OWScript_EndScriptLoop2_index ; $53 - const OWScript_EndScriptLoop3_index ; $54 - const OWScript_EndScriptLoop4_index ; $55 - const OWScript_EndScriptLoop5_index ; $56 - const OWScript_EndScriptLoop6_index ; $57 - const OWScript_SetFlagValue_index ; $58 - const OWScript_JumpIfFlagZero1_index ; $59 - const OWScript_JumpIfFlagNonzero1_index ; $5a - const OWScript_JumpIfFlagEqual_index ; $5b - const OWScript_JumpIfFlagNotEqual_index ; $5c - const OWScript_JumpIfFlagNotLessThan_index ; $5d - const OWScript_JumpIfFlagLessThan_index ; $5e - const OWScript_MaxOutFlagValue_index ; $5f - const OWScript_ZeroOutFlagValue_index ; $60 - const OWScript_JumpIfFlagNonzero2_index ; $61 - const OWScript_JumpIfFlagZero2_index ; $62 - const OWScript_IncrementFlagValue_index ; $63 - const OWScript_EndScriptLoop7_index ; $64 - const OWScript_EndScriptLoop8_index ; $65 - const OWScript_EndScriptLoop9_index ; $66 - const OWScript_EndScriptLoop10_index ; $67 + const ScriptCommand_EndScriptLoop2_index ; $53 + const ScriptCommand_EndScriptLoop3_index ; $54 + const ScriptCommand_EndScriptLoop4_index ; $55 + const ScriptCommand_EndScriptLoop5_index ; $56 + const ScriptCommand_EndScriptLoop6_index ; $57 + const ScriptCommand_SetFlagValue_index ; $58 + const ScriptCommand_JumpIfFlagZero1_index ; $59 + const ScriptCommand_JumpIfFlagNonzero1_index ; $5a + const ScriptCommand_JumpIfFlagEqual_index ; $5b + const ScriptCommand_JumpIfFlagNotEqual_index ; $5c + const ScriptCommand_JumpIfFlagNotLessThan_index ; $5d + const ScriptCommand_JumpIfFlagLessThan_index ; $5e + const ScriptCommand_MaxOutFlagValue_index ; $5f + const ScriptCommand_ZeroOutFlagValue_index ; $60 + const ScriptCommand_JumpIfFlagNonzero2_index ; $61 + const ScriptCommand_JumpIfFlagZero2_index ; $62 + const ScriptCommand_IncrementFlagValue_index ; $63 + const ScriptCommand_EndScriptLoop7_index ; $64 + const ScriptCommand_EndScriptLoop8_index ; $65 + const ScriptCommand_EndScriptLoop9_index ; $66 + const ScriptCommand_EndScriptLoop10_index ; $67 diff --git a/src/wram.asm b/src/wram.asm index 96d5934..60a8bc5 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1873,7 +1873,7 @@ wd0c5:: ; d0c5 ds $1 ; used to store the location of an overworld sequence, which is jumped to later -wNextOWSequence:: ; d0c6 +wNextScript:: ; d0c6 ds $2 wCurrentNPCNameTx:: ; d0c8 @@ -2151,7 +2151,7 @@ wd3b3:: ; d3b3 ds $2 -; ID of the NPC being interacted with in OWScript +; ID of the NPC being interacted with in Script wScriptNPC:: ; d3b6 ds $1 @@ -2180,10 +2180,10 @@ wEventFlags:: ds $40 ; 0 keeps looping, other values break the loop in RST20 -wBreakOWScriptLoop:: ; d412 +wBreakScriptLoop:: ; d412 ds $1 -wOWScriptPointer:: ; d413 +wScriptPointer:: ; d413 ds $2 ; generally set to ff when a flag check passes, 0 otherwise -- cgit v1.2.3 From 29ed945c4adce0b6bc45be3964f95393d8248390 Mon Sep 17 00:00:00 2001 From: Andrew Martinek Date: Sat, 9 May 2020 15:49:35 -0400 Subject: changed run_script and updated script extraction tool --- src/engine/bank03.asm | 1690 ++++++++++++++++++++++++------------------------ src/macros/scripts.asm | 2 +- 2 files changed, 846 insertions(+), 846 deletions(-) (limited to 'src') diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 7fb9ee9..07e903e 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -3145,18 +3145,18 @@ Func_d4fb: ; d4fb (3:54fb) Script_BeginGame: ; d52e (3:552e) start_script - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db $3c - run_script Func_d3e0 - run_script ScriptCommand_DoFrames + run_command Func_d3e0 + run_command ScriptCommand_DoFrames db $78 - run_script ScriptCommand_EnterMap + run_command ScriptCommand_EnterMap db $02 db MASON_LABORATORY db 14 db 26 db NORTH - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully MasonLaboratoryAfterDuel: ; d53b (3:553b) ld hl, .after_duel_table @@ -3203,217 +3203,217 @@ ChallengeMachineObjectTable: ; d572 (3:5572) Script_ChallengeMachine: ; d57d (3:557d) start_script - run_script Func_ccdc + run_command Func_ccdc tx Text05bd - run_script Func_d43d - run_script ScriptCommand_QuitScriptFully + run_command Func_d43d + run_command ScriptCommand_QuitScriptFully INCROM $d583, $d753 Script_EnterLabFirstTime: ; d753 (3:5753) start_script - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e3 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_SAM dw Script_d779 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret Script_d779: ; d779 (03:5779) start_script - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_d880 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e4 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_DRMASON - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e5 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_d882 - run_script Func_cfc6 + run_command Func_cfc6 db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db $03 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_DRMASON dw Script_d794 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret Script_d794: ; d794 (3:5794) start_script - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_d88b - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 40 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e6 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MovePlayer db WEST db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db WEST - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_d894 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e7 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db $07 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e8 .ows_d7bc - run_script ScriptCommand_CloseTextBox - run_script Func_d317 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_CloseTextBox + run_command Func_d317 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $07 dw .ows_d80c - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $01 dw .ows_d7e8 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $02 dw .ows_d7ee - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $03 dw .ows_d7f4 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $04 dw .ows_d7fa - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $05 dw .ows_d800 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_75 db $06 dw .ows_d806 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05d6 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d7e8 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05d7 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d7ee - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05d8 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d7f4 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05d9 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d7fa - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05da - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d800 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05db - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d806 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05dc - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d80c - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05e9 - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes dw 0000 dw .ows_d817 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_d7bc .ows_d817 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text05ea - run_script ScriptCommand_nop - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_nop + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_3E db $01 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_SAM dw Script_d827 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret Script_d827: ; d827 (3:5827) start_script - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_2 db SAMS_PRACTICE_DECK_ID db MUSIC_DUEL_THEME_1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ; 0xd82d INCROM $d82d, $d880 @@ -3452,17 +3452,17 @@ NPCMovement_d894: ; d894 (4:5894) Script_d932: ; d932 (3:5932) start_script - run_script Func_ccdc + run_command Func_ccdc tx Text0605 - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes tx Text0606 dw .ows_d93c - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_d93c - run_script ScriptCommand_OpenDeckMachine + run_command ScriptCommand_OpenDeckMachine db $09 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ; 0xd93f INCROM $d93f, $dadd @@ -3490,230 +3490,230 @@ Preload_IshiharaInIshiharasHouse: ; db3d (3:5b3d) Script_Ishihara: ; db4a (3:5b4a) start_script - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_1D - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $00 dw .ows_db80 - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_39 dw .ows_db5a - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_dc3e .ows_db5a - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_00 dw .ows_db90 - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_38 dw .ows_db90 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $01 dw .ows_db93 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $02 dw .ows_db93 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $03 dw .ows_dbcc - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $04 dw .ows_dbcc - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $05 dw .ows_dc05 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $06 dw .ows_dc05 .ows_db80 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $01 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_db8d - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_39 .ows_db8d - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0727 .ows_db90 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0728 .ows_db93 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0729 tx Text072a - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $02 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text072b dw .ows_dba8 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text072c .ows_dba8 - run_script Func_cf0c + run_command Func_cf0c db $ac dw .ows_dbaf - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text072d .ows_dbaf - run_script Func_cf12 + run_command Func_cf12 db $ac dw .ows_dbb6 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text072e .ows_dbb6 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $03 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text072f - run_script Func_ccdc + run_command Func_ccdc tx Text0730 - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db CLEFABLE - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db SURFING_PIKACHU1 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db SURFING_PIKACHU1 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0731 .ows_dbcc - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $03 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0732 tx Text0733 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $04 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text072b dw .ows_dbe1 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text072c .ows_dbe1 - run_script Func_cf0c + run_command Func_cf0c db $bb dw .ows_dbe8 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0734 .ows_dbe8 - run_script Func_cf12 + run_command Func_cf12 db $bb dw .ows_dbef - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0735 .ows_dbef - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $05 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text072f - run_script Func_ccdc + run_command Func_ccdc tx Text0736 - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db DITTO - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db FLYING_PIKACHU - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db FLYING_PIKACHU - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0737 .ows_dc05 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_1F db $05 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0738 tx Text0739 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $06 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text072b dw .ows_dc1a - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text072c .ows_dc1a - run_script Func_cf0c + run_command Func_cf0c db $b8 dw .ows_dc21 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text073a .ows_dc21 - run_script Func_cf12 + run_command Func_cf12 db $b8 dw .ows_dc28 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text073b .ows_dc28 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_00 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_1F db $07 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_38 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text072f - run_script Func_ccdc + run_command Func_ccdc tx Text073c - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db CHANSEY - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db SURFING_PIKACHU2 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db SURFING_PIKACHU2 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text073d .ows_dc3e - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_39 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text073e Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) @@ -3724,25 +3724,25 @@ Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) Script_Ronald: ; dc4b (3:5c4b) start_script - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_4E dw .ows_dc55 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_4E - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text073f .ows_dc55 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0740 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0741 dw .ows_dc60 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0742 .ows_dc60 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0743 ; 0xdc63 @@ -3752,7 +3752,7 @@ Script_Ronald: ; dc4b (3:5c4b) Script_Clerk1: ; dc64 (3:5c64) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text045a FightingClubLobbyAfterDuel: ; dc68 (3:5c68) @@ -3770,110 +3770,110 @@ FightingClubLobbyAfterDuel: ; dc68 (3:5c68) Script_Imakuni: ; dd0d (3:5d0d) start_script - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_IMAKUNI_STATE db IMAKUNI_TALKED - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_TEMP_TALKED_TO_IMAKUNI dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0467 tx Text0468 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_TEMP_TALKED_TO_IMAKUNI - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0469 dw .declineDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046a - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .declineDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046b - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_6 db IMAKUNI_DECK_ID db MUSIC_IMAKUNI - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ; 0xdd2d Script_BeatImakuni: ; dd2d (3:5d2d) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $07 dw .giveBoosters - run_script ScriptCommand_IncrementFlagValue + run_command ScriptCommand_IncrementFlagValue db EVENT_IMAKUNI_WIN_COUNT - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $03 dw .threeWins - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_IMAKUNI_WIN_COUNT db $06 dw .sixWins .giveBoosters - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046c - run_script ScriptCommand_GiveOneOfEachTrainerBooster - run_script ScriptCommand_Jump + run_command ScriptCommand_GiveOneOfEachTrainerBooster + run_command ScriptCommand_Jump dw .done .threeWins - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046d - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .giveImakuniCard .sixWins - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046e .giveImakuniCard - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text046f - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db IMAKUNI_CARD - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db IMAKUNI_CARD .done - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0470 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw ScriptJump_ImakuniCommon Script_LostToImakuni: ; dd5c (3:5d5c) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0471 ScriptJump_ImakuniCommon: ; dd60 (3:5d60) - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfPlayerCoordMatches db 18 db 4 dw .ows_dd69 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_dd6e .ows_dd69 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db EAST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 .ows_dd6e - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_dd78 - run_script Func_cdcb - run_script ScriptCommand_MaxOutFlagValue + run_command Func_cdcb + run_command ScriptCommand_MaxOutFlagValue db EVENT_TEMP_BATTLED_IMAKUNI - run_script Func_d408 + run_command Func_d408 db $09 - run_script Func_d41d - run_script ScriptCommand_QuitScriptFully + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully ; 0xdd78 NPCMovement_dd78 ; dd78 (3:5d78) @@ -3911,94 +3911,94 @@ Preload_ImakuniInWaterClubLobby: ; e0b0 (3:60b0) Script_Gal1: ; e0cf (3:60cf) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_12 db $02 dw .ows_e10e - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_12 db $00 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text041d tx Text041e - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_12 db $01 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text041f dw .ows_e0eb - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0420 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e0eb - run_script Func_cf0c + run_command Func_cf0c db $59 dw .ows_e0f3 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0421 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e0f3 - run_script Func_cf12 + run_command Func_cf12 db $59 dw .ows_e0fb - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0422 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e0fb - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_12 db $02 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0423 - run_script Func_ccdc + run_command Func_ccdc tx Text0424 - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db LAPRAS - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db ARCANINE1 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db ARCANINE1 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0425 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e10e - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0426 Script_Lass1: ; e111 (3:6111) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_14 db $01 dw .ows_e121 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0427 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_14 db $01 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_IMAKUNI_STATE db IMAKUNI_MENTIONED - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e121 - run_script ScriptCommand_JumpIfFlagNotEqual + run_command ScriptCommand_JumpIfFlagNotEqual db EVENT_IMAKUNI_ROOM db IMAKUNI_WATER_CLUB dw .ows_e12d - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_TEMP_BATTLED_IMAKUNI dw .ows_e12d - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0428 .ows_e12d - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0429 Preload_Man2InWaterClubLobby: ; e130 (3:6130) @@ -4008,12 +4008,12 @@ Preload_Man2InWaterClubLobby: ; e130 (3:6130) Script_Man2: ; e137 (3:6137) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text042a Script_Pappy2: ; e13b (3:613b) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text042b WaterClubMovePlayer: ; e13f (3:613f) @@ -4057,138 +4057,138 @@ WaterClubAfterDuel: ;e157 (3:6157) Script_Sara: ; e177 (3:6177) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042c - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text042d dw .yes_duel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042e - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .yes_duel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042f - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_2 db WATERFRONT_POKEMON_DECK_ID db MUSIC_DUEL_THEME_1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatSara: ; e18c (3:618c) start_script - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_BEAT_SARA - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0430 - run_script ScriptCommand_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_COLOSSEUM_WATER db BOOSTER_COLOSSEUM_WATER db NO_BOOSTER - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0431 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_LostToSara: ; e19a (03:619a) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0432 Script_Amanda: ; e19e (03:619e) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0433 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0434 dw .yes_duel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0435 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .yes_duel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0436 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_3 db LONELY_FRIENDS_DECK_ID db MUSIC_DUEL_THEME_1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatAmanda: ; e1b3 (03:61b3) start_script - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_BEAT_AMANDA - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0437 - run_script ScriptCommand_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db NO_BOOSTER - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0438 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_LostToAmanda: ; e1c1 (03:61c1) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0439 Script_NotReadyToSeeAmy: ; e1c5 (03:61c5) start_script - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $12 db $08 dw .ows_e1ec - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $14 db $08 dw .ows_e1f2 - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $18 db $08 dw .ows_e1f8 .ows_e1d5 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $04 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e213 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text043a - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $12 db $0a dw .ows_e1fe - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $14 db $0a dw .ows_e202 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e215 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e1ec - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e206 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_e1d5 .ows_e1f2 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e20b - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_e1d5 .ows_e1f8 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e20f - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_e1d5 .ows_e1fe - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e218 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e202 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e219 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully NPCMovement_e206: ; e206 (3:6206) db NORTH @@ -4229,119 +4229,119 @@ NPCMovement_e219: ; e219 (3:6219) Script_Joshua: ; e21c (3:621c) start_script - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_AMANDA dw .sara_and_amanda_not_beaten - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_SARA dw .sara_and_amanda_not_beaten - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .beat_sara_and_amanda .sara_and_amanda_not_beaten - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_TALKED - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text043b - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .beat_sara_and_amanda - run_script ScriptCommand_JumpIfFlagNonzero1 + run_command ScriptCommand_JumpIfFlagNonzero1 db EVENT_JOSHUA_STATE dw .already_talked - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_TALKED - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text043b - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text043c .already_talked - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text043d tx Text043e - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text043f dw .startDuel - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0440 tx Text0441 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .startDuel: - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0442 - run_script ScriptCommand_TryGivePCPack + run_command ScriptCommand_TryGivePCPack db $04 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_4 db SOUND_OF_THE_WAVES_DECK_ID db MUSIC_DUEL_THEME_1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_LostToJoshua: ; e260 (3:6260) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0443 tx Text0444 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatJoshua: ; e26c (3:626c) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0445 tx Text0446 - run_script ScriptCommand_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_WATER_COLORLESS db BOOSTER_MYSTERY_WATER_COLORLESS db NO_BOOSTER - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_JOSHUA_STATE db JOSHUA_TALKED dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0447 tx Text0448 - run_script ScriptCommand_JumpIfFlagNotEqual + run_command ScriptCommand_JumpIfFlagNotEqual db EVENT_JOSHUA_STATE db JOSHUA_BEATEN dw .firstJoshuaWin - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .firstJoshuaWin: - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_JOSHUA_STATE db JOSHUA_BEATEN - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0449 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPCByDirection + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPCByDirection dw NPCMovementTable_e2a1 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044a - run_script Func_cfc6 + run_command Func_cfc6 db $00 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_AMY dw Script_MeetAmy - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret NPCMovementTable_e2a1: ; e2a1 (3:62a1) @@ -4380,149 +4380,149 @@ Preload_Amy: ; e2ad (3:62ad) Script_MeetAmy: ; e2d1 (3:62d1) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044b - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_JOSHUA - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044c - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_AMY - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044d - run_script ScriptCommand_CloseTextBox - run_script Func_d095 + run_command ScriptCommand_CloseTextBox + run_command Func_d095 db $09 db $2f db $10 - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db $20 - run_script Func_d095 + run_command Func_d095 db $04 db $0e db $00 - run_script Func_d0be + run_command Func_d0be db $14 db $04 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db $03 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db $00 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MoveArbitraryNPC + run_command ScriptCommand_MoveArbitraryNPC db NPC_JOSHUA dw NPCMovement_e2ab - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044e - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw Script_Amy.askConfirmDuel Script_Amy: ; e304 (3:6304) start_script - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_BEAT_AMY dw ScriptJump_TalkToAmyAgain - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text044f .askConfirmDuel - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0450 dw .startDuel .denyDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0451 - run_script Func_d0d9 + run_command Func_d0d9 db $14 db $04 dw Script_LostToAmy.ows_e34e - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .startDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0452 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatAmy: ; e322 (3:6322) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0453 - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_BEAT_AMY dw .beatAmyCommon - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0454 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_BEAT_AMY - run_script ScriptCommand_TryGiveMedalPCPacks - run_script Func_d125 + run_command ScriptCommand_TryGiveMedalPCPacks + run_command Func_d125 db EVENT_BEAT_AMY - run_script Func_d435 + run_command Func_d435 db $03 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0455 .beatAmyCommon - run_script ScriptCommand_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_LABORATORY_WATER db BOOSTER_LABORATORY_WATER db NO_BOOSTER - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0456 - run_script Func_d0d9 + run_command Func_d0d9 db $14 db $04 dw Script_LostToAmy.ows_e34e - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_LostToAmy: ; e344 (3:6344) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0457 - run_script Func_d0d9 + run_command Func_d0d9 db $14 db $04 dw .ows_e34e - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_e34e - run_script Func_d095 + run_command Func_d095 db $08 db $2e db $10 - run_script Func_d0be + run_command Func_d0be db $16 db $04 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ScriptJump_TalkToAmyAgain: ; e356 (3:6356) - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0458 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0450 dw .startDuel - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw Script_Amy.denyDuel .startDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0459 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_6 db GO_GO_RAIN_DANCE_DECK_ID db MUSIC_DUEL_THEME_2 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ; 0xe369 INCROM $e369, $e525 @@ -4596,240 +4596,240 @@ GrassClubLobbyAfterDuel: ; e5c4 (3:65c4) Script_Brittany: ; e5d2 (3:65d2) start_script - run_script ScriptCommand_JumpIfFlagLessThan + run_command ScriptCommand_JumpIfFlagLessThan db EVENT_FLAG_35 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text06e0 tx Text06e1 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text06e2 dw .wantToDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06e3 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .wantToDuel - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06e4 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_4 db ETCETERA_DECK_ID db MUSIC_DUEL_THEME_1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatBrittany: ; e5ee (3:65ee) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06e5 - run_script ScriptCommand_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_GRASS_COLORLESS db BOOSTER_MYSTERY_GRASS_COLORLESS db NO_BOOSTER - run_script ScriptCommand_JumpIfFlagLessThan + run_command ScriptCommand_JumpIfFlagLessThan db EVENT_FLAG_35 db $02 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text06e6 tx Text06e7 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db FLAG_BEAT_BRITTANY - run_script ScriptCommand_JumpIfFlagNotLessThan + run_command ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_35 db $02 dw .finishSequence - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_3A dw .finishSequence - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_3B dw .finishSequence - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_35 db $01 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_1E - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06e8 .finishSequence - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_LostToBrittany: ; e618 (3:6618) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06e9 ; 0xe61c Script_e61c: ; e61c (3:661c) - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06ea Script_e61f: ; e61f (3:661f) start_script - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_04 dw Script_e61c - run_script ScriptCommand_JumpIfFlagNotLessThan + run_command ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $06 dw Script_e61c - run_script ScriptCommand_JumpIfFlagNotLessThan + run_command ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $04 dw .ows_e6a1 - run_script ScriptCommand_JumpIfFlagNotLessThan + run_command ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_37 db $02 dw .ows_e66a - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $00 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text06eb tx Text06ec - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $01 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e648 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06ee .ows_e648 - run_script Func_cf0c + run_command Func_cf0c db $1c dw .ows_e64f - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06ef .ows_e64f - run_script Func_cf12 + run_command Func_cf12 db $1c dw .ows_e656 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f0 .ows_e656 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $02 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06f1 - run_script Func_ccdc + run_command Func_ccdc tx Text06f2 - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db ODDISH - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db VILEPLUME - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db VILEPLUME - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f3 .ows_e66a - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $02 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text06f4 tx Text06f5 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $03 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e67f - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f6 .ows_e67f - run_script Func_cf0c + run_command Func_cf0c db $ab dw .ows_e686 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f7 .ows_e686 - run_script Func_cf12 + run_command Func_cf12 db $ab dw .ows_e68d - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f8 .ows_e68d - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $04 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06f9 - run_script Func_ccdc + run_command Func_ccdc tx Text06fa - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db CLEFAIRY - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db PIKACHU3 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db PIKACHU3 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f3 .ows_e6a1 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_37 db $04 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text06fb tx Text06fc - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $05 - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text06ed dw .ows_e6b6 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06fd .ows_e6b6 - run_script Func_cf0c + run_command Func_cf0c db $32 dw .ows_e6bd - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06fe .ows_e6bd - run_script Func_cf12 + run_command Func_cf12 db $32 dw .ows_e6c4 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06ff .ows_e6c4 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_04 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_37 db $06 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0700 - run_script Func_ccdc + run_command Func_ccdc tx Text0701 - run_script ScriptCommand_TakeCard + run_command ScriptCommand_TakeCard db CHARIZARD - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db BLASTOISE - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db BLASTOISE - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06f3 ; 0xe6d8 @@ -4894,48 +4894,48 @@ TrySecondRonaldFight: ; e837 (3:6837) Script_FirstRonaldEncounter: ; e862 (3:6862) start_script - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_4B - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e894 - run_script Func_d135 + run_command Func_d135 db $00 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0645 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0646 - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes dw 0000 dw .ows_e882 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0647 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_e885 .ows_e882 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0648 .ows_e885 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0649 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_SetPlayerDirection db $03 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db EAST db $04 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e894 - run_script Func_cdcb - run_script Func_d41d - run_script ScriptCommand_QuitScriptFully + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully NPCMovement_e894: ; e894 (3:6894) db SOUTH @@ -4950,70 +4950,70 @@ NPCMovement_e894: ; e894 (3:6894) Script_FirstRonaldFight: ; e8c0 (3:68c0) start_script - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e905 - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db $3c - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e90d - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064a - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $08 db $02 dw $68d6 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db WEST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064b - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db $4c db $01 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_6 db IM_RONALD_DECK_ID db MUSIC_RONALD - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatFirstRonaldFight: ; e8e9 (3:68e9) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064c - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db JIGGLYPUFF1 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db JIGGLYPUFF1 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064d - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw ScriptJump_FinishedFirstRonaldFight Script_LostToFirstRonaldFight: ; e8f7 (3:68f7) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064e ScriptJump_FinishedFirstRonaldFight - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_4C db $02 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e90f - run_script Func_cdcb - run_script Func_d41d - run_script ScriptCommand_QuitScriptFully + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully NPCMovement_e905: ; e905 (3:6905) db EAST @@ -5042,71 +5042,71 @@ NPCMovement_e90f: ; e90f (3:690f) ScriptSecondRonaldFight: ; e91e (3:691e) start_script - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e905 - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 60 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e90d - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text064f - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db $08 db $02 dw .ows_6934 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db WEST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 .ows_6934 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0650 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_4D db $01 - run_script ScriptCommand_StartBattle + run_command ScriptCommand_StartBattle db PRIZES_6 db POWERFUL_RONALD_DECK_ID db MUSIC_RONALD - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully Script_BeatSecondRonaldFight: ; e947 (3:6947) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0651 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db SUPER_ENERGY_RETRIEVAL - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db SUPER_ENERGY_RETRIEVAL - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0652 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw ScriptJump_FinishedSecondRonaldFight Script_LostToSecondRonaldFight: ; e955 (3:6955) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0653 ScriptJump_FinishedSecondRonaldFight ; e959 (3:6959) - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_4D db $02 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_e90f - run_script Func_cdcb - run_script Func_d41d - run_script ScriptCommand_QuitScriptFully + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully ; 0xe963 INCROM $e963, $ed57 @@ -5161,23 +5161,23 @@ FindExtraInteractableObjects: ; ed64 (3:6d64) Script_ee76: ; ee76 (3:6e76) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_21 db $01 dw .ows_ee7d - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_ee7d - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_21 db $02 - run_script Func_ccdc + run_command Func_ccdc tx Text06a2 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db SLOWPOKE1 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db SLOWPOKE1 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully ; 0xee88 INCROM $ee88, $ef96 @@ -5261,75 +5261,75 @@ Preload_Clerk9: ; ef96 (3:6f96) Script_Clerk9: ; f025 (3:7025) start_script - run_script ScriptCommand_JumpIfFlagZero1 + run_command ScriptCommand_JumpIfFlagZero1 db EVENT_FLAG_3F dw .ows_f066 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $07 dw .ows_f069 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $03 dw .ows_f06f - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $02 dw .ows_f072 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $01 dw .ows_f06c - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $07 dw .ows_f069 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $03 dw .ows_f06f - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $02 dw .ows_f072 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $01 dw .ows_f06c - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $07 dw .ows_f069 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $03 dw .ows_f06f - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $02 dw .ows_f072 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $01 dw .ows_f06c .ows_f066 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050a .ows_f069 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050b .ows_f06c - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050c .ows_f06f - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050d .ows_f072 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050e Preload_ChallengeHallNPCs2: ; f075 (3:7075) @@ -5359,32 +5359,32 @@ ChallengeHallLobbyLoadMap: ; f088 (3:7088) Script_Pappy3: ; f09c (3:709c) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text050f Script_Gal4: ; f0a0 (3:70a0) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0510 Script_Champ: ; f0a4 (3:70a4) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0511 Script_Hood2: ; f0a8 (3:70a8) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0512 Script_Lass5: ; f0ac (3:70ac) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0513 Script_Chap5: ; f0b0 (3:70b0) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0514 Preload_ChallengeHallLobbyRonald1: ; f0b4 (3:70b4) @@ -5504,7 +5504,7 @@ ChallengeHallLoadMap: ; f258 (3:7258) Script_Clerk13: ; f26c (3:726c) start_script - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0525 Preload_Guide: ; f270 (3:7270) @@ -5522,193 +5522,193 @@ Preload_Guide: ; f270 (3:7270) Script_Guide: ; f283 (3:7283) start_script - run_script ScriptCommand_JumpIfFlagZero2 + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_FLAG_42 dw .ows_f28b - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0526 .ows_f28b - run_script ScriptCommand_JumpIfFlagZero1 + run_command ScriptCommand_JumpIfFlagZero1 db $3f dw .ows_f292 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0527 .ows_f292 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0528 Script_Clerk12: ; f295 (3:7295) start_script - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $03 dw .ows_f2c4 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_41 db $02 dw .ows_f2c1 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $03 dw .ows_f2c4 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_40 db $02 dw .ows_f2c1 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $03 dw .ows_f2c4 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_3F db $02 dw .ows_f2c1 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f2cd - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f2d3 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f2c7 .ows_f2c1 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0529 .ows_f2c4 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text052a .ows_f2c7 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text052b - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f2d6 .ows_f2cd - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text052c - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f2d6 .ows_f2d3 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text052d .ows_f2d6 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text052e - run_script ScriptCommand_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text052f dw .ows_f2e1 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text0530 .ows_f2e1 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_59 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0531 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f349 - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db 8 db 18 dw .ows_f2fa - run_script ScriptCommand_JumpIfPlayerCoordMatches + run_command ScriptCommand_JumpIfPlayerCoordMatches db 12 db 18 dw .ows_f302 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $02 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f307 .ows_f2fa - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db EAST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db EAST db $02 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f307 .ows_f302 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db WEST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $02 .ows_f307 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db NORTH - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_FLAG_43 dw .ows_f33a - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_43 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db NORTH db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db EAST - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 30 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db EAST - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 30 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 .ows_f33a - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db EAST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db EAST db $01 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f34e - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db $4a dw Script_f353 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret ; f349 @@ -5733,38 +5733,38 @@ Script_HostStubbed: ; f352 (3:7352) Script_f353: ; f353 (3:7353) start_script - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script Func_d16b + run_command Func_d16b db $00 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0532 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37f - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0533 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f388 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0534 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f38e - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0535 - run_script Func_cd4f + run_command Func_cd4f db $04 db $00 db $00 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully NPCMovement_f37d: ; f37d (3:737d) db EAST | NO_MOVE @@ -5805,115 +5805,115 @@ NPCMovement_f390: ; f390 (3:7390) LostAtChallengeHall: ; f392 (3:7392) start_script - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw ScriptJump_f410 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $03 dw ScriptJump_f410.ows_f41a - run_script Func_d16b + run_command Func_d16b db $00 - run_script Func_d16b + run_command Func_d16b db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0536 .ows_f3ae - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f38b - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0537 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f38e - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f3ce - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f3d9 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_3F db $03 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_48 db $03 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_51 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f3e2 .ows_f3ce - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_40 db $03 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_49 db $03 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_55 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f3e2 .ows_f3d9 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_41 db $03 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_4A db $03 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f3e2 .ows_f3e2 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_CLERK12 dw Script_f3e9 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret Script_f3e9: ; f3e9 (3:73e9) start_script - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f40a - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db WEST - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db WEST db $01 - run_script ScriptCommand_SetPlayerDirection + run_command ScriptCommand_SetPlayerDirection db SOUTH - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MovePlayer + run_command ScriptCommand_MovePlayer db SOUTH db $01 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f40d - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully NPCMovement_f40a: ; f40a (3:740a) db WEST @@ -5926,159 +5926,159 @@ NPCMovement_f40d: ; f40d (3:740d) db $ff ScriptJump_f410: ; f410 (4:7410) - run_script Func_d16b + run_command Func_d16b db $00 - run_script Func_d16b + run_command Func_d16b db $01 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0538 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw LostAtChallengeHall.ows_f3ae .ows_f41a - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0539 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_RONALD1 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f42e - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text053a tx Text053b .ows_f42e - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_HOST - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw LostAtChallengeHall.ows_f3ae Script_f433: ; f433 (3:7433) start_script - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw WonAtChallengeHall.ows_f4a4 WonAtChallengeHall; f441 (3:7441) start_script - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37d - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 20 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f390 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $03 dw ScriptJump_f4db - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw .ows_f456 .ows_f456 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text053c tx Text053d - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37f - run_script Func_d16b + run_command Func_d16b db $00 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text053e - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f4c8 - run_script Func_cdd8 - run_script ScriptCommand_PrintTextString + run_command Func_cdd8 + run_command ScriptCommand_PrintTextString tx Text053f - run_script ScriptCommand_CloseTextBox - run_script Func_d195 - run_script Func_cdf5 + run_command ScriptCommand_CloseTextBox + run_command Func_d195 + run_command Func_cdf5 db $14 db $14 - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f4d0 - run_script Func_d16b + run_command Func_d16b db $00 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0540 tx Text0541 - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f383 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw .ows_f4a4 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f4a1 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_SetDialogName db $02 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0542 tx Text0543 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_HOST - run_script ScriptCommand_CloseTextBox + run_command ScriptCommand_CloseTextBox .ows_f4a1 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0544 .ows_f4a4 - run_script ScriptCommand_ZeroOutFlagValue + run_command ScriptCommand_ZeroOutFlagValue db EVENT_FLAG_47 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0545 - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes tx Text0546 dw .ows_f4bd - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_45 db $02 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text0547 tx Text0548 - run_script Func_cd4f + run_command Func_cd4f db $04 db $00 db $00 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_f4bd - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0549 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MaxOutFlagValue db EVENT_FLAG_47 - run_script Func_d1ad - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_Jump + run_command Func_d1ad + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_Jump dw .ows_f4a4 NPCMovement_f4c8: ; f4c8 (3:74c8) @@ -6108,110 +6108,110 @@ NPCMovement_f4d8: ; f4d8 (3:74d8) db $ff ScriptJump_f4db: ; f4db (3:74db) - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text054a - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f37f - run_script Func_d16b + run_command Func_d16b db $00 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text054b - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f513 - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db $02 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text054c tx Text054d - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f4d8 - run_script ScriptCommand_DoFrames + run_command ScriptCommand_DoFrames db 40 - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f34c - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $01 dw NO_JUMP - run_script ScriptCommand_PrintVariableText + run_command ScriptCommand_PrintVariableText tx Text054e tx Text054f - run_script ScriptCommand_SetDialogName + run_command ScriptCommand_SetDialogName db NPC_HOST - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f4c9 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f516 .ows_f513 - run_script ScriptCommand_MoveWramNPC + run_command ScriptCommand_MoveWramNPC dw NPCMovement_f4c8 .ows_f516 - run_script Func_cdd8 - run_script ScriptCommand_MoveActiveNPC + run_command Func_cdd8 + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f383 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0550 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_MoveActiveNPC + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC dw NPCMovement_f38b - run_script Func_d1b3 - run_script ScriptCommand_PrintTextString + run_command Func_d1b3 + run_command ScriptCommand_PrintTextString tx Text0551 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db $00 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db $00 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0552 - run_script ScriptCommand_CloseTextBox - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $02 dw .ows_f540 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_44 db $03 dw .ows_f549 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_3F db $02 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_48 db $02 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f552 .ows_f540 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_40 db $02 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_49 db $02 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f552 .ows_f549 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_41 db $02 - run_script ScriptCommand_SetFlagValue + run_command ScriptCommand_SetFlagValue db EVENT_FLAG_4A db $02 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_f552 .ows_f552 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db NPC_CLERK12 dw Script_f3e9 - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret ; f559 @@ -6286,13 +6286,13 @@ Func_f602: ; f602 (3:7602) Script_f631: ; f631 (3:7631) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0508 - run_script ScriptCommand_CloseAdvancedTextBox - run_script ScriptCommand_SetNextNPCandScript + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript db $02 dw $763c - run_script ScriptCommand_EndScriptLoop1 + run_command ScriptCommand_EndScriptLoop1 ret ; 0xf63c @@ -6309,59 +6309,59 @@ HallOfHonorLoadMap: ; fbdb (3:7bdb) Script_fbf1: ; fbf1 (3:7bf1) start_script - run_script ScriptCommand_JumpIfFlagNonzero2 + run_command ScriptCommand_JumpIfFlagNonzero2 db EVENT_RECEIVED_LEGENDARY_CARD dw .ows_fc10 - run_script ScriptCommand_MaxOutFlagValue + run_command ScriptCommand_MaxOutFlagValue db EVENT_RECEIVED_LEGENDARY_CARD - run_script Func_ccdc + run_command Func_ccdc tx Text05b8 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db ZAPDOS3 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db MOLTRES2 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db ARTICUNO2 - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db DRAGONITE1 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db $ff .ows_fc05 - run_script Func_d38f + run_command Func_d38f db $00 - run_script Func_ccdc + run_command Func_ccdc tx Text05b9 .ows_fc0a - run_script Func_d38f + run_command Func_d38f db $01 - run_script Func_d396 + run_command Func_d396 db $01 - run_script Func_d3b9 - run_script ScriptCommand_QuitScriptFully + run_command Func_d3b9 + run_command ScriptCommand_QuitScriptFully .ows_fc10 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_71 db $0f dw .ows_fc20 - run_script Func_d209 - run_script Func_ccdc + run_command Func_d209 + run_command Func_ccdc tx Text05ba - run_script ScriptCommand_GiveCard + run_command ScriptCommand_GiveCard db $00 - run_script ScriptCommand_ShowCardReceivedScreen + run_command ScriptCommand_ShowCardReceivedScreen db $00 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_fc05 .ows_fc20 - run_script Func_ccdc + run_command Func_ccdc tx Text05bb - run_script Func_d38f + run_command Func_d38f db $00 - run_script Func_ccdc + run_command Func_ccdc tx Text05bc - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw .ows_fc0a Func_fc2b: ; fc2b (3:7c2b) @@ -6391,17 +6391,17 @@ PointerTable_fc4c: ; fc4c (3:7c4c) Script_fc52: ; fc52 (3:7c52) start_script - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06c8 - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes dw $0000 dw .ows_fc5e - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06c9 .ows_fc5e - run_script Func_cd76 - run_script ScriptCommand_QuitScriptFully + run_command Func_cd76 + run_command ScriptCommand_QuitScriptFully Unknown_fc60: ; fc60 (3:7c60) INCROM $fc60, $fc64 @@ -6430,41 +6430,41 @@ Func_fc7a: ; fc7a (3:7c7a) set_flag_value EVENT_FLAG_74 start_script - run_script ScriptCommand_JumpIfFlagNotEqual + run_command ScriptCommand_JumpIfFlagNotEqual db EVENT_FLAG_74 db $02 dw Func_fcad.ows_fcd5 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06cd - run_script Func_d39d + run_command Func_d39d db $00 - run_script ScriptCommand_JumpIfFlagNotLessThan + run_command ScriptCommand_JumpIfFlagNotLessThan db EVENT_FLAG_72 db $04 dw Func_fc7a.ows_fcaa - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06ce - run_script ScriptCommand_AskQuestionJumpDefaultYes + run_command ScriptCommand_AskQuestionJumpDefaultYes tx Text06cf dw .ows_fca0 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06d0 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw Func_fc7a.ows_fcaa .ows_fca0 - run_script Func_d396 + run_command Func_d396 db $00 - run_script ScriptCommand_PlaySFX + run_command ScriptCommand_PlaySFX db $56 - run_script Func_ccdc + run_command Func_ccdc tx Text06d1 - run_script Func_d39d + run_command Func_d39d db $01 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully .ows_fcaa - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06d2 Func_fcad: ; fcad (3:7cad) @@ -6473,47 +6473,47 @@ Func_fcad: ; fcad (3:7cad) set_flag_value EVENT_FLAG_72 start_script - run_script ScriptCommand_PlaySFX + run_command ScriptCommand_PlaySFX db $56 - run_script Func_d396 + run_command Func_d396 db $00 - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $00 dw .ows_fccc - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $02 dw .ows_fccf - run_script ScriptCommand_JumpIfFlagEqual + run_command ScriptCommand_JumpIfFlagEqual db EVENT_FLAG_72 db $03 dw .ows_fcd2 - run_script ScriptCommand_Jump + run_command ScriptCommand_Jump dw Func_fc7a.ows_fcaa .ows_fccc - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06d3 .ows_fccf - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06d4 .ows_fcd2 - run_script ScriptCommand_PrintTextQuitFully + run_command ScriptCommand_PrintTextQuitFully tx Text06d5 .ows_fcd5 - run_script ScriptCommand_MoveArbitraryNPC + run_command ScriptCommand_MoveArbitraryNPC db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce1 - run_script ScriptCommand_PrintTextString + run_command ScriptCommand_PrintTextString tx Text06d6 - run_script ScriptCommand_MoveArbitraryNPC + run_command ScriptCommand_MoveArbitraryNPC db NPC_GIFT_CENTER_CLERK dw NPCMovement_fce3 - run_script ScriptCommand_QuitScriptFully + run_command ScriptCommand_QuitScriptFully NPCMovement_fce1: ; fce1 (3:7ce1) db SOUTH | NO_MOVE diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index 0c24463..bd1a58f 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -1,6 +1,6 @@ start_script EQUS "rst $20" -run_script: MACRO +run_command: MACRO db \1_index ENDM -- cgit v1.2.3