This website requires JavaScript.
Explore
Help
Sign in
imjasonh
/
nescript
Watch
1
Star
0
Fork
You've already forked nescript
0
mirror of
https://github.com/imjasonh/nescript
synced
2026-07-16 20:26:23 +00:00
Code
Activity
53c454669d
nescript
/
tests
/
emulator
/
goldens
/
platformer.audio.hash
2 lines
16 B
Text
Raw
Normal View
History
Unescape
Escape
runtime: gate controller-2 reads in NMI on __p2_input_used Drop the three-instruction JOY2 shift block (`LDA $4017 / LSR A / ROL ZP_INPUT_P2`) from inside the NMI's 8-iteration input loop when user code never reads controller 2. IR codegen emits the `__p2_input_used` marker from `IrOp::ReadInput(_, 1)`; the linker threads the flag through a new `NmiOptions::has_p2_input` bool, and `gen_nmi` writes the shift block only when the flag is set. Savings for single-player programs: - ~6 bytes of NMI code. - ~30 cycles per frame (3 instructions × 8 loop iterations, each 6-8 cycles depending on addressing — LDA abs is 4, LSR A is 2, ROL zp is 5, so ~11 cycles × 8 = ~88 cycles; rounded down for the page-crossing penalty landing differently in the new layout). This commit also fixes the IR codegen to drop the matching `__p1_input_used` marker from `IrOp::ReadInput(_, 0)`, even though the next commit is the one that actually consumes it. Landing the two markers together keeps the IR codegen's per-op bookkeeping coherent. Six audio goldens flip (every program that reads input + plays audio) with the expected NMI-layout-shift cycle drift. https://claude.ai/code/session_016kM6P7PukktBDqTZexrrAN
2026-04-16 13:43:33 +00:00
83c0eee4 132084
Copy permalink