This repository was archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsif.cpp
More file actions
68 lines (58 loc) · 1.33 KB
/
Copy pathsif.cpp
File metadata and controls
68 lines (58 loc) · 1.33 KB
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
#include <sif.hpp>
#include <stdio.h>
#include <Bus.hpp>
constexpr const char* REGS[] =
{
"SIF_MSCOM", "SIF_SMCOM", "SIF_MSFLG",
"SIF_SMFLG", "SIF_CTRL", "", "SIF_BD6"
};
constexpr const char* COMP[] =
{
"IOP", "EE"
};
SIF::SIF(Bus* bus)
: bus(bus)
{}
uint32_t SIF::read(uint32_t addr)
{
auto comp = (addr >> 9) & 0x1;
uint16_t offset = (addr >> 4) & 0xF;
auto ptr = (uint32_t*)®s + offset;
//printf("[SIF][%s]: Read 0x%08X from %s\n", COMP[comp], *ptr, REGS[offset]);
return *ptr;
}
void SIF::write(uint32_t addr, uint32_t data)
{
auto comp = (addr >> 9) & 0x1;
uint16_t offset = (addr >> 4) & 0xF;
auto ptr = (uint32_t*)®s + offset;
printf("[SIF][%s]: Writing 0x%08X to %s\n", COMP[comp], data, REGS[offset]);
if (offset == 4)
{
auto& control = regs.ctrl;
if (comp == 0)
{
uint8_t temp = data & 0xF0;
if (data & 0xA0)
{
control &= ~0xF000;
control |= 0x2000;
}
if (control & temp)
control &= ~temp;
else
control |= temp;
}
else
{
if (!(data & 0x100))
control &= ~0x100;
else
control |= 0x100;
}
}
else
{
*ptr = data;
}
}