Skip to content

Forward-port #68 stereoscopic battle sprites to integration - #312

Open
mkrieger95 wants to merge 26 commits into
ZallaxDev:integrationfrom
mkrieger95:port/stereo-battle-68-integration
Open

mkrieger95 wants to merge 26 commits into
ZallaxDev:integrationfrom
mkrieger95:port/stereo-battle-68-integration

Conversation

@mkrieger95

@mkrieger95 mkrieger95 commented Nov 22, 2026 •

Copy link
Copy Markdown

Forward-port #68: opt-in stereoscopic Pokémon battle sprites

Target: integration
Original work and credit: @darkmattericecoffee — original PR #68 and original depth-pack release.

I'm bringing the original author's stereoscopic battle-sprite work forward to the current Emerald3DS architecture so it can be reviewed and tested rather than remain stalled. This is a forward-port and compatibility integration, not my original feature. I have retained the attribution to @darkmattericecoffee, whose original work made this possible.

What I implemented

  • Ported the original depth-pack decoding, async file reading, battle-sprite identification, and layered stereoscopic compositor to the current integration codebase.
  • Adapted rendering to the split video/*.inc architecture. The experimental path only replaces validated battler sprites; unrelated sprites, weather, OBJ windows, HUD, and other rendering retain their existing paths or fall back to the original flat sprites.
  • Kept this opt-in at build time (STEREO_BATTLE=1) and OFF by default at runtime (3D POKÉMON). Normal builds (STEREO_BATTLE=0) exclude the new native renderer and its runtime hooks.
  • Added localized BATTLE → STEREO options (3D Pokémon, plane spread, and plane position) in the existing supported languages. The group is hidden without a valid depth pack; dependent controls are inactive when the feature is OFF.
  • Kept the original author's mons.bin/backs.bin as optional, locally supplied developer-build inputs. No Pokémon art, authored depth packs, or downloaded binaries are included in this PR. Missing/invalid packs or failed texture allocation do not enable depth rendering.
  • Added build-time asset validation, reproducible pack staging, stale-pack cleanup for normal builds, and SDK-free regression tests. The original reference compositor remains available for exact synthetic output comparisons.
  • Optimized sprite composition by quantizing each depth frame once, sharing the resulting group map across all cards. In a synthetic Linux-host CPU benchmark only, this measured 0.535 ms vs 0.250 ms per sprite (2.14× faster); it is not an Old/New 3DS FPS measurement.
  • Completed the Phase 7C source audit and fixed an overlapping trainer-ID/readiness cache key, cross-thread async publication of depth readiness, and out-of-bounds 64×64 OBJ tile-base acceptance. Added regression tests for each.

The original #68 wild-only gameplay patch is not enabled or recreated here. I deliberately kept gameplay modifications outside this renderer-focused port.

Automated verification

CI #948 passed all five jobs on the latest commit (6e3af73):

  • 3DS compilation and release verification for feature-on diagnostic and default-off builds
  • Host C regression tests, including OAM eligibility, ambiguous battlers, cache identity/readiness, OBJ VRAM bounds, and sprite composition
  • Byte-for-byte comparisons of synthetic reference and grouped-composer texture atlases
  • Python 3.11 and 3.15.2 asset and regression audits
  • Release-version verification and default-off depth-pack exclusion

I also added a strict dual-eye capture comparison script to support baseline-vs-feature-OFF and feature-ON visual reviews.

Required before merge — real rendering and hardware QA

I'm marking this PR Ready for Review so maintainers and the original author can review the implementation now. I am explicitly not asking for it to be merged until these checks have been performed and reviewed. Passing CI proves builds and synthetic tests, not real-ROM visual correctness or device performance.

  • Run the original author's real depth packs with real ROM data in Azahar; capture and inspect both eyes, including sprite depth, transparency, animation, shiny palettes, trainers, double battles, fainting, Transform/Substitute, weather, UI, and transitions.
  • Compare the original integration rendering against feature-OFF builds using matched real-game captures; confirm no visual regressions in existing functionality.
  • Test on both Old 3DS and New 3DS hardware, with the feature ON and OFF; confirm battle frame pacing, GPU/CPU cost, VBlank behavior, linear-memory/VRAM usage, long-session stability, and all relevant fallbacks.
  • Have maintainers and, if possible, @darkmattericecoffee review the results and any corrections before merging.

Status: ready for code review; hardware/real-ROM validation outstanding; not cleared for merge. The feature remains OFF by default, and the normal build retains the existing renderer.

Additional technical notes and test instructions: docs/STEREO_68_FORWARD_PORT.md in the PR's Files changed tab.

Start a new draft forward-port based on upstream integration, preserving
original work and full attribution to darkmattericecoffee's ZallaxDev#68.
Import the independent pack format, generators, pure C decoder and
synthetic host tests; exercise Python tests on both pinned interpreters.
Modernize deprecated Pillow getdata calls and correct test import path.
Keep runtime battle rendering and options untouched until reconciled
with the newer 3DS engine, localization, and weather semantics.

Original implementation: ZallaxDev#68
Original author: darkmattericecoffee (d188bc7)
The production export uses fill_transparent after packing planes, but the
original ZallaxDev#68 test asserted against the pre-fill intermediate containing
0xFF at background pixels. Update expected bytes to match the documented
final on-disk outline-free format; keep all semantic assertions.
…oper flag

Preserve the current integration renderer and all game/graphics paths.
Import darkmattericecoffee's native plane reader, battle compositor and
game-side battler identification. Compile/link in dedicated feature-on
CI build with STEREO_BATTLE=1. Keep ordinary builds identical in behavior
by leaving the new sources out by default and adding no rendering hooks.
Default the internal battle option OFF until UI and genuine runtime
integration are audited. No asset or old patch number is imported.

Upstream work by darkmattericecoffee, PR ZallaxDev#68 (d188bc7).
The original ZallaxDev#68 battle source depends on CtrStereoMon_ParseHeader,
CtrStereoMon_Find and ComposeTile from 3ds_stereo_mon_decode.c.
Ensure feature-enabled full builds link these functions, while ordinary
builds continue to exclude every ZallaxDev#68 runtime translation unit.
Gate every runtime hook behind a developer-only build switch and a
runtime setting that defaults OFF. Use original depth-plane match only for
validated battler OAM while composing an actual stereo eye. Keep ordinary
2D, other sprites, weather wrapping and current slot logic unchanged.
Draw full scenes per eye only with matched depth battlers, avoiding duplicate
flat sprites. No release asset packaging or public options yet.

The original stereoscopic implementation is credited to darkmattericecoffee (ZallaxDev#68).
… developer builds

Allow explicit local STEREO_MONS_PACK and STEREO_BACKS_PACK paths to
be copied through the original fill-only validator. With no files given,
create legal header-only empty containers; ordinary builds include none.
No artwork, download behavior, normal runtime options or user-visible
features changed. Credit remains with darkmattericecoffee (ZallaxDev#68).
Exercise actual Pillow image loading rather than mocked generator calls:
RGBA transparency and q5 colors, four-plane grayscale depths, and two-frame
indexed front sprites. Synthetic fixtures only, no ROM or Pokémon art.
Run on both normal audit interpreters to guard the 3.15 migration.
…aults

Add a BATTLE/STEREO options group only to experimental feature builds
with actual depth packs. Support on/off, spread and pivot in seven
locales; keep it OFF by default and grey tuning controls until enabled.
Hide absent/empty packs, explicitly enforce missing-pack fallback even
if a stale settings.txt says to enable, and preserve all other menus.
Original implementation design credit: darkmattericecoffee PR ZallaxDev#68.
Validate entire EM3DSTM1 index and payload before staging authored packs:
unique ascending IDs, valid frame/plane counts, contiguous bounded data,
no surplus bytes and correct pixel depth values. Mirror bounds checks in
native file loader so malformed RomFS assets cannot expose settings.
Preserve deterministic, idempotent transparency filling and add negative
synthetic fixtures; default rendering remains untouched.
Ensure invalid-pack tests exercise real one-byte plane values and
valid 64x64 frame lengths, not escaped-text representations.
…e assets

Rebuild authored packs whenever the selected local source paths change;
keep that config separate from engine compilation. Prune old stereo
RomFS files when returning to normal builds to prevent asset leakage.
Assert engine-only classification and ABI/optional-asset isolation in
synthetic tests, without requiring a ROM or author binaries.
Only replace explicitly validated battler OAM in a real left/right 3D eye;
cover all 128 indices, masks, flat mode and weather classifications with
SDK-free host tests. Preserve the current battle clear color in the
experimental whole-eye path and reset OBJ-window/edge state before its
early return. Other rendering paths remain byte-for-byte unchanged.

Original stereo feature credited to darkmattericecoffee PR ZallaxDev#68.
…nal pixels

Exercise both synthetic animation frames, 2/3/4 plane groups, alternate
palette tints, silhouette transparency and 2-pixel depth skirts.
Far-to-near composition at no eye shift must reconstruct all original
RGBA5551 pixels exactly, catching visual and palette regressions without
redistributing ROM or sprite artwork.
… tints

The pack's (0,0) pixel is deliberately plane NONE in the inherited
fixture; keep its source artwork transparent for both palette variants
so the zero-parallax parity assertion tests valid matching silhouettes.
After testing the experimental build, rebuild and verify a genuine
STEREO_BATTLE=0 release in the pinned toolchain. Assert stereo macro is
absent, stale depth packs were pruned, and publication audit passes on
both configurations. Upload the ordinary default-off engine artifact.
No game changes; regression checks are mandatory for this draft.
Gate the entire BATTLE/STEREO group and its rows behind the developer
macro, not just runtime absence checks. Restore original RowExists and
ExtraLive logic literally in normal builds so no extra groups or
option-lookup work can affect the base game. In feature-on builds keep
all seven-language controls and pack gating.
The new flat-eye clear branch is compiled only with CTR_STEREO_BATTLE;
therefore the baseline-off build has an otherwise unused parameter under
-Werror. Mark it unused only in that build. Preserve all rendering logic,
stereo eye clear behavior and existing OAM fallback unchanged.
@mkrieger95 mkrieger95 changed the title Draft: forward-port #68 stereoscopic battle sprites to integration Forward-port #68 stereoscopic battle sprites to integration Nov 23, 2026
@mkrieger95
mkrieger95 marked this pull request as ready for review November 23, 2026 01:37
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant