But perhaps touko is doing something really clever to reload the waveform data that avoids turning the channel off.
no, i use the standard method:
lda #%010_00000
sta $0804
stz $0804
touko: Would you mind sharing your code for reloading the waveform?
Yes of course
I set the timer to 31, and the used psg voice to 512 .
User_Timer_Irq:
stz $1403 ; // ACK TIMER
; // On reactive les interruption pour pas bloquer
; // Les interruptions HSYNC
cli
; // Save REG A
pha
; // We save the banks 3 and 4
; // We assume bank 4 is always bank3 +1
tma #3
pha
; // If voice is on
bbr0 <sample_voix1_on , Fin_Timer_Int
lda <sample_bank_voix1
tam #3
inc A
tam #4
lda #VOIX_PCM1
sta $800
; // Reset the wave pointer
lda #%010_00000
sta $0804
stz $0804
; // We fill the wave buffer
TIN_Buffer_Voix1:
tin $0000 , $806 , 32
; // Enable the voice 1
lda #%10011111
sta $804
; // ---------------------------------------------
; // Processing for the next 32 bytes to send
; // ---------------------------------------------
; // If all samples are < 16ko
lda #32
clc
adc MODIFIE_TIN_VOIX1
sta MODIFIE_TIN_VOIX1
bcc .pas_add_high
inc MODIFIE_TIN_VOIX1 + 1
; // Else
;lda #32
;clc
;adc MODIFIE_TIN_VOIX1
;sta MODIFIE_TIN_VOIX1
;bcc .pas_add_high
;inc MODIFIE_TIN_VOIX1 + 1
;bpl .pas_add_high
; // Si changement de bank, on remape la nouvelle bank sur le mpr3
;lda #$60
;sta MODIFIE_TIN_VOIX1 + 1
;inc <sample_bank_voix1
.pas_add_high:
; // we decrement the number of remaining buffer fill
dec <taille_sample_voix1
bne Fin_Timer_Int
dec <taille_sample_voix1 + 1
bpl Fin_Timer_Int
stz <sample_voix1_on
stz $804
Fin_Timer_Int:
; // we restore the banks 3/4
; // We assume bank 4 is always bank 3 + 1
pla
tam #3
inc A
tam #4
; // We restauring REG A
pla
rti
I place the timer code in RAM because i use some self modifying code .
The channel is turned off for 209 cycles(the TIN duration), at 6992 htz you have 1024 cycles before the buffer start to process the next sample .
Maybe a little bit dirty, but not seems to work so bad for my use, i'll definitely go with that for my future games .
Of course you can do some optimisations, like using a ZP buffer rather than directly in ROM at the expense of CPU used for preparing data done after all the transferts.
i'll post a regular .pce rom soon for testing.
EDIT: Ok here is a standard PCE rom if someone want to test :
https://www.dropbox.com/s/q7zrmts9ov9e8ny/test_samples.pce?dl=0