forked from samkusin/clemens_iigs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clem_scc.c
49 lines (43 loc) · 1.43 KB
/
clem_scc.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
#include "clem_debug.h"
#include "clem_device.h"
#include "clem_mmio_defs.h"
#include "clem_mmio_types.h"
#define CLEM_SCC_STATE_REGISTER_WAIT 0
#define CLEM_SCC_STATE_REGISTER_SELECTED 1
void clem_scc_reset(struct ClemensDeviceSCC *scc) {}
void clem_scc_glu_sync(struct ClemensDeviceSCC *scc, struct ClemensClock *clock) {
scc->ts_last_frame = clock->ts;
}
void clem_scc_write_switch(struct ClemensDeviceSCC *scc, uint8_t ioreg, uint8_t value) {
switch (ioreg) {
case CLEM_MMIO_REG_SCC_B_CMD:
case CLEM_MMIO_REG_SCC_A_CMD:
break;
case CLEM_MMIO_REG_SCC_B_DATA:
case CLEM_MMIO_REG_SCC_A_DATA:
if (scc->state == CLEM_SCC_STATE_REGISTER_WAIT) {
scc->selected_reg[CLEM_MMIO_REG_SCC_A_DATA - ioreg] = value;
scc->state = CLEM_SCC_STATE_REGISTER_SELECTED;
} else {
scc->state = CLEM_SCC_STATE_REGISTER_WAIT;
}
break;
}
// CLEM_LOG("clem_scc: %02X <- %02X", ioreg, value);
}
uint8_t clem_scc_read_switch(struct ClemensDeviceSCC *scc, uint8_t ioreg, uint8_t flags) {
uint8_t value = 0;
bool is_noop = (flags & CLEM_OP_IO_NO_OP) != 0;
switch (ioreg) {
case CLEM_MMIO_REG_SCC_B_CMD:
case CLEM_MMIO_REG_SCC_A_CMD:
break;
case CLEM_MMIO_REG_SCC_B_DATA:
case CLEM_MMIO_REG_SCC_A_DATA:
break;
}
// if (!is_noop) {
// CLEM_LOG("clem_scc: %02X -> %02X", ioreg, value);
// }
return value;
}