Files
gen1recomp/docs/game3/object-interactions.md
Shane McGovern 89c7959c70 fix(game3): gate the warp-cell walkable repair on the metatile behavior
Collision.installWarps force-marked every map-header warp cell walkable. That
is right for the outdoor MB_WARP_DOOR tiles extract can leave solid, but it also
opened cells that only carry a dead warp event. PalletTown_PlayersHouse_1F has
one at (3,9): the wall tile directly left of the door mat, mid 26, coll 1,
behavior 0x00 MB_NORMAL. pret never lets the player stand there, so the warp
never fires; the forced COLL_DOOR let the player walk out of the house through
the wall and land in PalletTown.

The repair now fires only when the behavior is unreadable (tileset attrs stopped
before that mid, so Collision.behavior returns nil) or is a behavior pret would
actually warp on. Collision.isWarpMetatileBehavior covers 0x60-0x6F plus 0x71,
matching field_control_avatar.c: the arrow warps (TryArrowWarp), the directional
stair warps (IsDirectionalStairWarpMetatileBehavior), and everything
IsWarpMetatileBehavior accepts (cave door, ladder, fall warp, regular warp,
Lavaridge 1F warp, warp door, escalators, union-room warp).

Warp indexing is unchanged: a dead warp on a wall is still registered, only the
grid write is gated.

tests/engine/firered_house_wall_warp_bug2297.lua is ROM-free: it embeds the pret
13x10 map.bin grid and the `building` metatile attributes, translates them with
the real ScriptingCollision.fromCell, binds the real Versions.WARPS table, and
asserts the wall stays solid, the four warp cells still behave, the repair still
applies for unreadable attrs and live warp behaviors, and an exhaustive
0x00-0xFF table pins the predicate. It fails 6 checks against the pre-fix file.

luajit tests/run_engine.lua: 585/585 suites passed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-19 09:19:26 +01:00

3.5 KiB
Raw Permalink Blame History

FireRed object interaction text

A-button interactions now use original ROM metatile behaviors, independently of translated movement collision. This restores the 28 shared furniture/sign scripts: bookshelves, shop shelves, food, computers, televisions, cabinets, kitchens, dressers, snacks, paintings, machines, telephones, posters, bins, cups, windows, lights, tools, video games, blueprints, burglary debris and building/Indigo signs. The wall Town Map script is also extracted. Existing PC handling remains available.

The source of truth is pret/pokefirered's GetInteractedMetatileScript in src/field_control_avatar.c, data/scripts/flavor_text.inc, and the user's ROM. The importer discovers the original bytecode and text rather than embedding game strings in source. Script extraction was checked against both US ROM revisions; the full importer still uses its existing FireRed 1.0 support.

Map-specific background scripts and NPCs take precedence over generic furniture. Background events respect their original facing and elevation constraints; TVs and building signs require facing north. Dynamic metatile changes are respected. The school notebook, S.S. Anne captain's book and rival's bookshelf are verified through their existing map-specific scripts.

Cache version 93 adds data/generated/gba/objects/pack.lua, containing the shared scripts, text, and original behavior tables for all tileset pairs. Fresh imports produce it automatically. The local test import was upgraded without touching saves. Restart the game to load the new code/cache.

This restores descriptive object text. Specialized interactive screens such as the questionnaire, wireless monitor, battle records and Trainer Tower time monitor are outside this change.

Warp collision uses the same behavior table

Collision.installWarps repairs cells that extract left solid even though the map header lists a warp there — outdoor MB_WARP_DOOR tiles, which classify as doors but can land on a tile whose extracted collision nibble is impassable. That repair is now gated on the extracted behavior: it only opens a solid cell when the behavior is unreadable (the tileset attrs stopped before that mid, so Collision.behavior returns nil) or is a behavior pret would actually warp on — Collision.isWarpMetatileBehavior, i.e. 0x60–0x6F plus 0x71, the arrow warps, directional stair warps, doors, ladders, escalators and union-room warp from field_control_avatar.c. A map header warp event can sit on a real wall — PalletTown_PlayersHouse_1F has a dead warp at (3,9), the wall tile left of the door mat, whose behavior is MB_NORMAL — and opening it let the player walk out of the house through the wall. The warp event itself stays indexed as before; only the forced-walkable write is gated.

Verification

Run with LuaJIT from the repository root:

luajit tests/game3_object_interactions_test.lua
luajit tests/game3_object_interactions_rom_test.lua '/path/to/FireRed.gba'
luajit tests/game3_object_interactions_cache_test.lua '/path/to/cache/firered'
luajit tests/engine/firered_house_wall_warp_bug2297.lua

The cache integration test audits all 425 imported layouts (1,578 furniture cells), exercises 25 furniture behaviors found on those maps via Field.interact, and checks three map-specific book scripts. The ROM test executes all 28 shared text scripts and verifies the wall Town Map script is present. Unit checks cover facing, elevation, delayed bundle loading, map bounds, and metatile overrides.