6502 Assembly programming for the Commodore PET

The PET was the predecessor to the VIC 20, Released in 1976 it was the earliest of the Commodore home computers

Later revisions added more memory and a higher screen resolution, though it was still only 'character based'

Pet 2001 / 3000 Pet 4000 SuperPet 9000
Cpu 1mhz 6502 1mhz 6502 1mhz 6502 + 1mhz 6809
Ram 4/8k + 8 /16k+ 96k
Resolution 40 x 25 characters
1 characters set
80 x 25 characters
2 character sets
80 x 25 Characters
2 character sets
Colors Green / Black Green / Black Green / Black
Sound chip None / Beeper None / Beeper None / Beeper

Thanks to "KnightFire66" for the PET photos!


Memory Map

From To Function
$0000 $3FF OS and Basic storage
$0400 $1FFF Basic Program / 8k main ram
$2000 $7FFF 32k extension
$8000 $83FF VRAM
$C000 $E7FF Basic ROM
$E800 $EFFF I/O
 $F000 
 $FFFF 
OS ROM

Character Map


Write #12 to $E84C

Write #14 to $E84C

Keymap

Rom Functions

Address Purpose
$FFD2 PrintChar A
$FFE4 ReadChar A
$FFCF Input a character


I/O Map

Port Purpose Notes
$E810 
Key Row select (0-9)
$E812 Key Data
$E820 IEEE488
$E840 IO Port B output
$E841 IO Port A output
$E842 IO Port B direction (1=out 0=in)
$E843 IO Port A direction
$E844 Read Timer 1 Counter L / Write Timer 1 Latch L
$E845 Read Timer 1 Counter H / Write Timer 1 Latch H
$E846 Access Timer 1 Counter L
$E847 Access Timer 1 Counter H
$E848 Read Timer 2 Counter / Write Timer 2 L byte 64-255 = Sound Frequency
$E849 Access Timer 2 Counter
$E84A Serial I/O shift register 15/51/85 = Sound Octive
$E84B Aux Control Register 16= Sound On
$E84C Peripheral control 12=Graphics
$E84D Interrupt Flag Register (IFR)
$E84E Interrupt enable register
$E84F IO Port A Output without handshaking
$E880 CRTC reg select
$E881 CRTC reg Data
$FFF0 64k Expansion Control Register



Sound

The PET did not have any built in sound, but a speaker can be connected to the IO port.

The PET is capable of up to 4 octaves... one of 3 possible pairs can be selected with $E84A

Address $E84B will turn the sound on or off... we write #16 to turn it on, #0 to turn it off.
Address $E84A can be used to select the Octave with value 15/51/85
Address $E848 can be used to select the note, a value of 64-255 should be passed.

It is not possible to set the volume, or play multiple tones at the same time.

Note Freq octave=15 octave=51 octave=85
Octive 0 Octive 1 Octive 1 Octive 2 Octive 2 Octive 3
B 251 125 251 125 251 125
C 238 118 238 118 238 118
C# 224 110 224 110 224 110
D 210 104 210 104 210 104
D# 199 99 199 99 199 99
E 188 93 188 93 188 93
F 177 88 177 88 177 88
F# 168 83 168 83 168 83
G 158 78 158 78 158 78
G# 149 74 149 74 149 74
A 140 69 140 69 140 69
A# 133 65 133 65 133 65

(Sound info taken from the PetFaq)

Sfx with Chibisound!

These tutorials use a sound 'driver' called ChibiSound,
Chibisound uses a single byte parameter in the Accumulator, and provides 64 different pitches, in low or high volume with either tones or noise.
Sending a value of 0 mutes sound, all other values make a tone...

Chibisound is intended to make it simple to have SFX in multiplatform games and was used in Grime Z80 and Grime 6502
 7 
 6 
 5 
 4 
 3 
 2 
 1 
 0 


T V P P P P P P
T=Tone V=Volume P=Pitch

Writing Chibi Sound!





 

View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
***Main Menu***
Youtube channel
Forum
AkuSprite Editor
Dec/Bin/Hex/Oct/Ascii Table

Z80 Content
***Z80 Tutorial List***
Learn Z80 Assembly
Hello World
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
Sources.7z
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
MSX & MSX2
Sam Coupe
TI-83
ZX Spectrum
Spectrum NEXT
Camputers Lynx

6502 Content
***6502 Tutorial List***
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Hello World Series
Grime 6502
6502 Downloads
6502 Cheatsheet
Sources.7z
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Commander x16
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
***68000 Tutorial List***
Learn 68000 Assembly
Hello World Series
Platform Specific Series
Grime 68000
68000 Downloads
68000 Cheatsheet
Sources.7z
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL
X68000 (Sharp x68k)

8086 Content
Learn 8086 Assembly
Platform Specific Series
Hello World Series
8086 Downloads
8086 Cheatsheet
Sources.7z
DevTools kit
8086 Platforms
Wonderswan
MsDos

ARM Content
Learn ARM Assembly
Platform Specific Series
ARM Downloads
ARM Cheatsheet
Sources.7z
DevTools kit
ARM Platforms
Gameboy Advance
Nintendo DS
Risc Os

Risc-V Content
Learn Risc-V Assembly
Risc-V Downloads
Risc-V Cheatsheet
Sources.7z
DevTools kit

PDP-11 Content
Learn PDP-11 Assembly
PDP-11 Downloads
PDP-11 Cheatsheet
Sources.7z
DevTools kit

TMS9900 Content
Learn TMS9900 Assembly
TMS9900 Downloads
TMS9900 Cheatsheet
Sources.7z
DevTools kit
TMS9900 Platforms
Ti 99

6809 Content
Learn 6809 Assembly
6809 Downloads
6809/6309 Cheatsheet
Sources.7z
DevTools kit
6809 Platforms
Dragon 32/Tandy Coco
Fujitsu FM7
TRS-80 Coco 3
Vectrex

My Game projects
Chibi Aliens
Chibi Akumas

Work in Progress
Learn 65816 Assembly
Learn eZ80 Assembly

Misc bits
Ruby programming









Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book

Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!












































Recent New Content
Lesson P34 - Creating a game for the NeoGeo CD!

Sprite Movement on the Dragon 32- Simple 6502 ASM Lesson S1

Amiga - ASM PSET and POINT for Pixel Plotting

Learn 65816 Assembly: 8 and 16 bit modes on the 65816

SNES - ASM PSET and POINT for Pixel Plotting

ARM Assembly Lesson H3

Lesson P65 - Mouse reading on the Sam Coupe

Mouse Reading in MS-DOS

Risc-V Assembly Lesson 3 - Bit ops and more maths!

Mouse reading on the MSX

Hello World on RISC-OS

Atari 800 / 5200 - ASM PSET and POINT for Pixel Plotting


Gaming + more:

Emily The Strange (DS) - Live full playthrough

$150 calculator: Unboxing the Ti-84 Plus CE (eZ80 cpu)























































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book

Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!












































Recent New Content
Lesson P34 - Creating a game for the NeoGeo CD!

Sprite Movement on the Dragon 32- Simple 6502 ASM Lesson S1

Amiga - ASM PSET and POINT for Pixel Plotting

Learn 65816 Assembly: 8 and 16 bit modes on the 65816

SNES - ASM PSET and POINT for Pixel Plotting

ARM Assembly Lesson H3

Lesson P65 - Mouse reading on the Sam Coupe

Mouse Reading in MS-DOS

Risc-V Assembly Lesson 3 - Bit ops and more maths!

Mouse reading on the MSX

Hello World on RISC-OS

Atari 800 / 5200 - ASM PSET and POINT for Pixel Plotting


Gaming + more:

Emily The Strange (DS) - Live full playthrough

$150 calculator: Unboxing the Ti-84 Plus CE (eZ80 cpu)























































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book

Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!












































Recent New Content
Lesson P34 - Creating a game for the NeoGeo CD!

Sprite Movement on the Dragon 32- Simple 6502 ASM Lesson S1

Amiga - ASM PSET and POINT for Pixel Plotting

Learn 65816 Assembly: 8 and 16 bit modes on the 65816

SNES - ASM PSET and POINT for Pixel Plotting

ARM Assembly Lesson H3

Lesson P65 - Mouse reading on the Sam Coupe

Mouse Reading in MS-DOS

Risc-V Assembly Lesson 3 - Bit ops and more maths!

Mouse reading on the MSX

Hello World on RISC-OS

Atari 800 / 5200 - ASM PSET and POINT for Pixel Plotting


Gaming + more:

Emily The Strange (DS) - Live full playthrough

$150 calculator: Unboxing the Ti-84 Plus CE (eZ80 cpu)