Commit Graph

545 Commits

Author SHA1 Message Date
bryanthaboi 1c13c4c0d6 Merge pull request #2398 from thibautbus/fix/game3-trainer-class-ids
Recognise FireRed trainer classes by id, not by their name
2026-09-22 20:12:50 -04:00
bryanthaboi 2a463da06b Merge pull request #2400 from thibautbus/fix/game3-unicode-braille
Let FireRed braille messages take Unicode braille cells
2026-09-22 20:12:40 -04:00
1jamie f2a75271b0 Merge upstream/dev into grandpas-garage and resolve switch_seq conflict 2026-09-22 18:41:25 -05:00
1jamie ce8a2d3777 Fix battle EXP distribution, party status badges, pacing trainer sight, and LeafGreen launcher colors 2026-09-22 18:32:26 -05:00
bryanthaboi d920f7acdb clean up 2026-09-22 17:05:12 -04:00
bryanthaboi 9208d83a28 Merge branch 'dev' into pr-2409
# Conflicts:
#	src/ui/game3/save_menu.lua
2026-09-22 16:41:00 -04:00
1jamie 109a87c81c fix(game3): fix BGM silence after fanfares during battle and overworld dialog
- Preserve active track voices in Player.stopAt after fast-forward catchup
- Add start-from-0 fallback in Player.stopAt when at timestamp predates the retained snaps ring
- Mute m4a worker during stopAt pause so it does not synthesize empty buffers while fanfare plays
- Ensure Audio.resumeBgm calls Source:play on bgmSource if stopped
2026-09-22 15:37:18 -05:00
bryanthaboi 23617f43b4 CLOSES #2290, CLOSES #2338, CLOSES #2186, CLOSES #2305, CLOSES #2332, CLOSES #2320, CLOSES #2344, CLOSES #2291, CLOSES #2335, CLOSES #2340, CLOSES #2385, CLOSES #2352, CLOSES #2378, CLOSES #2403, CLOSES #2404, CLOSES #2405, CLOSES #2367, CLOSES #2037, CLOSES #2177, CLOSES #2368, CLOSES #2382, CLOSES #1951
CLOSES #2290, CLOSES #2338, CLOSES #2186, CLOSES #2305, CLOSES #2332, CLOSES #2320, CLOSES #2344, CLOSES #2291, CLOSES #2335, CLOSES #2340, CLOSES #2385, CLOSES #2352, CLOSES #2378, CLOSES #2403, CLOSES #2404, CLOSES #2405, CLOSES #2367, CLOSES #2037, CLOSES #2177, CLOSES #2368, CLOSES #2382, CLOSES #1951
2026-09-22 16:27:28 -04:00
Shane McGovern 72f083f0c4 Merge remote-tracking branch 'upstream/dev' into nexhas28/gen3-review-v3-fixes
# Conflicts:
#	src/core/game3/save_schema_firered.lua
#	src/core/game3/scripting/natives.lua
#	src/import/RomExtractorGen3.lua
#	src/import/gba/versions.lua
2026-09-22 18:28:33 +01:00
Shane McGovern 41935aa2a2 fix(game3): wave 2 - 118 review fixes, seam work, and the gate to 282 suites
Second batch of the Gen 3 review work: the review lanes closed their queues
and the test gate grew with them.

Review census: 139 routed findings -- 118 fixed, 14 invalid (the report had
Gen 4+ semantics in more than one place), 6 struck as stale after
re-verification, 1 re-routed. Every fix carries its own pret citation in
docs/game3/review-v3-triage.md; the E10 opcode closure is itemised in
docs/game3/e10-opcode-spec.md (18 ops wired, 2 reclassified to the seam class).

Representative ROM-grounded changes:
- The POKéMON start-menu entry is now gated on FLAG_SYS_POKEMON_GET the way
  retail does it (pokefirered/src/start_menu.c:217-218, flag 0x828).
- Money ops read their amount raw and gate the change on the disable byte
  (pokefirered/src/scrcmd.c:1798-1830, pokefirered/asm/macros/event.inc:1166-1186);
  random and the warp family VarGet theirs
  (pokefirered/src/scrcmd.c:455-461, :719-731).
- The HM table matches FRLG: there is no Whirlpool HM
  (pokefirered/include/constants/items.h:411-418).
- The day-care party-full guard follows src/daycare.c:525, :1081.
- Knock Off keeps its battle-scoped send-out mask
  (pokefirered/src/battle_script_commands.c:2730-2752, :4489), carried from
  the first batch.

Structural work: the I6/I9/J1 architecture items landed as seams (profile
selector, capability flags, font provider, virtual-object layer), the adopted
footprint register keeps a KEEP verdict, the quantizer target is met, and the
30 drain items plus carves 1-4 are folded in.

Tests: T6 now runs 282 top-level suites (273 + 9 new), the re-sweep ends at
267 pass / 0 fail, the engine tier is 634 suites, modkit 37, and the full
gate ran green twice with T3 active on an imported Red cache. Documented
skips are the lua5.4 oversize-save oracle where lua5.4 is absent and the
config-partials listed in docs/game3/game3-artifact-conversions-v3.md.

Docs shipped: review-v3-triage.md, e10-opcode-spec.md, rse-seams.md,
game3-suite-sweep-v113.md, game3-artifact-conversions-v3.md,
test-baseline-v3.md (plus the first-batch docs already on the branch).
2026-09-22 18:23:06 +01:00
bryanthaboi 081787d614 Fix Gen 3 mod target expectations for LeafGreen 2026-09-22 11:49:50 -04:00
bryanthaboi 4bdb97fc8d Merge branch 'dev' of https://github.com/bryanthaboi/gen1recomp into dev 2026-09-22 11:44:52 -04:00
bryanthaboi 8356fdd8e1 othe rbig changes 2026-09-22 11:44:50 -04:00
bryanthaboi 9308439697 Merge pull request #2370 from bryanthaboi/nexhas28-fix-gen2-encounters-unknown-id
Close Gold's encounters id space so an unknown id fails the mod (#2369)
2026-09-22 10:25:51 -04:00
thibautbus 2701b930d8 Let FireRed braille messages take Unicode braille cells
Braille.encode spells a braille message from Latin letters, through
Braille.CODE and the Latin charmap byte of any other character. That
covers the US cart, but the European carts' braille lines use cells no
character reaches: German ä (dots 3-4-5), the full cell, dot 5 alone. A
translation mod therefore cannot hand over the German, Spanish or Italian
braille, and the 39 lines of the Dotted Hole, Ruin Valley and Mt. Ember
stay in English in every language.

pret's braille font holds every dot combination
(pokefirered/include/characters.h:282), so Braille.encode now draws a
Unicode braille character (U+2800-U+283F) as that very cell, mapping
Unicode's dot bits to the cart's cell numbering (dot 1 = 0x01, 4 = 0x02,
2 = 0x04, 5 = 0x08, 3 = 0x10, 6 = 0x20). A cell spells its own number sign,
as the carts' braille does. Latin text is spelled as before.
2026-09-22 15:57:49 +02:00
thibautbus 1c2a7d64de Give the FireRed rival and champion the rival's name by class id
Trainers.info gave a trainer the player's chosen rival name only when its
class was called "RIVAL". A mod that translates the class (RIVALE in
German and Italian) made the rival battle as the ROM's placeholder TERRY,
and the champion, whose class is CHAMPION, was always TERRY. pret's
B_TXT_TRAINER1_NAME names TRAINER_CLASS_RIVAL_EARLY, _RIVAL_LATE and
_CHAMPION by the rival's name (pokefirered/src/battle_message.c:2078);
Trainers.info now does the same, by class id.
2026-09-22 15:20:31 +02:00
Shane McGovern b5f2f4fcfd Merge remote-tracking branch 'upstream/dev' into nexhas28/gen3-review-v3-fixes
# Conflicts:
#	src/core/game3/battle/anim_seq.lua
#	src/core/game3/battle/effects/secondary.lua
#	src/core/game3/battle/engine.lua
#	src/core/game3/battle/state.lua
#	src/core/game3/battle/switch_seq.lua
#	tests/engine/game3_knock_off_item_test.lua
2026-09-22 12:25:30 +01:00
Shane McGovern e2454bf568 fix(game3): review v3 fixes (battle, field, script, save) + gated T6 tier
Second wave of fixes from the Gen 3 codebase review (210 findings), the
regressions the full-suite sweep surfaced, and a T6 tier so the top-level
tests/game3_*.lua suites run inside ./scripts/test.sh instead of outside it.

Battle: Knock Off and Thief/Trick item persistence follow the ROM, not the
review - the party slot is never written through during battle, and the
knocked-off mask suppresses the item on later send-outs
(pokefirered/src/battle_script_commands.c:2731 MOVE_EFFECT_KNOCK_OFF with the
STICKY_HOLD guard at :2732, opponent-steal guard at :2610-2622, mask use at
:4489). Rapid Spin keeps its one-per-use chain order (:8435-8474); Growl
keeps pret's target (src/data/battle_moves.h, include/battle.h:63).

Scripting: operand layouts match pret/asm/macros/event.inc - givemon 15 bytes
(:989-997), comparestat {B,W} (:1573-1576), setptr/loadbytefromptr/setptrbyte
take a word pointer (:118-137). 18 of the 20 E10 ops are wired per
src/scrcmd.c (per-op citations in docs/game3/e10-opcode-spec.md), money and
random and the warp family read their operands as VarGets
(src/scrcmd.c:1798-1830, :455-461, :719-731), and the day-care party-full
guard is in place (src/daycare.c:525,:1081).

Field and UI: fishing counts rounds as the ROM does
(src/field_player_avatar.c:1740-1765), an unresolved map section no longer
reports Pallet Town (src/region_map.c:3782), and a font provider sits behind
a FireRed capability/profile seam.

Save data: profile-driven Options.block, a save version round-trip, and slot
id validation that blocks path traversal (slotDiskPath("firered", "../evil")
returns nil).

Importer: the parallel import path now writes both completion markers,
object kind/clone bytes decode as pret defines them
(include/global.fieldmap.h:110-130), and the HM table drops Whirlpool
(include/constants/items.h:411-418).

Tests: six new scenario suites (battle_ai, capture, event, menu, move,
overworld) and eight engine suites (profile, capabilities, cache paths, font
provider, options block, save version round-trip, version dispatch,
versions_game). T6 runs every top-level game3 suite at GAME3_JOBS default 8
with per-suite logs, failure cause classification and a KNOWN_GAME3_FAILURES
ceiling of 23 as a shrinking guard.

Docs: the working notes under docs/game3 (triage ledger, pret citation audit,
e10 opcode spec, RSE seams, sweep v3/v113, test baseline, artifact
conversions, merge trial).

Full gate at this snapshot: exit 0, all tiers passed - engine 624/624,
T6 279/279 (0 known, 0 fresh failures), gen2 146/146, modkit 37/37, luacheck
clean, privacy gate 3/3 over a 9,711-file publication set.
2026-09-22 12:22:50 +01:00
thibautbus 32d52b88c0 Show only an egg's name in its FireRed party slot
The party menu drew an egg's slot like any other mon's: level, gender, HP
numbers and HP bar. pret's DisplayPartyPokemonData prints only the nickname
for an egg and blits the slot without its HP frame (sSlotTilemap_MainNoHP /
WideNoHP; pokefirered/src/party_menu.c:781, :2197), and
DisplayPartyPokemonDescriptionData likewise skips the level and gender of an
egg (party_menu.c:804). The slot now does the same, reusing the no-HP frame
the description slots already draw.
2026-09-22 12:47:50 +02:00
thibautbus f8fbe53346 Show a FireRed egg as an egg on the PC panel, summary and trade screens
Three screens that show a single mon still drew an egg as the species it
will hatch into, and printed its stored nickname untranslated:

- The PC's hovered-mon panel drew the hatch species' front pic, the stored
  "EGG" nickname, "/PICHU", gender, level and held item. pret draws the
  SPECIES_OR_EGG pic and, for an egg, prints only gText_EggNickname with the
  other lines blank (pokemon_storage_system_data.c:1034, :1091).
- The summary's egg page drew the hatch species' front pic, where pret uses
  SPECIES_OR_EGG (pokemon_summary_screen.c:4016). It also recognised an egg by
  mon.isEgg alone; it now uses Pokemon.isEgg like the rest of the engine.
- The trade scene drew a traded egg as its species and named it by the stored
  nickname (trade_scene.c:757, :1239).

The script string buffers (BufferMonNickname and the other nicknameOf
helpers) now also give the language's EGG for an egg, as GetMonData
(MON_DATA_NICKNAME) does (pokemon.c:3020).
2026-09-22 12:10:44 +02:00
thibautbus aaacf02dc0 Draw a FireRed egg's menu icon as an egg
The party, the PC boxes and the release animation drew an egg with the icon
of the species it will hatch into, so a Pichu egg showed as a Pichu. pret's
party menu picks the icon from GetMonData(MON_DATA_SPECIES_OR_EGG), which is
SPECIES_EGG for any egg (pokefirered/src/pokemon.c:3245, party_menu.c:2655).

Pokemon.speciesOrEgg does the same, and the icon call sites use it. The
species pass only extracted icons up to NUM_SPECIES - 1, so the egg extractor
now also bakes gMonIconTable[SPECIES_EGG] as pokemon/icons/412.rgba. Cache
version 114 re-imports existing caches so the icon appears.
2026-09-22 12:10:44 +02:00
thibautbus ee63ffff2d Name a FireRed egg by the language's own EGG
Party.giveMon stores "EGG" as a new egg's nickname (party.lua for a
gift egg, breeding.lua for the Day-Care's), and the party slots and the
other screens that name a mon through Pokemon.displayName and
displayMonName print that nickname as it is. A translated game therefore
listed its eggs as EGG, while the summary, which prints Strings("EGG")
for an egg, already said OEUF, EI, HUEVO or UOVO.

The cart does not rely on the stored nickname either: its Day-Care
writes the Japanese タマゴ there (daycare.c:1100), and GetMonData
returns gText_EggNickname for any egg's nickname (pokemon.c:3020). Do the
same in both name helpers: an egg reads as Strings("EGG"), whatever its
nickname holds, which also covers the eggs saves already carry. A
hatched egg, whose nickname is cleared, goes back to its species name.
2026-09-22 12:10:24 +02:00
bryanthaboi e5569bd0a1 Dublin time 2026-09-22 05:34:03 -04:00
Shane McGovern 1b8b9b4817 test(game3): make the plural-verb checks ROM-free
The bufferitemnameplural checks asserted hard-coded item names, but those
come from data/generated/gba/items/pack.lua, which does not exist in a
ROM-free checkout.  CI failed 2/70 there ("got BERRIES"), while a machine
with an imported pack passed, so the suite was green locally and red in CI.

Assert the pluralisation rule against each item's own singular name
(ItemsData.displayName) instead: a Poké Ball stack gains "S", a berry stack
has its final letter replaced by "IES", and quantity 1 stays singular.

72/72 with and without the pack; the full engine tier is 616/616 with no
ROM data.
2026-09-22 03:34:47 +01:00
Shane McGovern 2c356f28ea fix(game3): save, item, map, script and importer bugs found in review
The rest of the Gen 3 review fixes, each with a gated suite in tests/engine/.
ROM semantics were checked against pret/pokefirered.

Scripts
- givemon carried the wrong operand layout, found earlier; four more layout
  desyncs came out of pret asm/macros/event.inc: comparestat is {byte,word},
  and setptr / loadbytefromptr / setptrbyte each carry a leading byte plus a
  word. A wrong size mis-decodes every instruction after the bad one, so
  Versions.CACHE_VERSION moves to 113 and existing caches re-import.
- handlers for previously handler-less verbs: comparestat,
  bufferitemnameplural, setmonmove, setmonmetlocation, the modern
  fateful-encounter pair, the script-locals family (copylocal, setptr,
  loadbytefromptr, setptrbyte, copybyte, compare_local_to_* and
  compare_ptr_to_*), the RAM-script family (setvaddress, vgoto, vcall,
  vgoto_if, vcall_if, vmessage, vbuffermessage, vbufferstring, endram,
  returnram) and the same-map forms of the *at verbs.
- setdooropen / setdoorclosed read their coordinates through VarGet.

Battles
- Knock Off and Thief / Trick persist the item change instead of only
  touching the in-battle copy.
- knocked-off party slots are tracked in a bitmask, so a slot reused later
  does not inherit the flag.

Field and UI
- Player.reset restores facing and clears the surf flags.
- a definition-less Map.load no longer leaves collision unbound.
- an unresolved region-map section no longer reports PALLET TOWN.
- the naming screen splits input from the timer, so update(dt) stops
  indexing a number.
- the hall of fame commits through the engine save path and serializes its
  fields.

Persistence
- gameStats, the link-battle records and the trainer card are serialized.
- the PC deposit refuses at the 999 cap instead of destroying the overflow.

Robustness
- Data.load runs cached modules sandboxed.
- the file browser quotes shell arguments.
- .meta dimensions are bounds-checked and mids.idx validates its header.
2026-09-22 03:28:39 +01:00
Shane McGovern a5f55d3498 fix(game3): stop the save dialog reporting a write that failed
do_save() discarded both pcall results and set _phase = "saved" unconditionally,
so a refused or failed save still showed "<player> saved the game." and closed the
menu. Only a truthy saveGame now reports success; a raised error, an explicit
false, or a missing saveGame enters a new save_failed phase, logs the reason via
Logger, and shows "The game could not be saved."

Test: tests/engine/game3_save_menu_failure_test.lua (8/10 fail on the previous
code, 10/10 pass here).
2026-09-22 01:41:53 +01:00
bryanthaboi c17a8f0d45 Merge pull request #2365 from thibautbus/fix/easy-chat-word-page-rows
Draw the Easy Chat word page's last two words
2026-09-21 14:46:58 -04:00
bryanthaboi ff838c95e6 Merge pull request #2374 from thibautbus/fix/gen3-mod-names-survive-reload
Keep FireRed species and move patches after the pack reloads
2026-09-21 14:46:27 -04:00
bryanthaboi fe28fb8653 Merge pull request #2375 from thibautbus/fix/easy-chat-species-move-names
Let a translation reach the Easy Chat words
2026-09-21 14:45:32 -04:00
bryanthaboi 7da44937a3 Merge pull request #2376 from thibautbus/fix/frlg-summary-move-name-width
Give FireRed summary move names the room pret gives them
2026-09-21 14:45:25 -04:00
thibautbus 709c7db286 Read the Easy Chat species and move words from the dataset
Four of the 22 Easy Chat groups carry no text of their own: POKéMON,
POKéMON (NAT), MOVE 1 and MOVE 2 are lists of species and move ids, and
pret prints them through gSpeciesNames and gMoveNames.  The extractor
resolves them the same way, so easy_chat_data.lua ended up holding 807
copies of names the dataset already has -- copies that go stale the
moment anything renames a species or a move.  A mod that renames them,
a translation filling the species_names and move_names catalogs first
of all, changed every screen but this one: the picker still offered
the cart's English names, and the profile read back in them.

Resolve those two kinds of word at draw time instead, against the same
Pokemon.name / Pokemon.moveName the party screen and the Pokédex use.
When the dataset has no entry for an id it answers with a placeholder
("POKéMON 063", "-------"), which is worse than the word the cart
shipped, so that case keeps the extracted text.  An entry that names
the group ("easyChat.POKéMON|PIKACHU") still wins over both, since a
species name may need a wording other screens do not use.  A bare-key
entry does not: bare keys are shared with menu labels this engine
already translates (CUT, FLASH, STRENGTH), and one of those should not
decide what a move is called here.

tools/modkit.py keeps emitting those 807 rows, since the species and
move catalogs it writes come from the Gen 1 dataset and do not list a
Hoenn species or a Gen 3 move; its note now says an empty entry shows
the game's own name, so a translator only fills the ones nothing else
renames.
2026-09-21 17:24:41 +02:00
thibautbus bfc2534a81 Let a translation reach the Easy Chat vocabulary
The Easy Chat screen picks its words from src/core/game3/easy_chat_data.lua, the ROM's own word tables as the extractor writes them: 1,813 English words across 22 groups, plus the group names the picker lists. It drew them straight from that table, so every word the player composes with stayed English, and the screen's own prompts -- routed through Strings() already -- sat in a frame of untranslated vocabulary.

src/core/game3/easy_chat_text.lua is the seam. The data module stays exactly what the extractor produced, because it is regenerated from the ROM and anything written into it would be lost on the next import; the words are translated where they are drawn instead, the same split the rest of game3 uses for extracted text. Five sites go through it: the group list, its header, the word list, the word sitting in a slot, and the saved profile a message box prints (ShowEasyChatMessage). The ids the save file stores are untouched.

Each word carries its group's context ("easyChat.FEELINGS"), because the same English word means different things in different groups and 155 of them collide with labels this engine already translates elsewhere (ATTACK, BAG, CANCEL, BACK...). Strings() falls back to the plain key, so a catalog that does not need the distinction lands with one entry -- with the consequence that a mod which already translates BAG for the menus now sees that wording in the Easy Chat list too, until it adds a context-specific entry.

A seam nothing can discover is not much use: tools/modkit.py's catalog generator emits these keys too. The literal harvester cannot see them (the picker looks each word up at draw time, not at a Strings("...") call site), so the dataset dump walks EasyChatData.GROUPS and writes 1,835 rows into lang/strings.lua, where a translator finds them beside the rest of the engine text.

Each word is clipped to the box it sits in: in the picker, the red selection rectangle; in the phrase frame, the slot's own frame. The cart's words fit those boxes (72 px at most); a longer translation is cut at the box edge instead of running past the highlight, into the next slot's cursor, or off screen. Group names get the room up to the scroll arrows instead, because an official translation already needs more than the rectangle: the French cart's VIE QUOTIDIEN. is 83 px.

tests/engine/game3_easy_chat_text_test.lua covers the context lookup, the fallback to a plain key, the untouched English with no catalog, and that the extracted data itself is never rewritten. It lives in tests/engine so the T1/T2 tier actually runs it.
2026-09-21 17:24:41 +02:00
bryanthaboi fdc9506256 another big dump 2026-09-21 11:14:17 -04:00
thibautbus 35727406dc Give FireRed summary move names the room pret gives them
The summary's MOVES page drew each move name with a fixed 64 px limit.
pret prints the names at x 3 of POKESUM_WIN_MOVES_3, a 10-tile window
that starts at tile 20 (pokemon_summary_screen.c:857, :2543), so a name
has up to the right edge of the screen: 77 px from the pen at 163.  The
cart's own longest names are 72 px -- SKY UPPERCUT, FRENZY PLANT, HYDRO
CANNON -- and lost their last letters, as did translated names that the
cart's window would hold (RUGISSEMENT for GROWL).

Clip to the window's right edge instead, measured from wherever the
chrome manifest puts the pen.
2026-09-21 17:09:45 +02:00
thibautbus b54adf14cc Re-apply FireRed species and move patches after the pack reloads
A FireRed mod's pokemon and moves patches are merged onto the live
src.core.game3.pokemon module while the mods load (Game3:_loadMods).
Entering FireRed then runs Pokemon.install() from Runtime, which swaps
every species table for a fresh copy of the ROM pack -- names, stats,
types, learnsets, and the move names that live in the same pack.  The
only reload hook, in Gen3Compat.applyMerged, re-seeded the sprites and
nothing else, so every such patch was gone before the first frame: a
translation's species_names and move_names catalogs never reached the
party screen, the summary or a battle, and a mod's base stats reverted
to the ROM's.

Write the moves and pokemon registries again onto the new tables from
that hook, the way reapplyMoves already does for the moves module.  The
moves registry is part of it because its names and the battle-move copy
it mirrors into belong to the reloaded pack, and it goes first, in the
order Loader:_mergeOrder uses: the moves writer is what adds a mod's own
moves to the move index, and the species writer resolves learnsets, egg
moves and TM/HM lists through that index.
2026-09-21 15:29:01 +02:00
Shane McGovern e12cda633a Close Gold's encounters id space so an unknown id fails the mod
mod.content.encounters:patch on a Gold boot keys by encounter KIND
(encounters.grass.ROUTE_29), but the id space was open: a key the
catalog did not describe was treated as a mod's own data and merged
as-is.  A Gen 1 encounters mod ported unchanged writes the MAP where
Gold wants the kind, so the call was accepted, merged into
data.gen2Encounters.ROUTE_29 and read by nothing -- vanilla game, no
error, nothing in the Mod Manager (#2369).

That key cannot be a mod's own data the way an extra palette id can:
src/battle/gen2/Encounter.lua, src/core/gen2/Roamers.lua,
src/core/gen2/BugContest.lua and src/world/gen2/World.lua read this
table by name and the set of names is fixed, so an unknown id is a
write nothing reads.  Add an opt-in `keysClosed` shape slot (folded by
Schemas.shapeFor like the other gen2* slots) that Schemas.check honours
in its keys/keyValue branch, and set it on encounters' Gen 2 spec.  An
unknown id now names the ids that do exist instead of silently
no-opping; api 2 fails the mod, api 1 keeps the warning.

Also catalogue roamMons, which the extractor has always emitted
(RomExtractorGen2:readRoamMons) and Roamers.roster has always read, but
which was missing from gen2Keys.

Only encounters opts in: palettes, battle_anims and constants keep
their open id spaces, and Red's encounters id space is untouched.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-21 09:14:53 +01:00
bryanthaboi 4d7350c776 Merge remote-tracking branch 'origin/dev' into HEAD 2026-09-20 17:49:32 -04:00
bryanthaboi 1af407498c firered softlocks, specials, cave encounters, sevii ferry 2026-09-20 17:31:31 -04:00
thibautbus 823dd07727 Draw the Easy Chat word page's last two words
The word picker pages eight words at a time and its navigation moves through four rows of two: `row < 3` when moving down, `3 * 2 + col + 1` when stepping up into the previous page. The draw loop rendered three rows, so the seventh and eighth word of every page were selectable -- the cursor sat on them, and pressing A picked them -- while nothing was drawn there. A group's last words could be chosen only blind.

Eight is the cart's own page: easy_chat_2.c scrolls selectWordRowsAbove by four, and easy_chat_3.c's PrintECRowsWin2 prints row * 16 + 96 for each row. The loop now draws four, starting 2 px higher so the fourth row's 14 px of glyphs stop exactly at the bottom of the 78 px frame.

tests/engine/game3_easy_chat_page_test.lua drives the screen with a group larger than one page and checks all eight words reach the font, inside the frame. It reports the two missing words before this change.
2026-09-20 21:22:28 +02:00
bryanthaboi 66f117b064 Merge pull request #2355 from thibautbus/fix/gen2-contest-coins-strings 2026-09-20 13:33:17 -04:00
bryanthaboi 605654a086 CLOSES #2310 2026-09-20 13:21:16 -04:00
thibautbus 58624c3013 Route the Bug Contest status box through Strings()
The box above the menu during a Bug-Catching Contest (pokecrystal ContestStatus) drew its three labels and the empty-slot placeholder as bare literals: CAUGHT, LEVEL, BALLS: and "None". They were the last raw player-facing sinks in this file, which tests/gen2_ui_translation_harvest_test.py already lists among the modules that should have none.

The values keep the cart's own columns (x=8, 7, 8) only while the label fits them: "ATTRAPÉ" fills the seven tiles CAUGHT leaves, and "GEFANGEN" or "ATRAPADO" one more, so each value starts after its label instead of being drawn over by it.

"None" carries a context: the bare key is also the import wizard's "no limit" label (src/import/online/Wizard.lua), and one catalog entry cannot serve both -- which is also why the harvest gate asks for the three labels and not for it.

The caught mon's own name is left alone: it is a nickname, or a species the `pokemon` registry renames.
2026-09-20 14:34:38 +02:00
thibautbus 06d99eb2aa Route the two-row confirmation prompts through Strings()
The Bug-Catching Contest confirmation was drawn as two bare literals, one per row, with no hook a mod could reach. It becomes one catalog key, "Would you like to\nend the Contest?", the way every other confirmation prompt in this port is written (src/ui/StartMenu.lua, src/ui/gen2/SaveMenu.lua): "Would you like to" alone has no stable translation out of context, and the cart writes it as one text (data/text/common_2.asm).

Both prompts in this file now share one helper. It draws with Chrome.printWrapped, which wraps on the translated line break AND on pixel width, and reads the line count back from it to warn -- once per prompt -- when a translation needs a third row the box cannot hold. The title-screen prompt went through a hand-rolled splitter on the first line break, which handed Font.draw an embedded break, rendered as a space: a translation needing three rows printed two of them joined and ran past the box.

The official wordings fit: "Voulez-vous arrê- / ter le concours?" and "Möchtest du den / Wettkampf beenden?".

tests/engine/gen2_contest_coins_translation_test.lua drives StartMenu's confirmContest arm and StartGameCornerGame's no-coins branch with a mod-loaded catalog and checks the translated wording reaches the screen, plus the English case. On dev the three prompt checks fail; the refusal's own check passes there too, because that lookup already ran at runtime -- what dev was missing is the key, not the call.
2026-09-20 14:34:19 +02:00
bryanthaboi 7236afc11d Merge pull request #2351 from bryanthaboi/nexhas28-fix-yellow-badge-jingle-2339 2026-09-19 19:41:27 -04:00
Shane McGovern f11b9c762f fix(audio): play the badge jingle the cartridge plays (#2339)
Badge lines are end-battle texts (SaveEndBattleTextPointers), so they are
printed while the battle sound engine is still loaded.  A text sound command
names an id rather than a sound, and that engine's SFX_Headers_2 gives those
ids different sounds: the id behind sound_get_item_1 / sound_level_up is
SFX_Level_Up there, and the id behind sound_get_key_item is SFX_Ball_Poof.
The port resolved the jingle by name, so it always played the overworld
reading (Get_Item1 / Get_Key_Item) -- the wrong jingle for receiving the
BOULDERBADGE, and the same collision for Cerulean, Saffron, Cinnabar and
Viridian in Red, Blue and Yellow alike.

Add victories.badgeSoundFor(), which answers with the jingle that is actually
audible for the badge hand-over:

  Red/Blue  Brock Level_Up, Misty Ball_Poof, Sabrina Ball_Poof,
            Blaine Ball_Poof, Giovanni Level_Up
  Yellow    the same, except Misty: CeruleanGym.asm drops the command from
            that line, so Yellow's Cascade Badge has no jingle

Vermilion, Celadon and Fuchsia carry no sound on their badge lines in any
version.  The raw `badgeSound` field keeps the overworld-engine name, which is
what the TM texts (printed in the overworld) genuinely need.

Tests: pin the literal per-version jingle and its page for all five badge
leaders in tests/engine/gym_badge_jingle_page_bug1982.lua (53 checks), and
have the #1606 and driver suites assert through badgeSoundFor.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-19 23:28:31 +01:00
Shane McGovern 93e071bcaa Fix self-update on the PortMaster SBC build
The SBC and RG34XXSP ports hand LÖVE a source *directory*
(`love <dir>`), so `love.filesystem.isFused()` is false there and
`Boot.run` bailed on its first line.  The launcher still offered
"Update vX.Y.Z" and "Restart to update", so an update downloaded,
verified, and then was silently ignored forever.

- Boot.canUpdateInPlace() replaces the fused-only gate: a packaged
  build updates whether it is fused (AppImage, Flatpak game.love) or
  unpacked, and only a dev / source checkout (engine "0.0.0-dev") is
  excluded.  Fails closed when the host cannot be established.
  Prelaunch.updateAllowed now delegates to it, so the boot gate and the
  `--update` gate cannot disagree.
- Check.hostPort() reads the release-target marker, with
  POKEPORT_HANDHELD as a legacy fallback (the SBC launcher has always
  exported it, so packs predating this change still identify
  themselves).  The marker was read from the environment but never
  exported, so a full-package fallback on a handheld resolved to a
  desktop AppImage that cannot run there.
- A handheld now fetches its own package ("Download port update",
  reusing the worker's cross-platform download_full) instead of
  offering a URL it has no browser to open, and reports "Update package
  ready" once it is in the save directory for a manual re-extract.
- Launchers export POKEPORT_PORTMASTER / POKEPORT_RG34XXSP.

An in-place update only ever mounts a payload over the running source,
so relaxing the gate is less invasive than the fused path it joins.
A runtime bump still needs a full package, which the minShell gate
already reports as needs_full.

Tests: tests/engine/update_boot_host_gate.lua (new, 10 checks) pins the
gate; update_check_tests.lua pins both port asset names and hostPort().
scripts/test.sh --quick: all tiers passed; scripts/lint.sh: 0 errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-19 22:15:02 +01:00
bryanthaboi 641b0f3c37 Merge pull request #2329 from Nexhas28/nexhas28-fix-save-screen-map-names 2026-09-19 14:05:37 -04:00
bryanthaboi 60c1a631a7 Merge pull request #2288 from campavao/rfc-0021-item-survives-the-wire 2026-09-19 14:05:21 -04:00
Shane McGovern 171a2c21f7 fix(save): show the place name, not the internal map id, on the save screen
The location header drew `session.mapName or session.map`, and nothing in
src/ ever assigns session.mapName, so the fallback always won and the
screen printed the engine's internal id ("FR_ROUTE_22").

pret prints the sMapNames place name resolved from the map header:
  start_menu.c PrintSaveStats -> SAVE_STAT_LOCATION
  save_menu_util.c GetMapNameGeneric(dest, gMapHeader.regionMapSectionId)
  region_map.c GetMapName(dst, mapsec, 0)
and centres it in the 14-tile stats window. Do the same via the existing
MapSectionsExtract.getInfo() lookup, and centre the run instead of
drawing it at a fixed x.

getInfo() also gets two fixes on the path the save screen now depends on:
- the fuzzy id match picked whichever section pairs() happened to visit
  first, so "ROUTE_22" could resolve to "ROUTE 2". Prefer the exact match,
  else the longest.
- return `resolved` so callers can tell a real section from the Pallet
  Town placeholder the function falls back to for unknown maps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-19 14:04:06 +01:00
bryanthaboi 4640814677 Merge pull request #2326 from Nexhas28/nexhas28-fix-levelup-stat-box-persists 2026-09-19 08:38:08 -04:00