I got some new information about SCC. It has this "Deformation register" that can be used to syncronize the sample. This register is not used even by Konami, so documentation about this was pretty hard to find.
Here is example about SCC method1, that can be very usefull when you want to play samples at background. Using this method, you should be able to update the sample memory on VDP lineinterrupts. Timing is anyway very hard to get right.
;------------------------------------
SLOT: EQU #1
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
ORG #D000
BEGIN:
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,SLOT
LD H,#80
CALL #24
XOR A
LD (#BFFF),A ; Select SCC emulation in case of SCC+
LD A,#3F
LD (#9000),A ; Select SCC page from mapper
LD HL,0
LD (#9880),HL ; Set frequency to 0
LD A,15
LD (#988A),A ; Set volume to 15
LD A,1
LD (#988F),A ; Enable first channel.
LD HL,#98E0 ; Search Deformation register
LD A,#A5 ; Dummy data
LD (#9860),A
LD BC,(#98A0)
CP C
JR NZ,NORMALSCC
DEC L ; SCC+
NORMALSCC:
LD (HL),32 ; Set sample to start from beginning
RET
PLAY:
DI
LD HL,#C000
LD DE,#9800
LD B,#20
CONVLOOP1:
LD A,(HL)
XOR 128 ;Convert to signed
LD (DE),A
INC HL
INC DE
DJNZ CONVLOOP1
LD BC,#382 ;Frequency
LD (#9880),BC
PLAYLOOP:
LD BC,#3C6
WAIT: DEC BC
LD A,B
OR C
JP NZ,WAIT
LD DE,#9800
LD B,#20
CONVLOOP2:
LD A,(HL)
XOR 128 ;Convert to signed
LD (DE),A
INC HL
INC DE
DJNZ CONVLOOP2
LD A,H
CP #D0
JP NZ,PLAYLOOP
LD HL,0
LD (#9880),HL
RET
END:
;------------------------------------------------------------------------
Here is variation about method3. Now it uses sample restart feature and is much faster to use.
;------------------------------------
SLOT: EQU #1
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
ORG #D000
BEGIN:
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,SLOT
LD H,#80
CALL #24
XOR A
LD (#BFFF),A ; Select SCC emulation in case of SCC+
LD A,#3F
LD (#9000),A ; Select SCC page from mapper
LD HL,0
LD (#9880),HL ; Set frequency to 0
LD A,15
LD (#988A),A ; Set volume to 15
LD A,1
LD (#988F),A ; Enable first channel.
LD HL,#98E0 ; Search Deformation register
LD A,#A5 ; Dummy data
LD (#9800),A
LD BC,(#98A0)
CP C
JR NZ,NORMALSCC
DEC L ; SCC+
NORMALSCC:
LD (HL),32 ; Set sample to start from beginning
RET
PLAY:
DI
LD HL,#9881
LD DE,0C000H
LD BC,1000H
PLAYLOOP:
LD A,(DE)
XOR 128 ; Convert to signed data
INC DE
LD (#9800),A
LD (HL),#FF ; Output sample data from #9800
LD (HL),0 ; Stop sample playing
EXX
LD B,58
WAIT: DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
RET
END:
;------------------------------------------------------------------------