Skip to content

Commit d7c00cb

Browse files
committed
AICA MIDI out support
1 parent 97686ea commit d7c00cb

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* KallistiOS ##version##
2+
3+
dc/sound/midi.h
4+
Copyright (C) 2020 Thomas Sowell
5+
6+
*/
7+
8+
/** \file dc/sound/midi.h
9+
\brief MIDI support.
10+
11+
\author Thomas Sowell
12+
*/
13+
14+
#ifndef __DC_SOUND_MIDI_H
15+
#define __DC_SOUND_MIDI_H
16+
17+
#include <sys/cdefs.h>
18+
19+
__BEGIN_DECLS
20+
21+
void snd_midi(uint8 midi);
22+
23+
__END_DECLS
24+
25+
#endif /* __DC_SOUND_MIDI_H */

kernel/arch/dreamcast/sound/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# (c)2001 Dan Potter
55
#
66

7-
OBJS = snd_iface.o snd_sfxmgr.o snd_stream.o snd_stream_drv.o snd_mem.o
7+
OBJS = snd_iface.o snd_sfxmgr.o snd_stream.o snd_stream_drv.o snd_mem.o snd_midi.o
88

99
# Only compile this if we have an ARM compiler handy
1010
ifdef DC_ARM_CC

kernel/arch/dreamcast/sound/arm/aica_cmd_iface.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ typedef struct aica_channel {
6767
aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
6868
#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
6969

70+
#define AICA_CMDSTR_MIDI(T, CMDR, MIDIR) \
71+
uint8 T[sizeof(aica_cmd_t) + sizeof(uint32)]; \
72+
aica_cmd_t * CMDR = (aica_cmd_t *)T; \
73+
uint32 * MIDIR = (uint32 *)(CMDR->cmd_data);
74+
#define AICA_CMDSTR_MIDI_SIZE ((sizeof(aica_cmd_t) + sizeof(uint32))/4)
75+
7076
/* Command values (for aica_cmd_t) */
7177
#define AICA_CMD_NONE 0x00000000 /* No command (dummy packet) */
7278
#define AICA_CMD_PING 0x00000001 /* Check for signs of life */
7379
#define AICA_CMD_CHAN 0x00000002 /* Perform a wavetable action */
7480
#define AICA_CMD_SYNC_CLOCK 0x00000003 /* Reset the millisecond clock */
81+
#define AICA_CMD_MIDI 0x00000004
7582

7683
/* Response values (for aica_cmd_t) */
7784
#define AICA_RESP_NONE 0x00000000

kernel/arch/dreamcast/sound/arm/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ uint32 process_one(uint32 tail) {
127127
/* Reset our timer clock to zero */
128128
timer = 0;
129129
break;
130+
case AICA_CMD_MIDI:
131+
while ((SNDREG32(0x2808) & 0x1000) == 0x1000);
132+
SNDREG32(0x280C) = ((uint32 *)pkt->cmd_data)[0] & 0x000000FF;
133+
break;
130134
default:
131135
/* error */
132136
break;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <dc/sound/sound.h>
2+
#include <dc/sound/midi.h>
3+
4+
#include "arm/aica_cmd_iface.h"
5+
6+
void snd_midi(uint8 midi) {
7+
AICA_CMDSTR_MIDI(tmp, cmd, cmdmidi);
8+
9+
cmd->cmd = AICA_CMD_MIDI;
10+
cmd->timestamp = 0;
11+
cmd->size = AICA_CMDSTR_MIDI_SIZE;
12+
*cmdmidi = midi;
13+
snd_sh4_to_aica(tmp, cmd->size);
14+
}

0 commit comments

Comments
 (0)