From 309079524bd5d28883ad7aa707007673180103ae Mon Sep 17 00:00:00 2001 From: mid-kid Date: Tue, 4 Jun 2019 13:11:29 +0200 Subject: [PATCH 01/10] Fix menu_coords for pokecenter pc --- engine/events/pokecenter_pc.asm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index b899f9323..452d28306 100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -236,8 +236,7 @@ Function15715: PlayersPCMenuData: db MENU_BACKUP_TILES ; flags - db 0, 0 ; top left corner coords (y, x) - db 12, 15 ; bottom right corner coords (y, x) + menu_coords 0, 0, 15, 12 dw .PlayersPCMenuData db 1 ; default selected option From b6277408a09b24cecd9d982cce8ff98251752f93 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Tue, 4 Jun 2019 13:31:22 +0200 Subject: [PATCH 02/10] Misc fixes --- data/text/battle.asm | 3 +-- data/text/common_2.asm | 2 +- engine/pokemon/bills_pc.asm | 14 +++++++------- home/string.asm | 2 +- mobile/mobile_46.asm | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/data/text/battle.asm b/data/text/battle.asm index 56a1cb8e1..722c3e289 100644 --- a/data/text/battle.asm +++ b/data/text/battle.asm @@ -414,9 +414,8 @@ BecameConfusedText: text "" line "became confused!" prompt -; ItemHealedConfusion -BattleText_ItemHealedConfusion: ; ItemHealedConfusion +BattleText_ItemHealedConfusion: text "A @" text_ram wStringBuffer1 text " rid" diff --git a/data/text/common_2.asm b/data/text/common_2.asm index 6e2d21800..29f5dc0bb 100644 --- a/data/text/common_2.asm +++ b/data/text/common_2.asm @@ -815,7 +815,7 @@ UnknownText_0x1c0df3:: UnknownText_0x1c0e24:: text "It's @" - text_ram wBreedMon1 + text_ram wBreedMon1Nick text_start line "that was left with" cont "the DAY-CARE MAN." diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index b63e481f6..8dcde72fc 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -241,16 +241,16 @@ BillsPCDepositMenuHeader: Unreferenced_BillsPCClearThreeBoxes: hlcoord 0, 0 - ld b, 4 - ld c, 8 + ld b, 4 + ld c, 8 call ClearBox hlcoord 0, 4 ld b, 10 - ld c, 9 + ld c, 9 call ClearBox hlcoord 0, 14 - ld b, 2 - ld c, 8 + ld b, 2 + ld c, 8 call ClearBox ret @@ -1854,7 +1854,7 @@ TryWithdrawPokemon: ld h, b ld de, wStringBuffer1 call PlaceString - ld a, $e7 + ld a, "!" ld [bc], a ld c, 50 call DelayFrames @@ -1913,7 +1913,7 @@ ReleasePKMN_ByePKMN: call PlaceString ld l, c ld h, b - ld [hl], $e7 + ld [hl], "!" ld c, 50 call DelayFrames ret diff --git a/home/string.asm b/home/string.asm index 702ab50ff..86de2e273 100644 --- a/home/string.asm +++ b/home/string.asm @@ -6,7 +6,7 @@ InitString:: InitName:: ; Intended for names, so this function is limited to ten characters. push hl - ld c, 10 + ld c, NAME_LENGTH - 1 _InitString:: ; if the string pointed to by hl is empty (defined as "zero or more spaces ; followed by a null"), then initialize it to the string pointed to by de. diff --git a/mobile/mobile_46.asm b/mobile/mobile_46.asm index 78b728e46..e28cb2aeb 100644 --- a/mobile/mobile_46.asm +++ b/mobile/mobile_46.asm @@ -3796,9 +3796,9 @@ BattleTowerRoomMenu_WaitForMessage: call BattleTowerRoomMenu_IncrementJumptable BattleTowerRoomMenu_DelayRestartMenu: - ; Loops while (--[wcd50] != 0), - ; to create some sort of "delay" after the message is written on the screen, - ; before starting the menu again. + ; Loops while (--[wcd50] != 0), + ; to create some sort of "delay" after the message is written on the screen, + ; before starting the menu again. ld hl, wcd50 dec [hl] ret nz From 7b47aeaf79946ca3edecff16aafc2c5fd5c7af73 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Tue, 4 Jun 2019 13:34:18 +0200 Subject: [PATCH 03/10] Redump slots_1.png with 16 as width. --- Makefile | 1 + gfx/slots/slots_1.png | Bin 446 -> 433 bytes 2 files changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 9bd7e17a7..b3a9e8ce9 100644 --- a/Makefile +++ b/Makefile @@ -181,6 +181,7 @@ gfx/title/logo.2bpp: rgbgfx += -x 4 gfx/trade/ball.2bpp: tools/gfx += --remove-whitespace gfx/trade/game_boy_n64.2bpp: tools/gfx += --trim-whitespace +gfx/slots/slots_1.2bpp: tools/gfx += --trim-whitespace gfx/slots/slots_2.2bpp: tools/gfx += --interleave --png=$< gfx/slots/slots_3.2bpp: tools/gfx += --interleave --png=$< --remove-duplicates --keep-whitespace --remove-xflip diff --git a/gfx/slots/slots_1.png b/gfx/slots/slots_1.png index a10340844165a9ba0aefac896741d99f5f0abcf1..10431e7192fb7650f1810f94a52d6a67a05762e7 100644 GIT binary patch literal 433 zcmV;i0Z#sjP){f8eBy^KN)Gks)gXTK;01iGyiwbT|7VMN@EcGb(3Zl43q3_`o z+pQGpe{UOFse_*3~WA z7rNmKg1(CdgszJvUFogIYITOtrC;D~<_JqKi#ioKL_H-oy9)70JRFVW z5(l4>;y?&a`b9i`;ZUC65zDg&9~!$!mAa;^tNV}rH3vC*CD z8*nU%Qm8eF{j|W^ z#bojqm=Gzx>aoZTjse2YS~&5uTb%h>2OU3aqwQx8IQ6r8wASN7r#ogV`8OhquoDka zVmGmCCuP*H%3U1#QbD}Zb)dFD$<8VPc(bEv+m06hy5HZy<%rZQW_uPhV$0&tb3_iI b)Dpe{&b0L~*RU8000000NkvXXu0mjfs<_8e literal 446 zcmV;v0YUzWP)>m0004nNkl|%I0zP$H-m%BF!YX@{H_ob*c}LyE&;|NX>4>|2kyLAnR{Nzt;c$NRZySzBSRdn8D2Nd-!tXZE9mq#vFfg zY|dEp>G<^I$TsQ<)zMUxrmCok$1#nbiRFu@FZyrvZJteIF_VvkCNwN=Ml?3*PQb-= zDMeb0XOqq3{9bVmdudNRJyeb)pldH)=*$bOTfj;3NLH?^4c ztY0o>I$cb>8ELF5>QHw$bvSoYUA3S^*e1LseBi<1&f(0Vyh($ From c7fdf5f9ec4eb6597278fc234dbd2349b893f528 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Thu, 6 Jun 2019 23:59:13 +0200 Subject: [PATCH 04/10] Fix overworld scrolling function names --- engine/overworld/player_step.asm | 28 ++++++++++++++-------------- home/map.asm | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/engine/overworld/player_step.asm b/engine/overworld/player_step.asm index eb1e88cf4..b035face1 100644 --- a/engine/overworld/player_step.asm +++ b/engine/overworld/player_step.asm @@ -126,25 +126,25 @@ UpdateOverworldMap: .step_down call .ScrollOverworldMapDown call LoadMapPart - call ScrollMapUp + call ScrollMapDown ret .step_up call .ScrollOverworldMapUp call LoadMapPart - call ScrollMapDown + call ScrollMapUp ret .step_left call .ScrollOverworldMapLeft call LoadMapPart - call ScrollMapRight + call ScrollMapLeft ret .step_right call .ScrollOverworldMapRight call LoadMapPart - call ScrollMapLeft + call ScrollMapRight ret .ScrollOverworldMapDown: @@ -164,14 +164,14 @@ UpdateOverworldMap: cp 2 ; was 1 jr nz, .done_down ld [hl], 0 - call .Add6ToOverworldMapAnchor + call .ScrollMapDataDown .done_down ret -.Add6ToOverworldMapAnchor: +.ScrollMapDataDown: ld hl, wOverworldMapAnchor ld a, [wMapWidth] - add 6 + add 3 * 2 ; surrounding tiles add [hl] ld [hli], a ret nc @@ -195,14 +195,14 @@ UpdateOverworldMap: cp -1 ; was 0 jr nz, .done_up ld [hl], $1 - call .Sub6FromOverworldMapAnchor + call .ScrollMapDataUp .done_up ret -.Sub6FromOverworldMapAnchor: +.ScrollMapDataUp: ld hl, wOverworldMapAnchor ld a, [wMapWidth] - add 6 + add 3 * 2 ; surrounding tiles ld b, a ld a, [hl] sub b @@ -227,11 +227,11 @@ UpdateOverworldMap: cp -1 jr nz, .done_left ld [hl], 1 - call .DecrementwOverworldMapAnchor + call .ScrollMapDataLeft .done_left ret -.DecrementwOverworldMapAnchor: +.ScrollMapDataLeft: ld hl, wOverworldMapAnchor ld a, [hl] sub 1 @@ -256,11 +256,11 @@ UpdateOverworldMap: cp 2 jr nz, .done_right ld [hl], 0 - call .IncrementwOverworldMapAnchor + call .ScrollMapDataRight .done_right ret -.IncrementwOverworldMapAnchor: +.ScrollMapDataRight: ld hl, wOverworldMapAnchor ld a, [hl] add 1 diff --git a/home/map.asm b/home/map.asm index 659e5688d..02df97323 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1151,7 +1151,7 @@ UnmaskObject:: ld [hl], 0 ; unmasked ret -ScrollMapDown:: +ScrollMapUp:: hlcoord 0, 0 ld de, wBGMapBuffer call BackupBGMapRow @@ -1166,7 +1166,7 @@ ScrollMapDown:: ldh [hBGMapUpdate], a ret -ScrollMapUp:: +ScrollMapDown:: hlcoord 0, SCREEN_HEIGHT - 2 ld de, wBGMapBuffer call BackupBGMapRow @@ -1189,7 +1189,7 @@ ScrollMapUp:: ldh [hBGMapUpdate], a ret -ScrollMapRight:: +ScrollMapLeft:: hlcoord 0, 0 ld de, wBGMapBuffer call BackupBGMapColumn @@ -1204,7 +1204,7 @@ ScrollMapRight:: ldh [hBGMapUpdate], a ret -ScrollMapLeft:: +ScrollMapRight:: hlcoord SCREEN_WIDTH - 2, 0 ld de, wBGMapBuffer call BackupBGMapColumn From 54b87ecea87916bd140c0c6197eb203df9992221 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sun, 9 Jun 2019 00:05:32 +0200 Subject: [PATCH 05/10] Document in-battle move selection menu scrolling glitch What a mouthful... --- docs/bugs_and_glitches.md | 53 +++++++++++++++++++++++++++++++++++++++ tools/toc.py | 2 ++ 2 files changed, 55 insertions(+) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index c9437b3e1..dd0ed6290 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -55,6 +55,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b - [No bump noise if standing on tile `$3E`](#no-bump-noise-if-standing-on-tile-3e) - [Playing Entei's Pokédex cry can distort Raikou's and Suicune's](#playing-enteis-pokédex-cry-can-distort-raikous-and-suicunes) - [In-battle “`…`” ellipsis is too high](#in-battle--ellipsis-is-too-high) +- [Move selection menu doesn't handle joypad properly](#move-selection-menu-doesnt-handle-joypad-properly) - [Two tiles in the `port` tileset are drawn incorrectly](#two-tiles-in-the-port-tileset-are-drawn-incorrectly) - [`LoadMetatiles` wraps around past 128 blocks](#loadmetatiles-wraps-around-past-128-blocks) - [Surfing directly across a map connection does not load the new map](#surfing-directly-across-a-map-connection-does-not-load-the-new-map) @@ -1334,6 +1335,58 @@ This is a mistake with the “`…`” tile in [gfx/battle/hp_exp_bar_border.png ![image](https://raw.githubusercontent.com/pret/pokecrystal/master/docs/images/hp_exp_bar_border.png) +## Move selection menu doesn't handle joypad properly + +This is an oversight, where `hInMenu` isn't set properly in the menu that handles selecting moves in a battle. Because of this, your cursor is rendered unable to keep scrolling when one of the directional keys is being held. + +**Fix:** Edit `BattleTurn` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm): + +```diff + BattleTurn: ++ ldh a, [hInMenu] ++ push af ++ ld a, 1 ++ ldh [hInMenu], a ++ + .loop + + ... + + jp .loop + + .quit ++ pop af ++ ldh [hInMenu], a + ret +``` + +There existed one way in which this bug would be temporarily "fixed" in-game, and that's when the credits sequence is triggered, `hInMenu` will be set but never unset. This has no bad effect upon the rest of the game, but you might want to fix it regardless. + +**Fix:** Edit `Credits` in [engine/movie/credits.asm](https://github.com/pret/pokecrystal/blob/master/engine/movie/credits.asm): + +```diff + ldh a, [hVBlank] + push af + ld a, $5 + ldh [hVBlank], a ++ ldh a, [hInMenu] ++ push af + ld a, $1 + ldh [hInMenu], a + + ... + + ldh [hLCDCPointer], a + ldh [hBGMapAddress], a ++ pop af ++ ldh [hInMenu], a + pop af + ldh [hVBlank], a + pop af + ldh [rSVBK], a +``` + + ## Two tiles in the `port` tileset are drawn incorrectly This is a mistake with the left-hand warp carpet corner tiles in [gfx/tilesets/port.png](https://github.com/pret/pokecrystal/blob/master/gfx/tilesets/port.png): diff --git a/tools/toc.py b/tools/toc.py index 8ff50be94..13b75ae1c 100755 --- a/tools/toc.py +++ b/tools/toc.py @@ -17,6 +17,7 @@ valid_toc_headings = {'## TOC', '##TOC'} TocItem = namedtuple('TocItem', ['name', 'anchor', 'level']) punctuation_regexp = re.compile(r'[^\w\- ]+') +specialchar_regexp = re.compile(r'[⅔]+') def name_to_anchor(name): # GitHub's algorithm for generating anchors from headings @@ -24,6 +25,7 @@ def name_to_anchor(name): anchor = name.strip().lower() # lowercase anchor = re.sub(punctuation_regexp, '', anchor) # remove punctuation anchor = anchor.replace(' ', '-') # replace spaces with dash + anchor = re.sub(specialchar_regexp, '', anchor) # remove misc special chars return anchor def get_toc_index(lines): From 6b3735340604670d5fe1bfe4a31e59ad5c7bfb02 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sun, 9 Jun 2019 00:24:40 +0200 Subject: [PATCH 06/10] Properly disassemble MenuData_0x4851b --- mobile/mobile_12.asm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mobile/mobile_12.asm b/mobile/mobile_12.asm index 2f9041d1f..838e82f41 100644 --- a/mobile/mobile_12.asm +++ b/mobile/mobile_12.asm @@ -584,13 +584,21 @@ MenuHeader_0x48513: MenuData_0x4851b: db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_CALL_FUNCTION1_CANCEL ; flags - db 6 ; items + db 6, 0 ; rows, columns + db 1 ; horizontal spacing + dba .Items + dba Function483e8 + dba NULL + dba NULL -Unknown_4851d: - db $00, $01, $12, $2b, $45, $12, $e8, $43, $00, $00, $00, $00, $00, $00, $2e, $00, $01, $02, $03, $04 - db $05, $06, $07, $08, $09, $0a, $0b, $0c, $0d, $0e, $0f, $10, $11, $12, $13, $14, $15, $16, $17, $18 - db $19, $1a, $1b, $1c, $1d, $1e, $1f, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $2a, $2b, $2c - db $2d, $ff +.Items: + db 46 +x = 0 +rept 46 + db x +x = x + 1 +endr + db -1 Prefectures: Aichi: db "あいちけん@" ; Aichi From c048b24d255f5f5ac71f5e9d2f4d4864a06edeaf Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sun, 9 Jun 2019 02:31:24 +0200 Subject: [PATCH 07/10] Create constants for ScrollingMenu item formats ...I should've done this quite a while ago. --- constants/menu_constants.asm | 5 +++++ docs/menus.md | 8 ++++---- engine/events/buena.asm | 2 +- engine/events/elevator.asm | 2 +- engine/events/kurt.asm | 4 ++-- engine/events/pokecenter_pc.asm | 4 ++-- engine/items/mart.asm | 2 +- engine/items/pack.asm | 12 ++++++------ engine/items/switch_items.asm | 28 +++++++++++++++------------- engine/menus/scrolling_menu.asm | 6 +++--- engine/overworld/decorations.asm | 2 +- engine/pokemon/bills_pc.asm | 6 +++--- engine/pokemon/mail.asm | 4 ++-- mobile/mobile_12.asm | 2 +- mobile/mobile_22_2.asm | 4 ++-- wram.asm | 2 +- 16 files changed, 50 insertions(+), 43 deletions(-) diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index 4aaf10802..b2249db06 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -32,6 +32,11 @@ shift_const SCROLLINGMENU_ENABLE_START shift_const SCROLLINGMENU_ENABLE_SELECT +; ScrollingMenu items structure format + const_def 1 + const SCROLLINGMENU_ITEMS_NORMAL + const SCROLLINGMENU_ITEMS_QUANTITY + ; MonMenuOptions indexes (see data/mon_menu.asm) ; used by PokemonActionSubmenu (see engine/pokemon/mon_menu.asm) const_def 1 diff --git a/docs/menus.md b/docs/menus.md index 35bb14d3a..cd783290a 100644 --- a/docs/menus.md +++ b/docs/menus.md @@ -26,7 +26,7 @@ Structure: .MenuData: db 0 ; flags db 5, 0 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dba Items dba Function1 dba Function2 @@ -66,9 +66,9 @@ Function3: Called to display anything else, whenever the cursor is moved. There is no register of importance that should be preserved in any of these functions. -The `; horizontal spacing` item in each `MenuData` is a misnomer. It changes how the `Items` struct looks. +The `; item format` entry in each `MenuData` changes how the `Items` struct looks. -If it's 1: +If it's `SCROLLINGMENU_ITEMS_NORMAL` (1): ``` db entries not including cancel @@ -78,7 +78,7 @@ db -1 ; cancel ... ``` -If it's 2: +If it's `SCROLLINGMENU_ITEMS_QUANTITY` (2): ``` db entries not including cancel diff --git a/engine/events/buena.asm b/engine/events/buena.asm index 97a28549b..3e78dfa91 100644 --- a/engine/events/buena.asm +++ b/engine/events/buena.asm @@ -263,7 +263,7 @@ Buena_PrizeMenu: .MenuData: db SCROLLINGMENU_DISPLAY_ARROWS ; flags db 4, 13 ; rows, columns - db 1 ; spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dba .indices dba .prizeitem dba .prizepoints diff --git a/engine/events/elevator.asm b/engine/events/elevator.asm index 37de3f1b6..8394cf442 100644 --- a/engine/events/elevator.asm +++ b/engine/events/elevator.asm @@ -184,7 +184,7 @@ Elevator_MenuHeader: Elevator_MenuData: db SCROLLINGMENU_DISPLAY_ARROWS ; flags db 4, 0 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wCurElevator dba GetElevatorFloorStrings dba NULL diff --git a/engine/events/kurt.asm b/engine/events/kurt.asm index 234e5f424..3dd700dbb 100644 --- a/engine/events/kurt.asm +++ b/engine/events/kurt.asm @@ -87,8 +87,8 @@ Kurt_SelectApricorn: .MenuData: db SCROLLINGMENU_DISPLAY_ARROWS ; flags - db 4, 7 - db 1 + db 4, 7 ; rows, columns + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wBuffer1 dba .Name dba .Quantity diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index 452d28306..fa06d971e 100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -625,8 +625,8 @@ PCItemsJoypad: .MenuData: db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_DISPLAY_ARROWS ; flags - db 4, 8 ; rows/cols? - db 2 ; horizontal spacing? + db 4, 8 ; rows, columns + db SCROLLINGMENU_ITEMS_QUANTITY ; item format dbw 0, wNumPCItems dba PlaceMenuItemName dba PlaceMenuItemQuantity diff --git a/engine/items/mart.asm b/engine/items/mart.asm index 6341e9e6e..0209aac23 100644 --- a/engine/items/mart.asm +++ b/engine/items/mart.asm @@ -600,7 +600,7 @@ MenuHeader_Buy: .MenuData db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags db 4, 8 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wCurMart dba PlaceMenuItemName dba .PrintBCDPrices diff --git a/engine/items/pack.asm b/engine/items/pack.asm index 268a013bc..d5d331720 100644 --- a/engine/items/pack.asm +++ b/engine/items/pack.asm @@ -1465,7 +1465,7 @@ ItemsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns - db 2 ; horizontal spacing + db SCROLLINGMENU_ITEMS_QUANTITY ; item format dbw 0, wNumItems dba PlaceMenuItemName dba PlaceMenuItemQuantity @@ -1480,7 +1480,7 @@ PC_Mart_ItemsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns - db 2 ; horizontal spacing + db SCROLLINGMENU_ITEMS_QUANTITY ; item format dbw 0, wNumItems dba PlaceMenuItemName dba PlaceMenuItemQuantity @@ -1495,7 +1495,7 @@ KeyItemsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wNumKeyItems dba PlaceMenuItemName dba PlaceMenuItemQuantity @@ -1510,7 +1510,7 @@ PC_Mart_KeyItemsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wNumKeyItems dba PlaceMenuItemName dba PlaceMenuItemQuantity @@ -1525,7 +1525,7 @@ BallsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags db 5, 8 ; rows, columns - db 2 ; horizontal spacing + db SCROLLINGMENU_ITEMS_QUANTITY ; item format dbw 0, wNumBalls dba PlaceMenuItemName dba PlaceMenuItemQuantity @@ -1540,7 +1540,7 @@ PC_Mart_BallsPocketMenuHeader: .MenuData: db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags db 5, 8 ; rows, columns - db 2 ; horizontal spacing + db SCROLLINGMENU_ITEMS_QUANTITY ; item format dbw 0, wNumBalls dba PlaceMenuItemName dba PlaceMenuItemQuantity diff --git a/engine/items/switch_items.asm b/engine/items/switch_items.asm index 81b5ac6a5..10fe535b3 100644 --- a/engine/items/switch_items.asm +++ b/engine/items/switch_items.asm @@ -48,7 +48,7 @@ SwitchItemsInBag: call ItemSwitch_GetNthItem dec hl push hl - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW add hl, bc ld d, h ld e, l @@ -74,7 +74,7 @@ SwitchItemsInBag: call ItemSwitch_GetNthItem ld d, h ld e, l - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW add hl, bc pop bc call CopyBytes @@ -162,7 +162,7 @@ Function249d1: .asm_24a25 dec [hl] - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW push bc ld a, [wSwitchItem] call ItemSwitch_GetNthItem @@ -183,7 +183,7 @@ Function249d1: Function24a40: call ItemSwitch_GetNthItem ld de, wd002 - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW call CopyBytes ret @@ -192,13 +192,13 @@ Function24a4d: ld d, h ld e, l ld hl, wd002 - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW call CopyBytes ret ItemSwitch_GetNthItem: push af - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW ld hl, wMenuData_ItemsPointerAddr ld a, [hli] ld h, [hl] @@ -210,7 +210,7 @@ ItemSwitch_GetNthItem: Function24a6c: push hl - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW ld a, d sub e jr nc, .dont_negate @@ -224,13 +224,13 @@ Function24a6c: pop hl ret -ItemSwitch_ConvertSpacingToDW: +ItemSwitch_ConvertItemFormatToDW: ; This function is absolutely idiotic. push hl - ld a, [wMenuData_ScrollingMenuSpacing] + ld a, [wMenuData_ScrollingMenuItemFormat] ld c, a ld b, 0 - ld hl, .spacing_dws + ld hl, .format_dws add hl, bc add hl, bc ld c, [hl] @@ -239,12 +239,14 @@ ItemSwitch_ConvertSpacingToDW: pop hl ret -.spacing_dws - dw 0, 1, 2 +.format_dws + dw 0 + dw 1 + dw 2 Function24a97: push af - call ItemSwitch_ConvertSpacingToDW + call ItemSwitch_ConvertItemFormatToDW ld a, c cp 2 jr nz, .not_2 diff --git a/engine/menus/scrolling_menu.asm b/engine/menus/scrolling_menu.asm index e47d656bc..b26442dc7 100644 --- a/engine/menus/scrolling_menu.asm +++ b/engine/menus/scrolling_menu.asm @@ -497,10 +497,10 @@ ScrollingMenu_GetListItemCoordAndFunctionArgs: ld h, [hl] ld l, a inc hl ; items - ld a, [wMenuData_ScrollingMenuSpacing] - cp 1 + ld a, [wMenuData_ScrollingMenuItemFormat] + cp SCROLLINGMENU_ITEMS_NORMAL jr z, .got_spacing - cp 2 + cp SCROLLINGMENU_ITEMS_QUANTITY jr z, .pointless_jump .pointless_jump add hl, de diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm index c601b65c3..3b40641f3 100644 --- a/engine/overworld/decorations.asm +++ b/engine/overworld/decorations.asm @@ -409,7 +409,7 @@ PopulateDecoCategoryMenu: .ScrollingMenuData: db SCROLLINGMENU_DISPLAY_ARROWS ; flags db 8, 0 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wd002 ; text pointer dba DecorationMenuFunction dbw 0, 0 diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index 8dcde72fc..162c94887 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -2269,9 +2269,9 @@ _ChangeBox_MenuHeader: db 1 ; default option .MenuData - db MENU_UNUSED_1 | MENU_UNUSED_3 ; flags - db 4, 0 - db 1 + db SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags + db 4, 0 ; rows, columns + db SCROLLINGMENU_ITEMS_NORMAL ; item format dba .boxes dba .boxnames dba NULL diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm index 04c9a98e2..f89a51944 100644 --- a/engine/pokemon/mail.asm +++ b/engine/pokemon/mail.asm @@ -543,8 +543,8 @@ MailboxPC: .TopMenuData: db SCROLLINGMENU_DISPLAY_ARROWS ; flags - db 4, 0 ; rows/columns? - db 1 ; horizontal spacing? + db 4, 0 ; rows, columns + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wMailboxCount ; text pointer dba MailboxPC_PrintMailAuthor dba NULL diff --git a/mobile/mobile_12.asm b/mobile/mobile_12.asm index 838e82f41..f3453328b 100644 --- a/mobile/mobile_12.asm +++ b/mobile/mobile_12.asm @@ -585,7 +585,7 @@ MenuHeader_0x48513: MenuData_0x4851b: db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT | SCROLLINGMENU_CALL_FUNCTION1_CANCEL ; flags db 6, 0 ; rows, columns - db 1 ; horizontal spacing + db SCROLLINGMENU_ITEMS_NORMAL ; item format dba .Items dba Function483e8 dba NULL diff --git a/mobile/mobile_22_2.asm b/mobile/mobile_22_2.asm index c86b0711b..0e5b56099 100644 --- a/mobile/mobile_22_2.asm +++ b/mobile/mobile_22_2.asm @@ -883,8 +883,8 @@ MenuHeader_0x8b867: MenuData_0x8b870: db SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT ; flags - db 5 ; items - db 3, 1 + db 5, 3 ; rows, columns + db SCROLLINGMENU_ITEMS_NORMAL ; item format dbw 0, wd002 dba Function8b880 dba Function8b88c diff --git a/wram.asm b/wram.asm index 22cc9dca9..3d937aff5 100644 --- a/wram.asm +++ b/wram.asm @@ -1481,7 +1481,7 @@ NEXTU ; cf92 ; Scrolling Menu wMenuData_ScrollingMenuHeight:: db ; cf92 wMenuData_ScrollingMenuWidth:: db ; cf93 -wMenuData_ScrollingMenuSpacing:: db ; cf94 +wMenuData_ScrollingMenuItemFormat:: db ; cf94 wMenuData_ItemsPointerBank:: db ; cf95 wMenuData_ItemsPointerAddr:: dw ; cf97 wMenuData_ScrollingMenuFunction1:: ds 3 ; cf98 From d6db0104294aa5f449dac69e1965f552d95440fa Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sun, 9 Jun 2019 17:46:06 +0200 Subject: [PATCH 08/10] Document high nybble of PrintNum `c` register --- engine/math/print_num.asm | 2 ++ engine/pokedex/pokedex_2.asm | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/engine/math/print_num.asm b/engine/math/print_num.asm index fce3c9027..62ef97fb3 100644 --- a/engine/math/print_num.asm +++ b/engine/math/print_num.asm @@ -2,6 +2,8 @@ _PrintNum:: ; Print c digits of the b-byte value from de to hl. ; Allows 2 to 7 digits. For 1-digit numbers, add ; the value to char "0" instead of calling PrintNum. +; The high nybble of the c register specifies how many of the total amount of +; digits will be in front of the decimal point. ; Some extra flags can be given in bits 5-7 of b. ; Bit 5: money if set (unless left-aligned without leading zeros) ; Bit 6: right-aligned if set diff --git a/engine/pokedex/pokedex_2.asm b/engine/pokedex/pokedex_2.asm index 62e7e853b..0f42aea3a 100644 --- a/engine/pokedex/pokedex_2.asm +++ b/engine/pokedex/pokedex_2.asm @@ -124,14 +124,16 @@ DisplayDexEntry: jr z, .skip_height push hl push de +; Print the height with two of the four digits will be in front of the decimal point ld hl, sp+$0 ld d, h ld e, l hlcoord 12, 7 - lb bc, 2, PRINTNUM_MONEY | 4 + lb bc, 2, (2 << 4) | 4 call PrintNum +; Replace the decimal point with a ft symbol hlcoord 14, 7 - ld [hl], $5e ; ft symbol + ld [hl], $5e pop af pop hl @@ -148,11 +150,12 @@ DisplayDexEntry: or d jr z, .skip_weight push de +; Print the height with four of the five digits will be in front of the decimal point ld hl, sp+$0 ld d, h ld e, l hlcoord 11, 9 - lb bc, 2, PRINTNUM_RIGHTALIGN | 5 + lb bc, 2, (4 << 4) | 5 call PrintNum pop de From ad299b16358b5d73e24e0c12d2746936aad7f2ce Mon Sep 17 00:00:00 2001 From: mid-kid Date: Mon, 10 Jun 2019 01:52:46 +0200 Subject: [PATCH 09/10] Apply suggested changes --- docs/bugs_and_glitches.md | 50 +++++++++++++++++++----------------- engine/pokedex/pokedex_2.asm | 4 +-- engine/pokegear/pokegear.asm | 8 +++--- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index dd0ed6290..d1cbf0dee 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -1337,30 +1337,10 @@ This is a mistake with the “`…`” tile in [gfx/battle/hp_exp_bar_border.png ## Move selection menu doesn't handle joypad properly -This is an oversight, where `hInMenu` isn't set properly in the menu that handles selecting moves in a battle. Because of this, your cursor is rendered unable to keep scrolling when one of the directional keys is being held. +([Video](https://www.youtube.com/watch?v=vjFUo6Jr4po&t=438)) -**Fix:** Edit `BattleTurn` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm): - -```diff - BattleTurn: -+ ldh a, [hInMenu] -+ push af -+ ld a, 1 -+ ldh [hInMenu], a -+ - .loop - - ... - - jp .loop - - .quit -+ pop af -+ ldh [hInMenu], a - ret -``` - -There existed one way in which this bug would be temporarily "fixed" in-game, and that's when the credits sequence is triggered, `hInMenu` will be set but never unset. This has no bad effect upon the rest of the game, but you might want to fix it regardless. +`hInMenu` isn't defined in the menu that handles selecting moves in a battle. Because of this, your cursor is usually rendered unable to keep scrolling when one of the directional keys is being held. It's up for debate whether this behavior was intentional or not, but this value should be defined when in the move selection menu. A value of 1 will allow it to keep scrolling, though it's usually 0 by default. +There exists one way in which this behaviour would be temporarily changed in-game, and that's when the credits sequence is triggered, `hInMenu` will be set but never unset. This can be fixed with the following: **Fix:** Edit `Credits` in [engine/movie/credits.asm](https://github.com/pret/pokecrystal/blob/master/engine/movie/credits.asm): @@ -1387,6 +1367,30 @@ There existed one way in which this bug would be temporarily "fixed" in-game, an ``` +If you want to make sure `hInMenu` always has a defined value in the move selection menu, the following code will set it to 1: + +**Fix:** Edit `BattleTurn` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm): + +```diff + BattleTurn: ++ ldh a, [hInMenu] ++ push af ++ ld a, 1 ++ ldh [hInMenu], a ++ + .loop + + ... + + jp .loop + + .quit ++ pop af ++ ldh [hInMenu], a + ret +``` + + ## Two tiles in the `port` tileset are drawn incorrectly This is a mistake with the left-hand warp carpet corner tiles in [gfx/tilesets/port.png](https://github.com/pret/pokecrystal/blob/master/gfx/tilesets/port.png): diff --git a/engine/pokedex/pokedex_2.asm b/engine/pokedex/pokedex_2.asm index 0f42aea3a..ac47bd484 100644 --- a/engine/pokedex/pokedex_2.asm +++ b/engine/pokedex/pokedex_2.asm @@ -124,7 +124,7 @@ DisplayDexEntry: jr z, .skip_height push hl push de -; Print the height with two of the four digits will be in front of the decimal point +; Print the height, with two of the four digits in front of the decimal point ld hl, sp+$0 ld d, h ld e, l @@ -150,7 +150,7 @@ DisplayDexEntry: or d jr z, .skip_weight push de -; Print the height with four of the five digits will be in front of the decimal point +; Print the weight, with four of the five digits in front of the decimal point ld hl, sp+$0 ld d, h ld e, l diff --git a/engine/pokegear/pokegear.asm b/engine/pokegear/pokegear.asm index 13b561d4b..d0e7e8ca0 100644 --- a/engine/pokegear/pokegear.asm +++ b/engine/pokegear/pokegear.asm @@ -335,7 +335,7 @@ InitPokegearTilemap: .ok farcall PokegearMap ld a, $07 - ld bc, $12 + ld bc, SCREEN_WIDTH - 2 hlcoord 1, 2 call ByteFill hlcoord 0, 2 @@ -2165,7 +2165,7 @@ TownMapBubble: hlcoord 1, 1 ; Middle row - ld bc, 18 + ld bc, SCREEN_WIDTH - 2 ld a, " " call ByteFill @@ -2481,10 +2481,10 @@ Pokedex_GetArea: ld a, " " call ByteFill hlcoord 0, 1 - ld a, $6 + ld a, $06 ld [hli], a ld bc, SCREEN_WIDTH - 2 - ld a, $7 + ld a, $07 call ByteFill ld [hl], $17 call GetPokemonName From 7e84f7240328af68723f8419d5079daea32cf21d Mon Sep 17 00:00:00 2001 From: mid-kid Date: Mon, 17 Jun 2019 08:05:29 +0200 Subject: [PATCH 10/10] `end` -> `return` in clair bugfix --- docs/bugs_and_glitches.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index d1cbf0dee..ad6114c77 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -916,7 +916,7 @@ This can bring Pokémon straight from level 1 to 100 by gaining just a few exper + +.UnsetClairScene: + setmapscene DRAGONS_DEN_B1F, SCENE_DRAGONSDENB1F_NOTHING -+ end ++ return ```