forked from p1pkin/demul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cache.c
121 lines (103 loc) · 2.99 KB
/
Cache.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Demul
* Copyright (C) 2006 Demul Team
*
* Demul is not free software: you can't redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Demul isn't distributed in the hope that it will be useful,
* and WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "cache.h"
#include "onchip.h"
void FASTCALL WriteSQ32(u32 mem, u32 value) {
SQ0[(mem >> 2) & 15] = value;
}
void FASTCALL WriteSQ64(u32 mem, u64 *value) {
*(u64*)&SQ0[(mem >> 2) & 14] = *value;
}
u8 FASTCALL ReadCacheRam8(u32 mem) {
u32 value = 0;
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
value = *(u8*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)];
} else {
value = *(u8*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)];
}
}
return value;
}
u16 FASTCALL ReadCacheRam16(u32 mem) {
u32 value = 0;
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
value = *(u16*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)];
} else {
value = *(u16*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)];
}
}
return value;
}
u32 FASTCALL ReadCacheRam32(u32 mem) {
u32 value = 0;
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
value = *(u32*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)];
} else {
value = *(u32*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)];
}
}
return value;
}
void FASTCALL ReadCacheRam64(u32 mem, u64 *out) {
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
*out = *(u64*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)];
return;
} else {
*out = *(u64*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)];
return;
}
}
*out = 0;
}
void FASTCALL WriteCacheRam8(u32 mem, u8 value) {
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
*(u8*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)] = value;
} else {
*(u8*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)] = value;
}
}
}
void FASTCALL WriteCacheRam16(u32 mem, u16 value) {
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
*(u16*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)] = value;
} else {
*(u16*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)] = value;
}
}
}
void FASTCALL WriteCacheRam32(u32 mem, u32 value) {
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
*(u32*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)] = value;
} else {
*(u32*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)] = value;
}
}
}
void FASTCALL WriteCacheRam64(u32 mem, u64 *value) {
if (pOnChip[0x001c] & 0x20) {
if (pOnChip[0x001c] & 0x80) {
*(u64*)&pCram[((mem >> 13) & 0x1000) + (mem & 0x0fff)] = *value;
} else {
*(u64*)&pCram[((mem >> 1) & 0x1000) + (mem & 0x0fff)] = *value;
}
}
}