Mensaje original de RobsyHello everyone! I hope that you will enjoy this one: real sample replayer for MSX, using the keyboard "click" system. It can replay both 11 or 22 KHz WAV files converted from 8-bit to 1-bit.
In order to convert the sample and to view a full example working, download this
http://www.robsy.net/sample.zipRegards!
;--------------------------------------------------------------------
PLAY_SAMPLE:
;--------------------------------------------------------------------
; Plays a 22,050 or 11,025 Hz 1-bit sample using keyboard click
;--------------------------------------------------------------------
; Parameters: HL=sample data pointer
; BC=sample length in bytes
;--------------------------------------------------------------------
; Modifies: AF,BC,DE,HL,DI
;--------------------------------------------------------------------
; Disable interrupts
di
; Main loop
@@LOOP:
; Set bit counter
ld d,8 ; 8
; Check if finished
dec bc ; 7
ld a,b ; 5
or c ; 5
ret z ; 6 (FALSE)
; Read byte
ld a,[hl] ; 8
inc hl ; 7
@@COPY:
; Extract bit
rlca ; 5
ld e,a ; 5
; Convert to PPI format
ld a,0FFh ; 8
rra ; 5
; Output to PPI
out [0AAh],a ;12
ld a,e ; 5
; Delay - NOPs to sync time
db 0,0,0,0,0,0,0,0,0,0,0,0 ;12*5=60
; Extra delay: uncomment following lines to play 11,025 Hz samples
; db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; Check if byte completed
dec d ; 5
jr z,@@LOOP ;13 (TRUE) / 8 (FALSE)
; Balancing delay - additional NOPs
db 0,0,0,0,0,0,0,0 ; 8*5=40
; Continue
jr @@COPY ; 9
;--------------------------------------------------------------------
; Short loop: 162 T-states
; Long loop: 164 T-states
; Perfect 22,050 Hz: 162.5 T-states (for 3.54 MHz Z80)
;--------------------------------------------------------------------