aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAsh Ketchum <no-reply@sl0p.foo>2026-07-15 02:01:51 +0200
committerAsh Ketchum <no-reply@sl0p.foo>2026-07-15 02:01:51 +0200
commit849fc45bc57e9a1f85c4fa98103ec04991406627 (patch)
tree393b2932633e22a9d79fedbd442ef3f05a53159d
parentintro: real 2bpp graphic splash (POKeMON SL0P EDITION) (diff)
downloadpokeyellow-849fc45bc57e9a1f85c4fa98103ec04991406627.tar.gz
pokeyellow-849fc45bc57e9a1f85c4fa98103ec04991406627.tar.xz
pokeyellow-849fc45bc57e9a1f85c4fa98103ec04991406627.zip
menu: SL0P MENU scaffolding with WARP as a submenu
Refactor the flat warp menu into a table-driven top-level SL0P MENU opened by SELECT. Each entry = a name in SlopMenuText + a routine in SlopMenuHandlers; handlers return carry set (a warp was started, exit) or clear (back to the menu). Ships two entries: WARP -> WarpSubmenu (the 13-destination town list) HEAL -> SlopHealParty (restore party HP + clear status), demoing an action Shared open/close display handling (hide sprites, single-space flags, wTileMap push, restore). Add an entry by appending a name+handler and bumping SLOP_MENU_COUNT. (renamed engine/warp_menu.asm -> engine/slop_menu.asm)
-rw-r--r--engine/slop_menu.asm223
-rw-r--r--engine/warp_menu.asm110
-rw-r--r--home/overworld.asm4
-rw-r--r--main.asm2
4 files changed, 226 insertions, 113 deletions
diff --git a/engine/slop_menu.asm b/engine/slop_menu.asm
new file mode 100644
index 00000000..56c8e8c5
--- /dev/null
+++ b/engine/slop_menu.asm
@@ -0,0 +1,223 @@
+; SL0P MENU - a top-level menu opened with SELECT in the overworld (hooked in
+; home/overworld.asm). Table-driven so it's easy to grow: each entry has a name
+; in SlopMenuText and a handler in SlopMenuHandlers. A handler returns:
+; carry SET -> a map warp was started; exit the menu and let it proceed
+; carry CLEAR -> return to the SL0P menu (redraw)
+; Handlers may be submenus (WarpSubmenu) or direct actions (SlopHealParty).
+;
+; To add an entry: add a "NAME" line to SlopMenuText, a `dw Handler` to
+; SlopMenuHandlers, and bump SLOP_MENU_COUNT.
+
+DEF SLOP_MENU_COUNT EQU 2
+
+SECTION "Slop Menu", ROMX
+
+SlopMenu::
+; ---- open the menu display (shared by the top menu and every submenu) ----
+ ldh a, [hUILayoutFlags]
+ set BIT_SINGLE_SPACED_LINES, a ; single-spaced list text
+ set BIT_DOUBLE_SPACED_MENU, a ; single-spaced cursor
+ ldh [hUILayoutFlags], a
+ ld a, $ff
+ ld [wUpdateSpritesEnabled], a ; hide the overworld sprites
+ call ClearSprites
+.redraw
+ call ClearScreen
+ hlcoord 5, 1
+ ld de, SlopMenuTitle
+ call PlaceString
+ hlcoord 4, 3
+ lb bc, SLOP_MENU_COUNT + 2, 11
+ call TextBoxBorder
+ hlcoord 6, 4
+ ld de, SlopMenuText
+ call PlaceString
+ call SlopMenuShow
+ xor a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld [wMenuJoypadPollCount], a
+ ld a, 5
+ ld [wTopMenuItemX], a
+ ld a, 4
+ ld [wTopMenuItemY], a
+ ld a, PAD_A | PAD_B
+ ld [wMenuWatchedKeys], a
+ ld a, SLOP_MENU_COUNT - 1
+ ld [wMaxMenuItem], a
+ call HandleMenuInput
+ bit B_PAD_B, a
+ jr nz, .close
+; dispatch: call SlopMenuHandlers[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
+ add a
+ ld e, a
+ ld d, 0
+ ld hl, SlopMenuHandlers
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, .afterHandler
+ push de
+ jp hl ; call [hl]; returns to .afterHandler
+.afterHandler
+ jr c, .exitProceed ; handler started a warp -> let it run
+ jr .redraw ; otherwise back to the SL0P menu
+.exitProceed
+ call SlopMenuRestoreFlags
+ ret
+.close
+ call SlopMenuRestoreFlags
+ ld a, $01
+ ld [wUpdateSpritesEnabled], a
+ call LoadScreenTilesFromBuffer2
+ jp CloseTextDisplay
+
+SlopMenuRestoreFlags:
+ ldh a, [hUILayoutFlags]
+ res BIT_SINGLE_SPACED_LINES, a
+ res BIT_DOUBLE_SPACED_MENU, a
+ ldh [hUILayoutFlags], a
+ ret
+
+; push wTileMap into VRAM and switch on the menu window display (mirrors the
+; tail of DisplayTextIDInit) so a box drawn into wTileMap is actually shown.
+SlopMenuShow:
+ ld b, HIGH(vBGMap1)
+ call CopyScreenTileBufferToVRAM
+ xor a
+ ldh [hWY], a
+ call LoadFontTilePatterns
+ ld a, $01
+ ldh [hAutoBGTransferEnabled], a
+ ret
+
+SlopMenuTitle:
+ db "SL0P MENU@"
+SlopMenuText:
+ db "WARP"
+ next "HEAL@"
+SlopMenuHandlers:
+ dw WarpSubmenu
+ dw SlopHealParty
+
+
+; ---------------------------------------------------------------------------
+; WARP submenu: a town list. On A, start a fly-warp to the chosen map (no
+; BIT_USED_FLY, so no bird) and return carry set. On B, return carry clear.
+; The display was already set up by SlopMenu.
+; ---------------------------------------------------------------------------
+DEF WARP_COUNT EQU 13
+
+WarpSubmenu:
+ call ClearScreen
+ hlcoord 4, 0
+ ld de, WarpTitleText1
+ call PlaceString
+ hlcoord 5, 1
+ ld de, WarpTitleText2
+ call PlaceString
+ hlcoord 3, 2
+ lb bc, 13, 11
+ call TextBoxBorder
+ hlcoord 5, 3
+ ld de, WarpMenuText
+ call PlaceString
+ call SlopMenuShow
+ xor a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld [wMenuJoypadPollCount], a
+ ld a, 4
+ ld [wTopMenuItemX], a
+ ld a, 3
+ ld [wTopMenuItemY], a
+ ld a, PAD_A | PAD_B
+ ld [wMenuWatchedKeys], a
+ ld a, WARP_COUNT - 1
+ ld [wMaxMenuItem], a
+ call HandleMenuInput
+ bit B_PAD_B, a
+ jr nz, .cancel
+ ld a, [wCurrentMenuItem]
+ ld e, a
+ ld d, 0
+ ld hl, WarpMapTable
+ add hl, de
+ ld a, [hl]
+ ld [wDestinationMap], a
+ ld hl, wStatusFlags6
+ set BIT_FLY_WARP, [hl]
+ scf ; carry set = warp started
+ ret
+.cancel
+ and a ; carry clear = back to SL0P menu
+ ret
+
+WarpTitleText1:
+ db "SECRET SL0P@"
+WarpTitleText2:
+ db "WARP MENU@"
+WarpMenuText:
+ db "PALLET"
+ next "VIRIDIAN"
+ next "PEWTER"
+ next "CERULEAN"
+ next "LAVENDER"
+ next "VERMILION"
+ next "CELADON"
+ next "FUCHSIA"
+ next "CINNABAR"
+ next "INDIGO"
+ next "SAFFRON"
+ next "ROUTE 4"
+ next "ROUTE 10@"
+WarpMapTable:
+ db PALLET_TOWN, VIRIDIAN_CITY, PEWTER_CITY, CERULEAN_CITY, LAVENDER_TOWN
+ db VERMILION_CITY, CELADON_CITY, FUCHSIA_CITY, CINNABAR_ISLAND, INDIGO_PLATEAU
+ db SAFFRON_CITY, ROUTE_4, ROUTE_10
+
+
+; ---------------------------------------------------------------------------
+; HEAL action: restore every party member to full HP and clear status.
+; Returns carry clear (back to the SL0P menu).
+; ---------------------------------------------------------------------------
+; party_struct offsets: curHP +$01 (BE), status +$04, maxHP +$22 (BE), size $2C
+SlopHealParty:
+ ld a, [wPartyCount]
+ and a
+ jr z, .done
+ ld c, a
+ ld hl, wPartyMon1
+.loop
+ push hl ; save mon base
+ ld de, $04
+ add hl, de
+ xor a
+ ld [hl], a ; status = 0
+ pop hl
+ push hl
+ ld de, $22
+ add hl, de ; -> maxHP
+ ld a, [hli]
+ ld b, a ; maxHP hi
+ ld e, [hl] ; maxHP lo
+ ld d, b
+ pop hl ; mon base
+ push hl
+ inc hl ; -> curHP hi
+ ld a, d
+ ld [hli], a
+ ld a, e
+ ld [hl], a ; curHP = maxHP
+ pop hl ; mon base
+ ld de, $2C
+ add hl, de ; next mon
+ dec c
+ jr nz, .loop
+.done
+ and a ; carry clear = back to SL0P menu
+ ret
diff --git a/engine/warp_menu.asm b/engine/warp_menu.asm
deleted file mode 100644
index 1fcca73e..00000000
--- a/engine/warp_menu.asm
+++ /dev/null
@@ -1,110 +0,0 @@
-; Quick-warp menu, opened with SELECT in the overworld (hooked in
-; home/overworld.asm). Hides the overworld sprites, clears the screen, and draws
-; a single-spaced destination list. On selection it reuses the fly-warp
-; machinery (wDestinationMap + BIT_FLY_WARP) to warp in at the destination's
-; fly coordinates. BIT_USED_FLY is deliberately NOT set, so arrival uses the
-; teleport-in animation (the departure bird is redirected to a plain fade in
-; engine/overworld/player_animations.asm).
-
-DEF WARP_COUNT EQU 13
-
-SECTION "Warp Menu", ROMX
-
-WarpMenu::
-; single-space the list text (<NEXT> = 1 row) and the menu cursor
- ldh a, [hUILayoutFlags]
- set BIT_SINGLE_SPACED_LINES, a
- set BIT_DOUBLE_SPACED_MENU, a
- ldh [hUILayoutFlags], a
-; hide the overworld sprites so nothing shows behind the menu
- ld a, $ff
- ld [wUpdateSpritesEnabled], a
- call ClearSprites
- call ClearScreen
-; banner, two centered lines above the box
- hlcoord 4, 0
- ld de, WarpTitleText1
- call PlaceString
- hlcoord 5, 1
- ld de, WarpTitleText2
- call PlaceString
-; horizontally-centered menu box (screen is 20 wide; box is 13)
- hlcoord 3, 2
- lb bc, 13, 11
- call TextBoxBorder
- hlcoord 5, 3
- ld de, WarpMenuText
- call PlaceString
-; push wTileMap to VRAM and switch on the menu display (mirrors the tail of
-; DisplayTextIDInit); the overworld renders the scrolled map straight to VRAM,
-; so our box drawn into wTileMap would otherwise be invisible.
- ld b, HIGH(vBGMap1)
- call CopyScreenTileBufferToVRAM
- xor a
- ldh [hWY], a
- call LoadFontTilePatterns
- ld a, $01
- ldh [hAutoBGTransferEnabled], a
- xor a
- ld [wCurrentMenuItem], a
- ld [wLastMenuItem], a
- ld [wMenuWatchMovingOutOfBounds], a
- ld [wMenuJoypadPollCount], a
- ld a, 4
- ld [wTopMenuItemX], a ; cursor column (text at column 5)
- ld a, 3
- ld [wTopMenuItemY], a ; first item row
- ld a, PAD_A | PAD_B
- ld [wMenuWatchedKeys], a
- ld a, WARP_COUNT - 1
- ld [wMaxMenuItem], a
- call HandleMenuInput
- push af ; save pressed keys
- ldh a, [hUILayoutFlags] ; restore default UI spacing
- res BIT_SINGLE_SPACED_LINES, a
- res BIT_DOUBLE_SPACED_MENU, a
- ldh [hUILayoutFlags], a
- pop af
- bit B_PAD_B, a
- jr nz, .cancel
-; A pressed: look up the chosen map id and fire the fly-warp (no BIT_USED_FLY)
- ld a, [wCurrentMenuItem]
- ld e, a
- ld d, 0
- ld hl, WarpMapTable
- add hl, de
- ld a, [hl]
- ld [wDestinationMap], a
- ld hl, wStatusFlags6
- set BIT_FLY_WARP, [hl]
- ret ; overworld loop performs the warp
-.cancel
- ld a, $01
- ld [wUpdateSpritesEnabled], a ; re-enable overworld sprites
- call LoadScreenTilesFromBuffer2
- jp CloseTextDisplay ; redraw the overworld and return
-
-WarpMenuText:
- db "PALLET"
- next "VIRIDIAN"
- next "PEWTER"
- next "CERULEAN"
- next "LAVENDER"
- next "VERMILION"
- next "CELADON"
- next "FUCHSIA"
- next "CINNABAR"
- next "INDIGO"
- next "SAFFRON"
- next "ROUTE 4"
- next "ROUTE 10@"
-
-WarpMapTable:
- db PALLET_TOWN, VIRIDIAN_CITY, PEWTER_CITY, CERULEAN_CITY, LAVENDER_TOWN
- db VERMILION_CITY, CELADON_CITY, FUCHSIA_CITY, CINNABAR_ISLAND, INDIGO_PLATEAU
- db SAFFRON_CITY, ROUTE_4, ROUTE_10
-
-WarpTitleText1:
- db "SECRET SL0P@"
-WarpTitleText2:
- db "WARP MENU@"
diff --git a/home/overworld.asm b/home/overworld.asm
index a2626089..a41a7ba8 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -73,9 +73,9 @@ OverworldLoopLessDelay::
.notSimulating
ldh a, [hJoyPressed]
.checkIfStartIsPressed
- bit B_PAD_SELECT, a ; WARP MENU hotkey
+ bit B_PAD_SELECT, a ; SL0P MENU hotkey
jr z, .notWarpHotkey
- farcall WarpMenu
+ farcall SlopMenu
jp OverworldLoop
.notWarpHotkey
bit B_PAD_START, a
diff --git a/main.asm b/main.asm
index cd466490..fbc83a05 100644
--- a/main.asm
+++ b/main.asm
@@ -424,5 +424,5 @@ INCLUDE "engine/pikachu/pikachu_emotions.asm"
INCLUDE "engine/pikachu/pikachu_movement.asm"
INCLUDE "engine/pikachu/pikachu_pic_animation.asm"
INCLUDE "engine/debug/debug_menu.asm"
-INCLUDE "engine/warp_menu.asm"
+INCLUDE "engine/slop_menu.asm"
INCLUDE "engine/slop_intro.asm"