mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 14:45:41 +12:00
[PICA] Implement madi
This commit is contained in:
parent
672e782990
commit
26cce7c58f
2 changed files with 30 additions and 2 deletions
|
@ -103,6 +103,7 @@ class PICAShader {
|
|||
void jmpu(u32 instruction);
|
||||
void loop(u32 instruction);
|
||||
void mad(u32 instruction);
|
||||
void madi(u32 instruction);
|
||||
void max(u32 instruction);
|
||||
void min(u32 instruction);
|
||||
void mov(u32 instruction);
|
||||
|
|
|
@ -37,6 +37,10 @@ void PICAShader::run() {
|
|||
case ShaderOpcodes::RCP: rcp(instruction); break;
|
||||
case ShaderOpcodes::RSQ: rsq(instruction); break;
|
||||
|
||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
|
||||
madi(instruction);
|
||||
break;
|
||||
|
||||
case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F:
|
||||
mad(instruction);
|
||||
break;
|
||||
|
@ -158,12 +162,12 @@ void PICAShader::add(u32 instruction) {
|
|||
|
||||
void PICAShader::mul(u32 instruction) {
|
||||
const u32 operandDescriptor = operandDescriptors[instruction & 0x7f];
|
||||
const u32 src1 = (instruction >> 12) & 0x7f;
|
||||
u32 src1 = (instruction >> 12) & 0x7f;
|
||||
const u32 src2 = (instruction >> 7) & 0x1f; // src2 coming first because PICA moment
|
||||
const u32 idx = (instruction >> 19) & 3;
|
||||
const u32 dest = (instruction >> 21) & 0x1f;
|
||||
|
||||
if (idx) Helpers::panic("[PICA] MUL: idx != 0");
|
||||
src1 = getIndexedSource(src1, idx);
|
||||
vec4f srcVec1 = getSourceSwizzled<1>(src1, operandDescriptor);
|
||||
vec4f srcVec2 = getSourceSwizzled<2>(src2, operandDescriptor);
|
||||
|
||||
|
@ -379,6 +383,29 @@ void PICAShader::mad(u32 instruction) {
|
|||
}
|
||||
}
|
||||
|
||||
void PICAShader::madi(u32 instruction) {
|
||||
const u32 operandDescriptor = operandDescriptors[instruction & 0x1f];
|
||||
const u32 src1 = (instruction >> 17) & 0x1f;
|
||||
const u32 src2 = (instruction >> 12) & 0x1f;
|
||||
u32 src3 = (instruction >> 5) & 0x7f;
|
||||
const u32 idx = (instruction >> 22) & 3;
|
||||
const u32 dest = (instruction >> 24) & 0x1f;
|
||||
|
||||
src3 = getIndexedSource(src3, idx);
|
||||
|
||||
auto srcVec1 = getSourceSwizzled<1>(src1, operandDescriptor);
|
||||
auto srcVec2 = getSourceSwizzled<2>(src2, operandDescriptor);
|
||||
auto srcVec3 = getSourceSwizzled<3>(src3, operandDescriptor);
|
||||
auto& destVector = getDest(dest);
|
||||
|
||||
u32 componentMask = operandDescriptor & 0xf;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (componentMask & (1 << i)) {
|
||||
destVector[3 - i] = srcVec1[3 - i] * srcVec2[3 - i] + srcVec3[3 - i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PICAShader::cmp(u32 instruction) {
|
||||
const u32 operandDescriptor = operandDescriptors[instruction & 0x7f];
|
||||
const u32 src1 = (instruction >> 12) & 0x7f;
|
||||
|
|
Loading…
Add table
Reference in a new issue