mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-22 15:02:54 -04:00
4df8ccc871
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
76 lines
1.6 KiB
C++
76 lines
1.6 KiB
C++
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
|
|
|
#include "JSystem/JHostIO/JHICommonMem.h"
|
|
#include "JSystem/JKernel/JKRHeap.h"
|
|
#ifdef __REVOLUTION_SDK__
|
|
#include <revolution.h>
|
|
#else
|
|
#include <dolphin.h>
|
|
#endif
|
|
|
|
int JHIMemBuf::create() {
|
|
int rt = 1;
|
|
if (mp_buffer == NULL) {
|
|
mp_buffer = new (32) u8[0x20000];
|
|
|
|
if (mp_buffer == NULL) {
|
|
rt = 0;
|
|
OS_REPORT("ERROR: hioSync Alloc Mem NG!\n");
|
|
} else {
|
|
OS_REPORT("INFO: hioSync Alloc Mem OK! %08x\n", mp_buffer);
|
|
}
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
|
|
int JHIMemBuf::open() {
|
|
return 1;
|
|
}
|
|
|
|
void JHIMemBuf::close() {
|
|
if (mp_buffer != NULL) {
|
|
delete[] mp_buffer;
|
|
}
|
|
}
|
|
|
|
JHIMemBuf::~JHIMemBuf() {
|
|
close();
|
|
}
|
|
|
|
u8* JHIMemBuf::getPointer() const {
|
|
return mp_buffer;
|
|
}
|
|
|
|
u32 JHIMemBuf::readIO(u32 position) const {
|
|
u32 data;
|
|
readIO(position, &data);
|
|
return data;
|
|
}
|
|
|
|
void JHIMemBuf::readIO(u32 position, u32* out_data) const {
|
|
u8* read_ptr = getPointer() + position;
|
|
*out_data = (read_ptr[0] << 0x18) |
|
|
(read_ptr[1] << 0x10) |
|
|
(read_ptr[2] << 0x08) |
|
|
(read_ptr[3] << 0x00);
|
|
}
|
|
|
|
void JHIMemBuf::writeIO(u32 position, u8* src_data, u32 length) const {
|
|
u8* write_ptr = getPointer() + position;
|
|
|
|
while (--length != 0) {
|
|
*write_ptr = *src_data++;
|
|
write_ptr++;
|
|
}
|
|
}
|
|
|
|
void JHIMemBuf::writeIO(u32 position, u32 data) const {
|
|
u8* write_ptr = getPointer() + position;
|
|
|
|
*write_ptr++ = data >> 0x18;
|
|
*write_ptr++ = data >> 0x10;
|
|
*write_ptr++ = data >> 0x08;
|
|
*write_ptr++ = data >> 0x00;
|
|
}
|