WiiUPluginLoaderBackend/source/utils/dc.h

36 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-05-10 16:36:47 +02:00
#pragma once
#include <coreinit/debug.h>
#include <coreinit/screen.h>
extern "C" uint32_t __OSPhysicalToEffectiveUncached(uint32_t);
2024-11-27 20:44:36 +01:00
static uint32_t DCReadReg32(const OSScreenID screen, const uint32_t index) {
2024-05-10 16:36:47 +02:00
if (OSIsECOMode()) {
return 0;
}
2024-11-27 20:44:36 +01:00
const auto regs = reinterpret_cast<uint32_t *>(__OSPhysicalToEffectiveUncached(0xc200000));
2024-05-10 16:36:47 +02:00
return regs[index + (screen * 0x200)];
}
2024-11-27 20:44:36 +01:00
static void DCWriteReg32(const OSScreenID screen, const uint32_t index, const uint32_t val) {
2024-05-10 16:36:47 +02:00
if (OSIsECOMode()) {
return;
}
2024-11-27 20:44:36 +01:00
const auto regs = reinterpret_cast<uint32_t *>(__OSPhysicalToEffectiveUncached(0xc200000));
2024-05-10 16:36:47 +02:00
regs[index + (screen * 0x200)] = val;
}
// https://www.x.org/docs/AMD/old/42589_rv630_rrg_1.01o.pdf (reg id in document / 4)
#define D1GRPH_ENABLE_REG 0x1840
#define D1GRPH_CONTROL_REG 0x1841
#define D1GRPH_PITCH_REG 0x1848
#define D1OVL_PITCH_REG 0x1866
#define D1GRPH_X_END_REG 0x184d
#define D1GRPH_Y_END_REG 0x184e
2024-11-27 20:44:36 +01:00
static void SetDCPitchReg(const OSScreenID screen, const uint16_t pitch) {
2024-05-10 16:36:47 +02:00
DCWriteReg32(screen, D1GRPH_PITCH_REG, pitch);
DCWriteReg32(screen, D1OVL_PITCH_REG, pitch);
}