diff options
author | xCrystal <rgr.crystal@gmail.com> | 2018-03-10 18:52:52 +0100 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2018-03-10 18:52:52 +0100 |
commit | 3b49912566c7eb3297a701d1434d3bcc4e4bcfd4 (patch) | |
tree | df551181b2c81b19bfe957c236dcb47056f1e692 /src | |
parent | c170a328cec11702656541f734cf6fa6392a6434 (diff) |
more bank 1 disasm related to drawing cards and gfx
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/card_data_constants.asm | 5 | ||||
-rw-r--r-- | src/constants/duel_constants.asm | 2 | ||||
-rw-r--r-- | src/engine/bank1.asm | 133 | ||||
-rw-r--r-- | src/engine/home.asm | 63 | ||||
-rw-r--r-- | src/gfx.asm | 4 | ||||
-rw-r--r-- | src/gfx/duel/card_headers.png (renamed from src/gfx/duel/card_types.png) | bin | 803 -> 803 bytes |
6 files changed, 179 insertions, 28 deletions
diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 3af82a1..e857aa6 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -195,3 +195,8 @@ CARDPAGE_POKEMON_DESCRIPTION EQU $06 CARDPAGE_ENERGY EQU $09 CARDPAGE_TRAINER_1 EQU $0d CARDPAGE_TRAINER_2 EQU $0e + +; card type header constants ($10-tile headers in DuelCardHeaderGraphics) +HEADER_TRAINER EQU $00 +HEADER_ENERGY EQU $01 +HEADER_POKEMON EQU $02 diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index a4c6697..eaa9a65 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -1,5 +1,7 @@ MAX_BENCH_POKEMON EQU 5 MAX_PLAY_AREA_POKEMON EQU 6 ; arena + bench +MAX_HP EQU 120 +HP_BAR_LENGTH EQU MAX_HP / 10 ; hWhoseTurn constants PLAYER_TURN EQUS "HIGH(wPlayerDuelVariables)" diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 0bf8374..6c9cd9a 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -288,6 +288,7 @@ Func_420b: ; 420b (1:420b) ret ; 0x4225 +; handle the turn of the duelist identified by hWhoseTurn HandleTurn: ; 4225 (1:4225) ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable @@ -311,16 +312,19 @@ HandleTurn: ; 4225 (1:4225) call AddCardToHand ld a, [wDuelistType] cp DUELIST_TYPE_PLAYER - jr z, Func_4262 + jr z, HandleTurn_PlayerDrewCard call SwapTurn call IsClairvoyanceActive call SwapTurn - call c, Func_4b2c + call c, DisplayPlayerDrawCardScreen jr DuelMainInterface -Func_4262: - call Func_4b2c - call Func_100b +; display the animation of the player drawing the card at hTempCardIndex_ff98 +; save duel state to SRAM, and fall through to DuelMainInterface to effectively +; begin the turn +HandleTurn_PlayerDrewCard: + call DisplayPlayerDrawCardScreen + call SaveDuelStateToSRAM ; fallthrough Func_4268: @@ -1441,11 +1445,12 @@ Func_4ae9: ; 4ae9 (1:4ae9) ret ; 0x4b2c -Func_4b2c: ; 4b2c (1:4b2c) +; display the animation of the player drawing the card at hTempCardIndex_ff98 +DisplayPlayerDrawCardScreen: ; 4b2c (1:4b2c) ldtx hl, YouDrewText ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex - call $5e5f + call _DisplayPlayerDrawCardScreen ret ; 0x4b38 @@ -1920,7 +1925,7 @@ DrawDuelHUD: ; 5093 (1:5093) ld a, DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable ld e, a ; cur HP - call $6614 + call DrawHPBar ld hl, wcbc9 ld b, [hl] inc hl @@ -1929,15 +1934,15 @@ DrawDuelHUD: ; 5093 (1:5093) call BCCoordToBGMap0Address push de ld hl, wDefaultText - ld b, 6 ; first row of the HP bar + ld b, HP_BAR_LENGTH / 2 ; first row of the HP bar call SafeCopyDataHLtoDE pop de ld hl, BG_MAP_WIDTH add hl, de ld e, l ld d, h - ld hl, wDefaultText + 6 - ld b, 6 ; second row of the HP bar + ld hl, wDefaultText + HP_BAR_LENGTH / 2 + ld b, HP_BAR_LENGTH / 2 ; second row of the HP bar call SafeCopyDataHLtoDE ; print number of attached Pluspower and Defender with respective icon, if any @@ -2869,7 +2874,74 @@ JPWriteByteToBGMap0: ; 5b7a (1:5b7a) jp WriteByteToBGMap0 ; 0x5b7d - INCROM $5b7d, $5fdd + INCROM $5b7d, $5e5f + +; display the animation of the player drawing the card loaded in wLoadedCard1 +; print the text at hl (which is YouDrewText) +_DisplayPlayerDrawCardScreen: ; 5e5f (1:5e5f) + push hl + call DrawLargePictureOfCard + ld a, 18 + call CopyCardNameAndLevel + ld [hl], TX_END + ld hl, 0 + call LoadTxRam2 + pop hl + call DrawWideTextBox_WaitForInput + ret +; 0x5e75 + +; draw a large picture of the card loaded in wLoadedCard1, including its image +; and a header indicating the type of card (TRAINER, ENERGY, PoKéMoN) +DrawLargePictureOfCard: ; 5e75 (1:5e75) + call ZeroObjectPositionsAndToggleOAMCopy + call EmptyScreen + call LoadDuelHUDTiles + call Func_5aeb + ld a, $08 + ld [wcac2], a + call LoadCardOrDuelMenuBorderTiles + ld e, HEADER_TRAINER + ld a, [wLoadedCard1Type] + cp TYPE_TRAINER + jr z, .draw + ld e, HEADER_ENERGY + and TYPE_ENERGY + jr nz, .draw + ld e, HEADER_POKEMON +.draw + ld a, e + call LoadCardTypeHeaderTiles + ld de, v0Tiles1 + $20 tiles + call LoadLoaded1CardGfx + call SetBGP6OrSGB3ToCardPalette + call FlushAllPalettesOrSendPal23Packet + ld hl, LargeCardTileData + call WriteDataBlocksToBGMap0 + lb de, 6, 3 + call ApplyBGP6OrSGB3ToCardImage + ret +; 0x5eb7 + +LargeCardTileData: ; 5eb7 (1:5eb7) + db 5, 0, $d0, $d4, $d4, $d4, $d4, $d4, $d4, $d4, $d4, $d1, 0 ; top border + db 5, 1, $d6, $e0, $e1, $e2, $e3, $e4, $e5, $e6, $e7, $d7, 0 ; header top + db 5, 2, $d6, $e8, $e9, $ea, $eb, $ec, $ed, $ee, $ef, $d7, 0 ; header bottom + db 5, 3, $d6, $a0, $a6, $ac, $b2, $b8, $be, $c4, $ca, $d7, 0 ; image + db 5, 4, $d6, $a1, $a7, $ad, $b3, $b9, $bf, $c5, $cb, $d7, 0 ; image + db 5, 5, $d6, $a2, $a8, $ae, $b4, $ba, $c0, $c6, $cc, $d7, 0 ; image + db 5, 6, $d6, $a3, $a9, $af, $b5, $bb, $c1, $c7, $cd, $d7, 0 ; image + db 5, 7, $d6, $a4, $aa, $b0, $b6, $bc, $c2, $c8, $ce, $d7, 0 ; image + db 5, 8, $d6, $a5, $ab, $b1, $b7, $bd, $c3, $c9, $cf, $d7, 0 ; image + db 5, 9, $d6, 0 ; empty line 1 (left) + db 14, 9, $d7, 0 ; empty line 1 (right) + db 5, 10, $d6, 0 ; empty line 2 (left) + db 14, 10, $d7, 0 ; empty line 2 (right) + db 5, 11, $d2, $d5, $d5, $d5, $d5, $d5, $d5, $d5, $d5, $d3, 0 ; bottom border + db $ff +; 0x5f4a + + INCROM $5f4a, $5fdd ; return carry if the turn holder has any Pokemon with non-zero HP in the play area. ; return how many Pokemon with non-zero HP in b. @@ -3023,6 +3095,7 @@ MenuParameters_60c6: ; 60c6 (1:60c6) INCROM $60ce, $63bb +; given a card's status in a, print the Poison symbol at bc if it's poisoned CheckPrintPoisoned: ; 63bb (1:63bb) push af and POISONED @@ -3035,6 +3108,7 @@ CheckPrintPoisoned: ; 63bb (1:63bb) ret ; 0x63c7 +; given a card's status in a, print the Poison symbol at bc if it's double poisoned CheckPrintDoublePoisoned: ; 63c7 (1:63c7) push af and DOUBLE_POISONED - POISONED @@ -3042,6 +3116,8 @@ CheckPrintDoublePoisoned: ; 63c7 (1:63c7) jr CheckPrintPoisoned.print ; not double poisoned ; 0x63ce +; given a card's status in a, print the Confusion, Sleep, or Paralysis symbol at bc +; for each of those status that is active CheckPrintCnfSlpPrz: ; 63ce (1:63ce) push af push hl @@ -3110,7 +3186,36 @@ PrintPlayAreaCardAttachedEnergies: ; 63e6 (1:63e6) ret ; 0x6423 - INCROM $6423, $6785 + INCROM $6423, $6614 + +; input d, e: max. HP, current HP +DrawHPBar: ; 6614 (1:6614) + ld a, MAX_HP + ld c, LOW("< >") + call .fill_hp_bar ; empty bar + ld a, d + ld c, LOW("<🌕>") + call .fill_hp_bar ; fill (max. HP) with HP counters + ld a, d + sub e + ld c, LOW("<🌑>") + ; fill (max. HP - current HP) with damaged HP counters +.fill_hp_bar + or a + ret z + ld hl, wDefaultText + ld b, HP_BAR_LENGTH +.tile_loop + ld [hl], c + inc hl + dec b + ret z + sub MAX_HP / HP_BAR_LENGTH + jr nz, .tile_loop + ret +; 0x6635 + + INCROM $6635, $6785 Func_6785: ; 6785 (1:6785) call EnableSRAM @@ -3232,7 +3337,7 @@ AIUseEnergyCard: ; 69a5 (1:69a5) call PutHandCardInPlayArea ldh a, [hTemp_ffa0] call LoadCardDataToBuffer1_FromDeckIndex - call $5e75 + call DrawLargePictureOfCard call $68e4 ld a, $1 ld [wAlreadyPlayedEnergy], a diff --git a/src/engine/home.asm b/src/engine/home.asm index e351722..73b5a3b 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2691,7 +2691,9 @@ Func_0fe9: ; 0fe9 (0:0fe9) ret ; 0x100b -Func_100b: ; 100b (0:100b) +; save duel state to SRAM +; called between each two-player turn, just after player draws card +SaveDuelStateToSRAM: ; 100b (0:100b) ld a, $2 call BankswitchSRAM call $669d @@ -4281,11 +4283,11 @@ Func_1730: ; 1730 (0:1730) call SubstractHP ld a, [wcac2] cp $1 - jr nz, .asm_17e8 + jr nz, .skip_draw_huds push hl - bank1call $503a + bank1call DrawDuelHUDs pop hl -.asm_17e8 +.skip_draw_huds call PrintKnockedOutIfHLZero jr Func_17fb @@ -5675,7 +5677,7 @@ FillRectangle: ; 1f5f (0:1f5f) INCROM $1f96, $208d -; load the Deck and Hand icons for the "Draw X card(s) from the deck." screen +; loads the Deck and Hand icons for the "Draw X card(s) from the deck." screen LoadDuelDrawCardsScreenTiles: ; 208d (0:208d) ld hl, DuelOtherGraphics + $29 tiles ld de, v0Tiles1 + $74 tiles @@ -5683,7 +5685,26 @@ LoadDuelDrawCardsScreenTiles: ; 208d (0:208d) jp CopyFontsOrDuelGraphicsTiles ; 0x2098 - INCROM $2098, $20b0 +; loads the 8 tiles that make up the border of the main duel menu as well as the border +; of a large card picture (displayed after drawing the card or placing it in the arena). +LoadCardOrDuelMenuBorderTiles: ; 2098 (0:2098) + ld hl, DuelOtherGraphics + $15 tiles + ld de, v0Tiles1 + $50 tiles + ld b, $08 + jr CopyFontsOrDuelGraphicsTiles +; 0x20a2 + +; loads the graphics of a card type header, used to display a picture of a card after drawing it +; or placing it in the arena. register e determines which header (TRAINER, ENERGY, PoKéMoN) +LoadCardTypeHeaderTiles: ; 20a2 (0:20a2) + ld d, a + ld e, 0 + ld hl, DuelCardHeaderGraphics - $4000 + add hl, de + ld de, v0Tiles1 + $60 tiles + ld b, $10 + jr CopyFontsOrDuelGraphicsTiles +; 0x20b0 ; loads the symbols that are displayed near the names of a list of cards in the hand or discard pile LoadDuelCardSymbolTiles: ; 20b0 (0:20b0) @@ -5755,14 +5776,14 @@ LoadDuelCoinTossResultTiles: ; 210f (0:210f) LoadDuelHUDTiles: ; 2119 (0:2119) ld hl, DuelHUDGraphics - $4000 ld de, v0Tiles2 ; destination - ld b, (DuelCardTypeGraphics - DuelHUDGraphics) / TILE_SIZE ; number of tiles + ld b, (DuelCardHeaderGraphics - DuelHUDGraphics) / TILE_SIZE ; number of tiles ; fallthrough ; if hl ≤ $3fff ; copy b tiles from Gfx1:(hl+$4000) to de ; if $4000 ≤ hl ≤ $7fff ; copy b tiles from Gfx2:hl to de -CopyFontsOrDuelGraphicsTiles: +CopyFontsOrDuelGraphicsTiles: ; 2121 (0:2121) ld a, BANK(Fonts); BANK(DuelGraphics); BANK(VWF) call BankpushHome ld c, TILE_SIZE @@ -5861,9 +5882,9 @@ Func_21f2: ; 21f2 (0:21f2) jr z, .asm_2221 cp $a jr z, .asm_224d - cp $5 + cp TX_SYMBOL jr z, .asm_2225 - cp $6 + cp TX_START jr z, .asm_220f cp $7 jr z, .asm_2215 @@ -5957,6 +5978,10 @@ Func_2275: ; 2275 (0:2275) jr nz, .asm_2292 ret +; wcd0a <- 0 +; hffac <- 0 +; wcd0b <- 0 +; hffaf <- $f Func_2298: ; 2298 (0:2298) xor a ld [wcd0a], a @@ -5966,6 +5991,8 @@ Func_2298: ; 2298 (0:2298) ldh [hffaf], a ret +; Func_22ae +; hffae <- a Func_22a6: ; 22a6 (0:22a6) push af call Func_22ae @@ -5973,6 +6000,13 @@ Func_22a6: ; 22a6 (0:22a6) ldh [hffae], a ret +; hffad <- d +; hffae <- 0 +; wcd09 <- 0 +; hffaa <- BGMap0(e) +; hffab <- BGMap0(d) +; Func_2298 +;; writes BGMap0-translated DE to (hffab,hffaa) Func_22ae: ; 22ae (0:22ae) push hl ld a, d @@ -6018,6 +6052,11 @@ Func_22ca: ; 22ca (0:22ca) call Func_235e jr .asm_22e9 +; wcd05 <- a +; &(hffab,hffaa) <- a +; (hffab,hffaa) ++ +; hffac ++ +;; writes a to addr pointed to by (hffab,hffaa), then increments (hffab,hffaa) and hffac Func_22f2: ; 22f2 (0:22f2) ld [wcd05], a ld hl, hffaa @@ -6180,7 +6219,7 @@ Uppercase: ; 23b1 (0:23b1) Func_23c1: ; 23c1 (0:23c1) ld a, [hl] - cp $6 + cp TX_START jr nz, .asm_23cf call Func_23d3 inc b @@ -6204,7 +6243,7 @@ Func_23d3: ; 23d3 (0:23d3) jr c, .asm_23ec cp $10 jr nc, .asm_23ec - cp $5 + cp TX_SYMBOL jr nz, .asm_23d8 inc b jr .asm_23f4 diff --git a/src/gfx.asm b/src/gfx.asm index c6308b4..475fd93 100644 --- a/src/gfx.asm +++ b/src/gfx.asm @@ -13,8 +13,8 @@ DuelGraphics:: DuelHUDGraphics:: ; 76968 (1d:6968) INCBIN "gfx/duel/hud.2bpp" -DuelCardTypeGraphics:: ; 76ce8 (1d:6ce8) -INCBIN "gfx/duel/card_types.2bpp" +DuelCardHeaderGraphics:: ; 76ce8 (1d:6ce8) +INCBIN "gfx/duel/card_headers.2bpp" DuelDmgSgbSymbolGraphics:: ; 76fe8 (1d:6fe8) INCBIN "gfx/duel/dmg_sgb_symbols.t7.2bpp" diff --git a/src/gfx/duel/card_types.png b/src/gfx/duel/card_headers.png Binary files differindex b788b91..b788b91 100644 --- a/src/gfx/duel/card_types.png +++ b/src/gfx/duel/card_headers.png |