1er essai pour produire un LA440 à l'unisson sur les 4 voix
Code:
(main)MP
ORG $9000
main bsr inivol
ldy #song
jsr playmod
swi
rts
inivol ldu #vol+128
clrb
inivo1 pshs b
andb #$F0
stb ,-s
lsrb
lsrb
lsrb
lsrb
orb ,s+
lda ,s
anda #$0F
mul
addd #112
puls b
sta b,u
incb
bne inivo1
rts
playmod pshs d,x,y,u,dp,cc
orcc #$50
lda #$E7
tfr A,DP
setdp $E7
* init CNA
ldd <$E7CE
pshs d
andb #$FA
std <$E7CE
lda <$E7CD
pshs a
ora #$3F
sta <$E7CD
lda <$E7CF
ora #4
sta <$E7CF
lda <$E7C1
pshs a,dp
anda #$f7
sta <$E7C1
setdp playptn<-8
ldd #(playptn<-8)*256
tfr a,dp
clra
pshs d ; sentinel for end-of-song
sty <begsong
ldd ,y++
subd #2
leax d,y
stx <p_instr
jmp <playptn
setdp $E7
exitmod puls a,dp
sta <$E7C1
lda <$E7CF
anda #$FB
sta <$E7CF
puls a
sta <$E7CD
ldd <$E7CE
puls d
std <$E7CE
ldd <$E7CC
puls d,x,y,u,dp,cc,pc
DEF0 macro
IFEQ \2
\0 set *-\1
ENDC
endm
VOICE macro
LDB #0 ; 2
ADDB #0 ; 2 LSB frequence
DEF0 ch_flo,1,\0
STB <*-3 ; 4
LDB #0 ; 2
ADCB #0 ; 2 MSB frequence
DEF0 ch_fhi,1,\0
LDX #0 ; 3
tmp set *-2
DEF0 ch_beg,2,\0
ABX ; 3
CMPX #0 ; 4
DEF0 ch_end,2,\0
BLO ch\0L1 ; 3
LDX #0 ; 3
DEF0 ch_rpt,2,\0
ch\0L0 STX <tmp ; 5
LDB ,x ; 4
ORB #0 ; 2
DEF0 ch_vol,1,\0
IFEQ \0
LDA b,u ; 5 => 44
ELSE
ADDA b,u
ENDC
endm
org ((*+255)<-8)*256
setdp *<-8
ch0L1 bra ch0L0
ch1L1 bra ch1L0
ch2L1 bra ch2L0
ch3L1 bra ch3L0
* plays one frame
c_play pshs U,X,Y
ldu #vol+128 ; 3
ldy #105
f_loop set *
VOICE 0
VOICE 1
VOICE 2
VOICE 3 ; => 44*4=176
sta $E7CD ; 5 sortie son
leay -1,y ; 5
bne f_loop ; 3 ==> 189 cycles (5291khz)
PULS U,X,Y
* bra playptn
playptn ldb ,y+
beq c_ret ; 00000000
bpl c_call ; 0xxxxxxx xxxxxxxx
lslb
lslb
bcs c_vol ; 11ccvvvv
lslb
bcs c_instr ; 101xxxxx
lslb
bcs c_freq ; 1001ffff [ffffffff]
bne c_wait ; 1000wwww [wwwwwwww]
jmp <c_play ; 10000000
c_ret ldy ,s++ ; 9 cycles ouch!
bne playptn
jmp exitmod
c_call leax ,y+
ldd -1,x
pshs y
ldx #$0000
begsong set *-2
leay d,x
bra playptn
* 4 x 5000/s tous les 200us
* la 440 => 256*440z => 112640octets/sec ==> 22.5
ch_ref set ch_end
c_vol ldu #ch_ref
lslb
bcc c_vol1
leau ch2L0-ch0L0,u
c_vol1 lslb
bcc c_vol2
leau ch1L0-ch0L0,u
c_vol2 stb ch_vol-ch_ref,u
bra playptn
c_instr ldx #$0000
p_instr set *-2
abx
ldd ,x
addd <begsong
std ch_beg-ch_ref,u
ldd 2,x
addd <begsong
std ch_end-ch_ref,u
ldd 4,x
addd <begsong
std ch_rpt-ch_ref,u
jmp <playptn
c_freq bne c_freq2
ldd ,y++
bra c_freq3
c_freq2 ldb ,y+
lda -2,y
suba #%10010001
c_freq3 stb ch_flo-ch_ref,u
sta ch_fhi-ch_ref,u
jmp <playptn
c_wait ldb ,y+
lda -2,y
suba #%10000001
std <f_loop-2
jmp <c_play
vol RMB 256
sinus fdb sindat-song+000
fdb sindat-song+128
fdb sindat-song+000
sindat
fcb $8,$8,$8,$9,$9,$9,$A,$A
fcb $B,$B,$B,$C,$C,$C,$D,$D
fcb $D,$D,$E,$E,$E,$E,$F,$F
fcb $F,$F,$F,$F,$F,$F,$F,$F
fcb $F,$F,$F,$F,$F,$F,$F,$F
fcb $F,$F,$F,$E,$E,$E,$E,$D
fcb $D,$D,$D,$C,$C,$C,$B,$B
fcb $B,$A,$A,$9,$9,$9,$8,$8
fcb $8,$7,$7,$6,$6,$6,$5,$5
fcb $4,$4,$4,$3,$3,$3,$2,$2
fcb $2,$2,$1,$1,$1,$1,$0,$0
fcb $0,$0,$0,$0,$0,$0,$0,$0
fcb $0,$0,$0,$0,$0,$0,$0,$0
fcb $0,$0,$0,$1,$1,$1,$1,$2
fcb $2,$2,$2,$3,$3,$3,$4,$4
fcb $4,$5,$5,$6,$6,$6,$7,$7
* LA440 => 440*128*189/1000000=10.64448 [10:165]
song fdb sinus-song
fcb %11001111 ; voix 0: vol 15
fcb %10100000 ; instru 0
fcb %10010001+10,165 ;freq 440hz
fcb %11011111 ; voix 1: vol 15
fcb %10100000 ; instru 0
fcb %10010001+10,165 ;freq 440hz
fcb %11101111 ; voix 2: vol 15
fcb %10100000 ; instru 0
fcb %10010001+10,165 ;freq 440hz
fcb %11111111 ; voix 3: vol 15
fcb %10100000 ; instru 0
fcb %10010001+10,165 ;freq 440hz
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb %10000000 ; play frame
fcb 0 ; RETURN
end main
Mouais, ca a l'air de vouloir donner quelque chose.
Prochaine étape aapter le convertisseur midi dans ce nouveau format et faire jouer des sinus + du precussion.