1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
=============================================================================
*** How to use ***
You need to take "src-68k/echo.68k" and include it in your program. Then you
need to take "built/prog-z80.bin" (or if you built Echo from source, the
generated binary). Finally, go to the echo.68k file, look for @Z80Program
(should be near the end of the file) and change the filename to point where
the prog-z80.bin file is.
Echo should now be inside your program. Now call Echo_Init (see below) to
initialize Echo and load the instrument list, and then you can proceed to use
Echo as needed (e.g. call Echo_PlayBGM to start playing music).
Unless stated otherwise, calling the API subroutines will *not* modify the
68000 registers.
=============================================================================
*** Initialization ***
Echo_Init
in a0 = pointer to instrument list
Initializes Echo. Loads the instrument list, loads the Z80 engine and gets
it running. You need to call this before you can use Echo (usually when
the program is just starting).
The address of the instrument list is given in register a0. The instrument
list can be built using the Echo_List* macros. An example of a short
instrument list is as follows:
Echo_ListEntry instrument1
Echo_ListEntry instrument2
Echo_ListEntry instrument3
Echo_ListEnd
Where the parameter for Echo_ListEntry is the address (e.g. a label) to
the EIF/EEF/EWF data of the instrument.
=============================================================================
*** Background music ***
Echo_PlayBGM
in a0 = pointer to ESF data to play
Starts playback of the specified background music. The register a0 points
to the ESF data for the background music.
Echo_StopBGM
Stops playback of background music. Used both to stop and to pause music.
Echo_PauseBGM
Pauses BGM playback (SFXs should be unaffected).
Echo_ResumeBGM
Resumes BGM playback after it has been paused with Echo_PauseBGM.
=============================================================================
*** Sound effects ***
Echo_PlaySFX
in a0 = pointer to ESF data to play
Starts playback of the specified sound effect. The register a0 points to
the ESF data for the sound effect.
Echo_StopSFX
Stops playback of sound effects.
=============================================================================
*** Direct events ***
Echo_PlayDirect
in a0 = pointer to ESF data to inject
Injects events to be played as part of the BGM the next tick. The register
a0 points to the ESF data to be injected.
The injected events are a small stream on their own. The last event must
be $FF (this will return back to the BGM). Do *not* issue $FC, $FD or $FE
events, as you'll just break everything instead.
The buffer is small, so don't go overboard. There's room for up to 128
bytes (though again, each event is just 2-3 bytes). If there were direct
events pending to play, the new events will be appended at the end, so
take this into account when it comes to the buffer usage. You can check
if there are pending events with Echo_GetStatus (see bit 14) if you're
worried about running out of space.
The buffer is only checked every tick.
=============================================================================
*** Control ***
Echo_GetStatus
out d0 = status (see below)
Gets the current status of Echo. The status is returned as a word in d0,
with the following bits set as relevant:
Bit 0 .... Sound effect is playing
Bit 1 .... Background music is playing
Bit 14 ... Echo isn't done parsing direct events
Bit 15 ... Echo is busy (can't take commands)
The API will automatically wait if you try to send a command while Echo is
busy, so the only reason to check for that is if you don't want to halt
the 68000 until Echo is ready to take more commands.
Echo_SetVolume
in d0 = new volume ($00 = quietest, $FF = loudest)
Sets the global volume. Register d0 is a byte value ranging from 0
(quietest) to 255 (loudest), and every channel is affected immediately.
The scale of the volume in this case is *linear*.
Note that since PCM doesn't have volume, it gets toggled on/off depending
on the volume value (the cut off point is at 25%).
Echo_SetVolumeEx
in a0 = pointer to volume data (see below)
Sets the global volume for each channel separately. Register a0 points to
a list of 16 bytes (one for each Echo channel). Values for FM and PSG
channels are given in the same way as in events, that is: logarithmic
scale, 0..127 for FM, 0..15 for PSG, lower = louder.
The last byte (the one belonging to the PCM channel) is used to toggle
whether PCM plays, either 0 (disabled) or 1 (enabled).
NOTE: the Echo 1.4 docs requested for 13 bytes instead of 16. This has
been changed for the sake of expansion. Currently the extra bytes are
ignored, but consider adapting your code (just set them to zero).
=============================================================================
*** Settings ***
Echo_SetPCMRate
in d0 = new PCM rate (see below)
Changes the sample rate of PCM. Note this is a global parameter as it
affects both BGM and SFX. The value is what one would write in timer A of
the YM2612 register. Here are the approximate frequencies for some values
(default is $04):
NTSC PAL | NTSC PAL
----------------------------|--------------------------
$01 ... 26632Hz ... 26389Hz | $07 ... 6658Hz ... 6597Hz
$02 ... 17755Hz ... 17593Hz | $08 ... 5918Hz ... 5864Hz
$03 ... 13316Hz ... 13194Hz | $09 ... 5326Hz ... 5278Hz
$04 ... 10653Hz ... 10556Hz | $0A ... 4842Hz ... 4798Hz
$05 .... 8877Hz .... 8796Hz | $0B ... 4439Hz ... 4398Hz
$06 .... 7609Hz .... 7539Hz | $0C ... 4097Hz ... 4060Hz
The higher the sample rate, the better quality, but also takes up more
space and, more importantly, reduces CPU time available for other things
(which can hamper Echo's ability to process complex streams). Be careful
if you increase the sample rate.
=============================================================================
*** Raw access ***
Echo_SendCommand
in d0 = command
Sends an argument-less command to Echo. The command ID is given as a byte
in register d0.
Echo_SendCommandAddr
in d0 = command
in a0 = address
Sends a command to Echo that takes an address as its argument. The command
ID is given as a byte in register d0, while the address argument is given
in register a0.
Echo_SendCommandByte
in d0 = command
in d1 = argument
Sends a command to Echo that takes a byte as its argument. The command ID
is given as a byte in register d0, while the byte argument is given in
register d1.
=============================================================================
|