Skip to content

Commit

Permalink
0.3a-d043dc0
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtBagXon committed Nov 26, 2024
1 parent f4bd0f9 commit 173129c
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 155 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a fork of [model3emu-code](https://www.supermodel3.com) to add native **
This fork uses [ManyMouse](https://github.com/icculus/manymouse) to provide 2 player gun support in Linux and MacOSX.

Two player mouse input in Windows is currently unchanged _(supported in the official release)_ via
the Windows Raw Input system. A Windows package is provided for Sinden border support.
the Windows Raw Input system.

Better support for MAME style multi ROM sets has also been added.

Expand Down Expand Up @@ -53,7 +53,7 @@ The aim of the Supermodel project is to develop an emulator that is both accurat

## How To Get It

Windows builds are updated automatically and available on the official Supermodel [download page](https://supermodel3.com/Download.html). Linux and macOS users currently have to build from source.
Builds from this repository are updated automatically and available on the Github [release page](https://github.com/DirtBagXon/model3emu-code-sinden/releases).

## Build Instructions

Expand Down
8 changes: 4 additions & 4 deletions Src/Graphics/New3D/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ struct Model

struct Viewport
{
int vpX; // these are the original hardware values
int vpY;
int vpWidth;
int vpHeight;
float vpX; // these are the original hardware values
float vpY;
float vpWidth;
float vpHeight;
float angle_left;
float angle_right;
float angle_top;
Expand Down
22 changes: 11 additions & 11 deletions Src/Graphics/New3D/New3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@ void CNew3D::RenderViewport(UINT32 addr)
vp->number = (vpnode[0] >> 10);
m_currentPriority = vp->priority;

// Fetch viewport parameters (TO-DO: would rounding make a difference?)
vp->vpX = (int)(((vpnode[0x1A] & 0xFFFF) * (float)(1.0 / 16.0)) + 0.5f); // viewport X (12.4 fixed point)
vp->vpY = (int)(((vpnode[0x1A] >> 16) * (float)(1.0 / 16.0)) + 0.5f); // viewport Y (12.4)
vp->vpWidth = (int)(((vpnode[0x14] & 0xFFFF) * (float)(1.0 / 4.0)) + 0.5f); // width (14.2)
vp->vpHeight = (int)(((vpnode[0x14] >> 16) * (float)(1.0 / 4.0)) + 0.5f); // height (14.2)
// Fetch viewport parameters
vp->vpX = ((vpnode[0x1A] & 0xFFFF) * (float)(1.0 / 16.0)) ; // viewport X (12.4 fixed point)
vp->vpY = ((vpnode[0x1A] >> 16) * (float)(1.0 / 16.0)); // viewport Y (12.4)
vp->vpWidth = ((vpnode[0x14] & 0xFFFF) * (float)(1.0 / 4.0)); // width (14.2)
vp->vpHeight = ((vpnode[0x14] >> 16) * (float)(1.0 / 4.0)); // height (14.2)

uint32_t matrixBase = vpnode[0x16] & 0xFFFFFF; // matrix base address

Expand Down Expand Up @@ -1598,18 +1598,18 @@ void CNew3D::CalcViewport(Viewport* vp)
m_planes.correction = 1.0f / correction;

vp->x = 0;
vp->y = m_yOffs + (int)((float)(384 - (vp->vpY + vp->vpHeight))*m_yRatio);
vp->y = m_yOffs + (int)((384.0f - (vp->vpY + vp->vpHeight))*m_yRatio);
vp->width = m_totalXRes;
vp->height = (int)((float)vp->vpHeight*m_yRatio);
vp->height = (int)(vp->vpHeight*m_yRatio);

vp->projectionMatrix.FrustumRZ(l*correction, r*correction, b, t, NEAR_PLANE);
}
else {

vp->x = m_xOffs + (int)((float)vp->vpX*m_xRatio);
vp->y = m_yOffs + (int)((float)(384 - (vp->vpY + vp->vpHeight))*m_yRatio);
vp->width = (int)((float)vp->vpWidth*m_xRatio);
vp->height = (int)((float)vp->vpHeight*m_yRatio);
vp->x = m_xOffs + (int)(vp->vpX*m_xRatio);
vp->y = m_yOffs + (int)((384.0f - (vp->vpY + vp->vpHeight))*m_yRatio);
vp->width = (int)(vp->vpWidth*m_xRatio);
vp->height = (int)(vp->vpHeight*m_yRatio);

vp->projectionMatrix.FrustumRZ(l, r, b, t, NEAR_PLANE);
}
Expand Down
59 changes: 30 additions & 29 deletions Src/Graphics/New3D/R3DShaderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ vec4 ExtractColour(int type, uint value)
{
vec4 c = vec4(0.0);

if(type==0) { // T1RGB5
c.r = float((value >> 10) & 0x1Fu);
c.g = float((value >> 5 ) & 0x1Fu);
c.b = float((value ) & 0x1Fu);
if(type==0) { // T1RGB5
c.r = float((value >> 10) & 0x1Fu);
c.g = float((value >> 5 ) & 0x1Fu);
c.b = float((value ) & 0x1Fu);
c.rgb *= (1.0/31.0);
c.a = 1.0 - float((value >> 15) & 0x1u);
c.a = 1.0 - float((value >> 15) & 0x1u);
}
else if(type==1) { // Interleaved A4L4 (low byte)
c.rgb = vec3(float(value&0xFu));
c.a = float((value >> 4) & 0xFu);
c.rgb = vec3(float(value&0xFu));
c.a = float((value >> 4) & 0xFu);
c *= (1.0/15.0);
}
else if(type==2) {
c.a = float(value&0xFu);
c.a = float(value&0xFu);
c.rgb = vec3(float((value >> 4) & 0xFu));
c *= (1.0/15.0);
c *= (1.0/15.0);
}
else if(type==3) {
c.rgb = vec3(float((value>>8)&0xFu));
c.a = float((value >> 12) & 0xFu);
c *= (1.0/15.0);
c.rgb = vec3(float((value>>8)&0xFu));
c.a = float((value >> 12) & 0xFu);
c *= (1.0/15.0);
}
else if(type==4) {
c.a = float((value>>8)&0xFu);
c.a = float((value>>8)&0xFu);
c.rgb = vec3(float((value >> 12) & 0xFu));
c *= (1.0/15.0);
c *= (1.0/15.0);
}
else if(type==5) {
c = vec4(float(value&0xFFu) / 255.0);
Expand Down Expand Up @@ -145,7 +145,6 @@ float LinearTexLocations(int wrapMode, float size, float u, out float u0, out fl
return fract(u); // return weight
}
else { // mirror + mirror clamp - both are the same since the edge pixels are repeated anyway

float odd = floor(mod(u, 2.0)); // odd values are mirrored

if(odd > 0.0) {
Expand All @@ -161,7 +160,7 @@ float LinearTexLocations(int wrapMode, float size, float u, out float u0, out fl

if(u0 < 0.0) u0 = 0.0;
if(u1 >= 1.0) u1 = 1.0 - halfTexelSize;

return fract(u); // return weight
}
}
Expand All @@ -173,9 +172,9 @@ vec4 texBiLinear(usampler2D texSampler, ivec2 wrapMode, vec2 texSize, ivec2 texP
float b = LinearTexLocations(wrapMode.t, texSize.y, texCoord.y, ty[0], ty[1]);

vec4 p0q0 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[0],ty[0]) * texSize + texPos),level), level).r);
vec4 p1q0 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[1],ty[0]) * texSize + texPos),level), level).r);
vec4 p0q1 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[0],ty[1]) * texSize + texPos),level), level).r);
vec4 p1q1 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[1],ty[1]) * texSize + texPos),level), level).r);
vec4 p1q0 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[1],ty[0]) * texSize + texPos),level), level).r);
vec4 p0q1 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[0],ty[1]) * texSize + texPos),level), level).r);
vec4 p1q1 = ExtractColour(baseTexType,texelFetch(texSampler, WrapTexCoords(texPos,ivec2(vec2(tx[1],ty[1]) * texSize + texPos),level), level).r);

if(alphaTest) {
if(p0q0.a > p1q0.a) { p1q0.rgb = p0q0.rgb; }
Expand All @@ -192,10 +191,10 @@ vec4 texBiLinear(usampler2D texSampler, ivec2 wrapMode, vec2 texSize, ivec2 texP
}

// Interpolation in X direction.
vec4 pInterp_q0 = mix( p0q0, p1q0, a ); // Interpolates top row in X direction.
vec4 pInterp_q1 = mix( p0q1, p1q1, a ); // Interpolates bottom row in X direction.
vec4 pInterp_q0 = mix( p0q0, p1q0, a ); // Interpolates top row in X direction.
vec4 pInterp_q1 = mix( p0q1, p1q1, a ); // Interpolates bottom row in X direction.

return mix( pInterp_q0, pInterp_q1, b ); // Interpolate in Y direction.
return mix( pInterp_q0, pInterp_q1, b ); // Interpolate in Y direction.
}

vec4 GetTextureValue()
Expand All @@ -206,8 +205,8 @@ vec4 GetTextureValue()

int iLevel = int(fLevel);

ivec2 tex1Pos = GetTexturePosition(iLevel, ivec2(baseTexInfo.xy));
ivec2 tex1Size = GetTextureSize(iLevel, ivec2(baseTexInfo.zw));
ivec2 tex1Pos = GetTexturePosition(iLevel, baseTexInfo.xy);
ivec2 tex1Size = GetTextureSize(iLevel, baseTexInfo.zw);
vec4 tex1Data = texBiLinear(textureBank[texturePage], textureWrapMode, vec2(tex1Size), tex1Pos, fsTexCoord, iLevel);

// init second texel with blank data to avoid any potentially undefined behavior
Expand All @@ -216,13 +215,15 @@ vec4 GetTextureValue()
float blendFactor = 0.0;

// if LOD < 0, no need to blend with next mipmap level; slight performance boost
if (lod > 0.0)
// while at it, just generalize to all cases where only one mip level needs to be touched
float ffL = fract(fLevel);
if (ffL > 0.0)
{
ivec2 tex2Pos = GetTexturePosition(iLevel+1, ivec2(baseTexInfo.xy));
ivec2 tex2Size = GetTextureSize(iLevel+1, ivec2(baseTexInfo.zw));
ivec2 tex2Pos = GetTexturePosition(iLevel+1, baseTexInfo.xy);
ivec2 tex2Size = GetTextureSize(iLevel+1, baseTexInfo.zw);
tex2Data = texBiLinear(textureBank[texturePage], textureWrapMode, vec2(tex2Size), tex2Pos, fsTexCoord, iLevel+1);

blendFactor = fract(fLevel);
blendFactor = ffL;
}
else if (microTexture && lod < -microTextureMinLOD)
{
Expand All @@ -240,7 +241,7 @@ vec4 GetTextureValue()
tex1Data = mix(tex1Data, tex2Data, blendFactor);

if(textureInverted) {
tex1Data.rgb = vec3(1.0) - vec3(tex1Data.rgb);
tex1Data.rgb = vec3(1.0) - tex1Data.rgb;
}

if (alphaTest) {
Expand Down
Loading

0 comments on commit 173129c

Please sign in to comment.