| Commodore 64 | mortenbs.com Last updated Jan 2012. |
| The Commodore 64, truly an important part of the computer history. Using 5.25" diskettes or tape casettes, mostly game-programs were loaded into it's 64 Kb - of memory. The program was run by it's ~1 MHz processor, to a TV or monitor at 320x200 - pixels and 16 colors (8:5 aspect). Few pictures of my old Commodore 64 setup, 1991-1995. |
![[Cloud]](/it/c64/games/giana-cloud-001.gif)
![[Cloud]](/it/c64/games/giana-cloud-001.gif)
![[Giana]](/it/c64/games/giana-001.gif)
![[Giana]](/it/c64/games/giana-tree-001.gif)
![[Giana]](/it/c64/games/giana-monster-001.gif)








| Command | Description |
| NEW | Clear memory, new program... |
| RUN | Run program |
| LOAD"$",8 | Load device 8 |
| LOAD"NAME",8 | Load program on disk, device 8 |
| SAVE"@:filename",8 | Overwrite file, device 8 |
| OPEN 1,8,15,"N:NAME,01":CLOSE 1 | Format disk, device 8 (clear memory first) |
| OPEN 1,8,15,"S:filename":CLOSE 1 | Delete file, device 8 |
| OPEN 1,8,15,"R:NEW-NAME=OLD-NAME":CLOSE 1 | Rename file, device 8 |
| LIST | List all |
| LIST 10 | List line number 10 |
| LIST -100 | List all lines to 100 |
| LIST 110-400 | List from line 110 to 400 |
| LIST 1000- | List from line 1000 |
| REM >>Comment<< | Comments/remarks |
| Type | Range | Data type PC | Description | Var ex. |
| BYTE | $00..$FF (0..255) | BYTE | 8 bit unsigned | B |
| INT | $0000..$FFFF (0..65535) | WORD | 16 bit unsigned | I% |
| FLOAT | 2.94E-39..1.70E+38, +/- 2-128..2127 | FLOAT | F | |
| STR | len(S$) | STRING(255) | Max 255 chars | S$ |
| Command | Title | Description |
| B=VAL(S$) | STR to BYTE | |
| I%=VAL(S$) | STR to INT | |
| F=VAL(S$) | STR to FLOAT | |
| S$=STR$(B) | BYTE to STR | |
| S$=STR$(I%) | INT to STR | |
| S$=STR$(F) | FLOAT to STR | |
| B=ASC(S$) | CHAR (STR) to BYTE | ASCII value |
| S$=CHR$(B) | BYTE to CHAR (STR) | ASCII value |
| HB=INT(I%/256) | INT to BYTE (high) | Extract high BYTE from INT |
| LB=I%-(INT(I%/256)*256) | INT to BYTE (low) | Extract low BYTE from INT |
C64 Colors
| C64 color & display commands
|
| Command | Description |
| INPUT "QUERY: ";S$:PRINT "INPUT WAS: ";S$ | Keyboard input text |
| 10 GET K$:IF K$="" THEN 10 | Keyboard input char/key |
| J=PEEK(56321) | Read joystick port 1 |
| J=PEEK(56320) | Read joystick port 2 |
| IF (J AND 1)=0 THEN S$="UP" | Check joystick value if moved up |
| IF (J AND 2)=0 THEN S$="DOWN" | Check joystick value if moved down |
| IF (J AND 4)=0 THEN S$="LEFT" | Check joystick value if moved left |
| IF (J AND 8)=0 THEN S$="RIGHT" | Check joystick value if moved right |
| IF (J AND 16)=0 THEN S$="FIRE" | Check joystick value if pushed fire |
| Command | Description |
| POKE 788,52 | Turn RUN/STOP key off |
| POKE 788,49 | Turn RUN/STOP key on |
| POKE 657,128 | Turn SHIFT key off |
| POKE 657,0 | Turn SHIFT key on |
| POKE 792,193 | Turn RESTORE key off |
| POKE 792,71 | Turn RESTORE key on |
| POKE 198,0 | Clear keyboard buffer |
| POKE 650,127 | No keyboard repeat |
| POKE 650,0 | Normal keyboard repeat |
| POKE 56341,12 | Fast cursor speed [1..255] |
| POKE 56341,25 | Normal cursor speed |
|
|
| Waveform | Voice setting | MOS6581 | MOS8580 |
| 017 Triangle | |||
| 033 Sawtooth | |||
| 065 Square, duration 1 | |||
| 065 Square, duration 5 | |||
| 065 Square, duration 7 | |||
| 065 Square, duration 10 | |||
| 065 Square, duration 15 | |||
| 129 Noise |
| Command | Description |
| POKE 54296,15 | Set volume [0..15] (Master) |
| POKE 54276,17 | Set voice 1 waveform [17 tri/33 saw/65 square/129 noise] |
| POKE 54283,33 | Set voice 2 waveform [17 tri/33 saw/65 square/129 noise] |
| POKE 54290,129 | Set voice 3 waveform [17 tri/33 saw/65 square/129 noise] |
| POKE 54275,15 | Set voice 1 square duration [0..15] (High byte) |
| POKE 54282,15 | Set voice 2 square duration [0..15] (High byte) |
| POKE 54289,15 | Set voice 3 square duration [0..15] (High byte) |
| POKE 54274,0 | Set voice 1 square duration [0] (Low byte) |
| POKE 54281,0 | Set voice 2 square duration [0] (Low byte) |
| POKE 54288,0 | Set voice 3 square duration [0] (Low byte) |
| POKE 54277,(ATTACK1*16)+DECAY1 | Set voice 1 attack [0..15] + decay [0..15] |
| POKE 54284,(ATTACK2*16)+DECAY2 | Set voice 2 attack [0..15] + decay [0..15] |
| POKE 54291,(ATTACK3*16)+DECAY3 | Set voice 3 attack [0..15] + decay [0..15] |
| POKE 54278,(SUSTAIN1*16)+RELEASE1 | Set voice 1 sustain [0..15] + release [0..15] |
| POKE 54285,(SUSTAIN2*16)+RELEASE2 | Set voice 2 sustain [0..15] + release [0..15] |
| POKE 54292,(SUSTAIN3*16)+RELEASE3 | Set voice 3 sustain [0..15] + release [0..15] |
| POKE 54272,2145-(INT(2145/256)*256) | Set voice 1 frequency (ex. 2145=C3) (Low byte) |
| POKE 54273,INT(2145/256) | Set voice 1 frequency (ex. 2145=C3) (High byte) |
| POKE 54279,2703-(INT(2703/256)*256) | Set voice 2 frequency (ex. 2703=E3) (Low byte) |
| POKE 54280,INT(2703/256) | Set voice 2 frequency (ex. 2703=E3) (High byte) |
| POKE 54286,3215-(INT(3215/256)*256) | Set voice 3 frequency (ex. 3215=G3) (Low byte) |
| POKE 54287,INT(3215/256) | Set voice 3 frequency (ex. 3215=G3) (High byte) |
| POKE 53295,(RESONANCE*16)+FILTER_VOICE | Set resonance [0..15] + filter voice number [1/2/3] |
| FOR N=1 TO 500:NEXT | Pause... |
| POKE 54272,0:POKE 54273,0 | Stop sound, voice 1 |
| POKE 54279,0:POKE 54280,0 | Stop sound, voice 2 |
| POKE 54286,0:POKE 54287,0 | Stop sound, voice 3 |
| FOR N=1 TO 500:NEXT | Pause... |
| FOR N=54272 TO 54296:POKE N,0:NEXT | Reset sound... |
| Octave | C | C# | D | D# | E | F | F# | G | G# | A | A# | B |
| 0 | 268 | 284 | 301 | 318 | 337 | 358 | 379 | 401 | 425 | 451 | 477 | 506 |
| 1 | 536 | 568 | 602 | 637 | 675 | 716 | 758 | 803 | 851 | 902 | 955 | 1012 |
| 2 | 1072 | 1136 | 1204 | 1275 | 1351 | 1432 | 1517 | 1607 | 1703 | 1804 | 1911 | 2025 |
| 3 | 2145 | 2273 | 2408 | 2551 | 2703 | 2864 | 3034 | 3215 | 3406 | 3608 | 3823 | 4050 |
| 4 | 4291 | 4547 | 4817 | 5103 | 5407 | 5728 | 6069 | 6430 | 6812 | 7217 | 7647 | 8101 |
| 5 | 8583 | 9094 | 9634 | 10207 | 10814 | 11457 | 12139 | 12860 | 13625 | 14435 | 15294 | 16293 |
| 6 | 17167 | 18188 | 19269 | 20415 | 21629 | 22915 | 24278 | 25721 | 27251 | 28871 | 30588 | 32407 |
| 7 | 34334 | 36376 | 38539 | 40830 | 43258 | 45830 | 48556 | 51443 | 54502 | 57743 | 61176 | 64814 |
