Play recorded sounds: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 15: | Line 15: | ||
Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash"). |
Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash"). |
||
=={{header|68000 Assembly}}== |
|||
{{works with|Sega Genesis}} |
|||
This snippet of code will stream an unsigned 8-bit PCM sample to the Yamaha 2612's DAC. Unfortunately, the data needs to be continuously streamed, meaning that the game essentially comes to a halt while this is happening. However, a clever game designer can hide this fact quite easily by only using voice samples at key moments where the player expects a brief pause in the action. |
|||
<lang 68000devpac>dac_data equ $2A |
|||
dac_enable equ $2B |
|||
Test_DAC: |
|||
LEA pcmSample,a1 |
|||
MOVE.B #dac_enable,D0 |
|||
MOVE.B #$80,D1 |
|||
JSR FMRegWrite |
|||
SUBQ.B #1,d0 ;move.b #dac_data,D0 |
|||
.dac_loop: |
|||
MOVE.B (a1)+,d1 ;read the next byte from the stream. |
|||
BEQ .dac_done ;exit on null terminator |
|||
JSR FMRegWrite |
|||
BRA .dac_loop |
|||
.dac_done: |
|||
RTS |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
FMRegWrite: |
|||
MOVE.L A0,-(SP) |
|||
;IN: D0.B, D1.B |
|||
MOVEA.L #$A04000,A0 ;$A04000 = register selector, $A04001 = data to write. |
|||
.wait1: |
|||
BTST #7,(A0) ;read the YM2612's busy state from $A04000. Bit 7 equals 1 if busy |
|||
BNE .wait1 ;loop until not busy |
|||
MOVE.B D0,(A0) ;select the register ID held in D0.B and write it to $A04000. |
|||
.wait2: |
|||
BTST #7,(A0) ;read the YM2612's busy state from $A04000. Bit 7 equals 1 if busy |
|||
BNE .wait2 ;loop until not busy |
|||
MOVE.B D1,(1,A0) ;write the data for the selected register into $A04001. |
|||
MOVE.L (SP)+,A0 |
|||
rts |
|||
pcmSample: |
|||
incbin "X:\ResAll\pcmSample.bin"</lang> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |