KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
aica_comm.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 aica_comm.h
4 Copyright (C) 2000-2002 Megan Potter
5 Copyright (C) 2023 Ruslan Rostovtsev
6*/
7
8/** \file aica_comm.h
9 \brief Shared API for the SH4/AICA interface
10 \ingroup audio_aica
11
12 Structure and constant definitions for the SH-4/AICA interface. This file is
13 included from both the ARM and SH-4 sides of the fence.
14
15 \author Megan Potter
16 \author Ruslan Rostovtsev
17*/
18
19#ifndef __DC_SOUND_AICA_COMM_H
20#define __DC_SOUND_AICA_COMM_H
21
22#ifndef __ARCH_TYPES_H
23typedef unsigned long uint8;
24typedef unsigned long uint32;
25#endif
26
27/** \defgroup audio_aica AICA
28 \brief API defining the SH4/AICA shared interface
29 \ingroup audio_driver
30 @{
31*/
32
33/** \brief SH4-to-AICA command queue
34
35 Command queue; one of these for passing data from the SH-4 to the
36 AICA, and another for the other direction. If a command is written
37 to the queue and it is longer than the amount of space between the
38 head point and the queue size, the command will wrap around to
39 the beginning (i.e., queue commands _can_ be split up).
40*/
41typedef struct aica_queue {
42 uint32 head; /**< \brief Insertion point offset (in bytes) */
43 uint32 tail; /**< \brief Removal point offset (in bytes) */
44 uint32 size; /**< \brief Queue size (in bytes) */
45 uint32 valid; /**< \brief 1 if the queue structs are valid */
46 uint32 process_ok; /**< \brief 1 if it's ok to process the data */
47 uint32 data; /**< \brief Pointer to queue data buffer */
49
50/** \brief Command queue struct for commanding the AICA from the SH-4 */
51typedef struct aica_cmd {
52 uint32 size; /**< \brief Command data size in dwords */
53 uint32 cmd; /**< \brief Command ID */
54 uint32 timestamp; /**< \brief When to execute the command (0 == now) */
55 uint32 cmd_id; /**< \brief CmdID, for cmd/resp pairs, or chn id */
56 uint32 misc[4]; /**< \brief Misc Parameters / Padding */
57 uint8 cmd_data[]; /**< \brief Command data */
59
60/** \brief Maximum command size -- 256 dwords */
61#define AICA_CMD_MAX_SIZE 256
62
63/** \brief AICA command payload data for AICA_CMD_CHAN
64
65 This is the aica_cmd_t::cmd_data for AICA_CMD_CHAN.
66 Make this 16 dwords long for two aica bus queues.
67*/
68typedef struct aica_channel {
69 uint32 cmd; /**< \brief Command ID */
70 uint32 base; /**< \brief Sample base in RAM */
71 uint32 type; /**< \brief (8/16bit/ADPCM) */
72 uint32 length; /**< \brief Sample length */
73 uint32 loop; /**< \brief Sample looping */
74 uint32 loopstart; /**< \brief Sample loop start */
75 uint32 loopend; /**< \brief Sample loop end */
76 uint32 freq; /**< \brief Frequency */
77 uint32 vol; /**< \brief Volume 0-255 */
78 uint32 pan; /**< \brief Pan 0-255 */
79 uint32 pos; /**< \brief Sample playback pos */
80 uint32 pad[5]; /**< \brief Padding */
82
83/** \brief Macro for declaring an aica channel command
84
85 Declare an aica_cmd_t big enough to hold an aica_channel_t
86 using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR
87
88 \param T Buffer name
89 \param CMDR aica_cmd_t pointer name
90 \param CHANR aica_channel_t pointer name
91*/
92#define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
93 uint8 T[sizeof(aica_cmd_t) + sizeof(aica_channel_t)]; \
94 aica_cmd_t * CMDR = (aica_cmd_t *)T; \
95 aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
96
97/** \brief Size of an AICA channel command in words */
98#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
99
100/** \defgroup audio_aica_cmd Commands
101 \brief Values of commands for aica_cmd_t
102 @{
103*/
104#define AICA_CMD_NONE 0x00000000 /**< \brief No command (dummy packet) */
105#define AICA_CMD_PING 0x00000001 /**< \brief Check for signs of life */
106#define AICA_CMD_CHAN 0x00000002 /**< \brief Perform a wavetable action */
107#define AICA_CMD_SYNC_CLOCK 0x00000003 /**< \brief Reset the millisecond clock */
108/** @} */
109
110/** \defgroup audio_aica_resp Responses
111 \brief Values of responses to aica_cmd_t commands
112 @{
113 */
114#define AICA_RESP_NONE 0x00000000 /**< \brief No response */
115#define AICA_RESP_PONG 0x00000001 /**< \brief Response to CMD_PING */
116#define AICA_RESP_DBGPRINT 0x00000002 /**< \brief Payload is a C string */
117/** @} */
118
119/** \defgroup audio_aica_ch_cmd Channel Commands
120 \brief Command values (for aica_channel_t commands)
121 @{
122*/
123#define AICA_CH_CMD_MASK 0x0000000f /**< \brief Mask for commands */
124
125#define AICA_CH_CMD_NONE 0x00000000 /**< \brief No command */
126#define AICA_CH_CMD_START 0x00000001 /**< \brief Start command */
127#define AICA_CH_CMD_STOP 0x00000002 /**< \brief Stop command */
128#define AICA_CH_CMD_UPDATE 0x00000003 /**< \brief Update command */
129/** @} */
130
131/** \defgroup audio_aica_ch_start Channel Start Values
132 \brief Start values for AICA channels
133 @{
134*/
135#define AICA_CH_START_MASK 0x00300000 /**< \brief Mask for start values */
136
137#define AICA_CH_START_DELAY 0x00100000 /**< \brief Set params, but delay key-on */
138#define AICA_CH_START_SYNC 0x00200000 /**< \brief Set key-on for all selected channels */
139/** @} */
140
141/** \defgroup audio_aica_ch_update Channel Update Values
142 \brief Update values for AICA channels
143 @{
144*/
145#define AICA_CH_UPDATE_MASK 0x000ff000 /**< \brief Mask for update values */
146
147#define AICA_CH_UPDATE_SET_FREQ 0x00001000 /**< \brief frequency */
148#define AICA_CH_UPDATE_SET_VOL 0x00002000 /**< \brief volume*/
149#define AICA_CH_UPDATE_SET_PAN 0x00004000 /**< \brief panning */
150/** @} */
151
152/** \defgroup audio_aica_samples Sample Types
153 \brief Types of samples used by the AICA
154 @{
155*/
156#define AICA_SM_16BIT 0 /* Linear PCM 16-bit */
157#define AICA_SM_8BIT 1 /* Linear PCM 8-bit */
158#define AICA_SM_ADPCM 2 /* Yamaha ADPCM 4-bit */
159#define AICA_SM_ADPCM_LS 3 /* Long stream ADPCM 4-bit */
160/** @} */
161
162/** @} */
163
164#endif /* !__DC_SOUND_AICA_COMM_H */
unsigned long uint8
Definition aica_comm.h:23
unsigned long uint32
32-bit unsigned integer
Definition types.h:33
AICA command payload data for AICA_CMD_CHAN.
Definition aica_comm.h:68
uint32 vol
Volume 0-255.
Definition aica_comm.h:77
uint32 base
Sample base in RAM.
Definition aica_comm.h:70
uint32 length
Sample length.
Definition aica_comm.h:72
uint32 pan
Pan 0-255.
Definition aica_comm.h:78
uint32 type
(8/16bit/ADPCM)
Definition aica_comm.h:71
uint32 cmd
Command ID.
Definition aica_comm.h:69
uint32 freq
Frequency.
Definition aica_comm.h:76
uint32 loopstart
Sample loop start.
Definition aica_comm.h:74
uint32 loop
Sample looping.
Definition aica_comm.h:73
uint32 loopend
Sample loop end.
Definition aica_comm.h:75
uint32 pos
Sample playback pos.
Definition aica_comm.h:79
Command queue struct for commanding the AICA from the SH-4.
Definition aica_comm.h:51
uint32 cmd
Command ID.
Definition aica_comm.h:53
uint32 size
Command data size in dwords.
Definition aica_comm.h:52
uint32 timestamp
When to execute the command (0 == now)
Definition aica_comm.h:54
uint32 cmd_id
CmdID, for cmd/resp pairs, or chn id.
Definition aica_comm.h:55
SH4-to-AICA command queue.
Definition aica_comm.h:41
uint32 head
Insertion point offset (in bytes)
Definition aica_comm.h:42
uint32 process_ok
1 if it's ok to process the data
Definition aica_comm.h:46
uint32 valid
1 if the queue structs are valid
Definition aica_comm.h:45
uint32 tail
Removal point offset (in bytes)
Definition aica_comm.h:43
uint32 data
Pointer to queue data buffer.
Definition aica_comm.h:47
uint32 size
Queue size (in bytes)
Definition aica_comm.h:44