MADE FOR THE NES. READY FOR YOUR IDEAS. NO ACCOUNT NEEDED.
NESBASICBY NDB SOFTWARE

09 NES BASIC PROGRAMMING GUIDE

Graphics and the built-in sprite creator

SCREEN 0 is text. SCREEN 1 starts/clears a graphics canvas and its standard mapping. The canvas is 128×64 one-bit pixels, with local (0,0) at its top left and (127,63) at its bottom right. It occupies part of the NES screen, not a full-screen bitmap. COLOR selects one shared foreground/background pair. Valid NES palette indices are 0–63 except 13,29,45,61. The canvas does not have a separate color per pixel.

NES BASIC
10 SCREEN 1
20 COLOR 42,15
30 RECT 8,8,119,55
40 LINE 0,0,127,63
50 PSET 64,32
60 END

PSET plots one pixel. LINE is an inclusive integer segment. RECT uses opposite corners, not width and height. An optional final ink argument of 0/1 clears/sets pixels. Points outside the canvas clip. FILL fills a four-connected region with a bounded worklist; a complicated region can report FILL TOO COMPLEX. Large operations paint progressively and remain interruptible.

TILE works on the NES nametable in SCREEN 1: column 0–31, row 0–29, pattern 0–255. Patterns are shared. A TILE referencing a canvas pattern changes when that pattern is drawn later. SCREEN 1 restores the standard mapping. CLS clears the active canvas; placements outside it remain. Text restoration clears the canvas.

Sprites are real 8×8 NES hardware sprites. SPRITE slot,x,y,art shows one of 64 slots, using x=0–255 and y=1–239. Art 0–7 is predefined: ship, player, enemy, ball, projectile, star, block, pointer. Art 8–39 is editable. MOVE changes a shown slot's position; HIDE hides it. SPRCOL(a,b) tests unclipped 8×8 bounding boxes of visible slots, including transparent pixels. It is not per-pixel collision. The ninth sprite on the same scanline is hidden by the hardware limit; no automatic flicker is added. Arrange sprites accordingly.

EDITSPR 8 opens BASIC's own creator, independent of Paint. D-pad moves/wraps on the grid, A paints and B erases. Select opens tools; choose color/art with the pad. Tools also clear, fill, mirror horizontally, flip vertically and undo. Start requests exit. If edited, choose KEEP, DISCARD or CANCEL. Kept art becomes available to SPRITE immediately; it is not permanent until you SAVE the project.

Each pattern has four indexed pixel values: 0 transparent, 1 green, 2 white, 3 blue. This is a shared fixed sprite palette, not arbitrary per-sprite color editing. There is no composed 16×16 editor or independently named sprite file. A named BASIC project stores all 32 kept 8×8 patterns. Reopen the art ID to edit it. After KEEP, use SCREEN 1:SPRITE 0,80,80,8 as a direct fragment to display art 8.

Try Draw outside the lines Download the source ↓