summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2016-03-06 22:49:16 +0100
committerxCrystal <rgr.crystal@gmail.com>2016-03-06 22:49:16 +0100
commit2de2ac6a13a00189f16ba28ae932e155e5f6c8aa (patch)
tree599f10ab995ffa4c51983e95c5bfca4eb1564572
parent845e54b091ca11b1c32416515ca10eb477ff5716 (diff)
hTempCardNumber and some clean up
-rwxr-xr-xsrc/engine/bank1.asm17
-rwxr-xr-xsrc/engine/home.asm31
-rw-r--r--src/hram.asm5
3 files changed, 35 insertions, 18 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index 8d68012..d9a29c0 100755
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -252,7 +252,7 @@ DrawCardFromDeck: ; 4225 (1:4225)
ret
.deckNotEmpty
- ldh [$ff98], a
+ ldh [hTempCardNumber], a
call AddCardToHand
ld a, [$cc0d]
cp $00
@@ -490,7 +490,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc)
ld [wSelectedDuelSubMenuItem], a
.tryOpenAttackMenu
- call LoadPokemonAttacksToDuelPointerTable
+ call LoadPokemonMovesToDuelCardOrAttackList
or a
jr nz, .openAttackMenu
text_hl NoSelectableAttackText
@@ -533,7 +533,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc)
ld d, $00
ld hl, wDuelCardOrAttackList
add hl, de
- ld d, [hl] ; card id
+ ld d, [hl] ; card number within the deck (0 to 59)
inc hl
ld e, [hl] ; attack index (0 or 1)
call CopyMoveDataAndDamageToBuffer
@@ -655,11 +655,14 @@ Func_481b: ; $481b (1:481b)
ld [hl], a
ret
-LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823)
+; copies the following to the c510 buffer:
+; if pokemon's second moveslot is empty: <card_no>, 0
+; else: <card_no>, 0, <card_no>, 1
+LoadPokemonMovesToDuelCardOrAttackList: ; 4823 (1:4823)
call DrawWideTextBox
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
- ldh [$ff98], a
+ ldh [hTempCardNumber], a
call LoadDeckCardToBuffer1
ld c, $00
ld b, $0d
@@ -669,7 +672,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823)
ld de, wCardBuffer1Move1Name
call CheckIfMoveExists
jr c, .checkForSecondAttackSlot
- ldh a, [$ff98]
+ ldh a, [hTempCardNumber]
ld [hli], a
xor a
ld [hli], a
@@ -688,7 +691,7 @@ LoadPokemonAttacksToDuelPointerTable: ; 4823 (1:4823)
ld de, wCardBuffer1Move2Name
call CheckIfMoveExists
jr c, .finishLoadingAttacks
- ldh a, [$ff98]
+ ldh a, [hTempCardNumber]
ld [hli], a
ld a, $01
ld [hli], a
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 74af158..307cef4 100755
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -2269,7 +2269,8 @@ ShuffleDeck: ; 10bc (0:10bc)
ld b, a
ld a, DUELVARS_DECK_CARDS
add [hl]
- ld l, a ; hl = position in the wPlayerDeckCards or wOpponentDeckCards array of the first (top) card in the deck
+ ld l, a ; hl = position in the wPlayerDeckCards or wOpponentDeckCards array
+ ; of the first (top) card in the deck
ld a, b ; a = number of cards in the deck
call ShuffleCards
ret
@@ -2282,17 +2283,13 @@ _DrawCardFromDeck: ; 10cf (0:10cf)
call GetTurnDuelistVariable
cp DECK_SIZE
jr nc, .emptyDeck
- ; increment number of cards not in deck
inc a
- ld [hl], a
- ; point to top card in the deck
- add DUELVARS_DECK_CARDS - 1
+ ld [hl], a ; increment number of cards not in deck
+ add DUELVARS_DECK_CARDS - 1 ; point to top card in the deck
ld l, a
- ; grab card number (0-59) from wPlayerDeckCards or wOpponentDeckCards array
- ld a, [hl]
+ ld a, [hl] ; grab card number (0-59) from wPlayerDeckCards or wOpponentDeckCards array
ld l, a
- ; temporarily write $40 to corresponding card location variable
- ld [hl], $40
+ ld [hl], $40 ; temporarily write $40 to corresponding card location variable
pop hl
or a
ret
@@ -2373,7 +2370,21 @@ ShuffleCards: ; 127f (0:127f)
ret
; 0x12a3
-INCBIN "baserom.gbc",$12a3,$1324 - $12a3
+INCBIN "baserom.gbc",$12a3,$1312 - $12a3
+
+Func_1312: ; 1312 (0:1312)
+ push hl
+ ld e, a
+ ld d, $0
+ ld hl, wDuelCardOrAttackList
+ add hl, de
+ ld a, [hl]
+ ldh [hTempCardNumber], a
+ call LoadDeckCardToDE
+ pop hl
+ ldh a, [hTempCardNumber]
+ ret
+; 0x1324
LoadDeckCardToDE: ; 1324 (0:1324)
push af
diff --git a/src/hram.asm b/src/hram.asm
index 68e7e21..08e65aa 100644
--- a/src/hram.asm
+++ b/src/hram.asm
@@ -45,7 +45,10 @@ hWY:: ; ff95
hWhoseTurn:: ; ff97
ds 1
- ds 23
+hTempCardNumber:: ; ff98
+ ds 1
+
+ ds 22
hffaf:: ; ffaf
ds 1