Atari XE/XL, POKEY 6bit, CPU 65816 (HighMem)
sample_loop (IRQ 15KHz)
Code:
irq
.ia16
sta regA
stx regX
.ia8
lda #0
sta.l IRQEN
lda #1
sta.l IRQEN
v0 lda #0
sta.l audc1
v1 lda #0
sta.l audc2
v2 lda #0
sta.l audc3
; ---
; --- AUDC 1
; ---
clc
ist_0 lda #0
iad0_m adc #0
sta ist_0+1
lda p_0c+1
iad0_s adc #0
bcc ext_0
inc p_0c+2
bne ext_0
ire0_s lda #0
sta p_0c+2
ire0_m lda #0
ext_0 sta p_0c+1
; ---
; --- AUDC 2
; ---
clc
ist_1 lda #0
iad1_m adc #0
sta ist_1+1
lda p_1c+1
iad1_s adc #0
bcc ext_1
inc p_1c+2
bne ext_1
ire1_s lda #0
sta p_1c+2
ire1_m lda #0
ext_1 sta p_1c+1
; ---
; --- AUDC 3
; ---
clc
ist_2 lda #0
iad2_m adc #0
sta ist_2+1
lda p_2c+1
iad2_s adc #0
bcc ext_2
inc p_2c+2
bne ext_2
ire2_s lda #0
sta p_2c+2
ire2_m lda #0
ext_2 sta p_2c+1
; ---
; --- AUDC 4
; ---
clc
ist_3 lda #0
iad3_m adc #0
sta ist_3+1
lda p_3c+1
iad3_s adc #0
bcc ext_3
inc p_3c+2
bne ext_3
ire3_s lda #0
sta p_3c+2
ire3_m lda #0
ext_3 sta p_3c+1
p_0c lda.l sample_start+$FFFF ; ch #1
sta ivol0+1
p_1c lda.l sample_start+$FFFF ; ch #2
sta ivol1+1
p_2c lda.l sample_start+$FFFF ; ch #3
sta ivol2+1
p_3c lda.l sample_start+$FFFF ; ch #4
sta ivol3+1
clc
ivol0 lda volume
ivol1 adc volume
ivol2 adc volume
ivol3 adc volume
tax
lda vol6bit,x
sta v0+1
lda vol6bit+$100,x
sta v1+1
lda vol6bit+$200,x
sta v2+1
.ia16
lda.w #0
regA equ *-2
ldx.w #0
regX equ *-2
rti
main_loop (VBL)
Code:
mainloop
.ai16
sta regA
stx regX
sty regY
.ai8
dec cnts
seq
jmp nmiExit
stz patend
ldy track_pos
*---------------------------
* track 0
i_0 ;ldy #1
lda [pat1],y
sta i_0c+1
and #$1f
beq i_0c
tax
sta nr0
lda adr.tivol-1,x
sta playloop.ivol0+2
i_0c ldx EFFECT
beq i_0f
cpx #$40
bne @+
;ldy #2
lda [pat2],y
sta playloop.ivol0+2
@ cpx #$c0
bne @+
;ldy #2
lda [pat2],y
sta pause
@ cpx #$80
bne i_0f
stx patend
i_0f ;ldy #0
lda [pat0],y
beq i_1
tax
lda tadcl-1,x
sta playloop.iad0_m+1
lda tadch-1,x
sta playloop.iad0_s+1
; lda #0
; sta playloop.ist_0+1
ldx nr0
txa
add ^sample_start-1
sta playloop.p_0c+3
lda adr.tstrl-1,x
sta playloop.p_0c+1
lda adr.tstrh-1,x
sta playloop.p_0c+2
lda adr.trepl-1,x
sta playloop.ire0_m+1
lda adr.treph-1,x
sta playloop.ire0_s+1
* track 1
i_1 iny
;ldy #4
lda [pat1],y
sta i_1c+1
and #$1f
beq i_1c
tax
sta nr1
lda adr.tivol-1,x
sta playloop.ivol1+2
i_1c ldx EFFECT
beq i_1f
cpx #$40
bne @+
;ldy #5
lda [pat2],y
sta playloop.ivol1+2
@ cpx #$c0
bne @+
;ldy #5
lda [pat2],y
sta pause
@ cpx #$80
bne i_1f
stx patend
i_1f ;ldy #3
lda [pat0],y
beq i_2
tax
lda tadcl-1,x
sta playloop.iad1_m+1
lda tadch-1,x
sta playloop.iad1_s+1
; lda #0
; sta playloop.ist_1+1
ldx nr1
txa
add ^sample_start-1
sta playloop.p_1c+3
lda adr.tstrl-1,x
sta playloop.p_1c+1
lda adr.tstrh-1,x
sta playloop.p_1c+2
lda adr.trepl-1,x
sta playloop.ire1_m+1
lda adr.treph-1,x
sta playloop.ire1_s+1
* track 2
i_2 iny
;ldy #7
lda [pat1],y
sta i_2c+1
and #$1f
beq i_2c
tax
sta nr2
lda adr.tivol-1,x
sta playloop.ivol2+2
i_2c ldx EFFECT
beq i_2f
cpx #$40
bne @+
;ldy #8
lda [pat2],y
sta playloop.ivol2+2
@ cpx #$c0
bne @+
;ldy #8
lda [pat2],y
sta pause
@ cpx #$80
bne i_2f
stx patend
i_2f ;ldy #6
lda [pat0],y
beq i_3
tax
lda tadcl-1,x
sta playloop.iad2_m+1
lda tadch-1,x
sta playloop.iad2_s+1
; lda #0
; sta playloop.ist_2+1
ldx nr2
txa
add ^sample_start-1
sta playloop.p_2c+3
lda adr.tstrl-1,x
sta playloop.p_2c+1
lda adr.tstrh-1,x
sta playloop.p_2c+2
lda adr.trepl-1,x
sta playloop.ire2_m+1
lda adr.treph-1,x
sta playloop.ire2_s+1
* track 3
i_3 iny
;ldy #10
lda [pat1],y
sta i_3c+1
and #$1f
beq i_3c
tax
sta nr3
lda adr.tivol-1,x
sta playloop.ivol3+2
i_3c ldx EFFECT
beq i_3f
cpx #$40
bne @+
;ldy #11
lda [pat2],y
sta playloop.ivol3+2
@ cpx #$c0
bne @+
;ldy #11
lda [pat2],y
sta pause
@ cpx #$80
bne i_3f
stx patend
i_3f ;ldy #9
lda [pat0],y
beq i_e
tax
lda tadcl-1,x
sta playloop.iad3_m+1
lda tadch-1,x
sta playloop.iad3_s+1
; lda #0
; sta playloop.ist_3+1
ldx nr3
txa
add ^sample_start-1
sta playloop.p_3c+3
lda adr.tstrl-1,x
sta playloop.p_3c+1
lda adr.tstrh-1,x
sta playloop.p_3c+2
lda adr.trepl-1,x
sta playloop.ire3_m+1
lda adr.treph-1,x
sta playloop.ire3_s+1
i_e
lda patend
bne i_en
iny
sty track_pos
bne i_end
i_en inc patno
ldx patno
patmax cpx #0
bcc i_ens
lda #6
sta pause
patres ldx #0
stx patno
i_ens ldy adr.ORDER,x
sty pat0+1
iny
sty pat1+1
iny
sty pat2+1
stz track_pos
i_end
lda pause
sta cnts
nmiExit
lda.l consol
cmp #$06
bne skp
lda #$2c ; bit *
sta stop
skp
.ia16
lda.w #0
regA equ *-2
ldx.w #0
regX equ *-2
ldy.w #0
regY equ *-2
rti