#46

Widen the game's 16:9 culling cameras for Fill screen

Opencodedpalettewants to merge intofrom

With Fill screen on a wide display, objects at the sides popped in late. On the first right turn of Mute City, the boost panels appeared suddenly.

The game culls with two camera setups that take their aspect from a hardcoded 16:9, built in a register as movz w8, #0x3fe3, lsl #16; movk w8, #0x8e39 at 0x3d02dc and 0x66628c. Fill screen only widened the 4 camera aspect stores, so these cameras still culled with a 16:9 view. These are the only two places in the 4.0.1 code that build 16:9 this way.

  • nxpatch branches from these two sites to a trampoline that scales the constant by the same keypage aspect factor as the camera aspect stores. With Fill screen off, the factor is 0 and the value stays 16:9.
  • A mod that changes these sites is rejected like one that changes the aspect stores.
  • An emulator test checks the result for factors 1.34, 0 and -0, and that x16, x17, q1, q2, the flags and the stack stay unchanged.

This is 4.0.1 only. There were no 3.0.5 files to find its sites, so 3.0.5 keeps an empty list. The 3.0.5 aspect stores sit 0x2160 before their 4.0.1 matches, so the first site may be at 0x3ce17c in 3.0.5, but I did not check that, and the offset of the second site is unknown.

Tests

  • cargo test --workspace passes.
  • Tested on macOS (M1) with update 4.0.1 at a 3440x1440 ratio: first as a code patch at the same two sites, then with this change. The Mute City boost panels no longer pop in.