From d85f56c95c716fc53451d220ee299b02bfe0e4ba Mon Sep 17 00:00:00 2001 From: anmart Date: Mon, 22 Feb 2016 20:04:09 -0500 Subject: disassembled some more attack menu code disassembled another attack menu function and gave names to some ambiguous labels --- src/constants/duel_constants.asm | 3 +- src/engine/bank1.asm | 60 +++++++++++++++++++++++++++++----------- src/wram.asm | 8 +++++- 3 files changed, 52 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 95bbe8d..cfa27d2 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -27,7 +27,6 @@ DUELVARS_DUELIST_TYPE EQUS "wPlayerDuelistType & $ff" ; status condition constants CARD_NOSTATUS EQU $00 -;TODO - ??? EQU $01 +CARD_CONFUSED EQU $01 CARD_ASLEEP EQU $02 CARD_PARALYZED EQU $03 -;TODO - beyond diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 57905c3..8692cf9 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -50,7 +50,7 @@ StartDuel: ; 409f (1:409f) ld a, PLAYER_TURN ldh [hWhoseTurn], a ld a, $0 - ld [$c2f1], a + ld [wPlayerDuelistType], a ld a, [$cc19] ld [wOpponentDeckId], a call LoadPlayerDeck @@ -491,7 +491,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) ld [wSelectedDuelSubMenuItem], a .tryOpenAttackMenu - call $4823 + call LoadPokemonAttacksToDuelPointerTable or a jr nz, .asm_471f ld hl, $003c @@ -532,7 +532,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) add a ld e, a ld d, $00 - ld hl, $c510 + ld hl, DuelAttackPointerTable add hl, de ld d, [hl] inc hl @@ -558,20 +558,20 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) INCBIN "baserom.gbc",$478b, $4823 - $478b -Func_4823: ; 4823 (1:4823) +LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) call DrawWideTextBox ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable ldh [$ff98], a - call $1376 + call Func_1376 ld c, $00 ld b, $0d - ld hl, $c510 + ld hl, DuelAttackPointerTable xor a ld [$cbc7], a - ld de, $cc34 - call $4872 - jr c, .asm_4856 + ld de, wCardBuffer1 + $10 + call CheckIfMoveExists + jr c, .checkForSecondAttackSlot ldh a, [$ff98] ld [hli], a xor a @@ -580,17 +580,17 @@ Func_4823: ; 4823 (1:4823) push hl push bc ld e, b - ld hl, $cc34 + ld hl, wCardBuffer1 + $10 call $5c33 pop bc pop hl inc b inc b -.asm_4856 - ld de, $cc47 - call $4872 - jr c, .asm_4870 +.checkForSecondAttackSlot + ld de, wCardBuffer1 + $23 + call CheckIfMoveExists + jr c, .finishLoadingAttacks ldh a, [$ff98] ld [hli], a ld a, $01 @@ -604,11 +604,39 @@ Func_4823: ; 4823 (1:4823) pop bc pop hl -.asm_4870 +.finishLoadingAttacks ld a, c ret -INCBIN "baserom.gbc",$4872, $4918 - $4872 +CheckIfMoveExists: + push hl + push de + push bc + ld a, [de] + ld c, a + inc de + ld a, [de] + or c + jr z, .returnNoMoveFound + ld hl, $0006 + add hl, de + ld a, [hl] + and $FF - RESIDUAL + cp POKEMON_POWER + jr z, .returnNoMoveFound + or a + +.return + pop bc + pop de + pop hl + ret + +.returnNoMoveFound + scf + jr .return + +INCBIN "baserom.gbc",$488f, $4918 - $488f CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) ld a, DUELVARS_ARENA_CARD_STATUS diff --git a/src/wram.asm b/src/wram.asm index db424fe..ddee677 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -167,7 +167,13 @@ wPlayerDeck:: ; c400 wOpponentDeck:: ; c480 ds $80 - ds $500 + ds $10 + +; when the attack menu opens, it stores +; each move in the order of +; cardNumber, moveNumber, ... +DuelAttackPointerTable:: ; c510 + ds $4f0 ;--- Engine ----------------------------------------------- -- cgit v1.2.3 From deed2bb89f992404c1e63c9a75e9a3d99d9aec51 Mon Sep 17 00:00:00 2001 From: anmart Date: Tue, 23 Feb 2016 00:11:45 -0500 Subject: Added labels and some code Disassembled some pointer table and some functions related to the attack menu. Also updated some labels. --- src/engine/bank1.asm | 118 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 108 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 8692cf9..3736930 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -493,15 +493,15 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) .tryOpenAttackMenu call LoadPokemonAttacksToDuelPointerTable or a - jr nz, .asm_471f + jr nz, .openAttackMenu ld hl, $003c call DrawWideTextBox_WaitForInput jp Func_4295 -.asm_471f +.openAttackMenu push af ld a, [wSelectedDuelSubMenuItem] - ld hl, $47e4 + ld hl, AttackMenuCursorProperties call InitializeCursorParameters pop af ld [wNumMenuItems], a @@ -514,11 +514,11 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) .asm_4736 call DoFrame ldh a, [hButtonsPressed] - and a, $08 - jr nz, .asm_4782 + and $08 + jr nz, .displaySelectedMoveInfo call Func_264b jr nc, .asm_4736 - cp a, $ff + cp $ff jp z, Func_4295 ld [wSelectedDuelSubMenuItem], a call $488f @@ -551,12 +551,110 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) call DrawWideTextBox_WaitForInput jr .tryOpenAttackMenu -.asm_4782 ; 4782 (1:4782) - call $478b +.displaySelectedMoveInfo ; 4782 (1:4782) + call Func_478b call $4f9d jp .tryOpenAttackMenu -INCBIN "baserom.gbc",$478b, $4823 - $478b +Func_478b: ; 478b (1:478b) + ld a, $01 + ld [wCardPageNumber], a + xor a + ld [$cbc9], a + call Func_04a2 + call Func_3b31 + ld de, $8a00 + call $59ca + call $5a0e + call $59f5 + call $5a34 + ld de, $3830 + call $5999 + ld de, $0604 + call $5a56 + ldh a, [hCurrentMenuItem] + ld [wSelectedDuelSubMenuItem], a + add a + ld e, a + ld d, $00 + ld hl, $c511 + add hl, de + ld a, [hl] + or a + jr nz, .asm_47c9 + xor a + jr .asm_47cb + +.asm_47c9 + ld a, $02 + +.asm_47cb + ld [$cc04], a + +.asm_47ce + call Func_47ec + call EnableLCD + +.asm_47d4 + call DoFrame + ldh a, [hButtonsPressed2] + and a, $30 + jr nz, .asm_47ce + ldh a, [hButtonsPressed] + and a, $03 + jr z, .asm_47d4 + ret + +AttackMenuCursorProperties: + db $01 + db $0d + db $02 + db $02 + db $0f + db $00 + db $00 + db $00 + +Func_47ec: ; $47ec (1:47ec) + ld a, [$cc04] + ld hl, $47f5 + jp JumpToFunctionInTable + +PtrTable_47f5: ; $47f5 (1:47f5) + dw Func_47fd + dw Func_4802 + dw Func_480d + dw Func_4812 + +Func_47fd: ; $47fd (1:47fd) + call $5d1f + jr Func_481b + +Func_4802: ; $4802 (1:4802) + ld hl, $cc38 + ld a, [hli] + or [hl] + ret z + call $5d27 + jr Func_481b + +Func_480d: ; $480d (1:480d) + call $5d2f + jr Func_481b + +Func_4812: ; $4812 (1:4812) + ld hl, $cc4b + ld a, [hli] + or [hl] + ret z + call $5d37 + +Func_481b: ; $481b (1:481b) + ld hl, $cc04 + ld a, $01 + xor [hl] + ld [hl], a + ret LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) call DrawWideTextBox @@ -608,7 +706,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) ld a, c ret -CheckIfMoveExists: +CheckIfMoveExists: ; 4872 (1:4872) push hl push de push bc -- cgit v1.2.3 From 798a5c1a7d7cc8e02cd649241b357f00871d1290 Mon Sep 17 00:00:00 2001 From: anmart Date: Tue, 23 Feb 2016 11:26:15 -0500 Subject: Created wCardBuffer label macro created macro for wCardBuffer labels and updated references --- src/engine/bank1.asm | 10 +++++----- src/engine/home.asm | 8 ++++---- src/macros.asm | 38 ++++++++++++++++++++++++++++++++++++++ src/wram.asm | 5 +++-- 4 files changed, 50 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 3736930..2f965fb 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -667,7 +667,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) ld hl, DuelAttackPointerTable xor a ld [$cbc7], a - ld de, wCardBuffer1 + $10 + ld de, wCardBuffer1Move1Name call CheckIfMoveExists jr c, .checkForSecondAttackSlot ldh a, [$ff98] @@ -678,7 +678,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) push hl push bc ld e, b - ld hl, wCardBuffer1 + $10 + ld hl, wCardBuffer1Move1Name call $5c33 pop bc pop hl @@ -686,7 +686,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823) inc b .checkForSecondAttackSlot - ld de, wCardBuffer1 + $23 + ld de, wCardBuffer1Move2Name call CheckIfMoveExists jr c, .finishLoadingAttacks ldh a, [$ff98] @@ -716,10 +716,10 @@ CheckIfMoveExists: ; 4872 (1:4872) ld a, [de] or c jr z, .returnNoMoveFound - ld hl, $0006 + ld hl, wCardBuffer1Move1Category - (wCardBuffer1Move1Name + 1) add hl, de ld a, [hl] - and $FF - RESIDUAL + and $ff - RESIDUAL cp POKEMON_POWER jr z, .returnNoMoveFound or a diff --git a/src/engine/home.asm b/src/engine/home.asm index 148da07..71d70c5 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2996,7 +2996,7 @@ Func_1aac: ; 1aac (0:1aac) add DUELVARS_ARENA_CARD call GetTurnDuelistVariable call Func_1376 - ld a, [wCardBuffer1 + $7] + ld a, [wCardBuffer1ID] ld [wccc4], a call Func_1ad3 pop af @@ -5987,7 +5987,7 @@ Func_3432: ; 3432 (0:3432) ld e, a ld d, $0 call Func_2f0a - ld a, [wCardBuffer2 + $9] + ld a, [wCardBuffer2Stage] or a ret z ld e, $5 @@ -6252,7 +6252,7 @@ Func_3730: ; 3730 (0:3730) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call Func_138c - ld a, [wCardBuffer2 + $33] + ld a, [wCardBuffer2Weakness] ret ; 0x3743 @@ -6266,7 +6266,7 @@ Func_374a: ; 374a (0:374a) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call Func_138c - ld a, [wCardBuffer2 + $34] + ld a, [wCardBuffer2Resistance] ret ; 0x375d diff --git a/src/macros.asm b/src/macros.asm index f1a850d..1405c8a 100755 --- a/src/macros.asm +++ b/src/macros.asm @@ -311,3 +311,41 @@ ENDM tx: MACRO dw \1_ ENDM + +card_data_struct: MACRO +\1Type:: db +\1Gfx:: dw +\1Name:: dw +\1Rarity:: db +\1Set:: db +\1ID:: db +\1HP:: db +\1Stage:: db +\1PreEvoName:: dw +\1Move1:: move_data_struct \1Move1 +\1Move2:: move_data_struct \1Move2 +\1RetreatCost:: db +\1Weakness:: db +\1Resistance:: db +\1Kind:: dw +\1PokedexNumber:: db +\1Unknown1:: db +\1Level:: db +\1Length:: dw +\1Weight:: dw +\1Description:: dw +\1Unknown2:: db +ENDM + +move_data_struct: MACRO +\1Energy:: ds $4 +\1Name:: dw +\1Description:: ds $4 +\1Damage:: db +\1Category:: db +\1EffectCommands:: dw +\1Flag1:: db +\1Flag2:: db +\1Flag3:: db +\1Unknown:: ds $2 +ENDM diff --git a/src/wram.asm b/src/wram.asm index ddee677..7c7c774 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -1,4 +1,5 @@ INCLUDE "constants.asm" +INCLUDE "macros.asm" ;---------------------------------------------------------- ;--- Bank 0: $Cxxx ---------------------------------------- @@ -413,10 +414,10 @@ wDuelTheme:: ; cc1a ; Can be data from a card on either side of the field or hand, or from a card in the bench, depending on the duel state. ; Sometimes the two buffers even hold the same card's data. wCardBuffer1:: ; cc24 - ds CARD_DATA_LENGTH + card_data_struct wCardBuffer1 wCardBuffer2:: ; cc65 - ds CARD_DATA_LENGTH + card_data_struct wCardBuffer2 ds $4 -- cgit v1.2.3