mirror of
https://github.com/imjasonh/nescript
synced 2026-07-09 01:16:12 +00:00
Adds examples/uxrom_banked.ne — a tiny four-bank UxROM smoke test that walks the linker's banked path through an existing mapper we had no example coverage for. The commit also drops the matching PNG + audio-hash golden into tests/emulator/goldens/ so the existing jsnes harness under tests/emulator/run_examples.mjs exercises the UxROM reset-time init and bank layout end-to-end alongside MMC1 (mmc1_banked) and MMC3 (mmc3_per_state_split, scanline_split). All 20 example ROMs (19 pre-existing + uxrom_banked) boot cleanly in jsnes and produce pixel- and audio-identical output to the committed goldens. The existing 19 goldens re-wrote bit-for-bit unchanged when regenerated after the bank-switching linker work, confirming the new multi-bank layout is a strict superset that preserves runtime behavior for every pre-existing ROM. https://claude.ai/code/session_01UCressA5e8k1XsuoJYLav2 |
||
|---|---|---|
| .. | ||
| arrays_and_functions.ne | ||
| audio_demo.ne | ||
| bitwise_ops.ne | ||
| bouncing_ball.ne | ||
| coin_cavern.ne | ||
| comparisons.ne | ||
| function_chain.ne | ||
| hello_sprite.ne | ||
| inline_asm_demo.ne | ||
| logic_ops.ne | ||
| loop_break_continue.ne | ||
| match_demo.ne | ||
| mmc1_banked.ne | ||
| mmc3_per_state_split.ne | ||
| README.md | ||
| scanline_split.ne | ||
| sprites_and_palettes.ne | ||
| state_machine.ne | ||
| structs_enums_for.ne | ||
| two_player.ne | ||
| uxrom_banked.ne | ||
NEScript Examples
Quick Start
# Build the compiler
cargo build --release
# Compile all examples
for f in examples/*.ne; do cargo run -- build "$f"; done
# Or compile one
cargo run -- build examples/hello_sprite.ne
Open any .nes file in an NES emulator (Mesen, FCEUX, etc.)
Examples
| File | Features | Description |
|---|---|---|
hello_sprite.ne |
input, draw | Move a sprite with the d-pad |
bouncing_ball.ne |
if/else, variables | Auto-bouncing sprite with edge detection |
coin_cavern.ne |
states, functions, constants | 3-state game with gravity and coin collection |
arrays_and_functions.ne |
arrays, functions, while | Enemy array with collision detection |
state_machine.ne |
on enter/exit, transitions | Multi-state flow with timers |
sprites_and_palettes.ne |
sprites, palettes, scroll, cast | Inline CHR data, palette switching, type casting |
mmc1_banked.ne |
MMC1, banks, multiply | Banked mapper with software multiply |
Emulator Controls
| NES Button | Typical Key |
|---|---|
| D-pad | Arrow keys |
| A | Z |
| B | X |
| Start | Enter |
| Select | Right Shift |
About Sprites
Sprite names in draw Player at: (x, y) are parsed and recorded in the AST.
You can define sprites with inline CHR tile data:
sprite Player {
chr: [0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
}
If no matching sprite declaration exists, the draw uses the built-in default
tile (a smiley face). See sprites_and_palettes.ne for a full example.
Compiler Commands
# Compile to ROM
cargo run -- build game.ne
# Custom output path
cargo run -- build game.ne --output my_game.nes
# Type-check only
cargo run -- check game.ne
# View generated 6502 assembly
cargo run -- build game.ne --asm-dump
# Debug mode
cargo run -- build game.ne --debug