Commit Graph

1356 Commits

Author SHA1 Message Date
bryanthaboi 8e9206b612 Merge pull request #1835 from campavao/rfc-0019-level-visible
engine: pokemon.level_visible, a level a mode can take off the screen (RFC 0019)
2026-08-27 13:38:59 -04:00
bryanthaboi dc99b1f8da Merge pull request #1852 from colsonrice/feat/gen2-save-export
Export Gen 2 cart saves
2026-08-27 13:37:43 -04:00
bryanthaboi 377f1f8a71 Merge pull request #1877 from 1Jamie/flatpak-lic-fix
update flatpak information that was left as template default
2026-08-27 13:36:27 -04:00
bryanthaboi 2441996d45 maybe better menu situation 2026-08-27 12:44:22 -04:00
1jamie 5e7dc556f5 update flatpak information that was left as template default
flatpak properly now marks as oss and points to site and gh
2026-08-27 10:30:44 -05:00
Colson Rice 71a5602b58 Export Gen 2 cart saves
Closes the round trip. Gold, Silver and Crystal progress writes back to a
cartridge save the real game boots.

Writes into the image the save came from. Gen 2 SRAM holds a great deal
this codec does not model and the real game trusts it on CONTINUE, so a
save with no cartridge behind it is refused rather than built from nothing.
That refusal is the known limitation: a game begun in this project has no
lineage to write back into yet.

The image lives BESIDE the slot as saves/<version>/<id>.cart, not in the
save table. 32 KB of binary in the serialized table is 40 KB of Lua source
reparsed on every save and load, for every imported slot, forever.

Only the primary copy is written. TryLoadSaveFile rewrites the backup from
the primary the moment VerifyChecksum passes, so a stale backup heals
itself on the first load and this does not need a second offset mapping.
Crystal arranges its backup differently from Gold and Silver, so that
matters.

What encode now reaches that it did not:

  * the bag, all four pockets, bucketed by each item's own pocket, plus
    wCurBox and the box names. It used to leave them at whatever the
    template carried, so a potion bought in a session never arrived.
  * the RTC footer. importToSlot truncates to 32768, so the image is kept
    at its full length and the footer is carried through. Dropping it
    resets the clock and costs the player daily events, the bug contest
    and a clock-adjustment penalty.
  * 0x1C-0x1E, pokerus and caught data. Left to the template they survive
    POSITIONALLY, so reordering the party gives slot 1 the previous
    occupant's caught level and location.

A bag that cannot be bucketed is refused rather than written short: without
the item table every item falls into ITEM, which holds 20, and a real bag
is bigger than that. Silently dropping the overflow would be worse than
the bug this fixes.

Two bugs in the text encoder that only real names caught: the cart's table
carries the ligature halves PO and KE, so a name containing "PO" became
0x70 where the cart had a plain P; and #glyph counts BYTES in Lua, so every
multi-byte glyph was dropped and came back as "?", which is NIDORAN and
every name with an accent.

Tests

The round trip CHANGES things first, in each place export has to reach, and
reads them back through a fresh decode. Exporting onto the buffer a save was
decoded from proves nothing, because every region encode does not write
matches by construction.

The fixture-gated audit exports a real cart save too, and pins that the
image keeps its size, RTC and all.

./scripts/test.sh passes end to end, and luacheck is clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 10:41:30 -04:00
Colson Rice ebd315b01e Import Gen 2 cart saves
Gold, Silver and Crystal battery saves import now. Export is still refused.

GenSave.lua is pokered's SRAM window and nothing else, which is why the
guard refusing Gen 2 was right to be there. This adds Gen2Save.lua beside
it, covering pokegold and pokecrystal.

Every offset is generated, not transcribed. tools/gen2_sram_offsets.py
reads pokegold.sym and pokecrystal.sym from a pret build and emits
Gen2Layout.lua, including the text table from constants/charmap.asm and
Crystal's backup-save layout. Gen 2 copies a contiguous WRAM block into
SRAM bank 1, so a field's file offset is sPlayerData + (wField -
wPlayerData); the generator asserts that relation against sPokemonData
rather than assuming it, and range-guards anything outside
sGameData..sGameDataEnd.

Gold and Crystal are separate tables because they disagree about nearly
every field. Reading a Crystal save with Gold's numbers gives a party
count of 133 and 13113 hours played, with a checksum that validates.

The cart stores numbers and the engine is keyed by name, so the codec
crosswalks species, moves and items through the generated tables the same
way GenSave.crosswalks does for Gen 1. Without that, an import looks
perfect and the engine cannot read a byte of it.

Shapes that have to match what the engine reads:
  * events is byte index -> packed byte, which Save.scrubEvents validates
    with tonumber. A set of booleans is silently emptied.
  * the bag is one flat save.inventory keyed by item id, which PackMenu
    buckets by each item's pocket. Nothing reads save.keyItems or
    save.balls, and the TM/HM pocket lands here too.
  * position carries the map id, or Save.summary falls through to
    save.spawn and the player resumes somewhere else at their old
    coordinates.
  * mon.status is an ItemEffects.STATUS_CLASS key with statusTurns beside
    it, nil when healthy. 0 is truthy in Lua.

A save the real cartridge would open is not refused: TryLoadSaveFile falls
back to VerifyBackupChecksum, so this does too. Crystal's backup is
contiguous and laid out like the primary; Gold and Silver split theirs
across three sections and have none to offer.

Three suites that pinned Gen 2 import being refused now pin what refuses
instead. Tests live in tests/engine so the ROM-free tier actually runs
them.

./scripts/test.sh passes end to end, and luacheck is clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 10:32:40 -04:00
bryanthaboi e9b815fcac Update RomImporter.lua 2026-08-27 08:39:06 -04:00
bryanthaboi 8b56ec2d77 big egg energy 2026-08-27 07:40:02 -04:00
bryanthaboi f11724f08a Merge pull request #1841 from thibautbus/fix/gen2-pokedex-mod-text 2026-08-27 07:25:03 -04:00
bryanthaboi bd3e02986d test fix and iOS close hide 2026-08-27 07:11:43 -04:00
bryanthaboi eed246f645 CLOSES #1831, CLOSES #1834, CLOSES #1836, CLOSES #1860 2026-08-27 06:09:50 -04:00
bryanthaboi c9d06779d8 Merge pull request #1844 from colsonrice/fix/gen2-save-refusal-message
Refuse a Gen 2 cart save as a Gen 2 save, not as a broken Gen 1 one
2026-08-27 06:04:27 -04:00
bryanthaboi 48d8a4e922 CLOSES #1562, CLOSES #1804, CLOSES #1805, CLOSES #1810, CLOSES #1811, CLOSES #1814, CLOSES #1817, CLOSES #1818, CLOSES #1819, CLOSES #1821, CLOSES #1826, CLOSES #1827, CLOSES #1829, CLOSES #1833, CLOSES #1840, CLOSES #1842, CLOSES #1845, CLOSES #1846, CLOSES #1847, CLOSES #1848, CLOSES #1849, CLOSES #1853, CLOSES #1858, CLOSES #1862 2026-08-27 05:09:26 -04:00
bryanthaboi 5051cb902d Merge pull request #1863 from ShaneMcGovernIE/feat/handheld-osk-and-trigger-scroll 2026-08-26 17:47:04 -04:00
Shane McGovern 2720bfb5d8 feat(ui): scope on-screen VirtualKeyboard to Linux handhelds and restore L2/R2 trigger scrolling 2026-08-26 22:45:09 +01:00
bryanthaboi 6f587520d4 Update HostShell.lua 2026-08-26 17:15:56 -04:00
Colson Rice 3a0a72102f Teach the bug420 SaveConvert double the method importToSlot now calls
CI caught this: tests/engine/save_import_retry_bug420.lua replaces
SaveConvert with a minimal double, and importToSlot now asks it
importSupported before it measures the bytes, so the double answered nil
and the call died.

The double stands in for the real module, so it grows with it. Answering
true keeps that case about the thing it is testing, which is that
importToSlot names the game whose cache to read.

./scripts/test.sh passes end to end locally now, every ROM-free tier.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 15:47:08 -04:00
Colson Rice fe31293566 Refuse a Gen 2 cart save as a Gen 2 save, not as a broken Gen 1 one
#1832 reports a Crystal .sav failing to import with "save data checksum
invalid (main data checksum mismatch)". The save is fine. It is being
measured with the wrong generation's ruler.

SaveFileIO.importToSlot sends anything that is not exactly SAVE_SIZE into
mainChecksumValid, which is pokered's main-data checksum. Gen 2 carts are
MBC3+TIMER, so a real Gold, Silver or Crystal battery save carries an RTC
footer: 32786 bytes, never 32768. It misses the size test, falls into the
checksum branch, and is told it is damaged by a rule written for a
different game. Every real Gen 2 cart save takes that path, every time.

The generation check already exists, it just lives too late, inside
importSav and behind the size gate that has already rejected the save.
This lifts it into SaveConvert.importSupported and exportSupported and
asks before the bytes are measured. Both existing guards route through
the same predicates now, so the early caller and the late one cannot
describe the same game two different ways.

Nothing changes for Gen 1, and Gen 2 is still refused, for the real
reason and in a sentence a player can do something with.

tests/gen2_save_import_message_test.lua covers it. Against the code as it
stands it is 20/26, and the failures are the report itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 14:52:44 -04:00
thibautbus c8eeeaa1f6 Cover the #DEX registry projection fix with a targeted test 2026-08-26 19:44:00 +02:00
thibautbus 273350d11e Route the Gen2 #DEX screen's kind/text through the pokemon registry
src/ui/gen2/PokedexMenu.lua reads its KIND label and both description
pages from data.gen2Pokedex.entries, loaded straight from disk before
mods:load runs -- a separate table from data.pokemon, the `pokemon`
registry's own merge target. mod.content.pokemon:patch(id, { dexEntry =
... }) therefore validated but never reached the screen. Adds
src/core/gen2/PokedexText.lua to project a patched dexEntry onto the
#DEX table after the merge (Game2:load, alongside the other Gen 2
post-merge registries), and a text2 field to the dexEntry schema for
the entry's second description page, which the screen already reads
but the registry had no field for. Also routes the OPTION/SEARCH panel
titles (PokedexMenu.lua) through Strings(), the same literal-wrapping
pattern already used elsewhere in this screen and its siblings.
2026-08-26 19:43:53 +02:00
bryanthaboi 017eafc51b Update release.yml 2026-08-26 13:28:41 -04:00
bryanthaboi 3e4772abf4 big palette energy 2026-08-26 12:04:06 -04:00
DESKTOP-8SRFDDM\cam95 49a5408c2d engine: pokemon.level_visible, a level a mode can take off the screen (RFC 0019)
A Pokémon's level is printed on four Gen 1 surfaces -- both battle
healthboxes, the party rows, and both status pages -- and every one of them
prints it unconditionally. There is no seam, so a mode that wants the number
gone has two options today and both are bad: paint over the engine's own
pixels from render.hud (four rectangles, a background shade to match, and
the palette flashes and healthbox slide to survive), or monkey-patch the
render modules from inside the sandbox, which works and is exactly what
CONTRIBUTING-mods.md tells mods not to do.

The motivating case is a battle royale that scales every party to a shared
rung rising with its fog: the number is the same for everyone, it changes on
a clock, and it reads as a threat it is not -- a Lv37 opponent looks
dangerous to a player who has not worked out that their own team is Lv37
too. A randomizer keeping an encounter unreadable, a challenge run that
forbids level-checking and a blind Nuzlocke want the same switch.

New hook `pokemon.level_visible`, taking the shape the presentation
predicates on the battle screen already use -- battle.status_hud_visible,
battle.bottom_ui_visible, battle.caught_marker_visible: consulted behind
Runtime.wantsHook, default visible, only an explicit false suppresses. It is
not named battle.* because a level is not a battle-only readout, and it
carries the surface that asked (battle.enemy / battle.player / party /
summary) so a mode can hide an opponent's level and keep its own.

src/ui/LevelDisplay.lua holds the one definition of "visible", so the four
call sites are a one-line guard each rather than four copies of the same
five lines that can drift apart.

No layout moves. Each site keeps its own hand-rolled PrintLevel rule
(home/pokemon.asm:335-345), it just asks first. Two details are deliberate:
a status condition still replaces the level on a healthbox exactly as in the
cart, so hiding a level never hides PSN or BRN (the guard is an elseif on
the existing status branch); and on status page 2 the <to> arrow is hidden
with the level it points at, because an arrow with nothing after it is half
a sentence.

Gen 1 only. The Gen 2 screens and the Gen 1 PC box list -- where the level
is part of a row label rather than a drawn field -- keep their own readouts
and do not consult the hook. Both are stated as follow-ups in the RFC and
beside the hook in docs/modding.md, so a mod author reads the limit before
depending on it.

Verification: tests/modkit/cases/pokemon_level_visible.lua covers the
contract through the public mod API; gate_hooks picks the hook up on its own
because it walks the live catalog; gate_meta_coverage is satisfied by the
change that introduces the seam, so it never enters the DEBT ledger.
tests/run_modkit.lua 33/33, tests/run_engine.lua 327/331 -- the same four
audio/hostshell suites fail unchanged on dev without this branch.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-26 10:53:09 -05:00
bryanthaboi 522d8cecf3 mega big fix for shaders 2026-08-26 10:29:16 -04:00
bryanthaboi 40075ae469 Merge pull request #1830 from ShaneMcGovernIE/feat/sbc-handheld-optimizations
feat(sbc): handheld power governor, audio sample rate, and allocator tuning
2026-08-26 10:03:14 -04:00
Shane McGovern dce0dd32db fix(ci): pass all engine invariant and headless test suites 2026-08-26 13:42:44 +01:00
Shane McGovern 88e24f2c0c feat(core): add global Start+Select 5s emergency force-quit watchdog 2026-08-26 13:26:14 +01:00
Shane McGovern b7b96cd9ef fix(ui): hoist getNavLayer definition before Kit.endFrame to fix nil function crash 2026-08-26 13:23:59 +01:00
Shane McGovern 9886920c7a feat(ui): default controller navigation on and set starting focus to Layer 3 (Import/Play) 2026-08-26 12:50:12 +01:00
Shane McGovern f5f9e60b3c fix(input): resolve 1:1 Nintendo face button mapping on SBC/PortMaster devices 2026-08-26 12:49:01 +01:00
Shane McGovern 247ec919ea feat(ui): 4-layer vertical controller navigation, bright white glowing focus highlights, and handheld updater support 2026-08-26 12:44:20 +01:00
bryanthaboi fe338f47f2 Merge pull request #1820 from 1Jamie/app-image-fixes
feat(linux): ship raw x86 AppImage, Flatpak bundle, and dual-env curl
2026-08-26 07:40:48 -04:00
Shane McGovern 7e4c4eb46e feat(ui): add native controller menu navigation with Y hotkey toggle and soft-glow focus 2026-08-26 12:28:02 +01:00
Shane McGovern 1d735c3291 fix(launcher): render VirtualKeyboard on top of prompts and map Nintendo layout accurately 2026-08-26 12:16:41 +01:00
Shane McGovern dce0f92c2d feat(launcher): add Select button VirtualKeyboard toggle and default Nintendo layout 2026-08-26 12:05:05 +01:00
Shane McGovern f1bc392664 fix(kit): open VirtualKeyboard on pointer click as well as D-pad activation on handhelds 2026-08-26 12:01:43 +01:00
Shane McGovern ee427cd9eb fix(launcher): prioritize in-launcher FileBrowser on handhelds and fix modalUp detection 2026-08-26 11:56:26 +01:00
Shane McGovern 592daafa42 feat(launcher): add in-launcher File Browser and Virtual Keyboard for handhelds 2026-08-26 11:53:01 +01:00
Shane McGovern b78ab6fb50 feat(sbc): add handheld power governor, audio sample rate, and allocator tuning 2026-08-26 11:24:46 +01:00
1jamie 6a02a13f22 ci(linux): build and publish Flatpak on release and path-gated PR CI
Add a ubuntu-24.04 linux-flatpak job that runs build_flatpak.sh from the
shared love payload, wire it into release staging/upload, and mirror a
path-gated Flatpak build in ci.yml when flatpak packaging changes.
2026-08-25 15:32:29 -05:00
1jamie 0e8c93ec75 feat(linux): ship raw x86 AppImage, Flatpak bundle, and dual-env curl
Drop the pointless zip wrapper around the x86_64 AppImage, harden HostShell
so bundled curl keeps APPDIR libs while host curl scrubs LD_LIBRARY_PATH /
Steam LD_PRELOAD, and add a Flatpak channel with --device=all, bundled
curl, and AppStream releases metadata. Portable mode now probes writability
with a unique temp file and falls back soft on RO mounts / Flatpak.
2026-08-25 15:28:44 -05:00
bryanthaboi a6c914ecad Update video link and thumbnail in README 2026-08-25 16:02:55 -04:00
bryanthaboi 1f12e4838f Merge pull request #1791 from HighDrexler/fix/mobile-required-import-streaming-v2
Fix/mobile required import streaming v2
2026-08-25 15:55:34 -04:00
bryanthaboi 7fa762871f Merge pull request #1798 from campavao/rfc-0015-battle-rule-hooks
engine: battle.style and catch.nickname rule hooks
2026-08-25 15:55:07 -04:00
bryanthaboi 4d805abb9c Merge pull request #1812 from 1Jamie/save-editor-safe-areas-move-search
fix(save-editor): mobile safe areas, move search picker, and release window titles
2026-08-25 15:54:19 -04:00
bryanthaboi 51908faabf fix(mods): stop the Gen 2 require facade answering the engine
bootGame's require("src.core.Game") was resolving to Gen2Compat's Game
facade after a Gold session, so the next Gen 1 boot got an empty proxy
whose rawget(load) is nil (iOS: "src.core.Game missing load after
reload"; Android: Game:load called on a nil value).

Two independent causes, both needed:

  * callerIsMod decided "not under src/" meant "a mod", and main.lua is
    not under src/, so the engine's own require was gated as a mod's.
    Root chunks main.lua and conf.lua are now matched exactly, which a
    mod's own mods/<id>/main.lua cannot collide with.

  * devShim.generation was only ever set, never cleared, so the
    generation Gold declared outlived Gold's session. Loader.endSession
    drops it from SessionLifecycle.endMountedSession, and the facade
    gate now requires generation == 2 rather than ~= 1.

Only platforms that return to the launcher in-process (Android, and iOS
since #1808) keep the shim alive across sessions; everywhere else the
process restart cleared it.
2026-08-25 15:14:47 -04:00
bryanthaboi 54c7a3aeae Merge pull request #1808 from 1Jamie/fix/mobile-lc
fix(mobile): in-process launcher return for Android and iOS
2026-08-25 15:14:05 -04:00
bryanthaboi 5cc33af354 Merge pull request #1809 from 1Jamie/yellow-fixes
fix(yellow): address version:yellow issues and title pupil bake
2026-08-25 14:00:48 -04:00
1jamie 93c7dff4d6 fix(tests): keep yellow-fixes suites ROM-free and dig-fade accurate
Drop Data:load from #1635/#1743 engine tests so headless CI without
data/generated/ can run them, and relax dig's #916 hide-ratio check for
white fade-in under spinDrop (#1644).
2026-08-25 12:58:03 -05:00