-
Notifications
You must be signed in to change notification settings - Fork 0
VIC Graphics Test
Rudolf Stepan edited this page Jun 20, 2026
·
2 revisions
Comprehensive test program for the VIC bitmap mode (320x200 pixels).
# Program is already in data/disk/basic.prg
./sbc6502In the emulator:
BASIC
LOAD
RUN
The program runs 6 different graphics tests:
- Horizontal Lines — Draws horizontal lines spaced 20 pixels apart
- Vertical Lines — Draws vertical lines spaced 32 pixels apart
- Checkerboard Pattern — Draws a checkerboard pattern
- Rectangle — Draws a rectangle from (50,40) to (270,160)
- Diagonal Line — Draws a diagonal from top-left to bottom-right
- Full Screen — Fills the entire screen with white pixels
Each test is displayed for about 2 seconds, then the screen is cleared and the next test starts.
Memory Map:
- VIC Control Register:
$9000(36864)- Value
0: Text mode (40x25) - Value
1: Bitmap mode (320x200)
- Value
- Bitmap RAM:
$9010-$AF4F(36880-44879, 8000 bytes)
Pixel Formula:
X = 0-319 (horizontal)
Y = 0-199 (vertical)
BYTE_OFFSET = Y * 40 + INT(X / 8)
BIT_POSITION = 7 - (X AND 7)
ADDRESS = 36880 + BYTE_OFFSETSet pixel:
POKE ADDRESS, PEEK(ADDRESS) OR (2^BIT_POSITION)Clear pixel:
POKE ADDRESS, PEEK(ADDRESS) AND (255 - 2^BIT_POSITION)From a text file:
# Create program in examples/mygfx.txt
nano examples/mygfx.txt
# Convert
python3 tools/basic_convert.py examples/mygfx.txt data/disk/basic.prg
# Load in emulator
./sbc6502
BASIC
LOAD
RUNMinimal example:
10 REM Switch to graphics
20 POKE 36864,1
30 REM Draw pixel at (100,50)
40 A=36880+(50*40+INT(100/8))
50 POKE A,PEEK(A) OR 2^(7-(100 AND 7))
60 REM Wait for key
70 GET K$: IF K$="" THEN 70
80 REM Back to text mode
90 POKE 36864,0
100 END-
examples/hello.txt— Simple Hello World -
examples/graphics.txt— Interactive graphics demo -
examples/gfxtest.txt— This automated test (154 lines)
- Drawing many pixels is slow (BASIC is interpreted)
- Delay loops (
FOR W=1 TO 2000: NEXT W) are approximate, not exact - For faster graphics: use assembly routines via
SYS
Generated from 6502-sbc-emulator Markdown documentation. FPGA hardware track: 6502-sbc-fpga (FPGA Wiki).