Specifications

Our first task will be to attempt to reproduce the familiar chimes which we
hear when the SuperPET is turned on in 6502 mode. To do this, we'll translatete
the code which runs the chimes from 6502 to the equivalent 6809 code.
;chimer.asm— for
6809
6502
Code
driver jsr chimes
swi
chimes
jsr chime
e6a4
20
a7
e6 jsr
chime
chime ldy #$10
e6a7
a4
e7
ldy $e7 ;chime timer loc
sty $e7
e6a9
fO
25
beq $e690;contains $10
Ida #$10 e6ab
a9
10
Ida
#$10
sta $e84b
; set VIA timer to e6ad 8d 4b
e8
sta $e84b
Ida #$0f ; free running mode
e6b0
a9
Of
Ida
#$0f
sta $e84a
e6b2 8d 4a
e8
sta
$e84a
ldx #7 ; num. of note 2 play
e6b5
a2
07
ldx
#$07
outer Ida tabl, x
e6b7
bd 4d
e7
Ida $e7^d,x
sta $e848 ; play selected note
e6ba 8d
48 e8
sta
$e848
Ida $e7
e6bd
a5
e7
Ida
$e7
inner
leay -1,y
; same as dey e6bf
88
dey
bne inner
e6c0 dO fd
bne
$e6bf
ldy $e7 ;
reset y value
; when y dec in 6809 it goes
to $FFFF
; a rather long delay, so we reset here
sec
e6c2
38
sec
sbca #$01
e6c3 e9
01 sbc #$01
bne inner
e6c5 d0
f8
bne
$e6bf
dex ;
all notes played?
e6c7
ca
dex
bne outer ; no get next note e6c8 dO ed
bne
$e6b7
stx $e84a ; yes turn sound off
e6ca 8e 4a
e8 stx
$e84a ;x is double
e6cd 8e
4b e8 stx
$e84b ;one does al
rts e6d0
60
rts
tabl feb $00,$0e, $1e,$3e,$7e,$1e,$0e,$00 e l U 00 Oe 1e 3e 7e 1e Oe 00
"chimer"
org $1000
Mchimer.b09"
At left is chimer.cmd, needed for linking. Load chimer.mod in
the monitor (not from menul), then: >g 1000. The program will
produce the chimes we are so used to hearing every time the
6502 side is called.
[Ed. You'll need good ears. We couldn't hear chimes until we put an ear against
the case. The code is okay as is. Gary's second program, below, is easily heard.
For those who want music: John Toebes of Raleigh claims that you can run both
leads on the tiny speaker in SuperPET to a larger, external speaker and get good
sound. We asked if more power was needed, and John said: 'No!']
The example above shows that translating 6502 code into 6809 is almost triv
ial. About 95% of the code may be translated directly. The major traps: both the
X and Y registers are double-wide when compared to the equivalents in 6502; you
must use finesse in handling them.
;sound 1.asm
Ida #$10
sta $e84b
Ida #$0f
sta $e84a
Ida # 00
Here is another example; it will cycle through all
the tones available when using the CB2 sound of the
the VIA (6522 chip) of SuperPET. (.cmd file, left.)
As noted earlier, the 'nop' instruc-
"soundl" tion produces a rather quiet sound;
org $1000 there is, however, a 6809 instruction
SuperPET Gazette, Vol.I No.11
-178-
December 1983/January 1984