diff options
author | xCrystal <rgr.crystal@gmail.com> | 2018-03-04 19:00:36 +0100 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2018-03-04 19:00:36 +0100 |
commit | 1750d420b98f0b3d87c74fe1d59fca8498c8e0a0 (patch) | |
tree | b9a30206094ee9c0cc9264826b7a71b69f6c156b /src | |
parent | e0c37335bd97b33e24b5b5e8b63b123b577b4d82 (diff) |
Some text related stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/card_data_constants.asm | 1 | ||||
-rw-r--r-- | src/constants/text_constants.asm | 15 | ||||
-rw-r--r-- | src/engine/bank1.asm | 10 | ||||
-rw-r--r-- | src/engine/bank5.asm | 2 | ||||
-rw-r--r-- | src/engine/bank6.asm | 153 | ||||
-rw-r--r-- | src/engine/home.asm | 77 | ||||
-rw-r--r-- | src/wram.asm | 11 |
7 files changed, 217 insertions, 52 deletions
diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index a3074a9..3af82a1 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -96,6 +96,7 @@ TYPE_PKMN_PSYCHIC EQU PSYCHIC TYPE_PKMN_COLORLESS EQU COLORLESS TYPE_PKMN_UNUSED EQU UNUSED_TYPE const_def TYPE_PKMN_UNUSED + 1 - TYPE_PKMN_FIRE +TYPE_ENERGY EQU const_value const TYPE_ENERGY_FIRE ; $08 const TYPE_ENERGY_GRASS ; $09 const TYPE_ENERGY_LIGHTNING ; $0a diff --git a/src/constants/text_constants.asm b/src/constants/text_constants.asm index 062f5e4..2219241 100644 --- a/src/constants/text_constants.asm +++ b/src/constants/text_constants.asm @@ -1,15 +1,16 @@ -TX_START EQU $06 -TX_LINE EQU "\n" TX_END EQU $00 - -TX_RAM1 EQU $09 -TX_RAM2 EQU $0B -TX_RAM3 EQU $0C +TX_LARGE EQU $05 +TX_START EQU $06 +TX_RAM1 EQU $09 +TX_LINE EQU "\n" ; $0a +TX_RAM2 EQU $0B +TX_RAM3 EQU $0C text EQUS "db TX_START, " line EQUS "db TX_LINE, " done EQUS "db TX_END" +; TX_LARGE symbols from v0Tiles2 (full tile length) TX_FIRE EQUS "$05, $01" TX_GRASS EQUS "$05, $02" TX_LIGHTNING EQUS "$05, $03" @@ -17,4 +18,6 @@ TX_WATER EQUS "$05, $04" TX_FIGHTING EQUS "$05, $05" TX_PSYCHIC EQUS "$05, $06" TX_COLORLESS EQUS "$05, $07" +TX_HP EQUS "$05, $10" TX_LVL EQUS "$05, $11" +TX_No EQUS "$05, $13" diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 46a4b20..7cb6719 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -706,8 +706,8 @@ UsePokemonCard: ; 44db (1:44db) call SetDuelAIAction ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex - ld a, $14 - call Func_29f5 + ld a, 20 + call CopyCardNameAndLevel ld [hl], $00 ld hl, $0000 call LoadTxRam2 @@ -1848,7 +1848,7 @@ Func_522a: ; 522a (1:522a) Func_5236: ; 5236 (1:5236) ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable - cp $2 + cp 2 ret z ldtx hl, Text01a7 scf @@ -2895,8 +2895,8 @@ AIUseEnergyCard: ; 69a5 (1:69a5) INCROM $69c5, $6d84 -; converts clefairy doll/mysterious fossil at specified wLoadedCard to pokemon card -ConvertTrainerCardToPokemon: +; converts clefairy doll/mysterious fossil to pokemon card +ConvertTrainerCardToPokemon: ; 6d84 (1:6d84) ld c, a ld a, [hl] cp TYPE_TRAINER diff --git a/src/engine/bank5.asm b/src/engine/bank5.asm index 5820a24..0fd6f82 100644 --- a/src/engine/bank5.asm +++ b/src/engine/bank5.asm @@ -66,7 +66,7 @@ Func_14226: ; 14226 (5:4226) ret z call LoadCardDataToBuffer1_FromDeckIndex ld a, [wLoadedCard1Type] - cp TYPE_ENERGY_FIRE + cp TYPE_ENERGY jr nc, .check_for_next_pokemon ld a, [wLoadedCard1Stage] or a diff --git a/src/engine/bank6.asm b/src/engine/bank6.asm index 353044e..82e9cdd 100644 --- a/src/engine/bank6.asm +++ b/src/engine/bank6.asm @@ -1,4 +1,153 @@ - INCROM $18000, $186f7 +_CopyCardNameAndLevel: ; 18000 (6:4000) + push bc + push de + ld [wcd9b], a + ld hl, wLoadedCard1Name + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wDefaultText + push de + call CopyText ; copy card name to wDefaultText + pop hl + ld a, [hli] + cp TX_START + jp z, Func_18086 + ld a, [wcd9b] + ld c, a + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr nc, .level_done ; jump if energy or trainer + ld a, [wLoadedCard1Level] + or a + jr z, .level_done + inc c + inc c + ld a, [wLoadedCard1Level] + cp 10 + jr c, .level_done + inc c ; second digit +.level_done + ld hl, wLoadedCard1Name + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wDefaultText + push de + call CopyText + pop hl + push de + ld e, c + call Func_23c1 + add e + ld c, a + pop hl + push hl +.fill_loop + ld a, $70 + ld [hli], a + dec c + jr nz, .fill_loop + ld [hl], TX_END + pop hl + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr nc, .done + ld a, [wLoadedCard1Level] + or a + jr z, .done + ld a, TX_LARGE + ld [hli], a + ld [hl], $11 ; Lv + inc hl + ld a, [wLoadedCard1Level] + cp 10 + jr c, .one_digit + ld [hl], TX_LARGE + inc hl + ld b, $20 - 1 +.first_digit_loop + inc b + sub 10 + jr nc, .first_digit_loop + add 10 + ld [hl], b ; first digit + inc hl +.one_digit + ld [hl], TX_LARGE + inc hl + add $20 + ld [hl], a ; last (or only) digit + inc hl +.done + pop de + pop bc + ret +; 0x18086 + +Func_18086: ; 18086 (6:4086) + ld a, [wcd9b] + inc a + add a + ld b, a + ld hl, wDefaultText +.find_end_text_loop + dec b + ld a, [hli] + or a ; TX_END + jr nz, .find_end_text_loop + dec hl + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr nc, .level_done + ld a, [wLoadedCard1Level] + or a + jr z, .level_done + ld c, a + ld a, " " + ld [hli], a + dec b + ld a, "L" + ld [hli], a + dec b + ld a, "v" + ld [hli], a + dec b + ld a, c + cp 10 + jr c, .got_level + push bc + ld b, "0" - 1 +.first_digit_loop + inc b + sub 10 + jr nc, .first_digit_loop + add 10 + ld [hl], b ; first digit + inc hl + pop bc + ld c, a + dec b +.got_level + ld a, c + add "0" + ld [hli], a ; last (or only) digit + dec b +.level_done + push hl + ld a, " " +.fill_spaces_loop + ld [hli], a + dec b + jr nz, .fill_spaces_loop + ld [hl], TX_END + pop hl + pop de + pop bc + ret +; 0x180d5 + + INCROM $180d5, $186f7 INCLUDE "data/effect_commands.asm" @@ -104,7 +253,7 @@ Func_19a12: ; 19a12 (6:5a12) ld h, [hl] ld l, a ld de, wDefaultText - call PrintTextBoxBorderLabel + call CopyText ret ; 0x19a1f diff --git a/src/engine/home.asm b/src/engine/home.asm index b06f28c..5071510 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -4856,8 +4856,8 @@ Func_1b8d: ; 1b8d (0:1b8d) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call LoadCardDataToBuffer1_FromDeckIndex - ld a, $12 - call Func_29f5 + ld a, 18 + call CopyCardNameAndLevel ld [hl], $0 ld hl, wTxRam2 xor a @@ -4892,8 +4892,8 @@ Func_1bca: ; 1bca (0:1bca) add DUELVARS_ARENA_CARD call GetTurnDuelistVariable call LoadCardDataToBuffer1_FromDeckIndex - ld a, $12 - call Func_29f5 + ld a, 18 + call CopyCardNameAndLevel ld [hl], $0 ld hl, $0000 call LoadTxRam2 @@ -5039,7 +5039,7 @@ CopyPlayerName: ; 1c7d (0:1c7d) call DisableSRAM ret -; copy the opponent's name to de (usually via PrintTextBoxBorderLabel) +; copy the opponent's name to de (usually via CopyText) CopyOpponentName: ; 1c8e (0:1c8e) ld hl, wOpponentName ld a, [hli] @@ -5048,7 +5048,7 @@ CopyOpponentName: ; 1c8e (0:1c8e) ld a, [hld] ld l, [hl] ld h, a - jp PrintTextBoxBorderLabel + jp CopyText .special_name ld hl, wc500 ld a, [hl] @@ -5057,7 +5057,7 @@ CopyOpponentName: ; 1c8e (0:1c8e) jr CopyPlayerName.loop .print_player2 ldtx hl, Player2Text - jp PrintTextBoxBorderLabel + jp CopyText ; return, in hl, the total amount of cards owned anywhere, including duplicates GetRawAmountOfCardsOwned: ; 1caa (0:1caa) @@ -5367,7 +5367,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) push bc push hl ; top left tile of the box - ld hl, wTempCardCollection + ld hl, wc000 ld a, $5 ld [hli], a ld a, $18 @@ -5375,10 +5375,11 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) ; white tile before the text ld a, $70 ld [hli], a + ; text label ld e, l ld d, h pop hl - call PrintTextBoxBorderLabel + call CopyText ld hl, $c003 call Func_23c1 ld l, e @@ -5414,7 +5415,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) push de push bc call Func_22ae - ld hl, wTempCardCollection + ld hl, wc000 call Func_21c5 pop bc pop de @@ -6218,15 +6219,15 @@ Func_245d: ; 245d (0:245d) push bc ld de, wcaa0 push de - ld bc, $d8f0 + ld bc, -10000 call Func_2499 - ld bc, $fc18 + ld bc, -1000 call Func_2499 - ld bc, $ff9c + ld bc, -100 call Func_2499 - ld bc, $fff6 + ld bc, -10 call Func_2499 - ld bc, $ffff + ld bc, -1 call Func_2499 xor a ld [de], a @@ -6797,7 +6798,7 @@ PrintCardListItems: ; 2799 (0:2799) call DrawCardSymbol call Func_22ae ld a, [wcd1c] - call Func_29f5 + call CopyCardNameAndLevel ld hl, wDefaultText call Func_21c5 pop de @@ -6823,7 +6824,7 @@ CardTypeToSymbolID: ; 2988 (0:2988) ld a, [wLoadedCard1Type] cp TYPE_TRAINER jr nc, .trainer_card - cp TYPE_ENERGY_FIRE + cp TYPE_ENERGY jr c, .pokemon_card ; energy card and 7 ; convert energy constant to type constant @@ -6895,8 +6896,10 @@ CardSymbolTable: db $d8, $01 ; TYPE_PKMN_*, Stage 2 db $dc, $02 ; TYPE_TRAINER -Func_29f5: ; 29f5 (0:29f5) - farcall $6, $4000 +; copy the name and level of the card at wLoadedCard1 to wDefaultText +; a = string length in number of tiles (padded with spaces to fit) +CopyCardNameAndLevel: ; 29f5 (0:29f5) + farcall _CopyCardNameAndLevel ret ; 0x29fa @@ -7294,22 +7297,22 @@ Func_2c37: ; 2c37 (0:2c37) push af call ReadTextOffset ld c, $00 -.asm_2c42 +.char_loop ld a, [hli] - or a - jr z, .asm_2c58 + or a ; TX_END + jr z, .end cp $10 - jr nc, .asm_2c42 - cp $06 - jr c, .asm_2c55 - cp $0a - jr nz, .asm_2c42 + jr nc, .char_loop + cp TX_START + jr c, .skip + cp "\n" + jr nz, .char_loop inc c - jr .asm_2c42 -.asm_2c55 + jr .char_loop +.skip inc hl - jr .asm_2c42 -.asm_2c58 + jr .char_loop +.end pop af call BankswitchHome ld a, c @@ -7465,9 +7468,9 @@ Func_2d15: ; 2d15 (0:2d15) Func_2d43: ; 2d43 (0:2d43) call Func_2cf3 ld a, [hli] - or a + or a ; TX_END jr z, .asm_2d79 - cp $5 + cp TX_LARGE jr c, .asm_2d65 cp $10 jr nc, .asm_2d65 @@ -7674,11 +7677,9 @@ PrintTextNoDelay: ; 2e76 (0:2e76) call BankswitchHome ret -; Prints a name in the left side of the top border of a text box, usually to identify the talked-to NPC. -; input: - ; hl: text id - ; de: where to print the name -PrintTextBoxBorderLabel: ; 2e89 (0:2e89) +; copies a text given its id at hl, to de +; if hl is 0, the name of the turn duelist is copied instead +CopyText: ; 2e89 (0:2e89) ld a, l or h jr z, .special diff --git a/src/wram.asm b/src/wram.asm index ade377a..138e612 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -5,9 +5,18 @@ INCLUDE "vram.asm" SECTION "WRAM0", WRAM0 +UNION + wTempCardCollection:: ; c000 ds $100 +NEXTU + +wc000:: ; c000 + ds $100 + +ENDU + ds $100 SECTION "WRAM Duels 1", WRAM0 @@ -921,6 +930,8 @@ wRefreshMenuCursorSFX:: ; cd99 wcd9a:: ; cd9a ds $1 +; used in _CopyCardNameAndLevel to keep track of the remaining space to copy the text +wcd9b:: ; cd9b ds $1 wcd9c:: ; cd9c |