1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 08:55:38 +00:00
nescript/src
Claude 0de1d60c33
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 21:15:09 +00:00
..
analyzer compiler: satisfy four new clippy 1.95 lints so CI stays green 2026-04-16 15:15:24 +00:00
asm
assets codereview: address six findings from a fresh review pass 2026-04-15 03:56:42 +00:00
codegen runtime: gate controller-2 reads in NMI on __p2_input_used 2026-04-16 21:15:09 +00:00
errors W0110 inline fallback warning + docs refresh 2026-04-15 23:19:07 +00:00
ir codegen+ir: code-review followups (UTF-8 safety, leaf exhaustiveness, tests) 2026-04-16 17:46:06 +00:00
lexer sprite-per-scanline: add cycle_sprites runtime flicker + debug telemetry 2026-04-15 22:07:19 +00:00
linker runtime: gate controller-2 reads in NMI on __p2_input_used 2026-04-16 21:15:09 +00:00
optimizer compiler: satisfy four new clippy 1.95 lints so CI stays green 2026-04-16 15:15:24 +00:00
parser sprite-per-scanline: add cycle_sprites runtime flicker + debug telemetry 2026-04-15 22:07:19 +00:00
rom
runtime runtime: gate controller-2 reads in NMI on __p2_input_used 2026-04-16 21:15:09 +00:00
lib.rs
main.rs compiler: satisfy four new clippy 1.95 lints so CI stays green 2026-04-16 15:15:24 +00:00
pipeline.rs codereview: address six findings from a fresh review pass 2026-04-15 03:56:42 +00:00