summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2016-01-17 00:57:08 +0100
committerxCrystal <rgr.crystal@gmail.com>2016-01-17 00:57:08 +0100
commit2adaf3c8373de59f8557a48683386f7729bb49ae (patch)
treea77dbebb0b68554695c227d93bf4478a7dbbae74
parentc57303c887f376ab8d9c2b7edbf84658ddd1d017 (diff)
dissasemble 2fcb-302c
-rw-r--r--src/data/move_card_effects.asm (renamed from src/data/move_effects.asm)0
-rwxr-xr-xsrc/engine/bank6.asm2
-rwxr-xr-xsrc/engine/home.asm94
-rwxr-xr-xsrc/wram.asm11
4 files changed, 104 insertions, 3 deletions
diff --git a/src/data/move_effects.asm b/src/data/move_card_effects.asm
index 1dab5a8..1dab5a8 100644
--- a/src/data/move_effects.asm
+++ b/src/data/move_card_effects.asm
diff --git a/src/engine/bank6.asm b/src/engine/bank6.asm
index 409b69a..d59a510 100755
--- a/src/engine/bank6.asm
+++ b/src/engine/bank6.asm
@@ -1,6 +1,6 @@
INCBIN "baserom.gbc",$18000,$186f7 - $18000
-INCLUDE "data/move_effects.asm"
+INCLUDE "data/move_card_effects.asm"
INCBIN "baserom.gbc",$18f9c,$1996e - $18f9c
diff --git a/src/engine/home.asm b/src/engine/home.asm
index dd06781..e3b7192 100755
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -3765,7 +3765,99 @@ LoadCardGfx: ; 2fa0 (0:2fa0)
ret
; 0x2fcb
-INCBIN "baserom.gbc",$2fcb,$302c - $2fcb
+Func_2fcb: ; 2fcb (0:2fcb)
+ ld a, $1d
+ call BankpushHome
+ ld c, $10
+ call CopyGfxData
+ call BankpopHome
+ ret
+; 0x2fd9
+
+TryExecuteCommandFunction: ; 2fd9 (0:2fd9)
+; Checks if the command ID at a is one of the commands of the move or card effect currently in use,
+; and executes its associated function if so.
+; input: a = move effect / card function command ID
+ push af
+; grab pointer to command list from wCurrentMoveEffectOrCardFunction
+ ld hl, wCurrentMoveEffectOrCardFunction
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop af
+ call CheckMatchingCommand
+ jr nc, .executeFunction
+; return if input command ID wasn't found
+ or a
+ ret
+
+.executeFunction
+; executes the function at [wce22]:hl
+ ld a, [hBankROM]
+ push af
+ ld a, [wce22]
+ call BankswitchHome
+ or a
+ call CallF
+ push af
+; restore original bank and return
+ pop bc
+ pop af
+ call BankswitchHome
+ push bc
+ pop af
+ ret
+; 0x2ffe
+
+CheckMatchingCommand: ; 2ffe (0:2ffe)
+; input:
+; a = command ID to check
+; hl = pointer to current move effect or trainer card command list
+; return nc if command ID matching a is found, c otherwise
+ ld c, a
+ ld a, l
+ or h
+ jr nz, .notNullPointer
+; return c if pointer is $0000
+ scf
+ ret
+
+.notNullPointer
+ ld a, [hBankROM]
+ push af
+ ld a, BANK(MoveEffectAndTrainerCardCommands)
+ call BankswitchHome
+; store the bank number of command functions ($b) in wce22
+ ld a, $b
+ ld [wce22],a
+.checkCommandLoop
+ ld a, [hli]
+ or a
+ jr z, .noMoreCommands
+ cp c
+ jr z, .matchingCommandFound
+; skip function pointer for this command and move to the next one
+ inc hl
+ inc hl
+ jr .checkCommandLoop
+
+.matchingCommandFound
+; load function pointer for this command
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+; restore bank and return nc
+ pop af
+ call BankswitchHome
+ or a
+ ret
+; restore bank and return c
+.noMoreCommands
+ pop af
+ call BankswitchHome
+ scf
+ ret
+; 0x302c
; loads the deck id in a from DeckPointers
; sets carry flag if an invalid deck id is used
diff --git a/src/wram.asm b/src/wram.asm
index 18bb3ed..f33c488 100755
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -146,11 +146,20 @@ wCardBuffer1:: ; c224
wCardBuffer2:: ; cc65
ds CARD_DATA_LENGTH
- ds $67
+ ds $c
+
+wCurrentMoveEffectOrCardFunction:: ; ccb2
+ ds $1
+ ds $5a
wUppercaseFlag:: ; cd0d
ds $1
+ ds $114
+; During a duel, this is always $b after the first attack.
+; $b is the bank where the functions associated to card or effect commands are.
+; Its only purpose seems to be store this value to be read by TryExecuteCommandFunction.
+wce22:: ; ce22
;--- Bank 1: $Dxxx ----------------------------------------