-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeEndianMemory.cpp
More file actions
66 lines (41 loc) · 1.14 KB
/
Copy pathNativeEndianMemory.cpp
File metadata and controls
66 lines (41 loc) · 1.14 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
//
// NativeEndianMemory.cpp
// SDL3Test
//
// Created by Matt Parsons on 19/03/2026.
//
#include "NativeEndianMemory.hpp"
uint32_t NativeGate::Read8(uint32_t address){
address -= base;
address &= mask;
return data[address];
}
uint32_t NativeGate::Read16(uint32_t address){
address -= base;
address &= mask;
uint16_t* p = (uint16_t*)&data[address];
return __builtin_bswap16(*p);
}
uint32_t NativeGate::Read32(uint32_t address){
address -= base;
address &= mask;
uint32_t* p = (uint32_t*)&data[address];
return __builtin_bswap32(*p);
}
void NativeGate::Write8(uint32_t address, uint32_t value){
address -= base;
address &= mask;
data[address] = value;
}
void NativeGate::Write16(uint32_t address, uint32_t value){
address -= base;
address &= mask;
uint16_t* p = (uint16_t*)&data[address];
*p = __builtin_bswap16(value);
}
void NativeGate::Write32(uint32_t address, uint32_t value){
address -= base;
address &= mask;
uint32_t* p = (uint32_t*)&data[address];
*p = __builtin_bswap32(value);
}