From 9180362211cf465c52798124baa5c5c06ba1d332 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Mon, 15 Jan 2018 11:06:17 -0500 Subject: [PATCH] Move code out of gfx/ (close #474) --- charmap.asm | 2 +- docs/design_flaws.md | 4 +- .../events/loadfishinggfx.asm | 0 engine/load_font.asm | 156 ++++++++++++++++++ {gfx => engine}/load_pics.asm | 8 +- .../routines/loadoverworldfont.asm | 0 gfx/font.asm | 155 ----------------- main.asm | 8 +- 8 files changed, 167 insertions(+), 166 deletions(-) rename gfx/fishing.asm => engine/events/loadfishinggfx.asm (100%) create mode 100644 engine/load_font.asm rename {gfx => engine}/load_pics.asm (99%) rename gfx/overworld_font.asm => engine/routines/loadoverworldfont.asm (100%) diff --git a/charmap.asm b/charmap.asm index 3b15daf46..f01eafe94 100644 --- a/charmap.asm +++ b/charmap.asm @@ -80,7 +80,7 @@ ; Actual characters (from other graphics files) - ; needed for _LoadFontsExtra1 (see gfx/font.asm) + ; needed for _LoadFontsExtra1 (see engine/load_font.asm) charmap "", $60 ; gfx/font/black_arrow.2bpp charmap "▲", $61 ; gfx/font/up_arrow.png charmap "", $62 ; gfx/font/phone_icon.2bpp diff --git a/docs/design_flaws.md b/docs/design_flaws.md index 7dbe79cfb..c856e8b38 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -24,7 +24,7 @@ dba_pic: MACRO ; dbw bank, address ENDM ``` -The offset is translated into a correct bank by `FixPicBank` in [gfx/load_pics.asm](/gfx/load_pics.asm): +The offset is translated into a correct bank by `FixPicBank` in [engine/load_pics.asm](/engine/load_pics.asm): ```asm FixPicBank: ; 511c5 @@ -106,7 +106,7 @@ ROMX $49 "Pics 2" ``` -Two routines in [gfx/load_pics.asm](/gfx/load_pics.asm) make this assumption; `GetFrontpicPointer`: +Two routines in [engine/load_pics.asm](/engine/load_pics.asm) make this assumption; `GetFrontpicPointer`: ```asm ld a, [CurPartySpecies] diff --git a/gfx/fishing.asm b/engine/events/loadfishinggfx.asm similarity index 100% rename from gfx/fishing.asm rename to engine/events/loadfishinggfx.asm diff --git a/engine/load_font.asm b/engine/load_font.asm new file mode 100644 index 000000000..347a85746 --- /dev/null +++ b/engine/load_font.asm @@ -0,0 +1,156 @@ +INCLUDE "gfx/font.asm" + +; This and the following two functions are unreferenced. +; Debug, perhaps? +Unreferenced_fb434: + db 0 + +Unreferenced_Functionfb435: ; 4b435 + ld a, [Unreferenced_fb434] + and a + jp nz, Get1bpp_2 + jp Get1bpp +; fb43f + +Unreferenced_Functionfb43f: ; fb43f + ld a, [Unreferenced_fb434] + and a + jp nz, Get2bpp_2 + jp Get2bpp +; End unreferenced block +; fb449 + +_LoadStandardFont:: ; fb449 + ld de, Font + ld hl, vTiles1 + lb bc, BANK(Font), 128 ; "A" to "9" + ld a, [rLCDC] + bit rLCDC_ENABLE, a + jp z, Copy1bpp + + ld de, Font + ld hl, vTiles1 + lb bc, BANK(Font), 32 ; "A" to "]" + call Get1bpp_2 + ld de, Font + 32 * LEN_1BPP_TILE + ld hl, vTiles1 tile $20 + lb bc, BANK(Font), 32 ; "a" to $bf + call Get1bpp_2 + ld de, Font + 64 * LEN_1BPP_TILE + ld hl, vTiles1 tile $40 + lb bc, BANK(Font), 32 ; "Ä" to "←" + call Get1bpp_2 + ld de, Font + 96 * LEN_1BPP_TILE + ld hl, vTiles1 tile $60 + lb bc, BANK(Font), 32 ; "'" to "9" + call Get1bpp_2 + ret +; fb48a + +_LoadFontsExtra1:: ; fb48a + ld de, FontsExtra_SolidBlackGFX + ld hl, vTiles2 tile "" ; $60 + lb bc, BANK(FontsExtra_SolidBlackGFX), 1 + call Get1bpp_2 + ld de, PokegearPhoneIconGFX + ld hl, vTiles2 tile "" ; $62 + lb bc, BANK(PokegearPhoneIconGFX), 1 + call Get2bpp_2 + ld de, FontExtra tile 3 + ld hl, vTiles2 tile "" + lb bc, BANK(FontExtra), 22 ; "" to "ぉ" + call Get2bpp_2 + jr LoadFrame +; fb4b0 + +_LoadFontsExtra2:: ; fb4b0 + ld de, FontsExtra2_UpArrowGFX + ld hl, vTiles2 tile "▲" ; $61 + ld b, BANK(FontsExtra2_UpArrowGFX) + ld c, 1 + call Get2bpp_2 + ret +; fb4be + +_LoadFontsBattleExtra:: ; fb4be + ld de, FontBattleExtra + ld hl, vTiles2 tile $60 + lb bc, BANK(FontBattleExtra), 25 + call Get2bpp_2 + jr LoadFrame +; fb4cc + +LoadFrame: ; fb4cc + ld a, [TextBoxFrame] + maskbits NUM_FRAMES +- 1 + 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 ; "┌" to "┘" + call Get1bpp_2 + ld hl, vTiles2 tile " " ; $7f + ld de, TextBoxSpaceGFX + lb bc, BANK(TextBoxSpaceGFX), 1 + call Get1bpp_2 + ret +; fb4f2 + +LoadBattleFontsHPBar: ; fb4f2 + ld de, FontBattleExtra + ld hl, vTiles2 tile $60 + lb bc, BANK(FontBattleExtra), 12 + call Get2bpp_2 + ld hl, vTiles2 tile $70 + ld de, FontBattleExtra tile 16 + lb bc, BANK(FontBattleExtra), 3 ; "<ど>" to "『" + call Get2bpp_2 + call LoadFrame + +LoadHPBar: ; fb50d + ld de, EnemyHPBarBorderGFX + ld hl, vTiles2 tile $6c + lb bc, BANK(EnemyHPBarBorderGFX), 4 + call Get1bpp_2 + ld de, HPExpBarBorderGFX + ld hl, vTiles2 tile $73 + lb bc, BANK(HPExpBarBorderGFX), 6 + call Get1bpp_2 + ld de, ExpBarGFX + ld hl, vTiles2 tile $55 + lb bc, BANK(ExpBarGFX), 9 + call Get2bpp_2 + ld de, MobilePhoneTilesGFX tile 7 ; mobile phone icon + ld hl, vTiles2 tile $5e + lb bc, BANK(MobilePhoneTilesGFX), 2 + call Get2bpp_2 + ret +; fb53e + +StatsScreen_LoadFont: ; fb53e + call _LoadFontsBattleExtra + ld de, EnemyHPBarBorderGFX + ld hl, vTiles2 tile $6c + lb bc, BANK(EnemyHPBarBorderGFX), 4 + call Get1bpp_2 + ld de, HPExpBarBorderGFX + ld hl, vTiles2 tile $78 + lb bc, BANK(HPExpBarBorderGFX), 1 + call Get1bpp_2 + ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE + ld hl, vTiles2 tile $76 + lb bc, BANK(HPExpBarBorderGFX), 2 + call Get1bpp_2 + ld de, ExpBarGFX + ld hl, vTiles2 tile $55 + lb bc, BANK(ExpBarGFX), 8 + call Get2bpp_2 +LoadStatsScreenPageTilesGFX: ; fb571 + ld de, StatsScreenPageTilesGFX + ld hl, vTiles2 tile $31 + lb bc, BANK(StatsScreenPageTilesGFX), 17 + call Get2bpp_2 + ret +; fb57e diff --git a/gfx/load_pics.asm b/engine/load_pics.asm similarity index 99% rename from gfx/load_pics.asm rename to engine/load_pics.asm index e58ecb615..14ec463cc 100755 --- a/gfx/load_pics.asm +++ b/engine/load_pics.asm @@ -394,8 +394,8 @@ FixBackpicAlignment: ; 5127c .got_dims ld a, [hl] - ld b, $0 - ld c, $8 + ld b, 0 + ld c, 8 .loop rra rl b @@ -483,10 +483,10 @@ LoadFrontpic: ; 512f2 inc de ld b, a xor a - rept 8 +rept 8 rr b rla - endr +endr ld [hli], a dec c jr nz, .right_loop diff --git a/gfx/overworld_font.asm b/engine/routines/loadoverworldfont.asm similarity index 100% rename from gfx/overworld_font.asm rename to engine/routines/loadoverworldfont.asm diff --git a/gfx/font.asm b/gfx/font.asm index e525df85b..bd7b60c3c 100755 --- a/gfx/font.asm +++ b/gfx/font.asm @@ -80,158 +80,3 @@ INCBIN "gfx/font/up_arrow.2bpp" Footprints: ; f9434 INCLUDE "gfx/footprints.asm" ; fb434 - -; This and the following two functions are unreferenced. -; Debug, perhaps? -Unreferenced_fb434: - db 0 - -Unreferenced_Functionfb435: ; 4b435 - ld a, [Unreferenced_fb434] - and a - jp nz, Get1bpp_2 - jp Get1bpp -; fb43f - -Unreferenced_Functionfb43f: ; fb43f - ld a, [Unreferenced_fb434] - and a - jp nz, Get2bpp_2 - jp Get2bpp -; End unreferenced block -; fb449 - -_LoadStandardFont:: ; fb449 - ld de, Font - ld hl, vTiles1 - lb bc, BANK(Font), 128 ; "A" to "9" - ld a, [rLCDC] - bit rLCDC_ENABLE, a - jp z, Copy1bpp - - ld de, Font - ld hl, vTiles1 - lb bc, BANK(Font), 32 ; "A" to "]" - call Get1bpp_2 - ld de, Font + 32 * LEN_1BPP_TILE - ld hl, vTiles1 tile $20 - lb bc, BANK(Font), 32 ; "a" to $bf - call Get1bpp_2 - ld de, Font + 64 * LEN_1BPP_TILE - ld hl, vTiles1 tile $40 - lb bc, BANK(Font), 32 ; "Ä" to "←" - call Get1bpp_2 - ld de, Font + 96 * LEN_1BPP_TILE - ld hl, vTiles1 tile $60 - lb bc, BANK(Font), 32 ; "'" to "9" - call Get1bpp_2 - ret -; fb48a - -_LoadFontsExtra1:: ; fb48a - ld de, FontsExtra_SolidBlackGFX - ld hl, vTiles2 tile "" ; $60 - lb bc, BANK(FontsExtra_SolidBlackGFX), 1 - call Get1bpp_2 - ld de, PokegearPhoneIconGFX - ld hl, vTiles2 tile "" ; $62 - lb bc, BANK(PokegearPhoneIconGFX), 1 - call Get2bpp_2 - ld de, FontExtra tile 3 - ld hl, vTiles2 tile "" - lb bc, BANK(FontExtra), 22 ; "" to "ぉ" - call Get2bpp_2 - jr LoadFrame -; fb4b0 - -_LoadFontsExtra2:: ; fb4b0 - ld de, FontsExtra2_UpArrowGFX - ld hl, vTiles2 tile "▲" ; $61 - ld b, BANK(FontsExtra2_UpArrowGFX) - ld c, 1 - call Get2bpp_2 - ret -; fb4be - -_LoadFontsBattleExtra:: ; fb4be - ld de, FontBattleExtra - ld hl, vTiles2 tile $60 - lb bc, BANK(FontBattleExtra), 25 - call Get2bpp_2 - jr LoadFrame -; fb4cc - -LoadFrame: ; fb4cc - ld a, [TextBoxFrame] - maskbits NUM_FRAMES +- 1 - 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 ; "┌" to "┘" - call Get1bpp_2 - ld hl, vTiles2 tile " " ; $7f - ld de, TextBoxSpaceGFX - lb bc, BANK(TextBoxSpaceGFX), 1 - call Get1bpp_2 - ret -; fb4f2 - -LoadBattleFontsHPBar: ; fb4f2 - ld de, FontBattleExtra - ld hl, vTiles2 tile $60 - lb bc, BANK(FontBattleExtra), 12 - call Get2bpp_2 - ld hl, vTiles2 tile $70 - ld de, FontBattleExtra tile 16 - lb bc, BANK(FontBattleExtra), 3 ; "<ど>" to "『" - call Get2bpp_2 - call LoadFrame - -LoadHPBar: ; fb50d - ld de, EnemyHPBarBorderGFX - ld hl, vTiles2 tile $6c - lb bc, BANK(EnemyHPBarBorderGFX), 4 - call Get1bpp_2 - ld de, HPExpBarBorderGFX - ld hl, vTiles2 tile $73 - lb bc, BANK(HPExpBarBorderGFX), 6 - call Get1bpp_2 - ld de, ExpBarGFX - ld hl, vTiles2 tile $55 - lb bc, BANK(ExpBarGFX), 9 - call Get2bpp_2 - ld de, MobilePhoneTilesGFX tile 7 ; mobile phone icon - ld hl, vTiles2 tile $5e - lb bc, BANK(MobilePhoneTilesGFX), 2 - call Get2bpp_2 - ret -; fb53e - -StatsScreen_LoadFont: ; fb53e - call _LoadFontsBattleExtra - ld de, EnemyHPBarBorderGFX - ld hl, vTiles2 tile $6c - lb bc, BANK(EnemyHPBarBorderGFX), 4 - call Get1bpp_2 - ld de, HPExpBarBorderGFX - ld hl, vTiles2 tile $78 - lb bc, BANK(HPExpBarBorderGFX), 1 - call Get1bpp_2 - ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE - ld hl, vTiles2 tile $76 - lb bc, BANK(HPExpBarBorderGFX), 2 - call Get1bpp_2 - ld de, ExpBarGFX - ld hl, vTiles2 tile $55 - lb bc, BANK(ExpBarGFX), 8 - call Get2bpp_2 -LoadStatsScreenPageTilesGFX: ; fb571 - ld de, StatsScreenPageTilesGFX - ld hl, vTiles2 tile $31 - lb bc, BANK(StatsScreenPageTilesGFX), 17 - call Get2bpp_2 - ret -; fb57e diff --git a/main.asm b/main.asm index 174063b50..a939bd84d 100644 --- a/main.asm +++ b/main.asm @@ -258,7 +258,7 @@ INCLUDE "engine/mon_stats.asm" INCLUDE "engine/routines/initlist.asm" INCLUDE "engine/experience.asm" INCLUDE "engine/routines/switchpartymons.asm" -INCLUDE "gfx/load_pics.asm" +INCLUDE "engine/load_pics.asm" INCLUDE "engine/move_mon_wo_mail.asm" INCLUDE "data/pokemon/base_stats.asm" INCLUDE "data/pokemon/names.asm" @@ -355,7 +355,7 @@ SECTION "bank2E", ROMX INCLUDE "engine/events/map_name_sign.asm" INCLUDE "engine/events/checkforhiddenitems.asm" INCLUDE "engine/events/treemons.asm" -INCLUDE "gfx/fishing.asm" +INCLUDE "engine/events/loadfishinggfx.asm" INCLUDE "engine/radio.asm" INCLUDE "engine/mail_2.asm" @@ -447,7 +447,7 @@ INCLUDE "engine/crystal_intro.asm" SECTION "bank3E", ROMX -INCLUDE "gfx/font.asm" +INCLUDE "engine/load_font.asm" INCLUDE "engine/time_capsule.asm" INCLUDE "engine/events/name_rater.asm" INCLUDE "engine/routines/playslowcry.asm" @@ -477,7 +477,7 @@ INCLUDE "engine/warp_connection.asm" INCLUDE "engine/mystery_gift.asm" INCLUDE "engine/battle/used_move_text.asm" INCLUDE "mobile/mobile_41.asm" -INCLUDE "gfx/overworld_font.asm" +INCLUDE "engine/routines/loadoverworldfont.asm" SECTION "Mobile 42", ROMX