diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2016-03-08 00:02:21 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2016-03-08 00:02:21 +0100 | 
| commit | 5893de563f5d8395770eadd0b86a03f52cc384a1 (patch) | |
| tree | 19db9582c4e0bc7b31151b3f09cf781d9600baef | |
| parent | 21999824e7ac492c8f8f689b56fcfd6cf2c98eb4 (diff) | |
disassemble 488f to 4918 (check if enough energies)
| -rwxr-xr-x | src/engine/bank1.asm | 122 | ||||
| -rwxr-xr-x | src/engine/home.asm | 5 | ||||
| -rwxr-xr-x | src/wram.asm | 19 | 
3 files changed, 132 insertions, 14 deletions
| diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index d9a29c0..65de8de 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -520,13 +520,13 @@ OpenBattleAttackMenu: ; 46fc (1:46fc)  	cp $ff ; was B pressed?  	jp z, PrintDuelMenu  	ld [wSelectedDuelSubMenuItem], a -	call $488f -	jr nc, .asm_4759 +	call CheckIfEnoughEnergies +	jr nc, .enoughEnergy  	text_hl NotEnoughEnergyCardsText  	call DrawWideTextBox_WaitForInput  	jr .tryOpenAttackMenu -.asm_4759 +.enoughEnergy  	ldh a, [hCurrentMenuItem]  	add a  	ld e, a @@ -736,7 +736,121 @@ CheckIfMoveExists: ; 4872 (1:4872)  	scf  	jr .return -INCBIN "baserom.gbc",$488f, $4918 - $488f +; check if the arena pokemon card has enough energy attached to it +; in order to use the selected move. +; returns: carry if not enough energy, nc if enough energy. +CheckIfEnoughEnergies: ; 488f (1:488f) +	push hl +	push bc +	ld e, $0 +	call GetAttachedEnergies +	call HandleEnergyBurn +	ldh a, [hCurrentMenuItem] +	add a +	ld e, a +	ld d, $0 +	ld hl, wDuelCardOrAttackList +	add hl, de +	ld d, [hl] ; card number within the deck (0 to 59) +	inc hl +	ld e, [hl] ; attack index (0 or 1) +	call _CheckIfEnoughEnergies +	pop bc +	pop hl +	ret +; 0x48ac + +; check if a pokemon card has enough energy attached to it in order to use a move +; input: +;   d = card number within the deck (0 to 59) +;   e = attack index (0 or 1) +;   wAttachedEnergies and wTotalAttachedEnergies +; returns: carry if not enough energy, nc if enough energy. +_CheckIfEnoughEnergies: ; 48ac (1:48ac) +	push de +	ld a, d +	call LoadDeckCardToBuffer1 +	pop bc +	push bc +	ld de, wCardBuffer1Move1Energy +	ld a, c +	or a +	jr z, .gotMove +	ld de, wCardBuffer1Move2Energy + +.gotMove +	ld hl, wCardBuffer1Move1Name - wCardBuffer1Move1Energy +	add hl, de +	ld a, [hli] +	or [hl] +	jr z, .notUsable +	ld hl, wCardBuffer1Move1Category - wCardBuffer1Move1Energy +	add hl, de +	ld a, [hl] +	cp POKEMON_POWER +	jr z, .notUsable +	xor a +	ld [wAttachedEnergiesAccum], a +	ld hl, wAttachedEnergies +	ld c, (COLORLESS - FIRE) / 2 +.nextEnergyTypePair +	ld a, [de] +	swap a +	call _CheckIfEnoughEnergiesOfType +	jr c, .notEnoughEnergies +	ld a, [de] +	call _CheckIfEnoughEnergiesOfType +	jr c, .notEnoughEnergies +	inc de +	dec c +	jr nz, .nextEnergyTypePair +	ld a, [de] ; colorless energy +	swap a +	and $f +	ld b, a +	ld a, [wAttachedEnergiesAccum] +	ld c, a +	ld a, [wTotalAttachedEnergies] +	sub c +	cp b +	jr c, .notEnoughEnergies +	or a +.asm_48fb +	pop de +	ret + +.notUsable +.notEnoughEnergies +	scf +	jr .asm_48fb +; 0x4900 + +; given the amount of energies of a specific type required for an attack in the +; lower nybble of register a, test if the pokemon card has enough energies of that type +; to use the move. Return carry if not enough energy, nc if enough energy. +_CheckIfEnoughEnergiesOfType: ; 4900 (1:4900) +	and $f +	push af +	push hl +	ld hl, wAttachedEnergiesAccum +	add [hl] +	ld [hl], a ; accumulate the amount of energies required +	pop hl +	pop af +	jr z, .enoughEnergies ; jump if no energies of this type are required +	cp [hl] +	; jump if the energies required of this type are not more than the amount attached +	jr z, .enoughEnergies +	jr c, .enoughEnergies +	inc hl +	scf +	ret + +.enoughEnergies +	inc hl +	or a +	ret +; 0x4918  CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918)  	ld a, DUELVARS_ARENA_CARD_STATUS diff --git a/src/engine/home.asm b/src/engine/home.asm index cab1232..b336a9e 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2456,10 +2456,11 @@ LoadDeckCardToBuffer2: ; 138c (0:138c)  INCBIN "baserom.gbc",$13a2,$159f - $13a2 -; this function iterates through the card locations array to find out which and how many +; 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) +; 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. +; Feedback is returned in wAttachedEnergies and wTotalAttachedEnergies.  GetAttachedEnergies: ; 159f (0:159f)  	push hl  	push de diff --git a/src/wram.asm b/src/wram.asm index 69c95cb..a0b46e9 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -375,7 +375,7 @@ wcba3:: ; cba3  wSerialRecvIndex:: ; cba4  	ds $1 -wSerialRecvBuf:: ; $cba5 - $cbc4 +wSerialRecvBuf:: ; cba5 - cbc4  	ds $20  	ds $1 @@ -383,27 +383,30 @@ wSerialRecvBuf:: ; $cba5 - $cbc4  ; In a duel, the main menu current or last selected menu item  ; From 0 to 5: Hand, Attack, Check, Pkmn Power, Retreat, Done -wCurrentDuelMenuItem:: ; $cbc6 +wCurrentDuelMenuItem:: ; cbc6  	ds $1  ; When we're viewing a card's information, the page we are currently at  ; For Pokemon cards, values from $1 to $6 (two pages for move descriptions)  ; For Energy cards, it's always $9  ; For Trainer cards, $d or $e (two pages for trainer card descriptions) -wCardPageNumber:: ; $cbc7 +wCardPageNumber:: ; cbc7  	ds $1  	ds $3 -wBenchSelectedPokemon:: ; $cbcb +wBenchSelectedPokemon:: ; cbcb +	ds $1 +	ds $2 + +wAttachedEnergiesAccum:: ; cbce  	ds $1 -	ds $3  ; 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 +wSelectedDuelSubMenuItem:: ; cbcf  	ds $1 -wSelectedDuelSubMenuScrollOffset:: ; $cbd0 +wSelectedDuelSubMenuScrollOffset:: ; cbd0  	ds $1  	ds $35 @@ -414,7 +417,7 @@ wcc06:: ; cc06  ; 1 = player whose turn it is has won the duel  ; 2 = player whose turn it is has lost the duel  ; 3 = duel ended in a draw -wDuelFinished:: ; $cc07 +wDuelFinished:: ; cc07  	ds $1  	ds $1 | 
