-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmidi.c
98 lines (85 loc) · 1.7 KB
/
midi.c
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
/*
* MC6805 ACIA Connected to
*
* D0-D7 BUS:D0-D7
* E CPU:E
* R/W R/W
* CS0 GLUE:6850CS
* CS1 +5V
* CS2 BUS:A2
* RS BUS:A1
* IRQ MFP:I4
* TX CLK 0.5MHz
* RX CLK 0.5MHz
* TX DATA MIDI OUT
* RX DATA MIDI IN
* CTS GND
* RTS -
* DCD GND
*/
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mmu.h"
#include "state.h"
#include "diag.h"
#define MIDISIZE 4
#define MIDIBASE 0xfffc04
static BYTE midi_control;
static BYTE midi_status = 0x02; /* Always ready to receive */
static BYTE midi_data;
HANDLE_DIAGNOSTICS(midi)
static BYTE midi_read_byte(LONG addr)
{
switch(addr) {
case 0xfffc04:
return midi_status;
case 0xfffc06:
return midi_data;
default:
return 0;
}
}
static WORD midi_read_word(LONG addr)
{
return (midi_read_byte(addr)<<8)|midi_read_byte(addr+1);
}
static void midi_write_byte(LONG addr, BYTE data)
{
switch(addr) {
case 0xfffc04:
midi_control = data;
break;
case 0xfffc06:
midi_data = data;
break;
}
}
static void midi_write_word(LONG addr, WORD data)
{
midi_write_byte(addr, (data&0xff00)>>8);
midi_write_byte(addr+1, (data&0xff));
}
static int midi_state_collect(struct mmu_state *state)
{
state->size = 0;
return STATE_VALID;
}
static void midi_state_restore(struct mmu_state *state)
{
}
void midi_init()
{
struct mmu *midi;
midi = mmu_create("MIDI", "MIDI");
midi->start = MIDIBASE;
midi->size = MIDISIZE;
midi->read_byte = midi_read_byte;
midi->read_word = midi_read_word;
midi->write_byte = midi_write_byte;
midi->write_word = midi_write_word;
midi->state_collect = midi_state_collect;
midi->state_restore = midi_state_restore;
midi->diagnostics = midi_diagnostics;
mmu_register(midi);
}