mirror of
https://github.com/cybernesto/mcs-player.git
synced 2024-05-28 23:41:31 +00:00
118279b8e7
The Mockingboard PSGs base their frequency on the Apple II Clock. https://groups.google.com/g/comp.sys.apple2/c/lNSdI9GyBgc/m/8tAydOPUAwAJ Based on this discussion I made a spreadsheet to calculate the correct values of the frequency tables and updated the ones used by the Music Construction Set player.
380 lines
7.4 KiB
Plaintext
380 lines
7.4 KiB
Plaintext
;"Will Harvey's music"
|
|
;"Copyright (c) 1983"
|
|
;org $8500
|
|
;obj $8500
|
|
|
|
oregb = $00
|
|
orega = $01
|
|
orb2 = $80
|
|
ora2 = $81
|
|
ddrb2 = $82
|
|
ddra2 = $83
|
|
ddrb = $02
|
|
ddra = $03
|
|
t1cl = $04
|
|
t1ch = $05
|
|
acr = $0b
|
|
ifr = $0d
|
|
ier = $0e
|
|
|
|
slot = $ce
|
|
songadd = $eb
|
|
channadd = $d6
|
|
song = $4000
|
|
buffer = $800
|
|
|
|
; jmp intrupt
|
|
; jmp init
|
|
; jmp initmock
|
|
; jmp songadds
|
|
; jmp pause
|
|
; jmp continue
|
|
|
|
tempo !byte 04
|
|
decay !byte 03
|
|
startadd !word song-$02, song + $480 -$02
|
|
strong !byte $0a
|
|
start !byte 00
|
|
end !byte 06
|
|
rest !byte 08
|
|
tempcntr !byte 00
|
|
deccntr !byte 00
|
|
temp0 !byte 00
|
|
temp1 !byte 00
|
|
temp2 !byte 00
|
|
temp4 !byte 00
|
|
temp5 !byte 00
|
|
cntr !byte $01,$01
|
|
voice !byte $ff,$ff,$ff,$ff,$ff,$ff
|
|
plug !byte 00
|
|
freqlo !byte 00
|
|
freqhi !byte 00
|
|
tied !byte $00,$00
|
|
freqlos !byte $1D,$1E,$20,$22,$24,$26,$29,$2B
|
|
!byte $2E,$30,$33,$36,$3A,$3D,$41,$44
|
|
!byte $48,$4D,$51,$56,$5B,$61,$67,$6D
|
|
!byte $73,$7A,$81,$89,$91,$9A,$A3,$AC
|
|
!byte $B7,$C1,$CD,$D9,$E6,$F4,$02,$12
|
|
!byte $22,$33,$45,$59,$6D,$83,$9A,$B2
|
|
!byte $CC,$E8,$05,$23,$44,$66,$8B,$B2
|
|
!byte $DB,$06,$34,$65,$98,$CF,$01,$01
|
|
freqhis !byte $00,$00,$00,$00,$00,$00,$00,$00
|
|
!byte $00,$00,$00,$00,$00,$00,$00,$00
|
|
!byte $00,$00,$00,$00,$00,$00,$00,$00
|
|
!byte $00,$00,$00,$00,$00,$00,$00,$00
|
|
!byte $00,$00,$00,$00,$00,$00,$01,$01
|
|
!byte $01,$01,$01,$01,$01,$01,$01,$01
|
|
!byte $01,$01,$02,$02,$02,$02,$02,$02
|
|
!byte $02,$03,$03,$03,$03,$03,$00,$00
|
|
|
|
intrupt txa
|
|
pha
|
|
tya
|
|
pha
|
|
lda #%11000000
|
|
ldy #ifr
|
|
sta (slot),y
|
|
inc deccntr
|
|
inc tempcntr
|
|
lda deccntr
|
|
cmp decay
|
|
bne nodecay
|
|
jsr diminish
|
|
lda #0
|
|
sta deccntr
|
|
nodecay lda tempcntr
|
|
cmp tempo
|
|
beq music
|
|
jmp musicrti
|
|
music lda #$0
|
|
sta tempcntr
|
|
ldx #0
|
|
music12 stx temp2
|
|
txa
|
|
asl
|
|
sta temp4
|
|
dec cntr,x
|
|
lda cntr,x
|
|
bne music9
|
|
jsr stopvoic
|
|
music15 ldx temp4
|
|
lda songadd,x
|
|
clc
|
|
adc #2
|
|
sta songadd,x
|
|
bcc music10
|
|
inc songadd+1,x
|
|
music10 lda (songadd,x)
|
|
lsr
|
|
sta temp0
|
|
inc songadd,x
|
|
lda (songadd,x)
|
|
dec songadd,x
|
|
sta temp1
|
|
ora temp0
|
|
bne music11
|
|
jsr songadds
|
|
jmp music3
|
|
music11 ldx temp2
|
|
jsr search
|
|
lda temp2
|
|
sta voice,x
|
|
stx temp5
|
|
ldx temp0
|
|
lda freqlos,x
|
|
sta freqlo
|
|
lda freqhis,x
|
|
sta freqhi
|
|
lda strong
|
|
sta plug
|
|
ldx temp5
|
|
jsr plugit
|
|
ldx temp2
|
|
lda temp1
|
|
and #$40
|
|
sta tied,x
|
|
lda temp1
|
|
and #$3f
|
|
sta cntr,x
|
|
lda temp1
|
|
and #$80
|
|
bne music15
|
|
music9 ldx temp2
|
|
inx
|
|
cpx #$2
|
|
beq music3
|
|
jmp music12
|
|
music3 jsr initmock
|
|
musicrti pla
|
|
tay
|
|
pla
|
|
tax
|
|
lda $45
|
|
rti
|
|
|
|
search cpx #$0
|
|
bne s2
|
|
ldx start
|
|
s4 lda voice,x
|
|
bmi s3
|
|
inx
|
|
cpx end
|
|
bne s4
|
|
dex
|
|
rts
|
|
|
|
s2 ldx end
|
|
dex
|
|
s5 lda voice,x
|
|
bmi s3
|
|
dex
|
|
cpx start
|
|
bne s5
|
|
s3 rts
|
|
|
|
plugit txa
|
|
pha
|
|
tya
|
|
pha
|
|
lda #0
|
|
cpx #3
|
|
bcc pi2
|
|
dex
|
|
dex
|
|
dex
|
|
lda #$10
|
|
pi2 sta channadd
|
|
txa
|
|
asl
|
|
tay
|
|
lda freqlo
|
|
sta (channadd),y
|
|
iny
|
|
lda freqhi
|
|
sta (channadd),y
|
|
txa
|
|
clc
|
|
adc #$8
|
|
tay
|
|
lda plug
|
|
sta (channadd),y
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
rts
|
|
|
|
initmock txa
|
|
pha
|
|
tya
|
|
pha
|
|
lda #$ff
|
|
ldy #ddra
|
|
sta (slot),y
|
|
ldy #ddra2
|
|
sta (slot),y
|
|
lda #$1f
|
|
ldy #ddrb
|
|
sta (slot),y
|
|
ldy #ddrb2
|
|
sta (slot),y
|
|
ldx #$0
|
|
im2 txa
|
|
ldy #orega
|
|
sta (slot),y
|
|
lda #$f
|
|
ldy #oregb
|
|
sta (slot),y
|
|
lda #$c
|
|
sta (slot),y
|
|
lda buffer,x
|
|
ldy #orega
|
|
sta (slot),y
|
|
lda #$e
|
|
ldy #oregb
|
|
sta (slot),y
|
|
lda #$c
|
|
sta (slot),y
|
|
txa
|
|
ldy #ora2
|
|
sta (slot),y
|
|
lda #$17
|
|
ldy #orb2
|
|
sta (slot),y
|
|
lda #$14
|
|
sta (slot),y
|
|
lda buffer+$10,x
|
|
ldy #ora2
|
|
sta (slot),y
|
|
lda #$16
|
|
ldy #orb2
|
|
sta (slot),y
|
|
lda #$14
|
|
sta (slot),y
|
|
inx
|
|
cpx #$f
|
|
bne im2
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
rts
|
|
|
|
stopvoic ldx start
|
|
sv2 lda voice,x
|
|
cmp temp2
|
|
bne sv3
|
|
lda #$ff
|
|
sta voice,x
|
|
lda #$0
|
|
sta plug
|
|
jsr plugit
|
|
sv3 inx
|
|
cpx end
|
|
bne sv2
|
|
rts
|
|
|
|
songadds lda startadd
|
|
sta songadd
|
|
lda startadd+1
|
|
sta songadd+1
|
|
lda startadd+2
|
|
sta songadd+2
|
|
lda startadd+3
|
|
sta songadd+3
|
|
lda #<intrupt
|
|
sta $3fe
|
|
lda #>intrupt
|
|
sta $3ff
|
|
lda #<buffer
|
|
sta channadd
|
|
lda #>buffer
|
|
sta channadd+1
|
|
lda #$1
|
|
sta cntr
|
|
sta cntr+1
|
|
lda #$0
|
|
sta temp2
|
|
jsr stopvoic
|
|
lda #$1
|
|
sta temp2
|
|
jsr stopvoic
|
|
rts
|
|
|
|
init tya
|
|
pha
|
|
jsr initpar
|
|
jsr songadds
|
|
lda #%01000000
|
|
ldy #acr
|
|
sta (slot),y
|
|
lda #%01111111
|
|
ldy #ier
|
|
sta (slot),y
|
|
lda #%11000000
|
|
ldy #ifr
|
|
sta (slot),y
|
|
ldy #ier
|
|
sta (slot),y
|
|
lda #$ff
|
|
ldy #t1cl
|
|
sta (slot),y
|
|
lda #$40
|
|
ldy #t1ch
|
|
sta (slot),y
|
|
cli
|
|
pla
|
|
tay
|
|
rts
|
|
|
|
|
|
diminish ldx #$00
|
|
d1 lda voice,x
|
|
cmp #$2
|
|
bcs d2
|
|
tay
|
|
lda tied,y
|
|
bne d2
|
|
lda buffer+$8,x
|
|
cmp rest
|
|
beq d2
|
|
dec buffer+$8,x
|
|
d2 lda voice+3,x
|
|
cmp #$2
|
|
bcs d3
|
|
tay
|
|
lda tied,y
|
|
bne d3
|
|
lda buffer+$18,x
|
|
cmp rest
|
|
beq d3
|
|
dec buffer+$18,x
|
|
d3 inx
|
|
cpx #$3
|
|
bne d1
|
|
rts
|
|
|
|
pause sei
|
|
lda #0
|
|
sta temp2
|
|
jsr stopvoic
|
|
inc temp2
|
|
jsr stopvoic
|
|
jsr initmock
|
|
rts
|
|
|
|
continue cli
|
|
rts
|
|
|
|
initpar ldx #0
|
|
.loop lda params,x
|
|
sta buffer,x
|
|
sta buffer+$10,x
|
|
inx
|
|
cpx #$10
|
|
bne .loop
|
|
rts
|
|
|
|
params !byte $01,$00,$01,$00,$01,$00,$00,$f8
|
|
!byte $00,$00,$00,$00,$00,$00,$00,$00
|