📝 NES Code Editor

untitled
This file replaces steps/Step_Playground/src/main.c for the Play button. Everything from the Backgrounds and Sprites pages (CHR, palettes, nametable, animations) is still auto-generated as scene.inc and palettes.inc — so player_tiles, walk_tiles, NUM_STATIC_SPRITES etc. are all available. Press Ctrl+Space for autocomplete. Click Symbols… to see the full list.

Goal:
💡 Show hints
cc65 output idle
Press ▶ Play in NES to compile and run. cc65 errors and warnings appear here.

Auto-generated symbols available to your code

Every time you press Play, the server regenerates two headers from whatever you built on the other pages:

palettes.inc

  • palette_bytes[32] — 16 BG + 16 sprite colours

scene.inc

  • PLAYER_X / PLAYER_Y — where you placed the player
  • PLAYER_W / PLAYER_H — sprite size in 8×8 tiles
  • player_tiles[] / player_attrs[]
  • WALK_FRAME_COUNT / WALK_FRAME_TICKS
  • walk_tiles[] / walk_attrs[]
  • JUMP_FRAME_COUNT / JUMP_FRAME_TICKS
  • jump_tiles[] / jump_attrs[]
  • NUM_STATIC_SPRITES
  • ss_x / ss_y / ss_w / ss_h / ss_offset
  • ss_tiles[] / ss_attrs[]

load_background() (from graphics.s) copies the auto-generated .chr and .nam into PPU memory. You only need to call it once, before enabling rendering.

🧩 Snippet library

Pick a snippet to paste at your cursor. In Guided mode, your cursor must be on an editable (green) line — snippets marked fits: <region> match the region you're in now.

Loading…
Select a snippet to preview the code that will be inserted.

📚 Lesson library

Pick a lesson to load its starter code into the editor. Your current work is saved to a backup in localStorage first. Leave Guided mode on — each lesson only unlocks the parts you need.

Loading…

📝 Code page — help & shortcuts

Edit main.c (or main.s in Asm mode) and press ▶ Play in NES to compile + run. In Guided mode only the highlighted lines are editable; switch to Advanced to edit freely.

Keyboard shortcuts

?Open this help dialog Ctrl+SpaceAutocomplete symbols (player_tiles, walk_tiles, etc.) Ctrl+SSnapshot your code (auto-save also runs every few seconds) Ctrl+Z / Ctrl+Shift+ZUndo / redo (inside the editor) FFull-screen the in-browser emulator while it's open PPause / resume the in-browser emulator RReset the in-browser emulator

Buttons

💬 Leave feedback on this page

▶ Your game

D-pad Z B · X A Enter Start · Shift Select F fullscreen · P pause · R reset