aboutsummaryrefslogtreecommitdiffstats
path: root/engine/slop_menu.asm
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 /engine/slop_menu.asm
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)
Diffstat (limited to 'engine/slop_menu.asm')
-rw-r--r--engine/slop_menu.asm223
1 files changed, 223 insertions, 0 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