diff options
author | Andrew Martinek <andrewrmartinek@gmail.com> | 2016-07-29 15:58:18 -0400 |
---|---|---|
committer | Andrew Martinek <andrewrmartinek@gmail.com> | 2016-07-29 15:58:18 -0400 |
commit | 30a8cb35cf3ace29226f1c268db0d448cd23751d (patch) | |
tree | 2948bafe0a8ee9f4edad001084985b612622a9fd /src | |
parent | 8bfb38d813af48ed872443e90caaa3b32acca844 (diff) |
Began Disassembling Scripting system and AI.
Diffstat (limited to 'src')
-rwxr-xr-x | src/constants.asm | 5 | ||||
-rwxr-xr-x | src/constants/booster_constants.asm | 41 | ||||
-rw-r--r-- | src/constants/card_data_constants.asm | 12 | ||||
-rw-r--r-- | src/constants/duel_constants.asm | 3 | ||||
-rwxr-xr-x | src/constants/duelist_constants.asm | 41 | ||||
-rwxr-xr-x | src/constants/npc_constants.asm | 44 | ||||
-rwxr-xr-x | src/constants/overworld_script_constants.asm | 213 | ||||
-rwxr-xr-x | src/data/map_scripts.asm | 4 | ||||
-rwxr-xr-x | src/data/unknownNPCData.asm | 22 | ||||
-rwxr-xr-x | src/engine/bank1.asm | 246 | ||||
-rwxr-xr-x | src/engine/bank1c.asm | 4 | ||||
-rwxr-xr-x | src/engine/bank20.asm | 124 | ||||
-rwxr-xr-x | src/engine/bank3.asm | 416 | ||||
-rwxr-xr-x | src/engine/bank4.asm | 49 | ||||
-rwxr-xr-x | src/engine/bank5.asm | 323 | ||||
-rwxr-xr-x | src/engine/bank7.asm | 1 | ||||
-rwxr-xr-x | src/engine/bank8.asm | 132 | ||||
-rwxr-xr-x | src/engine/boosters.asm | 184 | ||||
-rwxr-xr-x | src/engine/home.asm | 109 | ||||
-rwxr-xr-x | src/macros.asm | 18 | ||||
-rwxr-xr-x | src/main.asm | 4 | ||||
-rwxr-xr-x | src/wram.asm | 15 |
22 files changed, 1590 insertions, 420 deletions
diff --git a/src/constants.asm b/src/constants.asm index fb199f6..392c8ca 100755 --- a/src/constants.asm +++ b/src/constants.asm @@ -2,11 +2,12 @@ INCLUDE "constants/map_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/text_constants.asm" INCLUDE "constants/duel_constants.asm" -INCLUDE "constants/duelist_constants.asm" +INCLUDE "constants/npc_constants.asm" INCLUDE "constants/card_constants.asm" INCLUDE "constants/deck_constants.asm" INCLUDE "constants/card_data_constants.asm" INCLUDE "constants/misc_constants.asm" INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/sgb_constants.asm" -INCLUDE "constants/overworld_script_constants.asm"
\ No newline at end of file +INCLUDE "constants/overworld_script_constants.asm" +INCLUDE "constants/booster_constants.asm" diff --git a/src/constants/booster_constants.asm b/src/constants/booster_constants.asm new file mode 100755 index 0000000..163b5cf --- /dev/null +++ b/src/constants/booster_constants.asm @@ -0,0 +1,41 @@ +BOOSTER_CARD_TYPE_GRASS EQU $00
+BOOSTER_CARD_TYPE_FIRE EQU $01
+BOOSTER_CARD_TYPE_LIGHTNING EQU $03
+BOOSTER_CARD_TYPE_WATER EQU $02
+BOOSTER_CARD_TYPE_FIGHTING EQU $04
+BOOSTER_CARD_TYPE_PSYCHIC EQU $05
+BOOSTER_CARD_TYPE_COLORLESS EQU $06
+BOOSTER_CARD_TYPE_TRAINER EQU $07
+BOOSTER_CARD_TYPE_ENERGY EQU $08
+BOOSTER_CARD_TYPE_AMOUNT EQU $09
+
+BOOSTER_ColoNeutral EQU $00
+BOOSTER_ColoGrass EQU $01
+BOOSTER_ColoFire EQU $02
+BOOSTER_ColoWater EQU $03
+BOOSTER_ColoLightning EQU $04
+BOOSTER_ColoFighting EQU $05
+BOOSTER_ColoTrainer EQU $06
+BOOSTER_EvoNeutral EQU $07
+BOOSTER_EvoGrass EQU $08
+BOOSTER_EvoNeutralFireEnergy EQU $09
+BOOSTER_EvoWater EQU $0a
+BOOSTER_EvoFighting EQU $0b
+BOOSTER_EvoPsychic EQU $0c
+BOOSTER_EvoTrainer EQU $0d
+BOOSTER_MysteryNeutral EQU $0e
+BOOSTER_MysteryGrassColorless EQU $0f
+BOOSTER_MysteryWaterColorless EQU $10
+BOOSTER_LightningColorless EQU $11
+BOOSTER_MysteryFightingColorless EQU $12
+BOOSTER_MysteryTrainerColorless EQU $13
+BOOSTER_LabTrainerLessFighting EQU $14
+BOOSTER_LabGrass EQU $15
+BOOSTER_LabWater EQU $16
+BOOSTER_LabPsychic EQU $17
+BOOSTER_LabTrainer EQU $18
+BOOSTER_EnergyLightningFire EQU $19
+BOOSTER_EnergyWaterFighting EQU $1a
+BOOSTER_EnergyGrassPsychic EQU $1b
+BOOSTER_RandomEnergies EQU $1c
+NO_BOOSTER EQU $ff
diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 8ee2ed3..637eb90 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -102,15 +102,3 @@ FLAG_3_BIT_1 EQU %00000010 UNABLE_RETREAT EQU $64 CARD_COLLECTION_SIZE EQU $100 - -;----BOOSTER CARD TYPES---- -BOOSTER_CARD_TYPE_GRASS EQU $00 -BOOSTER_CARD_TYPE_FIRE EQU $01 -BOOSTER_CARD_TYPE_LIGHTNING EQU $03 -BOOSTER_CARD_TYPE_WATER EQU $02 -BOOSTER_CARD_TYPE_FIGHTING EQU $04 -BOOSTER_CARD_TYPE_PSYCHIC EQU $05 -BOOSTER_CARD_TYPE_COLORLESS EQU $06 -BOOSTER_CARD_TYPE_TRAINER EQU $07 -BOOSTER_CARD_TYPE_ENERGY EQU $08 -BOOSTER_CARD_TYPE_AMOUNT EQU $09 diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 0411888..15e4662 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -42,6 +42,9 @@ CARD_LOCATION_BENCH_3 EQU $13 CARD_LOCATION_BENCH_4 EQU $14 CARD_LOCATION_BENCH_5 EQU $15 +;;; constant values +DUEL_MAX_POKEMON_IN_PLAY EQU $06 + ;;; status conditions ; two statuses can be combined if they are identified by a different nybble NO_STATUS EQU $00 diff --git a/src/constants/duelist_constants.asm b/src/constants/duelist_constants.asm deleted file mode 100755 index 2fbb190..0000000 --- a/src/constants/duelist_constants.asm +++ /dev/null @@ -1,41 +0,0 @@ -PLAYER EQU $01 -RONALD EQU $02 -SAM EQU $03 -IMAKUNI EQU $04 -NIKKI EQU $05 -RICK EQU $06 -KEN EQU $07 -AMY EQU $08 -ISAAC EQU $09 -MITCH EQU $0A -GENE EQU $0B -MURRAY EQU $0C -COURTNEY EQU $0D -STEVE EQU $0E -JACK EQU $0F -ROD EQU $10 -JOSEPH EQU $11 -DAVID EQU $12 -ERIK EQU $13 -JOHN EQU $14 -ADAM EQU $15 -JONATHAN EQU $16 -JOSHUA EQU $17 -NICHOLAS EQU $18 -BRANDON EQU $19 -MATTHEW EQU $1A -RYAN EQU $1B -ANDREW EQU $1C -CHRIS EQU $1D -MICHAEL EQU $1E -DANIEL EQU $1F -ROBERT EQU $20 -BRITTANY EQU $21 -KRISTIN EQU $22 -HEATHER EQU $23 -SARA EQU $24 -AMANDA EQU $25 -JENNIFER EQU $26 -JESSICA EQU $27 -STEPHANIE EQU $28 -AARON EQU $29 diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm new file mode 100755 index 0000000..af412d6 --- /dev/null +++ b/src/constants/npc_constants.asm @@ -0,0 +1,44 @@ +PLAYER_PIC EQU $01 +RONALD_PIC EQU $02 +SAM_PIC EQU $03 +IMAKUNI_PIC EQU $04 +NIKKI_PIC EQU $05 +RICK_PIC EQU $06 +KEN_PIC EQU $07 +AMY_PIC EQU $08 +ISAAC_PIC EQU $09 +MITCH_PIC EQU $0A +GENE_PIC EQU $0B +MURRAY_PIC EQU $0C +COURTNEY_PIC EQU $0D +STEVE_PIC EQU $0E +JACK_PIC EQU $0F +ROD_PIC EQU $10 +JOSEPH_PIC EQU $11 +DAVID_PIC EQU $12 +ERIK_PIC EQU $13 +JOHN_PIC EQU $14 +ADAM_PIC EQU $15 +JONATHAN_PIC EQU $16 +JOSHUA_PIC EQU $17 +NICHOLAS_PIC EQU $18 +BRANDON_PIC EQU $19 +MATTHEW_PIC EQU $1A +RYAN_PIC EQU $1B +ANDREW_PIC EQU $1C +CHRIS_PIC EQU $1D +MICHAEL_PIC EQU $1E +DANIEL_PIC EQU $1F +ROBERT_PIC EQU $20 +BRITTANY_PIC EQU $21 +KRISTIN_PIC EQU $22 +HEATHER_PIC EQU $23 +SARA_PIC EQU $24 +AMANDA_PIC EQU $25 +JENNIFER_PIC EQU $26 +JESSICA_PIC EQU $27 +STEPHANIE_PIC EQU $28 +AARON_PIC EQU $29 + +SARA EQU $1f +AMANDA EQU $20
\ No newline at end of file diff --git a/src/constants/overworld_script_constants.asm b/src/constants/overworld_script_constants.asm index 2306c38..ef76827 100755 --- a/src/constants/overworld_script_constants.asm +++ b/src/constants/overworld_script_constants.asm @@ -1,106 +1,111 @@ start_script EQUS "rst $20" -Func_ccbe_0 EQU $00 -Func_ccc6_index EQU $01 -Func_ccd4_index EQU $02 -Func_ccdc_index EQU $03 -Func_cce9_index EQU $04 -Func_cd01_index EQU $05 -Func_cd83_index EQU $06 -Func_cda8_index EQU $07 -Func_cdb9_index EQU $08 -Func_cdcb_index EQU $09 -Func_ce26_index EQU $0a -Func_ce84_index EQU $0b -Func_ce8a_index EQU $0c -Func_cf0c_index EQU $0d -Func_cf12_index EQU $0e -Func_cf3f_index EQU $0f -Func_cf4c_index EQU $10 -Func_cf53_index EQU $11 -Func_cf7b_index EQU $12 -Func_cf2d_index EQU $13 -Func_cf96_index EQU $14 -Func_cfc6_index EQU $15 -Func_cfd4_index EQU $16 -Func_d00b_index EQU $17 -Func_d025_index EQU $18 -Func_d032_index EQU $19 -Func_d03f_index EQU $1a -Func_d049_index EQU $1b -Func_d04f_index EQU $1c -Func_d055_index EQU $1d -OWScript_MovePlayer_index EQU $1e -Func_cee2_index EQU $1f -Func_d080_index EQU $20 -Func_d088_index EQU $21 -Func_d095_index EQU $22 -Func_d0be_index EQU $23 -Func_d0ce_index EQU $24 -Func_d0d9_index EQU $25 -Func_d0f2_index EQU $26 -Func_ce4a_index EQU $27 -Func_ceba_index EQU $28 -Func_d103_index EQU $29 -Func_d125_index EQU $2a -Func_d135_index EQU $2b -Func_d16b_index EQU $2c -Func_cd4f_index EQU $2d -Func_cd94_index EQU $2e -Func_ce52_index EQU $2f -Func_cdd8_index EQU $30 -Func_cdf5_index EQU $31 -Func_d195_index EQU $32 -Func_d1ad_index EQU $33 -Func_d1b3_index EQU $34 -Func_cccc_index EQU $35 -Func_d244_index EQU $36 -Func_d24c_index EQU $37 -DeckMachine_d336_index EQU $38 -Func_d271_index EQU $39 -Func_d36d_index EQU $3a -Func_ce6f_index EQU $3b -Func_d209_index EQU $3c -Func_d38f_index EQU $3d -Func_d396_index EQU $3e -Func_cd76_index EQU $3f -Func_d39d_index EQU $40 -Func_d3b9_index EQU $41 -Func_d3c9_index EQU $42 -Func_d3d1_index EQU $43 -Func_d3d4_index EQU $44 -Func_d3e0_index EQU $45 -Func_d3fe_index EQU $46 -Func_d408_index EQU $47 -Func_d40f_index EQU $48 -Func_d416_index EQU $49 -Func_d423_index EQU $4a -Func_d429_index EQU $4b -Func_d41d_index EQU $4c -Func_d42f_index EQU $4d -Func_d435_index EQU $4e -Func_cce4_index EQU $4f -Func_d2f6_index EQU $50 -Func_d317_index EQU $51 -Func_d43d_index EQU $52 -Func_ccbe_53 EQU $53 -Func_ccbe_54 EQU $54 -Func_ccbe_55 EQU $55 -Func_ccbe_56 EQU $56 -Func_ccbe_57 EQU $57 -Func_d44a_index EQU $58 -Func_d460_index EQU $59 -Func_d47b_index EQU $5a -Func_d484_index EQU $5b -Func_d49e_index EQU $5c -Func_d4a6_index EQU $5d -Func_d4ae_index EQU $5e -Func_d4bc_index EQU $5f -Func_d4c3_index EQU $60 -Func_d4ca_index EQU $61 -Func_d4df_index EQU $62 -Func_d452_index EQU $63 -Func_ccbe_64 EQU $64 -Func_ccbe_65 EQU $65 -Func_ccbe_66 EQU $66 -Func_ccbe_67 EQU $67
\ No newline at end of file +OWScript_EndScriptLoop_0 EQU $00 +OWScript_CloseTextBox_index EQU $01 +OWScript_PrintTextString_index EQU $02 +Func_ccdc_index EQU $03 +OWScript_AskQuestionJump_index EQU $04 +OWScript_StartBattle_index EQU $05 +Func_cd83_index EQU $06 +Func_cda8_index EQU $07 +OWScript_PrintTextCloseBox_index EQU $08 +Func_cdcb_index EQU $09 +Func_ce26_index EQU $0a +Func_ce84_index EQU $0b +OWScript_GiveBoosterPacks_index EQU $0c +Func_cf0c_index EQU $0d +Func_cf12_index EQU $0e +Func_cf3f_index EQU $0f +Func_cf4c_index EQU $10 +Func_cf53_index EQU $11 +Func_cf7b_index EQU $12 +Func_cf2d_index EQU $13 +Func_cf96_index EQU $14 +Func_cfc6_index EQU $15 +Func_cfd4_index EQU $16 +Func_d00b_index EQU $17 +Func_d025_index EQU $18 +Func_d032_index EQU $19 +Func_d03f_index EQU $1a +OWScript_ScriptJump_index EQU $1b +Func_d04f_index EQU $1c +Func_d055_index EQU $1d +OWScript_MovePlayer_index EQU $1e +Func_cee2_index EQU $1f +Func_d080_index EQU $20 +Func_d088_index EQU $21 +Func_d095_index EQU $22 +Func_d0be_index EQU $23 +Func_d0ce_index EQU $24 +Func_d0d9_index EQU $25 +Func_d0f2_index EQU $26 +Func_ce4a_index EQU $27 +Func_ceba_index EQU $28 +Func_d103_index EQU $29 +Func_d125_index EQU $2a +Func_d135_index EQU $2b +Func_d16b_index EQU $2c +Func_cd4f_index EQU $2d +Func_cd94_index EQU $2e +Func_ce52_index EQU $2f +Func_cdd8_index EQU $30 +Func_cdf5_index EQU $31 +Func_d195_index EQU $32 +Func_d1ad_index EQU $33 +Func_d1b3_index EQU $34 +OWScript_EndScriptCloseText_index EQU $35 +Func_d244_index EQU $36 +Func_d24c_index EQU $37 +DeckMachine_d336_index EQU $38 +Func_d271_index EQU $39 +Func_d36d_index EQU $3a +Func_ce6f_index EQU $3b +Func_d209_index EQU $3c +Func_d38f_index EQU $3d +Func_d396_index EQU $3e +Func_cd76_index EQU $3f +Func_d39d_index EQU $40 +Func_d3b9_index EQU $41 +Func_d3c9_index EQU $42 +Func_d3d1_index EQU $43 +Func_d3d4_index EQU $44 +Func_d3e0_index EQU $45 +Func_d3fe_index EQU $46 +Func_d408_index EQU $47 +Func_d40f_index EQU $48 +Func_d416_index EQU $49 +Func_d423_index EQU $4a +Func_d429_index EQU $4b +Func_d41d_index EQU $4c +Func_d42f_index EQU $4d +Func_d435_index EQU $4e +Func_cce4_index EQU $4f +Func_d2f6_index EQU $50 +Func_d317_index EQU $51 +Func_d43d_index EQU $52 +OWScript_EndScriptLoop_53 EQU $53 +OWScript_EndScriptLoop_54 EQU $54 +OWScript_EndScriptLoop_55 EQU $55 +OWScript_EndScriptLoop_56 EQU $56 +OWScript_EndScriptLoop_57 EQU $57 +OWScript_CustomModifyEventFlags_index EQU $58 +Func_d460_index EQU $59 +OWScript_JumpIfFlagSet_index EQU $5a +Func_d484_index EQU $5b +Func_d49e_index EQU $5c +Func_d4a6_index EQU $5d +Func_d4ae_index EQU $5e +OWScript_SetEventFlags_index EQU $5f +Func_d4c3_index EQU $60 +Func_d4ca_index EQU $61 +OWScript_JumpIfFlagNotSet_index EQU $62 +Func_d452_index EQU $63 +OWScript_EndScriptLoop_64 EQU $64 +OWScript_EndScriptLoop_65 EQU $65 +OWScript_EndScriptLoop_66 EQU $66 +OWScript_EndScriptLoop_67 EQU $67 + +; Script Flags +FLAG_BEAT_SARA EQU $15 +FLAG_BEAT_AMANDA EQU $16 + diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index b85eb6f..ae4e355 100755 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -138,8 +138,8 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $6157 - dw $613f + dw WaterClubAfterDuel + dw WaterClubMovePlayer dw $0000 ; LIGHTNING_CLUB_ENTRANCE diff --git a/src/data/unknownNPCData.asm b/src/data/unknownNPCData.asm index 6994cea..2786188 100755 --- a/src/data/unknownNPCData.asm +++ b/src/data/unknownNPCData.asm @@ -32,8 +32,8 @@ PointerTable_118f5: dw Data_11b3c
dw Data_11b49
dw Data_11b56
- dw Data_11b63
- dw Data_11b70
+ dw SaraData
+ dw AmandaData
dw Data_11b7d
dw Data_11b8a
dw Data_11b97
@@ -507,29 +507,29 @@ Data_11b56: db $11
db $03
db $16
-Data_11b63:
- db $1f
+SaraData:
+ db SARA ; trainer id
db $20
db $00
db $0e
db $00
- dw $6177 ; Pointer to NPC Data
+ dw OWSequence_Sara ; Pointer to NPC Data
db $bc
db $03
- db $24
+ db SARA_PIC ; battle profile picture
db $22
db $03
db $15
-Data_11b70:
- db $20
+AmandaData:
+ db AMANDA
db $20
db $00
db $16
db $00
- dw $619e ; Pointer to NPC Data
+ dw OWSequence_Amanda ; Pointer to NPC Data
db $bd
db $03
- db $25
+ db AMANDA_PIC
db $23
db $03
db $15
@@ -539,7 +539,7 @@ Data_11b7d: db $00
db $26
db $00
- dw $621c ; Pointer to NPC Data
+ dw OWSequence_Joshua ; Pointer to NPC Data
db $be
db $03
db $17
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index d9a5870..5f5451e 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -81,7 +81,7 @@ StartDuel: ; 409f (1:409f) call $70aa ld a, [wDuelTheme] call PlaySong - call $4b60 + call Func_4b60 ret c ; the loop returns here after every turn switch @@ -90,7 +90,7 @@ StartDuel: ; 409f (1:409f) ld [wCurrentDuelMenuItem], a call HandleSwordsDanceOrFocusEnergySubstatus call $54c8 - call DrawCardFromDeck + call HandleTurn call Func_0f58 ld a, [wDuelFinished] or a @@ -212,7 +212,7 @@ StartDuel: ; 409f (1:409f) jr z, .asm_41f3 ld a, PLAYER_TURN ldh [hWhoseTurn], a - call $4b60 + call Func_4b60 jp $40ee .asm_41f3 @@ -226,14 +226,14 @@ StartDuel: ; 409f (1:409f) .asm_4201 ld a, h ldh [hWhoseTurn], a - call $4b60 + call Func_4b60 jp nc, $40ee ret ; 0x420b INCBIN "baserom.gbc",$420b,$4225 - $420b -DrawCardFromDeck: ; 4225 (1:4225) +HandleTurn: ; 4225 (1:4225) ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable ld [wcc0d], a @@ -928,7 +928,241 @@ CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) scf ret -INCBIN "baserom.gbc",$4933, $5aeb - $4933 +INCBIN "baserom.gbc",$4933, $4b60 - $4933 + +Func_4b60: ; 4b60 (1:4b60) + call $7107 + call SwapTurn + call $7107 + call SwapTurn + call $4e84 + call $4d97 + ld [$ffa0], a + call SwapTurn + call $4d97 + call SwapTurn + ld c, a + ld a, [$ffa0] + ld b, a + and c + jr nz, .asm_4bd0 + ld a, b + or c + jr z, .asm_4bb2 + ld a, b + or a + jr nz, .asm_4b9c +.asm_4b8c + call $4df3 + call $7107 + call $4e6e + call $4d97 + jr c, .asm_4b8c + jr .asm_4bd0 + +.asm_4b9c + call SwapTurn +.asm_4b9f + call $4df3 + call $7107 + call $4e6e + call $4d97 + jr c, .asm_4b9f + call SwapTurn + jr .asm_4bd0 + +.asm_4bb2 + ld hl, $006b + call DrawWideTextBox_WaitForInput + call $4e06 + call $7107 + call SwapTurn + call $4e06 + call $7107 + call SwapTurn + call $4dfc + jp Func_4b60 + +.asm_4bd0 + ld a, [$ff97] + push af + ld a, $c2 + ld [$ff97], a + call Func_4cd5 + call SwapTurn + call Func_4cd5 + call SwapTurn + jp c, $4c77 + call $311d + ld hl, $0072 + call DrawWideTextBox_WaitForInput + call Func_0f58 + ld a, [wcc08] + ld l, a + ld h, $0 + call Func_2ec4 + ld hl, $0073 + call DrawWideTextBox_PrintText + call EnableLCD + call $4c7c + call WaitForWideTextBoxInput + pop af + ld [$ff97], a + call $7133 + call SwapTurn + call $7133 + call SwapTurn + call Func_04a2 + ld a, $6 + call Func_2167 + ld hl, $0075 + call DrawWideTextBox_WaitForInput + ld a, [$ff97] + cp $c2 + jr nz, .asm_4c52 + ld de, wc590 + call PrintPlayerName + ld hl, $0000 + call Func_2ebb + ld hl, $0053 + ld de, $0074 + call TossCoin + jr c, .asm_4c4a + call SwapTurn + ld hl, $0054 + +.asm_4c4a + call DrawWideTextBox_WaitForInput + call Func_0f58 + or a + ret + +.asm_4c52 + ld de, wc590 + call PrintOpponentName + ld hl, $0000 + call Func_2ebb + ld hl, $0054 + ld de, $0074 + call TossCoin + jr c, .asm_4c6f + call SwapTurn + ld hl, $0053 + +.asm_4c6f + call DrawWideTextBox_WaitForInput + call Func_0f58 + or a + ret +; 0x4c77 + + +INCBIN "baserom.gbc",$4c77, $4cd5 - $4c77 + +; Select Basic Pokemon From Hand +Func_4cd5: ; 4cd5 (1:4cd5) + ld a, $f1 + call GetTurnDuelistVariable + cp $0 + jr z, .asm_4d15 + cp $1 + jr z, .asm_4cec + push af + push hl + call Func_2bc3 + pop hl + pop af + ld [hl], a + or a + ret + +.asm_4cec + ld hl, $0057 + call DrawWideTextBox_PrintText + call Func_0f58 + ld hl, wPlayerCardLocations + ld de, wOpponentCardLocations + ld c, $80 + call Func_0e63 + jr c, .asm_4d12 + ld c, $80 + call Func_0e63 + jr c, .asm_4d12 + ld a, $f1 + call GetTurnDuelistVariable + ld [hl], $1 + or a + ret + +.asm_4d12 + jp Func_0f35 + +.asm_4d15 + call Func_04a2 + ld a, $5 + call Func_2167 + ld hl, $0069 + call DrawWideTextBox_WaitForInput + ld a, $1 + call $51e7 +.asm_4d28 + xor a + ld hl, $006e + call $5502 + jr c, .asm_4d28 + ld a, [$ff98] + call LoadDeckCardToBuffer1 + ld a, $2 + call $51e7 + jr c, .asm_4d28 + ld a, [$ff98] + call $1485 + ld a, [$ff98] + ld hl, $0062 + call $4b31 + jr .asm_4d4c + +.asm_4d4c + call Func_04a2 + ld a, $4 + call Func_2167 + ld hl, $006d + call Func_2c73 + ld a, $3 + call $51e7 +.asm_4d5f + ld a, $1 + ld hl, $006f + call $5502 + jr c, .asm_4d8e + ld a, $ef + call GetTurnDuelistVariable + cp $6 + jr nc, .asm_4d86 + ld a, [$ff98] + call $1485 + ld a, [$ff98] + ld hl, $0061 + call $4b31 + ld a, $5 + call $51e7 + jr .asm_4d5f + +.asm_4d86 + ld hl, $00b2 + call DrawWideTextBox_WaitForInput + jr .asm_4d5f + +.asm_4d8e + ld a, $4 + call $51e7 + jr c, .asm_4d5f + or a + ret +; 0x4d97 + + +INCBIN "baserom.gbc",$4d97, $5aeb - $4d97 Func_5aeb: ; 5aeb (1:5aeb) INCBIN "baserom.gbc",$5aeb,$6785 - $5aeb diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 6d9d685..9abadde 100755 --- 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 Func_ca6c + farcall CheckIfEventFlagSet or a jr z, .asm_70013 ld b, $2 @@ -276,7 +276,7 @@ Func_70214: ; 70214 (1c:4214) ret nz ld hl, Unknown_7024a ld a, $10 - farcall Func_ca6c + farcall CheckIfEventFlagSet ld c, $8 .asm_70227 push bc diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 17f8afc..0142e93 100755 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -2,7 +2,129 @@ Func_80000: ; 80000 (20:4000) INCBIN "baserom.gbc",$80000,$80028 - $80000 Func_80028: ; 80028 (20:4028) -INCBIN "baserom.gbc",$80028,$8020f - $80028 + call Func_801f1 + ld bc, $0000 + call Func_80077 + farcallx $3, $49c7 + call $41a1 + farcallx $3, $43ee + ret +; 0x8003d + +INCBIN "baserom.gbc",$8003d,$80077 - $8003d + +Func_80077: ; 80077 (20:4077) + ld a, $1 + ld [$d292], a + jr .asm_80082 + + xor a + ld [$d292], a + +.asm_80082 + push hl + push bc + push de + call Func_04cf + ld hl, wd4c2 + ld [hl], e + inc hl + ld [hl], d + call $43b9 + ld a, [wd4c6] + ld [$d23d], a + ld de, $d23e + ld bc, $0006 + call Func_3bf5 + ld l, e + ld h, d + ld a, [hli] + ld [$d12f], a + ld a, [hli] + ld [$d130], a + ld a, [hli] + ld [$d23a], a + ld a, [hli] + ld [$d23b], a + ld a, [hli] + ld [$d23c], a + call $40bd + pop de + pop bc + pop hl + ret +; 0x800bd + +INCBIN "baserom.gbc",$800bd,$801a1 - $800bd + +Func_801a1: ; 801a1 (20:41a1) + push hl + push bc + push de + ld a, [$ff81] + push af + ld a, $1 + call BankswitchRAM + ld hl, $a000 + ld de, $9800 + ld c, $20 +.asm_801b4 + push bc + push hl + push de + ld b, $20 + call $06fc + ld a, [wConsole] + cp $2 + jr nz, .asm_801d6 + pop de + pop hl + push hl + push de + ld bc, $0400 + add hl, bc + call BankswitchVRAM_1 + ld b, $20 + call $06fc + call BankswitchVRAM_0 + +.asm_801d6 + pop hl + ld de, $0020 + add hl, de + ld e, l + ld d, h + pop hl + ld bc, $0020 + add hl, bc + pop bc + dec c + jr nz, .asm_801b4 + pop af + call BankswitchRAM + call DisableExtRAM + pop de + pop bc + pop hl + ret + +Func_801f1: ; 801f1 (20:41f1) + push hl + push bc + ld a, [$ff81] + push af + ld a, $1 + call BankswitchRAM + ld hl, $a000 + ld bc, $0800 + xor a + call $3c10 + pop af + call BankswitchRAM + call DisableExtRAM + pop bc + pop hl + ret Func_8020f: ; 8020f (20:420f) push bc diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm index 991fc92..82d8080 100755 --- a/src/engine/bank3.asm +++ b/src/engine/bank3.asm @@ -126,7 +126,8 @@ Func_c10a: ; c10a (3:410a) ld l, a jp [hl] -Func_c111: ; c111 (3:4111) +; closes dialogue window. seems to be for other things as well. +CloseDialogueBox: ; c111 (3:4111) ld a, [wd0c1] bit 0, a call nz, Func_c135 @@ -969,7 +970,7 @@ Func_c74d: ; c74d (3:474d) push bc push de call MainMenu_c75a - call Func_c111 + call CloseDialogueBox pop de pop bc pop hl @@ -1090,7 +1091,7 @@ PC_c7ea: ; c7ea (3:47ea) call DoFrameIfLCDEnabled text_hl TurnedPCOffText call Func_c891 - call Func_c111 + call CloseDialogueBox xor a ld [wd112], a call Func_39fc @@ -1307,7 +1308,7 @@ Func_c9c7: ; c9c7 (3:49c7) Func_c9cb: ; c9cb (3:49cb) push hl push bc - ld hl, $d3d2 + ld hl, wEventFlags ld bc, $0040 .asm_c9d3 xor a @@ -1409,10 +1410,10 @@ Func_ca0e: ; ca0e (3:4a0e) Func_ca69: ; ca69 (3:4a69) call Func_cab3 -Func_ca6c: ; ca6c (3:4a6c) +CheckIfEventFlagSet: ; ca6c (3:4a6c) push hl push bc - call Func_cb1d + call GetEventFlagMod ld c, [hl] ld a, [wd3d1] .asm_ca75 @@ -1433,10 +1434,12 @@ INCBIN "baserom.gbc",$ca84,$ca8f - $ca84 Func_ca8f: ; ca8f (3:4a8f) call Func_cab3 -Func_ca92: ; ca92 (3:4a92) + +; a - pointer on table for cb1d, c - set or reset control bit +ModifyEventFlags: ; ca92 (3:4a92) push hl push bc - call Func_cb1d + call GetEventFlagMod ld a, [wd3d1] .asm_ca9a bit 0, a @@ -1476,10 +1479,10 @@ Func_cab3: ; cab3 (3:4ab3) INCBIN "baserom.gbc",$cac2,$cac5 - $cac2 -Func_cac5: ; cac5 (3:4ac5) +SetEventFlags: ; cac5 (3:4ac5) push bc ld c, $ff - call $4a92 + call ModifyEventFlags pop bc ret ; 0xcacd @@ -1489,7 +1492,7 @@ INCBIN "baserom.gbc",$cacd,$cad0 - $cacd Func_cad0: ; cad0 (3:4ad0) push bc ld c, $0 - call Func_ca92 + call ModifyEventFlags pop bc ret @@ -1500,7 +1503,7 @@ Func_cad8: ; cad8 (3:4ad8) ld bc, $0008 .asm_cae0 ld a, [hli] - call Func_ca6c + call CheckIfEventFlagSet jr z, .asm_cae7 inc b @@ -1540,25 +1543,26 @@ Func_cad8: ; cad8 (3:4ad8) INCBIN "baserom.gbc",$cb15,$cb1d - $cb15 -Func_cb1d: ; cb1d (3:4b1d) +GetEventFlagMod: ; cb1d (3:4b1d) push bc ld c, a ld b, $0 sla c rl b - ld hl, Unknown_cb37 + ld hl, EventFlagMods add hl, bc ld a, [hli] ld c, a ld a, [hl] ld [wd3d1], a ld b, $0 - ld hl, $d3d2 + ld hl, wEventFlags add hl, bc pop bc ret -Unknown_cb37: ; cb37 (3:4b37) +; offset - bytes to set or reset +EventFlagMods: ; cb37 (3:4b37) INCBIN "baserom.gbc",$cb37,$cc32 - $cb37 Func_cc32: ; cc32 (3:4c32) @@ -1568,7 +1572,7 @@ Func_cc32: ; cc32 (3:4c32) inc hl ld d, [hl] pop hl - call $48ba + call Func_c8ba ret ; 0xcc3e @@ -1583,10 +1587,10 @@ RST20: ; cc42 (3:4c42) ld a, h ld [wOWScriptPointer+1], a xor a - ld [wd412], a + ld [wBreakOWScriptLoop], a .asm_cc4f call RunOverworldScript - ld a, [wd412] + ld a, [wBreakOWScriptLoop] ; if you break out, it jumps or a jr z, .asm_cc4f ld hl, wOWScriptPointer @@ -1617,7 +1621,6 @@ IncreaseOWScriptPointerBy7: ; cc74 (3:4c74) IncreaseOWScriptPointerBy3: ; cc78 (3:4c78) ld a, 3 -; AH! increases the RST20 pointer by a, given from the above ^ or supplied IncreaseOWScriptPointer: ; cc7a (3:4c7a) ld c, a ld a, [wOWScriptPointer] @@ -1628,7 +1631,7 @@ IncreaseOWScriptPointer: ; cc7a (3:4c7a) ld [wOWScriptPointer+1], a ret -Func_cc8b: ; cc8b (3:4c8b) +SetOWScriptPointer: ; cc8b (3:4c8b) ld hl, wOWScriptPointer ld [hl], c inc hl @@ -1638,17 +1641,17 @@ Func_cc8b: ; cc8b (3:4c8b) INCBIN "baserom.gbc",$cc92,$cc96 - $cc92 -Func_cc96: ; cc96 (3:4c96) +GetOWSArgs1AfterPointer: ; cc96 (3:4c96) ld a, $1 - jr Func_cca0 + jr GetOWSArgsAfterPointer -Func_cc9a: ; cc9a (3:4c9a) +GetOWSArgs2AfterPointer: ; cc9a (3:4c9a) ld a, $2 - jr Func_cca0 -Func_cc9e: ; cc9e (3:4c9e) + jr GetOWSArgsAfterPointer +GetOWSArgs3AfterPointer: ; cc9e (3:4c9e) ld a, $3 -Func_cca0: ; cca0 (3:4ca0) +GetOWSArgsAfterPointer: ; cca0 (3:4ca0) push hl ld l, a ld a, [wOWScriptPointer] @@ -1674,22 +1677,23 @@ Func_ccb9: ; ccb9 (3:4cb9) ld [$d415], a ret -Func_ccbe: ; ccbe (3:4cbe) +OWScript_EndScriptLoop: ; ccbe (3:4cbe) ld a, $01 - ld [wd412], a + ld [wBreakOWScriptLoop], a jp IncreaseOWScriptPointerBy1 -Func_ccc6: ; ccc6 (3:4cc6) - call Func_c111 +OWScript_CloseTextBox: ; ccc6 (3:4cc6) + call CloseDialogueBox jp IncreaseOWScriptPointerBy1 -Func_cccc: ; cccc (3:4ccc) - call Func_ccc6 - call Func_ccbe +OWScript_EndScriptCloseText: ; cccc (3:4ccc) + call OWScript_CloseTextBox + call OWScript_EndScriptLoop pop hl ret -Func_ccd4: ; ccd4 (3:4cd4) +;args: 2-Text String Index +OWScript_PrintTextString: ; ccd4 (3:4cd4) ld l, c ld h, b call Func_cc32 @@ -1704,22 +1708,25 @@ Func_ccdc: ; ccdc (3:4cdc) Func_cce4: ; cce4 (3:4ce4) ld a, $1 ld [wcd9a], a -Func_cce9: ; cce9 (3:4ce9) + +; Asks the player a question then jumps if they answer yes +OWScript_AskQuestionJump: ; cce9 (3:4ce9) ld l, c ld h, b call Func_c8ed ld a, [hCurrentMenuItem] ld [$d415], a jr c, .asm_ccfe - call Func_cc9e + call GetOWSArgs3AfterPointer jr z, .asm_ccfe - jp Func_cc8b + jp SetOWScriptPointer .asm_ccfe jp IncreaseOWScriptPointerBy5 -; this seems to be called when battles officially start. Might be a good way to find trainer data. -Func_cd01: ; cd01 (3:4d01) +; args - prize cards, deck index - 2, duel theme index +; 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 l, $0 @@ -1772,7 +1779,7 @@ Func_cd66: ; cd66 (3:4d66) ld [wcc18], a ld a, b ld [wcc19], a - call Func_cc9e + call GetOWSArgs3AfterPointer ld a, c ld [wDuelTheme], a ret @@ -1788,7 +1795,7 @@ Func_cd83: ; cd83 (3:4d83) ld a, [$d415] or a jr nz, .asm_cd8c - call Func_cc9e + call GetOWSArgs3AfterPointer .asm_cd8c ld l, c ld h, b @@ -1803,7 +1810,7 @@ Unknown_cd98: and $3 add a inc a - call Func_cca0 + call GetOWSArgsAfterPointer ld l, c ld h, b call Func_cc32 @@ -1813,20 +1820,20 @@ Func_cda8: ; cda8 (3:4da8) ld a, [$d415] or a jr nz, .asm_cdb1 - call Func_cc9e + call GetOWSArgs3AfterPointer .asm_cdb1 ld l, c ld h, b call Func_c891 jp IncreaseOWScriptPointerBy5 -Func_cdb9: ; cdb9 (3:4db9) +OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) ld l, c ld h, b call Func_cc32 - call Func_c111 + call CloseDialogueBox ld a, $1 - ld [wd412], a + ld [wBreakOWScriptLoop], a call IncreaseOWScriptPointerBy3 pop hl ret @@ -1925,7 +1932,7 @@ Func_ce6f: ; ce6f (3:4e6f) push af ld a, c push af - call Func_cc9a + call GetOWSArgs2AfterPointer push bc call IncreaseOWScriptPointerBy1 pop bc @@ -1936,7 +1943,8 @@ Func_ce84: ; ce84 (3:4e84) call Func_c135 jp IncreaseOWScriptPointerBy1 -Func_ce8a: ; ce8a (3:4e8a) +; args: booster pack index, booster pack index, boosterpack index +OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) xor a ld [wd117], a push bc @@ -1952,7 +1960,7 @@ Func_ce8a: ; ce8a (3:4e8a) cp $ff jr z, .asm_ceb4 farcall BoosterPack_1031b - call Func_cc9e + call GetOWSArgs3AfterPointer ld a, c cp $ff jr z, .asm_ceb4 @@ -2027,9 +2035,9 @@ asm_cf19 asm_cf1f call Func_ccb3 - call Func_cc9a + call GetOWSArgs2AfterPointer jr z, asm_cf2a - jp Func_cc8b + jp SetOWScriptPointer asm_cf2a jp IncreaseOWScriptPointerBy4 @@ -2085,9 +2093,9 @@ Func_cf67: ; cf67 (3:4f67) Func_cf6d: ; cf6d (3:4f6d) call Func_ccb3 - call Func_cc96 + call GetOWSArgs1AfterPointer jr z, .asm_cf78 - jp Func_cc8b + jp SetOWScriptPointer .asm_cf78 jp IncreaseOWScriptPointerBy3 @@ -2139,12 +2147,12 @@ Func_cf96: ; cf96 (3:4f96) ld a, c rlca add $3 - call Func_cca0 - jp Func_cc8b + call GetOWSArgsAfterPointer + jp SetOWScriptPointer Func_cfc0: ; cfc0 (3:4fc0) - call Func_cc96 - jp Func_cc8b + call GetOWSArgs1AfterPointer + jp SetOWScriptPointer Func_cfc6: ; cfc6 (3:4fc6) ld a, [wd3b6] @@ -2229,9 +2237,9 @@ Func_d03f: ; d03f (3:503f) call Func_1d91 jp IncreaseOWScriptPointerBy1 -Func_d049: ; d049 (3:5049) - call Func_cc96 - jp Func_cc8b +OWScript_ScriptJump: ; d049 (3:5049) + call GetOWSArgs1AfterPointer + jp SetOWScriptPointer Func_d04f: ; d04f (3:504f) call Func_cad8 @@ -2268,7 +2276,7 @@ Func_d080: ; d080 (3:5080) Func_d088: ; d088 (3:5088) ld a, c ld [wd3ab], a - call Func_cc9a + call GetOWSArgs2AfterPointer call Func_c926 jp IncreaseOWScriptPointerBy4 @@ -2276,7 +2284,7 @@ Func_d095: ; d095 (3:5095) ld a, [wd3b6] ld [wd3aa], a push bc - call Func_cc9e + call GetOWSArgs3AfterPointer ld a, [wd3b6] ld l, $5 call Func_39ad @@ -2487,7 +2495,7 @@ Func_d209: ; d209 (3:5209) ld hl, $5240 add hl, bc ld a, [hl] - call Func_cac5 + call SetEventFlags pop bc ld hl, $5234 ld a, c @@ -2783,25 +2791,25 @@ Func_d43d: ; d43d (3:543d) set 6, [hl] jp IncreaseOWScriptPointerBy1 -Func_d44a: ; d44a (3:544a) +OWScript_CustomModifyEventFlags: ; d44a (3:544a) ld a, c ld c, b - call Func_ca92 + call ModifyEventFlags jp IncreaseOWScriptPointerBy3 Func_d452: ; d452 (3:5452) ld a, c push af - call Func_ca6c + call CheckIfEventFlagSet inc a ld c, a pop af - call Func_ca92 + call ModifyEventFlags jp IncreaseOWScriptPointerBy2 Func_d460: ; d460 (3:5460) ld a, c - call Func_ca6c + call CheckIfEventFlagSet or a jr z, asm_d46d asm_d467 @@ -2810,16 +2818,16 @@ asm_d467 asm_d46d call Func_ccb3 - call Func_cc9a + call GetOWSArgs2AfterPointer jr z, .asm_d478 - jp Func_cc8b + jp SetOWScriptPointer .asm_d478 jp IncreaseOWScriptPointerBy4 -Func_d47b: ; d47b (3:547b) +OWScript_JumpIfFlagSet: ; d47b (3:547b) ld a, c - call Func_ca6c + call CheckIfEventFlagSet or a jr nz, asm_d46d jr asm_d467 @@ -2835,9 +2843,9 @@ Func_d48a: ; d48a (3:548a) Func_d490: ; d490 (3:5490) call Func_ccb3 - call Func_cc9e + call GetOWSArgs3AfterPointer jr z, .asm_d49b - jp Func_cc8b + jp SetOWScriptPointer .asm_d49b jp IncreaseOWScriptPointerBy5 @@ -2863,12 +2871,12 @@ Func_d4ae: ; d4ae (3:54ae) Func_d4b6: ; d4b6 (3:54b6) ld a, c ld c, b - call Func_ca6c + call CheckIfEventFlagSet ret -Func_d4bc: ; d4bc (3:54bc) +OWScript_SetEventFlags: ; d4bc (3:54bc) ld a, c - call Func_cac5 + call SetEventFlags jp IncreaseOWScriptPointerBy2 Func_d4c3: ; d4c3 (3:54c3) @@ -2878,20 +2886,20 @@ Func_d4c3: ; d4c3 (3:54c3) Func_d4ca: ; d4ca (3:54ca) ld a, c - call Func_ca6c + call CheckIfEventFlagSet or a jr z, asm_d4e6 Func_d4d1: call Func_ccb3 - call Func_cc9a + call GetOWSArgs2AfterPointer jr z, .asm_d4dc - jp Func_cc8b + jp SetOWScriptPointer .asm_d4dc jp IncreaseOWScriptPointerBy4 -Func_d4df: +OWScript_JumpIfFlagNotSet: ld a, c - call Func_ca6c + call CheckIfEventFlagSet or a jr z, Func_d4d1 asm_d4e6 @@ -2901,20 +2909,236 @@ asm_d4e6 INCBIN "baserom.gbc",$d4ec,$d753 - $d4ec -; move to it's own file after we know where scripts start and end +OWSequence_d753: ; d753 (3:5753) + start_script + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_MovePlayer + db $00 + db $02 + run_script OWScript_PrintTextString + argt Text05e3 + run_script OWScript_CloseTextBox + run_script Func_d088 + db $07 + db $79 + db $57 + run_scriptx OWScript_EndScriptLoop_0 + ret + + start_script + run_script Func_ce4a + db $80 + db $58 + db $02 + + ; there's more to this script but it hasn't been disassembled yet + +INCBIN "baserom.gbc",$d77e,$e13f - $d77e + +WaterClubMovePlayer: ; e13f (3:613f) + ld a, [wPlayerYCoord] + cp $8 + ret nz + call Func_ca69 + inc sp + cp $2 + ret nc + ld a, $21 + ld [wd3ab], a + ld bc, OWSequence_NotReadyToSeeAmy + jp Func_c926 + +WaterClubAfterDuel: ;e157 (3:6157) + ld hl, .afterDuelTable + call FindEndOfBattleScript + ret + +.afterDuelTable + dw $1f1f + dw OWSequence_BeatSara + dw OWSequence_LostToSara + + dw $2020 + dw OWSequence_BeatAmanda + dw OWSequence_LostToAmanda + + dw $2121 + dw $626c + dw $6260 + + dw $2222 + dw $6322 + dw $6344 + db $00 + +OWSequence_Sara: ; e177 (3:6177) + start_script + run_script OWScript_PrintTextString + argt Text042c + run_script OWScript_AskQuestionJump + argt Text042d + dw .yesDuel + run_script OWScript_PrintTextString + argt Text042e + run_script OWScript_EndScriptCloseText +.yesDuel + run_script OWScript_PrintTextString + argt Text042f + run_script OWScript_StartBattle + db 2 + db WATERFRONT_POKEMON_DECK - 2 ; 6189 + db MUSIC_DUELTHEME1 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatSara: ; e18c (3:618c) + start_script + run_script OWScript_SetEventFlags + db FLAG_BEAT_SARA + run_script OWScript_PrintTextString + argt Text0430 + run_script OWScript_GiveBoosterPacks + db BOOSTER_ColoWater + db BOOSTER_ColoWater + db NO_BOOSTER + run_script OWScript_PrintTextString + argt Text0431 + run_script OWScript_EndScriptCloseText + +OWSequence_LostToSara: ; e19a (03:619a) + start_script + run_script OWScript_PrintTextCloseBox + argt Text0432 + +OWSequence_Amanda: ; e19e (03:619e) start_script - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - run_script OWScript_MovePlayer, $0, $2 - ; there are more but the scripts haven't been disassembled - -INCBIN "baserom.gbc",$d76f,$f580 - $d76f + run_script OWScript_PrintTextString + argt Text0433 + run_script OWScript_AskQuestionJump + argt Text0434 + dw .yesDuel + run_script OWScript_PrintTextString + argt Text0435 + run_script OWScript_EndScriptCloseText +.yesDuel + run_script OWScript_PrintTextString + argt Text0436 + run_script OWScript_StartBattle + db 03 + db LONELY_FRIENDS_DECK - 2 + db MUSIC_DUELTHEME1 + run_script OWScript_EndScriptCloseText + +OWSequence_BeatAmanda: ; e1b3 (03:61b3) + start_script + run_script OWScript_SetEventFlags + db FLAG_BEAT_AMANDA + run_script OWScript_PrintTextString + argt Text0437 + run_script OWScript_GiveBoosterPacks + db BOOSTER_LightningColorless + db BOOSTER_LightningColorless + db NO_BOOSTER + run_script OWScript_PrintTextString + argt Text0438 + run_script OWScript_EndScriptCloseText + +OWSequence_LostToAmanda: ; e1c1 (03:61c1) + start_script + run_script OWScript_PrintTextCloseBox + argt Text0439 + +OWSequence_NotReadyToSeeAmy: +INCBIN "baserom.gbc",$e1c5,$e21c - $e1c5 + +OWSequence_Joshua: + start_script + run_script OWScript_JumpIfFlagNotSet + db FLAG_BEAT_AMANDA + dw .saraAndAmandaNotBeaten + run_script OWScript_JumpIfFlagNotSet + db FLAG_BEAT_SARA + dw .saraAndAmandaNotBeaten + run_script OWScript_ScriptJump + dw .beatSaraAndAmanda +.saraAndAmandaNotBeaten + run_script OWScript_CustomModifyEventFlags + db $33 ; offset on flagmod table + db $01 ; the control bit + run_script OWScript_PrintTextString + argt Text043b + run_script OWScript_EndScriptCloseText +.beatSaraAndAmanda + run_script OWScript_JumpIfFlagSet + db $33 + dw $623c + run_script OWScript_CustomModifyEventFlags + db $33 + db $01 + run_script OWScript_PrintTextString + argt Text043b + run_script OWScript_PrintTextString + argt Text043c + run_script Func_d484 + db $33 + db $01 + +INCBIN "baserom.gbc",$e23f,$e52c - $e23f + +FindEndOfBattleScript: ; e52c (3:652c) + ld c, $0 + ld a, [wd0c3] + or a + jr z, .playerWon + ld c, $2 + +.playerWon + ld a, [wd0c4] + ld b, a + ld de, $0005 +.checkEnemyByteLoop + ld a, [hli] + or a + ret z + cp b + jr z, .foundEnemy + add hl, de + jr .checkEnemyByteLoop + +.foundEnemy + ld a, [hli] + ld [wd3ab], a + ld b, $0 + add hl, bc + ld c, [hl] + inc hl + ld b, [hl] + jp Func_c926 +; 0xe553 + +INCBIN "baserom.gbc",$e553,$f580 - $e553 Func_f580: ; f580 (3:7580) call Func_ca69 diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm index c810209..362a8bb 100755 --- a/src/engine/bank4.asm +++ b/src/engine/bank4.asm @@ -457,7 +457,7 @@ Func_10f4a: ; 10f4a (4:4f4a) jr nz, .asm_10f5f ld c, a ld a, $1e - farcall Func_ca6c + farcall CheckIfEventFlagSet or a ld a, c jr nz, .asm_10f5f @@ -530,7 +530,7 @@ Func_10fde: ; 10fde (4:4fde) ld [wd33c], a call Func_12ab5 ld a, $3e - farcall Func_ca6c + farcall CheckIfEventFlagSet or a jr nz, .asm_11015 ld c, $f @@ -962,21 +962,20 @@ INCLUDE "data/unknownNPCData.asm" INCBIN "baserom.gbc",$11f4e,$1217b - $11f4e -owsCons = 0 OverworldScriptTable: ; 1217b (4:617b) - dw Func_ccbe - dw Func_ccc6 ; seems to end conversation with mason and starts bringing aid over - dw Func_ccd4 ; Seems to begin dialogue with NPCs + dw OWScript_EndScriptLoop + dw OWScript_CloseTextBox + dw OWScript_PrintTextString dw Func_ccdc - dw Func_cce9 ; opens the "start battle?" box - dw Func_cd01 ; seems to start a battle. + dw OWScript_AskQuestionJump + dw OWScript_StartBattle dw Func_cd83 dw Func_cda8 - dw Func_cdb9 + dw OWScript_PrintTextCloseBox dw Func_cdcb dw Func_ce26 dw Func_ce84 - dw Func_ce8a ; Called after player wins a battle. Handles Booster Packs. + dw OWScript_GiveBoosterPacks dw Func_cf0c dw Func_cf12 dw Func_cf3f @@ -991,7 +990,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d025 dw Func_d032 dw Func_d03f - dw Func_d049 + dw OWScript_ScriptJump dw Func_d04f dw Func_d055 dw OWScript_MovePlayer @@ -1017,7 +1016,7 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d195 dw Func_d1ad dw Func_d1b3 - dw Func_cccc ; Ends dialogue but seems to be more of a loading thing. it's used to load mason's lab, i bet it's used to load battles + in general + dw OWScript_EndScriptCloseText dw Func_d244 dw Func_d24c dw DeckMachine_d336 @@ -1047,27 +1046,27 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d2f6 dw Func_d317 dw Func_d43d - dw Func_ccbe - dw Func_ccbe - dw Func_ccbe - dw Func_ccbe - dw Func_ccbe - dw Func_d44a + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_CustomModifyEventFlags dw Func_d460 - dw Func_d47b + dw OWScript_JumpIfFlagSet dw Func_d484 dw Func_d49e dw Func_d4a6 dw Func_d4ae - dw Func_d4bc + dw OWScript_SetEventFlags dw Func_d4c3 dw Func_d4ca - dw Func_d4df ; Used by 2 lightning club members and npcs in mason's lab. Not sure why. + dw OWScript_JumpIfFlagNotSet dw Func_d452 - dw Func_ccbe - dw Func_ccbe - dw Func_ccbe - dw Func_ccbe + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop + dw OWScript_EndScriptLoop INCBIN "baserom.gbc",$1224b,$1229f - $1224b diff --git a/src/engine/bank5.asm b/src/engine/bank5.asm new file mode 100755 index 0000000..11f91d7 --- /dev/null +++ b/src/engine/bank5.asm @@ -0,0 +1,323 @@ +PointerTable_14000: ; 14000 (05:4000)
+ dw $47bd ; 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 $49e8 ; LEGENDARY_MOLTRES_DECK
+ dw $4b0f ; LEGENDARY_ZAPDOS_DECK
+ dw $4c0b ; LEGENDARY_ARTICUNO_DECK
+ dw $4d60 ; LEGENDARY_DRAGONITE_DECK
+ dw $4e89 ; FIRST_STRIKE_DECK
+ dw $4f0e ; ROCK_CRUSHER_DECK
+ dw $4f8f ; GO_GO_RAIN_DANCE_DECK
+ dw $5019 ; ZAPPING_SELFDESTRUCT_DECK
+ dw $509b ; FLOWER_POWER_DECK
+ dw $5122 ; STRANGE_PSYSHOCK_DECK
+ dw $51ad ; WONDERS_OF_SCIENCE_DECK
+ dw $5232 ; FIRE_CHARGE_DECK
+ dw $52bd ; IM_RONALD_DECK
+ dw $534b ; POWERFUL_RONALD_DECK
+ dw $53e8 ; INVINCIBLE_RONALD_DECK
+ dw $546f ; LEGENDARY_RONALD_DECK
+ dw $48dc ; 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
+
+INCBIN "baserom.gbc",$1406a,$14226 - $1406a
+
+Func_14226: ; 14226 (5:4226)
+ call CreateHandCardBuffer
+ ld hl, wDuelCardOrAttackList
+.checkForNextPokemon
+ ld a, [hli]
+ ld [$ff98], a
+ cp $ff
+ ret z
+ call LoadDeckCardToBuffer1
+ ld a, [wCardBuffer1Type]
+ cp FIRE_ENERGY_CARD
+ jr nc, .checkForNextPokemon
+ ld a, [wCardBuffer1Stage]
+ or a
+ jr nz, .checkForNextPokemon
+ push hl
+ ld a, [$ff98]
+ call $1485
+ pop hl
+ jr .checkForNextPokemon
+; 0x1424b
+
+INCBIN "baserom.gbc",$1424b,$14663 - $1424b
+
+Func_14663: ; 14663 (5:4663)
+ farcall Func_200e5
+ 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 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_14683
+ dw Func_14687
+
+; when battle AI gets called
+Func_14674: ; 14674 (5:4674)
+ call Func_1468b
+ ret
+
+Func_14678: ; 14678 (5:4678)
+ call Func_15636
+ call $4226
+ ret
+
+Func_1467f: ; 1467f (5:467f)
+ call $5b72
+ ret
+
+Func_14683: ; 14683 (5:4683)
+ call $5b72
+ ret
+
+Func_14687: ; 14687 (5:4687)
+ call $41e5
+ ret
+
+; AI for general decks i think
+Func_1468b: ; 1468b (5:468b)
+ call Func_15649
+ ld a, $1
+ call Func_14663
+ farcallx $8, $67d3
+ jp nc, $4776
+ farcallx $8, $6790
+ farcallx $8, $66a3
+ farcallx $8, $637f
+ ret c
+ farcallx $8, $662d
+ ld a, $2
+ call Func_14663
+ ld a, $3
+ call Func_14663
+ ld a, $4
+ call Func_14663
+ call $5eae
+ ret c
+ ld a, $5
+ call Func_14663
+ ld a, $6
+ call Func_14663
+ ld a, $7
+ call Func_14663
+ ld a, $8
+ call Func_14663
+ call $4786
+ ld a, $a
+ call Func_14663
+ ld a, $b
+ call Func_14663
+ ld a, $c
+ call Func_14663
+ ld a, [wAlreadyPlayedEnergy]
+ or a
+ jr nz, .asm_146ed
+ call $64e8
+
+.asm_146ed
+ call $5eae
+ farcallx $8, $66a3
+ farcallx $8, $637f
+ ret c
+ farcallx $8, $6790
+ ld a, $d
+ farcallx $8, $619b
+ ld a, $d
+ call Func_14663
+ ld a, $f
+ call Func_14663
+ ld a, [$ce20]
+ and $4
+ jr z, .asm_14776
+ ld a, $1
+ call Func_14663
+ ld a, $2
+ call Func_14663
+ ld a, $3
+ call Func_14663
+ ld a, $4
+ call Func_14663
+ call $5eae
+ ret c
+ ld a, $5
+ call Func_14663
+ ld a, $6
+ call Func_14663
+ ld a, $7
+ call Func_14663
+ ld a, $8
+ call Func_14663
+ call $4786
+ ld a, $a
+ call Func_14663
+ ld a, $b
+ call Func_14663
+ ld a, $c
+ call Func_14663
+ ld a, [wAlreadyPlayedEnergy]
+ or a
+ jr nz, .asm_1475b
+ call $64e8
+
+.asm_1475b
+ call $5eae
+ farcallx $8, $66a3
+ farcallx $8, $637f
+ ret c
+ farcallx $8, $6790
+ ld a, $d
+ farcallx $8, $619b
+ ld a, $d
+ call Func_14663
+
+.asm_14776
+ ld a, $e
+ farcallx $8, $619b
+ call $69f8
+ ret c
+ ld a, $5
+ bank1call $67be
+ ret
+; 0x14786
+
+
+INCBIN "baserom.gbc",$14786,$15636 - $14786
+Func_15636: ; 15636 (5:5636)
+ ld a, $10
+ ld hl, $cda5
+ call ZeroData
+ ld a, $5
+ ld [$cda6], a
+ ld a, $ff
+ ld [$cda5], a
+ ret
+
+Func_15649: ; 15649 (5:5649)
+ ld a, [$cda6]
+ inc a
+ ld [$cda6], a
+ xor a
+ ld [$ce20], a
+ ld [$cddb], a
+ ld [$cddc], a
+ ld [$ce03], a
+ ld a, [wcc10]
+ cp $ff
+ jr z, .asm_156b1
+ or a
+ jr z, .asm_156b1
+ ld a, [wcc11]
+ cp $ff
+ jr z, .asm_156b1
+ call SwapTurn
+ call GetCardInDeckPosition
+ call SwapTurn
+ ld a, e
+ cp MEWTWO1 ; I believe this is a check for Mewtwo1's Barrier move
+ jr nz, .asm_156b1
+ ld a, [$cda7]
+ bit 7, a
+ jr nz, .asm_156aa
+ inc a
+ ld [$cda7], a
+ cp $3
+ jr c, .asm_156c2
+ ld a, (wPlayerArenaCard & $FF)
+ call GetNonTurnDuelistVariable
+ call SwapTurn
+ call GetCardInDeckPosition
+ call SwapTurn
+ ld a, e
+ cp MEWTWO1
+ jr nz, .asm_156a4
+ farcallx $8, $67a9
+ jr nc, .asm_156aa
+
+.asm_156a4
+ xor a
+ ld [$cda7], a
+ jr .asm_156c2
+
+.asm_156aa
+ ld a, $80
+ ld [$cda7], a
+ jr .asm_156c2
+
+.asm_156b1
+ ld a, [$cda7]
+ bit 7, a
+ jr z, .asm_156be
+ inc a
+ ld [$cda7], a
+ jr .asm_156c2
+
+.asm_156be
+ xor a
+ ld [$cda7], a
+
+.asm_156c2
+ ret
+; 0x156c3
+
+INCBIN "baserom.gbc",$156c3,$1575e - $156c3
+
+; zeroes a bytes starting at hl
+ZeroData: ; 1575e (5:575e)
+ push af
+ push bc
+ push hl
+ ld b, a
+ xor a
+.clearLoop
+ ld [hli], a
+ dec b
+ jr nz, .clearLoop
+ pop hl
+ pop bc
+ pop af
+ ret
+; 0x1576b
+
+INCBIN "baserom.gbc",$1576b,$18000 - $1576b
\ No newline at end of file diff --git a/src/engine/bank7.asm b/src/engine/bank7.asm index f246505..160092d 100755 --- a/src/engine/bank7.asm +++ b/src/engine/bank7.asm @@ -250,7 +250,6 @@ Func_1c719: ; 1c719 (7:4719) pop hl ret - Func_1c72e: ; 1c72e (7:472e) INCBIN "baserom.gbc",$1c72e,$1c768 - $1c72e diff --git a/src/engine/bank8.asm b/src/engine/bank8.asm new file mode 100755 index 0000000..fca29ba --- /dev/null +++ b/src/engine/bank8.asm @@ -0,0 +1,132 @@ +INCBIN "baserom.gbc",$20000,$200e5 - $20000
+
+; 0 - e4 is a big set of data, seems to be one entry for each card
+
+Func_200e5: ; 200e5 (8:40e5)
+ ld [$ce18], a
+ call CreateHandCardBuffer
+ ld hl, wDuelCardOrAttackList
+ ld de, wHandCardBuffer
+ call CopyBuffer
+ ld hl, wHandCardBuffer
+ ld a, [hli]
+ ld [$ce16], a
+ cp $ff
+ ret z
+ push hl
+ ld a, [$ce18]
+ ld d, a
+ ld hl, $4000
+.asm_4106
+ xor a
+ ld [$ce21], a
+ ld a, [hli]
+ cp $ff
+ jp z, $41b1
+ cp d
+ jp nz, .incHL5
+ ld a, [hli]
+ ld [$ce17], a
+ ld a, [$ce16]
+ call LoadDeckCardToBuffer1
+ cp $d2
+ jr nz, .asm_2012b
+ ld b, a
+ ld a, [$ce20]
+ and $2
+ jr nz, .incHL4
+ ld a, b
+
+.asm_2012b
+ ld b, a
+ ld a, [$ce17]
+ cp b
+ jr nz, .incHL4
+ push hl
+ push de
+ ld a, [$ce16]
+ ld [$ff9f], a
+ bank1call $35a9
+ jp c, $41a8
+ call $1944
+ ld a, $1
+ call TryExecuteEffectCommandFunction
+ jp c, $41a8
+ farcallx $5, $743b
+ jr c, .asm_201a8
+ pop de
+ pop hl
+ push hl
+ call CallIndirect
+ pop hl
+ jr nc, .incHL4
+ inc hl
+ inc hl
+ ld [$ce19], a
+ push de
+ push hl
+ ld a, [$ce16]
+ ld [$ff9f], a
+ ld a, $6
+ bank1call $67be
+ pop hl
+ pop de
+ jr c, .incHL2
+ push hl
+ call CallIndirect
+ pop hl
+ inc hl
+ inc hl
+ ld a, [$ce20]
+ ld b, a
+ ld a, [$ce21]
+ or b
+ ld [$ce20], a
+ pop hl
+ and $8
+ jp z, $40f7
+ call $123b
+ ld hl, wDuelCardOrAttackList
+ ld de, $cf68
+ call $697b
+ ld hl, $cf68
+ ld a, [$ce20]
+ and $f7
+ ld [$ce20], a
+ jp $40f7
+
+.incHL5
+ inc hl
+
+.incHL4
+ inc hl
+ inc hl
+
+.incHL2
+ inc hl
+ inc hl
+ jp .asm_4106
+
+.asm_201a8
+ pop de
+ pop hl
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+ jp .asm_4106
+; 0x201b1
+
+INCBIN "baserom.gbc",$201b1,$2297b - $201b1
+
+; copies $ff terminated buffer from hl to de
+CopyBuffer: ; 2297b (8:697b)
+ ld a, [hli]
+ ld [de], a
+ cp $ff
+ ret z
+ inc de
+ jr CopyBuffer
+; 0x22983
+
+INCBIN "baserom.gbc",$22983,$24000 - $22983
diff --git a/src/engine/boosters.asm b/src/engine/boosters.asm index 3809e3a..7537897 100755 --- a/src/engine/boosters.asm +++ b/src/engine/boosters.asm @@ -124,7 +124,7 @@ CheckCardViable: ; 1e268 (7:6268) swap a and $0f ld c, a - ld a, [wBoosterDataRarityIndex] + ld a, [wBoosterDataCurrSet] cp c jr nz, .invalidCard .returnValidCard @@ -464,7 +464,7 @@ InitBoosterData: ; 1e430 (7:6430) dec c jr nz, .clearTempCardCollectionLoop call FindBoosterDataPointer - ld de, wBoosterDataRarityIndex + ld de, wBoosterDataCurrSet ld bc, $c call CopyData call LoadRarityAmountsToWram @@ -502,43 +502,43 @@ FindBoosterDataPointer: ; 1e46f (7:646f) ret BoosterData_PtrTbl: ; 1e480 (7:6480) - dw BoosterData_1e4e4 - dw BoosterData_1e4f0 - dw BoosterData_1e4fc - dw BoosterData_1e508 - dw BoosterData_1e514 - dw BoosterData_1e520 - dw BoosterData_1e52c - dw BoosterData_1e538 - dw BoosterData_1e544 - dw BoosterData_1e550 - dw BoosterData_1e55c - dw BoosterData_1e568 - dw BoosterData_1e574 - dw BoosterData_1e580 - dw BoosterData_1e58c - dw BoosterData_1e598 - dw BoosterData_1e5a4 - dw BoosterData_1e5b0 - dw BoosterData_1e5bc - dw BoosterData_1e5c8 - dw BoosterData_1e5d4 - dw BoosterData_1e5e0 - dw BoosterData_1e5ec - dw BoosterData_1e5f8 - dw BoosterData_1e604 - dw BoosterData_1e610 - dw BoosterData_1e61c - dw BoosterData_1e628 - dw BoosterData_1e634 + dw PackColoNeutral + dw PackColoGrass + dw PackColoFire + dw PackColoWater + dw PackColoLightning + dw PackColoFighting + dw PackColoTrainer + dw PackEvoNeutral + dw PackEvoGrass + dw PackEvoNeutralFireEnergy + dw PackEvoWater + dw PackEvoFighting + dw PackEvoPsychic + dw PackEvoTrainer + dw PackMysteryNeutral + dw PackMysteryGrassColorless + dw PackMysteryWaterColorless + dw PackLightningColorless + dw PackMysteryFightingColorless + dw PackMysteryTrainerColorless + dw PackLabTrainerLessFighting + dw PackLabGrass + dw PackLabWater + dw PackLabPsychic + dw PackLabTrainer + dw PackEnergyLightningFire + dw PackEnergyWaterFighting + dw PackEnergyGrassPsychic + dw PackRandomEnergies LoadRarityAmountsToWram: ; 1e4ba (7:64ba) - ld a, [wBoosterDataRarityIndex] + ld a, [wBoosterDataCurrSet] add a add a ld c, a ld b, $00 - ld hl, BoosterRarityAmountTable + ld hl, BoosterSetRarityAmountTable add hl, bc inc hl ld a, [hli] @@ -549,14 +549,14 @@ LoadRarityAmountsToWram: ; 1e4ba (7:64ba) ld [wBoosterDataRareAmount], a ret -BoosterRarityAmountTable: ; 1e4d4 (7::64d4) +BoosterSetRarityAmountTable: ; 1e4d4 (7::64d4) db $01, $05, $03, $01 ; other, commons, uncommons, rares db $01, $05, $03, $01 ; other, commons, uncommons, rares db $00, $06, $03, $01 ; other, commons, uncommons, rares db $00, $06, $03, $01 ; other, commons, uncommons, rares -BoosterData_1e4e4:: ; 1e4e4 (7:64e4) - db $00 ;booster rarity table index +PackColoNeutral:: ; 1e4e4 (7:64e4) + db COLOSSEUM >> 4 ; booster pack set dw GenerateEndingEnergy ; energy or energy generation function ; Card Type Chances @@ -570,8 +570,8 @@ BoosterData_1e4e4:: ; 1e4e4 (7:64e4) db $14 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e4f0:: ; 1e4f0 (7:64f0) - db $00 ;booster rarity table index +PackColoGrass:: ; 1e4f0 (7:64f0) + db COLOSSEUM >> 4 ; booster pack set dw GRASS_ENERGY ; energy or energy generation function ; Card Type Chances @@ -585,8 +585,8 @@ BoosterData_1e4f0:: ; 1e4f0 (7:64f0) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e4fc:: ; 1e4fc (7:64fc) - db $00 ;booster rarity table index +PackColoFire:: ; 1e4fc (7:64fc) + db COLOSSEUM >> 4 ; booster pack set dw FIRE_ENERGY ; energy or energy generation function ; Card Type Chances @@ -600,8 +600,8 @@ BoosterData_1e4fc:: ; 1e4fc (7:64fc) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e508:: ; 1e508 (7:6508) - db $00 ;booster rarity table index +PackColoWater:: ; 1e508 (7:6508) + db COLOSSEUM >> 4 ; booster pack set dw WATER_ENERGY ; energy or energy generation function ; Card Type Chances @@ -615,8 +615,8 @@ BoosterData_1e508:: ; 1e508 (7:6508) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e514:: ; 1e514 (7:6514) - db $00 ;booster rarity table index +PackColoLightning:: ; 1e514 (7:6514) + db COLOSSEUM >> 4 ; booster pack set dw LIGHTNING_ENERGY ; energy or energy generation function ; Card Type Chances @@ -630,8 +630,8 @@ BoosterData_1e514:: ; 1e514 (7:6514) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e520:: ; 1e520 (7:6520) - db $00 ;booster rarity table index +PackColoFighting:: ; 1e520 (7:6520) + db COLOSSEUM >> 4 ; booster pack set dw FIGHTING_ENERGY ; energy or energy generation function ; Card Type Chances @@ -645,8 +645,8 @@ BoosterData_1e520:: ; 1e520 (7:6520) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e52c:: ; 1e52c (7:652c) - db $00 ;booster rarity table index +PackColoTrainer:: ; 1e52c (7:652c) + db COLOSSEUM >> 4 ; booster pack set dw GenerateEndingEnergy ; energy or energy generation function ; Card Type Chances @@ -660,8 +660,8 @@ BoosterData_1e52c:: ; 1e52c (7:652c) db $30 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e538:: ; 1e538 (7:6538) - db $01 ;booster rarity table index +PackEvoNeutral:: ; 1e538 (7:6538) + db EVOLUTION >> 4 ; booster pack set dw GenerateEndingEnergy ; energy or energy generation function ; Card Type Chances @@ -675,8 +675,8 @@ BoosterData_1e538:: ; 1e538 (7:6538) db $14 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e544:: ; 1e544 (7:6544) - db $01 ;booster rarity table index +PackEvoGrass:: ; 1e544 (7:6544) + db EVOLUTION >> 4 ; booster pack set dw GRASS_ENERGY ; energy or energy generation function ; Card Type Chances @@ -690,8 +690,8 @@ BoosterData_1e544:: ; 1e544 (7:6544) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e550:: ; 1e550 (7:6550) - db $01 ;booster rarity table index +PackEvoNeutralFireEnergy:: ; 1e550 (7:6550) + db EVOLUTION >> 4 ; booster pack set dw FIRE_ENERGY ; energy or energy generation function ; Card Type Chances @@ -705,8 +705,8 @@ BoosterData_1e550:: ; 1e550 (7:6550) db $14 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e55c:: ; 1e55c (7:655c) - db $01 ;booster rarity table index +PackEvoWater:: ; 1e55c (7:655c) + db EVOLUTION >> 4 ; booster pack set dw WATER_ENERGY ; energy or energy generation function ; Card Type Chances @@ -720,8 +720,8 @@ BoosterData_1e55c:: ; 1e55c (7:655c) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e568:: ; 1e568 (7:6568) - db $01 ;booster rarity table index +PackEvoFighting:: ; 1e568 (7:6568) + db EVOLUTION >> 4 ; booster pack set dw FIGHTING_ENERGY ; energy or energy generation function ; Card Type Chances @@ -735,8 +735,8 @@ BoosterData_1e568:: ; 1e568 (7:6568) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e574:: ; 1e574 (7:6574) - db $01 ;booster rarity table index +PackEvoPsychic:: ; 1e574 (7:6574) + db EVOLUTION >> 4 ; booster pack set dw PSYCHIC_ENERGY ; energy or energy generation function ; Card Type Chances @@ -750,8 +750,8 @@ BoosterData_1e574:: ; 1e574 (7:6574) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e580:: ; 1e580 (7:6580) - db $01 ;booster rarity table index +PackEvoTrainer:: ; 1e580 (7:6580) + db EVOLUTION >> 4 ; booster pack set dw GenerateEndingEnergy ; energy or energy generation function ; Card Type Chances @@ -765,8 +765,8 @@ BoosterData_1e580:: ; 1e580 (7:6580) db $30 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e58c:: ; 1e58c (7:658c) - db $02 ;booster rarity table index +PackMysteryNeutral:: ; 1e58c (7:658c) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -780,8 +780,8 @@ BoosterData_1e58c:: ; 1e58c (7:658c) db $11 ; Trainer Card Chance db $11 ; Energy Card Chance -BoosterData_1e598:: ; 1e598 (7:6598) - db $02 ;booster rarity table index +PackMysteryGrassColorless:: ; 1e598 (7:6598) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -795,8 +795,8 @@ BoosterData_1e598:: ; 1e598 (7:6598) db $0C ; Trainer Card Chance db $0C ; Energy Card Chance -BoosterData_1e5a4:: ; 1e5a4 (7:65a4) - db $02 ;booster rarity table index +PackMysteryWaterColorless:: ; 1e5a4 (7:65a4) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -810,8 +810,8 @@ BoosterData_1e5a4:: ; 1e5a4 (7:65a4) db $0C ; Trainer Card Chance db $0C ; Energy Card Chance -BoosterData_1e5b0:: ; 1e5b0 (7:65b0) - db $02 ;booster rarity table index +PackLightningColorless:: ; 1e5b0 (7:65b0) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -825,8 +825,8 @@ BoosterData_1e5b0:: ; 1e5b0 (7:65b0) db $0C ; Trainer Card Chance db $0C ; Energy Card Chance -BoosterData_1e5bc:: ; 1e5bc (7:65bc) - db $02 ;booster rarity table index +PackMysteryFightingColorless:: ; 1e5bc (7:65bc) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -840,8 +840,8 @@ BoosterData_1e5bc:: ; 1e5bc (7:65bc) db $0C ; Trainer Card Chance db $0C ; Energy Card Chance -BoosterData_1e5c8:: ; 1e5c8 (7:65c8) - db $02 ;booster rarity table index +PackMysteryTrainerColorless:: ; 1e5c8 (7:65c8) + db MYSTERY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -855,8 +855,8 @@ BoosterData_1e5c8:: ; 1e5c8 (7:65c8) db $30 ; Trainer Card Chance db $0C ; Energy Card Chance -BoosterData_1e5d4:: ; 1e5d4 (7:65d4) - db $03 ;booster rarity table index +PackLabTrainerLessFighting:: ; 1e5d4 (7:65d4) + db LABORATORY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -870,8 +870,8 @@ BoosterData_1e5d4:: ; 1e5d4 (7:65d4) db $18 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e5e0:: ; 1e5e0 (7:65e0) - db $03 ;booster rarity table index +PackLabGrass:: ; 1e5e0 (7:65e0) + db LABORATORY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -885,8 +885,8 @@ BoosterData_1e5e0:: ; 1e5e0 (7:65e0) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e5ec:: ; 1e5ec (7:65ec) - db $03 ;booster rarity table index +PackLabWater:: ; 1e5ec (7:65ec) + db LABORATORY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -900,8 +900,8 @@ BoosterData_1e5ec:: ; 1e5ec (7:65ec) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e5f8:: ; 1e5f8 (7:65f8) - db $03 ;booster rarity table index +PackLabPsychic:: ; 1e5f8 (7:65f8) + db LABORATORY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -915,8 +915,8 @@ BoosterData_1e5f8:: ; 1e5f8 (7:65f8) db $10 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e604:: ; 1e604 (7:6604) - db $03 ;booster rarity table index +PackLabTrainer:: ; 1e604 (7:6604) + db LABORATORY >> 4 ; booster pack set dw $0000 ; energy or energy generation function ; Card Type Chances @@ -930,8 +930,8 @@ BoosterData_1e604:: ; 1e604 (7:6604) db $30 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e610:: ; 1e610 (7:6610) - db $00 ;booster rarity table index +PackEnergyLightningFire:: ; 1e610 (7:6610) + db COLOSSEUM >> 4 ; booster pack set dw GenerateEnergyBoosterLightningFire ; energy or energy generation function ; Card Type Chances @@ -945,8 +945,8 @@ BoosterData_1e610:: ; 1e610 (7:6610) db $00 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e61c:: ; 1e61c (7:661c) - db $00 ;booster rarity table index +PackEnergyWaterFighting:: ; 1e61c (7:661c) + db COLOSSEUM >> 4 ; booster pack set dw GenerateEnergyBoosterWaterFighting ; energy or energy generation function ; Card Type Chances @@ -960,8 +960,8 @@ BoosterData_1e61c:: ; 1e61c (7:661c) db $00 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e628:: ; 1e628 (7:6628) - db $00 ;booster rarity table index +PackEnergyGrassPsychic:: ; 1e628 (7:6628) + db COLOSSEUM >> 4 ; booster pack set dw GenerateEnergyBoosterGrassPsychic ; energy or energy generation function ; Card Type Chances @@ -975,8 +975,8 @@ BoosterData_1e628:: ; 1e628 (7:6628) db $00 ; Trainer Card Chance db $00 ; Energy Card Chance -BoosterData_1e634:: ; 1e634 (7:6634) - db $00 ;booster rarity table index +PackRandomEnergies:: ; 1e634 (7:6634) + db COLOSSEUM >> 4 ; booster pack set dw GenerateRandomEnergyBoosterPack ; energy or energy generation function ; Card Type Chances diff --git a/src/engine/home.asm b/src/engine/home.asm index 93264a3..c984fa1 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2329,7 +2329,49 @@ AddCardToHand: ; 1123 (0:1123) ret ; 0x1139 -INCBIN "baserom.gbc",$1139,$127f - $1139 +INCBIN "baserom.gbc",$1139,$123b - $1139 + +CreateHandCardBuffer: ; 123b (0:123b) + call FindLastCardInHand + inc b + jr .skipCard + +.checkNextCardLoop + ld a, [hld] + push hl + ld l, a + bit 6, [hl] + pop hl + jr nz, .skipCard + ld [de], a + inc de + +.skipCard + dec b + jr nz, .checkNextCardLoop + ld a, $ff + ld [de], a + ld l, (wPlayerNumberOfCardsInHand & $ff) + ld a, [hl] + or a + ret nz + scf + ret +; 0x1258 + +INCBIN "baserom.gbc",$1258,$1271 - $1258 + +; puts an index to the last (newest) card in current player's hand into hl. +FindLastCardInHand: ; 1271 (0:1271) + ldh a, [hWhoseTurn] + ld h, a + ld l, (wPlayerNumberOfCardsInHand & $ff) + ld b, [hl] + ld a, (wPlayerHand & $ff) - 1 + add [hl] + ld l, a + ld de, wDuelCardOrAttackList + ret ; shuffles the deck by swapping the position of each card with the position of another random card ; input: @@ -2455,7 +2497,65 @@ LoadDeckCardToBuffer2: ; 138c (0:138c) ret ; 0x13a2 -INCBIN "baserom.gbc",$13a2,$159f - $13a2 +INCBIN "baserom.gbc",$13a2,$1485 - $13a2 + +Func_1485: ; 1485 (0:1485) + push af + ld a, $ff & wPlayerNumberOfPokemonInPlay + call GetTurnDuelistVariable + cp DUEL_MAX_POKEMON_IN_PLAY + jr nc, .tooManyPokemonInPlay + inc [hl] + ld e, a + pop af + push af + call $14d2 + ld a, e + add $bb + ld l, a + pop af + ld [hl], a + call LoadDeckCardToBuffer2 + ld a, $c8 + add e + ld l, a + ld a, [wCardBuffer2HP] + ld [hl], a + ld a, $c2 + add e + ld l, a + ld [hl], $0 + ld a, $d4 + add e + ld l, a + ld [hl], $0 + ld a, $e0 + add e + ld l, a + ld [hl], $0 + ld a, $da + add e + ld l, a + ld [hl], $0 + ld a, $ce + add e + ld l, a + ld a, [wCardBuffer2Stage] + ld [hl], a + ld a, e + or a + call z, $1461 + ld a, e + or a + ret + +.tooManyPokemonInPlay + pop af + scf + ret +; 0x14d2 + +INCBIN "baserom.gbc",$14d2,$159f - $14d2 ; This function iterates through the card locations array to find out which and how many ; energy cards are in arena (i.e. attached to the active pokemon). @@ -5007,6 +5107,7 @@ Func_2bcf: ; 2bcf (0:2bcf) Func_2bd7: ; 2bd7 (0:2bd7) ld a, $5 jr Func_2bdb + Func_2bdb: ; 2bdb (0:2bdb) ld c, a ldh a, [hBankROM] @@ -6869,7 +6970,7 @@ Credits_3911: ; 3911 (0:3911) Func_3917: ; 3917 (0:3917) ld a, $22 - farcall Func_ca6c + farcall CheckIfEventFlagSet call EnableExtRAM ld [$a00a], a call DisableExtRAM @@ -7139,7 +7240,7 @@ Func_3abd: ; 3abd (0:3abd) INCBIN "baserom.gbc",$3ae8,$3aed - $3ae8 -; finds an OWScript from the first byte and puts the next two bytes (usually arguments?) into bc +; finds an OWScript from the first byte and puts the next two bytes (usually arguments?) into cb RunOverworldScript: ; 3aed (0:3aed) ld hl, wOWScriptPointer ld a, [hli] diff --git a/src/macros.asm b/src/macros.asm index 874c473..db39480 100755 --- a/src/macros.asm +++ b/src/macros.asm @@ -406,25 +406,13 @@ ENDM run_script: MACRO db \1_index - if(_NARG > 1) - - rept (_NARG + -1) - shift - db \1 - endr - - endc ENDM ; for the repeated functions on the table, need to specify which one, unfortunately run_scriptx: MACRO db \1 - if(_NARG > 1) - - rept (_NARG + -1) - shift - db \1 - endr +ENDM - endc +argt: MACRO + dw \1_ ENDM diff --git a/src/main.asm b/src/main.asm index d77d6d7..3f294cb 100755 --- a/src/main.asm +++ b/src/main.asm @@ -16,7 +16,7 @@ SECTION "bank4",ROMX,BANK[$4] INCLUDE "engine/bank4.asm" SECTION "bank5",ROMX,BANK[$5] -INCBIN "baserom.gbc",$14000,$4000 +INCLUDE "engine/bank5.asm" SECTION "bank6",ROMX,BANK[$6] INCLUDE "engine/bank6.asm" @@ -26,7 +26,7 @@ INCLUDE "engine/bank7.asm" INCLUDE "engine/boosters.asm" SECTION "bank8",ROMX,BANK[$8] -INCBIN "baserom.gbc",$20000,$4000 +INCLUDE "engine/bank8.asm" SECTION "bank9",ROMX,BANK[$9] emptybank diff --git a/src/wram.asm b/src/wram.asm index 396a61b..54577e6 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -764,7 +764,10 @@ wceb5:: ; ceb5 ds $17 wcecc:: ; cecc - ds $ed + ds $9c + +wHandCardBuffer:: ; cf68 + ds $51 wcfb9:: ; cfb9 ds $2a @@ -1047,12 +1050,16 @@ wd3d0:: ; d3d0 ds $1 wd3d1:: ; d3d1 - ds $40 + ds $1 + +wEventFlags:: + ds $3f wd411:: ; d411 ds $1 -wd412:: ; d412 +; 0 keeps looping, other values break the loop in RST20 +wBreakOWScriptLoop:: ; d412 ds $1 wOWScriptPointer:: ; d413 @@ -1194,7 +1201,7 @@ wBoosterCurrentCardRarity:: ; d684 wBoosterCurrentCardSet:: ; d685 ds $1 -wBoosterDataRarityIndex:: ; d686 +wBoosterDataCurrSet:: ; d686 ds $1 wBoosterDataEnergyFunctionPointer:: ; d687 |