mirror of
https://github.com/imjasonh/nescript
synced 2026-07-08 08:55:38 +00:00
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 |
||
|---|---|---|
| .. | ||
| arrays_and_functions.audio.hash | ||
| arrays_and_functions.png | ||
| audio_demo.audio.hash | ||
| audio_demo.png | ||
| auto_chr_background.audio.hash | ||
| auto_chr_background.png | ||
| bitwise_ops.audio.hash | ||
| bitwise_ops.png | ||
| bouncing_ball.audio.hash | ||
| bouncing_ball.png | ||
| coin_cavern.audio.hash | ||
| coin_cavern.png | ||
| comparisons.audio.hash | ||
| comparisons.png | ||
| friendly_assets.audio.hash | ||
| friendly_assets.png | ||
| function_chain.audio.hash | ||
| function_chain.png | ||
| hello_sprite.audio.hash | ||
| hello_sprite.png | ||
| inline_asm_demo.audio.hash | ||
| inline_asm_demo.png | ||
| logic_ops.audio.hash | ||
| logic_ops.png | ||
| loop_break_continue.audio.hash | ||
| loop_break_continue.png | ||
| match_demo.audio.hash | ||
| match_demo.png | ||
| metasprite_demo.audio.hash | ||
| metasprite_demo.png | ||
| mmc1_banked.audio.hash | ||
| mmc1_banked.png | ||
| mmc3_per_state_split.audio.hash | ||
| mmc3_per_state_split.png | ||
| nested_structs.audio.hash | ||
| nested_structs.png | ||
| noise_triangle_sfx.audio.hash | ||
| noise_triangle_sfx.png | ||
| palette_and_background.audio.hash | ||
| palette_and_background.png | ||
| platformer.audio.hash | ||
| platformer.png | ||
| pong.audio.hash | ||
| pong.png | ||
| scanline_split.audio.hash | ||
| scanline_split.png | ||
| sfx_pitch_envelope.audio.hash | ||
| sfx_pitch_envelope.png | ||
| sha256.audio.hash | ||
| sha256.png | ||
| sprite_flicker_demo.audio.hash | ||
| sprite_flicker_demo.png | ||
| sprites_and_palettes.audio.hash | ||
| sprites_and_palettes.png | ||
| state_machine.audio.hash | ||
| state_machine.png | ||
| structs_enums_for.audio.hash | ||
| structs_enums_for.png | ||
| two_player.audio.hash | ||
| two_player.png | ||
| uxrom_banked.audio.hash | ||
| uxrom_banked.png | ||
| uxrom_banked_to_banked.audio.hash | ||
| uxrom_banked_to_banked.png | ||
| uxrom_user_banked.audio.hash | ||
| uxrom_user_banked.png | ||
| war.audio.hash | ||
| war.png | ||