diff options
author | xCrystal <rgr.crystal@gmail.com> | 2018-06-12 13:08:33 +0200 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2018-06-12 13:08:33 +0200 |
commit | eb954b0364e04df40c571817cb6092390a7e716f (patch) | |
tree | e45ade2cd9a8f4f24bdbaea40476b6a499b319e1 /src | |
parent | fefed7461368d7685114e69205be9bb2fc742d3d (diff) |
Redesign TX_SYMBOL constants
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/hardware_constants.asm | 25 | ||||
-rw-r--r-- | src/constants/text_constants.asm | 99 | ||||
-rw-r--r-- | src/engine/bank01.asm | 42 | ||||
-rw-r--r-- | src/engine/bank04.asm | 2 | ||||
-rw-r--r-- | src/engine/bank06.asm | 6 | ||||
-rw-r--r-- | src/engine/home.asm | 65 | ||||
-rw-r--r-- | src/macros/data.asm | 5 | ||||
-rw-r--r-- | src/wram.asm | 2 |
8 files changed, 132 insertions, 114 deletions
diff --git a/src/constants/hardware_constants.asm b/src/constants/hardware_constants.asm index 098b569..a93e250 100644 --- a/src/constants/hardware_constants.asm +++ b/src/constants/hardware_constants.asm @@ -1,7 +1,9 @@ -; From http://nocash.emubase.de/pandocs.htm. +; From http://bgb.bircd.org/pandocs.htm GBC EQU $11 +LY_VBLANK EQU 145 + ; MBC3 MBC3SRamEnable EQU $0000 MBC3RomBank EQU $2000 @@ -30,8 +32,6 @@ TIMER EQU 2 SERIAL EQU 3 JOYPAD EQU 4 -LY_VBLANK EQU 145 - ; OAM attribute flags OAM_PALETTE EQU %111 OAM_TILE_BANK EQU 3 @@ -44,18 +44,18 @@ OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) rJOYP EQU $ff00 ; Joypad (R/W) rSB EQU $ff01 ; Serial transfer data (R/W) rSC EQU $ff02 ; Serial Transfer Control (R/W) -rSC_ON EQU 7 -rSC_CGB EQU 1 -rSC_CLOCK EQU 0 +SC_ON EQU 7 +SC_CGB EQU 1 +SC_CLOCK EQU 0 rDIV EQU $ff04 ; Divider Register (R/W) rTIMA EQU $ff05 ; Timer counter (R/W) rTMA EQU $ff06 ; Timer Modulo (R/W) rTAC EQU $ff07 ; Timer Control (R/W) -rTAC_ON EQU 2 -rTAC_4096_HZ EQU 0 -rTAC_262144_HZ EQU 1 -rTAC_65536_HZ EQU 2 -rTAC_16384_HZ EQU 3 +TAC_ON EQU 2 +TAC_4096_HZ EQU 0 +TAC_262144_HZ EQU 1 +TAC_65536_HZ EQU 2 +TAC_16384_HZ EQU 3 rIF EQU $ff0f ; Interrupt Flag (R/W) rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W) rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W) @@ -79,8 +79,7 @@ rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W) rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W) rNR52 EQU $ff26 ; Sound on/off rLCDC EQU $ff40 ; LCD Control (R/W) -rLCDC_ENABLE EQU 7 -rLCDC_ENABLE_MASK EQU 1 << rLCDC_ENABLE +LCDC_ON EQU 7 rSTAT EQU $ff41 ; LCDC Status (R/W) rSCY EQU $ff42 ; Scroll Y (R/W) rSCX EQU $ff43 ; Scroll X (R/W) diff --git a/src/constants/text_constants.asm b/src/constants/text_constants.asm index 38f4e9b..92554af 100644 --- a/src/constants/text_constants.asm +++ b/src/constants/text_constants.asm @@ -17,49 +17,56 @@ done EQUS "db TX_END" ; TX_SYMBOL (full-tile icons/symbols loaded at the beginning of v0Tiles2) ; TODO: Use symbols in menus (cursor tile number, tile behind cursor), draw text boxes, WriteByteToBGMap0, etc - charmap "<", TX_SYMBOL - charmap " >", $00 - charmap "FIRE>", $01 - charmap "GRASS>", $02 - charmap "LIGHTNING>", $03 - charmap "WATER>", $04 - charmap "FIGHTING>", $05 - charmap "PSYCHIC>", $06 - charmap "COLORLESS>", $07 - charmap "POISONED>", $08 - charmap "ASLEEP>", $09 - charmap "CONFUSED>", $0a - charmap "PARALYZED>", $0b - charmap "β³>", $0c - charmap "PKMN_ICON>", $0d ; icon displayed along with no. of Pkmn in duel screen -; charmap $0e - charmap "β·>", $0f - charmap "HP>", $10 - charmap "Lv>", $11 - charmap "E>", $12 - charmap "No>", $13 - charmap "PLUSPOWER>", $14 - charmap "DEFENDER>", $15 - charmap "π>", $16 ; HP tile - charmap "π>", $17 ; HP tile with damage counter - charmap "β>", $18 - charmap "β>", $19 - charmap "β>", $1a - charmap "β>", $1b - charmap "TOP β>", $1c - charmap "BOTTOM β>", $1d - charmap "LEFT β>", $1e - charmap "RIGHT β>", $1f - charmap "0>", $20 - charmap "1>", $21 - charmap "2>", $22 - charmap "3>", $23 - charmap "4>", $24 - charmap "5>", $25 - charmap "6>", $26 - charmap "7>", $27 - charmap "8>", $28 - charmap "9>", $29 - charmap "+>", $2b - charmap "β½>", $2f - charmap "PRIZE_ICON>", $30 ; icon displayed along with no. of prizes in duel screen +; If user-defined functions ever become a thing a symbol(*) syntax would probably be preferred over SYM_* + + charmap "<", TX_SYMBOL + const_def + txsymbol SPACE + txsymbol FIRE + txsymbol GRASS + txsymbol LIGHTNING + txsymbol WATER + txsymbol FIGHTING + txsymbol PSYCHIC + txsymbol COLORLESS + txsymbol POISONED + txsymbol ASLEEP + txsymbol CONFUSED + txsymbol PARALYZED + txsymbol CURSOR_U + txsymbol POKEMON + txsymbol UNKNOWN_0E + txsymbol CURSOR_R + txsymbol HP + txsymbol Lv + txsymbol E + txsymbol No + txsymbol PLUSPOWER + txsymbol DEFENDER + txsymbol HP_OK + txsymbol HP_NOK + txsymbol BOX_TOP_L + txsymbol BOX_TOP_R + txsymbol BOX_BTM_L + txsymbol BOX_BTM_R + txsymbol BOX_TOP + txsymbol BOX_BOTTOM + txsymbol BOX_LEFT + txsymbol BOX_RIGHT + txsymbol 0 + txsymbol 1 + txsymbol 2 + txsymbol 3 + txsymbol 4 + txsymbol 5 + txsymbol 6 + txsymbol 7 + txsymbol 8 + txsymbol 9 + txsymbol DOT + txsymbol PLUS + txsymbol MINUS + txsymbol x + txsymbol SLASH + txsymbol CURSOR_D + txsymbol PRIZE diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 2113a87..c1b6542 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -1858,22 +1858,22 @@ DrawDuelHUD: ; 5093 (1:5093) push de pop bc - ; print the Pkmn icon along with the no. of play area Pokemon - ld a, LOW("<PKMN_ICON>") + ; print the Pokemon icon along with the no. of play area Pokemon + ld a, SYM_POKEMON call WriteByteToBGMap0 inc b ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable - add LOW("<0>") - 1 + add SYM_0 - 1 call WriteByteToBGMap0 inc b ; print the Prize icon along with the no. of prizes yet to draw - ld a, LOW("<PRIZE_ICON>") + ld a, SYM_PRIZE call WriteByteToBGMap0 inc b call CountPrizes - add LOW("<0>") + add SYM_0 call WriteByteToBGMap0 ; print the arena Pokemon card name and level text @@ -1956,11 +1956,11 @@ DrawDuelHUD: ; 5093 (1:5093) call GetTurnDuelistVariable or a jr z, .check_defender - ld a, LOW("<PLUSPOWER>") + ld a, SYM_PLUSPOWER call WriteByteToBGMap0 inc b ld a, [hl] ; number of attached Pluspower - add LOW("<0>") + add SYM_0 call WriteByteToBGMap0 dec b .check_defender @@ -1969,11 +1969,11 @@ DrawDuelHUD: ; 5093 (1:5093) or a jr z, .done inc c - ld a, LOW("<DEFENDER>") + ld a, SYM_DEFENDER call WriteByteToBGMap0 inc b ld a, [hl] ; number of attached Defender - add LOW("<0>") + add SYM_0 call WriteByteToBGMap0 .done ret @@ -1996,10 +1996,10 @@ DrawDuelHorizontalSeparator: ; 516f (1:516f) DuelEAndHPTileData: ; 5188 (1:5188) ; x, y, tiles[], 0 - db 1, 1, LOW("<E>"), 0 - db 1, 2, LOW("<HP>"), 0 - db 9, 8, LOW("<E>"), 0 - db 9, 9, LOW("<HP>"), 0 + db 1, 1, SYM_E, 0 + db 1, 2, SYM_HP, 0 + db 9, 8, SYM_E, 0 + db 9, 9, SYM_HP, 0 db $ff ; 0x5199 @@ -3190,7 +3190,7 @@ CheckPrintPoisoned: ; 63bb (1:63bb) and POISONED jr z, .print .poison - ld a, LOW("<POISONED>") + ld a, SYM_POISONED .print call WriteByteToBGMap0 pop af @@ -3224,8 +3224,8 @@ CheckPrintCnfSlpPrz: ; 63ce (1:63ce) ret .status_symbols - ; NO_STATUS, CONFUSED, ASLEEP, PARALYZED - db LOW("< >"), LOW("<CONFUSED>"), LOW("<ASLEEP>"), LOW("<PARALYZED>") + ; NO_STATUS, CONFUSED, ASLEEP, PARALYZED + db SYM_SPACE, SYM_CONFUSED, SYM_ASLEEP, SYM_PARALYZED ; 0x63e6 ; print the symbols of the attached energies of a turn holder's play area card @@ -3246,7 +3246,7 @@ PrintPlayAreaCardAttachedEnergies: ; 63e6 (1:63e6) jr nz, .empty_loop pop hl ld de, wAttachedEnergies - lb bc, LOW("<FIRE>"), NUM_TYPES - 1 + lb bc, SYM_FIRE, NUM_TYPES - 1 .next_color ld a, [de] ; energy count of current color inc de @@ -3264,7 +3264,7 @@ PrintPlayAreaCardAttachedEnergies: ; 63e6 (1:63e6) ld a, [wTotalAttachedEnergies] cp 9 jr c, .place_tiles - ld a, LOW("<+>") + ld a, SYM_PLUS ld [wDefaultText + 7], a .place_tiles pop bc @@ -3280,14 +3280,14 @@ PrintPlayAreaCardAttachedEnergies: ; 63e6 (1:63e6) ; input d, e: max. HP, current HP DrawHPBar: ; 6614 (1:6614) ld a, MAX_HP - ld c, LOW("< >") + ld c, SYM_SPACE call .fill_hp_bar ; empty bar ld a, d - ld c, LOW("<π>") + ld c, SYM_HP_OK call .fill_hp_bar ; fill (max. HP) with HP counters ld a, d sub e - ld c, LOW("<π>") + ld c, SYM_HP_NOK ; fill (max. HP - current HP) with damaged HP counters .fill_hp_bar or a diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 9bf84f3..3656e52 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -10,7 +10,7 @@ Func_10000: ; 10000 (4:4000) ldh [hSCX], a ldh [hSCY], a ld a, [wLCDC] - bit 7, a + bit LCDC_ON, a jr nz, .asm_10025 xor a ld [rSCX], a diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 1a85a24..7c19b74 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -58,14 +58,14 @@ _CopyCardNameAndLevel: ; 18000 (6:4000) jr z, .done ld a, TX_SYMBOL ld [hli], a - ld [hl], LOW("<Lv>") + ld [hl], SYM_Lv inc hl ld a, [wLoadedCard1Level] cp 10 jr c, .one_digit ld [hl], TX_SYMBOL inc hl - ld b, LOW("<0>") - 1 + ld b, SYM_0 - 1 .first_digit_loop inc b sub 10 @@ -76,7 +76,7 @@ _CopyCardNameAndLevel: ; 18000 (6:4000) .one_digit ld [hl], TX_SYMBOL inc hl - add LOW("<0>") + add SYM_0 ld [hl], a ; last (or only) digit inc hl .done diff --git a/src/engine/home.asm b/src/engine/home.asm index 00684cf..87dc7a3 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -191,7 +191,7 @@ SetupTimer: ; 0241 (0:0241) .set_timer ld a, b ld [rTMA], a - ld a, rTAC_16384_HZ + ld a, TAC_16384_HZ ld [rTAC], a ld a, $7 ld [rTAC], a @@ -209,7 +209,7 @@ CheckForCGB: ; 025c (0:025c) WaitForVBlank: ; 0264 (0:0264) push hl ld a, [wLCDC] - bit rLCDC_ENABLE, a + bit LCDC_ON, a jr z, .asm_275 ld hl, wVBlankCtr ld a, [hl] @@ -224,12 +224,12 @@ WaitForVBlank: ; 0264 (0:0264) ; turn LCD on EnableLCD: ; 0277 (0:0277) - ld a, [wLCDC] ; - bit rLCDC_ENABLE, a ; - ret nz ; assert that LCD is off - or rLCDC_ENABLE_MASK ; - ld [wLCDC], a ; - ld [rLCDC], a ; turn LCD on + ld a, [wLCDC] ; + bit LCDC_ON, a ; + ret nz ; assert that LCD is off + or 1 << LCDC_ON ; + ld [wLCDC], a ; + ld [rLCDC], a ; turn LCD on ld a, FLUSH_ALL ld [wFlushPaletteFlags], a ret @@ -237,7 +237,7 @@ EnableLCD: ; 0277 (0:0277) ; wait for vblank, then turn LCD off DisableLCD: ; 028a (0:028a) ld a, [rLCDC] ; - bit rLCDC_ENABLE, a ; + bit LCDC_ON, a ; ret z ; assert that LCD is on ld a, [rIE] ld [wIE], a @@ -903,8 +903,9 @@ Func_05f4: ; 5f4 (0:5f4) ret ; 0x614 -; given two numbers in the two nybbles of register a, write them -; in text format to hl (most significant nybble first) +; given two one-digit numbers in the two nybbles of register a, +; write them in text (ascii) format to hl (most significant nybble first). +; numbers above 9 are converted to VWF tiles. WriteNumbersInTextFormat: ; 614 (0:614) push af swap a @@ -912,7 +913,9 @@ WriteNumbersInTextFormat: ; 614 (0:614) pop af ; fallthrough -; given a number in the (bottom nybble) of register a, write it in text format to hl +; given a one-digit number in the (bottom nybble) of register a, +; write it in text (ascii) format to hl. +; numbers above 9 are converted to VWF tiles. WriteNumberInTextFormat: and $0f add "0" @@ -5309,7 +5312,7 @@ GetCardAlbumProgress: ; 1da4 (0:1da4) ; if LCD on, copy during h-blank only SafeCopyDataDEtoHL: ; 1dca (0:1dca) ld a, [wLCDC] ; - bit rLCDC_ENABLE, a ; + bit LCDC_ON, a ; jr nz, .lcd_on ; assert that LCD is on .lcd_off_loop ld a, [de] @@ -5386,7 +5389,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) ld hl, wc000 ld a, TX_SYMBOL ld [hli], a - ld a, LOW("<β>") + ld a, SYM_BOX_TOP_L ld [hli], a ; white tile before the text ld a, $70 @@ -5415,7 +5418,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) .draw_top_border_line_loop ld a, TX_SYMBOL ld [hli], a - ld a, LOW("<TOP β>") + ld a, SYM_BOX_TOP ld [hli], a dec b jr nz, .draw_top_border_line_loop @@ -5423,7 +5426,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) .draw_top_border_right_tile ld a, TX_SYMBOL ld [hli], a - ld a, LOW("<β>") + ld a, SYM_BOX_TOP_R ld [hli], a ld [hl], $0 pop bc @@ -6140,7 +6143,7 @@ Func_2325: ; 2325 (0:2325) ret ; search linked-list for letters e/d (regisers), if found hoist the result to -; head of list and return it. carry flag denotes success. +; head of list and return it. carry flag denotes success. Func_235e: ; 235e (0:235e) ld a, [wcd0a] ; or a ; @@ -6171,7 +6174,7 @@ Func_235e: ; 235e (0:235e) ld a, [hl] ; if key1[l] == e and ; cp d ; key2[l] == d: ; jr z, .asm_238f ; break ; -.asm_238a ; +.asm_238a ld h, $c8 ; ; ld l, [hl] ; l β next[l] ; jr .asm_237d @@ -6269,7 +6272,7 @@ Func_23d3: ; 23d3 (0:23d3) ; convert the number at hl to TX_SYMBOL text format and write it to wcaa0 ; replace leading zeros with $00 -TwoByteNumberToLargeText_TrimLeadingZeros: ; 245d (0:245d) +TwoByteNumberToTxSymbol_TrimLeadingZeros: ; 245d (0:245d) push de push bc ld de, wcaa0 @@ -6291,14 +6294,14 @@ TwoByteNumberToLargeText_TrimLeadingZeros: ; 245d (0:245d) .digit_loop inc hl ld a, [hl] - cp LOW("<0>") + cp SYM_0 jr nz, .done ; jump if not zero - ld [hl], LOW("< >") ; trim leading zero + ld [hl], SYM_SPACE ; trim leading zero inc hl dec e jr nz, .digit_loop dec hl - ld [hl], LOW("<0>") + ld [hl], SYM_0 .done dec hl pop bc @@ -6309,7 +6312,7 @@ TwoByteNumberToLargeText_TrimLeadingZeros: ; 245d (0:245d) ld a, TX_SYMBOL ld [de], a inc de - ld a, LOW("<0>") - 1 + ld a, SYM_0 - 1 .substract_loop inc a add hl, bc @@ -7648,12 +7651,16 @@ ReadTextOffset: ; 2ded (0:2ded) pop de ret -; convert the number at hl to text (ascii) format and write it to wcaa0 -; return c = 4 - leading_zeros +; if [wcd0a] != 0: +; convert the number at hl to text (ascii) format and write it to wcaa0 +; return c = 4 - leading_zeros +; if [wcd0a] == 0: +; convert the number at hl to TX_SYMBOL text format and write it to wcaa0 +; replace leading zeros with $00 TwoByteNumberToText_CountLeadingZeros: ; 2e12 (0:2e12) ld a, [wcd0a] or a - jp z, TwoByteNumberToLargeText_TrimLeadingZeros + jp z, TwoByteNumberToTxSymbol_TrimLeadingZeros ld de, wcaa0 push de call TwoByteNumberToText @@ -7683,7 +7690,7 @@ CopyTurnDuelistName: ; 2e2c (0:2e2c) pop hl ret -; prints text with id at hl with letter delay in a textbox area +; prints text with id at hl, with letter delay, in a textbox area PrintText: ; 2e41 (0:2e41) ld a, l or h @@ -7721,7 +7728,7 @@ PrintText: ; 2e41 (0:2e41) jr nc, .next_tile_loop ret -; prints text with id at hl without letter delay in a textbox area +; prints text with id at hl, without letter delay, in a textbox area PrintTextNoDelay: ; 2e76 (0:2e76) ldh a, [hBankROM] push af @@ -10085,7 +10092,7 @@ Func_3c46: ; 3c46 (0:3c46) DoFrameIfLCDEnabled: ; 3c48 (0:3c48) push af ld a, [rLCDC] - bit rLCDC_ENABLE, a + bit LCDC_ON, a jr z, .done push bc push de diff --git a/src/macros/data.asm b/src/macros/data.asm index 80978b7..7028636 100644 --- a/src/macros/data.asm +++ b/src/macros/data.asm @@ -84,3 +84,8 @@ ENDM tx: MACRO dw \1_ ENDM + +txsymbol: MACRO + const SYM_\1 + charmap "\1>", const_value + -1 +ENDM diff --git a/src/wram.asm b/src/wram.asm index 2d3b9bc..3506b07 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1064,7 +1064,7 @@ wce2b:: ; ce2b wTxRam2:: ; cd3f ds $2 -; text pointer for the second TX_RAM2 on a text +; text pointer for the second TX_RAM2 of a text wTxRam2_b:: ; ce41 ds $2 |