diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2016-01-26 18:25:20 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2016-01-26 18:25:20 +0100 | 
| commit | 51827f0bf6b4f7230bdbfc210b0060b66b73c7ae (patch) | |
| tree | 51d72c3f18f23239940300216dd4a4f2c0272052 | |
| parent | 5a33e213bf35bfb535443e078669877ca4c567f3 (diff) | |
more home incbins
| -rwxr-xr-x | src/engine/bank1.asm | 3 | ||||
| -rwxr-xr-x | src/engine/home.asm | 69 | ||||
| -rwxr-xr-x | src/wram.asm | 11 | 
3 files changed, 72 insertions, 11 deletions
| diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 90b2255..18b3e2d 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -262,6 +262,9 @@ LoadPlayerDeck: ; 6793 (1:6793)  INCBIN "baserom.gbc",$67b2,$7107 - $67b2 +; initializes duel variables such as cards in deck and in hand, or Pokemon in play area +; player turn: [c200, c2ff] +; opponent turn: [c300, c3ff]  InitializeDuelVariables: ; 7107 (1:7107)  	ld a, [hWhoseTurn]  	ld h, a diff --git a/src/engine/home.asm b/src/engine/home.asm index 3d12777..bef33b3 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2139,7 +2139,64 @@ ShuffleDeck: ; 10bc (0:10bc)  	ret  ; 0x10cf -INCBIN "baserom.gbc",$10cf,$127f - $10cf +; draw a card from the deck, saving its location as $40 +; returns c if deck is empty, nc if a card was succesfully drawn +DrawCardFromDeck: ; 10cf (0:10cf) +	push hl +	ld a, wPlayerNumberOfCardsNotInDeck & $ff +	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 (wPlayerDeckCards - 1) & $ff +	ld l, a +	; grab card number (0-59) from wPlayerDeckCards or wOpponentDeckCards array +	ld a, [hl] +	ld l, a +	; temporarily write $40 to corresponding card location variable +	ld [hl], $40 +	pop hl +	or a +	ret + +.emptyDeck +	pop hl +	scf +	ret +; 0x10e8 + +INCBIN "baserom.gbc",$10e8,$1123 - $10e8 + +; adds a card to the hand and increments the number of cards in the hand +; the card is identified by register a, which contains the card number within the deck (0-59) +AddCardToHand: ; 1123 (0:1123) +	push af +	push hl +	push de +	ld e, a +	ld l, a +	ld a, [hWhoseTurn] +	ld h, a +	; write $1 (hand) into the location of this card +	ld [hl], $1 +	; increment number of cards in hand +	ld l, wPlayerNumberOfCardsInHand & $ff +	inc [hl] +	; add card to hand +	ld a, (wPlayerHand - 1) & $ff +	add [hl] +	ld l, a +	ld [hl], e +	pop de +	pop hl +	pop af +	ret +; 0x1139 + +INCBIN "baserom.gbc",$1139,$127f - $1139  ; shuffles the deck by swapping the position of each card with the position of another random card  ; input: @@ -2183,7 +2240,7 @@ ShuffleCards: ; 127f (0:127f)  INCBIN "baserom.gbc",$12a3,$160b - $12a3 -; returns [[hWhoseTurn] * $100 + a] in a +; returns [[hWhoseTurn] << 8 + a] in a  ; i.e. variable a of the player whose turn it is  GetTurnDuelistVariable: ; 160b (0:160b)  	ld l, a @@ -2192,7 +2249,7 @@ GetTurnDuelistVariable: ; 160b (0:160b)  	ld a, [hl]  	ret -; returns [([hWhoseTurn] ^ $1) * $100 + a] in a +; returns [([hWhoseTurn] ^ $1) << 8 + a] in a  ; i.e. variable a of the player whose turn it is not  GetOpposingTurnDuelistVariable: ; 1611 (0:1611)  	ld l, a @@ -2208,9 +2265,9 @@ GetOpposingTurnDuelistVariable: ; 1611 (0:1611)  INCBIN "baserom.gbc",$161e,$1c72 - $161e -; returns [([hWhoseTurn] ^ $1) * $100 + a] in a +; returns [([hWhoseTurn] ^ $1) << 8 + a] in a  ; i.e. variable a of the player whose turn it is not -; Also: [hWhoseTurn] <-- [hWhoseTurn ^ $1] +; Also: [hWhoseTurn] <-- ([hWhoseTurn] ^ $1)  GetOpposingTurnDuelistVariable_SwapTurn: ; 1c72 (0:1c72)  	push af  	push hl @@ -3541,7 +3598,7 @@ DrawWideTextBox: ; 2a9e (0:2a9e)  DrawWideTextBox_WaitForInput: ; 2aab (0:2aab)  	call DrawWideTextBox_PrintText -	 +;	fallthrough  WaitForWideTextBoxInput: ; 2aae (0:2aae)  	xor a  	ld hl, WideTextBoxPromptCursorData diff --git a/src/wram.asm b/src/wram.asm index ffcc81b..fa8beff 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -26,11 +26,12 @@ wPlayerCardLocations:: ; c200  wPlayerHand:: ; c242	  	ds DECK_SIZE -; 60-byte array that indicates in which order the cards are in the deck. -; initially numbers 0 to 59 in order, until deck is shuffled. -; the earlier a card appears in the array, the closer to the top of the deck it is. +; 60-byte array that maps each card to its position in the deck. +; During a duel, each card of the deck is assigned a number between 0 and 59, following the index number order. +; This array is initialized to 00, 01, 02, ..., 59, until deck is shuffled. +; The earlier a card appears in the array, the closer to the top of the deck it is.  wPlayerDeckCards:: ; c27e -	ds $3c +	ds DECK_SIZE  ; stores x = (60 - deck remaining cards)  ; the first x cards in the wPlayerDeckCards array are ignored (e.g. when drawing a card) @@ -87,7 +88,7 @@ wOpponentHand:: ; c342  	ds DECK_SIZE  wOpponentDeckCards:: ; c37e -	ds $3c +	ds DECK_SIZE  wOpponentNumberOfCardsNotInDeck:: ; c3ba	  	ds $1 | 
