diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2016-03-07 21:44:32 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2016-03-07 22:16:50 +0100 | 
| commit | 390500b3f1cf30bf2369721392d6ab2ef6f5a73b (patch) | |
| tree | 822823ac1b491da0218fc8467233dad4499d4d14 /src | |
| parent | 8289a369312c524ff6dd9ef81e4be989335a9696 (diff) | |
disassemble GetAttachedEnergies and HandleEnergyBurn
Diffstat (limited to 'src')
| -rw-r--r-- | src/constants/card_data_constants.asm | 4 | ||||
| -rw-r--r-- | src/engine/effect_functions.asm | 4 | ||||
| -rwxr-xr-x | src/engine/home.asm | 96 | ||||
| -rwxr-xr-x | src/wram.asm | 12 | 
4 files changed, 110 insertions, 6 deletions
| diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index bc4e6d3..1148490 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -24,6 +24,10 @@ DOUBLE_COLORLESS_ENERGY_CARD EQU $E  TRAINER_CARD EQU $10 +NUM_TYPES EQU FIRE_ENERGY_CARD - FIRE + +ENERGY_CARD_F EQU 3 +  ;;; rarity  CIRCLE    EQU $0  DIAMOND   EQU $1 diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index df4bb99..a749bd8 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -33,7 +33,7 @@ SleepEffect: ; 2c030 (b:4030)  	jr applyEffect  applyEffect -	ld a, [$ff97] +	ldh a, [hWhoseTurn]  	ld hl, $cc05  	cp [hl]  	jr nz, .canInduceStatus @@ -67,7 +67,7 @@ applyEffect  	ld hl, $ccce  	add hl, de  	call SwapTurn -	ld a, [$ff97] +	ldh a, [hWhoseTurn]  	ld [hli], a  	call SwapTurn  	ld [hl], b diff --git a/src/engine/home.asm b/src/engine/home.asm index 2d70bef..a435fb5 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2454,7 +2454,77 @@ LoadDeckCardToBuffer2: ; 138c (0:138c)  	ret  ; 0x13a2 -INCBIN "baserom.gbc",$13a2,$15ef - $13a2 +INCBIN "baserom.gbc",$13a2,$159f - $13a2 + +; 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). +; one or more location constants (so long as they don't clash with the arena location constant) +; can be specified in register e; if so, energies found in that location will be counted too. +GetAttachedEnergies: ; 159f (0:159f) +	push hl +	push de +	push bc +	xor a +	ld c, NUM_TYPES +	ld hl, wAttachedEnergies +.zeroEnergiesLoop +	ld [hli], a +	dec c +	jr nz, .zeroEnergiesLoop +	ld a, CARD_LOCATION_ARENA +	or e ; if e is non-0, arena is not the only location that counts +	ld e, a +	ldh a, [hWhoseTurn] +	ld h, a +	ld l, DUELVARS_CARD_LOCATIONS +	ld c, DECK_SIZE +.nextCard +	ld a, [hl] +	cp e +	jr nz, .notInRequestedLocation + +	push hl +	push de +	push bc +	ld a, l +	call LoadDeckCardToBuffer2 +	ld a, [wCardBuffer2Type] +	bit ENERGY_CARD_F, a +	jr z, .notAnEnergyCard +	and $7 ; zero bit 3 to extract the type +	ld e, a +	ld d, $0 +	ld hl, wAttachedEnergies +	add hl, de +	inc [hl] ; increment the number of energy cards of this type +	cp COLORLESS +	jr nz, .notColorless +	inc [hl] ; each colorless energy counts as two +.notAnEnergyCard +.notColorless +	pop bc +	pop de +	pop hl + +.notInRequestedLocation +	inc l +	dec c +	jr nz, .nextCard +	; all 60 cards checked +	ld hl, wAttachedEnergies +	ld c, NUM_TYPES +	xor a +.sumAttachedEnergiesLoop +	add [hl] +	inc hl +	dec c +	jr nz, .sumAttachedEnergiesLoop +	ld [hl], a ; save to wTotalAttachedEnergies +	pop bc +	pop de +	pop hl +	ret +; 0x15ef  ; returns in a how many times card e can be found in location b  ; e = card id to search @@ -6368,7 +6438,29 @@ Func_374a: ; 374a (0:374a)  	ret  ; 0x375d -INCBIN "baserom.gbc",$375d,$377f - $375d +; this function checks if charizard's energy burn is active, and if so +; turns all energies except double colorless energies into fire energies +HandleEnergyBurn: ; 375d (0:375d) +	ld a, DUELVARS_ARENA_CARD +	call GetTurnDuelistVariable +	call GetCardInDeckPosition +	ld a, e +	cp CHARIZARD +	ret nz +	xor a +	call CheckIfUnderAnyCannotUseStatus2 +	ret c +	ld hl, wAttachedEnergies +	ld c, COLORLESS - FIRE +	xor a +.zeroNextEnergy +	ld [hli], a +	dec c +	jr nz, .zeroNextEnergy +	ld a, [wTotalAttachedEnergies] +	ld [wAttachedEnergies], a +	ret +; 0x377f  SetupSound_T: ; 377f (0:377f)  	farcall SetupSound_Ext diff --git a/src/wram.asm b/src/wram.asm index 7458dbe..69c95cb 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -398,7 +398,7 @@ wBenchSelectedPokemon:: ; $cbcb  	ds $1  	ds $3 -; When you're in a duel menu like your hand and you press a, +; When you're in a duel submenu like the cards in your hand and you press A,  ; the following two addresses keep track of which item was selected by the cursor  wSelectedDuelSubMenuItem:: ; $cbcf  	ds $1 @@ -446,7 +446,15 @@ wIsPracticeDuel:: ; cc13  wDuelTheme:: ; cc1a  	ds $1 -	ds $9 + +; holds the energies attached to a given pokemon card. 1 byte for each of the +; 8 energy types (including the unused one that shares byte with the colorless energy) +wAttachedEnergies:: ; cc1b +	ds NUM_TYPES + +; holds the total amount of energies attached to a given pokemon card +wTotalAttachedEnergies:: ; cc23 +	ds $1  ; Used as temporary storage for a loaded card's data  wCardBuffer1:: ; cc24 | 
