1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-27 23:14:05 +00:00

native port

This commit is contained in:
Blake Warner 2022-01-16 12:27:17 -05:00
parent df2d4debbb
commit 0255e10db6
86 changed files with 1991 additions and 1211 deletions

View File

@ -61,7 +61,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
@ -78,7 +78,7 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)..\..\..\external\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug_qt' Or '$(Configuration)'=='Debug_wtl' Or'$(Configuration)'=='Debug_mupenplus'">
@ -117,7 +117,7 @@
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -149,7 +149,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32_ASM;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
@ -195,7 +195,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug_qt' Or '$(Configuration)'=='Debug_wtl' Or '$(Configuration)'=='Release_qt' Or '$(Configuration)'=='Release_wtl'">
<ClCompile>
<PreprocessorDefinitions>GL_USE_UNIFORMBLOCK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NATIVE;GL_USE_UNIFORMBLOCK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>ZILMAR_API;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -217,7 +217,7 @@ copy /Y "$(OutDir)$(TargetName).*" "$(PJ64PluginsDirWTL_x64)")</Command>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">
<ClCompile>
<PreprocessorDefinitions>MUPENPLUSAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MUPENPLUSAPI;NATIVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<PostBuildEvent>
<Message>Copy result to plugins folder</Message>
@ -355,6 +355,7 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
<ClCompile Include="..\..\src\Log.cpp" />
<ClCompile Include="..\..\src\MupenPlusPluginAPI.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_qt' Or '$(Configuration)'=='Debug_wtl' Or '$(Configuration)'=='Release_qt' Or '$(Configuration)'=='Release_wtl'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\mupenplus\CommonAPIImpl_mupenplus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_qt' Or '$(Configuration)'=='Debug_wtl' Or '$(Configuration)'=='Release_qt' Or '$(Configuration)'=='Release_wtl'">true</ExcludedFromBuild>
@ -369,6 +370,7 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_qt' Or '$(Configuration)'=='Debug_wtl' Or '$(Configuration)'=='Release_qt' Or '$(Configuration)'=='Release_wtl'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\N64.cpp" />
<ClCompile Include="..\..\src\Native.cpp" />
<ClCompile Include="..\..\src\NoiseTexture.cpp" />
<ClCompile Include="..\..\src\PaletteTexture.cpp" />
<ClCompile Include="..\..\src\Performance.cpp" />
@ -378,9 +380,13 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
<ClCompile Include="..\..\src\RSP.cpp" />
<ClCompile Include="..\..\src\RSP_LoadMatrix.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_wtl|Win32'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\RSP_LoadMatrixX86.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_wtl|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\SoftwareRender.cpp" />
<ClCompile Include="..\..\src\TexrectDrawer.cpp" />
@ -433,6 +439,7 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
</ClCompile>
<ClCompile Include="..\..\src\ZilmarPluginAPI.cpp">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_wtl|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ZlutTexture.cpp" />
</ItemGroup>

View File

@ -443,6 +443,9 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramUniformFactoryFast.cpp">
<Filter>Source Files\Graphics\OpenGL\GLSL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Native.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\3DMath.h">

View File

@ -42,7 +42,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\lib\</OutDir>
<OutDir>$(SolutionDir)..\..\..\external\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>$(ProjectName)</TargetName>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
@ -73,7 +73,7 @@
<PreprocessorDefinitions>DEBUG_DUMP;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp17</LanguageStandard>

View File

@ -76,7 +76,7 @@
<PreprocessorDefinitions>DEBUG_DUMP;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ConformanceMode Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ConformanceMode>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>

View File

@ -63,7 +63,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32_ASM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
@ -73,7 +73,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PreprocessorDefinitions>_DEBUG;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Lib>

View File

@ -47,7 +47,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\lib\</OutDir>
<OutDir>$(SolutionDir)..\..\..\external\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)build\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
@ -63,7 +63,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<ConformanceMode Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ConformanceMode>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>
<ConformanceMode Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ConformanceMode>

View File

@ -71,6 +71,7 @@
<PreprocessorDefinitions>TIXML_USE_TICPP;_WINDOWS;WIN32;_DEBUG;_LIB;TIXML_USE_TICPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -65,6 +65,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -42,8 +42,12 @@ inline float DotProduct(const float v0[3], const float v1[3])
inline float GetFloatMatrixElement(s16 _int, u16 _fract)
{
#ifdef NATIVE
return (((u16)_int << 0x10) | (u16)_fract) * (1 / 65536.0f);
#else
const s32 element = static_cast<s32>((static_cast<u16>(_int) << 16) | _fract);
return _FIXED2FLOAT(element, 16);
#endif
}
inline std::pair<s16, u16> GetIntMatrixElement(f32 _elem)

View File

@ -19,6 +19,10 @@
#include <Graphics/PixelBuffer.h>
#include <DisplayWindow.h>
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace graphics;
#define DEPTH_TEX_WIDTH 640

View File

@ -13,6 +13,10 @@
#include <DisplayWindow.h>
#include <algorithm>
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace graphics;
RDRAMtoColorBuffer::RDRAMtoColorBuffer()
@ -179,7 +183,7 @@ u32 RGBA32ToABGR32(u32 col, bool _fullAlpha)
void RDRAMtoColorBuffer::_copyFromRDRAM(u32 _height, bool _fullAlpha)
{
Cleaner cleaner(this);
const u32 address = m_pCurBuffer->m_startAddress;
const word address = m_pCurBuffer->m_startAddress;
const u32 width = m_pCurBuffer->m_width;
const u32 height = _height;
@ -232,7 +236,7 @@ void RDRAMtoColorBuffer::_copyFromRDRAM(u32 _height, bool _fullAlpha)
if (!FBInfo::fbInfo.isSupported()) {
if (bUseAlpha && config.frameBufferEmulation.copyToRDRAM == Config::ctDisable) {
u32 totalBytes = (width * height) << m_pCurBuffer->m_size >> 1;
word totalBytes = (width * height) << m_pCurBuffer->m_size >> 1;
if (address + totalBytes > RDRAMSize + 1)
totalBytes = RDRAMSize + 1 - address;
memset(RDRAM + address, 0, totalBytes);

View File

@ -56,6 +56,9 @@ BufferedLog::~BufferedLog()
void BufferedLog::print(const char* _message)
{
m_log << _message;
#ifdef _MSC_VER
OutputDebugStringA(_message);
#endif
}
bool BufferedLog::needPrint(u32 _mode) const

View File

@ -84,11 +84,11 @@ private:
struct TriInfo {
std::array<Vertex, 3> vertices;
gDPCombine combine; // Combine mode at the time of rendering
u32 cycle_type;
word cycle_type;
gDPInfo::OtherMode otherMode;
u32 geometryMode; // geometry mode flags
u32 frameBufferAddress;
u32 tri_n; // Triangle number
word geometryMode; // geometry mode flags
word frameBufferAddress;
word tri_n; // Triangle number
TriangleType type; // 0-normal, 1-texrect, 2-fillrect

View File

@ -21,6 +21,10 @@
#include "DepthBuffer.h"
#include "DepthBufferRender.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
static vertexi * max_vtx; // Max y vertex (ending vertex)
static vertexi * start_vtx, *end_vtx; // First and last vertex in array
static vertexi * right_vtx, *left_vtx; // Current right and left vertex

View File

@ -195,10 +195,13 @@ void FrameBuffer::updateEndAddress()
inline
u32 _cutHeight(u32 _address, u32 _height, u32 _stride)
{
#ifndef NATIVE
if (_address > RDRAMSize)
return 0;
if (_address + _stride * _height > (RDRAMSize + 1))
return (RDRAMSize + 1 - _address) / _stride;
#endif
return _height;
}
@ -853,7 +856,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
if ((m_pCurrent->m_startAddress != _address)) {
if (isSubBuffer(m_pCurrent)) {
const u32 stride = _width << _size >> 1;
const u32 addrOffset = _address - m_pCurrent->m_startAddress;
const word addrOffset = _address - m_pCurrent->m_startAddress;
m_pCurrent->m_originX = (addrOffset % stride) >> (_size - 1);
m_pCurrent->m_originY = addrOffset / stride;
gSP.changed |= CHANGED_VIEWPORT;
@ -1498,7 +1501,7 @@ void FrameBufferList::renderBuffer()
const u32 vFullHeight = rdpRes.vi_ispal ? 288 : 240;
const f32 dstScaleY = m_overscan.getScaleY(vFullHeight);
const u32 addrOffset = ((rdpRes.vi_origin - pBuffer->m_startAddress) << 1 >> pBuffer->m_size);
const word addrOffset = ((rdpRes.vi_origin - pBuffer->m_startAddress) << 1 >> pBuffer->m_size);
srcY0 = static_cast<s32>(addrOffset / pBuffer->m_width);
if ((addrOffset != 0) && (pBuffer->m_width == addrOffset * 2))
srcY0 = 1;
@ -1747,7 +1750,9 @@ void FrameBuffer_ActivateBufferTextureBG(u32 t, u32 _frameBufferAddress)
void FrameBuffer_CopyToRDRAM(u32 _address, bool _sync)
{
#ifndef NATIVE
ColorBufferToRDRAM::get().copyToRDRAM(_address, _sync);
#endif
}
void FrameBuffer_CopyChunkToRDRAM(u32 _address)
@ -1755,7 +1760,7 @@ void FrameBuffer_CopyChunkToRDRAM(u32 _address)
ColorBufferToRDRAM::get().copyChunkToRDRAM(_address);
}
bool FrameBuffer_CopyDepthBuffer( u32 address )
bool FrameBuffer_CopyDepthBuffer( word address )
{
FrameBufferList & fblist = frameBufferList();
FrameBuffer * pCopyBuffer = fblist.getCopyBuffer();
@ -1775,17 +1780,17 @@ bool FrameBuffer_CopyDepthBuffer( u32 address )
return false;
}
bool FrameBuffer_CopyDepthBufferChunk(u32 address)
bool FrameBuffer_CopyDepthBufferChunk(word address)
{
return DepthBufferToRDRAM::get().copyChunkToRDRAM(address);
}
void FrameBuffer_CopyFromRDRAM(u32 _address, bool _bCFB)
void FrameBuffer_CopyFromRDRAM(word _address, bool _bCFB)
{
RDRAMtoColorBuffer::get().copyFromRDRAM(_address, _bCFB);
}
void FrameBuffer_AddAddress(u32 address, u32 _size)
void FrameBuffer_AddAddress(word address, u32 _size)
{
RDRAMtoColorBuffer::get().addAddress(address, _size);
}

View File

@ -241,10 +241,10 @@ void FrameBuffer_Init();
void FrameBuffer_Destroy();
void FrameBuffer_CopyToRDRAM( u32 _address , bool _sync );
void FrameBuffer_CopyChunkToRDRAM(u32 _address);
void FrameBuffer_CopyFromRDRAM(u32 address, bool bUseAlpha);
void FrameBuffer_AddAddress(u32 address, u32 _size);
bool FrameBuffer_CopyDepthBuffer(u32 address);
bool FrameBuffer_CopyDepthBufferChunk(u32 address);
void FrameBuffer_CopyFromRDRAM(word address, bool bUseAlpha);
void FrameBuffer_AddAddress(word address, u32 _size);
bool FrameBuffer_CopyDepthBuffer(word address);
bool FrameBuffer_CopyDepthBufferChunk(word address);
void FrameBuffer_ActivateBufferTexture(u32 t, u32 _frameBufferAddress);
void FrameBuffer_ActivateBufferTextureBG(u32 t, u32 _frameBufferAddress);

View File

@ -36,9 +36,9 @@ namespace FBInfo {
}
void FBInfo::Write(u32 addr, u32 size)
void FBInfo::Write(word addr, u32 size)
{
const u32 address = RSP_SegmentToPhysical(addr);
const word address = RSP_SegmentToPhysical(addr);
const FrameBuffer* writeBuffer = frameBufferList().findBuffer(address);
if (writeBuffer == nullptr)
return;
@ -53,9 +53,9 @@ namespace FBInfo {
LOG(LOG_WARNING, "FBWList size=%u", size);
}
void FBInfo::Read(u32 addr)
void FBInfo::Read(word addr)
{
const u32 address = RSP_SegmentToPhysical(addr);
const word address = RSP_SegmentToPhysical(addr);
FrameBuffer * pBuffer = frameBufferList().findBuffer(address);
if (pBuffer == nullptr || _findBuffer(m_writeBuffers, pBuffer).first)

View File

@ -30,11 +30,11 @@ namespace FBInfo {
public:
FBInfo();
void Write(u32 addr, u32 size);
void Write(word addr, u32 size);
void WriteList(FrameBufferModifyEntry *plist, u32 size);
void Read(u32 addr);
void Read(word addr);
void GetInfo(void *pinfo);

View File

@ -144,9 +144,9 @@ u32 G_MWO_aLIGHT_8, G_MWO_bLIGHT_8;
GBIInfo GBI;
void GBI_Unknown( u32 w0, u32 w1 )
void GBI_Unknown( const Gwords words )
{
DebugMsg(DEBUG_NORMAL, "UNKNOWN GBI COMMAND 0x%02X", _SHIFTR(w0, 24, 8));
DebugMsg(DEBUG_NORMAL, "UNKNOWN GBI COMMAND 0x%02X", _SHIFTR(words.w0, 24, 8));
}
void GBIInfo::init()
@ -338,7 +338,7 @@ void GBIInfo::_makeCurrent(MicrocodeInfo * _pCurrent)
m_pCurrent = _pCurrent;
}
bool GBIInfo::_makeExistingMicrocodeCurrent(u32 uc_start, u32 uc_dstart, u32 uc_dsize)
bool GBIInfo::_makeExistingMicrocodeCurrent(word uc_start, word uc_dstart, u32 uc_dsize)
{
auto iter = std::find_if(m_list.begin(), m_list.end(), [=](const MicrocodeInfo& info) {
return info.address == uc_start && info.dataAddress == uc_dstart && info.dataSize == uc_dsize;
@ -351,7 +351,7 @@ bool GBIInfo::_makeExistingMicrocodeCurrent(u32 uc_start, u32 uc_dstart, u32 uc_
return true;
}
void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
void GBIInfo::loadMicrocode(word uc_start, word uc_dstart, u16 uc_dsize)
{
if (_makeExistingMicrocodeCurrent(uc_start, uc_dstart, uc_dsize))
return;
@ -364,7 +364,11 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
current.type = NONE;
// See if we can identify it by CRC
#ifdef NATIVE
const u32 uc_crc = CRC_Calculate_Strict( 0xFFFFFFFF, (void*)uc_start, 4096 );
#else
const u32 uc_crc = CRC_Calculate_Strict( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 );
#endif
SpecialMicrocodeInfo infoToSearch;
infoToSearch.crc = uc_crc;
auto it = std::lower_bound(specialMicrocodes.begin(), specialMicrocodes.end(), infoToSearch,
@ -380,9 +384,13 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
return;
}
#ifdef NATIVE
const char* uc_data = (const char*)uc_dstart;
#else
// See if we can identify it by text
char uc_data[2048];
UnswapCopyWrap(RDRAM, uc_dstart & 0x1FFFFFFF, (u8*)uc_data, 0, 0x7FF, 2048);
#endif
char uc_str[256];
strcpy(uc_str, "Not Found");
@ -478,3 +486,20 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
assert(false && "unknown ucode!!!'n");
_makeCurrent(&current);
}
#ifdef EXTENDED_GFX
Gwords::Gwords() : w0(0), w1(0), w2(0), w3(0) {
}
Gwords::Gwords(word _w0, word _w1) : w0(_w0), w1(_w1), w2(0), w3(0) {
}
Gwords::Gwords(word _w0, word _w1, word _w2, word _w3) : w0(_w0), w1(_w1), w2(_w2), w3(_w3) {
}
#else
Gwords::Gwords() : w0(0), w1(0) {
}
Gwords::Gwords(word _w0, word _w1) : w0(_w0), w1(_w1) {
}
#endif

View File

@ -253,6 +253,8 @@ extern u32 G_MWO_aLIGHT_8, G_MWO_bLIGHT_8;
#define G_TEXRECTFLIP 0xE5 /* -27 */
#define G_TEXRECT 0xE4 /* -28 */
#define G_MARK_SEGMENT 0x30
#define G_RDPNOOP 0xC0
#define G_TRI_FILL 0xC8 /* fill triangle: 11001000 */
@ -414,6 +416,33 @@ extern u32 G_ZOBJ, G_ZRDPCMD, G_ZWAITSIGNAL, G_ZMTXCAT, G_ZMULT_MPMTX, G_ZLIGHTI
#define G_DL_PUSH 0x00
#define G_DL_NOPUSH 0x01
#ifdef NATIVE
typedef struct {
s16 x;
s16 y;
s16 z;
u16 flag;
s16 s;
s16 t;
union {
struct {
u8 r;
u8 g;
u8 b;
u8 a;
} color;
struct {
s8 x;
s8 y; // r
s8 z; // g
s8 a; // b
} normal;
};
} Vertex;
#else
typedef struct
{
s16 y;
@ -442,7 +471,17 @@ typedef struct
} normal;
};
} Vertex;
#endif
#ifdef NATIVE
typedef struct
{
s16 x, y;
s16 z;
u16 ci;
s16 s, t;
} PDVertex;
#else
typedef struct
{
s16 y, x;
@ -450,7 +489,17 @@ typedef struct
s16 z;
s16 t, s;
} PDVertex;
#endif
#ifdef NATIVE
typedef struct
{
u8 v2, v1, v0, flag;
s16 s0, t0;
s16 s1, t1;
s16 s2, t2;
} DKRTriangle;
#else
typedef struct
{
u8 v2, v1, v0, flag;
@ -458,28 +507,47 @@ typedef struct
s16 t1, s1;
s16 t2, s2;
} DKRTriangle;
#endif
#ifdef NATIVE
typedef struct
{
s16 x, y;
s16 z;
u16 flag;
} SWVertex;
#else
typedef struct
{
s16 y, x;
u16 flag;
s16 z;
} SWVertex;
#endif
#ifdef NATIVE
struct Light
{
u8 r, g, b, pad0;
u8 r2, g2, b2, pad1;
s8 x, y, z, pad2;
};
#else
struct Light
{
u8 pad0, b, g, r;
u8 pad1, b2, g2, r2;
s8 pad2, z, y, x;
};
#endif
// GBI commands
typedef void (*GBIFunc)( u32 w0, u32 w1 );
typedef void (*GBIFunc)( const Gwords words );
struct MicrocodeInfo
{
u32 address = 0;
u32 dataAddress = 0;;
word address = 0;
word dataAddress = 0;;
u16 dataSize = 0;
u32 type = NONE;
bool NoN = false;
@ -499,7 +567,7 @@ struct GBIInfo
void init();
void destroy();
void loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize);
void loadMicrocode(word uc_start, word uc_dstart, u16 uc_dsize);
u32 getMicrocodeType() const {return m_pCurrent != nullptr ? m_pCurrent->type : NONE;}
bool isHWLSupported() const;
void setHWLSupported(bool _supported);
@ -514,7 +582,7 @@ private:
void _flushCommands();
void _makeCurrent(MicrocodeInfo * _pCurrent);
bool _makeExistingMicrocodeCurrent(u32 uc_start, u32 uc_dstart, u32 uc_dsize);
bool _makeExistingMicrocodeCurrent(word uc_start, word uc_dstart, u32 uc_dsize);
bool m_hwlSupported;
MicrocodeInfo * m_pCurrent;

View File

@ -1,3 +1,4 @@
#define WGL_WGLEXT_PROTOTYPES
#include "WindowsWGL.h"
#include <Config.h>
#include <GLideN64.h>
@ -46,9 +47,9 @@ bool WindowsWGL::start()
}
if ((SetPixelFormat(hDC, pixelFormat, &pfd)) == FALSE) {
auto err = GetLastError();
auto currentFormat = GetPixelFormat(hDC);
MessageBoxW(hWnd, L"Error while setting pixel format!", pluginNameW, MB_ICONERROR | MB_OK);
stop();
return false;
}
if ((hRC = wglCreateContext(hDC)) == NULL) {

View File

@ -175,6 +175,7 @@ bool DisplayWindowWindows::_resizeWindow()
m_heightOffset = 0;
_setBufferSize();
return true;
return (SetWindowPos(hWnd, NULL, 0, 0, m_screenWidth, m_screenHeight, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW) == TRUE);
} else {
m_screenWidth = m_width = config.video.windowedWidth;
@ -193,6 +194,7 @@ bool DisplayWindowWindows::_resizeWindow()
windowRect.right = windowRect.left + config.video.windowedWidth - 1;
windowRect.bottom = windowRect.top + config.video.windowedHeight - 1 + m_heightOffset;
return true;
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
return (SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,

View File

@ -25,6 +25,10 @@
#include "VI.h"
#include "Log.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace graphics;
GraphicsDrawer::GraphicsDrawer()
@ -78,7 +82,7 @@ void GraphicsDrawer::addTriangle(u32 _v0, u32 _v1, u32 _v2)
}
else if ((gSP.geometryMode & G_SHADING_SMOOTH) == 0) {
// Flat shading
SPVertex & vtx0 = triangles.vertices[triangles.elements[firstIndex + (((RSP.w1 >> 24) & 3) % 3)]];
SPVertex & vtx0 = triangles.vertices[triangles.elements[firstIndex + (((RSP.words.w1 >> 24) & 3) % 3)]];
for (u32 i = firstIndex; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.r = vtx.flat_r = vtx0.r;
@ -888,7 +892,7 @@ void GraphicsDrawer::_drawThickLine(u32 _v0, u32 _v1, float _width)
}
else if ((gSP.geometryMode & G_SHADING_SMOOTH) == 0) {
// Flat shading
SPVertex & vtx0 = triangles.vertices[_v0 + ((RSP.w1 >> 24) & 3)];
SPVertex & vtx0 = triangles.vertices[_v0 + ((RSP.words.w1 >> 24) & 3)];
SPVertex & vtx1 = triangles.vertices[_v0];
vtx1.r = vtx1.flat_r = vtx0.r;
vtx1.g = vtx1.flat_g = vtx0.g;
@ -1104,7 +1108,11 @@ bool texturedRectDepthBufferCopy(const GraphicsDrawer::TexturedRectParams & _par
u16 * pSrc = reinterpret_cast<u16*>(TMEM) + _params.s/32;
u16 *pDst = reinterpret_cast<u16*>(RDRAM + gDP.colorImage.address);
for (u32 x = 0; x < width; ++x)
#ifdef NATIVE
pDst[(ulx + x) ^ 1] = pSrc[x];
#else
pDst[(ulx + x) ^ 1] = swapword(pSrc[x]);
#endif
return true;
}

View File

@ -1,12 +1,16 @@
#include "N64.h"
u8 *HEADER;
#ifndef NATIVE
u8* HEADER;
u8 *DMEM;
u8 *IMEM;
#endif
u64 TMEM[512];
#ifndef NATIVE
u8 *RDRAM;
#endif
u32 RDRAMSize = 0;
word RDRAMSize = 0;
N64Regs REG;

View File

@ -3,16 +3,28 @@
#include "Types.h"
/*
#ifdef NATIVE
#define RDRAM_PTR(a) ((u8*)a)
#else
#define RDRAM_PTR(a) RDRAM[a]
#endif
*/
#define MI_INTR_DP 0x20 // Bit 5: DP intr
struct N64Regs
{
#ifdef NATIVE
N64Regs();
~N64Regs();
#endif
u32 *MI_INTR;
u32 *DPC_START;
u32 *DPC_END;
u32 *DPC_CURRENT;
u32 *DPC_STATUS;
word *DPC_START;
word *DPC_END;
word *DPC_CURRENT;
word *DPC_STATUS;
u32 *DPC_CLOCK;
u32 *DPC_BUFBUSY;
u32 *DPC_PIPEBUSY;
@ -38,11 +50,17 @@ struct N64Regs
extern N64Regs REG;
extern u8 *HEADER;
#ifdef NATIVE
#define RDRAM ((u8*)0)
#define DMEM ((u8*)0)
#define IMEM ((u8*)0)
#else
extern u8 *DMEM;
extern u8 *IMEM;
extern u8 *RDRAM;
#endif
extern u64 TMEM[512];
extern u32 RDRAMSize;
extern word RDRAMSize;
extern bool ConfigOpen;
#endif

155
src/Native.cpp Normal file
View File

@ -0,0 +1,155 @@
#include "PluginAPI.h"
#include "N64.h"
#include "RSP.h"
#include "Native.h"
#include "GLideNUI-wtl/GLideNUI.h"
#include "GLideN64.h"
#include "Config.h"
#include "DebugDump.h"
#include "Config.h"
#include "DisplayWindow.h"
#include <wchar.h>
#define START_WIDTH 1280
#define START_HEIGHT 720
static u64 g_width = START_WIDTH;
static u64 g_height = START_HEIGHT;
extern "C" {
u64 gfx_width()
{
return g_width;
}
u64 gfx_height()
{
return g_height;
}
}
#ifdef WTL_UI
void ConfigInit(void* hinst);
void ConfigCleanup(void);
#endif
N64Regs::N64Regs() {
MI_INTR = new u32;
DPC_START = new word;
DPC_END = new word;
DPC_CURRENT = new word;
DPC_STATUS = new word;
DPC_CLOCK = new u32;
DPC_BUFBUSY = new u32;
DPC_PIPEBUSY = new u32;
DPC_TMEM = new u32;
VI_STATUS = new u32;
VI_ORIGIN = new u32;
VI_WIDTH = new u32;
VI_INTR = new u32;
VI_V_CURRENT_LINE = new u32;
VI_TIMING = new u32;
VI_V_SYNC = new u32;
VI_H_SYNC = new u32;
VI_LEAP = new u32;
VI_H_START = new u32;
VI_V_START = new u32;
VI_V_BURST = new u32;
VI_X_SCALE = new u32;
VI_Y_SCALE = new u32;
SP_STATUS = new u32;
*MI_INTR = 0;
*DPC_START = 0;
*DPC_END = 0;
*DPC_CURRENT = 0;
*DPC_STATUS = 0;
*DPC_CLOCK = 0;
*DPC_BUFBUSY = 0;
*DPC_PIPEBUSY = 0;
*DPC_TMEM = 0;
*VI_STATUS = 0;
*VI_ORIGIN = 0;
*VI_WIDTH = 320;
*VI_INTR = 0;
*VI_V_CURRENT_LINE = 0;
*VI_TIMING = 0;
*VI_V_SYNC = 0;
*VI_H_SYNC = 0;
*VI_LEAP = 0;
*VI_H_START = 0;
*VI_V_START = 0;
*VI_V_BURST = 0;
*VI_X_SCALE = 1024;
*VI_Y_SCALE = 512;
*SP_STATUS = 0;
}
N64Regs::~N64Regs() {
}
extern "C"
{
void gfx_resize(long width, long height)
{
g_width = width;
g_height = height;
config.video.windowedWidth = g_width;
config.video.windowedHeight = g_height;
dwnd().setWindowSize(g_width, g_height);
(*REG.VI_ORIGIN)++;
}
}
void _CheckInterrupts() {
}
extern "C" {
void gfx_init(const char* romName, OSViMode* viMode) {
REG.VI_STATUS = &viMode->comRegs.ctrl;
REG.VI_WIDTH = &viMode->comRegs.width;
REG.VI_TIMING = &viMode->comRegs.burst;
REG.VI_V_SYNC = &viMode->comRegs.vSync;
REG.VI_H_SYNC = &viMode->comRegs.hSync;
REG.VI_LEAP = &viMode->comRegs.leap;
REG.VI_H_START = &viMode->comRegs.hStart;
REG.VI_X_SCALE = &viMode->comRegs.xScale;
REG.VI_V_CURRENT_LINE = &viMode->comRegs.vCurrent;
REG.VI_ORIGIN = &viMode->fldRegs->origin;
REG.VI_Y_SCALE = &viMode->fldRegs->yScale;
REG.VI_V_START = &viMode->fldRegs->vStart;
REG.VI_V_BURST = &viMode->fldRegs->vBurst;
REG.VI_INTR = &viMode->fldRegs->vIntr;
CheckInterrupts = _CheckInterrupts;
//StartDump(DEBUG_LOW | DEBUG_NORMAL | DEBUG_DETAIL | DEBUG_IGNORED | DEBUG_ERROR);
REG.VI_STATUS;
RDRAMSize = (word)-1;
api().RomOpen(romName);
config.frameBufferEmulation.enable = 0;
config.frameBufferEmulation.aspect = Config::aAdjust;
}
void gfx_shutdown() {
RDRAMSize = 0;
api().RomClosed();
}
void gfx_run(OSTask_t* task, u32 sz) {
if(sizeof(OSTask_t) != sz)
{
return;
}
RSP_ProcessDList(task->data_ptr, task->data_size, task->ucode_boot, task->ucode_data, task->ucode_size);
api().UpdateScreen();
//Sleep(30);
}
}

61
src/Native.h Normal file
View File

@ -0,0 +1,61 @@
#pragma once
typedef struct {
/* 0x00 */ u32 ctrl;
/* 0x04 */ u32 width;
/* 0x08 */ u32 burst;
/* 0x0C */ u32 vSync;
/* 0x10 */ u32 hSync;
/* 0x14 */ u32 leap;
/* 0x18 */ u32 hStart;
/* 0x1C */ u32 xScale;
/* 0x20 */ u32 vCurrent;
} OSViCommonRegs; // size = 0x20
typedef struct {
/* 0x00 */ u32 origin;
/* 0x04 */ u32 yScale;
/* 0x08 */ u32 vStart;
/* 0x0C */ u32 vBurst;
/* 0x10 */ u32 vIntr;
} OSViFieldRegs; // size = 0x14
typedef struct {
/* 0x00 */ u8 type;
/* 0x04 */ OSViCommonRegs comRegs;
/* 0x24 */ OSViFieldRegs fldRegs[2];
} OSViMode; // size = 0x4C
typedef struct {
/* 0x00 */ u32 type;
/* 0x04 */ u32 flags;
/* 0x08 */ u64* ucode_boot;
/* 0x0C */ u32 ucode_boot_size;
/* 0x10 */ u64* ucode;
/* 0x14 */ u32 ucode_size;
/* 0x18 */ u64* ucode_data;
/* 0x1C */ u32 ucode_data_size;
/* 0x20 */ u64* dram_stack;
/* 0x24 */ u32 dram_stack_size;
/* 0x28 */ u64* output_buff;
/* 0x2C */ u64* output_buff_size;
/* 0x30 */ u64* data_ptr;
/* 0x34 */ u32 data_size;
/* 0x38 */ u64* yield_data_ptr;
/* 0x3C */ u32 yield_data_size;
} OSTask_t; // size = 0x40
extern "C" {
void gfx_init(const char* romName, OSViMode* viMode);
void gfx_shutdown();
void gfx_start_frame();
void gfx_end_frame();
void gfx_run(OSTask_t* task, u32 sz);
}

View File

@ -3,7 +3,7 @@
#include "arm_neon.h"
#include "GBI.h"
void RSP_LoadMatrix( f32 mtx[4][4], u32 address )
void RSP_LoadMatrix( f32 mtx[4][4], word address )
{
f32 recip = FIXED2FLOATRECIP16;

View File

@ -88,7 +88,11 @@ void PaletteTexture::update()
u32 * palette = (u32*)m_pbuf;
u16 *src = (u16*)&TMEM[256];
for (int i = 0; i < 256; ++i)
#ifdef NATIVE
palette[i] = src[i * 4];
#else
palette[i] = swapword(src[i * 4]);
#endif
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
Context::UpdateTextureDataParams params;

View File

@ -36,7 +36,7 @@ public:
void ProcessDList();
void ProcessRDPList();
void RomClosed();
int RomOpen();
int RomOpen(const char* romName = nullptr);
void ShowCFB();
void UpdateScreen();
int InitiateGFX(const GFX_INFO & _gfxInfo);

View File

@ -11,225 +11,240 @@
#include "DebugDump.h"
#include "DisplayWindow.h"
void RDP_Unknown( u32 w0, u32 w1 )
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
#define SIGN_MASK(n) (1 << (12 - 1))
#define SIGN12(a) \
(a & SIGN_MASK(12) ? \
(((1 << 12) / 2 - (a & (SIGN_MASK(12) - 1))) * -1) \
: (a))
void RDP_Unknown( const Gwords words )
{
DebugMsg(DEBUG_NORMAL, "RDP_Unknown\r\n");
DebugMsg(DEBUG_NORMAL, "\tUnknown RDP opcode %02X\r\n", _SHIFTR(w0, 24, 8));
DebugMsg(DEBUG_NORMAL, "\tUnknown RDP opcode %02X\r\n", _SHIFTR(words.w0, 24, 8));
}
void RDP_NoOp( u32 w0, u32 w1 )
void RDP_NoOp( const Gwords words )
{
gDPNoOp();
gDPNoOp(words);
}
void RDP_SetCImg( u32 w0, u32 w1 )
{
gDPSetColorImage( _SHIFTR( w0, 21, 3 ), // fmt
_SHIFTR( w0, 19, 2 ), // siz
_SHIFTR( w0, 0, 12 ) + 1, // width
w1 ); // img
void RDP_MarkSegment(const Gwords words) {
RSP.translateSegment = true;
}
void RDP_SetZImg( u32 w0, u32 w1 )
void RDP_SetCImg( const Gwords words )
{
gDPSetDepthImage( w1 ); // img
gDPSetColorImage( _SHIFTR( words.w0, 21, 3 ), // fmt
_SHIFTR( words.w0, 19, 2 ), // siz
_SHIFTR( words.w0, 0, 12 ) + 1, // width
words.w1 ); // img
}
void RDP_SetTImg( u32 w0, u32 w1 )
void RDP_SetZImg( const Gwords words )
{
gDPSetTextureImage( _SHIFTR( w0, 21, 3), // fmt
_SHIFTR( w0, 19, 2 ), // siz
_SHIFTR( w0, 0, 12 ) + 1, // width
w1 ); // img
gDPSetDepthImage( words.w1 ); // img
}
void RDP_SetCombine( u32 w0, u32 w1 )
void RDP_SetTImg( const Gwords words )
{
gDPSetCombine( _SHIFTR( w0, 0, 24 ), // muxs0
w1 ); // muxs1
gDPSetTextureImage( _SHIFTR( words.w0, 21, 3), // fmt
_SHIFTR( words.w0, 19, 2 ), // siz
_SHIFTR( words.w0, 0, 12 ) + 1, // width
words.w1 ); // img
}
void RDP_SetEnvColor( u32 w0, u32 w1 )
void RDP_SetCombine( const Gwords words )
{
gDPSetEnvColor( _SHIFTR( w1, 24, 8 ), // r
_SHIFTR( w1, 16, 8 ), // g
_SHIFTR( w1, 8, 8 ), // b
_SHIFTR( w1, 0, 8 ) ); // a
gDPSetCombine( _SHIFTR( words.w0, 0, 24 ), // muxs0
words.w1 ); // muxs1
}
void RDP_SetPrimColor( u32 w0, u32 w1 )
void RDP_SetEnvColor( const Gwords words )
{
gDPSetPrimColor( _SHIFTR( w0, 8, 5 ), // m
_SHIFTR( w0, 0, 8 ), // l
_SHIFTR( w1, 24, 8 ), // r
_SHIFTR( w1, 16, 8 ), // g
_SHIFTR( w1, 8, 8 ), // b
_SHIFTR( w1, 0, 8 ) ); // a
gDPSetEnvColor( _SHIFTR( words.w1, 24, 8 ), // r
_SHIFTR( words.w1, 16, 8 ), // g
_SHIFTR( words.w1, 8, 8 ), // b
_SHIFTR( words.w1, 0, 8 ) ); // a
}
void RDP_SetPrimColor( const Gwords words )
{
gDPSetPrimColor( _SHIFTR( words.w0, 8, 5 ), // m
_SHIFTR( words.w0, 0, 8 ), // l
_SHIFTR( words.w1, 24, 8 ), // r
_SHIFTR( words.w1, 16, 8 ), // g
_SHIFTR( words.w1, 8, 8 ), // b
_SHIFTR( words.w1, 0, 8 ) ); // a
}
void RDP_SetBlendColor( u32 w0, u32 w1 )
void RDP_SetBlendColor( const Gwords words )
{
gDPSetBlendColor( _SHIFTR( w1, 24, 8 ), // r
_SHIFTR( w1, 16, 8 ), // g
_SHIFTR( w1, 8, 8 ), // b
_SHIFTR( w1, 0, 8 ) ); // a
gDPSetBlendColor( _SHIFTR( words.w1, 24, 8 ), // r
_SHIFTR( words.w1, 16, 8 ), // g
_SHIFTR( words.w1, 8, 8 ), // b
_SHIFTR( words.w1, 0, 8 ) ); // a
}
void RDP_SetFogColor( u32 w0, u32 w1 )
void RDP_SetFogColor( const Gwords words )
{
gDPSetFogColor( _SHIFTR( w1, 24, 8 ), // r
_SHIFTR( w1, 16, 8 ), // g
_SHIFTR( w1, 8, 8 ), // b
_SHIFTR( w1, 0, 8 ) ); // a
gDPSetFogColor( _SHIFTR( words.w1, 24, 8 ), // r
_SHIFTR( words.w1, 16, 8 ), // g
_SHIFTR( words.w1, 8, 8 ), // b
_SHIFTR( words.w1, 0, 8 ) ); // a
}
void RDP_SetFillColor( u32 w0, u32 w1 )
void RDP_SetFillColor( const Gwords words )
{
gDPSetFillColor( w1 );
gDPSetFillColor( words.w1 );
}
void RDP_FillRect( u32 w0, u32 w1 )
void RDP_FillRect( const Gwords words )
{
const u32 ulx = _SHIFTR(w1, 14, 10);
const u32 uly = _SHIFTR(w1, 2, 10);
const u32 lrx = _SHIFTR(w0, 14, 10);
const u32 lry = _SHIFTR(w0, 2, 10);
const u32 ulx = _SHIFTR(words.w1, 14, 10);
const u32 uly = _SHIFTR(words.w1, 2, 10);
const u32 lrx = _SHIFTR(words.w0, 14, 10);
const u32 lry = _SHIFTR(words.w0, 2, 10);
if (lrx < ulx || lry < uly)
return;
gDPFillRectangle(ulx, uly, lrx, lry);
}
void RDP_SetTile( u32 w0, u32 w1 )
void RDP_SetTile( const Gwords words )
{
gDPSetTile( _SHIFTR( w0, 21, 3 ), // fmt
_SHIFTR( w0, 19, 2 ), // siz
_SHIFTR( w0, 9, 9 ), // line
_SHIFTR( w0, 0, 9 ), // tmem
_SHIFTR( w1, 24, 3 ), // tile
_SHIFTR( w1, 20, 4 ), // palette
_SHIFTR( w1, 18, 2 ), // cmt
_SHIFTR( w1, 8, 2 ), // cms
_SHIFTR( w1, 14, 4 ), // maskt
_SHIFTR( w1, 4, 4 ), // masks
_SHIFTR( w1, 10, 4 ), // shiftt
_SHIFTR( w1, 0, 4 ) ); // shifts
gDPSetTile( _SHIFTR( words.w0, 21, 3 ), // fmt
_SHIFTR( words.w0, 19, 2 ), // siz
_SHIFTR( words.w0, 9, 9 ), // line
_SHIFTR( words.w0, 0, 9 ), // tmem
_SHIFTR( words.w1, 24, 3 ), // tile
_SHIFTR( words.w1, 20, 4 ), // palette
_SHIFTR( words.w1, 18, 2 ), // cmt
_SHIFTR( words.w1, 8, 2 ), // cms
_SHIFTR( words.w1, 14, 4 ), // maskt
_SHIFTR( words.w1, 4, 4 ), // masks
_SHIFTR( words.w1, 10, 4 ), // shiftt
_SHIFTR( words.w1, 0, 4 ) ); // shifts
}
void RDP_LoadTile( u32 w0, u32 w1 )
void RDP_LoadTile( const Gwords words )
{
gDPLoadTile( _SHIFTR( w1, 24, 3 ), // tile
_SHIFTR( w0, 12, 12 ), // uls
_SHIFTR( w0, 0, 12 ), // ult
_SHIFTR( w1, 12, 12 ), // lrs
_SHIFTR( w1, 0, 12 ) ); // lrt
gDPLoadTile( _SHIFTR( words.w1, 24, 3 ), // tile
_SHIFTR( words.w0, 12, 12 ), // uls
_SHIFTR( words.w0, 0, 12 ), // ult
_SHIFTR( words.w1, 12, 12 ), // lrs
_SHIFTR( words.w1, 0, 12 ) ); // lrt
}
static u32 lbw0, lbw1;
void RDP_LoadBlock( u32 w0, u32 w1 )
void RDP_LoadBlock( const Gwords words )
{
lbw0 = w0;
lbw1 = w1;
gDPLoadBlock( _SHIFTR( w1, 24, 3 ), // tile
_SHIFTR( w0, 12, 12 ), // uls
_SHIFTR( w0, 0, 12 ), // ult
_SHIFTR( w1, 12, 12 ), // lrs
_SHIFTR( w1, 0, 12 ) ); // dxt
lbw0 = words.w0;
lbw1 = words.w1;
gDPLoadBlock( _SHIFTR( words.w1, 24, 3 ), // tile
_SHIFTR( words.w0, 12, 12 ), // uls
_SHIFTR( words.w0, 0, 12 ), // ult
_SHIFTR( words.w1, 12, 12 ), // lrs
_SHIFTR( words.w1, 0, 12 ) ); // dxt
}
void RDP_RepeatLastLoadBlock()
{
RDP_LoadBlock(lbw0, lbw1);
RDP_LoadBlock(Gwords(lbw0, lbw1));
}
void RDP_SetTileSize( u32 w0, u32 w1 )
void RDP_SetTileSize( const Gwords words )
{
gDPSetTileSize( _SHIFTR( w1, 24, 3 ), // tile
_SHIFTR( w0, 12, 12 ), // uls
_SHIFTR( w0, 0, 12 ), // ult
_SHIFTR( w1, 12, 12 ), // lrs
_SHIFTR( w1, 0, 12 ) ); // lrt
gDPSetTileSize( _SHIFTR( words.w1, 24, 3 ), // tile
_SHIFTR( words.w0, 12, 12 ), // uls
_SHIFTR( words.w0, 0, 12 ), // ult
_SHIFTR( words.w1, 12, 12 ), // lrs
_SHIFTR( words.w1, 0, 12 ) ); // lrt
}
void RDP_LoadTLUT( u32 w0, u32 w1 )
void RDP_LoadTLUT( const Gwords words )
{
gDPLoadTLUT( _SHIFTR( w1, 24, 3 ), // tile
_SHIFTR( w0, 12, 12 ), // uls
_SHIFTR( w0, 0, 12 ), // ult
_SHIFTR( w1, 12, 12 ), // lrs
_SHIFTR( w1, 0, 12 ) ); // lrt
gDPLoadTLUT( _SHIFTR( words.w1, 24, 3 ), // tile
_SHIFTR( words.w0, 12, 12 ), // uls
_SHIFTR( words.w0, 0, 12 ), // ult
_SHIFTR( words.w1, 12, 12 ), // lrs
_SHIFTR( words.w1, 0, 12 ) ); // lrt
}
void RDP_SetOtherMode( u32 w0, u32 w1 )
void RDP_SetOtherMode( const Gwords words )
{
gDPSetOtherMode( _SHIFTR( w0, 0, 24 ), // mode0
w1 ); // mode1
gDPSetOtherMode( _SHIFTR( words.w0, 0, 24 ), // mode0
words.w1 ); // mode1
}
void RDP_SetPrimDepth( u32 w0, u32 w1 )
void RDP_SetPrimDepth( const Gwords words )
{
gDPSetPrimDepth( _SHIFTR( w1, 16, 16 ), // z
_SHIFTR( w1, 0, 16 ) ); // dz
gDPSetPrimDepth( _SHIFTR( words.w1, 16, 16 ), // z
_SHIFTR( words.w1, 0, 16 ) ); // dz
}
void RDP_SetScissor( u32 w0, u32 w1 )
void RDP_SetScissor( const Gwords words )
{
gDPSetScissor( _SHIFTR( w1, 24, 2 ), // mode
_SHIFTR( w0, 12, 12 ), // ulx
_SHIFTR( w0, 0, 12 ), // uly
_SHIFTR( w1, 12, 12 ), // lrx
_SHIFTR( w1, 0, 12 ) ); // lry
gDPSetScissor( _SHIFTR( words.w1, 24, 2 ), // mode
_SHIFTR( words.w0, 12, 12 ), // ulx
_SHIFTR( words.w0, 0, 12 ), // uly
_SHIFTR( words.w1, 12, 12 ), // lrx
_SHIFTR( words.w1, 0, 12 ) ); // lry
}
void RDP_SetConvert( u32 w0, u32 w1 )
void RDP_SetConvert( const Gwords words )
{
gDPSetConvert( _SHIFTR( w0, 13, 9 ), // k0
_SHIFTR( w0, 4, 9 ), // k1
_SHIFTL( w0, 5, 4 ) | _SHIFTR( w1, 27, 5 ), // k2
_SHIFTR( w1, 18, 9 ), // k3
_SHIFTR( w1, 9, 9 ), // k4
_SHIFTR( w1, 0, 9 ) ); // k5
gDPSetConvert( _SHIFTR( words.w0, 13, 9 ), // k0
_SHIFTR( words.w0, 4, 9 ), // k1
_SHIFTL( words.w0, 5, 4 ) | _SHIFTR( words.w1, 27, 5 ), // k2
_SHIFTR( words.w1, 18, 9 ), // k3
_SHIFTR( words.w1, 9, 9 ), // k4
_SHIFTR( words.w1, 0, 9 ) ); // k5
}
void RDP_SetKeyR( u32 w0, u32 w1 )
void RDP_SetKeyR( const Gwords words )
{
gDPSetKeyR( _SHIFTR( w1, 8, 8 ), // cR
_SHIFTR( w1, 0, 8 ), // sR
_SHIFTR( w1, 16, 12 ) ); // wR
gDPSetKeyR( _SHIFTR( words.w1, 8, 8 ), // cR
_SHIFTR( words.w1, 0, 8 ), // sR
_SHIFTR( words.w1, 16, 12 ) ); // wR
}
void RDP_SetKeyGB( u32 w0, u32 w1 )
void RDP_SetKeyGB( const Gwords words )
{
gDPSetKeyGB( _SHIFTR( w1, 24, 8 ), // cG
_SHIFTR( w1, 16, 8 ), // sG
_SHIFTR( w0, 12, 12 ), // wG
_SHIFTR( w1, 8, 8 ), // cB
_SHIFTR( w1, 0, 8 ), // SB
_SHIFTR( w0, 0, 12 ) ); // wB
gDPSetKeyGB( _SHIFTR( words.w1, 24, 8 ), // cG
_SHIFTR( words.w1, 16, 8 ), // sG
_SHIFTR( words.w0, 12, 12 ), // wG
_SHIFTR( words.w1, 8, 8 ), // cB
_SHIFTR( words.w1, 0, 8 ), // SB
_SHIFTR( words.w0, 0, 12 ) ); // wB
}
void RDP_FullSync( u32 w0, u32 w1 )
void RDP_FullSync( const Gwords words )
{
gDPFullSync();
}
void RDP_TileSync( u32 w0, u32 w1 )
void RDP_TileSync( const Gwords words )
{
gDPTileSync();
}
void RDP_PipeSync( u32 w0, u32 w1 )
void RDP_PipeSync( const Gwords words )
{
gDPPipeSync();
gDPPipeSync(words);
}
void RDP_LoadSync( u32 w0, u32 w1 )
void RDP_LoadSync( const Gwords words )
{
gDPLoadSync();
}
static
bool _getTexRectParams(u32 & w2, u32 & w3)
bool _getTexRectParams(word & w2, word & w3)
{
if (RSP.LLE) {
w2 = RDP.w2;
@ -243,8 +258,8 @@ bool _getTexRectParams(u32 & w2, u32 & w3)
halfTexRect
} texRectMode = gdpTexRect;
const u32 cmd1 = (*(u32*)&RDRAM[RSP.PC[RSP.PCi] + 0]) >> 24;
const u32 cmd2 = (*(u32*)&RDRAM[RSP.PC[RSP.PCi] + 8]) >> 24;
const word cmd1 = (*(word*)&RDRAM[RSP.PC[RSP.PCi] + 0]) >> 24;
const word cmd2 = (*(word*)&RDRAM[RSP.PC[RSP.PCi] + sizeof(Gwords)]) >> 24;
if (cmd1 == G_RDPHALF_1) {
if (cmd2 == G_RDPHALF_2)
texRectMode = gspTexRect;
@ -255,34 +270,34 @@ bool _getTexRectParams(u32 & w2, u32 & w3)
switch (texRectMode) {
case gspTexRect:
w2 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += 8;
w2 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += sizeof(Gwords);
w3 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += 8;
w3 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += sizeof(Gwords);
break;
case gdpTexRect:
if ((config.generalEmulation.hacks & hack_WinBack) != 0) {
RSP.PC[RSP.PCi] += 8;
RSP.PC[RSP.PCi] += sizeof(Gwords);
return false;
}
{
const u32 ucode = GBI.getMicrocodeType();
const word ucode = GBI.getMicrocodeType();
if (ucode == F5Rogue || ucode == F5Indi_Naboo) {
w2 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 8];
w3 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 12];
RSP.PC[RSP.PCi] += 8;
w2 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 8];
w3 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 12];
RSP.PC[RSP.PCi] += sizeof(Gwords);
return true;
}
}
w2 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 0];
w3 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += 8;
w2 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 0];
w3 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += sizeof(Gwords);
break;
case halfTexRect:
w2 = 0;
w3 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += 8;
w3 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.PC[RSP.PCi] += sizeof(Gwords);
break;
default:
assert(false && "Unknown texrect mode");
@ -291,17 +306,17 @@ bool _getTexRectParams(u32 & w2, u32 & w3)
}
static
void _TexRect( u32 w0, u32 w1, bool flip )
void _TexRect( const Gwords words, bool flip )
{
u32 w2, w3;
word w2, w3;
if (!_getTexRectParams(w2, w3))
return;
RDP.w0 = w0;
RDP.w1 = w1;
const s32 ulx = _SHIFTR(w1, 12, 12);
const s32 uly = _SHIFTR(w1, 0, 12);
const s32 lrx = _SHIFTR(w0, 12, 12);
const s32 lry = _SHIFTR(w0, 0, 12);
RDP.w0 = words.w0;
RDP.w1 = words.w1;
const s32 ulx = SIGN12(_SHIFTR(words.w1, 12, 12));
const s32 uly = _SHIFTR(words.w1, 0, 12);
const s32 lrx = SIGN12(_SHIFTR(words.w0, 12, 12));
const s32 lry = _SHIFTR(words.w0, 0, 12);
if (lrx < ulx || lry < uly)
return;
if (gDP.otherMode.cycleType == G_CYC_COPY)
@ -310,7 +325,7 @@ void _TexRect( u32 w0, u32 w1, bool flip )
f32(uly >> 2),
f32(lrx >> 2),
f32(lry >> 2),
_SHIFTR(w1, 24, 3), // tile
_SHIFTR(words.w1, 24, 3), // tile
(s16)_SHIFTR(w2, 16, 16), // s
(s16)_SHIFTR(w2, 0, 16), // t
_FIXED2FLOAT((s16)_SHIFTR(w3, 16, 16), 10), // dsdx
@ -322,7 +337,7 @@ void _TexRect( u32 w0, u32 w1, bool flip )
_FIXED2FLOAT(uly, 2),
_FIXED2FLOAT(lrx, 2),
_FIXED2FLOAT(lry, 2),
_SHIFTR(w1, 24, 3), // tile
_SHIFTR(words.w1, 24, 3), // tile
(s16)_SHIFTR(w2, 16, 16), // s
(s16)_SHIFTR(w2, 0, 16), // t
_FIXED2FLOAT((s16)_SHIFTR(w3, 16, 16), 10), // dsdx
@ -330,54 +345,54 @@ void _TexRect( u32 w0, u32 w1, bool flip )
flip);
}
void RDP_TexRectFlip( u32 w0, u32 w1 )
void RDP_TexRectFlip( const Gwords words )
{
_TexRect(w0, w1, true);
_TexRect(words, true);
}
void RDP_TexRect( u32 w0, u32 w1 )
void RDP_TexRect( const Gwords words )
{
_TexRect(w0, w1, false);
_TexRect(words, false);
}
void RDP_TriFill( u32 _w0, u32 _w1 )
void RDP_TriFill(const Gwords words)
{
gDPTriFill(_w0, _w1);
gDPTriFill(words.w0, words.w1);
}
void RDP_TriShade( u32 _w0, u32 _w1 )
void RDP_TriShade(const Gwords words)
{
gDPTriShade(_w0, _w1);
gDPTriShade(words.w0, words.w1);
}
void RDP_TriTxtr( u32 _w0, u32 _w1 )
void RDP_TriTxtr(const Gwords words)
{
gDPTriTxtr(_w0, _w1);
gDPTriTxtr(words.w0, words.w1);
}
void RDP_TriShadeTxtr( u32 _w0, u32 _w1 )
void RDP_TriShadeTxtr(const Gwords words)
{
gDPTriShadeTxtr(_w0, _w1);
gDPTriShadeTxtr(words.w0, words.w1);
}
void RDP_TriFillZ( u32 _w0, u32 _w1 )
void RDP_TriFillZ(const Gwords words)
{
gDPTriFillZ(_w0, _w1);
gDPTriFillZ(words.w0, words.w1);
}
void RDP_TriShadeZ( u32 _w0, u32 _w1 )
void RDP_TriShadeZ(const Gwords words)
{
gDPTriShadeZ(_w0, _w1);
gDPTriShadeZ(words.w0, words.w1);
}
void RDP_TriTxtrZ( u32 _w0, u32 _w1 )
void RDP_TriTxtrZ(const Gwords words)
{
gDPTriTxtrZ(_w0, _w1);
gDPTriTxtrZ(words.w0, words.w1);
}
void RDP_TriShadeTxtrZ( u32 _w0, u32 _w1 )
void RDP_TriShadeTxtrZ(const Gwords words)
{
gDPTriShadeTxtrZ(_w0, _w1);
gDPTriShadeTxtrZ(words.w0, words.w1);
}
RDPInfo RDP;
@ -422,6 +437,9 @@ void RDP_Init()
GBI.cmd[G_TEXRECTFLIP] = RDP_TexRectFlip;
GBI.cmd[G_TEXRECT] = RDP_TexRect;
GBI.cmd[G_RDPNOOP] = RDP_NoOp;
#ifdef NATIVE
GBI.cmd[G_MARK_SEGMENT] = RDP_MarkSegment;
#endif
RDP.w0 = RDP.w1 = RDP.w2 = RDP.w3 = 0;
RDP.cmd_ptr = RDP.cmd_cur = 0;
@ -522,8 +540,8 @@ const u32 CmdLength[64] =
void RDP_Half_1( u32 _c )
{
u32 w0 = 0, w1 = _c;
u32 cmd = _SHIFTR( _c, 24, 8 );
word w0 = 0, w1 = _c;
word cmd = _SHIFTR( _c, 24, 8 );
if (cmd >= 0xc8 && cmd <=0xcf) {//triangle command
DebugMsg(DEBUG_NORMAL, "gDPHalf_1 LLE Triangle\n");
RDP.cmd_ptr = 0;
@ -532,41 +550,52 @@ void RDP_Half_1( u32 _c )
RDP.cmd_data[RDP.cmd_ptr++] = w1;
RSP_CheckDLCounter();
w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
w0 = *(word*)&RDRAM[RSP.PC[RSP.PCi]];
w1 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.cmd = _SHIFTR( w0, 24, 8 );
DebugMsg(DEBUG_NORMAL, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(w0, 24, 8), w0, w1);
DebugMsg(DEBUG_NORMAL, "0x%08lX: CMD=0x%02lX w0=0x%08lX w1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(w0, 24, 8), w0, w1);
RSP.PC[RSP.PCi] += 8;
RSP.PC[RSP.PCi] += sizeof(Gwords);
// RSP.nextCmd = _SHIFTR( *(u32*)&RDRAM[RSP.PC[RSP.PCi]], 24, 8 );
} while (RSP.cmd != 0xb3);
RDP.cmd_data[RDP.cmd_ptr++] = w1;
RSP.cmd = (RDP.cmd_data[RDP.cmd_cur] >> 24) & 0x3f;
w0 = RDP.cmd_data[RDP.cmd_cur+0];
w1 = RDP.cmd_data[RDP.cmd_cur+1];
LLEcmd[RSP.cmd](w0, w1);
LLEcmd[RSP.cmd](Gwords(w0, w1));
LLETriangle::get().flush(cmd);
} else {
DebugMsg(DEBUG_NORMAL | DEBUG_IGNORED, "gDPHalf_1()\n");
}
}
#ifdef NATIVE
#define rdram ((u32*)0)
#define rsp_dmem ((u32*)0)
#else
#define rdram ((u32*)RDRAM)
#define rsp_dmem ((u32*)DMEM)
#endif
#define dp_start (*(u32*)REG.DPC_START)
#define dp_end (*(u32*)REG.DPC_END)
#define dp_current (*(u32*)REG.DPC_CURRENT)
#define dp_status (*(u32*)REG.DPC_STATUS)
#define dp_start (*(word*)REG.DPC_START)
#define dp_end (*(word*)REG.DPC_END)
#define dp_current (*(word*)REG.DPC_CURRENT)
#define dp_status (*(word*)REG.DPC_STATUS)
inline u32 READ_RDP_DATA(u32 address)
#ifdef NATIVE
inline u32 READ_RDP_DATA(word address) {
return rsp_dmem[(address & 0xfff) >> 2];
}
#else
inline u32 READ_RDP_DATA(word address)
{
if (dp_status & 0x1) // XBUS_DMEM_DMA enabled
return rsp_dmem[(address & 0xfff)>>2];
else
return rdram[(address & 0xffffff)>>2];
}
#endif
void RDP_ProcessRDPList()
{
@ -590,7 +619,7 @@ void RDP_ProcessRDPList()
bool setZero = true;
while (RDP.cmd_cur != RDP.cmd_ptr) {
u32 cmd = (RDP.cmd_data[RDP.cmd_cur] >> 24) & 0x3f;
word cmd = (RDP.cmd_data[RDP.cmd_cur] >> 24) & 0x3f;
if ((((RDP.cmd_ptr - RDP.cmd_cur)&maxCMDMask) * 4) < CmdLength[cmd]) {
setZero = false;
@ -607,10 +636,10 @@ void RDP_ProcessRDPList()
RDP.w3 = RDP.cmd_data[RDP.cmd_cur + 3];
RSP.cmd = cmd;
#ifdef DEBUG_DUMP
DebugMsg(DEBUG_LOW, "CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", cmd, RDP.w0, RDP.w1);
DebugMsg(DEBUG_LOW, "CMD=0x%02lX words.w0=0x%08lX words.w1=0x%08lX\n", cmd, RDP.w0, RDP.w1);
#endif
LLETriangle::get().flush(cmd);
LLEcmd[cmd](RDP.w0, RDP.w1);
LLEcmd[cmd](Gwords(RDP.w0, RDP.w1));
RDP.cmd_cur = (RDP.cmd_cur + CmdLength[cmd] / 4) & maxCMDMask;
}

View File

@ -6,24 +6,24 @@ const unsigned int maxCMDMask = MAXCMD - 1;
typedef struct
{
u32 w0, w1, w2, w3;
u32 cmd_ptr;
u32 cmd_cur;
u32 cmd_data[MAXCMD + 32];
word w0, w1, w2, w3;
word cmd_ptr;
word cmd_cur;
word cmd_data[MAXCMD + 32];
} RDPInfo;
extern RDPInfo RDP;
void RDP_Init();
void RDP_Half_1(u32 _c);
void RDP_TexRect(u32 w0, u32 w1);
void RDP_TexRect(const Gwords words);
void RDP_ProcessRDPList();
void RDP_RepeatLastLoadBlock();
void RDP_SetScissor(u32 w0, u32 w1);
void RDP_SetTImg(u32 w0, u32 w1);
void RDP_LoadBlock(u32 w0, u32 w1);
void RDP_SetTile(u32 w0, u32 w1);
void RDP_SetTileSize(u32 w0, u32 w1);
void RDP_SetScissor(const Gwords words);
void RDP_SetTImg(const Gwords words);
void RDP_LoadBlock(const Gwords words);
void RDP_SetTile(const Gwords words);
void RDP_SetTileSize(const Gwords words);
#endif

View File

@ -18,6 +18,10 @@
#include "TextureFilterHandler.h"
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace std;
#define SP_STATUS_HALT 0x0001
@ -30,7 +34,8 @@ static
void _ProcessDList()
{
while (!RSP.halt) {
if ((RSP.PC[RSP.PCi] + 8) > RDRAMSize) {
#ifndef NATIVE
if ((RSP.PC[RSP.PCi] + sizeof(Gwords)) > RDRAMSize) {
#ifdef DEBUG_DUMP
if ((config.debug.dumpMode & DEBUG_DETAIL) != 0)
DebugMsg(DEBUG_DETAIL | DEBUG_ERROR, "// Attempting to execute RSP command at invalid RDRAM location\n");
@ -41,22 +46,27 @@ void _ProcessDList()
#endif
break;
}
RSP.w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
RSP.w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.cmd = _SHIFTR(RSP.w0, 24, 8);
#ifdef DEBUG_DUMP
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.w0, 24, 8), RSP.w0, RSP.w1);
#endif
RSP.PC[RSP.PCi] += 8;
u32 pci = RSP.PCi;
#ifdef NATIVE
RSP.words = *(Gwords*)(RSP.PC[RSP.PCi]);
RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8);
#else
RSP.words = *(Gwords*)&RDRAM[RSP.PC[RSP.PCi]];
RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8);
#endif
#ifdef DEBUG_DUMP
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.words.w0, 24, 8), RSP.words.w0, RSP.words.w1);
#endif
RSP.PC[RSP.PCi] += sizeof(Gwords);
auto pci = RSP.PCi;
if (RSP.count == 1)
--pci;
RSP.nextCmd = _SHIFTR(*(u32*)&RDRAM[RSP.PC[pci]], 24, 8);
RSP.nextCmd = _SHIFTR(*(word*)&RDRAM[RSP.PC[pci]], 24, 8);
GBI.cmd[RSP.cmd](RSP.w0, RSP.w1);
GBI.cmd[RSP.cmd](RSP.words);
RSP_CheckDLCounter();
}
}
@ -65,32 +75,34 @@ static
void _ProcessDListFactor5()
{
// Lemmy's note: read first 64 bits of this dlist
RSP.F5DL[0] = _SHIFTR(*(u32*)&RDRAM[RSP.PC[0]], 0, 24);
RSP.PC[0] += 8;
RSP.F5DL[0] = _SHIFTR(*(word*)&RDRAM[RSP.PC[0]], 0, 24);
RSP.PC[0] += sizeof(Gwords);
#ifndef NATIVE
static u32 vAddrToClear[7] = { 0x11C >> 2, 0x120 >> 2, 0x124 >> 2, 0x37C >> 2,
0x58C >> 2, 0x5B0 >> 2, 0x5B4 >> 2};
u32 * pDmem32 = reinterpret_cast<u32*>(DMEM);
word * pDmem32 = reinterpret_cast<word*>(DMEM);
for (u32 i = 0; i < 7; ++i)
pDmem32[vAddrToClear[i]] = 0U;
#endif
while (!RSP.halt) {
if ((RSP.PC[RSP.PCi] + 8) > RDRAMSize) {
if ((RSP.PC[RSP.PCi] + sizeof(Gwords)) > RDRAMSize) {
break;
}
RSP.w0 = *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
RSP.w1 = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 4];
RSP.cmd = _SHIFTR(RSP.w0, 24, 8);
RSP.words.w0 = *(word*)&RDRAM[RSP.PC[RSP.PCi]];
RSP.words.w1 = *(word*)&RDRAM[RSP.PC[RSP.PCi] + sizeof(word)];
RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8);
#ifdef DEBUG_DUMP
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.w0, 24, 8), RSP.w0, RSP.w1);
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.words.w0, 24, 8), RSP.words.w0, RSP.words.w1);
#endif
RSP.nextCmd = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi] + 8], 24, 8);
RSP.nextCmd = _SHIFTR(*(word*)&RDRAM[RSP.PC[RSP.PCi] + sizeof(Gwords)], 24, 8);
GBI.cmd[RSP.cmd](RSP.w0, RSP.w1);
RSP.PC[RSP.PCi] += 8;
GBI.cmd[RSP.cmd](RSP.words);
RSP.PC[RSP.PCi] += sizeof(Gwords);
RSP_CheckDLCounter();
}
}
@ -107,10 +119,14 @@ void RSP_CheckDLCounter()
}
}
void RSP_ProcessDList()
void RSP_ProcessDList(void* displayList, word displayListLength, void* uc_start, void* uc_dstart, word uc_dsize, u32 matrixStackSize, void* ZSortBOSS_pc)
{
RSP.LLE = false;
if (displayList == nullptr) {
return;
}
if (ConfigOpen || dwnd().isResizeWindow()) {
*REG.MI_INTR |= MI_INTR_DP;
CheckInterrupts();
@ -126,14 +142,16 @@ void RSP_ProcessDList()
dwnd().updateScale();
}
RSP.PC[0] = *(u32*)&DMEM[0x0FF0];
RSP.PC[0] = (word)displayList;
RSP.PCi = 0;
RSP.count = -1;
RSP.halt = false;
RSP.busy = true;
gSP.matrix.stackSize = min( 32U, *(u32*)&DMEM[0x0FE4] >> 6 );
gSP.matrix.stackSize = min(32U, matrixStackSize >> 6);
if (gSP.matrix.stackSize == 0)
gSP.matrix.stackSize = 32;
gSP.matrix.modelViewi = 0;
@ -146,22 +164,23 @@ void RSP_ProcessDList()
gDPSetTexturePersp(G_TP_PERSP);
// Get the start of the display list and the length of it
const u32 dlist_start = *(u32*)(DMEM + 0xFF0);
const u32 dlist_length = *(u32*)(DMEM + 0xFF4);
const word dlist_start = *(word*)displayList;
const word dlist_length = displayListLength;
DebugMsg(DEBUG_NORMAL, "--- NEW DLIST --- ucode: %d, fbuf: %08lx, fbuf_width: %d, dlist start: %08lx, dlist_length: %d, x_scale: %f, y_scale: %f\n",
GBI.getMicrocodeType(), *REG.VI_ORIGIN, *REG.VI_WIDTH, dlist_start, dlist_length, (*REG.VI_X_SCALE & 0xFFF) / 1024.0f, (*REG.VI_Y_SCALE & 0xFFF) / 1024.0f);
u32 uc_start = *(u32*)&DMEM[0x0FD0];
u32 uc_dstart = *(u32*)&DMEM[0x0FD8];
u32 uc_dsize = *(u32*)&DMEM[0x0FDC];
if ((uc_start != RSP.uc_start) || (uc_dstart != RSP.uc_dstart))
gSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize);
if (((word)uc_start != RSP.uc_start) || ((word)uc_dstart != RSP.uc_dstart))
gSPLoadUcodeEx((word)uc_start, (word)uc_dstart, uc_dsize);
depthBufferList().setCleared(false);
if (GBI.getMicrocodeType() == ZSortBOSS) {
RSP.PC[1] = *(u32*)&DMEM[0xff8];
#ifdef NATIVE
RSP.PC[1] = (word)ZSortBOSS_pc;
#else
RSP.PC[1] = *(word*)&DMEM[0xff8];
#endif
*REG.SP_STATUS &= ~0x300; // clear sig1 | sig2
*REG.SP_STATUS |= 0x800; // set sig4
}
@ -202,6 +221,12 @@ void RSP_ProcessDList()
gDP.changed |= CHANGED_COLORBUFFER;
}
void RSP_ProcessDList() {
RSP_ProcessDList((void*)*(word*)&DMEM[0x0FF0], *(word*)(DMEM + 0xFF4), (void*)*(word*)&DMEM[0x0FD0],
(void*)*(word*)&DMEM[0x0FD8], *(word*)&DMEM[0x0FDC], *(u32*)&DMEM[0x0FE4],
(void*)*(word*)&DMEM[0xff8]);
}
static
void RSP_SetDefaultState()
{
@ -246,10 +271,11 @@ void setDepthClearColor()
DepthClearColor = 0xFFFCFFFC;
}
void RSP_Init()
void RSP_Init(const char* romName)
{
if (RDRAMSize == 0) {
#ifdef OS_WINDOWS
#if defined(OS_WINDOWS) && !defined(NATIVE)
// Calculate RDRAM size by intentionally causing an access violation
u32 test;
try
@ -273,6 +299,13 @@ void RSP_Init()
RSP.LLE = false;
RSP.infloop = false;
#ifdef NATIVE
RSP.translateSegment = false;
#endif
#ifdef NATIVE
const char* romname = romName;
#else
// get the name of the ROM
char romname[21];
for (int i = 0; i < 20; ++i)
@ -282,6 +315,7 @@ void RSP_Init()
// remove all trailing spaces
while (romname[strlen(romname) - 1] == ' ')
romname[strlen(romname) - 1] = 0;
#endif
if (strcmp(RSP.romname, romname) != 0)
TFH.shutdown();

View File

@ -4,15 +4,20 @@
#include "Types.h"
#include "N64.h"
#define MAX_SEGMENTS 16
typedef struct
{
u32 PC[18], PCi;
u32 F5DL[10];
u32 uc_start, uc_dstart, cmd, nextCmd;
u32 w0, w1;
word PC[18], PCi;
word F5DL[10];
word uc_start, uc_dstart, cmd, nextCmd;
Gwords words;
s32 count;
bool busy, halt, infloop;
bool LLE;
#ifdef NATIVE
bool translateSegment;
#endif
char romname[21];
wchar_t pluginpath[PLUGIN_PATH_SIZE];
} RSPInfo;
@ -22,11 +27,26 @@ extern RSPInfo RSP;
extern u32 DepthClearColor;
extern u32 rectDepthBufferCopyFrame;
#define RSP_SegmentToPhysical( segaddr ) ((gSP.segment[(segaddr >> 24) & 0x0F] + (segaddr & RDRAMSize)) & RDRAMSize)
#ifdef NATIVE
//#define RSP_SegmentToPhysical( segaddr ) ((segaddr < (16 << 24)) ? ((gSP.segment[(segaddr >> 24) & 0x0F] + segaddr)) : segaddr)
//#define RSP_SegmentToPhysical( segaddr ) ((RSP_SegmentToPhysical2(segaddr) & 0x00FFFF00) != 0 ? segaddr : ((gSP.segment[(segaddr >> 24) & 0x0F] + segaddr)))
//#define RSP_SegmentToPhysical(segaddr) (segaddr)
void RSP_Init();
word RSP_SegmentToPhysical(word segaddr);
#define SEGMENT_MASK(addr) (addr)
#else
#define SEGMENT_MASK(addr) (addr & 0x00FFFFFF)
#define RSP_SegmentToPhysical( segaddr ) ((gSP.segment[(segaddr >> 24) & 0x0F] + (segaddr & RDRAMSize)) & RDRAMSize)
#endif
void RSP_Init(const char* romName = nullptr);
void RSP_ProcessDList(void* displayList, word displayListLength, void* uc_start, void* uc_dstart, word uc_dsize, u32 matrixStackSize = 0, void* ZSortBOSS_pc = nullptr);
void RSP_ProcessDList();
void RSP_LoadMatrix( f32 mtx[4][4], u32 address );
void RSP_LoadMatrix( f32 mtx[4][4], word address );
void RSP_CheckDLCounter();
#endif

View File

@ -1,7 +1,9 @@
#include "RSP.h"
#include "3DMath.h"
void RSP_LoadMatrix( f32 mtx[4][4], u32 address )
#define ENDIAN_BIT_SWAP 0
void RSP_LoadMatrix( f32 mtx[4][4], word address )
{
struct _N64Matrix
{
@ -9,7 +11,13 @@ void RSP_LoadMatrix( f32 mtx[4][4], u32 address )
u16 fraction[4][4];
} *n64Mat = (struct _N64Matrix *)&RDRAM[address];
#ifdef NATIVE2
for (u32 i = 0; i < 4; i++)
for (u32 j = 0; j < 4; j++)
mtx[i][j] = GetFloatMatrixElement(n64Mat->integer[i][j ^ 1], n64Mat->fraction[i][j ^ 1]);
mtx[i][j] = GetFloatMatrixElement(n64Mat->integer[i][j], n64Mat->fraction[i][j]);
#else
for (u32 i = 0; i < 4; i++)
for (u32 j = 0; j < 4; j++)
mtx[i][j] = GetFloatMatrixElement(n64Mat->integer[i][j ^ ENDIAN_BIT_SWAP], n64Mat->fraction[i][j ^ ENDIAN_BIT_SWAP]);
#endif
}

View File

@ -2,7 +2,7 @@
#include "RSP.h"
#include "GBI.h"
void RSP_LoadMatrix( f32 mtx[4][4], u32 address )
void RSP_LoadMatrix( f32 mtx[4][4], word address )
{
f32 recip = FIXED2FLOATRECIP16;
#if defined (WIN32_ASM)

View File

@ -115,7 +115,7 @@ void TexrectDrawer::_setDrawBuffer()
frameBufferList().setCurrentDrawBuffer();
}
TexrectDrawer::iRect TexrectDrawer::_getiRect(u32 w0, u32 w1) const
TexrectDrawer::iRect TexrectDrawer::_getiRect(word w0, word w1) const
{
iRect rect;
rect.ulx = _SHIFTR(w1, 12, 12);
@ -141,9 +141,9 @@ bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
return true;
}
auto sideBySide = [&](u32 pc) ->bool {
const u32 w0 = *(u32*)&RDRAM[pc];
const u32 w1 = *(u32*)&RDRAM[pc + 4];
auto sideBySide = [&](word pc) ->bool {
const word w0 = *(word*)&RDRAM[pc];
const word w1 = *(word*)&RDRAM[pc + sizeof(word)];
const iRect nextRect = _getiRect(w0, w1);
if (COMPARE_COORDS(m_curRect.ulx, nextRect.ulx)) {

View File

@ -49,7 +49,7 @@ private:
struct iRect {
s32 ulx = 0, uly = 0, lrx = 0, lry = 0;
};
iRect _getiRect(u32 w0, u32 w1) const;
iRect _getiRect(word w0, word w1) const;
iRect m_curRect;
};

View File

@ -21,6 +21,10 @@
#include "Graphics/Parameters.h"
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace std;
using namespace graphics;
@ -1092,8 +1096,13 @@ void TextureCache::_getTextureDestData(CachedTexture& tmptex,
tx = min(x, clampSClamp) & maskSMask;
u32 taddr = ((tline + tx) ^ xorval) & 0x3ff;
#ifdef NATIVE
gr = tmem16[taddr];
ab = tmem16[taddr | 0x400];
#else
gr = swapword(tmem16[taddr]);
ab = swapword(tmem16[taddr | 0x400]);
#endif
pDest[j++] = (ab << 16) | gr;
}
}

View File

@ -61,4 +61,43 @@ private:
T m_val;
};
#include "porting.h"
struct Gwords {
Gwords();
Gwords(word _w0, word _w1);
word w0;
word w1;
#ifdef EXTENDED_GFX
word w2;
word w3;
Gwords(word _w0, word _w1, word _w2, word _w3);
#endif
};
#ifdef EXTENDED_GFX
static_assert(sizeof(Gwords) == sizeof(word) * 4, "Gwords is incorrect size");
#else
static_assert(sizeof(Gwords) == sizeof(word) * 2, "Gwords is incorrect size");
#endif
struct RGBA8
{
#ifdef NATIVE
u8 a;
u8 b;
u8 g;
u8 r;
#else
u8 r;
u8 g;
u8 b;
u8 a;
#endif
};
static_assert(sizeof(RGBA8) == 4);
#endif // TYPES_H

View File

@ -32,6 +32,10 @@ u16 VI_GetMaxBufferHeight(u16 _width)
void VI_UpdateSize()
{
#ifdef NATIVE2
VI.width = 320;
VI.height = 240;
#else
const f32 xScale = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 0, 12 ), 10 );
// f32 xOffset = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 16, 12 ), 10 );
@ -94,6 +98,7 @@ void VI_UpdateSize()
depthBufferList().destroy();
depthBufferList().init();
}
#endif
VI.rwidth = VI.width != 0 ? 1.0f / VI.width : 0.0f;
VI.rheight = VI.height != 0 ? 1.0f / VI.height : 0.0f;

View File

@ -19,6 +19,10 @@ the plugin
#ifndef _GFX_H_INCLUDED__
#define _GFX_H_INCLUDED__
#ifndef word
#include "porting.h"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@ -56,36 +60,38 @@ typedef struct {
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
#ifndef NATIVE
unsigned char * HEADER; /* This is the rom header (first 40h bytes of the rom) */
unsigned char * RDRAM;
unsigned char * DMEM;
unsigned char * IMEM;
#endif
unsigned int * MI_INTR_REG;
word * MI_INTR_REG;
unsigned int * DPC_START_REG;
unsigned int * DPC_END_REG;
unsigned int * DPC_CURRENT_REG;
unsigned int * DPC_STATUS_REG;
unsigned int * DPC_CLOCK_REG;
unsigned int * DPC_BUFBUSY_REG;
unsigned int * DPC_PIPEBUSY_REG;
unsigned int * DPC_TMEM_REG;
word * DPC_START_REG;
word * DPC_END_REG;
word * DPC_CURRENT_REG;
word * DPC_STATUS_REG;
word * DPC_CLOCK_REG;
word * DPC_BUFBUSY_REG;
word * DPC_PIPEBUSY_REG;
word * DPC_TMEM_REG;
unsigned int * VI_STATUS_REG;
unsigned int * VI_ORIGIN_REG;
unsigned int * VI_WIDTH_REG;
unsigned int * VI_INTR_REG;
unsigned int * VI_V_CURRENT_LINE_REG;
unsigned int * VI_TIMING_REG;
unsigned int * VI_V_SYNC_REG;
unsigned int * VI_H_SYNC_REG;
unsigned int * VI_LEAP_REG;
unsigned int * VI_H_START_REG;
unsigned int * VI_V_START_REG;
unsigned int * VI_V_BURST_REG;
unsigned int * VI_X_SCALE_REG;
unsigned int * VI_Y_SCALE_REG;
word * VI_STATUS_REG;
word * VI_ORIGIN_REG;
word * VI_WIDTH_REG;
word * VI_INTR_REG;
word * VI_V_CURRENT_LINE_REG;
word * VI_TIMING_REG;
word * VI_V_SYNC_REG;
word * VI_H_SYNC_REG;
word * VI_LEAP_REG;
word * VI_H_START_REG;
word * VI_V_START_REG;
word * VI_V_BURST_REG;
word * VI_X_SCALE_REG;
word * VI_Y_SCALE_REG;
void (*CheckInterrupts)( void );
} GFX_INFO;

View File

@ -157,8 +157,10 @@ void PluginAPI::ProcessDList()
#ifdef RSPTHREAD
_callAPICommand(ProcessDListCommand());
#else
#ifndef NATIVE
RSP_ProcessDList();
#endif
#endif
}
void PluginAPI::ProcessRDPList()
@ -196,7 +198,7 @@ void PluginAPI::RomClosed()
osal_keys_quit();
}
int PluginAPI::RomOpen()
int PluginAPI::RomOpen(const char* romName)
{
osal_keys_init();
@ -208,7 +210,8 @@ int PluginAPI::RomOpen()
m_pluginThreadCv.wait(m_pluginThreadMtx);
m_pluginThreadMtx.unlock();
#else
RSP_Init();
RSP_Init(romName);
GBI.init();
Config_LoadConfig();
if (!dwnd().start())
@ -236,10 +239,12 @@ void PluginAPI::UpdateScreen()
}
void PluginAPI::_initiateGFX(const GFX_INFO & _gfxInfo) const {
HEADER = _gfxInfo.HEADER;
#ifndef NATIVE
HEADER = _gfxInfo.HEADER;
DMEM = _gfxInfo.DMEM;
IMEM = _gfxInfo.IMEM;
RDRAM = _gfxInfo.RDRAM;
#endif
REG.MI_INTR = _gfxInfo.MI_INTR_REG;
REG.DPC_START = _gfxInfo.DPC_START_REG;

View File

@ -1,4 +1,5 @@
#include "convert.h"
#include <string.h>
const volatile unsigned char Five2Eight[32] =
{
@ -99,10 +100,13 @@ const volatile unsigned char One2Eight[2] =
255, // 1 = 11111111
};
void UnswapCopyWrap(const u8 *src, u32 srcIdx, u8 *dest, u32 destIdx, u32 destMask, u32 numBytes)
void UnswapCopyWrap(const u8 *src, word srcIdx, u8 *dest, word destIdx, word destMask, word numBytes)
{
#ifdef NATIVE
memcpy(dest + destIdx, src + srcIdx, numBytes);
#else
// copy leading bytes
u32 leadingBytes = srcIdx & 3;
word leadingBytes = srcIdx & 3;
if (leadingBytes != 0) {
leadingBytes = 4 - leadingBytes;
if (leadingBytes > numBytes)
@ -138,6 +142,7 @@ void UnswapCopyWrap(const u8 *src, u32 srcIdx, u8 *dest, u32 destIdx, u32 destMa
--srcIdx;
}
}
#endif
}
void DWordInterleaveWrap(u32 *src, u32 srcIdx, u32 srcMask, u32 numQWords)

View File

@ -11,12 +11,15 @@ extern const volatile unsigned char Two2Eight[4];
extern const volatile unsigned char One2Four[2];
extern const volatile unsigned char One2Eight[2];
void UnswapCopyWrap(const u8 *src, u32 srcIdx, u8 *dest, u32 destIdx, u32 destMask, u32 numBytes);
void UnswapCopyWrap(const u8 *src, word srcIdx, u8 *dest, word destIdx, word destMask, word numBytes);
void DWordInterleaveWrap(u32 *src, u32 srcIdx, u32 srcMask, u32 numQWords);
inline u16 swapword( u16 value )
{
#ifdef NATIVE2
return value;
#else
#ifdef WIN32_ASM
__asm
{
@ -26,6 +29,7 @@ inline u16 swapword( u16 value )
#else // WIN32_ASM
return (value << 8) | (value >> 8);
#endif // WIN32_ASM
#endif
}
inline u16 RGBA8888_RGBA4444( u32 color )

View File

@ -23,6 +23,10 @@
#include "DisplayWindow.h"
#include <Graphics/Context.h>
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace std;
gDPInfo gDP;
@ -165,7 +169,7 @@ void gDPSetCombine( u32 muxs0, u32 muxs1 )
#endif
}
void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address )
void gDPSetColorImage( u32 format, u32 size, u32 width, word address )
{
address = RSP_SegmentToPhysical( address );
@ -186,7 +190,7 @@ void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address )
#endif
}
void gDPSetTextureImage(u32 format, u32 size, u32 width, u32 address)
void gDPSetTextureImage(u32 format, u32 size, u32 width, word address)
{
gDP.textureImage.format = format;
gDP.textureImage.size = size;
@ -213,7 +217,7 @@ void gDPSetTextureImage(u32 format, u32 size, u32 width, u32 address)
#endif
}
void gDPSetDepthImage( u32 address )
void gDPSetDepthImage( word address )
{
address = RSP_SegmentToPhysical( address );
gDP.depthImageAddress = address;
@ -463,7 +467,7 @@ void gDPLoadTile32b(u32 uls, u32 ult, u32 lrs, u32 lrt)
const u32 height = lrt - ult + 1;
const u32 line = gDP.loadTile->line << 2;
const u32 tbase = gDP.loadTile->tmem << 2;
const u32 addr = gDP.textureImage.address >> 2;
const word addr = gDP.textureImage.address >> 2;
const u32 * src = reinterpret_cast<const u32*>(RDRAM);
u16 * tmem16 = reinterpret_cast<u16*>(TMEM);
u32 c, ptr, tline, s, xorval;
@ -475,8 +479,13 @@ void gDPLoadTile32b(u32 uls, u32 ult, u32 lrs, u32 lrt)
for (u32 i = 0; i < width; ++i) {
c = src[addr + s + i];
ptr = ((tline + i) ^ xorval) & 0x3ff;
#ifdef NATIVE
tmem16[ptr | 0x400] = c >> 16;
tmem16[ptr] = c & 0xffff;
#else
tmem16[ptr] = c >> 16;
tmem16[ptr | 0x400] = c & 0xffff;
#endif
}
}
}
@ -542,7 +551,7 @@ void gDPLoadTile(u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt)
gDP.loadTile->loadHeight = max(gDP.loadTile->loadHeight, info.height);
}
u32 address = gDP.textureImage.address + gDP.loadTile->ult * gDP.textureImage.bpl + (gDP.loadTile->uls << gDP.textureImage.size >> 1);
word address = gDP.textureImage.address + gDP.loadTile->ult * gDP.textureImage.bpl + (gDP.loadTile->uls << gDP.textureImage.size >> 1);
u32 bpl2 = bpl;
if (gDP.loadTile->lrs > gDP.textureImage.width)
bpl2 = (gDP.textureImage.width - gDP.loadTile->uls);
@ -556,9 +565,9 @@ void gDPLoadTile(u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt)
if (gDP.loadTile->size == G_IM_SIZ_32b)
gDPLoadTile32b(gDP.loadTile->uls, gDP.loadTile->ult, gDP.loadTile->lrs, gDP.loadTile->lrt);
else {
u32 tmemAddr = gDP.loadTile->tmem;
const u32 line = gDP.loadTile->line;
const u32 qwpr = bpr >> 3;
word tmemAddr = gDP.loadTile->tmem;
const word line = gDP.loadTile->line;
const word qwpr = bpr >> 3;
for (u32 y = 0; y < height; ++y) {
if (address + bpl > RDRAMSize)
UnswapCopyWrap(RDRAM, address, reinterpret_cast<u8*>(TMEM), tmemAddr << 3, 0xFFF, RDRAMSize - address);
@ -589,7 +598,7 @@ void gDPLoadBlock32(u32 uls,u32 lrs, u32 dxt)
const u32 line = gDP.loadTile->line << 2;
u16 *tmem16 = reinterpret_cast<u16*>(TMEM);
u32 addr = gDP.loadTile->imageAddress >> 2;
word addr = gDP.loadTile->imageAddress >> 2;
u32 width = (lrs - uls + 1) << 2;
if (width == 4) // lr_s == 0, 1x1 texture
width = 1;
@ -610,12 +619,21 @@ void gDPLoadBlock32(u32 uls,u32 lrs, u32 dxt)
i += line;
ptr = ((tb + i) ^ t) & 0x3ff;
c = src[addr + i];
#ifdef NATIVE
tmem16[ptr | 0x400] = c >> 16;
tmem16[ptr] = c & 0xffff;
ptr = ((tb + i + 1) ^ t) & 0x3ff;
c = src[addr + i + 1];
tmem16[ptr | 0x400] = c >> 16;
tmem16[ptr] = c & 0xffff;
#else
tmem16[ptr] = c >> 16;
tmem16[ptr | 0x400] = c & 0xffff;
ptr = ((tb + i + 1) ^ t) & 0x3ff;
c = src[addr + i + 1];
tmem16[ptr] = c >> 16;
tmem16[ptr | 0x400] = c & 0xffff;
#endif
j += dxt;
}
} else {
@ -623,8 +641,13 @@ void gDPLoadBlock32(u32 uls,u32 lrs, u32 dxt)
for (u32 i = 0; i < width; i++) {
ptr = ((tb + i) ^ 1) & 0x3ff;
c = src[addr + i];
#ifdef NATIVE
tmem16[ptr | 0x400] = c >> 16;
tmem16[ptr] = c & 0xffff;
#else
tmem16[ptr] = c >> 16;
tmem16[ptr | 0x400] = c & 0xffff;
#endif
}
}
}
@ -664,7 +687,14 @@ void gDPLoadBlock(u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt)
bytes = (bytes & (~7U)) + 8;
info.bytes = bytes;
u32 address = gDP.textureImage.address + ult * gDP.textureImage.bpl + (uls << gDP.textureImage.size >> 1);
word address = gDP.textureImage.address + ult * gDP.textureImage.bpl + (uls << gDP.textureImage.size >> 1);
#ifdef NATIVE
if(address == 0 || address == 0xCDCDCDCD)
{
return;
}
#endif
if (bytes == 0 || (address + bytes) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load texture block out of range\n");
@ -730,7 +760,7 @@ void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt )
return;
}
u16 count = static_cast<u16>((gDP.tiles[tile].lrs - gDP.tiles[tile].uls + 1) * (gDP.tiles[tile].lrt - gDP.tiles[tile].ult + 1));
u32 address = gDP.textureImage.address + gDP.tiles[tile].ult * gDP.textureImage.bpl + (gDP.tiles[tile].uls << gDP.textureImage.size >> 1);
word address = gDP.textureImage.address + gDP.tiles[tile].ult * gDP.textureImage.bpl + (gDP.tiles[tile].uls << gDP.textureImage.size >> 1);
u16 pal = static_cast<u16>((gDP.tiles[tile].tmem - 256) >> 4);
u16 * dest = reinterpret_cast<u16*>(TMEM);
u32 destIdx = gDP.tiles[tile].tmem << 2;
@ -738,7 +768,12 @@ void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt )
int i = 0;
while (i < count) {
for (u16 j = 0; (j < 16) && (i < count); ++j, ++i) {
#ifdef NATIVE
//dest[(destIdx | 0x0400) & 0x07FF] = *reinterpret_cast<u16*>(RDRAM + (address ^ 2));
dest[(destIdx) & 0x07FF] = *reinterpret_cast<u16*>(RDRAM + (address));
#else
dest[(destIdx | 0x0400) & 0x07FF] = swapword(*reinterpret_cast<u16*>(RDRAM + (address ^ 2)));
#endif
address += 2;
destIdx += 4;
}
@ -984,9 +1019,16 @@ void gDPTileSync()
DebugMsg( DEBUG_NORMAL | DEBUG_IGNORED, "gDPTileSync();\n" );
}
void gDPPipeSync()
void gDPPipeSync(const Gwords words)
{
const word line = _SHIFTR(words.w0, 0, 16);
const char* file = (const char*)words.w1;
DebugMsg( DEBUG_NORMAL | DEBUG_IGNORED, "gDPPipeSync();\n" );
if (line && file) {
DebugMsg(DEBUG_NORMAL, "\nLINE %s : %d;\n\n", file, line);
}
}
void gDPLoadSync()
@ -994,9 +1036,16 @@ void gDPLoadSync()
DebugMsg( DEBUG_NORMAL | DEBUG_IGNORED, "gDPLoadSync();\n" );
}
void gDPNoOp()
void gDPNoOp(const Gwords words)
{
DebugMsg( DEBUG_NORMAL | DEBUG_IGNORED, "gDPNoOp();\n" );
const word line = _SHIFTR(words.w0, 0, 16);
const char* file = (const char*)words.w1;
DebugMsg(DEBUG_NORMAL | DEBUG_IGNORED, "gDPNoOp();\n");
if (line && file) {
DebugMsg(DEBUG_NORMAL, "\nLINE %s : %d;\n\n", file, line);
}
}
LLETriangle::LLETriangle()
@ -1403,7 +1452,7 @@ void LLETriangle::draw(bool _shade, bool _texture, bool _zbuffer, u32 * _pData)
}
}
void gDPTriFill(u32 w0, u32 w1)
void gDPTriFill(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 8 * sizeof(s32));
@ -1412,7 +1461,7 @@ void gDPTriFill(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "trifill\n");
}
void gDPTriShade(u32 w0, u32 w1)
void gDPTriShade(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 24 * sizeof(s32));
@ -1421,7 +1470,7 @@ void gDPTriShade(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "trishade\n");
}
void gDPTriTxtr(u32 w0, u32 w1)
void gDPTriTxtr(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 8 * sizeof(s32));
@ -1432,7 +1481,7 @@ void gDPTriTxtr(u32 w0, u32 w1)
DebugMsg(DEBUG_NORMAL, "tritxtr\n");
}
void gDPTriShadeTxtr(u32 w0, u32 w1)
void gDPTriShadeTxtr(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 40 * sizeof(s32));
@ -1441,7 +1490,7 @@ void gDPTriShadeTxtr(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "trishadetxtr\n");
}
void gDPTriFillZ(u32 w0, u32 w1)
void gDPTriFillZ(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 8 * sizeof(s32));
@ -1451,7 +1500,7 @@ void gDPTriFillZ(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "trifillz\n");
}
void gDPTriShadeZ(u32 w0, u32 w1)
void gDPTriShadeZ(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 24 * sizeof(s32));
@ -1461,7 +1510,7 @@ void gDPTriShadeZ(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "trishadez\n");
}
void gDPTriTxtrZ(u32 w0, u32 w1)
void gDPTriTxtrZ(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 8 * sizeof(s32));
@ -1472,7 +1521,7 @@ void gDPTriTxtrZ(u32 w0, u32 w1)
DebugMsg( DEBUG_NORMAL, "tritxtrz\n");
}
void gDPTriShadeTxtrZ(u32 w0, u32 w1)
void gDPTriShadeTxtrZ(word w0, word w1)
{
u32 ewdata[44];
memcpy(&ewdata[0], RDP.cmd_data + RDP.cmd_cur, 44 * sizeof(s32));

View File

@ -237,13 +237,13 @@ struct gDPInfo
struct
{
u32 format, size, width, bpl;
u32 address;
word address;
} textureImage;
struct
{
u32 format, size, width, height, bpl;
u32 address, changed;
word address, changed;
} colorImage;
u32 depthImageAddress;
@ -297,9 +297,9 @@ void gDPSetPrimDepth( u16 z, u16 dz );
void gDPSetTexturePersp( u32 enable );
void gDPSetTextureLUT( u32 mode );
void gDPSetCombine( u32 muxs0, u32 muxs1 );
void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address );
void gDPSetTextureImage( u32 format, u32 size, u32 width, u32 address );
void gDPSetDepthImage( u32 address );
void gDPSetColorImage( u32 format, u32 size, u32 width, word address );
void gDPSetTextureImage( u32 format, u32 size, u32 width, word address );
void gDPSetDepthImage( word address );
void gDPSetEnvColor( u32 r, u32 g, u32 b, u32 a );
void gDPSetBlendColor( u32 r, u32 g, u32 b, u32 a );
void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a );
@ -319,18 +319,18 @@ void gDPSetKeyGB(u32 cG, u32 sG, u32 wG, u32 cB, u32 sB, u32 wB );
void gDPTextureRectangle( f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, s16 s, s16 t, f32 dsdx, f32 dtdy, bool flip );
void gDPFullSync();
void gDPTileSync();
void gDPPipeSync();
void gDPPipeSync(const Gwords words);
void gDPLoadSync();
void gDPNoOp();
void gDPNoOp(const Gwords words);
void gDPTriFill( u32 w0, u32 w1 );
void gDPTriShade( u32 w0, u32 w1 );
void gDPTriTxtr( u32 w0, u32 w1 );
void gDPTriShadeTxtr( u32 w0, u32 w1 );
void gDPTriFillZ( u32 w0, u32 w1 );
void gDPTriShadeZ( u32 w0, u32 w1 );
void gDPTriTxtrZ( u32 w0, u32 w1 );
void gDPTriShadeTxtrZ( u32 w0, u32 w1 );
void gDPTriFill( word w0, word w1 );
void gDPTriShade( word w0, word w1 );
void gDPTriTxtr( word w0, word w1 );
void gDPTriShadeTxtr( word w0, word w1 );
void gDPTriFillZ( word w0, word w1 );
void gDPTriShadeZ( word w0, word w1 );
void gDPTriTxtrZ( word w0, word w1 );
void gDPTriShadeTxtrZ( word w0, word w1 );
bool isCurrentColorImageDepthImage();
bool isDepthCompareEnabled();

View File

@ -19,6 +19,10 @@
#include "Log.h"
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
using namespace std;
using namespace graphics;
@ -127,7 +131,7 @@ f32 identityMatrix[4][4] =
{ 0.0f, 0.0f, 0.0f, 1.0f }
};
void gSPLoadUcodeEx( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
void gSPLoadUcodeEx( word uc_start, word uc_dstart, u16 uc_dsize )
{
gSP.matrix.modelViewi = 0;
gSP.status[0] = gSP.status[1] = gSP.status[2] = gSP.status[3] = 0;
@ -136,10 +140,12 @@ void gSPLoadUcodeEx( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
gSP.geometryMode = 0U;
gSP.changed |= CHANGED_MATRIX | CHANGED_LIGHT | CHANGED_LOOKAT | CHANGED_GEOMETRYMODE;
#ifndef NATIVE
if ((((uc_start & 0x1FFFFFFF) + 4096) > RDRAMSize) || (((uc_dstart & 0x1FFFFFFF) + uc_dsize) > RDRAMSize)) {
DebugMsg(DEBUG_NORMAL|DEBUG_ERROR, "gSPLoadUcodeEx out of RDRAM\n");
return;
}
#endif
GBI.loadMicrocode(uc_start, uc_dstart, uc_dsize);
RSP.uc_start = uc_start;
@ -158,7 +164,7 @@ void gSPMatrix( u32 matrix, u8 param )
{
f32 mtx[4][4];
u32 address = RSP_SegmentToPhysical( matrix );
word address = RSP_SegmentToPhysical( matrix );
if (address + 64 > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load matrix from invalid address\n");
@ -213,7 +219,7 @@ void gSPMatrix( u32 matrix, u8 param )
void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply )
{
f32 mtx[4][4];
u32 address = gSP.DMAOffsets.mtx + RSP_SegmentToPhysical( matrix );
word address = gSP.DMAOffsets.mtx + RSP_SegmentToPhysical( matrix );
if (address + 64 > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load matrix from invalid address\n");
@ -248,9 +254,19 @@ void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply )
mtx[3][0], mtx[3][1], mtx[3][2], mtx[3][3] );
}
extern "C" u64 gfx_width();
extern "C" u64 gfx_height();
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define HALF_SCREEN_WIDTH (SCREEN_WIDTH / 2)
#define HALF_SCREEN_HEIGHT (SCREEN_HEIGHT / 2)
#define RATIO_X (gfx_width() / (2.0f * HALF_SCREEN_WIDTH))
#define RATIO_Y (gfx_height() / (2.0f * HALF_SCREEN_HEIGHT))
void gSPViewport( u32 v )
{
u32 address = RSP_SegmentToPhysical( v );
word address = RSP_SegmentToPhysical( v );
if ((address + 16) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load viewport from invalid address\n");
@ -258,14 +274,28 @@ void gSPViewport( u32 v )
return;
}
gSP.viewport.vscale[0] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 2], 2 );
gSP.viewport.vscale[1] = _FIXED2FLOAT( *(s16*)&RDRAM[address ], 2 );
gSP.viewport.vscale[2] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 6], 10 );// * 0.00097847357f;
gSP.viewport.vscale[3] = *(s16*)&RDRAM[address + 4];
gSP.viewport.vtrans[0] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 10], 2 );
gSP.viewport.vtrans[1] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 8], 2 );
gSP.viewport.vtrans[2] = _FIXED2FLOAT( *(s16*)&RDRAM[address + 14], 10 );// * 0.00097847357f;
gSP.viewport.vtrans[3] = *(s16*)&RDRAM[address + 12];
#ifdef NATIVE
Vp_t* vp = (Vp_t*)address;
gSP.viewport.vscale[0] = _FIXED2FLOAT( vp->vscale.x, 2 );
gSP.viewport.vscale[1] = _FIXED2FLOAT( vp->vscale.y, 2 );
gSP.viewport.vscale[2] = _FIXED2FLOAT( vp->vscale.z, 10 );// * 0.00097847357f;
gSP.viewport.vscale[3] = vp->vscale.w;
gSP.viewport.vtrans[0] = _FIXED2FLOAT( vp->vtrans.x, 2 );
gSP.viewport.vtrans[1] = _FIXED2FLOAT( vp->vtrans.y, 2 );
gSP.viewport.vtrans[2] = _FIXED2FLOAT( vp->vtrans.z, 10 );// * 0.00097847357f;
gSP.viewport.vtrans[3] = vp->vtrans.w;
#else
gSP.viewport.vscale[0] = _FIXED2FLOAT( vp->vscale.y, 2 );
gSP.viewport.vscale[1] = _FIXED2FLOAT( vp->vscale.x, 2 );
gSP.viewport.vscale[2] = _FIXED2FLOAT( vp->vscale.w, 10 );// * 0.00097847357f;
gSP.viewport.vscale[3] = vp->vscale.z;
gSP.viewport.vtrans[0] = _FIXED2FLOAT( vp->vtrans.y, 2 );
gSP.viewport.vtrans[1] = _FIXED2FLOAT( vp->vtrans.x, 2 );
gSP.viewport.vtrans[2] = _FIXED2FLOAT( vp->vtrans.w, 10 );// * 0.00097847357f;
gSP.viewport.vtrans[3] = vp->vtrans.z;
#endif
if (gSP.viewport.vscale[1] < 0.0f && !GBI.isNegativeY())
gSP.viewport.vscale[1] = -gSP.viewport.vscale[1];
@ -277,6 +307,11 @@ void gSPViewport( u32 v )
gSP.viewport.nearz = gSP.viewport.vtrans[2] - gSP.viewport.vscale[2];
gSP.viewport.farz = (gSP.viewport.vtrans[2] + gSP.viewport.vscale[2]) ;
/*gSP.viewport.x *= RATIO_X;
gSP.viewport.y *= RATIO_Y;
gSP.viewport.width /= RATIO_X;
gSP.viewport.height /= RATIO_Y;*/
gSP.changed |= CHANGED_VIEWPORT;
DebugMsg(DEBUG_NORMAL, "gSPViewport scale(%02f, %02f, %02f), trans(%02f, %02f, %02f)\n",
@ -286,7 +321,7 @@ void gSPViewport( u32 v )
void gSPForceMatrix( u32 mptr )
{
u32 address = RSP_SegmentToPhysical( mptr );
word address = RSP_SegmentToPhysical( mptr );
if (address + 64 > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load from invalid address");
@ -304,7 +339,7 @@ void gSPForceMatrix( u32 mptr )
void gSPLight( u32 l, s32 n )
{
--n;
u32 addrByte = RSP_SegmentToPhysical( l );
word addrByte = RSP_SegmentToPhysical( l );
if ((addrByte + sizeof( Light )) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load light from invalid address\n");
@ -327,7 +362,7 @@ void gSPLight( u32 l, s32 n )
gSP.lights.xyz[n][Z] = light->z;
Normalize( gSP.lights.xyz[n] );
u32 addrShort = addrByte >> 1;
word addrShort = addrByte >> 1;
gSP.lights.pos_xyzw[n][X] = (float)(((short*)RDRAM)[(addrShort+4)^1]);
gSP.lights.pos_xyzw[n][Y] = (float)(((short*)RDRAM)[(addrShort+5)^1]);
gSP.lights.pos_xyzw[n][Z] = (float)(((short*)RDRAM)[(addrShort+6)^1]);
@ -348,7 +383,7 @@ void gSPLight( u32 l, s32 n )
void gSPLightCBFD( u32 l, s32 n )
{
u32 addrByte = RSP_SegmentToPhysical( l );
word addrByte = RSP_SegmentToPhysical( l );
if ((addrByte + sizeof( Light )) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load light from invalid address\n");
@ -371,7 +406,7 @@ void gSPLightCBFD( u32 l, s32 n )
gSP.lights.xyz[n][Z] = light->z;
Normalize( gSP.lights.xyz[n] );
u32 addrShort = addrByte >> 1;
word addrShort = addrByte >> 1;
gSP.lights.pos_xyzw[n][X] = (float)(((short*)RDRAM)[(addrShort+16)^1]);
gSP.lights.pos_xyzw[n][Y] = (float)(((short*)RDRAM)[(addrShort+17)^1]);
gSP.lights.pos_xyzw[n][Z] = (float)(((short*)RDRAM)[(addrShort+18)^1]);
@ -390,10 +425,10 @@ void gSPLightCBFD( u32 l, s32 n )
void gSPLightAcclaim(u32 l, s32 n)
{
u32 addrByte = RSP_SegmentToPhysical(l);
word addrByte = RSP_SegmentToPhysical(l);
if (n < 10) {
const u32 addrShort = addrByte >> 1;
const word addrShort = addrByte >> 1;
gSP.lights.pos_xyzw[n][X] = (f32)(((s16*)RDRAM)[(addrShort + 0) ^ 1]);
gSP.lights.pos_xyzw[n][Y] = (f32)(((s16*)RDRAM)[(addrShort + 1) ^ 1]);
gSP.lights.pos_xyzw[n][Z] = (f32)(((s16*)RDRAM)[(addrShort + 2) ^ 1]);
@ -415,7 +450,7 @@ void gSPLightAcclaim(u32 l, s32 n)
void gSPLookAt( u32 _l, u32 _n )
{
u32 address = RSP_SegmentToPhysical(_l);
word address = RSP_SegmentToPhysical(_l);
if ((address + sizeof(Light)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load light from invalid address\n");
@ -932,7 +967,7 @@ void gSPVertex(u32 a, u32 n, u32 v0)
return;
}
const u32 address = RSP_SegmentToPhysical(a);
const word address = RSP_SegmentToPhysical(a);
if ((address + sizeof(Vertex)* n) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "gSPVertex Using Vertex outside RDRAM n = %i, v0 = %i, from %08x\n", n, v0, a);
@ -1002,7 +1037,7 @@ void gSPCIVertex( u32 a, u32 n, u32 v0 )
return;
}
const u32 address = RSP_SegmentToPhysical( a );
const word address = RSP_SegmentToPhysical( a );
if ((address + sizeof( PDVertex ) * n) > RDRAMSize)
return;
@ -1025,7 +1060,7 @@ void gSPCIVertex( u32 a, u32 n, u32 v0 )
template <u32 VNUM>
u32 gSPLoadDMAVertexData(u32 address, SPVertex * spVtx, u32 v0, u32 vi, u32 n)
u32 gSPLoadDMAVertexData(word address, SPVertex * spVtx, u32 v0, u32 vi, u32 n)
{
const u32 end = n - (n%VNUM) + v0;
for (; vi < end; vi += VNUM) {
@ -1057,7 +1092,7 @@ void gSPDMAVertex( u32 a, u32 n, u32 v0 )
return;
}
const u32 address = gSP.DMAOffsets.vtx + RSP_SegmentToPhysical(a);
const word address = gSP.DMAOffsets.vtx + RSP_SegmentToPhysical(a);
if ((address + 10 * n) > RDRAMSize)
return;
@ -1108,7 +1143,7 @@ void gSPCBFDVertex( u32 a, u32 n, u32 v0 )
return;
}
const u32 address = RSP_SegmentToPhysical(a);
const word address = RSP_SegmentToPhysical(a);
if ((address + sizeof( Vertex ) * n) > RDRAMSize)
return;
@ -1185,7 +1220,7 @@ void gSPF3DAMVertex(u32 a, u32 n, u32 v0)
return;
}
const u32 address = RSP_SegmentToPhysical(a);
const word address = RSP_SegmentToPhysical(a);
if ((address + sizeof(Vertex)* n) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "gSPF3DAMVertex Using Vertex outside RDRAM n = %i, v0 = %i, from %08x\n", n, v0, a);
@ -1259,7 +1294,7 @@ void gSPSWVertex(const SWVertex * vertex, u32 v0, u32 n)
void gSPT3DUXVertex(u32 a, u32 n, u32 ci)
{
const u32 address = RSP_SegmentToPhysical(a);
const word address = RSP_SegmentToPhysical(a);
const u32 colors = RSP_SegmentToPhysical(ci);
struct T3DUXVertex {
@ -1319,11 +1354,11 @@ void gSPT3DUXVertex(u32 a, u32 n, u32 ci)
}
}
void gSPDisplayList( u32 dl )
void gSPDisplayList( word dl )
{
u32 address = RSP_SegmentToPhysical( dl );
word address = RSP_SegmentToPhysical( dl );
if ((address + 8) > RDRAMSize) {
if ((address + sizeof(Gwords)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load display list from invalid address\n");
DebugMsg(DEBUG_NORMAL, "gSPDisplayList( 0x%08X );\n", dl );
return;
@ -1341,11 +1376,11 @@ void gSPDisplayList( u32 dl )
}
}
void gSPBranchList( u32 dl )
void gSPBranchList( word dl )
{
u32 address = RSP_SegmentToPhysical( dl );
word address = RSP_SegmentToPhysical( dl );
if ((address + 8) > RDRAMSize) {
if ((address + sizeof(Gwords)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to branch to display list at invalid address\n");
DebugMsg(DEBUG_NORMAL, "gSPBranchList( 0x%08X );\n", dl );
return;
@ -1353,22 +1388,22 @@ void gSPBranchList( u32 dl )
DebugMsg(DEBUG_NORMAL, "gSPBranchList( 0x%08X ) nopush\n", dl );
if (address == (RSP.PC[RSP.PCi] - 8)) {
if (address == (RSP.PC[RSP.PCi] - sizeof(Gwords))) {
RSP.infloop = true;
RSP.PC[RSP.PCi] -= 8;
RSP.PC[RSP.PCi] -= sizeof(Gwords);
RSP.halt = true;
return;
}
RSP.PC[RSP.PCi] = address;
RSP.nextCmd = _SHIFTR( *(u32*)&RDRAM[address], 24, 8 );
RSP.nextCmd = _SHIFTR( *(word*)&RDRAM[address], 24, 8 );
}
void gSPBranchLessZ(u32 branchdl, u32 vtx, u32 zval)
void gSPBranchLessZ(word branchdl, u32 vtx, u32 zval)
{
const u32 address = RSP_SegmentToPhysical( branchdl );
const word address = RSP_SegmentToPhysical( branchdl );
if ((address + 8) > RDRAMSize) {
if ((address + sizeof(Gwords)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Specified display list at invalid address\n");
DebugMsg(DEBUG_NORMAL, "gSPBranchLessZ( 0x%08X, %i, %i );\n", branchdl, vtx, zval );
return;
@ -1382,11 +1417,11 @@ void gSPBranchLessZ(u32 branchdl, u32 vtx, u32 zval)
DebugMsg(DEBUG_NORMAL, "gSPBranchLessZ( 0x%08X, %i, %i );\n", branchdl, vtx, zval );
}
void gSPBranchLessW( u32 branchdl, u32 vtx, u32 wval )
void gSPBranchLessW( word branchdl, u32 vtx, u32 wval )
{
const u32 address = RSP_SegmentToPhysical( branchdl );
const word address = RSP_SegmentToPhysical( branchdl );
if ((address + 8) > RDRAMSize) {
if ((address + sizeof(Gwords)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Specified display list at invalid address\n");
DebugMsg(DEBUG_NORMAL, "gSPBranchLessW( 0x%08X, %i, %i );\n", branchdl, vtx, wval);
return;
@ -1401,8 +1436,8 @@ void gSPBranchLessW( u32 branchdl, u32 vtx, u32 wval )
void gSPDlistCount(u32 count, u32 v)
{
u32 address = RSP_SegmentToPhysical( v );
if (address == 0 || (address + 8) > RDRAMSize) {
word address = RSP_SegmentToPhysical( v );
if (address == 0 || (address + sizeof(Gwords)) > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to branch to display list at invalid address\n");
DebugMsg(DEBUG_NORMAL, "gSPDlistCnt(%d, 0x%08X );\n", count, v);
return;
@ -1418,7 +1453,7 @@ void gSPDlistCount(u32 count, u32 v)
++RSP.PCi; // go to the next PC in the stack
RSP.PC[RSP.PCi] = address; // jump to the address
RSP.nextCmd = _SHIFTR( *(u32*)&RDRAM[address], 24, 8 );
RSP.nextCmd = _SHIFTR( *(word*)&RDRAM[address], 24, 8 );
RSP.count = count + 1;
}
@ -1445,7 +1480,7 @@ void gSPSetVertexColorBase( u32 base )
}
void gSPDMATriangles( u32 tris, u32 n ){
const u32 address = RSP_SegmentToPhysical( tris );
const word address = RSP_SegmentToPhysical( tris );
if (address + sizeof( DKRTriangle ) * n > RDRAMSize) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "// Attempting to load triangles from invalid address\n");
@ -1574,7 +1609,7 @@ void gSPPopMatrix( u32 param )
(param == G_MTX_PROJECTION) ? "G_MTX_PROJECTION" : "G_MTX_INVALID");
}
void gSPSegment( s32 seg, s32 base )
void gSPSegment( s32 seg, word base )
{
gSP.segment[seg] = base;
@ -1750,8 +1785,11 @@ void gSPTexture( f32 sc, f32 tc, u32 level, u32 tile, u32 on )
DebugMsg(DEBUG_NORMAL, "gSPTexture: tile: %d, mipmap_lvl: %d, on: %d, s_scale: %f, t_scale: %f\n", tile, level, on, sc, tc);
}
void gSPEndDisplayList()
void gSPEndDisplayList(const Gwords words)
{
const word line = _SHIFTR(words.w0, 0, 24);
const char* file = (const char*)words.w1;
if (RSP.PCi > 0)
--RSP.PCi;
else {
@ -1760,6 +1798,10 @@ void gSPEndDisplayList()
}
DebugMsg(DEBUG_NORMAL, "gSPEndDisplayList();\n\n");
if (line && file) {
DebugMsg(DEBUG_NORMAL, "\nLINE %s : %d;\n\n", file, line);
}
}
void gSPGeometryMode( u32 clear, u32 set )
@ -1989,7 +2031,7 @@ void gSPSprite2DBase(u32 _base)
{
DebugMsg(DEBUG_NORMAL, "gSPSprite2DBase\n");
assert(RSP.nextCmd == 0xBE);
const u32 address = RSP_SegmentToPhysical( _base );
const word address = RSP_SegmentToPhysical( _base );
uSprite *pSprite = (uSprite*)&RDRAM[address];
if (pSprite->tlutPtr != 0) {
@ -2117,3 +2159,19 @@ void gSPSetupFunctions()
{
g_ConkerUcode = GBI.getMicrocodeType() == F3DEX2CBFD;
}
#ifdef NATIVE
word RSP_SegmentToPhysical(word segaddr) {
if (RSP.translateSegment) {
RSP.translateSegment = false;
const u32 idx = (segaddr >> 24) & 0x0F;
const word addr = (segaddr & 0x00FFFFFF);
DebugMsg(DEBUG_NORMAL, "Translatings segment address %x (%x) -> %x\n", segaddr, idx, gSP.segment[idx] + addr);
return gSP.segment[idx] + addr;
}
return segaddr;
}
#endif

View File

@ -47,9 +47,25 @@ struct SPVertex
s16 flag;
};
struct S16XYZW
{
s16 x;
s16 y;
s16 z;
s16 w;
};
typedef struct {
S16XYZW vscale; /* scale, 2 bits fraction */
S16XYZW vtrans; /* translate, 2 bits fraction */
/* both the above arrays are padded to 64-bit boundary */
} Vp_t;
static_assert(sizeof(Vp_t) == 16, "Vp_t is incorrect size");
struct gSPInfo
{
u32 segment[16];
word segment[16];
struct
{
@ -110,7 +126,7 @@ struct gSPInfo
struct
{
u32 address, width, height, format, size, palette;
word address, width, height, format, size, palette;
f32 imageX, imageY, scaleW, scaleH;
u8 clampS, clampT;
} bgImage;
@ -121,7 +137,7 @@ struct gSPInfo
struct {
u8 sid;
u32 flag;
u32 addr;
word addr;
} selectDL;
u32 status[4];
@ -149,7 +165,7 @@ struct gSPInfo
extern gSPInfo gSP;
void gSPLoadUcodeEx( u32 uc_start, u32 uc_dstart, u16 uc_dsize );
void gSPLoadUcodeEx( word uc_start, word uc_dstart, u16 uc_dsize );
void gSPNoOp();
void gSPMatrix( u32 matrix, u8 param );
void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply );
@ -167,10 +183,10 @@ void gSPT3DUXVertex(u32 v, u32 n, u32 ci);
void gSPF3DAMVertex( u32 v, u32 n, u32 v0 );
void gSPSWVertex(const SWVertex * vertex, u32 n, const bool * const verticesToProcess);
void gSPSWVertex(const SWVertex * vertex, u32 v0, u32 n);
void gSPDisplayList(u32 dl);
void gSPBranchList( u32 dl );
void gSPBranchLessZ(u32 branchdl, u32 vtx, u32 zval);
void gSPBranchLessW( u32 branchdl, u32 vtx, u32 wval );
void gSPDisplayList(word dl);
void gSPBranchList( word dl );
void gSPBranchLessZ(word branchdl, u32 vtx, u32 zval);
void gSPBranchLessW( word branchdl, u32 vtx, u32 wval );
void gSPDlistCount(u32 count, u32 v);
void gSPSprite2DBase(u32 _base );
void gSPDMATriangles( u32 tris, u32 n );
@ -178,7 +194,7 @@ void gSP1Quadrangle( s32 v0, s32 v1, s32 v2, s32 v3 );
void gSPCullDisplayList( u32 v0, u32 vn );
void gSPPopMatrix( u32 param );
void gSPPopMatrixN( u32 param, u32 num );
void gSPSegment( s32 seg, s32 base );
void gSPSegment( s32 seg, word base );
void gSPClipRatio( u32 ratio );
void gSPInsertMatrix( u32 where, u32 num );
void gSPModifyVertex(u32 _vtx, u32 _where, u32 _val );
@ -187,7 +203,7 @@ void gSPLightColor( u32 lightNum, u32 packedColor );
void gSPFogFactor( s16 fm, s16 fo );
void gSPPerspNormalize( u16 scale );
void gSPTexture( f32 sc, f32 tc, u32 level, u32 tile, u32 on );
void gSPEndDisplayList();
void gSPEndDisplayList(const Gwords words);
void gSPGeometryMode( u32 clear, u32 set );
void gSPSetGeometryMode( u32 mode );
void gSPClearGeometryMode( u32 mode );

View File

@ -24,6 +24,7 @@
#define M64P_PLUGIN_H
#include "m64p_types.h"
#include "Types.h"
#ifdef __cplusplus
extern "C" {
@ -39,9 +40,11 @@ extern "C" {
/***** Structures *****/
typedef struct {
#ifndef NATIVE
unsigned char * RDRAM;
unsigned char * DMEM;
unsigned char * IMEM;
#endif
unsigned int * MI_INTR_REG;
@ -73,16 +76,18 @@ typedef struct {
typedef struct {
unsigned char * HEADER; /* This is the rom header (first 40h bytes of the rom) */
#ifndef NATIVE
unsigned char * RDRAM;
unsigned char * DMEM;
unsigned char * IMEM;
#endif
unsigned int * MI_INTR_REG;
unsigned int * DPC_START_REG;
unsigned int * DPC_END_REG;
unsigned int * DPC_CURRENT_REG;
unsigned int * DPC_STATUS_REG;
word * DPC_START_REG;
word * DPC_END_REG;
word * DPC_CURRENT_REG;
word * DPC_STATUS_REG;
unsigned int * DPC_CLOCK_REG;
unsigned int * DPC_BUFBUSY_REG;
unsigned int * DPC_PIPEBUSY_REG;
@ -120,9 +125,11 @@ typedef struct {
} GFX_INFO;
typedef struct {
#ifndef NATIVE
unsigned char * RDRAM;
unsigned char * DMEM;
unsigned char * IMEM;
#endif
unsigned int * MI_INTR_REG;

20
src/porting.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include <stdint.h>
#if UINTPTR_MAX == 0xffffffff
#elif UINTPTR_MAX == 0xffffffffffffffff
#define IS_64_BIT 1
#else
/* wtf */
#endif
#ifdef NATIVE
#ifdef IS_64_BIT
#define word uint64_t
#else
#define word uint32_t
#endif
#else
#define word uint32_t
#endif

View File

@ -8,245 +8,245 @@
#include "gDP.h"
#include "GBI.h"
void F3D_SPNoOp( u32 w0, u32 w1 )
void F3D_SPNoOp( const Gwords words )
{
gSPNoOp();
}
void F3D_Mtx( u32 w0, u32 w1 )
void F3D_Mtx( const Gwords words )
{
if (_SHIFTR( w0, 0, 16 ) != 64) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "G_MTX: address = 0x%08X length = %i params = 0x%02X\n", w1, _SHIFTR(w0, 0, 16), _SHIFTR(w0, 16, 8));
if (_SHIFTR( words.w0, 0, 16 ) != 64) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "G_MTX: address = 0x%08X length = %i params = 0x%02X\n", words.w1, _SHIFTR(words.w0, 0, 16), _SHIFTR(words.w0, 16, 8));
return;
}
gSPMatrix( w1, _SHIFTR( w0, 16, 8 ) );
gSPMatrix( words.w1, _SHIFTR( words.w0, 16, 8 ) );
}
void F3D_Reserved0( u32 w0, u32 w1 )
void F3D_Reserved0( const Gwords words )
{
DebugMsg(DEBUG_NORMAL | DEBUG_IGNORED, "G_RESERVED0: w0=0x%08lX w1=0x%08lX\n", w0, w1);
DebugMsg(DEBUG_NORMAL | DEBUG_IGNORED, "G_RESERVED0: words.w0=0x%08lX words.w1=0x%08lX\n", words.w0, words.w1);
}
void F3D_MoveMem( u32 w0, u32 w1 )
void F3D_MoveMem( const Gwords words )
{
switch (_SHIFTR( w0, 16, 8 )) {
switch (_SHIFTR( words.w0, 16, 8 )) {
case F3D_MV_VIEWPORT:
gSPViewport( w1 );
gSPViewport( words.w1 );
break;
case G_MV_MATRIX_1:
gSPForceMatrix( w1 );
gSPForceMatrix( words.w1 );
// force matrix takes four commands
RSP.PC[RSP.PCi] += 24;
break;
case G_MV_L0:
gSPLight( w1, LIGHT_1 );
gSPLight( words.w1, LIGHT_1 );
break;
case G_MV_L1:
gSPLight( w1, LIGHT_2 );
gSPLight( words.w1, LIGHT_2 );
break;
case G_MV_L2:
gSPLight( w1, LIGHT_3 );
gSPLight( words.w1, LIGHT_3 );
break;
case G_MV_L3:
gSPLight( w1, LIGHT_4 );
gSPLight( words.w1, LIGHT_4 );
break;
case G_MV_L4:
gSPLight( w1, LIGHT_5 );
gSPLight( words.w1, LIGHT_5 );
break;
case G_MV_L5:
gSPLight( w1, LIGHT_6 );
gSPLight( words.w1, LIGHT_6 );
break;
case G_MV_L6:
gSPLight( w1, LIGHT_7 );
gSPLight( words.w1, LIGHT_7 );
break;
case G_MV_L7:
gSPLight( w1, LIGHT_8 );
gSPLight( words.w1, LIGHT_8 );
break;
case G_MV_LOOKATX:
gSPLookAt(w1, 0);
gSPLookAt(words.w1, 0);
break;
case G_MV_LOOKATY:
gSPLookAt(w1, 1);
gSPLookAt(words.w1, 1);
break;
}
}
void F3D_Vtx( u32 w0, u32 w1 )
void F3D_Vtx( const Gwords words )
{
gSPVertex( w1, _SHIFTR( w0, 20, 4 ) + 1, _SHIFTR( w0, 16, 4 ) );
gSPVertex( words.w1, _SHIFTR( words.w0, 20, 4 ) + 1, _SHIFTR( words.w0, 16, 4 ) );
}
void F3D_Reserved1( u32 w0, u32 w1 )
void F3D_Reserved1( const Gwords words )
{
}
void F3D_DList( u32 w0, u32 w1 )
void F3D_DList( const Gwords words )
{
switch (_SHIFTR( w0, 16, 8 ))
switch (_SHIFTR( words.w0, 16, 8 ))
{
case G_DL_PUSH:
gSPDisplayList( w1 );
gSPDisplayList( words.w1 );
break;
case G_DL_NOPUSH:
gSPBranchList( w1 );
gSPBranchList( words.w1 );
break;
}
}
void F3D_Reserved2( u32 w0, u32 w1 )
void F3D_Reserved2( const Gwords words )
{
}
void F3D_Reserved3( u32 w0, u32 w1 )
void F3D_Reserved3( const Gwords words )
{
}
void F3D_Sprite2D_Base( u32 w0, u32 w1 )
void F3D_Sprite2D_Base( const Gwords words )
{
gSPSprite2DBase( w1 );
gSPSprite2DBase( words.w1 );
}
void F3D_Tri1( u32 w0, u32 w1 )
void F3D_Tri1( const Gwords words )
{
gSP1Triangle( _SHIFTR( w1, 16, 8 ) / 10,
_SHIFTR( w1, 8, 8 ) / 10,
_SHIFTR( w1, 0, 8 ) / 10);
gSP1Triangle( _SHIFTR( words.w1, 16, 8 ) / 10,
_SHIFTR( words.w1, 8, 8 ) / 10,
_SHIFTR( words.w1, 0, 8 ) / 10);
}
void F3D_CullDL( u32 w0, u32 w1 )
void F3D_CullDL( const Gwords words )
{
gSPCullDisplayList( _SHIFTR( w0, 0, 24 ) / 40, (w1 / 40) - 1 );
gSPCullDisplayList( _SHIFTR( words.w0, 0, 24 ) / 40, (words.w1 / 40) - 1 );
}
void F3D_PopMtx( u32 w0, u32 w1 )
void F3D_PopMtx( const Gwords words )
{
gSPPopMatrix( w1 );
gSPPopMatrix( words.w1 );
}
void F3D_MoveWord( u32 w0, u32 w1 )
void F3D_MoveWord( const Gwords words )
{
switch (_SHIFTR( w0, 0, 8 )) {
switch (_SHIFTR( words.w0, 0, 8 )) {
case G_MW_MATRIX:
gSPInsertMatrix( _SHIFTR( w0, 8, 16 ), w1 );
gSPInsertMatrix( _SHIFTR( words.w0, 8, 16 ), words.w1 );
break;
case G_MW_NUMLIGHT:
gSPNumLights( ((w1 - 0x80000000) >> 5) - 1 );
gSPNumLights( ((words.w1 - 0x80000000) >> 5) - 1 );
break;
case G_MW_CLIP:
gSPClipRatio( w1 );
gSPClipRatio( words.w1 );
break;
case G_MW_SEGMENT:
gSPSegment( _SHIFTR( w0, 10, 4 ), w1 & 0x00FFFFFF );
gSPSegment( _SHIFTR( words.w0, 10, 4 ), SEGMENT_MASK(words.w1) );
break;
case G_MW_FOG:
/* u32 fm, fo, min, max;
fm = _SHIFTR( w1, 16, 16 );
fo = _SHIFTR( w1, 0, 16 );
fm = _SHIFTR( words.w1, 16, 16 );
fo = _SHIFTR( words.w1, 0, 16 );
min = 500 - (fo * (128000 / fm)) / 256;
max = (128000 / fm) + min;*/
gSPFogFactor( (s16)_SHIFTR( w1, 16, 16 ), (s16)_SHIFTR( w1, 0, 16 ) );
gSPFogFactor( (s16)_SHIFTR( words.w1, 16, 16 ), (s16)_SHIFTR( words.w1, 0, 16 ) );
break;
case G_MW_LIGHTCOL:
switch (_SHIFTR( w0, 8, 16 ))
switch (_SHIFTR( words.w0, 8, 16 ))
{
case F3D_MWO_aLIGHT_1:
gSPLightColor( LIGHT_1, w1 );
gSPLightColor( LIGHT_1, words.w1 );
break;
case F3D_MWO_aLIGHT_2:
gSPLightColor( LIGHT_2, w1 );
gSPLightColor( LIGHT_2, words.w1 );
break;
case F3D_MWO_aLIGHT_3:
gSPLightColor( LIGHT_3, w1 );
gSPLightColor( LIGHT_3, words.w1 );
break;
case F3D_MWO_aLIGHT_4:
gSPLightColor( LIGHT_4, w1 );
gSPLightColor( LIGHT_4, words.w1 );
break;
case F3D_MWO_aLIGHT_5:
gSPLightColor( LIGHT_5, w1 );
gSPLightColor( LIGHT_5, words.w1 );
break;
case F3D_MWO_aLIGHT_6:
gSPLightColor( LIGHT_6, w1 );
gSPLightColor( LIGHT_6, words.w1 );
break;
case F3D_MWO_aLIGHT_7:
gSPLightColor( LIGHT_7, w1 );
gSPLightColor( LIGHT_7, words.w1 );
break;
case F3D_MWO_aLIGHT_8:
gSPLightColor( LIGHT_8, w1 );
gSPLightColor( LIGHT_8, words.w1 );
break;
}
break;
case G_MW_POINTS:
{
const u32 val = _SHIFTR(w0, 8, 16);
gSPModifyVertex(val / 40, val % 40, w1);
const u32 val = _SHIFTR(words.w0, 8, 16);
gSPModifyVertex(val / 40, val % 40, words.w1);
}
break;
case G_MW_PERSPNORM:
gSPPerspNormalize( w1 );
gSPPerspNormalize( words.w1 );
break;
}
}
void F3D_Texture( u32 w0, u32 w1 )
void F3D_Texture( const Gwords words )
{
gSPTexture( _FIXED2FLOAT( _SHIFTR( w1, 16, 16 ), 16 ),
_FIXED2FLOAT( _SHIFTR( w1, 0, 16 ), 16 ),
_SHIFTR( w0, 11, 3 ),
_SHIFTR( w0, 8, 3 ),
_SHIFTR( w0, 0, 8 ) );
gSPTexture( _FIXED2FLOAT( _SHIFTR( words.w1, 16, 16 ), 16 ),
_FIXED2FLOAT( _SHIFTR( words.w1, 0, 16 ), 16 ),
_SHIFTR( words.w0, 11, 3 ),
_SHIFTR( words.w0, 8, 3 ),
_SHIFTR( words.w0, 0, 8 ) );
}
void F3D_SetOtherMode_H( u32 w0, u32 w1 )
void F3D_SetOtherMode_H( const Gwords words )
{
const u32 length = _SHIFTR(w0, 0, 8);
const u32 shift = _SHIFTR(w0, 8, 8);
gSPSetOtherMode_H(length, shift, w1);
const u32 length = _SHIFTR(words.w0, 0, 8);
const u32 shift = _SHIFTR(words.w0, 8, 8);
gSPSetOtherMode_H(length, shift, words.w1);
}
void F3D_SetOtherMode_L( u32 w0, u32 w1 )
void F3D_SetOtherMode_L( const Gwords words )
{
const u32 length = _SHIFTR(w0, 0, 8);
const u32 shift = _SHIFTR(w0, 8, 8);
gSPSetOtherMode_L(length, shift, w1);
const u32 length = _SHIFTR(words.w0, 0, 8);
const u32 shift = _SHIFTR(words.w0, 8, 8);
gSPSetOtherMode_L(length, shift, words.w1);
}
void F3D_EndDL( u32 w0, u32 w1 )
void F3D_EndDL( const Gwords words )
{
gSPEndDisplayList();
gSPEndDisplayList(words);
}
void F3D_SetGeometryMode( u32 w0, u32 w1 )
void F3D_SetGeometryMode( const Gwords words )
{
gSPSetGeometryMode( w1 );
gSPSetGeometryMode( words.w1 );
}
void F3D_ClearGeometryMode( u32 w0, u32 w1 )
void F3D_ClearGeometryMode( const Gwords words )
{
gSPClearGeometryMode( w1 );
gSPClearGeometryMode( words.w1 );
}
void F3D_Quad( u32 w0, u32 w1 )
void F3D_Quad( const Gwords words )
{
gSP1Quadrangle( _SHIFTR( w1, 24, 8 ) / 10, _SHIFTR( w1, 16, 8 ) / 10, _SHIFTR( w1, 8, 8 ) / 10, _SHIFTR( w1, 0, 8 ) / 10 );
gSP1Quadrangle( _SHIFTR( words.w1, 24, 8 ) / 10, _SHIFTR( words.w1, 16, 8 ) / 10, _SHIFTR( words.w1, 8, 8 ) / 10, _SHIFTR( words.w1, 0, 8 ) / 10 );
}
void F3D_RDPHalf_1( u32 w0, u32 w1 )
void F3D_RDPHalf_1( const Gwords words )
{
gDP.half_1 = w1;
RDP_Half_1(w1);
gDP.half_1 = words.w1;
RDP_Half_1(words.w1);
}
void F3D_RDPHalf_2( u32 w0, u32 w1 )
void F3D_RDPHalf_2( const Gwords words )
{
gDP.half_2 = w1;
gDP.half_2 = words.w1;
}
void F3D_RDPHalf_Cont( u32 w0, u32 w1 )
void F3D_RDPHalf_Cont( const Gwords words )
{
}

View File

@ -66,31 +66,31 @@
#define F3D_RDPHALF_CONT 0xB2
#define F3D_TRI4 0xB1
void F3D_SPNoOp( u32 w0, u32 w1 );
void F3D_Mtx( u32 w0, u32 w1 );
void F3D_Reserved0( u32 w0, u32 w1 );
void F3D_MoveMem( u32 w0, u32 w1 );
void F3D_Vtx( u32 w0, u32 w1 );
void F3D_Reserved1( u32 w0, u32 w1 );
void F3D_DList( u32 w0, u32 w1 );
void F3D_Reserved2( u32 w0, u32 w1 );
void F3D_Reserved3( u32 w0, u32 w1 );
void F3D_Sprite2D_Base( u32 w0, u32 w1 );
void F3D_Tri1( u32 w0, u32 w1 );
void F3D_CullDL( u32 w0, u32 w1 );
void F3D_PopMtx( u32 w0, u32 w1 );
void F3D_MoveWord( u32 w0, u32 w1 );
void F3D_Texture( u32 w0, u32 w1 );
void F3D_SetOtherMode_H( u32 w0, u32 w1 );
void F3D_SetOtherMode_L( u32 w0, u32 w1 );
void F3D_EndDL( u32 w0, u32 w1 );
void F3D_SetGeometryMode( u32 w0, u32 w1 );
void F3D_ClearGeometryMode( u32 w0, u32 w1 );
//void F3D_Line3D( u32 w0, u32 w1 );
void F3D_Quad( u32 w0, u32 w1 );
void F3D_RDPHalf_1( u32 w0, u32 w1 );
void F3D_RDPHalf_2( u32 w0, u32 w1 );
void F3D_RDPHalf_Cont( u32 w0, u32 w1 );
void F3D_SPNoOp( const Gwords words );
void F3D_Mtx( const Gwords words );
void F3D_Reserved0( const Gwords words );
void F3D_MoveMem( const Gwords words );
void F3D_Vtx( const Gwords words );
void F3D_Reserved1( const Gwords words );
void F3D_DList( const Gwords words );
void F3D_Reserved2( const Gwords words );
void F3D_Reserved3( const Gwords words );
void F3D_Sprite2D_Base( const Gwords words );
void F3D_Tri1( const Gwords words );
void F3D_CullDL( const Gwords words );
void F3D_PopMtx( const Gwords words );
void F3D_MoveWord( const Gwords words );
void F3D_Texture( const Gwords words );
void F3D_SetOtherMode_H( const Gwords words );
void F3D_SetOtherMode_L( const Gwords words );
void F3D_EndDL( const Gwords words );
void F3D_SetGeometryMode( const Gwords words );
void F3D_ClearGeometryMode( const Gwords words );
//void F3D_Line3D( const Gwords words );
void F3D_Quad( const Gwords words );
void F3D_RDPHalf_1( const Gwords words );
void F3D_RDPHalf_2( const Gwords words );
void F3D_RDPHalf_Cont( const Gwords words );
void F3D_Init();
#endif

View File

@ -5,43 +5,43 @@
#include "F3DAM.h"
#include "gSP.h"
void F3DAM_MoveWord(u32 w0, u32 w1)
void F3DAM_MoveWord( const Gwords words )
{
switch (_SHIFTR(w0, 16, 8)) {
switch (_SHIFTR(words.w0, 16, 8)) {
case G_MW_FOG:
switch (_SHIFTR(w0, 0, 8)) {
switch (_SHIFTR(words.w0, 0, 8)) {
case 0:
gSPFogFactor((s16)_SHIFTR(w1, 16, 16), (s16)_SHIFTR(w1, 0, 16));
gSPFogFactor((s16)_SHIFTR(words.w1, 16, 16), (s16)_SHIFTR(words.w1, 0, 16));
break;
case 0x0C:
gSP.textureCoordScale[0] = w1;
gSP.textureCoordScale[0] = words.w1;
break;
case 0x10:
gSP.textureCoordScale[1] = w1;
gSP.textureCoordScale[1] = words.w1;
break;
}
break;
default:
F3DEX2_MoveWord(w0, w1);
F3DEX2_MoveWord(words);
break;
}
}
void F3DAM_Vtx( u32 w0, u32 w1 )
void F3DAM_Vtx( const Gwords words )
{
u32 n = _SHIFTR( w0, 12, 8 );
u32 n = _SHIFTR( words.w0, 12, 8 );
gSPF3DAMVertex( w1, n, _SHIFTR( w0, 1, 7 ) - n );
gSPF3DAMVertex( words.w1, n, _SHIFTR( words.w0, 1, 7 ) - n );
}
void F3DAM_Texture( u32 w0, u32 w1 )
void F3DAM_Texture( const Gwords words )
{
gSP.textureCoordScaleOrg = w1;
gSP.textureCoordScaleOrg = words.w1;
gSPTexture( 1.0f,
1.0f,
_SHIFTR( w0, 11, 3 ),
_SHIFTR( w0, 8, 3 ),
_SHIFTR( w0, 1, 7 ) );
_SHIFTR( words.w0, 11, 3 ),
_SHIFTR( words.w0, 8, 3 ),
_SHIFTR( words.w0, 1, 7 ) );
}
void F3DAM_Init()

View File

@ -10,32 +10,32 @@
#include "gDP.h"
#include "GBI.h"
void F3DBETA_Vtx( u32 w0, u32 w1 )
void F3DBETA_Vtx( const Gwords words )
{
gSPVertex( w1, _SHIFTR( w0, 9, 7 ), _SHIFTR( w0, 16, 8 ) / 5 );
gSPVertex( words.w1, _SHIFTR( words.w0, 9, 7 ), _SHIFTR( words.w0, 16, 8 ) / 5 );
}
void F3DBETA_Tri1( u32 w0, u32 w1 )
void F3DBETA_Tri1( const Gwords words )
{
gSP1Triangle( _SHIFTR( w1, 16, 8 ) / 5,
_SHIFTR( w1, 8, 8 ) / 5,
_SHIFTR( w1, 0, 8 ) / 5);
gSP1Triangle( _SHIFTR( words.w1, 16, 8 ) / 5,
_SHIFTR( words.w1, 8, 8 ) / 5,
_SHIFTR( words.w1, 0, 8 ) / 5);
}
void F3DBETA_Tri2( u32 w0, u32 w1 )
void F3DBETA_Tri2( const Gwords words )
{
gSP2Triangles( _SHIFTR( w0, 16, 8 ) / 5, _SHIFTR( w0, 8, 8 ) / 5, _SHIFTR( w0, 0, 8 ) / 5, 0,
_SHIFTR( w1, 16, 8 ) / 5, _SHIFTR( w1, 8, 8 ) / 5, _SHIFTR( w1, 0, 8 ) / 5, 0);
gSP2Triangles( _SHIFTR( words.w0, 16, 8 ) / 5, _SHIFTR( words.w0, 8, 8 ) / 5, _SHIFTR( words.w0, 0, 8 ) / 5, 0,
_SHIFTR( words.w1, 16, 8 ) / 5, _SHIFTR( words.w1, 8, 8 ) / 5, _SHIFTR( words.w1, 0, 8 ) / 5, 0);
}
void F3DBETA_Quad( u32 w0, u32 w1 )
void F3DBETA_Quad( const Gwords words )
{
gSP1Quadrangle( _SHIFTR( w1, 24, 8 ) / 5, _SHIFTR( w1, 16, 8 ) / 5, _SHIFTR( w1, 8, 8 ) / 5, _SHIFTR( w1, 0, 8 ) / 5 );
gSP1Quadrangle( _SHIFTR( words.w1, 24, 8 ) / 5, _SHIFTR( words.w1, 16, 8 ) / 5, _SHIFTR( words.w1, 8, 8 ) / 5, _SHIFTR( words.w1, 0, 8 ) / 5 );
}
void F3DBETA_Perpnorm(u32 w0, u32 w1)
void F3DBETA_Perpnorm(const Gwords words)
{
gSPPerspNormalize(w1);
gSPPerspNormalize(words.w1);
}
void F3DBETA_Init()

View File

@ -8,7 +8,7 @@
void F3DBETA_Init();
void F3DBETA_Perpnorm(u32 w0, u32 w1);
void F3DBETA_Perpnorm(const Gwords words);
#endif

View File

@ -9,90 +9,90 @@
#include "gDP.h"
#include "GBI.h"
void F3DDKR_DMA_Mtx( u32 w0, u32 w1 )
void F3DDKR_DMA_Mtx( const Gwords words )
{
if (_SHIFTR( w0, 0, 16 ) != 64) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "G_MTX: address = 0x%08X length = %i params = 0x%02X\n", w1, _SHIFTR(w0, 0, 16), _SHIFTR(w0, 16, 8));
if (_SHIFTR( words.w0, 0, 16 ) != 64) {
DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "G_MTX: address = 0x%08X length = %i params = 0x%02X\n", words.w1, _SHIFTR(words.w0, 0, 16), _SHIFTR(words.w0, 16, 8));
return;
}
u32 index = _SHIFTR( w0, 16, 4 );
u32 index = _SHIFTR( words.w0, 16, 4 );
u32 multiply;
if (index == 0) {// DKR
index = _SHIFTR( w0, 22, 2 );
index = _SHIFTR( words.w0, 22, 2 );
multiply = 0;
}
else { // JFG
multiply = _SHIFTR( w0, 23, 1 );
multiply = _SHIFTR( words.w0, 23, 1 );
}
gSPDMAMatrix( w1, index, multiply );
gSPDMAMatrix( words.w1, index, multiply );
}
void F3DDKR_DMA_Vtx( u32 w0, u32 w1 )
void F3DDKR_DMA_Vtx( const Gwords words )
{
if ((w0 & F3DDKR_VTX_APPEND)) {
if ((words.w0 & F3DDKR_VTX_APPEND)) {
if (gSP.matrix.billboard)
gSP.vertexi = 1;
} else
gSP.vertexi = 0;
u32 n = _SHIFTR( w0, 19, 5 ) + 1;
u32 n = _SHIFTR( words.w0, 19, 5 ) + 1;
gSPDMAVertex( w1, n, gSP.vertexi + _SHIFTR( w0, 9, 5 ) );
gSPDMAVertex( words.w1, n, gSP.vertexi + _SHIFTR( words.w0, 9, 5 ) );
gSP.vertexi += n;
}
void F3DJFG_DMA_Vtx(u32 w0, u32 w1)
void F3DJFG_DMA_Vtx(const Gwords words)
{
if ((w0 & F3DDKR_VTX_APPEND)) {
if ((words.w0 & F3DDKR_VTX_APPEND)) {
if (gSP.matrix.billboard)
gSP.vertexi = 1;
} else
gSP.vertexi = 0;
u32 n = _SHIFTR(w0, 19, 5);
u32 n = _SHIFTR(words.w0, 19, 5);
gSPDMAVertex(w1, n, gSP.vertexi + _SHIFTR(w0, 9, 5));
gSPDMAVertex(words.w1, n, gSP.vertexi + _SHIFTR(words.w0, 9, 5));
gSP.vertexi += n;
}
void F3DDKR_DMA_Tri(u32 w0, u32 w1)
void F3DDKR_DMA_Tri(const Gwords words)
{
gSPDMATriangles( w1, _SHIFTR( w0, 4, 12 ) );
gSPDMATriangles( words.w1, _SHIFTR( words.w0, 4, 12 ) );
gSP.vertexi = 0;
}
void F3DDKR_DMA_DList( u32 w0, u32 w1 )
void F3DDKR_DMA_DList( const Gwords words )
{
gSPDlistCount(_SHIFTR(w0, 16, 8), w1);
gSPDlistCount(_SHIFTR(words.w0, 16, 8), words.w1);
}
void F3DDKR_DMA_Offsets( u32 w0, u32 w1 )
void F3DDKR_DMA_Offsets( const Gwords words )
{
gSPSetDMAOffsets( _SHIFTR( w0, 0, 24 ), _SHIFTR( w1, 0, 24 ) );
gSPSetDMAOffsets( _SHIFTR( words.w0, 0, 24 ), _SHIFTR( words.w1, 0, 24 ) );
}
void F3DDKR_DMA_Tex_Offset(u32 w0, u32 w1)
void F3DDKR_DMA_Tex_Offset(const Gwords words)
{
gSPSetDMATexOffset(w1);
gSPSetDMATexOffset(words.w1);
}
void F3DDKR_MoveWord( u32 w0, u32 w1 )
void F3DDKR_MoveWord( const Gwords words )
{
switch (_SHIFTR( w0, 0, 8 )) {
switch (_SHIFTR( words.w0, 0, 8 )) {
case 0x02:
gSP.matrix.billboard = w1 & 1;
gSP.matrix.billboard = words.w1 & 1;
break;
case 0x0A:
gSP.matrix.modelViewi = _SHIFTR( w1, 6, 2 );
gSP.matrix.modelViewi = _SHIFTR( words.w1, 6, 2 );
gSP.changed |= CHANGED_MATRIX;
break;
default:
F3D_MoveWord( w0, w1 );
F3D_MoveWord(words);
break;
}
}

View File

@ -9,45 +9,45 @@
#include "gDP.h"
#include "GBI.h"
void F3DEX_Vtx( u32 w0, u32 w1 )
void F3DEX_Vtx( const Gwords words )
{
gSPVertex( w1, _SHIFTR( w0, 10, 6 ), _SHIFTR( w0, 17, 7 ) );
gSPVertex( words.w1, _SHIFTR( words.w0, 10, 6 ), _SHIFTR( words.w0, 17, 7 ) );
}
void F3DEX_Tri1( u32 w0, u32 w1 )
void F3DEX_Tri1( const Gwords words )
{
gSP1Triangle( _SHIFTR( w1, 17, 7 ), _SHIFTR( w1, 9, 7 ), _SHIFTR( w1, 1, 7 ));
gSP1Triangle( _SHIFTR( words.w1, 17, 7 ), _SHIFTR( words.w1, 9, 7 ), _SHIFTR( words.w1, 1, 7 ));
}
void F3DEX_CullDL( u32 w0, u32 w1 )
void F3DEX_CullDL( const Gwords words )
{
gSPCullDisplayList( _SHIFTR( w0, 1, 15 ), _SHIFTR( w1, 1, 15 ) );
gSPCullDisplayList( _SHIFTR( words.w0, 1, 15 ), _SHIFTR( words.w1, 1, 15 ) );
}
void F3DEX_ModifyVtx( u32 w0, u32 w1 )
void F3DEX_ModifyVtx( const Gwords words )
{
gSPModifyVertex( _SHIFTR( w0, 1, 15 ), _SHIFTR( w0, 16, 8 ), w1 );
gSPModifyVertex( _SHIFTR( words.w0, 1, 15 ), _SHIFTR( words.w0, 16, 8 ), words.w1 );
}
void F3DEX_Tri2( u32 w0, u32 w1 )
void F3DEX_Tri2( const Gwords words )
{
gSP2Triangles( _SHIFTR( w0, 17, 7 ), _SHIFTR( w0, 9, 7 ), _SHIFTR( w0, 1, 7 ), 0,
_SHIFTR( w1, 17, 7 ), _SHIFTR( w1, 9, 7 ), _SHIFTR( w1, 1, 7 ), 0);
gSP2Triangles( _SHIFTR( words.w0, 17, 7 ), _SHIFTR( words.w0, 9, 7 ), _SHIFTR( words.w0, 1, 7 ), 0,
_SHIFTR( words.w1, 17, 7 ), _SHIFTR( words.w1, 9, 7 ), _SHIFTR( words.w1, 1, 7 ), 0);
}
void F3DEX_Quad( u32 w0, u32 w1 )
void F3DEX_Quad( const Gwords words )
{
gSP1Quadrangle( _SHIFTR( w1, 25, 7 ), _SHIFTR( w1, 17, 7 ), _SHIFTR( w1, 9, 7 ), _SHIFTR( w1, 1, 7 ) );
gSP1Quadrangle( _SHIFTR( words.w1, 25, 7 ), _SHIFTR( words.w1, 17, 7 ), _SHIFTR( words.w1, 9, 7 ), _SHIFTR( words.w1, 1, 7 ) );
}
void F3DEX_Branch_Z( u32 w0, u32 w1 )
void F3DEX_Branch_Z( const Gwords words )
{
gSPBranchLessZ(gDP.half_1, _SHIFTR(w0, 1, 11), _SHIFTR(w1, 16, 16));
gSPBranchLessZ(gDP.half_1, _SHIFTR(words.w0, 1, 11), _SHIFTR(words.w1, 16, 16));
}
void F3DEX_Load_uCode( u32 w0, u32 w1 )
void F3DEX_Load_uCode( const Gwords words )
{
gSPLoadUcodeEx( w1, gDP.half_1, _SHIFTR( w0, 0, 16 ) + 1 );
gSPLoadUcodeEx( words.w1, gDP.half_1, _SHIFTR( words.w0, 0, 16 ) + 1 );
}
void F3DEX_Init()

View File

@ -42,13 +42,13 @@
#define F3DEX_BRANCH_Z 0xB0
#define F3DEX_LOAD_UCODE 0xAF // 0xCF
void F3DEX_Vtx( u32 w0, u32 w1 );
void F3DEX_Tri1( u32 w0, u32 w1 );
void F3DEX_CullDL( u32 w0, u32 w1 );
void F3DEX_ModifyVtx( u32 w0, u32 w1 );
void F3DEX_Tri2( u32 w0, u32 w1 );
void F3DEX_Branch_Z( u32 w0, u32 w1 );
void F3DEX_Load_uCode( u32 w0, u32 w1 );
void F3DEX_Vtx( const Gwords words );
void F3DEX_Tri1( const Gwords words );
void F3DEX_CullDL( const Gwords words );
void F3DEX_ModifyVtx( const Gwords words );
void F3DEX_Tri2( const Gwords words );
void F3DEX_Branch_Z( const Gwords words );
void F3DEX_Load_uCode( const Gwords words );
void F3DEX_Init();
#endif

View File

@ -14,158 +14,158 @@
using namespace std;
void F3DEX2_Mtx( u32 w0, u32 w1 )
void F3DEX2_Mtx( const Gwords words )
{
gSPMatrix( w1, _SHIFTR( w0, 0, 8 ) ^ G_MTX_PUSH );
gSPMatrix( words.w1, _SHIFTR( words.w0, 0, 8 ) ^ G_MTX_PUSH );
}
void F3DEX2_MoveMem( u32 w0, u32 w1 )
void F3DEX2_MoveMem( const Gwords words )
{
switch (_SHIFTR( w0, 0, 8 ))
switch (_SHIFTR( words.w0, 0, 8 ))
{
case F3DEX2_MV_VIEWPORT:
gSPViewport( w1 );
gSPViewport( words.w1 );
break;
case G_MV_MATRIX:
gSPForceMatrix( w1 );
gSPForceMatrix( words.w1 );
// force matrix takes two commands
RSP.PC[RSP.PCi] += 8;
break;
case G_MV_LIGHT:
{
const u32 offset = (_SHIFTR(w0, 5, 11))&0x7F8;
const u32 offset = (_SHIFTR(words.w0, 5, 11))&0x7F8;
const u32 n = offset / 24;
if (n < 2)
gSPLookAt(w1, n);
gSPLookAt(words.w1, n);
else
gSPLight(w1, n - 1);
gSPLight(words.w1, n - 1);
}
break;
}
}
void F3DEX2_Vtx( u32 w0, u32 w1 )
void F3DEX2_Vtx( const Gwords words )
{
u32 n = _SHIFTR( w0, 12, 8 );
u32 n = _SHIFTR( words.w0, 12, 8 );
gSPVertex( w1, n, _SHIFTR( w0, 1, 7 ) - n );
gSPVertex( words.w1, n, _SHIFTR( words.w0, 1, 7 ) - n );
}
void F3DEX2_Reserved1( u32 w0, u32 w1 )
void F3DEX2_Reserved1( const Gwords words )
{
}
void F3DEX2_Tri1( u32 w0, u32 w1 )
void F3DEX2_Tri1( const Gwords words )
{
gSP1Triangle( _SHIFTR( w0, 17, 7 ),
_SHIFTR( w0, 9, 7 ),
_SHIFTR( w0, 1, 7 ));
gSP1Triangle( _SHIFTR( words.w0, 17, 7 ),
_SHIFTR( words.w0, 9, 7 ),
_SHIFTR( words.w0, 1, 7 ));
}
void F3DEX2_Line3D( u32 w0, u32 w1 )
void F3DEX2_Line3D( const Gwords words )
{
assert(false);
}
void F3DEX2_PopMtx( u32 w0, u32 w1 )
void F3DEX2_PopMtx( const Gwords words )
{
gSPPopMatrixN( 0, w1 >> 6 );
gSPPopMatrixN( 0, words.w1 >> 6 );
}
void F3DEX2_MoveWord( u32 w0, u32 w1 )
void F3DEX2_MoveWord( const Gwords words )
{
switch (_SHIFTR( w0, 16, 8 ))
switch (_SHIFTR( words.w0, 16, 8 ))
{
case G_MW_FORCEMTX:
if (w1 == 0)
if (words.w1 == 0)
gSP.changed |= CHANGED_MATRIX;
else
gSP.changed &= ~CHANGED_MATRIX;
break;
case G_MW_MATRIX:
gSPInsertMatrix( _SHIFTR( w0, 0, 16 ), w1 );
gSPInsertMatrix( _SHIFTR( words.w0, 0, 16 ), words.w1 );
break;
case G_MW_NUMLIGHT:
gSPNumLights( w1 / 24 );
gSPNumLights( words.w1 / 24 );
break;
case G_MW_CLIP:
gSPClipRatio( w1 );
gSPClipRatio( words.w1 );
break;
case G_MW_SEGMENT:
gSPSegment( _SHIFTR( w0, 2, 4 ) , w1 & 0x00FFFFFF );
gSPSegment( _SHIFTR( words.w0, 2, 4 ) , SEGMENT_MASK(words.w1) );
break;
case G_MW_FOG:
gSPFogFactor( (s16)_SHIFTR( w1, 16, 16 ), (s16)_SHIFTR( w1, 0, 16 ) );
gSPFogFactor( (s16)_SHIFTR( words.w1, 16, 16 ), (s16)_SHIFTR( words.w1, 0, 16 ) );
break;
case G_MW_LIGHTCOL:
gSPLightColor((_SHIFTR( w0, 0, 16 ) / 24) + 1, w1 );
gSPLightColor((_SHIFTR( words.w0, 0, 16 ) / 24) + 1, words.w1 );
break;
case G_MW_PERSPNORM:
gSPPerspNormalize( w1 );
gSPPerspNormalize( words.w1 );
break;
}
}
void F3DEX2_Texture( u32 w0, u32 w1 )
void F3DEX2_Texture( const Gwords words )
{
gSPTexture( _FIXED2FLOAT( _SHIFTR( w1, 16, 16 ), 16 ),
_FIXED2FLOAT( _SHIFTR( w1, 0, 16 ), 16 ),
_SHIFTR( w0, 11, 3 ),
_SHIFTR( w0, 8, 3 ),
_SHIFTR( w0, 1, 7 ) );
gSPTexture( _FIXED2FLOAT( _SHIFTR( words.w1, 16, 16 ), 16 ),
_FIXED2FLOAT( _SHIFTR( words.w1, 0, 16 ), 16 ),
_SHIFTR( words.w0, 11, 3 ),
_SHIFTR( words.w0, 8, 3 ),
_SHIFTR( words.w0, 1, 7 ) );
}
void F3DEX2_SetOtherMode_H( u32 w0, u32 w1 )
void F3DEX2_SetOtherMode_H( const Gwords words )
{
const u32 length = _SHIFTR(w0, 0, 8) + 1;
const u32 shift = max(0, (s32)(32 - _SHIFTR(w0, 8, 8) - length));
gSPSetOtherMode_H(length, shift, w1);
const u32 length = _SHIFTR(words.w0, 0, 8) + 1;
const u32 shift = max(0, (s32)(32 - _SHIFTR(words.w0, 8, 8) - length));
gSPSetOtherMode_H(length, shift, words.w1);
}
void F3DEX2_SetOtherMode_L( u32 w0, u32 w1 )
void F3DEX2_SetOtherMode_L( const Gwords words )
{
const u32 length = _SHIFTR(w0, 0, 8) + 1;
const u32 shift = max(0, (s32)(32 - _SHIFTR(w0, 8, 8) - length));
gSPSetOtherMode_L(length, shift, w1);
const u32 length = _SHIFTR(words.w0, 0, 8) + 1;
const u32 shift = max(0, (s32)(32 - _SHIFTR(words.w0, 8, 8) - length));
gSPSetOtherMode_L(length, shift, words.w1);
}
void F3DEX2_GeometryMode( u32 w0, u32 w1 )
void F3DEX2_GeometryMode( const Gwords words )
{
gSPGeometryMode( ~_SHIFTR( w0, 0, 24 ), w1 );
gSPGeometryMode( ~_SHIFTR( words.w0, 0, 24 ), words.w1 );
}
void F3DEX2_DMAIO( u32 w0, u32 w1 )
void F3DEX2_DMAIO( const Gwords words )
{
gSP.DMAIO_address = RSP_SegmentToPhysical(w1);
gSP.DMAIO_address = RSP_SegmentToPhysical(words.w1);
}
void F3DEX2_Special_1( u32 w0, u32 w1 )
void F3DEX2_Special_1( const Gwords words )
{
const u32 param = _SHIFTR(w0, 0, 8);
const u32 param = _SHIFTR(words.w0, 0, 8);
if (GBI.isCombineMatrices())
gSPCombineMatrices(param);
else
gSPDlistCount(param, w1);
gSPDlistCount(param, words.w1);
}
void F3DEX2_Special_2( u32 w0, u32 w1 )
void F3DEX2_Special_2( const Gwords words )
{
}
void F3DEX2_Special_3( u32 w0, u32 w1 )
void F3DEX2_Special_3( const Gwords words )
{
}
void F3DEX2_Quad( u32 w0, u32 w1 )
void F3DEX2_Quad( const Gwords words )
{
gSP2Triangles( _SHIFTR( w0, 17, 7 ),
_SHIFTR( w0, 9, 7 ),
_SHIFTR( w0, 1, 7 ),
gSP2Triangles( _SHIFTR( words.w0, 17, 7 ),
_SHIFTR( words.w0, 9, 7 ),
_SHIFTR( words.w0, 1, 7 ),
0,
_SHIFTR( w1, 17, 7 ),
_SHIFTR( w1, 9, 7 ),
_SHIFTR( w1, 1, 7 ),
_SHIFTR( words.w1, 17, 7 ),
_SHIFTR( words.w1, 9, 7 ),
_SHIFTR( words.w1, 1, 7 ),
0 );
}

View File

@ -66,23 +66,23 @@
#define F3DEX2_LINE3D 0x08
void F3DEX2_Mtx( u32 w0, u32 w1 );
void F3DEX2_MoveMem( u32 w0, u32 w1 );
void F3DEX2_Vtx( u32 w0, u32 w1 );
void F3DEX2_Reserved1( u32 w0, u32 w1 );
void F3DEX2_Tri1( u32 w0, u32 w1 );
void F3DEX2_PopMtx( u32 w0, u32 w1 );
void F3DEX2_MoveWord( u32 w0, u32 w1 );
void F3DEX2_Texture( u32 w0, u32 w1 );
void F3DEX2_SetOtherMode_H( u32 w0, u32 w1 );
void F3DEX2_SetOtherMode_L( u32 w0, u32 w1 );
void F3DEX2_GeometryMode( u32 w0, u32 w1 );
void F3DEX2_Line3D( u32 w0, u32 w1 );
void F3DEX2_DMAIO( u32 w0, u32 w1 );
void F3DEX2_Special_1( u32 w0, u32 w1 );
void F3DEX2_Special_2( u32 w0, u32 w1 );
void F3DEX2_Special_3( u32 w0, u32 w1 );
void F3DEX2_Quad( u32 w0, u32 w1 );
void F3DEX2_Mtx( const Gwords words );
void F3DEX2_MoveMem( const Gwords words );
void F3DEX2_Vtx( const Gwords words );
void F3DEX2_Reserved1( const Gwords words );
void F3DEX2_Tri1( const Gwords words );
void F3DEX2_PopMtx( const Gwords words );
void F3DEX2_MoveWord( const Gwords words );
void F3DEX2_Texture( const Gwords words );
void F3DEX2_SetOtherMode_H( const Gwords words );
void F3DEX2_SetOtherMode_L( const Gwords words );
void F3DEX2_GeometryMode( const Gwords words );
void F3DEX2_Line3D( const Gwords words );
void F3DEX2_DMAIO( const Gwords words );
void F3DEX2_Special_1( const Gwords words );
void F3DEX2_Special_2( const Gwords words );
void F3DEX2_Special_3( const Gwords words );
void F3DEX2_Quad( const Gwords words );
void F3DEX2_Init();
#endif

View File

@ -10,31 +10,31 @@
using namespace std;
void F3DEX2ACCLAIM_MoveMem( u32 w0, u32 w1 )
void F3DEX2ACCLAIM_MoveMem( const Gwords words )
{
switch (_SHIFTR( w0, 0, 8 ))
switch (_SHIFTR( words.w0, 0, 8 ))
{
case F3DEX2_MV_VIEWPORT:
gSPViewport( w1 );
gSPViewport( words.w1 );
break;
case G_MV_MATRIX:
gSPForceMatrix( w1 );
gSPForceMatrix( words.w1 );
// force matrix takes two commands
RSP.PC[RSP.PCi] += 8;
break;
case G_MV_LIGHT:
{
const u32 offset = (_SHIFTR(w0, 5, 11))&0x7F8;
const u32 offset = (_SHIFTR(words.w0, 5, 11))&0x7F8;
if (offset <= 24 * 3) {
const u32 n = offset / 24;
if (n < 2)
gSPLookAt(w1, n);
gSPLookAt(words.w1, n);
else
gSPLight(w1, n - 1);
gSPLight(words.w1, n - 1);
} else {
const u32 n = 2 + (offset - 24 * 4) / 16;
gSPLightAcclaim(w1, n);
gSPLightAcclaim(words.w1, n);
}
}
break;

View File

@ -12,15 +12,15 @@
#include "GBI.h"
static
void F3DEX2CBFD_Vtx( u32 w0, u32 w1 )
void F3DEX2CBFD_Vtx( const Gwords words )
{
u32 n = _SHIFTR( w0, 12, 8 );
u32 n = _SHIFTR( words.w0, 12, 8 );
gSPCBFDVertex( w1, n, _SHIFTR( w0, 1, 7 ) - n );
gSPCBFDVertex(words.w1, n, _SHIFTR(words.w0, 1, 7) - n);
}
static
void F3DEX2CBFD_CoordMod(u32 _w0, u32 _w1)
void F3DEX2CBFD_CoordMod(word _w0, word _w1)
{
DebugMsg(DEBUG_NORMAL, "gSPCoordMod( %u, %u );\n", _w0, _w1);
if ((_w0 & 8) != 0)
@ -44,67 +44,67 @@ void F3DEX2CBFD_CoordMod(u32 _w0, u32 _w1)
}
static
void F3DEX2CBFD_MoveWord( u32 w0, u32 w1 )
void F3DEX2CBFD_MoveWord( const Gwords words )
{
switch (_SHIFTR( w0, 16, 8 ))
switch (_SHIFTR( words.w0, 16, 8 ))
{
case G_MW_NUMLIGHT:
gSPNumLights( w1 / 48 );
gSPNumLights( words.w1 / 48 );
break;
case G_MW_CLIP:
gSPClipRatio( w1 );
gSPClipRatio( words.w1 );
break;
case G_MW_SEGMENT:
gSPSegment( _SHIFTR( w0, 0, 16 ) >> 2, w1 & 0x00FFFFFF );
gSPSegment( _SHIFTR( words.w0, 0, 16 ) >> 2, SEGMENT_MASK(words.w1) );
break;
case G_MW_FOG:
gSPFogFactor( (s16)_SHIFTR( w1, 16, 16 ), (s16)_SHIFTR( w1, 0, 16 ) );
gSPFogFactor( (s16)_SHIFTR( words.w1, 16, 16 ), (s16)_SHIFTR( words.w1, 0, 16 ) );
break;
case G_MW_PERSPNORM:
gSPPerspNormalize( w1 );
gSPPerspNormalize( words.w1 );
break;
case G_MW_COORD_MOD:
F3DEX2CBFD_CoordMod( w0, w1 );
F3DEX2CBFD_CoordMod( words.w0, words.w1 );
break;
}
}
static
void F3DEX2CBFD_MoveMem( u32 w0, u32 w1 )
void F3DEX2CBFD_MoveMem( const Gwords words )
{
switch (_SHIFTR( w0, 0, 8 ))
switch (_SHIFTR( words.w0, 0, 8 ))
{
case F3DEX2_MV_VIEWPORT:
gSPViewport( w1 );
gSPViewport( words.w1 );
break;
case G_MV_LIGHT:
{
const u32 offset = _SHIFTR(w0, 5, 14);
const u32 offset = _SHIFTR(words.w0, 5, 14);
const u32 n = offset / 48;
if (n < 2)
gSPLookAt(w1, n);
gSPLookAt(words.w1, n);
else
gSPLightCBFD(w1, n - 2);
gSPLightCBFD(words.w1, n - 2);
}
break;
case G_MV_NORMALES:
gSP.cbfd.vertexNormalBase = RSP_SegmentToPhysical(w1);
DebugMsg(DEBUG_NORMAL, "gSPSetVertexNormaleBase( 0x%08X );\n", w1);
gSP.cbfd.vertexNormalBase = RSP_SegmentToPhysical(words.w1);
DebugMsg(DEBUG_NORMAL, "gSPSetVertexNormaleBase( 0x%08X );\n", words.w1);
break;
}
}
static
void F3DEX2CBFD_Tri4( u32 w0, u32 w1 )
void F3DEX2CBFD_Tri4( const Gwords words )
{
gSP4Triangles( _SHIFTR( w0, 23, 5 ), _SHIFTR( w0, 18, 5 ), (_SHIFTR( w0, 15, 3 )<<2)|_SHIFTR( w1, 30, 2 ),
_SHIFTR( w0, 10, 5 ), _SHIFTR( w0, 5, 5 ), _SHIFTR( w0, 0, 5 ),
_SHIFTR( w1, 25, 5 ), _SHIFTR( w1, 20, 5 ), _SHIFTR( w1, 15, 5 ),
_SHIFTR( w1, 10, 5 ), _SHIFTR( w1, 5, 5 ), _SHIFTR( w1, 0, 5 ) );
gSP4Triangles( _SHIFTR( words.w0, 23, 5 ), _SHIFTR( words.w0, 18, 5 ), (_SHIFTR( words.w0, 15, 3 )<<2)|_SHIFTR( words.w1, 30, 2 ),
_SHIFTR( words.w0, 10, 5 ), _SHIFTR( words.w0, 5, 5 ), _SHIFTR( words.w0, 0, 5 ),
_SHIFTR( words.w1, 25, 5 ), _SHIFTR( words.w1, 20, 5 ), _SHIFTR( words.w1, 15, 5 ),
_SHIFTR( words.w1, 10, 5 ), _SHIFTR( words.w1, 5, 5 ), _SHIFTR( words.w1, 0, 5 ) );
}
static
void F3DEX2CBFD_SwitchLightingMode(u32, u32)
void F3DEX2CBFD_SwitchLightingMode(const Gwords words)
{
gSP.cbfd.advancedLighting = true;
}

View File

@ -8,10 +8,14 @@
#include "gSP.h"
#include "DebugDump.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
inline
void F3DFLX2_LoadAlphaLight(u32 _a)
{
const u32 address = RSP_SegmentToPhysical(_a);
const word address = RSP_SegmentToPhysical(_a);
const s16* const data = reinterpret_cast<const s16*>(RDRAM + address);
@ -30,22 +34,22 @@ void F3DFLX2_LoadAlphaLight(u32 _a)
}
static
void F3DFLX2_MoveMem(u32 w0, u32 w1)
void F3DFLX2_MoveMem(const Gwords words)
{
switch (_SHIFTR(w0, 0, 8))
switch (_SHIFTR(words.w0, 0, 8))
{
case G_MV_LIGHT:
{
const u32 offset = (w0 >> 5) & 0x7F8;
const u32 offset = (words.w0 >> 5) & 0x7F8;
const u32 n = offset / 24;
if (n == 1)
F3DFLX2_LoadAlphaLight(w1);
F3DFLX2_LoadAlphaLight(words.w1);
else
gSPLight(w1, n - 1);
gSPLight(words.w1, n - 1);
}
break;
default:
F3DEX2_MoveMem(w0, w1);
F3DEX2_MoveMem(words);
break;
}
}

View File

@ -14,17 +14,18 @@
u32 G_GOLDEN_MOVEWORD;
void F3D_TriX(u32 w0, u32 w1)
void F3D_TriX(const Gwords _words)
{
while(w1 != 0) {
u32 v0 = w1 & 0xf;
w1 >>= 4;
Gwords words = _words;
while(words.w1 != 0) {
u32 v0 = words.w1 & 0xf;
words.w1 >>= 4;
u32 v1 = w1 & 0xf;
w1 >>= 4;
u32 v1 = words.w1 & 0xf;
words.w1 >>= 4;
u32 v2 = w0 & 0xf;
w0 >>= 4;
u32 v2 = words.w0 & 0xf;
words.w0 >>= 4;
gSPTriangle(v0, v1, v2);
}

View File

@ -5,7 +5,7 @@
void F3DGOLDEN_Init();
void F3D_TriX(u32 w0, u32 w1);
void F3D_TriX(const Gwords words);
#endif

View File

@ -8,14 +8,14 @@
#define F3DPD_VTXCOLORBASE 0x07
void F3DPD_Vtx( u32 w0, u32 w1 )
void F3DPD_Vtx( const Gwords words )
{
gSPCIVertex( w1, _SHIFTR( w0, 20, 4 ) + 1, _SHIFTR( w0, 16, 4 ) );
gSPCIVertex( words.w1, _SHIFTR( words.w0, 20, 4 ) + 1, _SHIFTR( words.w0, 16, 4 ) );
}
void F3DPD_VtxColorBase( u32 w0, u32 w1 )
void F3DPD_VtxColorBase( const Gwords words )
{
gSPSetVertexColorBase( w1 );
gSPSetVertexColorBase( words.w1 );
}
void F3DPD_Init()

View File

@ -21,47 +21,47 @@
#define F3DSETA_MW_FOG 0x06
#define F3DSETA_MW_LIGHTCOL 0x08
void F3DSETA_MoveWord(u32 w0, u32 w1)
void F3DSETA_MoveWord(const Gwords words)
{
switch (_SHIFTR( w0, 8, 8 )) {
switch (_SHIFTR( words.w0, 8, 8 )) {
case F3DSETA_MW_NUMLIGHT:
gSPNumLights( ((w1 - 0x80000000) >> 5) - 1 );
gSPNumLights( ((words.w1 - 0x80000000) >> 5) - 1 );
break;
case F3DSETA_MW_CLIP:
gSPClipRatio( w1 );
gSPClipRatio( words.w1 );
break;
case F3DSETA_MW_SEGMENT:
gSPSegment( _SHIFTR( w0, 10, 4 ), w1 & 0x00FFFFFF );
gSPSegment( _SHIFTR( words.w0, 10, 4 ), SEGMENT_MASK(words.w1) );
break;
case F3DSETA_MW_FOG:
gSPFogFactor( (s16)_SHIFTR( w1, 16, 16 ), (s16)_SHIFTR( w1, 0, 16 ) );
gSPFogFactor( (s16)_SHIFTR( words.w1, 16, 16 ), (s16)_SHIFTR( words.w1, 0, 16 ) );
break;
case F3DSETA_MW_LIGHTCOL:
switch (_SHIFTR( w0, 0, 8 ))
switch (_SHIFTR( words.w0, 0, 8 ))
{
case F3D_MWO_aLIGHT_1:
gSPLightColor( LIGHT_1, w1 );
gSPLightColor( LIGHT_1, words.w1 );
break;
case F3D_MWO_aLIGHT_2:
gSPLightColor( LIGHT_2, w1 );
gSPLightColor( LIGHT_2, words.w1 );
break;
case F3D_MWO_aLIGHT_3:
gSPLightColor( LIGHT_3, w1 );
gSPLightColor( LIGHT_3, words.w1 );
break;
case F3D_MWO_aLIGHT_4:
gSPLightColor( LIGHT_4, w1 );
gSPLightColor( LIGHT_4, words.w1 );
break;
case F3D_MWO_aLIGHT_5:
gSPLightColor( LIGHT_5, w1 );
gSPLightColor( LIGHT_5, words.w1 );
break;
case F3D_MWO_aLIGHT_6:
gSPLightColor( LIGHT_6, w1 );
gSPLightColor( LIGHT_6, words.w1 );
break;
case F3D_MWO_aLIGHT_7:
gSPLightColor( LIGHT_7, w1 );
gSPLightColor( LIGHT_7, words.w1 );
break;
case F3D_MWO_aLIGHT_8:
gSPLightColor( LIGHT_8, w1 );
gSPLightColor( LIGHT_8, words.w1 );
break;
}
break;
@ -70,9 +70,9 @@ void F3DSETA_MoveWord(u32 w0, u32 w1)
}
}
void F3DSETA_Perpnorm(u32 w0, u32 w1)
void F3DSETA_Perpnorm(const Gwords words)
{
gSPPerspNormalize(w1);
gSPPerspNormalize(words.w1);
}
void F3DSETA_Init()

View File

@ -12,18 +12,18 @@
u32 G_TEXA_LOADTEX, G_TEXA_SETTILESIZE;
void F3DTTEXA_LoadTex(u32 w0, u32 w1)
void F3DTTEXA_LoadTex(const Gwords words)
{
RDP_SetTImg(0x3d100000, w1);
RDP_SetTile(0x35100000, 0x07000000);
RDP_LoadBlock(0x33000000, 0x27000000 | _SHIFTR(w0, 0, 24));
RDP_SetTImg(Gwords(0x3d100000, words.w1));
RDP_SetTile(Gwords(0x35100000, 0x07000000));
RDP_LoadBlock(Gwords(0x33000000, 0x27000000 | _SHIFTR(words.w0, 0, 24)));
}
void F3DTTEXA_SetTileSize(u32 w0, u32 w1)
void F3DTTEXA_SetTileSize(const Gwords words)
{
const u32 firstHalf = _SHIFTL(_SHIFTR(w1, 24, 8), 9, 8);
RDP_SetTile(0x35400000 | firstHalf, _SHIFTR(w0, 0, 24));
RDP_SetTileSize(0x32000000, _SHIFTR(w1, 0, 24));
const u32 firstHalf = _SHIFTL(_SHIFTR(words.w1, 24, 8), 9, 8);
RDP_SetTile(Gwords(0x35400000 | firstHalf, _SHIFTR(words.w0, 0, 24)));
RDP_SetTileSize(Gwords(0x32000000, _SHIFTR(words.w1, 0, 24)));
}
void F3DTEXA_Init()

View File

@ -7,9 +7,9 @@
#define F3DZEX2_BRANCH_W 0x04
void F3DZEX2_Branch_W( u32 w0, u32 w1 )
void F3DZEX2_Branch_W( const Gwords words )
{
gSPBranchLessW(gDP.half_1, _SHIFTR( w0, 1, 7 ), w1);
gSPBranchLessW(gDP.half_1, _SHIFTR( words.w0, 1, 7 ), words.w1);
}
void F3DZEX2_Init()

View File

@ -90,29 +90,30 @@ void F5INDI_LoadSTMatrix()
}
static
void F5INDI_DMA_Direct(u32 _w0, u32 _w1)
void F5INDI_DMA_Direct(const Gwords words)
{
u32 * pSrc = CAST_RDRAM(u32*, _SHIFTR(_w1, 0, 24));
u32 * pDst = CAST_DMEM(u32*, _SHIFTR(_w0, 8, 12));
const u32 count = (_SHIFTR(_w0, 0, 8) + 1) >> 2;
u32 * pSrc = CAST_RDRAM(u32*, _SHIFTR(words.w1, 0, 24));
u32 * pDst = CAST_DMEM(u32*, _SHIFTR(words.w0, 8, 12));
const u32 count = (_SHIFTR(words.w0, 0, 8) + 1) >> 2;
for (u32 i = 0; i < count; ++i) {
pDst[i] = pSrc[i];
}
}
static
void F5INDI_DMA_Segmented(u32 _w0, u32 _w1)
void F5INDI_DMA_Segmented(const Gwords words)
{
if (_SHIFTR(_w0, 0, 8) == 0)
if (_SHIFTR(words.w0, 0, 8) == 0)
return;
u32 * FD4 = CAST_DMEM(u32*, 0xFD4);
u32 * FD8 = CAST_DMEM(u32*, 0xFD8);
u32 * FDC = CAST_DMEM(u32*, 0xFDC);
s32 A0 = _SHIFTR(_w0, 0, 8);
s32 A0 = _SHIFTR(words.w0, 0, 8);
u32 A2 = *FDC;
s32 A3 = A0 + 1;
s32 A1 = A2 - A3;
u32 V1 = _SHIFTR(_w0, 8, 12);
u32 V1 = _SHIFTR(words.w0, 8, 12);
word tmp;
while (A1 < 0) {
u32 V0 = *FD4;
A3 = A0 - A2;
@ -120,12 +121,12 @@ void F5INDI_DMA_Segmented(u32 _w0, u32 _w1)
V1 += A2;
A0 = A3;
_w1 = *FD8;
tmp = *FD8;
u32 * pSrc = CAST_RDRAM(u32*, _SHIFTR(_w1, 0, 24));
u32 * pSrc = CAST_RDRAM(u32*, _SHIFTR(tmp, 0, 24));
*FD8 = *pSrc;
*FDC = 0x100;
*FD4 = _w1 + 0x08;
*FD4 = tmp + 0x08;
A2 = *FDC;
A3 = A0 + 1;
@ -140,10 +141,10 @@ void F5INDI_DMA_Segmented(u32 _w0, u32 _w1)
}
static
void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
void F5INDI_Lighting_Overlay1(const Gwords words)
{
static bool showErrorMessage = true;
const u32 S = ((_SHIFTR(_w1, 24, 7) << 2) + 4) & 0xFFF8;
const u32 S = ((_SHIFTR(words.w1, 24, 7) << 2) + 4) & 0xFFF8;
memset(DMEM + 0xD40, 0, S);
u8 L = *(DMEM + (0x58B ^ 3));
@ -153,7 +154,7 @@ void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
}
u32 lightAddr = 0xB10;
const u32 dataAddr = _SHIFTR(_w0, 8, 12);
const u32 dataAddr = _SHIFTR(words.w0, 8, 12);
while (true) {
u8 * dst = DMEM + 0xD40;
@ -209,7 +210,7 @@ void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
++V;
s16 Z1 = (s16)_SHIFTR(*V, 16, 16);
const u32 addr = 0x170 + offsetAddr[offsetAddrIdx ^ 3];
const word addr = 0x170 + offsetAddr[offsetAddrIdx ^ 3];
if (addr >= 0x1000 && showErrorMessage) {
dwnd().getDrawer().showMessage("Wrong data address detected!!! Please report to developers.\n", Milliseconds(5000));
showErrorMessage = false;
@ -289,9 +290,9 @@ void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
}
static
void F5INDI_Lighting_Overlay2(u32 _w0, u32 _w1)
void F5INDI_Lighting_Overlay2(const Gwords words)
{
const u32 S = ((_SHIFTR(_w1, 24, 7) << 2) + 4) & 0xFFF8;
const u32 S = ((_SHIFTR(words.w1, 24, 7) << 2) + 4) & 0xFFF8;
memset(DMEM + 0xD40, 0, S + 8);
u8 L = *(DMEM + (0x58B ^ 3));
@ -301,7 +302,7 @@ void F5INDI_Lighting_Overlay2(u32 _w0, u32 _w1)
}
u32 lightAddr = 0xB10;
const u32 dataAddr = _SHIFTR(_w0, 8, 12);
const u32 dataAddr = _SHIFTR(words.w0, 8, 12);
while (true) {
u8 * dst = DMEM + 0xD40;
@ -435,11 +436,11 @@ void F5INDI_Lighting_Overlay2(u32 _w0, u32 _w1)
}
static
void F5INDI_Lighting_Basic(u32 _w0, u32 _w1)
void F5INDI_Lighting_Basic(const Gwords words)
{
s32 count = _SHIFTR(_w1, 24, 7);
s32 count = _SHIFTR(words.w1, 24, 7);
const u8* factor = DMEM + 0x158;
const u8* data = DMEM + _SHIFTR(_w0, 8, 12);
const u8* data = DMEM + _SHIFTR(words.w0, 8, 12);
u8 * dst = DMEM + 0xD40;
while (count > 0) {
for (u32 j = 0; j < 8; ++j) {
@ -457,10 +458,10 @@ void F5INDI_Lighting_Basic(u32 _w0, u32 _w1)
}
static
void F5INDI_RebuildAndAdjustColors(u32 _w0, u32 _w1)
void F5INDI_RebuildAndAdjustColors(const Gwords words)
{
const u32 addr = _SHIFTR(_w0, 8, 12);
const u32 count = std::min(_SHIFTR(_w1, 24, 8), (0x588 - addr) >> 2);
const u32 addr = _SHIFTR(words.w0, 8, 12);
const u32 count = std::min((u32)_SHIFTR(words.w1, 24, 8), (u32)((0x588 - addr) >> 2));
const u16* data = CAST_DMEM(const u16*, addr);
std::vector<u32> vres(count);
for (u32 i = 0; i < count; ++i) {
@ -474,7 +475,7 @@ void F5INDI_RebuildAndAdjustColors(u32 _w0, u32 _w1)
}
static
const SWVertex * F5INDI_LoadVtx(u32 _w0, u32 _w1, std::vector<SWVertex> & _vres)
const SWVertex * F5INDI_LoadVtx(word _w0, word _w1, std::vector<SWVertex> & _vres)
{
const u32 count = _SHIFTR(_w1, 24, 8);
const u32 dmem_addr = _SHIFTR(_w0, 8, 12);
@ -499,7 +500,7 @@ const SWVertex * F5INDI_LoadVtx(u32 _w0, u32 _w1, std::vector<SWVertex> & _vres)
}
static
const SWVertex * F5INDI_AdjustVtx(u32 _w0, u32 _w1, std::vector<SWVertex> & _vres)
const SWVertex * F5INDI_AdjustVtx(word _w0, word _w1, std::vector<SWVertex> & _vres)
{
const u32 dmem_addr = _SHIFTR(_w0, 8, 12);
if (*CAST_DMEM(const u64*, 0x128) == 0)
@ -524,26 +525,26 @@ const SWVertex * F5INDI_AdjustVtx(u32 _w0, u32 _w1, std::vector<SWVertex> & _vre
}
static
void F5INDI_MoveMem(u32 _w0, u32 _w1)
void F5INDI_MoveMem(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_01Cmd (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F5INDI_01Cmd (0x%08x, 0x%08x)\n", words.w0, words.w1);
if (_SHIFTR(_w1, 0, 24) != 0)
F5INDI_DMA_Direct(_w0, _w1);
if (_SHIFTR(words.w1, 0, 24) != 0)
F5INDI_DMA_Direct(words);
else
F5INDI_DMA_Segmented(_w0, _w1);
F5INDI_DMA_Segmented(words);
switch (_w0 & 0x00f00000) {
switch (words.w0 & 0x00f00000) {
case 0x00000000:
switch (_w0) {
switch (words.w0) {
case 0x0101300F:
gSPViewport(_w1);
gSPViewport(words.w1);
break;
case 0x0105C03F:
gSPForceMatrix(_w1);
gSPForceMatrix(words.w1);
break;
case 0x010E403F:
RSP_LoadMatrix(getIndiData().mtx_vtx_gen, _SHIFTR(_w1, 0, 24));
RSP_LoadMatrix(getIndiData().mtx_vtx_gen, _SHIFTR(words.w1, 0, 24));
F5INDI_LoadSTMatrix();
break;
}
@ -552,69 +553,69 @@ void F5INDI_MoveMem(u32 _w0, u32 _w1)
case 0x00100000:
{
std::vector<SWVertex> vertices;
const u32 n = _SHIFTR(_w1, 24, 7);
gSPSWVertex(F5INDI_AdjustVtx(_w0, _w1, vertices), n, nullptr);
const u32 n = _SHIFTR(words.w1, 24, 7);
gSPSWVertex(F5INDI_AdjustVtx(words.w0, words.w1, vertices), n, nullptr);
}
break;
case 0x00300000:
// Set num of lights
*(DMEM + (0x058B^3)) = static_cast<u8>(_w1 >> 24);
*(DMEM + (0x058B^3)) = static_cast<u8>(words.w1 >> 24);
break;
case 0x00500000:
{
const u32 n = _SHIFTR(_w1, 24, 7);
const u32 n = _SHIFTR(words.w1, 24, 7);
std::vector<SWVertex> vres(n);
gSPSWVertex(F5INDI_LoadVtx(_w0, _w1, vres), n, nullptr);
gSPSWVertex(F5INDI_LoadVtx(words.w0, words.w1, vres), n, nullptr);
}
break;
default:
if (_SHIFTR(_w0, 8, 12) == 0x480) {
if (_SHIFTR(words.w0, 8, 12) == 0x480) {
// Lighting
const u32 F = (_w0 >> 22);
const u32 F = (words.w0 >> 22);
if ((F & 2) != 0)
F5INDI_RebuildAndAdjustColors(_w0, _w1);
F5INDI_RebuildAndAdjustColors(words);
const u8 L = *(DMEM + (0x58B ^ 3));
const u32 C = _SHIFTR(_w1, 24, 8) | L;
const u32 C = _SHIFTR(words.w1, 24, 8) | L;
if ((C & 0x80) == 0) {
if ((F & 1) != 0)
F5INDI_Lighting_Overlay1(_w0, _w1);
F5INDI_Lighting_Overlay1(words);
else
F5INDI_Lighting_Overlay2(_w0, _w1);
F5INDI_Lighting_Overlay2(words);
} else
F5INDI_Lighting_Basic(_w0, _w1);
F5INDI_Lighting_Basic(words);
}
break;
}
}
static
void F5INDI_SetDListAddr(u32 _w0, u32 _w1)
void F5INDI_SetDListAddr(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_SetDListAddr (0x%08x, 0x%08x)\n", _w0, _w1);
const u32 count = _w0 & 0x1FF;
const u32 * pSrc = CAST_RDRAM(const u32*, _SHIFTR(_w1, 0, 24));
DebugMsg(DEBUG_NORMAL, "F5INDI_SetDListAddr (0x%08x, 0x%08x)\n", words.w0, words.w1);
const u32 count = words.w0 & 0x1FF;
const u32 * pSrc = CAST_RDRAM(const u32*, _SHIFTR(words.w1, 0, 24));
u32 * pDst = CAST_DMEM(u32*, 0xFD4);
pDst[0] = _w1 + 8;
pDst[0] = words.w1 + 8;
pDst[1] = *pSrc;
pDst[2] = count;
}
static
void F5INDI_DList(u32 _w0, u32 _w1)
void F5INDI_DList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_DList (0x%08x)\n", _w1);
gSPDisplayList(_w1);
DebugMsg(DEBUG_NORMAL, "F5INDI_DList (0x%08x)\n", words.w1);
gSPDisplayList(words.w1);
_updateF5DL();
}
static
void F5INDI_BranchDList(u32 _w0, u32 _w1)
void F5INDI_BranchDList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_BranchDList (0x%08x)\n", _w1);
gSPBranchList(_w1);
DebugMsg(DEBUG_NORMAL, "F5INDI_BranchDList (0x%08x)\n", words.w1);
gSPBranchList(words.w1);
_updateF5DL();
}
@ -670,29 +671,29 @@ void F5INDI_DoSubDList()
RSP.PCi++;
RSP.F5DL[RSP.PCi] = _SHIFTR(*CAST_RDRAM(const u32*, dlistAddr), 0, 24);
RSP.PC[RSP.PCi] = dlistAddr + 8;
RSP.PC[RSP.PCi] = dlistAddr + sizeof(Gwords);
while (true) {
RSP.w0 = *CAST_RDRAM(u32*, RSP.PC[RSP.PCi]);
RSP.w1 = *CAST_RDRAM(u32*, RSP.PC[RSP.PCi] + 4);
RSP.words.w0 = *CAST_RDRAM(u32*, RSP.PC[RSP.PCi]);
RSP.words.w1 = *CAST_RDRAM(u32*, RSP.PC[RSP.PCi] + 4);
RSP.cmd = _SHIFTR(RSP.w0, 24, 8);
RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8);
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02X W0=0x%08X W1=0x%08X\n", RSP.PC[RSP.PCi], RSP.cmd, RSP.w0, RSP.w1);
DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02X W0=0x%08X W1=0x%08X\n", RSP.PC[RSP.PCi], RSP.cmd, RSP.words.w0, RSP.words.w1);
if (RSP.w0 == 0xB8000000 && RSP.w1 == 0xFFFFFFFF)
if (RSP.words.w0 == 0xB8000000 && RSP.words.w1 == 0xFFFFFFFF)
break;
RSP.nextCmd = _SHIFTR(*CAST_RDRAM(const u32*, RSP.PC[RSP.PCi] + 8), 24, 8);
GBI.cmd[RSP.cmd](RSP.w0, RSP.w1);
GBI.cmd[RSP.cmd](RSP.words);
RSP.PC[RSP.PCi] += 8;
if (RSP.nextCmd == 0xBD) {
// Naboo
u32* command = CAST_DMEM(u32*, 0xE58);
command[0] = RSP.w0;
command[1] = RSP.w1;
command[0] = RSP.words.w0;
command[1] = RSP.words.w1;
break;
}
}
@ -729,15 +730,15 @@ bool F5INDI_AddVertices(const u32 _vert[3], GraphicsDrawer & _drawer)
return true;
}
void F5INDI_Tri(u32 _w0, u32 _w1)
void F5INDI_Tri(const Gwords words)
{
const bool bTri2 = RSP.cmd == F5INDI_TRI2;
DebugMsg(DEBUG_NORMAL, "F5INDI_Tri%d (0x%08x, 0x%08x)\n", bTri2 ? 2 : 1, _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F5INDI_Tri%d (0x%08x, 0x%08x)\n", bTri2 ? 2 : 1, words.w0, words.w1);
const u32* params = CAST_RDRAM(const u32*, RSP.PC[RSP.PCi]);
const u32 w3 = params[3];
const u32 v1 = (_SHIFTR(_w1, 16, 12) - 0x600) / 40;
const u32 v2 = (_SHIFTR(_w1, 0, 12) - 0x600) / 40;
const u32 v1 = (_SHIFTR(words.w1, 16, 12) - 0x600) / 40;
const u32 v2 = (_SHIFTR(words.w1, 0, 12) - 0x600) / 40;
const u32 v3 = (_SHIFTR( w3, 16, 12) - 0x600) / 40;
const u32 v4 = (_SHIFTR( w3, 0, 12) - 0x600) / 40;
const u32 vert[4] = { v1, v2, v3, v4 };
@ -754,11 +755,11 @@ void F5INDI_Tri(u32 _w0, u32 _w1)
const u32 C4 = *CAST_DMEM(const u32*, 0xD40 + S4);
const u32 colors[4] = { C1, C2, C3, C4 };
const bool useTex = (_w0 & 0x0200) != 0;
const bool useTex = (words.w0 & 0x0200) != 0;
u32 ST[4];
const u32 * texbase;
if ((_w0 & 0x0800) != 0) {
if ((words.w0 & 0x0800) != 0) {
F5INDI_CalcST(params, ST);
texbase = ST;
} else {
@ -823,7 +824,7 @@ void F5INDI_Tri(u32 _w0, u32 _w1)
RSP.PC[RSP.PCi] += 8;
}
void F5INDI_GenVertices(u32 _w0, u32 _w1)
void F5INDI_GenVertices(const Gwords words)
{
f32 combined[4][4];
memcpy(combined, gSP.matrix.combined, sizeof(combined));
@ -832,7 +833,7 @@ void F5INDI_GenVertices(u32 _w0, u32 _w1)
const SWVertex * vertex = CAST_DMEM(const SWVertex*, 0x170);
bool verticesToProcess[32];
u32 A = (_w0 & 0x0000FFFF) | (_w1 & 0xFFFF0000);
u32 A = (words.w0 & 0x0000FFFF) | (words.w1 & 0xFFFF0000);
u32 B = 1;
u32 count = 0;
@ -1469,17 +1470,17 @@ void F5Naboo_PrepareAndDrawTriangle(const u32 _vert[3], GraphicsDrawer & _drawer
const u32 C = A | B;
CAST_DMEM(u16*, 0x100)[0x0 ^ 1] = C;
auto doCommands = [](u32 addr)
auto doCommands = [](word addr)
{
const u32 * commands = CAST_DMEM(const u32*, addr);
u32 w0 = commands[0];
u32 w1 = commands[1];
u32 cmd = _SHIFTR(w0, 24, 8);
GBI.cmd[cmd](w0, w1);
GBI.cmd[cmd](Gwords(w0, w1));
w0 = commands[2];
w1 = commands[3];
cmd = _SHIFTR(w0, 24, 8);
GBI.cmd[cmd](w0, w1);
GBI.cmd[cmd](Gwords(w0, w1));
};
const u32 dlistAddr = _SHIFTR(*CAST_DMEM(const u32*, 0x58C), 0, 24);
@ -1851,14 +1852,14 @@ void F5Naboo_GenVertices0C()
};
for (u32 addrShift = startAddr; addrShift <= endAddr; addrShift += 4) {
for (word addrShift = startAddr; addrShift <= endAddr; addrShift += 4) {
PrepareVertexDataStep3(vd1);
PrepareVertexDataStep3(vd2);
// Step 4
const u32 addr1 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr), 16, 16) + addrShift;
const u32 addr2 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr + 8), 16, 16) + addrShift;
const word addr1 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr), 16, 16) + addrShift;
const word addr2 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr + 8), 16, 16) + addrShift;
PrepareVertexDataStep4_7(addr1, vd1);
PrepareVertexDataStep4_7(addr2, vd2);
@ -2026,8 +2027,8 @@ void F5Naboo_GenVertices09()
for (u32 i = 0; i < 4; ++i)
pDst[i] = (pSrc1[i] + pSrc2[i]) >> 1;
};
const u32 addr3 = _SHIFTR(_V, 16, 16) + _addrShift + (_addrShift & 4);
const u32 addr4 = _SHIFTR(_V, 0, 16) + _addrShift - (_addrShift & 4);
const word addr3 = _SHIFTR(_V, 16, 16) + _addrShift + (_addrShift & 4);
const word addr4 = _SHIFTR(_V, 0, 16) + _addrShift - (_addrShift & 4);
const u32 factor1 = 0x7FFF - _vd.L;
const u32 factor2 = 0xFFFE - _vd.M - _vd.N;
u32 U = *CAST_DMEM(const u32*, _addr);
@ -2086,15 +2087,15 @@ void F5Naboo_GenVertices09()
*CAST_DMEM(u32*, _addr + 0x168) = _vd.color2.color;
};
for (u32 addrShift = startAddr; addrShift <= endAddr; addrShift += 4) {
for (word addrShift = startAddr; addrShift <= endAddr; addrShift += 4) {
PrepareVertexDataStep3(vd1);
PrepareVertexDataStep3(vd2);
// Step 4
const u32 addr1 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr), 16, 16) + addrShift;
const u32 addr2 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr + 8), 16, 16) + addrShift;
//const u32 addrShift2 = addrShift + (addrShift & 4);
const word addr1 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr), 16, 16) + addrShift;
const word addr2 = _SHIFTR(*CAST_DMEM(const u32*, dmemSrcAddr + 8), 16, 16) + addrShift;
//const word addrShift2 = addrShift + (addrShift & 4);
PrepareVertexDataStep4(addr1, *CAST_DMEM(const u32*, dmemSrcAddr + 0x20), addrShift, vd1);
PrepareVertexDataStep4(addr2, *CAST_DMEM(const u32*, dmemSrcAddr + 0x24), addrShift, vd2);
@ -2165,16 +2166,16 @@ void F5Naboo_GenVertices09()
}
static
void F5NABOO_TexturedPolygons(u32, u32)
void F5NABOO_TexturedPolygons(const Gwords words)
{
F5Naboo_DrawPolygons();
}
static
void F5INDI_GeometryGen(u32 _w0, u32 _w1)
void F5INDI_GeometryGen(const Gwords words)
{
const u32 mode = _SHIFTR(_w1, 0, 8);
DebugMsg(DEBUG_NORMAL, "F5INDI_GeometryGen (0x%08x, 0x%08x): mode=0x%02x\n", _w0, _w1, mode);
const u32 mode = _SHIFTR(words.w1, 0, 8);
DebugMsg(DEBUG_NORMAL, "F5INDI_GeometryGen (0x%08x, 0x%08x): mode=0x%02x\n", words.w0, words.w1, mode);
switch (mode) {
case 0x09: // Naboo
F5Naboo_GenVertices09();
@ -2198,7 +2199,7 @@ void F5INDI_GeometryGen(u32 _w0, u32 _w1)
RSP.PC[RSP.PCi] += 24;
break;
case 0x18:
F5INDI_GenVertices(_w0, _w1);
F5INDI_GenVertices(words);
break;
case 0x24:
F5INDI_DoSubDList();
@ -2216,15 +2217,15 @@ void F5INDI_GeometryGen(u32 _w0, u32 _w1)
}
static
void F5INDI_Texrect(u32 _w0, u32 _w1)
void F5INDI_Texrect(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_Texrect (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F5INDI_Texrect (0x%08x, 0x%08x)\n", words.w0, words.w1);
F5INDI_DoSubDList();
RDP_TexRect(_w0, _w1);
RDP_TexRect(words);
}
static
void F5INDI_JumpDL(u32 _w0, u32 _w1)
void F5INDI_JumpDL(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_JumpDL\n");
RSP.PC[RSP.PCi] = RSP.F5DL[RSP.PCi];
@ -2232,25 +2233,25 @@ void F5INDI_JumpDL(u32 _w0, u32 _w1)
}
static
void F5INDI_EndDisplayList(u32 _w0, u32 _w1)
void F5INDI_EndDisplayList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_EndDisplayList\n");
gSPEndDisplayList();
gSPEndDisplayList(words);
}
static
void F5INDI_MoveWord(u32 _w0, u32 _w1)
void F5INDI_MoveWord(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F5INDI_MoveWord (0x%08x, 0x%08x)\n", _w0, _w1);
const u32 destAddr = _SHIFTR(_w0, 0, 12);
*CAST_DMEM(u32*, destAddr) = _w1;
DebugMsg(DEBUG_NORMAL, "F5INDI_MoveWord (0x%08x, 0x%08x)\n", words.w0, words.w1);
const u32 destAddr = _SHIFTR(words.w0, 0, 12);
*CAST_DMEM(u32*, destAddr) = words.w1;
switch (destAddr) {
case G_MWO_CLIP_RNX:
case G_MWO_CLIP_RNY:
case G_MWO_CLIP_RPX:
case G_MWO_CLIP_RPY:
gSPClipRatio(_w1);
gSPClipRatio(words.w1);
break;
case G_MW_SEGMENT:
assert(false);
@ -2260,15 +2261,15 @@ void F5INDI_MoveWord(u32 _w0, u32 _w1)
// Used to adjust colors (See command 0x01 - Case 02)
break;
case 0x160:
gSP.fog.multiplierf = _FIXED2FLOAT((s32)_w1, 16);
gSP.fog.multiplierf = _FIXED2FLOAT((s32)words.w1, 16);
gSP.changed |= CHANGED_FOGPOSITION;
break;
case 0x164:
gSP.fog.offsetf = _FIXED2FLOAT((s32)_w1, 16);
gSP.fog.offsetf = _FIXED2FLOAT((s32)words.w1, 16);
gSP.changed |= CHANGED_FOGPOSITION;
break;
case 0x14C:
gSPPerspNormalize(_w1);
gSPPerspNormalize(words.w1);
break;
case 0x58C:
// sub dlist address;
@ -2281,19 +2282,19 @@ void F5INDI_MoveWord(u32 _w0, u32 _w1)
}
static
void F5INDI_SetOtherMode(u32 w0, u32 w1)
void F5INDI_SetOtherMode(const Gwords words)
{
//u32 mask = (s32)0x80000000 >> _SHIFTR(w0, 0, 5); // unspecified behaviour
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << _SHIFTR(w0, 0, 5)));
mask >>= _SHIFTR(w0, 8, 5);
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << _SHIFTR(words.w0, 0, 5)));
mask >>= _SHIFTR(words.w0, 8, 5);
const u32 A0 = _SHIFTR(w0, 16, 3);
const u32 A0 = _SHIFTR(words.w0, 16, 3);
if (A0 == 0) {
gDP.otherMode.h = (gDP.otherMode.h&(~mask)) | w1;
gDP.otherMode.h = (gDP.otherMode.h&(~mask)) | words.w1;
if (mask & 0x00300000) // cycle type
gDP.changed |= CHANGED_CYCLETYPE;
} else if (A0 == 4) {
gDP.otherMode.l = (gDP.otherMode.l&(~mask)) | w1;
gDP.otherMode.l = (gDP.otherMode.l&(~mask)) | words.w1;
if (mask & 0x00000003) // alpha compare
gDP.changed |= CHANGED_ALPHACOMPARE;
@ -2304,26 +2305,26 @@ void F5INDI_SetOtherMode(u32 w0, u32 w1)
}
static
void F5INDI_SetOtherMode_Conditional(u32 w0, u32 w1)
void F5INDI_SetOtherMode_Conditional(const Gwords words)
{
if (_SHIFTR(w0, 23, 1) != *CAST_DMEM(const u32*, 0x11C))
if (_SHIFTR(words.w0, 23, 1) != *CAST_DMEM(const u32*, 0x11C))
return;
F5INDI_SetOtherMode(w0, w1);
F5INDI_SetOtherMode(words);
}
static
void F5INDI_ClearGeometryMode(u32 w0, u32 w1)
void F5INDI_ClearGeometryMode(const Gwords words)
{
gSPClearGeometryMode(~w1);
gSPClearGeometryMode(~words.w1);
}
static
void F5INDI_Texture(u32 w0, u32 w1)
void F5INDI_Texture(const Gwords words)
{
F3D_Texture(w0, w1);
*CAST_DMEM(u32*, 0x148) = w0;
const u32 V0 = (gSP.geometryMode ^ w0) & 2;
F3D_Texture(words);
*CAST_DMEM(u32*, 0x148) = words.w0;
const u32 V0 = (gSP.geometryMode ^ words.w0) & 2;
gSP.geometryMode ^= V0;
}

View File

@ -21,6 +21,10 @@
#include "FrameBuffer.h"
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#endif
#define F3DSWRS_VTXCOLOR 0x02
#define F3DSWRS_MOVEMEM 0x03
#define F3DSWRS_VTX 0x04
@ -133,22 +137,22 @@ void _updateF5DL()
RSP.F5DL[RSP.PCi] = _SHIFTR(*(u32*)&RDRAM[RSP.PC[RSP.PCi]], 0, 24);
}
void F3DSWRS_Mtx(u32 w0, u32 w1)
void F3DSWRS_Mtx(const Gwords words)
{
const u32 param = _SHIFTR(w0, 16, 8);
const u32 param = _SHIFTR(words.w0, 16, 8);
if ((param & G_MTX_PROJECTION) != 0)
F3DSWRS_PerspMatrixAddress = _SHIFTR(w1, 0, 24);
F3D_Mtx(w0, w1);
F3DSWRS_PerspMatrixAddress = _SHIFTR(words.w1, 0, 24);
F3D_Mtx(words);
}
void F3DSWRS_VertexColor(u32, u32 _w1)
void F3DSWRS_VertexColor(const Gwords words)
{
gSPSetVertexColorBase(_w1);
gSPSetVertexColorBase(words.w1);
}
void F3DSWRS_MoveMem(u32 _w0, u32)
void F3DSWRS_MoveMem(const Gwords words)
{
switch (_SHIFTR(_w0, 16, 8)) {
switch (_SHIFTR(words.w0, 16, 8)) {
case F3D_MV_VIEWPORT://G_MV_VIEWPORT:
F3DSWRS_ViewportAddress = _SHIFTR((RSP.PC[RSP.PCi] + 8), 0, 24);
gSPViewport(F3DSWRS_ViewportAddress);
@ -163,12 +167,12 @@ void F3DSWRS_MoveMem(u32 _w0, u32)
RSP.PC[RSP.PCi] += 16;
}
void F3DSWRS_Vtx(u32 _w0, u32 _w1)
void F3DSWRS_Vtx(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_Vtx (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_Vtx (0x%08x, 0x%08x)\n", words.w0, words.w1);
const u32 address = RSP_SegmentToPhysical(_w1);
const u32 n = _SHIFTR(_w0, 10, 6);
const word address = RSP_SegmentToPhysical(words.w1);
const u32 n = _SHIFTR(words.w0, 10, 6);
if ((address + sizeof(SWVertex)* n) > RDRAMSize)
return;
@ -972,18 +976,18 @@ void TriGen02()
drawer.drawTriangles();
}
void F3DSWRS_TriGen(u32 _w0, u32 _w1)
void F3DSWRS_TriGen(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_TriGen (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_TriGen (0x%08x, 0x%08x)\n", words.w0, words.w1);
const u32 nextCmd = RSP.nextCmd;
RSP.nextCmd = G_TRI1;
const u32 mode = _SHIFTR(_w0, 8, 8);
const u32 mode = _SHIFTR(words.w0, 8, 8);
switch (mode) {
case 0x00:
{
const u32 mode00 = _SHIFTR(_w0, 0, 8);
const u32 mode00 = _SHIFTR(words.w0, 0, 8);
switch (mode00) {
case 0x00:
TriGen0000();
@ -1007,31 +1011,31 @@ void F3DSWRS_TriGen(u32 _w0, u32 _w1)
RSP.PC[RSP.PCi] += 32;
}
void F3DSWRS_JumpSWDL(u32, u32)
void F3DSWRS_JumpSWDL(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_JumpSWDL\n");
RSP.PC[RSP.PCi] = RSP.F5DL[RSP.PCi];
_updateF5DL();
}
void F3DSWRS_DList(u32, u32 _w1)
void F3DSWRS_DList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_DList (0x%08x)\n", _w1);
gSPDisplayList(_w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_DList (0x%08x)\n", words.w1);
gSPDisplayList(words.w1);
_updateF5DL();
}
void F3DSWRS_BranchDList(u32, u32 _w1)
void F3DSWRS_BranchDList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_BranchDList (0x%08x)\n", _w1);
gSPBranchList(_w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_BranchDList (0x%08x)\n", words.w1);
gSPBranchList(words.w1);
_updateF5DL();
}
void F3DSWRS_EndDisplayList(u32, u32)
void F3DSWRS_EndDisplayList(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_EndDisplayList\n");
gSPEndDisplayList();
gSPEndDisplayList(words);
// _updateSWDL();
}
@ -1041,7 +1045,7 @@ void _addVertices(const u32 _vert[3], GraphicsDrawer & _drawer)
if (_drawer.isClipped(_vert[0], _vert[1], _vert[2]))
return;
SPVertex & vtx0 = _drawer.getVertex(_vert[(((RSP.w1 >> 24) & 3) % 3)]);
SPVertex & vtx0 = _drawer.getVertex(_vert[(((RSP.words.w1 >> 24) & 3) % 3)]);
for (u32 i = 0; i < 3; ++i) {
SPVertex & vtx = _drawer.getVertex(_vert[i]);
@ -1067,21 +1071,21 @@ void _addVertices(const u32 _vert[3], GraphicsDrawer & _drawer)
}
}
void F3DSWRS_Tri(u32 _w0, u32 _w1)
void F3DSWRS_Tri(const Gwords words)
{
const bool bTri2 = RSP.cmd == F3DSWRS_TRI2;
DebugMsg(DEBUG_NORMAL, "F3DSWRS_Tri%d (0x%08x, 0x%08x)\n", bTri2 ? 2 : 1, _w0, _w1);
const u32 v1 = (_SHIFTR(_w1, 13, 11) & 0x7F8) / 40;
const u32 v2 = (_SHIFTR( _w1, 5, 11 ) & 0x7F8) / 40;
const u32 v3 = ((_w1 << 3) & 0x7F8) / 40;
const u32 v4 = (_SHIFTR( _w1, 21, 11 ) & 0x7F8) / 40;
DebugMsg(DEBUG_NORMAL, "F3DSWRS_Tri%d (0x%08x, 0x%08x)\n", bTri2 ? 2 : 1, words.w0, words.w1);
const u32 v1 = (_SHIFTR(words.w1, 13, 11) & 0x7F8) / 40;
const u32 v2 = (_SHIFTR( words.w1, 5, 11 ) & 0x7F8) / 40;
const u32 v3 = ((words.w1 << 3) & 0x7F8) / 40;
const u32 v4 = (_SHIFTR( words.w1, 21, 11 ) & 0x7F8) / 40;
const u32 vert[4] = { v1, v2, v3, v4 };
const u32 colorParam = *(u32*)&RDRAM[RSP.PC[RSP.PCi] + 8];
const u32 colorIdx[4] = { _SHIFTR(colorParam, 16, 8), _SHIFTR(colorParam, 8, 8),
_SHIFTR(colorParam, 0, 8), _SHIFTR(colorParam, 24, 8) };
const bool useTex = (_w0 & 2) != 0;
const bool useTex = (words.w0 & 2) != 0;
const u8 * texbase = RDRAM + RSP.PC[RSP.PCi] + 16;
F3DSWRS_PrepareVertices(vert, RDRAM + gSP.vertexColorBase, colorIdx, texbase, useTex, gDP.otherMode.texturePersp != 0, bTri2 ? 4 : 3);
@ -1106,35 +1110,35 @@ void F3DSWRS_Tri(u32 _w0, u32 _w1)
RSP.PC[RSP.PCi] += 8;
}
void F3DSWRS_MoveWord(u32 _w0, u32 _w1)
void F3DSWRS_MoveWord(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_MoveWord (0x%08x, 0x%08x)\n", _w0, _w1);
switch (_SHIFTR(_w0, 0, 8)){
DebugMsg(DEBUG_NORMAL, "F3DSWRS_MoveWord (0x%08x, 0x%08x)\n", words.w0, words.w1);
switch (_SHIFTR(words.w0, 0, 8)){
case G_MW_CLIP:
gSPClipRatio( _w1 );
gSPClipRatio( words.w1 );
break;
case G_MW_SEGMENT:
gSPSegment( _SHIFTR( _w0, 8, 16 ) >> 2, _w1 & 0x00FFFFFF );
gSPSegment( _SHIFTR( words.w0, 8, 16 ) >> 2, SEGMENT_MASK(words.w1) );
break;
case F3DSWRS_MW_FOG_MULTIPLIER:
gSP.fog.multiplierf = _FIXED2FLOAT((s32)_w1, 16);
gSP.fog.multiplierf = _FIXED2FLOAT((s32)words.w1, 16);
gSP.changed |= CHANGED_FOGPOSITION;
break;
case F3DSWRS_MW_FOG_OFFSET:
gSP.fog.offsetf = _FIXED2FLOAT((s32)_w1, 16);
gSP.fog.offsetf = _FIXED2FLOAT((s32)words.w1, 16);
gSP.changed |= CHANGED_FOGPOSITION;
break;
case G_MW_PERSPNORM:
gSPPerspNormalize( _w1 );
gSPPerspNormalize( words.w1 );
break;
}
}
void F3DSWRS_TexrectGen(u32 _w0, u32 _w1)
void F3DSWRS_TexrectGen(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_TexrectGen (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_TexrectGen (0x%08x, 0x%08x)\n", words.w0, words.w1);
const u32 vtxIdx = ((_w0 >> 5) & 0x07F8) / 40;
const u32 vtxIdx = ((words.w0 >> 5) & 0x07F8) / 40;
const u32* params = (const u32*)&RDRAM[RSP.PC[RSP.PCi]];
@ -1147,7 +1151,7 @@ void F3DSWRS_TexrectGen(u32 _w0, u32 _w1)
const f32 screenX = v.x / v.w * gSP.viewport.vscale[0] + gSP.viewport.vtrans[0];
const f32 screenY = -v.y / v.w * gSP.viewport.vscale[1] + gSP.viewport.vtrans[1];
const bool flip = (_w0 & 1) != 0;
const bool flip = (words.w0 & 1) != 0;
const u32 w_i = std::max(1U, u32(v.w));
const u32 viewport = *(u32*)&RDRAM[F3DSWRS_ViewportAddress];
@ -1192,12 +1196,12 @@ void F3DSWRS_TexrectGen(u32 _w0, u32 _w1)
u16 dtdy_i = (u16)((param4Y / offset_y_i) >> 10);
u16 E = 0, F = 0;
if ((_w0 & 2) != 0) {
if ((words.w0 & 2) != 0) {
dsdx_i = -dsdx_i;
E = _SHIFTR(params[4], 16, 16);;
}
if ((_w0 & 4) != 0) {
if ((words.w0 & 4) != 0) {
dtdy_i = -dtdy_i;
F = _SHIFTR(params[4], 0, 16);;
}
@ -1244,20 +1248,20 @@ void F3DSWRS_TexrectGen(u32 _w0, u32 _w1)
gDPTextureRectangle(ulx, uly, lrx, lry, gSP.texture.tile, (s16)S, (s16)T, dsdx, dtdy, flip);
}
void F3DSWRS_SetOtherMode_H_EX(u32 _w0, u32 _w1)
void F3DSWRS_SetOtherMode_H_EX(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_SetOtherMode_H_EX (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_SetOtherMode_H_EX (0x%08x, 0x%08x)\n", words.w0, words.w1);
RSP.PC[RSP.PCi] += 8;
gDP.otherMode.h &= *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
gDP.otherMode.h |= _w1;
gDP.otherMode.h |= words.w1;
}
void F3DSWRS_SetOtherMode_L_EX(u32 _w0, u32 _w1)
void F3DSWRS_SetOtherMode_L_EX(const Gwords words)
{
DebugMsg(DEBUG_NORMAL, "F3DSWRS_SetOtherMode_L_EX (0x%08x, 0x%08x)\n", _w0, _w1);
DebugMsg(DEBUG_NORMAL, "F3DSWRS_SetOtherMode_L_EX (0x%08x, 0x%08x)\n", words.w0, words.w1);
RSP.PC[RSP.PCi] += 8;
gDP.otherMode.l &= *(u32*)&RDRAM[RSP.PC[RSP.PCi]];
gDP.otherMode.l |= _w1;
gDP.otherMode.l |= words.w1;
}
void F5Rogue_Init()

View File

@ -9,14 +9,14 @@
#include "gDP.h"
#include "GBI.h"
void L3D_Line3D( u32 w0, u32 w1 )
void L3D_Line3D( const Gwords words )
{
u32 wd = _SHIFTR( w1, 0, 8 );
u32 wd = _SHIFTR( words.w1, 0, 8 );
if (wd == 0)
gSPLine3D( _SHIFTR( w1, 16, 8 ) / 10, _SHIFTR( w1, 8, 8 ) / 10, _SHIFTR( w1, 24, 8 ) );
gSPLine3D( _SHIFTR( words.w1, 16, 8 ) / 10, _SHIFTR( words.w1, 8, 8 ) / 10, _SHIFTR( words.w1, 24, 8 ) );
else
gSPLineW3D( _SHIFTR( w1, 16, 8 ) / 10, _SHIFTR( w1, 8, 8 ) / 10, wd, _SHIFTR( w1, 24, 8 ) );
gSPLineW3D( _SHIFTR( words.w1, 16, 8 ) / 10, _SHIFTR( words.w1, 8, 8 ) / 10, wd, _SHIFTR( words.w1, 24, 8 ) );
}
void L3D_Init()

View File

@ -4,7 +4,7 @@
#define L3D_LINE3D 0xB5
void L3D_Line3D( u32 w0, u32 w1 );
void L3D_Line3D( word w0, word w1 );
void L3D_Init();
#endif

View File

@ -11,14 +11,14 @@
#include "gDP.h"
#include "GBI.h"
void L3DEX_Line3D( u32 w0, u32 w1 )
void L3DEX_Line3D( const Gwords words )
{
u32 wd = _SHIFTR( w1, 0, 8 );
u32 wd = _SHIFTR( words.w1, 0, 8 );
if (wd == 0)
gSPLine3D( _SHIFTR( w1, 17, 7 ), _SHIFTR( w1, 9, 7 ), 0 );
gSPLine3D( _SHIFTR( words.w1, 17, 7 ), _SHIFTR( words.w1, 9, 7 ), 0 );
else
gSPLineW3D( _SHIFTR( w1, 17, 7 ), _SHIFTR( w1, 9, 7 ), wd, 0 );
gSPLineW3D( _SHIFTR( words.w1, 17, 7 ), _SHIFTR( words.w1, 9, 7 ), wd, 0 );
}
void L3DEX_Init()

View File

@ -2,7 +2,7 @@
#define L3DEX_H
#include "Types.h"
void L3DEX_Line3D( u32 w0, u32 w1 );
void L3DEX_Line3D( word w0, word w1 );
void L3DEX_Init();
#endif

View File

@ -11,14 +11,14 @@
#include "gDP.h"
#include "GBI.h"
void L3DEX2_Line3D( u32 w0, u32 w1 )
void L3DEX2_Line3D( const Gwords words )
{
u32 wd = _SHIFTR( (w0 + 1), 0, 8 );
u32 wd = _SHIFTR( (words.w0 + 1), 0, 8 );
if (wd == 0)
gSPLine3D( _SHIFTR( w0, 17, 7 ), _SHIFTR( w0, 9, 7 ), 0 );
gSPLine3D( _SHIFTR( words.w0, 17, 7 ), _SHIFTR( words.w0, 9, 7 ), 0 );
else
gSPLineW3D( _SHIFTR( w0, 17, 7 ), _SHIFTR( w0, 9, 7 ), wd, 0 );
gSPLineW3D( _SHIFTR( words.w0, 17, 7 ), _SHIFTR( words.w0, 9, 7 ), wd, 0 );
}
void L3DEX2_Init()

View File

@ -4,7 +4,7 @@
#define L3DEX2_LINE3D 0x08
void L3DEX2_Line3D( u32 w0, u32 w1 );
void L3DEX2_Line3D( word w0, word w1 );
void L3DEX2_Init();
#endif

View File

@ -18,6 +18,11 @@
#include <Graphics/Parameters.h>
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#define DMEM ((u8*)0)
#endif
using namespace graphics;
#define S2DEX_MV_MATRIX 0
@ -64,6 +69,63 @@ using namespace graphics;
#define G_TX_LOADTILE 0x07
#define G_TX_RENDERTILE 0x00
#ifdef NATIVE
struct uObjBg
{
u16 imageX; /* Texture width (8-byte alignment, u10.2) */
u16 imageW; /* x-coordinate of upper-left
position of texture (u10.5) */
u16 frameX; /* Transfer destination frame width (u10.2) */
s16 frameW; /* x-coordinate of upper-left
position of transfer destination frame (s10.2) */
u16 imageY; /* Texture height (u10.2) */
u16 imageH; /* y-coordinate of upper-left position of
texture (u10.5) */
u16 frameY; /* Transfer destination frame height (u10.2) */
s16 frameH; /* y-coordinate of upper-left position of transfer
destination frame (s10.2) */
u32 imagePtr; /* Address of texture source in DRAM*/
u16 imageLoad; /* Method for loading the BG image texture
G_BGLT_LOADBLOCK (use LoadBlock)
G_BGLT_LOADTILE (use LoadTile) */
u8 imageFmt; /*Texel format
G_IM_FMT_RGBA (RGBA format)
G_IM_FMT_YUV (YUV format)
G_IM_FMT_CI (CI format)
G_IM_FMT_IA (IA format)
G_IM_FMT_I (I format) */
u8 imageSiz; /* Texel size
G_IM_SIZ_4b (4 bits/texel)
G_IM_SIZ_8b (8 bits/texel)
G_IM_SIZ_16b (16 bits/texel)
G_IM_SIZ_32b (32 bits/texel) */
u16 imagePal; /* Position of palette for 4-bit color
index texture (4-bit precision, 0~15) */
u16 imageFlip; /* Image inversion on/off (horizontal
direction only)
0 (normal display (no inversion))
G_BG_FLAG_FLIPS (horizontal inversion of texture image) */
u16 tmemW; /* TMEM width Word size for frame 1 line
When LoadBlock GS_PIX2TMEM(imageW/4,imageSiz)
When LoadTile GS_PIX2TMEM(frameW/4,imageSiz)+1 */
u16 tmemH; /* Quadruple TMEM height(s13.2) which can be loaded at once
When normal texture 512/tmemW*4
When CI Texture 256/tmemW*4 */
u16 tmemLoadSH; /* SH value
When LoadBlock tmemSize/2-1
When LoadTile tmemW*16-1 */
u16 tmemLoadTH; /* TH value or Stride value
When LoadBlock GS_CALC_DXT(tmemW)
When LoadTile tmemH-1 */
u16 tmemSizeW; /* imagePtr skip value for one line of image 1
When LoadBlock tmemW*2
When LoadTile GS_PIX2TMEM(imageW/4,imageSiz)*2 */
u16 tmemSize; /* imagePtr skip value for one load iteration
= tmemSizeW*tmemH */
}; /* 40 bytes */
#else
struct uObjBg {
u16 imageW; /* Texture width (8-byte alignment, u10.2) */
u16 imageX; /* x-coordinate of upper-left
@ -116,6 +178,9 @@ struct uObjBg {
When LoadBlock tmemW*2
When LoadTile GS_PIX2TMEM(imageW/4,imageSiz)*2 */
}; /* 40 bytes */
#endif
static_assert(sizeof(uObjBg) == 40, "incorrect uObjBg size");
struct uObjScaleBg
{
@ -665,7 +730,7 @@ void gSPSetSpriteTile(const uObjSprite *_pObjSprite)
static
void gSPObjLoadTxtr(u32 tx)
{
const u32 address = RSP_SegmentToPhysical(tx);
const word address = RSP_SegmentToPhysical(tx);
uObjTxtr *objTxtr = (uObjTxtr*)&RDRAM[address];
if ((gSP.status[objTxtr->block.sid >> 2] & objTxtr->block.mask) != objTxtr->block.flag) {
@ -700,7 +765,7 @@ void gSPObjLoadTxtr(u32 tx)
static
void gSPObjRectangle(u32 _sp)
{
const u32 address = RSP_SegmentToPhysical(_sp);
const word address = RSP_SegmentToPhysical(_sp);
uObjSprite *objSprite = (uObjSprite*)&RDRAM[address];
gSPSetSpriteTile(objSprite);
@ -712,7 +777,7 @@ void gSPObjRectangle(u32 _sp)
static
void gSPObjRectangleR(u32 _sp)
{
const u32 address = RSP_SegmentToPhysical(_sp);
const word address = RSP_SegmentToPhysical(_sp);
const uObjSprite *objSprite = (uObjSprite*)&RDRAM[address];
gSPSetSpriteTile(objSprite);
ObjCoordinates objCoords(objSprite, true);
@ -727,7 +792,7 @@ void gSPObjRectangleR(u32 _sp)
static
void gSPObjSprite(u32 _sp)
{
const u32 address = RSP_SegmentToPhysical(_sp);
const word address = RSP_SegmentToPhysical(_sp);
uObjSprite *pObjSprite = (uObjSprite*)&RDRAM[address];
gSPSetSpriteTile(pObjSprite);
@ -926,7 +991,7 @@ void _loadBGImage(const uObjScaleBg * _pBgInfo, bool _loadScale, bool _fbImage)
}
static
bool _useOnePieceBgCode(u32 address, bool & fbImage)
bool _useOnePieceBgCode(word address, bool & fbImage)
{
fbImage = false;
if (config.frameBufferEmulation.enable != 0) {
@ -997,11 +1062,15 @@ void BgRectCopyOnePiece(u32 _bg, bool _fbImage)
DebugMsg(DEBUG_NORMAL, "BgRectCopyOnePiece\n");
}
//#define runCommand(w0, w1) GBI.cmd[_SHIFTR(w0, 24, 8)](w0, w1)
//#define runCommand(words.w0, words.w1) GBI.cmd[_SHIFTR(words.w0, 24, 8)](words.w0, words.w1)
inline
void runCommand(u32 w0, u32 w1)
void runCommand(const Gwords words)
{
GBI.cmd[_SHIFTR(w0, 24, 8)](w0, w1);
GBI.cmd[_SHIFTR(words.w0, 24, 8)](words);
};
inline void runCommand(word w0, word w1) {
GBI.cmd[_SHIFTR(w0, 24, 8)](Gwords(w0, w1));
};
static
@ -1157,9 +1226,9 @@ void BgRect1CycStripped(u32 _bgAddr)
*reinterpret_cast<u32*>(DMEM + 0x578) = G2;
*reinterpret_cast<u32*>(DMEM + 0x57C) = (L2 << 16) | A2_1;
runCommand(J2, 0x27000000);
runCommand(J2_1, K2);
runCommand((G_SETTILESIZE<<24), 0);
runCommand(Gwords(J2, 0x27000000));
runCommand(Gwords(J2_1, K2));
runCommand(Gwords((G_SETTILESIZE<<24), 0));
}
if (config.graphics2D.enableNativeResTexrects != 0)
@ -1330,7 +1399,7 @@ void BgRect1CycStripped(u32 _bgAddr)
const u32 w1 = (JJ << 2) | HH;
RDP.w2 = (H2 << 16) | F1_1;
RDP.w3 = (objBg.scaleW << 16) | objBg.scaleH;
RDP_TexRect(w0, w1);
RDP_TexRect(Gwords(w0, w1));
if (FF <= 0)
stop = true;
else {
@ -1488,7 +1557,7 @@ void BgRectCopyStripped(u32 _bgAddr)
w1 = T0 | T1;
RDP.w2 = R;
RDP.w3 = 0x10000400;
RDP_TexRect(w0, w1);
RDP_TexRect(Gwords(w0, w1));
T1 = BB + 1;
S += Z;
if (U > 0)
@ -1512,7 +1581,7 @@ void BgRectCopyStripped(u32 _bgAddr)
w1 = T0 | T1;
RDP.w2 = R;
RDP.w3 = 0x10000400;
RDP_TexRect(w0, w1);
RDP_TexRect(Gwords(w0, w1));
T1 += 4;
AT -= 4;
if (AT <= 0)
@ -1536,9 +1605,9 @@ void BgRectCopyStripped(u32 _bgAddr)
}
}
void S2DEX_BG_1Cyc(u32 w0, u32 w1)
void S2DEX_BG_1Cyc(const Gwords words)
{
const u32 bgAddr = RSP_SegmentToPhysical(w1);
const u32 bgAddr = RSP_SegmentToPhysical(words.w1);
bool fbImage = false;
if (_useOnePieceBgCode(bgAddr, fbImage))
BgRect1CycOnePiece(bgAddr, fbImage);
@ -1546,9 +1615,9 @@ void S2DEX_BG_1Cyc(u32 w0, u32 w1)
BgRect1CycStripped(bgAddr);
}
void S2DEX_BG_Copy(u32 w0, u32 w1)
void S2DEX_BG_Copy(const Gwords words)
{
const u32 bgAddr = RSP_SegmentToPhysical(w1);
const u32 bgAddr = RSP_SegmentToPhysical(words.w1);
bool fbImage = false;
if (_useOnePieceBgCode(bgAddr, fbImage))
BgRectCopyOnePiece(bgAddr, fbImage);
@ -1556,61 +1625,61 @@ void S2DEX_BG_Copy(u32 w0, u32 w1)
BgRectCopyStripped(bgAddr);
}
void S2DEX_Obj_MoveMem(u32 w0, u32 w1)
void S2DEX_Obj_MoveMem(const Gwords words)
{
switch (_SHIFTR(w0, 0, 16)) {
switch (_SHIFTR(words.w0, 0, 16)) {
case S2DEX_MV_MATRIX:
gSPObjMatrix(w1);
gSPObjMatrix(words.w1);
break;
case S2DEX_MV_SUBMUTRIX:
gSPObjSubMatrix(w1);
gSPObjSubMatrix(words.w1);
break;
case S2DEX_MV_VIEWPORT:
gSPViewport(w1);
gSPViewport(words.w1);
break;
}
}
void S2DEX_MoveWord(u32 w0, u32 w1)
void S2DEX_MoveWord(const Gwords words)
{
switch (_SHIFTR(w0, 0, 8))
switch (_SHIFTR(words.w0, 0, 8))
{
case G_MW_GENSTAT:
gSPSetStatus(_SHIFTR(w0, 0, 16), w1);
gSPSetStatus(_SHIFTR(words.w0, 0, 16), words.w1);
break;
default:
F3D_MoveWord(w0, w1);
F3D_MoveWord(words);
break;
}
}
void S2DEX_RDPHalf_0(u32 w0, u32 w1) {
void S2DEX_RDPHalf_0(const Gwords words) {
if (RSP.nextCmd == G_SELECT_DL) {
gSP.selectDL.addr = _SHIFTR(w0, 0, 16);
gSP.selectDL.sid = _SHIFTR(w0, 18, 8);
gSP.selectDL.flag = w1;
gSP.selectDL.addr = _SHIFTR(words.w0, 0, 16);
gSP.selectDL.sid = _SHIFTR(words.w0, 18, 8);
gSP.selectDL.flag = words.w1;
return;
}
if (RSP.nextCmd == G_RDPHALF_1) {
RDP_TexRect(w0, w1);
RDP_TexRect(words);
return;
}
assert(false);
}
void S2DEX_Select_DL(u32 w0, u32 w1)
void S2DEX_Select_DL(const Gwords words)
{
gSP.selectDL.addr |= (_SHIFTR(w0, 0, 16)) << 16;
gSP.selectDL.addr |= (_SHIFTR(words.w0, 0, 16)) << 16;
const u8 sid = gSP.selectDL.sid;
const u32 flag = gSP.selectDL.flag;
const u32 mask = w1;
const u32 mask = words.w1;
if ((gSP.status[sid] & mask) == flag)
// Do nothing;
return;
gSP.status[sid] = (gSP.status[sid] & ~mask) | (flag & mask);
switch (_SHIFTR(w0, 16, 8))
switch (_SHIFTR(words.w0, 16, 8))
{
case G_DL_PUSH:
gSPDisplayList(gSP.selectDL.addr);
@ -1621,48 +1690,48 @@ void S2DEX_Select_DL(u32 w0, u32 w1)
}
}
void S2DEX_Obj_RenderMode(u32 w0, u32 w1)
void S2DEX_Obj_RenderMode(const Gwords words)
{
gSP.objRendermode = w1;
gSP.objRendermode = words.w1;
DebugMsg(DEBUG_NORMAL, "gSPObjRendermode(0x%08x)\n", gSP.objRendermode);
}
void S2DEX_Obj_Rectangle(u32 w0, u32 w1)
void S2DEX_Obj_Rectangle(const Gwords words)
{
gSPObjRectangle(w1);
gSPObjRectangle(words.w1);
}
void S2DEX_Obj_Rectangle_R(u32 w0, u32 w1)
void S2DEX_Obj_Rectangle_R(const Gwords words)
{
gSPObjRectangleR(w1);
gSPObjRectangleR(words.w1);
}
void S2DEX_Obj_Sprite(u32 w0, u32 w1)
void S2DEX_Obj_Sprite(const Gwords words)
{
gSPObjSprite(w1);
gSPObjSprite(words.w1);
}
void S2DEX_Obj_LoadTxtr(u32 w0, u32 w1)
void S2DEX_Obj_LoadTxtr(const Gwords words)
{
gSPObjLoadTxtr(w1);
gSPObjLoadTxtr(words.w1);
}
void S2DEX_Obj_LdTx_Rect(u32 w0, u32 w1)
void S2DEX_Obj_LdTx_Rect(const Gwords words)
{
gSPObjLoadTxtr(w1);
gSPObjRectangle(w1 + sizeof(uObjTxtr));
gSPObjLoadTxtr(words.w1);
gSPObjRectangle(words.w1 + sizeof(uObjTxtr));
}
void S2DEX_Obj_LdTx_Rect_R(u32 w0, u32 w1)
void S2DEX_Obj_LdTx_Rect_R(const Gwords words)
{
gSPObjLoadTxtr(w1);
gSPObjRectangleR(w1 + sizeof(uObjTxtr));
gSPObjLoadTxtr(words.w1);
gSPObjRectangleR(words.w1 + sizeof(uObjTxtr));
}
void S2DEX_Obj_LdTx_Sprite(u32 w0, u32 w1)
void S2DEX_Obj_LdTx_Sprite(const Gwords words)
{
gSPObjLoadTxtr(w1);
gSPObjSprite(w1 + sizeof(uObjTxtr));
gSPObjLoadTxtr(words.w1);
gSPObjSprite(words.w1 + sizeof(uObjTxtr));
}
void S2DEX_Init()

View File

@ -3,19 +3,19 @@
#include "Types.h"
void S2DEX_BG_1Cyc(u32 w0, u32 w1);
void S2DEX_BG_Copy( u32 w0, u32 w1 );
void S2DEX_Obj_Rectangle( u32 w0, u32 w1 );
void S2DEX_Obj_Sprite( u32 w0, u32 w1 );
void S2DEX_Obj_MoveMem( u32 w0, u32 w1 );
void S2DEX_RDPHalf_0( u32 w0, u32 w1 );
void S2DEX_Select_DL( u32 w0, u32 w1 );
void S2DEX_Obj_RenderMode( u32 w0, u32 w1 );
void S2DEX_Obj_Rectangle_R( u32 w0, u32 w1 );
void S2DEX_Obj_LoadTxtr( u32 w0, u32 w1 );
void S2DEX_Obj_LdTx_Sprite( u32 w0, u32 w1 );
void S2DEX_Obj_LdTx_Rect( u32 w0, u32 w1 );
void S2DEX_Obj_LdTx_Rect_R( u32 w0, u32 w1 );
void S2DEX_BG_1Cyc(const Gwords words);
void S2DEX_BG_Copy( const Gwords words );
void S2DEX_Obj_Rectangle( const Gwords words );
void S2DEX_Obj_Sprite( const Gwords words );
void S2DEX_Obj_MoveMem( const Gwords words );
void S2DEX_RDPHalf_0( const Gwords words );
void S2DEX_Select_DL( const Gwords words );
void S2DEX_Obj_RenderMode( const Gwords words );
void S2DEX_Obj_Rectangle_R( const Gwords words );
void S2DEX_Obj_LoadTxtr( const Gwords words );
void S2DEX_Obj_LdTx_Sprite( const Gwords words );
void S2DEX_Obj_LdTx_Rect( const Gwords words );
void S2DEX_Obj_LdTx_Rect_R( const Gwords words );
void S2DEX_1_03_Init();
void S2DEX_1_05_Init();
void S2DEX_1_07_Init();

View File

@ -23,15 +23,15 @@
#define S2DEX2_BG_COPY 0x0A
#define S2DEX2_OBJ_RENDERMODE 0x0B
void S2DEX2_MoveWord( u32 w0, u32 w1 )
void S2DEX2_MoveWord( const Gwords words )
{
switch (_SHIFTR( w0, 16, 8 ))
switch (_SHIFTR( words.w0, 16, 8 ))
{
case G_MW_GENSTAT:
gSPSetStatus(_SHIFTR(w0, 0, 16), w1);
gSPSetStatus(_SHIFTR(words.w0, 0, 16), words.w1);
break;
default:
F3DEX2_MoveWord(w0, w1);
F3DEX2_MoveWord(words);
break;
}
}

View File

@ -60,14 +60,14 @@ static u32 t32uxSetTileW1 = 0;
static
void T3DUX_ProcessRDP(u32 _cmds)
{
u32 addr = RSP_SegmentToPhysical(_cmds) >> 2;
word addr = RSP_SegmentToPhysical(_cmds) >> 2;
if (addr != 0) {
RSP.LLE = true;
u32 w0 = ((u32*)RDRAM)[addr++];
u32 w1 = ((u32*)RDRAM)[addr++];
RSP.cmd = _SHIFTR( w0, 24, 8 );
while (w0 + w1 != 0) {
GBI.cmd[RSP.cmd]( w0, w1 );
GBI.cmd[RSP.cmd]( Gwords(w0, w1) );
w0 = ((u32*)RDRAM)[addr++];
w1 = ((u32*)RDRAM)[addr++];
RSP.cmd = _SHIFTR( w0, 24, 8 );
@ -90,7 +90,7 @@ void T3DUX_ProcessRDP(u32 _cmds)
static
void T3DUX_LoadGlobState(u32 pgstate)
{
const u32 addr = RSP_SegmentToPhysical(pgstate);
const word addr = RSP_SegmentToPhysical(pgstate);
T3DUXGlobState *gstate = (T3DUXGlobState*)&RDRAM[addr];
const u32 w0 = gstate->othermode0;
const u32 w1 = gstate->othermode1;
@ -98,7 +98,7 @@ void T3DUX_LoadGlobState(u32 pgstate)
w1 ); // mode1
for (int s = 0; s < 16; ++s)
gSPSegment(s, gstate->segBases[s] & 0x00FFFFFF);
gSPSegment(s, SEGMENT_MASK(gstate->segBases[s]));
gSPViewport(pgstate + 80);
@ -158,7 +158,7 @@ void T3DUX_LoadObject(u32 pstate, u32 pvtx, u32 ptri, u32 pcol)
drawer.drawDMATriangles(static_cast<u32>(pVtx - drawer.getDMAVerticesData()));
pVtx = drawer.getDMAVerticesData();
pal = newPal;
RDP_SetTile(t32uxSetTileW0, w1);
RDP_SetTile(Gwords(t32uxSetTileW0, w1));
}
}
@ -213,7 +213,7 @@ void T3DUX_LoadObject(u32 pstate, u32 pvtx, u32 ptri, u32 pcol)
void RunT3DUX()
{
while (true) {
u32 addr = RSP.PC[RSP.PCi] >> 2;
word addr = RSP.PC[RSP.PCi] >> 2;
const u32 pgstate = ((u32*)RDRAM)[addr++];
const u32 pstate = ((u32*)RDRAM)[addr++];
const u32 pvtx = ((u32*)RDRAM)[addr++];

View File

@ -79,14 +79,14 @@ struct VtxOut {
static
void Turbo3D_ProcessRDP(u32 _cmds)
{
u32 addr = RSP_SegmentToPhysical(_cmds) >> 2;
word addr = RSP_SegmentToPhysical(_cmds) >> 2;
if (addr != 0) {
RSP.LLE = true;
u32 w0 = ((u32*)RDRAM)[addr++];
u32 w1 = ((u32*)RDRAM)[addr++];
RSP.cmd = _SHIFTR( w0, 24, 8 );
while (w0 + w1 != 0) {
GBI.cmd[RSP.cmd]( w0, w1 );
GBI.cmd[RSP.cmd]( Gwords(w0, w1) );
w0 = ((u32*)RDRAM)[addr++];
w1 = ((u32*)RDRAM)[addr++];
RSP.cmd = _SHIFTR( w0, 24, 8 );
@ -102,7 +102,7 @@ void Turbo3D_ProcessRDP(u32 _cmds)
static
void Turbo3D_LoadGlobState(u32 pgstate)
{
const u32 addr = RSP_SegmentToPhysical(pgstate);
const word addr = RSP_SegmentToPhysical(pgstate);
T3DGlobState *gstate = (T3DGlobState*)&RDRAM[addr];
const u32 w0 = gstate->othermode0;
const u32 w1 = gstate->othermode1;
@ -110,7 +110,7 @@ void Turbo3D_LoadGlobState(u32 pgstate)
w1 ); // mode1
for (int s = 0; s < 16; ++s)
gSPSegment(s, gstate->segBases[s] & 0x00FFFFFF);
gSPSegment(s, SEGMENT_MASK(gstate->segBases[s]));
gSPViewport(pgstate + 80);
@ -120,7 +120,7 @@ void Turbo3D_LoadGlobState(u32 pgstate)
static
void Turbo3D_LoadObject(u32 pstate, u32 pvtx, u32 ptri)
{
u32 addr = RSP_SegmentToPhysical(pstate);
word addr = RSP_SegmentToPhysical(pstate);
T3DState *ostate = (T3DState*)&RDRAM[addr];
const u32 tile = (ostate->textureState)&7;
gSP.texture.tile = tile;
@ -182,7 +182,7 @@ void Turbo3D_LoadObject(u32 pstate, u32 pvtx, u32 ptri)
void RunTurbo3D()
{
while (true) {
u32 addr = RSP.PC[RSP.PCi] >> 2;
word addr = RSP.PC[RSP.PCi] >> 2;
const u32 pgstate = ((u32*)RDRAM)[addr++];
const u32 pstate = ((u32*)RDRAM)[addr++];
const u32 pvtx = ((u32*)RDRAM)[addr++];

View File

@ -33,25 +33,25 @@ struct ZSORTRDP
f32 view_trans[2];
} zSortRdp = {{0, 0}, {0, 0}};
void ZSort_RDPCMD( u32, u32 _w1 )
void ZSort_RDPCMD( const Gwords words )
{
u32 addr = RSP_SegmentToPhysical(_w1) >> 2;
word addr = RSP_SegmentToPhysical(words.w1) >> 2;
if (addr) {
RSP.LLE = true;
while(true)
{
u32 w0 = ((u32*)RDRAM)[addr++];
word w0 = ((word*)RDRAM)[addr++];
RSP.cmd = _SHIFTR( w0, 24, 8 );
if (RSP.cmd == 0xDF)
break;
u32 w1 = ((u32*)RDRAM)[addr++];
word w1 = ((word*)RDRAM)[addr++];
if (RSP.cmd == G_TEXRECT || RSP.cmd == G_TEXRECTFLIP) {
addr++;
RDP.w2 = ((u32*)RDRAM)[addr++];
RDP.w2 = ((word*)RDRAM)[addr++];
addr++;
RDP.w3 = ((u32*)RDRAM)[addr++];
RDP.w3 = ((word*)RDRAM)[addr++];
}
GBI.cmd[RSP.cmd]( w0, w1 );
GBI.cmd[RSP.cmd]( words );
};
RSP.LLE = false;
}
@ -138,7 +138,7 @@ u32 ZSort_LoadObject (u32 _zHeader, u32 * _pRdpCmds)
w1 = ((u32*)addr)[1];
if (w1 != _pRdpCmds[0]) {
_pRdpCmds[0] = w1;
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
}
ZSort_DrawObject(addr + 8, type);
}
@ -150,16 +150,16 @@ u32 ZSort_LoadObject (u32 _zHeader, u32 * _pRdpCmds)
w1 = ((u32*)addr)[1];
if (w1 != _pRdpCmds[0]) {
_pRdpCmds[0] = w1;
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
}
w1 = ((u32*)addr)[2];
if (w1 != _pRdpCmds[1]) {
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
_pRdpCmds[1] = w1;
}
w1 = ((u32*)addr)[3];
if (w1 != _pRdpCmds[2]) {
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
_pRdpCmds[2] = w1;
}
if (type != 0) {
@ -171,11 +171,11 @@ u32 ZSort_LoadObject (u32 _zHeader, u32 * _pRdpCmds)
return RSP_SegmentToPhysical(((u32*)addr)[0]);
}
void ZSort_Obj( u32 _w0, u32 _w1 )
void ZSort_Obj( const Gwords words )
{
u32 rdpcmds[3] = {0, 0, 0};
u32 cmd1 = _w1;
u32 zHeader = RSP_SegmentToPhysical(_w0);
u32 cmd1 = words.w1;
u32 zHeader = RSP_SegmentToPhysical(words.w0);
while (zHeader)
zHeader = ZSort_LoadObject(zHeader, rdpcmds);
zHeader = RSP_SegmentToPhysical(cmd1);
@ -183,16 +183,16 @@ void ZSort_Obj( u32 _w0, u32 _w1 )
zHeader = ZSort_LoadObject(zHeader, rdpcmds);
}
void ZSort_Interpolate( u32, u32 )
void ZSort_Interpolate( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_Interpolate Ignored");
}
void ZSort_XFMLight( u32 _w0, u32 _w1 )
void ZSort_XFMLight( const Gwords words )
{
int mid = _SHIFTR(_w0, 0, 8);
gSPNumLights(1 + _SHIFTR(_w1, 12, 8));
u32 addr = -1024 + _SHIFTR(_w1, 0, 12);
int mid = _SHIFTR(words.w0, 0, 8);
gSPNumLights(1 + _SHIFTR(words.w1, 12, 8));
word addr = -1024 + _SHIFTR(words.w1, 0, 12);
assert(mid == GZM_MMTX);
/*
@ -236,19 +236,19 @@ void ZSort_XFMLight( u32 _w0, u32 _w1 )
}
}
void ZSort_LightingL( u32, u32 )
void ZSort_LightingL( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_LightingL Ignored");
}
void ZSort_Lighting( u32 _w0, u32 _w1 )
void ZSort_Lighting( const Gwords words )
{
u32 csrs = -1024 + _SHIFTR(_w0, 12, 12);
u32 nsrs = -1024 + _SHIFTR(_w0, 0, 12);
u32 num = 1 + _SHIFTR(_w1, 24, 8);
u32 cdest = -1024 + _SHIFTR(_w1, 12, 12);
u32 tdest = -1024 + _SHIFTR(_w1, 0, 12);
u32 csrs = -1024 + _SHIFTR(words.w0, 12, 12);
u32 nsrs = -1024 + _SHIFTR(words.w0, 0, 12);
u32 num = 1 + _SHIFTR(words.w1, 24, 8);
u32 cdest = -1024 + _SHIFTR(words.w1, 12, 12);
u32 tdest = -1024 + _SHIFTR(words.w1, 0, 12);
int use_material = (csrs != 0x0ff0);
tdest >>= 1;
GraphicsDrawer & drawer = dwnd().getDrawer();
@ -292,18 +292,18 @@ void ZSort_Lighting( u32 _w0, u32 _w1 )
}
}
void ZSort_MTXRNSP( u32, u32 )
void ZSort_MTXRNSP( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_MTXRNSP Ignored");
}
void ZSort_MTXCAT(u32 _w0, u32 _w1)
void ZSort_MTXCAT( const Gwords words )
{
M44 *s = nullptr;
M44 *t = nullptr;
u32 S = _SHIFTR(_w0, 0, 4);
u32 T = _SHIFTR(_w1, 16, 4);
u32 D = _SHIFTR(_w1, 0, 4);
u32 S = _SHIFTR(words.w0, 0, 4);
u32 T = _SHIFTR(words.w1, 16, 4);
u32 D = _SHIFTR(words.w1, 0, 4);
switch (S) {
case GZM_MMTX:
s = (M44*)gSP.matrix.modelView[gSP.matrix.modelViewi];
@ -343,11 +343,11 @@ void ZSort_MTXCAT(u32 _w0, u32 _w1)
}
}
void ZSort_MultMPMTX( u32 _w0, u32 _w1 )
void ZSort_MultMPMTX( const Gwords words )
{
int num = 1 + _SHIFTR(_w1, 24, 8);
int src = -1024 + _SHIFTR(_w1, 12, 12);
int dst = -1024 + _SHIFTR(_w1, 0, 12);
int num = 1 + _SHIFTR(words.w1, 24, 8);
int src = -1024 + _SHIFTR(words.w1, 12, 12);
int dst = -1024 + _SHIFTR(words.w1, 0, 12);
s16 * saddr = (s16*)(DMEM+src);
zSortVDest * daddr = (zSortVDest*)(DMEM+dst);
int idx = 0;
@ -389,22 +389,22 @@ void ZSort_MultMPMTX( u32 _w0, u32 _w1 )
}
}
void ZSort_LinkSubDL( u32, u32 )
void ZSort_LinkSubDL( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_LinkSubDL Ignored");
}
void ZSort_SetSubDL( u32, u32 )
void ZSort_SetSubDL( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_SetSubDL Ignored");
}
void ZSort_WaitSignal( u32, u32 )
void ZSort_WaitSignal( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_WaitSignal Ignored");
}
void ZSort_SendSignal( u32, u32 )
void ZSort_SendSignal( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSort_SendSignal Ignored");
}
@ -421,22 +421,22 @@ void ZSort_SetTexture()
gSPSetGeometryMode(G_SHADING_SMOOTH | G_SHADE);
}
void ZSort_MoveMem( u32 _w0, u32 _w1 )
void ZSort_MoveMem( const Gwords words )
{
int idx = _w0 & 0x0E;
int ofs = _SHIFTR(_w0, 6, 9)<<3;
int len = 1 + (_SHIFTR(_w0, 15, 9)<<3);
int flag = _w0 & 0x01;
u32 addr = RSP_SegmentToPhysical(_w1);
word idx = words.w0 & 0x0E;
word ofs = _SHIFTR(words.w0, 6, 9)<<3;
word len = 1 + (_SHIFTR(words.w0, 15, 9)<<3);
word flag = words.w0 & 0x01;
word addr = RSP_SegmentToPhysical(words.w1);
switch (idx)
{
case GZF_LOAD: //save/load
if (flag == 0) {
int dmem_addr = (idx<<3) + ofs;
word dmem_addr = (idx<<3) + ofs;
memcpy(DMEM + dmem_addr, RDRAM + addr, len);
} else {
int dmem_addr = (idx<<3) + ofs;
word dmem_addr = (idx<<3) + ofs;
memcpy(RDRAM + addr, DMEM + dmem_addr, len);
}
break;
@ -504,9 +504,9 @@ void ZSort_MoveMem( u32 _w0, u32 _w1 )
}
void SZort_SetScissor(u32 _w0, u32 _w1)
void SZort_SetScissor( const Gwords words )
{
RDP_SetScissor(_w0, _w1);
RDP_SetScissor(words);
if ((gDP.scissor.lrx - gDP.scissor.ulx) > (zSortRdp.view_scale[0] - zSortRdp.view_trans[0]))
{

View File

@ -15,7 +15,7 @@ struct zSortVDest{
typedef f32 M44[4][4];
void ZSort_Init();
void ZSort_RDPCMD( u32, u32 _w1 );
void ZSort_RDPCMD( const Gwords words );
int Calc_invw( int _w );
#endif // ZSORT_H

View File

@ -11,6 +11,11 @@
#include "3DMath.h"
#include "DisplayWindow.h"
#ifdef NATIVE
#define RDRAM ((u8*)0)
#define DMEM ((u8*)0)
#endif
#define CLAMP(x, min, max) ((x > max) ? max : ((x < min) ? min: x))
#define SATURATES8(x) ((x > 127) ? 127 : ((x < -128) ? -128: x))
@ -36,7 +41,7 @@ struct ZSortBOSSState {
struct ZSortBOSSState gstate;
void ZSortBOSS_EndMainDL( u32, u32 )
void ZSortBOSS_EndMainDL( const Gwords words )
{
if(gstate.subdl == PROCESSED) {
// is this really happening?
@ -63,7 +68,7 @@ void ZSortBOSS_EndMainDL( u32, u32 )
LOG(LOG_VERBOSE, "ZSortBOSS_EndMainDL");
}
void ZSortBOSS_EndSubDL( u32, u32 )
void ZSortBOSS_EndSubDL( const Gwords words )
{
if(gstate.maindl == PROCESSED) {
RSP.halt = true;
@ -80,7 +85,7 @@ void ZSortBOSS_EndSubDL( u32, u32 )
LOG(LOG_VERBOSE, "ZSortBOSS_EndSubDL");
}
void ZSortBOSS_WaitSignal( u32 , u32 )
void ZSortBOSS_WaitSignal( const Gwords words )
{
if(!gstate.waiting_for_signal) {
// *REG.MI_INTR |= MI_INTR_SP;
@ -101,26 +106,26 @@ void ZSortBOSS_WaitSignal( u32 , u32 )
LOG(LOG_VERBOSE, "ZSortBOSS_WaitSignal");
}
void ZSortBOSS_MoveWord( u32 _w0, u32 _w1 )
void ZSortBOSS_MoveWord( const Gwords words )
{
assert((_w0 & 3) == 0);
assert((words.w0 & 3) == 0);
if(((_w0 & 0xfff) == 0x10) && (RSP.nextCmd == 0x04)) { // Next cmd is G_ZSBOSS_MOVEMEM
gstate.invw_factor = (f32)_w1;
if(((words.w0 & 0xfff) == 0x10) && (RSP.nextCmd == 0x04)) { // Next cmd is G_ZSBOSS_MOVEMEM
gstate.invw_factor = (f32)words.w1;
}
memcpy((DMEM + (_w0 & 0xfff)), &_w1, sizeof(u32));
LOG(LOG_VERBOSE, "ZSortBOSS_MoveWord (Write 0x%08x to DMEM: 0x%04x)", _w1, (_w0 & 0xfff));
memcpy((DMEM + (words.w0 & 0xfff)), &words.w1, sizeof(u32));
LOG(LOG_VERBOSE, "ZSortBOSS_MoveWord (Write 0x%08x to DMEM: 0x%04x)", words.w1, (words.w0 & 0xfff));
}
void ZSortBOSS_ClearBuffer( u32, u32 )
void ZSortBOSS_ClearBuffer( const Gwords words )
{
memset((DMEM + 0xc20), 0, 512);
LOG(LOG_VERBOSE, "ZSortBOSS_ClearBuffer (Write 0x0 to DMEM: 0x0c20 -> 0x0e20)");
}
static
void StoreMatrix( f32 mtx[4][4], u32 address )
void StoreMatrix( f32 mtx[4][4], word address )
{
struct _N64Matrix
{
@ -137,18 +142,18 @@ void StoreMatrix( f32 mtx[4][4], u32 address )
}
}
void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 )
void ZSortBOSS_MoveMem( const Gwords words )
{
int flag = (_w0 >> 23) & 0x01;
int len = 1 + (_w0 >> 12) & 0x7ff;
u32 addr = RSP_SegmentToPhysical(_w1);
int flag = (words.w0 >> 23) & 0x01;
int len = 1 + (words.w0 >> 12) & 0x7ff;
word addr = RSP_SegmentToPhysical(words.w1);
assert((addr & 3) == 0);
assert((_w0 & 3) == 0);
assert((words.w0 & 3) == 0);
LOG(LOG_VERBOSE, "ZSortBOSS_MoveMem (R/W: %d, RDRAM: 0x%08x, DMEM: 0x%04x; len: %d)", flag, addr, (_w0 & 0xfff), len);
LOG(LOG_VERBOSE, "ZSortBOSS_MoveMem (R/W: %d, RDRAM: 0x%08x, DMEM: 0x%04x; len: %d)", flag, addr, (words.w0 & 0xfff), len);
// model matrix
if((_w0 & 0xfff) == 0x830) {
if((words.w0 & 0xfff) == 0x830) {
assert(flag == 0);
RSP_LoadMatrix(gSP.matrix.modelView[gSP.matrix.modelViewi], addr);
gSP.changed |= CHANGED_MATRIX;
@ -156,7 +161,7 @@ void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 )
}
// projection matrix
if((_w0 & 0xfff) == 0x870) {
if((words.w0 & 0xfff) == 0x870) {
assert(flag == 0);
RSP_LoadMatrix(gSP.matrix.projection, addr);
gSP.changed |= CHANGED_MATRIX;
@ -164,7 +169,7 @@ void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 )
}
// combined matrix
if((_w0 & 0xfff) == 0x8b0) {
if((words.w0 & 0xfff) == 0x8b0) {
if(flag == 0) {
RSP_LoadMatrix(gSP.matrix.combined, addr);
gSP.changed &= ~CHANGED_MATRIX;
@ -175,7 +180,7 @@ void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 )
}
// VIEWPORT
if((_w0 & 0xfff) == 0x0) {
if((words.w0 & 0xfff) == 0x0) {
u32 a = addr >> 1;
const f32 scale_x = _FIXED2FLOAT( ((s16*)RDRAM)[(a+0)^1], 2 );
@ -211,26 +216,26 @@ void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 )
return;
}
if((_w0 & 0xfff) == 0x730) {
if((words.w0 & 0xfff) == 0x730) {
assert(len == 256);
memcpy(gstate.fogtable, (RDRAM + addr), len);
}
if(flag == 0) {
memcpy((DMEM + (_w0 & 0xfff)), (RDRAM + addr), len);
memcpy((DMEM + (words.w0 & 0xfff)), (RDRAM + addr), len);
} else {
memcpy((RDRAM + addr), (DMEM + (_w0 & 0xfff)), len);
memcpy((RDRAM + addr), (DMEM + (words.w0 & 0xfff)), len);
}
}
void ZSortBOSS_MTXCAT(u32 _w0, u32 _w1)
void ZSortBOSS_MTXCAT( const Gwords words )
{
M44 *s = nullptr;
M44 *t = nullptr;
M44 *d = nullptr;
u32 S = (_w1 >> 16) & 0xfff;
u32 T = _w0 & 0xfff;
u32 D = _w1 & 0xfff;
u32 S = (words.w1 >> 16) & 0xfff;
u32 T = words.w0 & 0xfff;
u32 D = words.w1 & 0xfff;
switch(S) {
// model matrix
@ -293,12 +298,12 @@ void ZSortBOSS_MTXCAT(u32 _w0, u32 _w1)
LOG(LOG_VERBOSE, "ZSortBOSS_MTXCAT (S: 0x%04x, T: 0x%04x, D: 0x%04x)", S, T, D);
}
void ZSortBOSS_MultMPMTX( u32 _w0, u32 _w1 )
void ZSortBOSS_MultMPMTX( const Gwords words )
{
assert((_w0 & 0xfff) == 0x8b0); // combined matrix
int num = 1 + _SHIFTR(_w1, 24, 8);
int src = (_w1 >> 12) & 0xfff;
int dst = _w1 & 0xfff;
assert((words.w0 & 0xfff) == 0x8b0); // combined matrix
int num = 1 + _SHIFTR(words.w1, 24, 8);
int src = (words.w1 >> 12) & 0xfff;
int dst = words.w1 & 0xfff;
assert((src & 3) == 0);
assert((dst & 3) == 0);
@ -426,16 +431,16 @@ u32 ZSortBOSS_LoadObject(u32 _zHeader)
w1 = ((u32*)addr)[1];
if(w1 != gstate.rdpcmds[0]) {
gstate.rdpcmds[0] = w1;
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
}
w1 = ((u32*)addr)[2];
if(w1 != gstate.rdpcmds[1]) {
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
gstate.rdpcmds[1] = w1;
}
w1 = ((u32*)addr)[3];
if(w1 != gstate.rdpcmds[2]) {
ZSort_RDPCMD (0, w1);
ZSort_RDPCMD (Gwords(0, w1));
gstate.rdpcmds[2] = w1;
}
if(type != ZH_NULL) {
@ -447,26 +452,26 @@ u32 ZSortBOSS_LoadObject(u32 _zHeader)
return RSP_SegmentToPhysical(((u32*)addr)[0]);
}
void ZSortBOSS_Obj( u32 _w0, u32 _w1 )
void ZSortBOSS_Obj( const Gwords words )
{
// make sure no pending subdl
assert((*REG.SP_STATUS & 0x80) == 0);
u32 zHeader = RSP_SegmentToPhysical(_w0);
u32 zHeader = RSP_SegmentToPhysical(words.w0);
while(zHeader)
zHeader = ZSortBOSS_LoadObject(zHeader);
zHeader = RSP_SegmentToPhysical(_w1);
zHeader = RSP_SegmentToPhysical(words.w1);
while(zHeader)
zHeader = ZSortBOSS_LoadObject(zHeader);
}
void ZSortBOSS_TransposeMTX( u32, u32 _w1 )
void ZSortBOSS_TransposeMTX( const Gwords words )
{
M44 *mtx = nullptr;
f32 m[4][4];
assert((_w1 & 0xfff) == 0x830); // model matrix
assert((words.w1 & 0xfff) == 0x830); // model matrix
switch(_w1 & 0xfff) {
switch(words.w1 & 0xfff) {
// model matrix
case 0x830:
mtx = (M44*)gSP.matrix.modelView[gSP.matrix.modelViewi];
@ -495,20 +500,20 @@ void ZSortBOSS_TransposeMTX( u32, u32 _w1 )
}
}
LOG(LOG_VERBOSE, "ZSortBOSS_TransposeMTX (MTX: 0x%04x)", (_w1 & 0xfff));
LOG(LOG_VERBOSE, "ZSortBOSS_TransposeMTX (MTX: 0x%04x)", (words.w1 & 0xfff));
}
void ZSortBOSS_Lighting( u32 _w0, u32 _w1 )
void ZSortBOSS_Lighting( const Gwords words )
{
u32 num = 1 + (_w1 >> 24);
u32 nsrs = _w0 & 0xfff;
u32 csrs = (_w0 >> 12) & 0xfff;
u32 cdest = (_w1 >> 12) & 0xfff;
u32 tdest = _w1 & 0xfff;
u32 num = 1 + (words.w1 >> 24);
u32 nsrs = words.w0 & 0xfff;
u32 csrs = (words.w0 >> 12) & 0xfff;
u32 cdest = (words.w1 >> 12) & 0xfff;
u32 tdest = words.w1 & 0xfff;
assert((tdest & 3) == 0);
tdest >>= 1;
u32 r4 = _w0 << 7;
u32 r4 = words.w0 << 7;
u32 r9 = DMEM[0x944];
assert(r9 == 0);
@ -543,7 +548,7 @@ void ZSortBOSS_Lighting( u32 _w0, u32 _w1 )
((s16*)DMEM)[(tdest++)^1] = (s16)vtx.t;
}
LOG(LOG_VERBOSE, "ZSortBOSS_Lighting (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_Lighting (0x%08x, 0x%08x)", words.w0, words.w1);
}
static
@ -568,18 +573,18 @@ void ZSortBOSS_TransformVectorNormalize(float vec[3], float mtx[4][4])
vec[2] = vres[2] * recip;
}
void ZSortBOSS_TransformLights( u32 _w0, u32 _w1 )
void ZSortBOSS_TransformLights( const Gwords words )
{
assert((_w0 & 0xfff) == 0x830); // model matrix
assert(_w1 == 0x1630); // no light only lookat
assert((_w1 & 3) == 0);
assert((words.w0 & 0xfff) == 0x830); // model matrix
assert(words.w1 == 0x1630); // no light only lookat
assert((words.w1 & 3) == 0);
M44 *mtx = nullptr;
int addr = _w1 & 0xfff;
gSP.numLights = 1 - (_w1 >> 12);
int addr = words.w1 & 0xfff;
gSP.numLights = 1 - (words.w1 >> 12);
/*
switch(_w0 & 0xfff) {
switch(words.w0 & 0xfff) {
// model matrix
case 0x830:
mtx = (M44*)gSP.matrix.modelView[gSP.matrix.modelViewi];
@ -620,27 +625,27 @@ void ZSortBOSS_TransformLights( u32 _w0, u32 _w1 )
addr += 24;
}
LOG(LOG_VERBOSE, "ZSortBOSS_TransformLights (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_TransformLights (0x%08x, 0x%08x)", words.w0, words.w1);
}
void ZSortBOSS_Audio1( u32 _w0, u32 _w1 )
void ZSortBOSS_Audio1( const Gwords words )
{
u32 addr = RSP_SegmentToPhysical(_w1);
u32 val = ((u32*)DMEM)[(_w0 & 0xfff) >> 2];
word addr = RSP_SegmentToPhysical(words.w1);
u32 val = ((u32*)DMEM)[(words.w0 & 0xfff) >> 2];
((u32*)DMEM)[0] = val;
memcpy(RDRAM+addr, DMEM, 0x8);
LOG(LOG_VERBOSE, "ZSortBOSS_Audio1 (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_Audio1 (0x%08x, 0x%08x)", words.w0, words.w1);
}
void ZSortBOSS_Audio2( u32 _w0, u32 _w1 )
void ZSortBOSS_Audio2( const Gwords words )
{
int len = _w1 >> 24;
int len = words.w1 >> 24;
// Written by previous ZSortBOSS_MoveWord
u32 dst = ((u32*)DMEM)[0x10>>2];
f32 f1 = (f32)((_w0>>16) & 0xff) + (f32)(_w0 & 0xffff) / 65536.f;
f32 f2 = (f32)((_w1>>16) & 0xff) + (f32)(_w1 & 0xffff) / 65536.f;
f32 f1 = (f32)((words.w0>>16) & 0xff) + (f32)(words.w0 & 0xffff) / 65536.f;
f32 f2 = (f32)((words.w1>>16) & 0xff) + (f32)(words.w1 & 0xffff) / 65536.f;
// Written by previous ZSortBOSS_MoveWord
u16 v11[2];
@ -678,12 +683,12 @@ void ZSortBOSS_Audio2( u32 _w0, u32 _w1 )
}
}
LOG(LOG_VERBOSE, "ZSortBOSS_Audio2 (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_Audio2 (0x%08x, 0x%08x)", words.w0, words.w1);
}
void ZSortBOSS_Audio3( u32 _w0, u32 _w1 )
void ZSortBOSS_Audio3( const Gwords words )
{
u32 addr = RSP_SegmentToPhysical(_w0);
word addr = RSP_SegmentToPhysical(words.w0);
assert((addr & 3) == 0);
for(int i = 0; i < 8; i++) {
@ -692,24 +697,24 @@ void ZSortBOSS_Audio3( u32 _w0, u32 _w1 )
}
}
addr = RSP_SegmentToPhysical(_w1);
addr = RSP_SegmentToPhysical(words.w1);
assert((addr & 3) == 0);
// What is this?
memcpy(DMEM, (RDRAM + addr), 0x8);
memcpy((DMEM+8), &addr, sizeof(addr));
LOG(LOG_VERBOSE, "ZSortBOSS_Audio3 (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_Audio3 (0x%08x, 0x%08x)", words.w0, words.w1);
}
void ZSortBOSS_Audio4( u32 _w0, u32 _w1 )
void ZSortBOSS_Audio4( const Gwords words )
{
u32 addr = RSP_SegmentToPhysical(_w1);
word addr = RSP_SegmentToPhysical(words.w1);
assert((addr & 3) == 0);
u32 src = ((_w0 & 0xf000) >> 12) + addr;
u32 src = ((words.w0 & 0xf000) >> 12) + addr;
s16 * dst = (s16*)(DMEM+0x30);
int len = (_w0 & 0xfff);
int len = (words.w0 & 0xfff);
// Written by previous ZSortBOSS_MoveWord
s16 v1 = ((s16*)DMEM)[(0>>1)^1];
@ -769,23 +774,23 @@ void ZSortBOSS_Audio4( u32 _w0, u32 _w1 )
}
}
LOG(LOG_VERBOSE, "ZSortBOSS_Audio4 (0x%08x, 0x%08x)", _w0, _w1);
LOG(LOG_VERBOSE, "ZSortBOSS_Audio4 (0x%08x, 0x%08x)", words.w0, words.w1);
}
// RDP Commands
void ZSortBOSS_UpdateMask( u32 _w0, u32 _w1 )
void ZSortBOSS_UpdateMask( const Gwords words )
{
gstate.updatemask[0] = _w0 | 0xff000000;
gstate.updatemask[1] = _w1;
gstate.updatemask[0] = words.w0 | 0xff000000;
gstate.updatemask[1] = words.w1;
LOG(LOG_VERBOSE, "ZSortBOSS_UpdateMask (mask0: 0x%08x, mask1: 0x%08x)", gstate.updatemask[0], gstate.updatemask[1]);
}
void ZSortBOSS_SetOtherMode_L( u32 _w0, u32 _w1 )
void ZSortBOSS_SetOtherMode_L( const Gwords words )
{
//u32 mask = (s32)0x80000000 >> (_w0 & 0x1f); // unspecified behaviour
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << (_w0 & 0x1f)));
mask >>= (_w0 >> 8) & 0x1f;
gDP.otherMode.l = (gDP.otherMode.l & ~mask) | _w1;
//u32 mask = (s32)0x80000000 >> (words.w0 & 0x1f); // unspecified behaviour
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << (words.w0 & 0x1f)));
mask >>= (words.w0 >> 8) & 0x1f;
gDP.otherMode.l = (gDP.otherMode.l & ~mask) | words.w1;
const u32 w0 = gDP.otherMode.h;
const u32 w1 = gDP.otherMode.l;
@ -796,12 +801,12 @@ void ZSortBOSS_SetOtherMode_L( u32 _w0, u32 _w1 )
LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_L (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l);
}
void ZSortBOSS_SetOtherMode_H( u32 _w0, u32 _w1 )
void ZSortBOSS_SetOtherMode_H( const Gwords words )
{
//u32 mask = (s32)0x80000000 >> (_w0 & 0x1f); // unspecified behaviour
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << (_w0 & 0x1f)));
mask >>= (_w0 >> 8) & 0x1f;
gDP.otherMode.h = (gDP.otherMode.h & ~mask) | _w1;
//u32 mask = (s32)0x80000000 >> (words.w0 & 0x1f); // unspecified behaviour
u32 mask = static_cast<u32>(s32(0x80000000) / (1 << (words.w0 & 0x1f)));
mask >>= (words.w0 >> 8) & 0x1f;
gDP.otherMode.h = (gDP.otherMode.h & ~mask) | words.w1;
const u32 w0 = gDP.otherMode.h;
const u32 w1 = gDP.otherMode.l;
@ -812,10 +817,10 @@ void ZSortBOSS_SetOtherMode_H( u32 _w0, u32 _w1 )
LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_H (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l);
}
void ZSortBOSS_SetOtherMode( u32 _w0, u32 _w1 )
void ZSortBOSS_SetOtherMode( const Gwords words )
{
gDP.otherMode.h = (_w0 & gstate.updatemask[0]) | (gDP.otherMode.h & ~gstate.updatemask[0]);
gDP.otherMode.l = (_w1 & gstate.updatemask[1]) | (gDP.otherMode.l & ~gstate.updatemask[1]);
gDP.otherMode.h = (words.w0 & gstate.updatemask[0]) | (gDP.otherMode.h & ~gstate.updatemask[0]);
gDP.otherMode.l = (words.w1 & gstate.updatemask[1]) | (gDP.otherMode.l & ~gstate.updatemask[1]);
const u32 w0 = gDP.otherMode.h;
const u32 w1 = gDP.otherMode.l;
@ -826,25 +831,25 @@ void ZSortBOSS_SetOtherMode( u32 _w0, u32 _w1 )
LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l);
}
void ZSortBOSS_TriangleCommand( u32, u32 _w1 )
void ZSortBOSS_TriangleCommand( const Gwords words )
{
assert(((_w1 >> 8) & 0x3f) == 0x0e); //Shade, Texture Triangle
assert(((words.w1 >> 8) & 0x3f) == 0x0e); //Shade, Texture Triangle
gSP.texture.scales = 1.0f;
gSP.texture.scalet = 1.0f;
gSP.texture.level = (_w1 >> 3) & 0x7;
gSP.texture.level = (words.w1 >> 3) & 0x7;
gSP.texture.on = 1;
gSP.texture.tile = _w1 & 0x7;
gSP.texture.tile = words.w1 & 0x7;
gSPSetGeometryMode(G_SHADING_SMOOTH | G_SHADE);
LOG(LOG_VERBOSE, "ZSortBOSS_TriangleCommand (cmd: 0x%02x, level: %d, tile: %d)", ((_w1 >> 8) & 0x3f), gSP.texture.level, gSP.texture.tile);
LOG(LOG_VERBOSE, "ZSortBOSS_TriangleCommand (cmd: 0x%02x, level: %d, tile: %d)", ((words.w1 >> 8) & 0x3f), gSP.texture.level, gSP.texture.tile);
}
void ZSortBOSS_FlushRDPCMDBuffer( u32, u32 )
void ZSortBOSS_FlushRDPCMDBuffer( const Gwords words )
{
LOG(LOG_VERBOSE, "ZSortBOSS_FlushRDPCMDBuffer Ignored");
}
void ZSortBOSS_Reserved( u32, u32 )
void ZSortBOSS_Reserved( const Gwords words )
{
assert(0);
}