Playing sound samples: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (add sound code category) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
Definitions of [[YM2610_registers#ADPCM-A part|ADPCM-A registers]]: | Definitions of [[YM2610_registers#ADPCM-A part|ADPCM-A registers]]: | ||
< | <syntaxhighlight lang="z80"> | ||
;ADPCM-A reg defines | ;ADPCM-A reg defines | ||
PA_CTRL: EQU $00 | PA_CTRL: EQU $00 | ||
Line 12: | Line 12: | ||
PA_ENDL: EQU $20 | PA_ENDL: EQU $20 | ||
PA_ENDH: EQU $28 | PA_ENDH: EQU $28 | ||
</ | </syntaxhighlight> | ||
(Full list of defines [[YM2610 ASM defines|here]]) | (Full list of defines [[YM2610 ASM defines|here]]) | ||
Example code to play back V ROM $000000-$00FFFF on CH1 with max volume. | Example code to play back V ROM $000000-$00FFFF on CH1 with max volume. | ||
< | <syntaxhighlight lang="z80"> | ||
;playback parameters | ;playback parameters | ||
CHMASK: equ $01 | CHMASK: equ $01 | ||
Line 41: | Line 41: | ||
rst $18 | rst $18 | ||
ret | ret | ||
</ | </syntaxhighlight> | ||
RST $18 writes D reg to port $06 and E reg to port $07. | RST $18 writes D reg to port $06 and E reg to port $07. | ||
Line 50: | Line 50: | ||
[[Category:Code]] | [[Category:Code]] | ||
[[Category:Sound Code]] |
Latest revision as of 04:49, 26 November 2015
ADPCM-A
Definitions of ADPCM-A registers:
;ADPCM-A reg defines
PA_CTRL: EQU $00
PA_MVOL: EQU $01
PA_CVOL: EQU $08
PA_STARTL: EQU $10
PA_STARTH: EQU $18
PA_ENDL: EQU $20
PA_ENDH: EQU $28
(Full list of defines here)
Example code to play back V ROM $000000-$00FFFF on CH1 with max volume.
;playback parameters
CHMASK: equ $01
MVOL: equ $3F
CVOL: equ $C0+$1F
START: equ $0000
END: equ $00FF
PlayADPCMA:
ld de,PA_MVOL<<8 +MVOL ;master volume
rst $18
ld de,PA_CVOL<<8 +CVOL ;left/right/channel volume
rst $18
ld de,PA_STARTL<<8 +START AND $FF ;start address low
rst $18
ld de,PA_STARTH<<8 +START / $100 ;start address high
rst $18
ld de,PA_ENDL<<8 +END AND $FF ;end address low
rst $18
ld de,PA_ENDH<<8 +END / $100 ;end address high
rst $18
ld de,PA_CTRL<<8 +CHMASK ;play this channel
rst $18
ret
RST $18 writes D reg to port $06 and E reg to port $07.
ADPCM-A demo
An interactive demo with source files can be found here.