1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Command 05 - 02 WIP

This commit is contained in:
Sergey Lipskiy 2017-04-28 18:56:53 +07:00
parent f0bbfbc84e
commit 02e84b90f2
4 changed files with 61 additions and 11 deletions

View File

@ -3,6 +3,7 @@
* Incomplete!
*/
#include <array>
#include "GLideN64.h"
#include "DebugDump.h"
#include "F3D.h"
@ -57,7 +58,14 @@ void F3DSWRS_MoveMem(u32 _w0, u32)
void F3DSWRS_Vtx(u32 _w0, u32 _w1)
{
gSPSWVertex( _w1, _SHIFTR( _w0, 10, 6 ), 0 );
const u32 address = RSP_SegmentToPhysical(_w1);
const u32 n = _SHIFTR(_w0, 10, 6);
if ((address + sizeof(SWVertex)* n) > RDRAMSize)
return;
const SWVertex * vertex = (const SWVertex*)&RDRAM[address];
gSPSWVertex(vertex, n, 0 );
}
void F3DSWRS_Jump2(u32, u32)
@ -67,8 +75,57 @@ void F3DSWRS_Jump2(u32, u32)
RSP.swDL[RSP.PCi].SWOtherDL = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4], 0, 24);
}
static
void Jump3_2(u32 * _result) {
typedef std::array<s16, 4> Vector;
u32 params[10];
for (u32 i = 1; i < 10; ++i)
params[i] = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + i * 4];
Vector v0{ 0, 0, 0, 0 };
Vector v1{ 0, 0, 0, 0 };
Vector v2{ 0, 0, 0, 0 };
Vector v3{ 0, 0, 0, 0 };
s16 V0 = _SHIFTR(params[9], 0, 16);
s16 V1 = _SHIFTR(params[8], 0, 16);
V1 <<= 4;
v0[0] = _SHIFTR(params[8], 16, 16);
v0[1] = V1;
v0[2] = _SHIFTR(params[9], 16, 16);
v2[0] = V0;
v3[2] = V0;
v1[1] = _SHIFTR(params[2], 16, 16);
_result[0] = ((v0[0] + v1[0]) << 16) | (v0[1] + v1[1]);
_result[1] = ((v0[2] + v1[2]) << 16) | (v0[3] + v1[3]);
v1 = v2;
v1[1] = _SHIFTR(params[2], 0, 16);
_result[2] = ((v0[0] + v1[0]) << 16) | (v0[1] + v1[1]);
_result[3] = ((v0[2] + v1[2]) << 16) | (v0[3] + v1[3]);
v1 = v3;
v1[1] = _SHIFTR(params[1], 16, 16);
_result[4] = ((v0[0] + v1[0]) << 16) | (v0[1] + v1[1]);
_result[5] = ((v0[2] + v1[2]) << 16) | (v0[3] + v1[3]);
for (u32 i = 0; i < 4; ++i)
v1[i] = v2[i] + v3[i];
v1[1] = _SHIFTR(params[1], 0, 16);
_result[6] = ((v0[0] + v1[0]) << 16) | (v0[1] + v1[1]);
_result[7] = ((v0[2] + v1[2]) << 16) | (v0[3] + v1[3]);
}
void F3DSWRS_Jump3(u32 _w0, u32 _w1)
{
const u32 mode = _SHIFTR(_w0, 8, 8);
switch (mode) {
case 0x02: {
u32 vecdata[8];
Jump3_2(vecdata);
const SWVertex * vertex = (const SWVertex*)&vecdata[0];
gSPSWVertex(vertex, 4, 0);
}
break;
default:
break;
}
RSP.PC[RSP.PCi] = RSP.swDL[RSP.PCi].SWOtherDL;
RSP.swDL[RSP.PCi].SWStartDL = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi]], 0, 24);
RSP.swDL[RSP.PCi].SWOtherDL = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4], 0, 24);

View File

@ -15,7 +15,7 @@ typedef struct
struct {
u32 SWStartDL;
u32 SWOtherDL;
} swDL[18];
} swDL[10];
} RSPInfo;
extern RSPInfo RSP;

View File

@ -1440,15 +1440,8 @@ void gSPF3DAMVertex(u32 a, u32 n, u32 v0)
}
}
void gSPSWVertex(u32 a, u32 n, u32 v0)
void gSPSWVertex(const SWVertex * vertex, u32 n, u32 v0)
{
u32 address = RSP_SegmentToPhysical(a);
if ((address + sizeof(SWVertex)* n) > RDRAMSize)
return;
SWVertex *vertex = (SWVertex*)&RDRAM[address];
GraphicsDrawer & drawer = dwnd().getDrawer();
if ((n + v0) <= INDEXMAP_SIZE) {
unsigned int i = v0;

View File

@ -160,7 +160,7 @@ void gSPDMAVertex( u32 v, u32 n, u32 v0 );
void gSPCBFDVertex( u32 v, u32 n, u32 v0 );
void gSPT3DUXVertex(u32 v, u32 n, u32 ci);
void gSPF3DAMVertex( u32 v, u32 n, u32 v0 );
void gSPSWVertex(u32 a, u32 n, u32 v0);
void gSPSWVertex(const SWVertex * vertex, u32 n, u32 v0);
void gSPDisplayList(u32 dl);
void gSPSWDisplayList(u32 dl);
void gSPBranchList( u32 dl );