shithub: pokecrystal

Download patch

ref: 163f3e0c3f56831b5255b31045798ac950098faa
parent: 177341425cb959ee75f41e6d43c7e6a47d6aef59
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Thu Jan 11 17:16:17 EST 2018

Local UI tiles don't belong in charmap
Separate 1bpp font tiles from gfx/mobile/phone_tiles.png

--- a/charmap.asm
+++ b/charmap.asm
@@ -80,15 +80,12 @@
 
 ; Actual characters (from other graphics files)
 
-	charmap "|",         $31 ; from gfx/stats/stats_tiles
-
-	charmap "<SHINY>",   $3f ; gfx/stats/shiny
-
-	charmap "<BLACK>",   $60 ; from gfx/mobile/phone_tiles.2bpp
+	; needed for _LoadFontsExtra1 (see gfx/font.asm)
+	charmap "<BLACK>",   $60 ; gfx/font/black_arrow.2bpp
 	charmap "▲",         $61 ; gfx/font/up_arrow.png
-	charmap "<PHONE>",   $62 ; gfx/font/overworld_phone_icon.2bpp
-	charmap "_",         $62 ; from gfx/battle/hp_exp_bar_border.1bpp
+	charmap "<PHONE>",   $62 ; gfx/font/phone_icon.2bpp
 
+	; needed for Special_MagikarpHouseSign (see engine/events/magikarp.asm)
 	charmap "′",         $6e ; gfx/font/feet_inches.png
 	charmap "″",         $6f ; gfx/font/feet_inches.png
 
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -1,6 +1,6 @@
 TILE_WIDTH EQU 8 ; pixels
-LEN_1BPP_TILE EQU TILE_WIDTH     ; bytes
-LEN_2BPP_TILE EQU TILE_WIDTH * 2 ; bytes
+LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes
+LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes
 
 NUM_PAL_COLORS EQU 4
 
--- a/constants/item_data_constants.asm
+++ b/constants/item_data_constants.asm
@@ -43,6 +43,7 @@
 
 
 ; mail
+MAIL_LINE_LENGTH   EQU $10
 MAIL_MSG_LENGTH    EQU $20
 MAILBOX_CAPACITY   EQU 10
 MAIL_STRUCT_LENGTH EQU $2f ; mailmsg struct
--- a/engine/namingscreen.asm
+++ b/engine/namingscreen.asm
@@ -1,3 +1,9 @@
+NAMINGSCREEN_CURSOR     EQU $7e
+
+NAMINGSCREEN_BORDER     EQUS "\"<BLACK>\"" ; $60
+NAMINGSCREEN_MIDDLELINE EQUS "\"→\"" ; $eb
+NAMINGSCREEN_UNDERLINE  EQUS "\"<DOT>\"" ; $f2
+
 _NamingScreen: ; 0x116b7
 	call DisableSpriteUpdates
 	call NamingScreen
@@ -287,7 +293,7 @@
 	call WaitTop
 	hlcoord 0, 0
 	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-	ld a, $60
+	ld a, NAMINGSCREEN_BORDER
 	call ByteFill
 	hlcoord 1, 1
 	lb bc, 6, 18
@@ -729,7 +735,7 @@
 	ld a, [hl]
 	cp "@"
 	jr z, .end_of_string
-	ld [hl], $f2
+	ld [hl], NAMINGSCREEN_UNDERLINE
 	and a
 	ret
 
@@ -776,12 +782,12 @@
 	ret z
 	dec [hl]
 	call NamingScreen_GetTextCursorPosition
-	ld [hl], $f2
+	ld [hl], NAMINGSCREEN_UNDERLINE
 	inc hl
 	ld a, [hl]
-	cp $f2
+	cp NAMINGSCREEN_UNDERLINE
 	ret nz
-	ld [hl], $eb
+	ld [hl], NAMINGSCREEN_MIDDLELINE
 	ret
 
 NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
@@ -800,17 +806,17 @@
 ; 11be0
 
 NamingScreen_InitNameEntry: ; 11be0
-; load $f2, ($eb * [wNamingScreenMaxNameLength]), $50 into the dw address at wNamingScreenDestinationPointer
+; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer
 	ld hl, wNamingScreenDestinationPointer
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld [hl], $f2
+	ld [hl], NAMINGSCREEN_UNDERLINE
 	inc hl
 	ld a, [wNamingScreenMaxNameLength]
 	dec a
 	ld c, a
-	ld a, $eb
+	ld a, NAMINGSCREEN_MIDDLELINE
 .loop
 	ld [hli], a
 	dec c
@@ -829,9 +835,9 @@
 	ld c, a
 .loop
 	ld a, [hl]
-	cp $eb
+	cp NAMINGSCREEN_MIDDLELINE
 	jr z, .terminator
-	cp $f2
+	cp NAMINGSCREEN_UNDERLINE
 	jr nz, .not_terminator
 .terminator
 	ld [hl], "@"
@@ -891,22 +897,22 @@
 	call LoadFontsExtra
 
 	ld de, NamingScreenGFX_MiddleLine
-	ld hl, vTiles1 tile $6b
+	ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE
 	lb bc, BANK(NamingScreenGFX_MiddleLine), 1
 	call Get1bpp
 
 	ld de, NamingScreenGFX_UnderLine
-	ld hl, vTiles1 tile $72
+	ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE
 	lb bc, BANK(NamingScreenGFX_UnderLine), 1
 	call Get1bpp
 
-	ld de, vTiles2 tile $60
+	ld de, vTiles2 tile NAMINGSCREEN_BORDER
 	ld hl, NamingScreenGFX_Border
 	ld bc, 1 tiles
 	ld a, BANK(NamingScreenGFX_Border)
 	call FarCopyBytes
 
-	ld de, vTiles0 tile $7e
+	ld de, vTiles0 tile NAMINGSCREEN_CURSOR
 	ld hl, NamingScreenGFX_Cursor
 	ld bc, 2 tiles
 	ld a, BANK(NamingScreenGFX_Cursor)
@@ -915,7 +921,7 @@
 	ld a, $5
 	ld hl, wSpriteAnimDict + 9 * 2
 	ld [hli], a
-	ld [hl], $7e
+	ld [hl], NAMINGSCREEN_CURSOR
 	xor a
 	ld [hSCY], a
 	ld [wGlobalAnimYOffset], a
@@ -1019,9 +1025,9 @@
 	ld e, [hl]
 	inc hl
 	ld d, [hl]
-	ld hl, $10
+	ld hl, MAIL_LINE_LENGTH
 	add hl, de
-	ld [hl], $4e
+	ld [hl], "<NEXT>"
 	ret
 
 ; 11ef4 (4:5ef4)
@@ -1046,7 +1052,7 @@
 	call WaitTop
 	hlcoord 0, 0
 	ld bc, 6 * SCREEN_WIDTH
-	ld a, $60 ; border
+	ld a, NAMINGSCREEN_BORDER
 	call ByteFill
 	hlcoord 0, 6
 	ld bc, 12 * SCREEN_WIDTH
@@ -1176,13 +1182,13 @@
 	jr c, .start
 	ld hl, wNamingScreenCurrNameLength
 	ld a, [hl]
-	cp $10
+	cp MAIL_LINE_LENGTH
 	ret nz
 	inc [hl]
 	call NamingScreen_GetTextCursorPosition
-	ld [hl], $f2
+	ld [hl], NAMINGSCREEN_UNDERLINE
 	dec hl
-	ld [hl], $4e
+	ld [hl], "<NEXT>"
 	ret
 
 .start
@@ -1202,13 +1208,13 @@
 	call NamingScreen_DeleteCharacter
 	ld hl, wNamingScreenCurrNameLength
 	ld a, [hl]
-	cp $10
+	cp MAIL_LINE_LENGTH
 	ret nz
 	dec [hl]
 	call NamingScreen_GetTextCursorPosition
-	ld [hl], $f2
+	ld [hl], NAMINGSCREEN_UNDERLINE
 	inc hl
-	ld [hl], $4e
+	ld [hl], "<NEXT>"
 	ret
 
 .finished
--- a/engine/print_party.asm
+++ b/engine/print_party.asm
@@ -1,3 +1,6 @@
+PRINTPARTY_HP    EQUS "\"◀\"" ; $71
+PRINTPARTY_SHINY EQUS "\"<ENEMY>\"" ; $3f
+
 PrintPage1: ; 1dc1b0
 	hlcoord 0, 0
 	decoord 0, 0, wPrinterTileMapBuffer
@@ -141,17 +144,17 @@
 	call LoadFontsBattleExtra
 
 	ld de, GBPrinterHPIcon
-	ld hl, vTiles2 tile $71
+	ld hl, vTiles2 tile PRINTPARTY_HP
 	lb bc, BANK(GBPrinterHPIcon), 1
 	call Request1bpp
 
 	ld de, GBPrinterLvIcon
-	ld hl, vTiles2 tile $6e
+	ld hl, vTiles2 tile "<LV>"
 	lb bc, BANK(GBPrinterLvIcon), 1
 	call Request1bpp
 
 	ld de, ShinyIconGFX
-	ld hl, vTiles2 tile $3f
+	ld hl, vTiles2 tile PRINTPARTY_SHINY
 	lb bc, BANK(ShinyIconGFX), 1
 	call Get2bpp
 
@@ -166,7 +169,7 @@
 	ld a, [TempMonLevel]
 	call PrintLevel_Force3Digits
 	hlcoord 12, 2
-	ld [hl], "◀" ; Filled left triangle
+	ld [hl], PRINTPARTY_HP
 	inc hl
 	ld de, TempMonMaxHP
 	lb bc, 2, 3
@@ -330,7 +333,7 @@
 	farcall CheckShininess
 	ret nc
 	hlcoord 18, 2
-	ld [hl], "<SHINY>"
+	ld [hl], PRINTPARTY_SHINY
 	ret
 ; 1dc550
 
--- a/engine/stats_screen.asm
+++ b/engine/stats_screen.asm
@@ -459,7 +459,7 @@
 	ld bc, SCREEN_WIDTH
 	ld d, SCREEN_HEIGHT
 .loop
-	ld a, "|"
+	ld a, $31 ; vertical divider
 	ld [hl], a
 	add hl, bc
 	dec d
@@ -470,7 +470,7 @@
 StatsScreen_PlaceHorizontalDivider: ; 4df8f (13:5f8f)
 	hlcoord 0, 7
 	ld b, SCREEN_WIDTH
-	ld a, "_"
+	ld a, $62 ; horizontal divider (empty HP/exp bar)
 .loop
 	ld [hli], a
 	dec b
@@ -489,7 +489,7 @@
 	farcall CheckShininess
 	ret nc
 	hlcoord 19, 0
-	ld [hl], "<SHINY>"
+	ld [hl], $3f ; shiny icon
 	ret
 
 StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
@@ -550,7 +550,7 @@
 	ld b, $0
 	predef DrawPlayerHP
 	hlcoord 8, 9
-	ld [hl], $41
+	ld [hl], $41 ; right HP/exp bar end cap
 	ld de, .Status_Type
 	hlcoord 0, 12
 	call PlaceString
@@ -562,7 +562,7 @@
 	and $f0
 	jr z, .NotImmuneToPkrs
 	hlcoord 8, 8
-	ld [hl], "."
+	ld [hl], "." ; Pokérus immunity dot
 .NotImmuneToPkrs:
 	ld a, [MonType]
 	cp BOXMON
@@ -588,7 +588,7 @@
 	hlcoord 9, 8
 	ld de, SCREEN_WIDTH
 	ld b, 10
-	ld a, "|"
+	ld a, $31 ; vertical divider
 .vertical_divider
 	ld [hl], a
 	add hl, de
@@ -620,9 +620,9 @@
 	ld de, TempMonExp + 2
 	predef FillInExpBar
 	hlcoord 10, 16
-	ld [hl], $40
+	ld [hl], $40 ; left exp bar end cap
 	hlcoord 19, 16
-	ld [hl], $41
+	ld [hl], $41 ; right exp bar end cap
 	ret
 
 .PrintNextLevel: ; 4e0d3 (13:60d3)
@@ -748,7 +748,7 @@
 	hlcoord 10, 8
 	ld de, SCREEN_WIDTH
 	ld b, 10
-	ld a, "|"
+	ld a, $31 ; vertical divider
 .BluePageVerticalDivider:
 	ld [hl], a
 	add hl, de
@@ -1087,17 +1087,17 @@
 
 StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd)
 	hlcoord 13, 5
-	ld a, $36
+	ld a, $36 ; first of 4 small square tiles
 	call .load_square
 	hlcoord 15, 5
-	ld a, $36
+	ld a, $36 ; """
 	call .load_square
 	hlcoord 17, 5
-	ld a, $36
+	ld a, $36 ; """
 	call .load_square
 	ld a, c
 	cp GREEN_PAGE
-	ld a, $3a
+	ld a, $3a ; first of 4 large square tiles
 	hlcoord 13, 5 ; PINK_PAGE (< GREEN_PAGE)
 	jr c, .load_square
 	hlcoord 15, 5 ; GREEN_PAGE (= GREEN_PAGE)
@@ -1120,7 +1120,7 @@
 CopyNickname: ; 4e505 (13:6505)
 	ld de, StringBuffer1
 	ld bc, PKMN_NAME_LENGTH
-	jr .okay ; uuterly pointless
+	jr .okay ; utterly pointless
 .okay
 	ld a, [MonType]
 	cp BOXMON
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -1,3 +1,6 @@
+TIMESET_UP_ARROW   EQUS "\"♂\"" ; $ef
+TIMESET_DOWN_ARROW EQUS "\"♀\"" ; $f5
+
 InitClock: ; 90672 (24:4672)
 ; Ask the player to set the time.
 	ld a, [hInMenu]
@@ -410,11 +413,11 @@
 	ld a, $1
 	ld [hInMenu], a
 	ld de, TimeSetUpArrowGFX
-	ld hl, vTiles1 tile $6f
+	ld hl, vTiles0 tile TIMESET_UP_ARROW
 	lb bc, BANK(TimeSetUpArrowGFX), 1
 	call Request1bpp
 	ld de, TimeSetDownArrowGFX
-	ld hl, vTiles1 tile $75
+	ld hl, vTiles0 tile TIMESET_DOWN_ARROW
 	lb bc, BANK(TimeSetDownArrowGFX), 1
 	call Request1bpp
 	xor a
@@ -431,9 +434,9 @@
 	ld c, 9
 	call TextBox
 	hlcoord 14, 3
-	ld [hl], "♂" ; gets overwritten with special up arrow
+	ld [hl], TIMESET_UP_ARROW
 	hlcoord 14, 6
-	ld [hl], "♀" ; gets overwritten with special down arrow
+	ld [hl], TIMESET_DOWN_ARROW
 	hlcoord 10, 5
 	call .PlaceWeekdayString
 	call ApplyTilemap
--- a/gfx/font.asm
+++ b/gfx/font.asm
@@ -54,8 +54,8 @@
 INCBIN "gfx/font/unused_weekday_kanji.2bpp"
 ; f8f24
 
-OverworldPhoneIconGFX: ; f8f24
-INCBIN "gfx/font/overworld_phone_icon.2bpp"
+PokegearPhoneIconGFX: ; f8f24
+INCBIN "gfx/font/phone_icon.2bpp"
 ; f8f34
 
 UnusedBoldFontGFX: ; unused bold letters + unown chars
@@ -66,7 +66,15 @@
 INCBIN "gfx/frames/space.1bpp"
 ; f9214
 
-MobilePhoneTilesGFX: ; f9214
+FontsExtra_SolidBlackGFX: ; f9214
+INCBIN "gfx/font/black.1bpp"
+; f921c
+
+UnusedUpArrowGFX: ; unused up arrow + whitespace
+INCBIN "gfx/font/unused_arrow.1bpp"
+; f9234
+
+MobilePhoneTilesGFX: ; f9234
 INCBIN "gfx/mobile/phone_tiles.2bpp"
 ; f9344
 
@@ -105,7 +113,7 @@
 _LoadStandardFont:: ; fb449
 	ld de, Font
 	ld hl, vTiles1
-	lb bc, BANK(Font), $80
+	lb bc, BANK(Font), 128 ; "A" to "9"
 	ld a, [rLCDC]
 	bit rLCDC_ENABLE, a
 	jp z, Copy1bpp
@@ -112,35 +120,35 @@
 
 	ld de, Font
 	ld hl, vTiles1
-	lb bc, BANK(Font), $20
+	lb bc, BANK(Font), 32 ; "A" to "]"
 	call Get1bpp_2
-	ld de, Font + $20 * LEN_1BPP_TILE
+	ld de, Font + 32 * LEN_1BPP_TILE
 	ld hl, vTiles1 tile $20
-	lb bc, BANK(Font), $20
+	lb bc, BANK(Font), 32 ; "a" to $bf
 	call Get1bpp_2
-	ld de, Font + $40 * LEN_1BPP_TILE
+	ld de, Font + 64 * LEN_1BPP_TILE
 	ld hl, vTiles1 tile $40
-	lb bc, BANK(Font), $20
+	lb bc, BANK(Font), 32 ; "Ä" to "←"
 	call Get1bpp_2
-	ld de, Font + $60 * LEN_1BPP_TILE
+	ld de, Font + 96 * LEN_1BPP_TILE
 	ld hl, vTiles1 tile $60
-	lb bc, BANK(Font), $20
+	lb bc, BANK(Font), 32 ; "'" to "9"
 	call Get1bpp_2
 	ret
 ; fb48a
 
 _LoadFontsExtra1:: ; fb48a
-	ld de, MobilePhoneTilesGFX
+	ld de, FontsExtra_SolidBlackGFX
 	ld hl, vTiles2 tile "<BLACK>" ; $60
-	lb bc, BANK(MobilePhoneTilesGFX), 1
+	lb bc, BANK(FontsExtra_SolidBlackGFX), 1
 	call Get1bpp_2
-	ld de, OverworldPhoneIconGFX
+	ld de, PokegearPhoneIconGFX
 	ld hl, vTiles2 tile "<PHONE>" ; $62
-	lb bc, BANK(OverworldPhoneIconGFX), 1
+	lb bc, BANK(PokegearPhoneIconGFX), 1
 	call Get2bpp_2
-	ld de, FontExtra + 3 * LEN_2BPP_TILE
-	ld hl, vTiles2 tile $63
-	lb bc, BANK(FontExtra), $16
+	ld de, FontExtra tile 3
+	ld hl, vTiles2 tile "<BOLD_D>"
+	lb bc, BANK(FontExtra), 22 ; "<BOLD_D>" to "ぉ"
 	call Get2bpp_2
 	jr LoadFrame
 ; fb4b0
@@ -157,7 +165,7 @@
 _LoadFontsBattleExtra:: ; fb4be
 	ld de, FontBattleExtra
 	ld hl, vTiles2 tile $60
-	lb bc, BANK(FontBattleExtra), $19
+	lb bc, BANK(FontBattleExtra), 25
 	call Get2bpp_2
 	jr LoadFrame
 ; fb4cc
@@ -165,13 +173,13 @@
 LoadFrame: ; fb4cc
 	ld a, [TextBoxFrame]
 	and 7
-	ld bc, LEN_1BPP_TILE * 6
+	ld bc, 6 * LEN_1BPP_TILE
 	ld hl, Frames
 	call AddNTimes
 	ld d, h
 	ld e, l
 	ld hl, vTiles2 tile "┌" ; $79
-	lb bc, BANK(Frames), 6
+	lb bc, BANK(Frames), 6 ; "┌" to "┘"
 	call Get1bpp_2
 	ld hl, vTiles2 tile " " ; $7f
 	ld de, TextBoxSpaceGFX
@@ -183,11 +191,11 @@
 LoadBattleFontsHPBar: ; fb4f2
 	ld de, FontBattleExtra
 	ld hl, vTiles2 tile $60
-	lb bc, BANK(FontBattleExtra), $c
+	lb bc, BANK(FontBattleExtra), 12
 	call Get2bpp_2
 	ld hl, vTiles2 tile $70
-	ld de, FontBattleExtra tile $10
-	lb bc, BANK(FontBattleExtra), 3
+	ld de, FontBattleExtra tile 16
+	lb bc, BANK(FontBattleExtra), 3 ; "<ど>" to "『"
 	call Get2bpp_2
 	call LoadFrame
 
@@ -204,7 +212,7 @@
 	ld hl, vTiles2 tile $55
 	lb bc, BANK(ExpBarGFX), 9
 	call Get2bpp_2
-	ld de, MobilePhoneTilesGFX + 9 * LEN_2BPP_TILE
+	ld de, MobilePhoneTilesGFX tile 7 ; mobile phone icon
 	ld hl, vTiles2 tile $5e
 	lb bc, BANK(MobilePhoneTilesGFX), 2
 	call Get2bpp_2
binary files /dev/null b/gfx/font/black.png differ
binary files a/gfx/font/font_battle_extra.png b/gfx/font/font_battle_extra.png differ
binary files a/gfx/font/font_extra.png b/gfx/font/font_extra.png differ
binary files a/gfx/font/overworld_phone_icon.png /dev/null differ
binary files /dev/null b/gfx/font/overworld_space.png differ
binary files /dev/null b/gfx/font/phone_icon.png differ
binary files a/gfx/font/space.png /dev/null differ
binary files /dev/null b/gfx/font/unused_arrow.png differ
binary files a/gfx/mobile/phone_tiles.png b/gfx/mobile/phone_tiles.png differ
--- a/gfx/overworld_font.asm
+++ b/gfx/overworld_font.asm
@@ -1,17 +1,17 @@
 LoadOverworldFont:: ; 106594
-	ld de, .font
+	ld de, .OverworldFontGFX
 	ld hl, vTiles1
-	lb bc, BANK(.font), $80
+	lb bc, BANK(.OverworldFontGFX), $80
 	call Get2bpp
-	ld de, .space
+	ld de, .OverworldFontSpaceGFX
 	ld hl, vTiles2 tile " "
-	lb bc, BANK(.space), 1
+	lb bc, BANK(.OverworldFontSpaceGFX), 1
 	call Get2bpp
 	ret
 ; 1065ad
 
-.font
+.OverworldFontGFX:
 INCBIN "gfx/font/overworld.2bpp"
 
-.space
-INCBIN "gfx/font/space.2bpp"
+.OverworldFontSpaceGFX:
+INCBIN "gfx/font/overworld_space.2bpp"
--- a/mobile/mobile_41.asm
+++ b/mobile/mobile_41.asm
@@ -1010,16 +1010,16 @@
 ; 106464
 
 Function106464:: ; 106464
-	ld de, MobilePhoneTilesGFX
-	ld hl, vTiles2 tile $60
-	lb bc, BANK(MobilePhoneTilesGFX), 1
+	ld de, FontsExtra_SolidBlackGFX
+	ld hl, vTiles2 tile "<BLACK>" ; $60
+	lb bc, BANK(FontsExtra_SolidBlackGFX), 1
 	call Get2bpp
 	ld de, FontsExtra2_UpArrowGFX
-	ld hl, vTiles2 tile $61
+	ld hl, vTiles2 tile "▲" ; $61
 	lb bc, BANK(FontsExtra2_UpArrowGFX), 1
 	call Get2bpp
 	ld de, GFX_106514
-	ld hl, vTiles2 tile $62
+	ld hl, vTiles2 tile "<PHONE>" ; $62
 	ld c, 9
 	ld b, BANK(GFX_106514)
 	call Get2bpp
@@ -1103,8 +1103,8 @@
 ; 10650a
 
 Function10650a: ; 10650a
-	ld de, MobilePhoneTilesGFX + $20
-	lb bc, BANK(MobilePhoneTilesGFX), $11
+	ld de, MobilePhoneTilesGFX
+	lb bc, BANK(MobilePhoneTilesGFX), 17
 	call Get2bpp
 	ret
 ; 106514