summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2018-06-01 13:46:32 +0200
committerxCrystal <rgr.crystal@gmail.com>2018-06-01 13:46:32 +0200
commit69b4bec8e640ae2702718d93acfda183fd39cc7e (patch)
tree557a9b0e283c204bc76fcbda8fda41fb2d429415 /src
parent1c82f51723c8c2eb347f73a16e05c9a30199aabe (diff)
Clarify ConvertSpecialTrainerCardToPokemon
Diffstat (limited to 'src')
-rw-r--r--src/engine/bank01.asm23
-rw-r--r--src/engine/home.asm4
-rw-r--r--src/hram.asm2
3 files changed, 16 insertions, 13 deletions
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index 7933fc4..6a21178 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -3436,39 +3436,42 @@ AIUseEnergyCard: ; 69a5 (1:69a5)
INCROM $69c5, $6d84
-; converts clefairy doll/mysterious fossil to pokemon card
-ConvertTrainerCardToPokemon: ; 6d84 (1:6d84)
+; given the deck index of a turn holder's card in register a,
+; and a pointer in hl to the wLoadedCard* buffer where the card data is loaded,
+; check if the card is Clefairy Doll or Mysterious Fossil, and, if so, convert it
+; to a Pokemon card in the wLoadedCard* buffer, using .trainer_to_pkmn_data.
+ConvertSpecialTrainerCardToPokemon: ; 6d84 (1:6d84)
ld c, a
ld a, [hl]
cp TYPE_TRAINER
- ret nz
+ ret nz ; return if the card is not TRAINER type
push hl
ldh a, [hWhoseTurn]
ld h, a
ld l, c
ld a, [hl]
- and TYPE_TRAINER
+ and CARD_LOCATION_PLAY_AREA
pop hl
- ret z
+ ret z ; return if the card is not in the arena or bench
ld a, e
cp MYSTERIOUS_FOSSIL
jr nz, .check_for_clefairy_doll
ld a, d
- cp $00
+ cp $00 ; MYSTERIOUS_FOSSIL >> 8
jr z, .start_ram_data_overwrite
ret
.check_for_clefairy_doll
cp CLEFAIRY_DOLL
ret nz
ld a, d
- cp $00
+ cp $00 ; CLEFAIRY_DOLL >> 8
ret nz
.start_ram_data_overwrite
push de
- ld [hl], COLORLESS
+ ld [hl], TYPE_PKMN_COLORLESS
ld bc, CARD_DATA_HP
add hl, bc
- ld de, .data_to_overwrite
+ ld de, .trainer_to_pkmn_data
ld c, CARD_DATA_UNKNOWN2 - CARD_DATA_HP
.loop
ld a, [de]
@@ -3479,7 +3482,7 @@ ConvertTrainerCardToPokemon: ; 6d84 (1:6d84)
pop de
ret
-.data_to_overwrite
+.trainer_to_pkmn_data
db 10 ; CARD_DATA_HP
ds $07 ; CARD_DATA_MOVE1_NAME - (CARD_DATA_HP + 1)
tx DiscardName ; CARD_DATA_MOVE1_NAME
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 240d016..f3b5baf 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -3499,7 +3499,7 @@ LoadCardDataToBuffer1_FromDeckIndex: ; 1376 (0:1376)
call LoadCardDataToBuffer1_FromCardID
pop af
ld hl, wLoadedCard1
- bank1call ConvertTrainerCardToPokemon
+ bank1call ConvertSpecialTrainerCardToPokemon
ld a, e
pop bc
pop de
@@ -3516,7 +3516,7 @@ LoadCardDataToBuffer2_FromDeckIndex: ; 138c (0:138c)
call LoadCardDataToBuffer2_FromCardID
pop af
ld hl, wLoadedCard2
- bank1call ConvertTrainerCardToPokemon
+ bank1call ConvertSpecialTrainerCardToPokemon
ld a, e
pop bc
pop de
diff --git a/src/hram.asm b/src/hram.asm
index b96ee37..9cb5e8c 100644
--- a/src/hram.asm
+++ b/src/hram.asm
@@ -116,4 +116,4 @@ hffb5:: ; ffb5
; used in DivideBCbyDE
hffb6:: ; ffb6
- ds 1 \ No newline at end of file
+ ds 1