* = $c000
;*****************************************************
;* Sid Champ *
;*****************************************************]
savestk = $34a
low_vc = $34b
hi_vc = $34c
loop = $34d
key_counter = $34e
vc1_freq = $d400 ;voice 1 freq
waveform = $d402 ;voice 1 waveform
vc1_reg = $d403
vc1_env = $d405 ;voice 1 envelope
sigvol = $d418 ;volume
lda #0
sta $d020 ;black border
sta $d021 ;and screen
lda #$93
jsr $ffd2 ;clear screen using kernal call
jsr dis_msg1
;setup sound
lda #$f
sta sigvol
lda #129
sta waveform ;$d402 – Voice 1 Pulse Waveform Width (low byte)
lda #$00
sta vc1_reg ;$d402 – Save register
lda #$09
sta vc1_env ;$d405 – Voice 1 Attack/Decay Register
lda #$00
sta vc1_env+1 ;$d400 – Voice 1 Frequency Control (low byte)
;Get tone
lda #$41
sta 54272+4 ;$d404 – Voice 1 Control Register
lda #$12
sta vc1_freq + 1 ;$d401 – Voice 1 Frequency Control (high byte)
lda #$68
sta vc1_freq
jsr clear_sid
;******** Main Loop ********
main
lda $c5 ;get keyboard
sta key_counter
jsr changevoice
jtime
lda $dc00 ;$dc00 – Data Port Register A (joystick)
sta savestk ;save value in register
lda savestk
cmp #$7f
bne check_joy
sta savestk
jmp main
check_joy
cmp #119
beq lft ;left joystick movement
cmp #123
beq rgt ;right joystick movement
cmp #111
beq fire ;fire button pressed
wait
jmp main
lft
inc low_vc ;increase variable low_vc
lda low_vc
sta $d020 ;set border to variable color
jsr hold_tone
jmp main
rgt
dec low_vc ;decrease variable low_vc
lda low_vc
sta $d020 ;set border to variable color
jsr hold_tone
jmp main
fire
inc loop
jmp main
clear_sid
ldx #23
lp1
lda #0
sta vc1_freq,x
dex
bne lp1
rts
hold_tone
ldy loop
tlp1
ldx #23
tlp2
lda #17
sta vc1_freq+4 ;$d404 – Voice 1 Pulse Waveform Width (low byte)
dex
stx $d41b ;$d41b – Random Number Generator
bne tlp2
dey
bne tlp1
lda #16
sta vc1_freq+4 ;$d404 – Voice 1 Pulse Waveform Width (low byte)
rts
dis_msg1
ldx #0
msl1
lda msg1,x ;read bytes “SPACE BAR TO CHANGE VOICE”
sta $597,x
lda #7
sta $d997,x
inx
cpx #25
bne msl1
rts
changevoice
lda #17
sta 54272+2 ;color ram memory
sta 53280 ;border color
rts
msg1 text ‘SPACE BAR TO CHANGE VOICE’
instr byte 225,0,65,64,9,0
byte 0,0,17,16,96,0
byte 0,0,33,32,9,0
byte 0,0,17,16,0,240
byte 0,0,17,16,102,0
byte 0,0,33,32,96,0
byte 0,0,129,128,0,0