[GPU] Get PICA register access working

This commit is contained in:
wheremyfoodat 2022-09-21 19:10:53 +03:00
parent 09000da701
commit 71ca62e2cc
5 changed files with 113 additions and 10 deletions

View file

@ -2,7 +2,8 @@
#include <cstdio>
void GPU::reset() {
regs.fill(0);
// TODO: Reset blending, texturing, etc here
}
void GPU::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {

40
src/core/PICA/regs.cpp Normal file
View file

@ -0,0 +1,40 @@
#include "gpu.hpp"
u32 GPU::readReg(u32 address) {
printf("Ignoring read from GPU register %08X\n", address);
return 0;
}
void GPU::writeReg(u32 address, u32 value) {
if (address >= 0x1EF01000 && address < 0x1EF01C00) { // Internal registers
const u32 index = (address - 0x1EF01000) / sizeof(u32);
writeInternalReg(index, value, 0xffffffff);
} else {
Helpers::panic("Ignoring write to GPU register %08X. Value: %08X\n", address, value);
}
}
u32 GPU::readInternalReg(u32 index) {
if (index > regNum) {
printf("Tried to read invalid GPU register. Index: %X\n", index);
return 0;
}
return regs[index];
}
void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
if (index > regNum) {
Helpers::panic("Tried to write to invalid GPU register. Index: %X, value: %08X\n", index, value);
return;
}
u32 currentValue = regs[index];
u32 newValue = (currentValue & ~mask) | (value & mask); // Only overwrite the bits specified by "mask"
switch (index) {
default:
printf("GPU: Wrote to unimplemented internal reg: %X, value: %08X\n", index, newValue);
break;
}
}