mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Rewrite SetOtherMode_H and SetOtherMode_L.
Fixed Paper Mario.
This commit is contained in:
parent
9c4bb7d0c2
commit
1bdc3cb1ed
76
F3D.cpp
76
F3D.cpp
|
@ -212,80 +212,16 @@ void F3D_Texture( u32 w0, u32 w1 )
|
|||
|
||||
void F3D_SetOtherMode_H( u32 w0, u32 w1 )
|
||||
{
|
||||
switch (_SHIFTR( w0, 8, 8 ))
|
||||
{
|
||||
case G_MDSFT_PIPELINE:
|
||||
gDPPipelineMode( w1 >> G_MDSFT_PIPELINE );
|
||||
break;
|
||||
case G_MDSFT_CYCLETYPE:
|
||||
gDPSetCycleType( w1 >> G_MDSFT_CYCLETYPE );
|
||||
break;
|
||||
case G_MDSFT_TEXTPERSP:
|
||||
gDPSetTexturePersp( w1 >> G_MDSFT_TEXTPERSP );
|
||||
break;
|
||||
case G_MDSFT_TEXTDETAIL:
|
||||
gDPSetTextureDetail( w1 >> G_MDSFT_TEXTDETAIL );
|
||||
break;
|
||||
case G_MDSFT_TEXTLOD:
|
||||
gDPSetTextureLOD( w1 >> G_MDSFT_TEXTLOD );
|
||||
break;
|
||||
case G_MDSFT_TEXTLUT:
|
||||
gDPSetTextureLUT( w1 >> G_MDSFT_TEXTLUT );
|
||||
break;
|
||||
case G_MDSFT_TEXTFILT:
|
||||
gDPSetTextureFilter( w1 >> G_MDSFT_TEXTFILT );
|
||||
break;
|
||||
case G_MDSFT_TEXTCONV:
|
||||
gDPSetTextureConvert( w1 >> G_MDSFT_TEXTCONV );
|
||||
break;
|
||||
case G_MDSFT_COMBKEY:
|
||||
gDPSetCombineKey( w1 >> G_MDSFT_COMBKEY );
|
||||
break;
|
||||
case G_MDSFT_RGBDITHER:
|
||||
gDPSetColorDither( w1 >> G_MDSFT_RGBDITHER );
|
||||
break;
|
||||
case G_MDSFT_ALPHADITHER:
|
||||
gDPSetAlphaDither( w1 >> G_MDSFT_ALPHADITHER );
|
||||
break;
|
||||
default:
|
||||
u32 shift = _SHIFTR( w0, 8, 8 );
|
||||
u32 length = _SHIFTR( w0, 0, 8 );
|
||||
u32 mask = ((1 << length) - 1) << shift;
|
||||
|
||||
gDP.otherMode.h &= ~mask;
|
||||
gDP.otherMode.h |= w1 & mask;
|
||||
|
||||
gDP.changed |= CHANGED_CYCLETYPE;
|
||||
break;
|
||||
}
|
||||
const u32 length = _SHIFTR(w0, 0, 8);
|
||||
const u32 shift = _SHIFTR(w0, 8, 8);
|
||||
gSPSetOtherMode_H(length, shift, w1);
|
||||
}
|
||||
|
||||
void F3D_SetOtherMode_L( u32 w0, u32 w1 )
|
||||
{
|
||||
const u32 shift = _SHIFTR( w0, 8, 8 );
|
||||
switch (shift)
|
||||
{
|
||||
case G_MDSFT_ALPHACOMPARE:
|
||||
gDPSetAlphaCompare( w1 >> G_MDSFT_ALPHACOMPARE );
|
||||
break;
|
||||
case G_MDSFT_ZSRCSEL:
|
||||
gDPSetDepthSource( w1 >> G_MDSFT_ZSRCSEL );
|
||||
break;
|
||||
case G_MDSFT_RENDERMODE:
|
||||
gDPSetRenderMode( w1 & 0xCCCCFFFF, w1 & 0x3333FFFF );
|
||||
break;
|
||||
}
|
||||
const u32 length = _SHIFTR( w0, 0, 8 );
|
||||
// u32 mask = ((1 << length) - 1) << shift;
|
||||
u32 mask = 0;
|
||||
for (int i = length; i > 0; i--)
|
||||
mask = (mask << 1) | 1;
|
||||
mask <<= shift;
|
||||
|
||||
gDP.otherMode.l &= ~mask;
|
||||
gDP.otherMode.l |= w1 & mask;
|
||||
|
||||
gDP.changed |= CHANGED_RENDERMODE | CHANGED_ALPHACOMPARE;
|
||||
const u32 length = _SHIFTR(w0, 0, 8);
|
||||
const u32 shift = _SHIFTR(w0, 8, 8);
|
||||
gSPSetOtherMode_L(length, shift, w1);
|
||||
}
|
||||
|
||||
void F3D_EndDL( u32 w0, u32 w1 )
|
||||
|
|
81
F3DEX2.cpp
81
F3DEX2.cpp
|
@ -12,6 +12,8 @@
|
|||
#include "GBI.h"
|
||||
#include "OpenGL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void F3DEX2_Mtx( u32 w0, u32 w1 )
|
||||
{
|
||||
gSPMatrix( w1, _SHIFTR( w0, 0, 8 ) ^ G_MTX_PUSH );
|
||||
|
@ -116,83 +118,16 @@ void F3DEX2_Texture( u32 w0, u32 w1 )
|
|||
|
||||
void F3DEX2_SetOtherMode_H( u32 w0, u32 w1 )
|
||||
{
|
||||
switch (32 - _SHIFTR( w0, 8, 8 ) - (_SHIFTR( w0, 0, 8 ) + 1))
|
||||
{
|
||||
case G_MDSFT_PIPELINE:
|
||||
gDPPipelineMode( w1 >> G_MDSFT_PIPELINE );
|
||||
break;
|
||||
case G_MDSFT_CYCLETYPE:
|
||||
gDPSetCycleType( w1 >> G_MDSFT_CYCLETYPE );
|
||||
break;
|
||||
case G_MDSFT_TEXTPERSP:
|
||||
gDPSetTexturePersp( w1 >> G_MDSFT_TEXTPERSP );
|
||||
break;
|
||||
case G_MDSFT_TEXTDETAIL:
|
||||
gDPSetTextureDetail( w1 >> G_MDSFT_TEXTDETAIL );
|
||||
break;
|
||||
case G_MDSFT_TEXTLOD:
|
||||
gDPSetTextureLOD( w1 >> G_MDSFT_TEXTLOD );
|
||||
break;
|
||||
case G_MDSFT_TEXTLUT:
|
||||
gDPSetTextureLUT( w1 >> G_MDSFT_TEXTLUT );
|
||||
break;
|
||||
case G_MDSFT_TEXTFILT:
|
||||
gDPSetTextureFilter( w1 >> G_MDSFT_TEXTFILT );
|
||||
break;
|
||||
case G_MDSFT_TEXTCONV:
|
||||
gDPSetTextureConvert( w1 >> G_MDSFT_TEXTCONV );
|
||||
break;
|
||||
case G_MDSFT_COMBKEY:
|
||||
gDPSetCombineKey( w1 >> G_MDSFT_COMBKEY );
|
||||
break;
|
||||
case G_MDSFT_RGBDITHER:
|
||||
gDPSetColorDither( w1 >> G_MDSFT_RGBDITHER );
|
||||
break;
|
||||
case G_MDSFT_ALPHADITHER:
|
||||
gDPSetAlphaDither( w1 >> G_MDSFT_ALPHADITHER );
|
||||
break;
|
||||
default:
|
||||
u32 length = _SHIFTR( w0, 0, 8 ) + 1;
|
||||
u32 shift = 32 - _SHIFTR( w0, 8, 8 ) - length;
|
||||
u32 mask = ((1 << length) - 1) << shift;
|
||||
|
||||
gDP.otherMode.h &= ~mask;
|
||||
gDP.otherMode.h |= w1 & mask;
|
||||
|
||||
gDP.changed |= CHANGED_CYCLETYPE;
|
||||
break;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void F3DEX2_SetOtherMode_L( u32 w0, u32 w1 )
|
||||
{
|
||||
const u32 length = _SHIFTR( w0, 0, 8 ) + 1;
|
||||
int shift = 32 - _SHIFTR( w0, 8, 8 ) - length;
|
||||
if (shift < 0) shift = 0;
|
||||
switch (shift)
|
||||
{
|
||||
case G_MDSFT_ALPHACOMPARE:
|
||||
gDPSetAlphaCompare( w1 >> G_MDSFT_ALPHACOMPARE );
|
||||
break;
|
||||
case G_MDSFT_ZSRCSEL:
|
||||
gDPSetDepthSource( w1 >> G_MDSFT_ZSRCSEL );
|
||||
break;
|
||||
case G_MDSFT_RENDERMODE:
|
||||
gDPSetRenderMode( w1 & 0xCCCCFFFF, w1 & 0x3333FFFF );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//u32 mask = ((1 << length) - 1) << shift;
|
||||
u32 mask = 0;
|
||||
for (int i = length; i > 0; i--)
|
||||
mask = (mask << 1) | 1;
|
||||
mask <<= shift;
|
||||
|
||||
gDP.otherMode.l &= ~mask;
|
||||
gDP.otherMode.l |= w1 & mask;
|
||||
|
||||
gDP.changed |= CHANGED_RENDERMODE | CHANGED_ALPHACOMPARE;
|
||||
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);
|
||||
}
|
||||
|
||||
void F3DEX2_GeometryMode( u32 w0, u32 w1 )
|
||||
|
|
24
gDP.cpp
24
gDP.cpp
|
@ -82,7 +82,7 @@ void gDPPipelineMode( u32 mode )
|
|||
|
||||
void gDPSetCycleType( u32 type )
|
||||
{
|
||||
gDP.otherMode.cycleType = type;
|
||||
gDP.otherMode.cycleType = type & 3;
|
||||
|
||||
gDP.changed |= CHANGED_CYCLETYPE;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void gDPSetCycleType( u32 type )
|
|||
|
||||
void gDPSetTexturePersp( u32 enable )
|
||||
{
|
||||
gDP.otherMode.texturePersp = enable;
|
||||
gDP.otherMode.texturePersp = enable & 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTexturePersp( %s );\n",
|
||||
|
@ -104,7 +104,7 @@ void gDPSetTexturePersp( u32 enable )
|
|||
|
||||
void gDPSetTextureDetail( u32 type )
|
||||
{
|
||||
gDP.otherMode.textureDetail = type;
|
||||
gDP.otherMode.textureDetail = type & 3;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTextureDetail( %s );\n",
|
||||
|
@ -114,7 +114,7 @@ void gDPSetTextureDetail( u32 type )
|
|||
|
||||
void gDPSetTextureLOD( u32 mode )
|
||||
{
|
||||
gDP.otherMode.textureLOD = mode;
|
||||
gDP.otherMode.textureLOD = mode & 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTextureLOD( %s );\n",
|
||||
|
@ -124,7 +124,7 @@ void gDPSetTextureLOD( u32 mode )
|
|||
|
||||
void gDPSetTextureLUT( u32 mode )
|
||||
{
|
||||
gDP.otherMode.textureLUT = mode;
|
||||
gDP.otherMode.textureLUT = mode & 3;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTextureLUT( %s );\n",
|
||||
|
@ -134,7 +134,7 @@ void gDPSetTextureLUT( u32 mode )
|
|||
|
||||
void gDPSetTextureFilter( u32 type )
|
||||
{
|
||||
gDP.otherMode.textureFilter = type;
|
||||
gDP.otherMode.textureFilter = type & 3;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTextureFilter( %s );\n",
|
||||
|
@ -144,7 +144,7 @@ void gDPSetTextureFilter( u32 type )
|
|||
|
||||
void gDPSetTextureConvert( u32 type )
|
||||
{
|
||||
gDP.otherMode.textureConvert = type;
|
||||
gDP.otherMode.textureConvert = type & 7;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPSetTextureConvert( %s );\n",
|
||||
|
@ -154,7 +154,7 @@ void gDPSetTextureConvert( u32 type )
|
|||
|
||||
void gDPSetCombineKey( u32 type )
|
||||
{
|
||||
gDP.otherMode.combineKey = type;
|
||||
gDP.otherMode.combineKey = type & 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_COMBINE, "gDPSetCombineKey( %s );\n",
|
||||
|
@ -164,7 +164,7 @@ void gDPSetCombineKey( u32 type )
|
|||
|
||||
void gDPSetColorDither( u32 type )
|
||||
{
|
||||
gDP.otherMode.colorDither = type;
|
||||
gDP.otherMode.colorDither = type & 3;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED, "gDPSetColorDither( %s );\n",
|
||||
|
@ -174,7 +174,7 @@ void gDPSetColorDither( u32 type )
|
|||
|
||||
void gDPSetAlphaDither( u32 type )
|
||||
{
|
||||
gDP.otherMode.alphaDither = type;
|
||||
gDP.otherMode.alphaDither = type & 3;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED, "gDPSetAlphaDither( %s );\n",
|
||||
|
@ -184,7 +184,7 @@ void gDPSetAlphaDither( u32 type )
|
|||
|
||||
void gDPSetAlphaCompare( u32 mode )
|
||||
{
|
||||
gDP.otherMode.alphaCompare = mode;
|
||||
gDP.otherMode.alphaCompare = mode & 3;
|
||||
|
||||
gDP.changed |= CHANGED_ALPHACOMPARE;
|
||||
|
||||
|
@ -196,7 +196,7 @@ void gDPSetAlphaCompare( u32 mode )
|
|||
|
||||
void gDPSetDepthSource( u32 source )
|
||||
{
|
||||
gDP.otherMode.depthSource = source;
|
||||
gDP.otherMode.depthSource = source & 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED, "gDPSetDepthSource( %s );\n",
|
||||
|
|
52
gSP.cpp
52
gSP.cpp
|
@ -1779,6 +1779,58 @@ void gSPClearGeometryMode( u32 mode )
|
|||
#endif
|
||||
}
|
||||
|
||||
void gSPSetOtherMode_H(u32 _length, u32 _shift, u32 _data)
|
||||
{
|
||||
const u32 mask = (((u64)1 << _length) - 1) << _shift;
|
||||
|
||||
if (mask & 0x00000030) // alpha dither mode
|
||||
gDPSetAlphaDither(_data >> G_MDSFT_ALPHADITHER);
|
||||
|
||||
if (mask & 0x000000C0) // rgb dither mode
|
||||
gDPSetColorDither(_data >> G_MDSFT_RGBDITHER);
|
||||
|
||||
if (mask & 0x00000100) // Combine Key
|
||||
gDPSetCombineKey(_data >> G_MDSFT_COMBKEY);
|
||||
|
||||
if (mask & 0x00000E00) // Texture convert
|
||||
gDPSetTextureConvert(_data >> G_MDSFT_TEXTCONV);
|
||||
|
||||
if (mask & 0x00003000) // filter mode
|
||||
gDPSetTextureFilter(_data >> G_MDSFT_TEXTFILT);
|
||||
|
||||
if (mask & 0x0000C000) // tlut mode
|
||||
gDPSetTextureLUT(_data >> G_MDSFT_TEXTLUT);
|
||||
|
||||
if (mask & 0x00010000) // LOD enable
|
||||
gDPSetTextureLOD(_data >> G_MDSFT_TEXTLOD);
|
||||
|
||||
if (mask & 0x00060000) // Texture detail mode
|
||||
gDPSetTextureDetail(_data >> G_MDSFT_TEXTDETAIL);
|
||||
|
||||
if (mask & 0x00080000) // Persp enable
|
||||
gDPSetTexturePersp(_data >> G_MDSFT_TEXTPERSP);
|
||||
|
||||
if (mask & 0x00300000) // cycle type
|
||||
gDPSetCycleType(_data >> G_MDSFT_CYCLETYPE);
|
||||
|
||||
if (mask & 0x00800000) // Pipeline mode
|
||||
gDPPipelineMode(_data >> G_MDSFT_PIPELINE);
|
||||
}
|
||||
|
||||
void gSPSetOtherMode_L(u32 _length, u32 _shift, u32 _data)
|
||||
{
|
||||
u32 mask = (((u64)1 << _length) - 1) << _shift;
|
||||
|
||||
if (mask & 0x00000003) // alpha compare
|
||||
gDPSetAlphaCompare(_data >> G_MDSFT_ALPHACOMPARE);
|
||||
|
||||
if (mask & 0x00000004) // z-src selection
|
||||
gDPSetDepthSource(_data >> G_MDSFT_ZSRCSEL);
|
||||
|
||||
if (mask & 0xFFFFFFF8) // rendermode / blender bits
|
||||
gDPSetRenderMode(_data & 0xCCCCFFFF, _data & 0x3333FFFF);
|
||||
}
|
||||
|
||||
void gSPLine3D( s32 v0, s32 v1, s32 flag )
|
||||
{
|
||||
video().getRender().drawLine(v0, v1, 1.5f);
|
||||
|
|
4
gSP.h
4
gSP.h
|
@ -199,7 +199,9 @@ void gSPEndDisplayList();
|
|||
void gSPGeometryMode( u32 clear, u32 set );
|
||||
void gSPSetGeometryMode( u32 mode );
|
||||
void gSPClearGeometryMode( u32 mode );
|
||||
void gSPLine3D( s32 v0, s32 v1, s32 flag );
|
||||
void gSPSetOtherMode_H(u32 _length, u32 _shift, u32 _data);
|
||||
void gSPSetOtherMode_L(u32 _length, u32 _shift, u32 _data);
|
||||
void gSPLine3D(s32 v0, s32 v1, s32 flag);
|
||||
void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag );
|
||||
void gSPObjRectangle( u32 sp );
|
||||
void gSPObjRectangleR(u32 sp);
|
||||
|
|
Loading…
Reference in New Issue
Block a user