Commodore64 Basic Reference Expanded
Commodore64 Basic Reference Expanded
============
Version: BASIC V2
Memory available: ~38911 bytes
COMMANDS
========
CONTROL STRUCTURES
==================
- GOTO line_number
- GOSUB line_number / RETURN
FUNCTIONS
=========
INPUT/OUTPUT
============
- INPUT var
- PRINT expr
Example: PRINT "HELLO WORLD"
- GET var
Example: GET A$ ; Read a single character into A$
EXAMPLES
========
ERROR CODES
===========
MEMORY MAP
==========
SPRITES:
- 8 hardware sprites
- Each sprite is 24x21 pixels
- Enable: POKE 53269,1 for sprite 0
- X/Y position: POKE 53248 + N*2, X : POKE 53249 + N*2, Y
- Multicolor: POKE 53276,1
Voice 1:
- Frequency Low: 54272 ($D400)
- Frequency High: 54273 ($D401)
- Waveform Control: 54276 ($D404)
- Attack/Decay: 54277 ($D405)
- Sustain/Release: 54278 ($D406)
Example:
POKE 54296,15 ; Volume = max
POKE 54272,100 ; Set frequency low byte
POKE 54273,0 ; Set frequency high byte
POKE 54276,17 ; Triangle waveform + Gate on
DISK/TAPE I/O
=============
Tape:
- LOAD and SAVE work without specifying device
- Tape counter and motor control not programmable
USR Function:
You can define USR(x) to call a machine code routine.
Example:
POKE 785,0 : POKE 786,2 : POKE 787,0 ; Set USR pointer to 512
POKE 512,96 ; RTS instruction at $0200
PRINT USR(0) ; Call the routine
You can embed your own machine code starting at 512 (or other locations).
Each row of the keyboard matrix is mapped to a specific bit in a CIA port.
Example:
- Row 0 (Ctrl, 1, Q, etc.): POKE 56320,254 : PRINT PEEK(56321)
- You can detect keypresses by scanning each row with POKE/PEEK.
COLOR CODES
===========
0 - Black 8 - Orange
1 - White 9 - Brown
2 - Red 10 - Light red
3 - Cyan 11 - Dark grey
4 - Purple 12 - Grey
5 - Green 13 - Light green
6 - Blue 14 - Light blue
7 - Yellow 15 - Light grey