blob: 57069325dd20615d729e3eb065dd61b0e1eda0d5 (
plain)
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
|
#pragma once
uint16_t* BUS_REGISTER_BASE = (uint16_t*)0xDEADBEEF;
typedef struct
{
uint16_t action;
uint16_t reg;
uint8_t input;
uint8_t output
} BusDevice;
BusDevice* BUS = (BusDevice*)BUS_REGISTER_BASE;
bool bus_read_write( uint8_t dev, uint8_t registry, uint8_t* buffer, int len, bool assume_echo )
{
// Something that we dont want to run, since the emulation would be hard.
BUS->action = 0x01;
BUS->reg = registry;
for ( int loop =0 ; loop < len; loop ++ )
{
char output = buffer[loop];
BUS->output = output;
buffer[loop] = BUS->input;
if ( ( assume_echo ) && ( buffer[loop] != output ) )
return false;
}
return true;
}
|