mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-28 07:54:51 -04:00
15732e241c
* Undo array allocation changes from #43 Doesn't work * Expand dmeter heap sizes, give names * Fix manual operator delete call in resource.cpp * Disable map rendering for now Aurora can't handle lines * Re-enable assert heap on DVD thread Should be fine? * Some basic debug groups with the new Aurora API * Allow Aurora backend to be set via CLI * Give materials debug groups * More debug groups * JKRHeap separation: array edition Pain
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 = JKR_NEW_ARRAY_ARGS(u8, 0x20000, 32);
|
|
|
|
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) {
|
|
JKR_DELETE_ARRAY(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;
|
|
}
|