Merge remote-tracking branch 'refs/remotes/mamedev/master'

This commit is contained in:
Antonio Giner 2016-03-18 22:41:17 +01:00
commit e39daaf5bd
201 changed files with 14120 additions and 13192 deletions

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -8,8 +8,6 @@ yiq_enable 0/1 Enables YIQ-colorspace post-processing.
NTSC TV appearance on TV-based systems when configured
properly.
hlslpath [path] Path to the .fx files that are in use. (default: hlsl)
hlsl_prescale_x [horizontal] HLSL pre-scale override factor for X. (0 for auto)
hlsl_prescale_y [vertical] HLSL pre-scale override factor for Y. (0 for auto)
hlsl_write [filename] Enables HLSL AVI writing. (huge disk bandwidth suggested)
hlsl_snap_width [width] HLSL upscaled-snapshot width. (default: 2048)
hlsl_snap_height [height] HLSL upscaled-snapshot height. (default: 1536)
@ -104,17 +102,17 @@ vector_length_ratio 500.0 Vector fade length (4.0 - vectors fade t
Bloom Post-Processing Options
-----------------------------
Name Default Values Description
bloom_blend_mode 0 or 1 0 for addition blend mode or 1 for darken blend mode.
bloom_scale 0.500 Bloom intensity factor. (0.000-2.000)
bloom_overdrive 0.00,0.00,0.00 Bloom overdrive factor to bright full saturated colors. (0.000-2.000)
bloom_blend_mode 0 or 1 0 for brighten blend mode or 1 for darken blend mode.
bloom_scale 0.0 Bloom intensity factor. (0.000-2.000)
bloom_overdrive 0.0,0.0,0.0 Bloom overdrive factor to bright full saturated colors. (0.000-2.000)
bloom_lvl0_weight 1.00 Bloom level 0 (full-size target) weight. (0.00-1.00)
bloom_lvl1_weight 0.21 Bloom level 1 (half-size target) weight. (0.00-1.00)
bloom_lvl2_weight 0.19 Bloom level 2 (quarter-size target) weight. (0.00-1.00)
bloom_lvl3_weight 0.17 Bloom level 3 (.) weight. (0.00-1.00)
bloom_lvl4_weight 0.14 Bloom level 4 (.) weight. (0.00-1.00)
bloom_lvl5_weight 0.14 Bloom level 5 (.) weight. (0.00-1.00)
bloom_lvl6_weight 0.13 Bloom level 6 (.) weight. (0.00-1.00)
bloom_lvl7_weight 0.12 Bloom level 7 (.) weight. (0.00-1.00)
bloom_lvl8_weight 0.11 Bloom level 8 (.) weight. (0.00-1.00)
bloom_lvl9_weight 0.10 Bloom level 9 (.) weight. (0.00-1.00)
bloom_lvl10_weight 0.09 Bloom level 10 (1x1 target) weight. (0.00-1.00)
bloom_lvl1_weight 0.64 Bloom level 1 (1/2-size target) weight. (0.00-1.00)
bloom_lvl2_weight 0.32 Bloom level 2 (1/4-size target) weight. (0.00-1.00)
bloom_lvl3_weight 0.16 Bloom level 3 (1/8-size target) weight. (0.00-1.00)
bloom_lvl4_weight 0.08 Bloom level 4 (1/16-size target) weight. (0.00-1.00)
bloom_lvl5_weight 0.04 Bloom level 5 (1/32-size target) weight. (0.00-1.00)
bloom_lvl6_weight 0.04 Bloom level 6 (1/64-size target) weight. (0.00-1.00)
bloom_lvl7_weight 0.02 Bloom level 7 (1/128-size target) weight. (0.00-1.00)
bloom_lvl8_weight 0.02 Bloom level 8 (1/256-size target) weight. (0.00-1.00)
bloom_lvl9_weight 0.01 Bloom level 9 (1/512-size target) weight. (0.00-1.00)
bloom_lvl10_weight 0.01 Bloom level 10 (1/1024-size target) weight. (0.00-1.00)

View File

@ -1,101 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:ImJezze
//-----------------------------------------------------------------------------
// Distortion Effect
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Sampler Definitions
//-----------------------------------------------------------------------------
texture DiffuseTexture;
sampler DiffuseSampler = sampler_state
{
Texture = <DiffuseTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
//-----------------------------------------------------------------------------
// Distortion Vertex Shader
//-----------------------------------------------------------------------------
uniform float2 ScreenDims; // size of the window or fullscreen
uniform float2 TargetDims;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.Color = Input.Color;
Output.TexCoord = Input.Position.xy / ScreenDims;
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
return Output;
}
//-----------------------------------------------------------------------------
// Post-Processing Pixel Shader
//-----------------------------------------------------------------------------
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 BaseCoord = Input.TexCoord;
// Color
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
BaseColor.a = 1.0f;
return BaseColor;
}
//-----------------------------------------------------------------------------
// Distortion Effect
//-----------------------------------------------------------------------------
technique DefaultTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
}

View File

@ -1,535 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz,ImJezze
//-----------------------------------------------------------------------------
// Scanline, Shadowmask & Distortion Effect
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Sampler Definitions
//-----------------------------------------------------------------------------
texture DiffuseTexture;
sampler DiffuseSampler = sampler_state
{
Texture = <DiffuseTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
texture ShadowTexture;
sampler ShadowSampler = sampler_state
{
Texture = <ShadowTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
AddressW = WRAP;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
float2 ScreenCoord : TEXCOORD1;
};
struct PS_INPUT
{
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
float2 ScreenCoord : TEXCOORD1;
};
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
static const float Epsilon = 1.0e-7f;
static const float PI = 3.1415927f;
static const float PHI = 1.618034f;
static const float E = 2.7182817f;
static const float Gelfond = 23.140692f; // e^pi (Gelfond constant)
static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneider constant)
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(float2 seed)
{
// irrationals for pseudo randomness
float2 i = float2(Gelfond, GelfondSchneider);
return frac(cos(dot(seed, i)) * 123456.0f);
}
// www.dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/
float normalizedSigmoid(float n, float k)
{
// valid for n and k in range of -1.0 and 1.0
return (n - n * k) / (k - abs(n) * 2.0f * k + 1);
}
// www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
float roundBox(float2 p, float2 b, float r)
{
return length(max(abs(p) - b + r, 0.0f)) - r;
}
//-----------------------------------------------------------------------------
// Scanline, Shadowmask & Distortion Vertex Shader
//-----------------------------------------------------------------------------
uniform float2 ScreenDims; // size of the window or fullscreen
uniform float2 SourceDims; // size of the texture in power-of-two size
uniform float2 SourceRect; // size of the uv rectangle
uniform float2 TargetDims; // size of the target surface
uniform float2 QuadDims; // size of the screen quad
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
uniform bool SwapXY = false;
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
uniform bool PrepareVector = false;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
float2 ScreenCoordOffset = 0.0f;
ScreenCoordOffset += shadowUVOffset;
Output.ScreenCoord = Input.Position.xy;
Output.ScreenCoord += ScreenCoordOffset;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.TexCoord = PrepareVector
? Input.Position.xy / ScreenDims
: Input.TexCoord;
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.Color = Input.Color;
return Output;
}
//-----------------------------------------------------------------------------
// Scanline, Shadowmask & Distortion Pixel Shader
//-----------------------------------------------------------------------------
uniform float HumBarHertzRate = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform float HumBarAlpha = 0.0f;
uniform float TimeMilliseconds = 0.0f;
uniform float2 ScreenScale = float2(1.0f, 1.0f);
uniform float2 ScreenOffset = float2(0.0f, 0.0f);
uniform float ScanlineAlpha = 1.0f;
uniform float ScanlineScale = 1.0f;
uniform float ScanlineBrightScale = 1.0f;
uniform float ScanlineBrightOffset = 1.0f;
uniform float ScanlineOffset = 1.0f;
uniform float ScanlineHeight = 1.0f;
uniform float3 BackColor = float3(0.0f, 0.0f, 0.0f);
uniform float CurvatureAmount = 1.0f;
uniform float RoundCornerAmount = 0.0f;
uniform float SmoothBorderAmount = 0.0f;
uniform float VignettingAmount = 0.0f;
uniform float ReflectionAmount = 0.0f;
uniform int ShadowTileMode = 0; // 0 based on screen dimension, 1 based on source dimension
uniform float ShadowAlpha = 0.0f;
uniform float2 ShadowCount = float2(6.0f, 6.0f);
uniform float2 ShadowUV = float2(0.25f, 0.25f);
uniform float3 Power = float3(1.0f, 1.0f, 1.0f);
uniform float3 Floor = float3(0.0f, 0.0f, 0.0f);
float2 GetRatioCorrection()
{
if (PrepareVector)
{
float ScreenRatio = ScreenDims.x / ScreenDims.y;
float QuadRatio = QuadDims.x / QuadDims.y;
float ScreenQuadRatio = QuadRatio / ScreenRatio;
return ScreenQuadRatio > 1.0f
? float2(1.0, 1.0f / ScreenQuadRatio)
: float2(ScreenQuadRatio, 1.0);
}
else
{
return SourceRect;
}
}
float GetNoiseFactor(float n, float random)
{
// smaller n become more noisy
return 1.0f + random * max(0.0f, 0.25f * pow(E, -8 * n));
}
float GetVignetteFactor(float2 coord, float amount)
{
float2 VignetteCoord = coord;
float VignetteLength = length(VignetteCoord);
float VignetteBlur = (amount * 0.75f) + 0.25;
// 0.5 full screen fitting circle
float VignetteRadius = 1.0f - (amount * 0.25f);
float Vignette = smoothstep(VignetteRadius, VignetteRadius - VignetteBlur, VignetteLength);
return saturate(Vignette);
}
float GetSpotAddend(float2 coord, float amount)
{
float2 RatioCorrection = GetRatioCorrection();
// normalized screen canvas ratio
float2 CanvasRatio = PrepareVector
? float2(1.0f, QuadDims.y / QuadDims.x)
: float2(1.0f, SwapXY
? QuadDims.x / QuadDims.y
: QuadDims.y / QuadDims.x);
// upper right quadrant
float2 spotOffset = PrepareVector
? RotationType == 1 // 90°
? float2(-0.25f, -0.25f)
: RotationType == 2 // 180°
? float2(0.25f, -0.25f)
: RotationType == 3 // 270°
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f)
: SwapXY
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f);
float2 SpotCoord = coord;
SpotCoord += spotOffset * RatioCorrection;
SpotCoord *= CanvasRatio;
SpotCoord /= RatioCorrection;
float SpotBlur = amount;
// 0.5 full screen fitting circle
float SpotRadius = amount * 0.75f;
float Spot = smoothstep(SpotRadius, SpotRadius - SpotBlur, length(SpotCoord));
float SigmoidSpot = amount * normalizedSigmoid(Spot, 0.75);
// increase strength by 100%
SigmoidSpot = SigmoidSpot * 2.0f;
return saturate(SigmoidSpot);
}
float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount)
{
float2 RatioCorrection = GetRatioCorrection();
// reduce smooth amount down to radius amount
smoothAmount = min(smoothAmount, radiusAmount);
float2 CanvasDims = PrepareVector
? ScreenDims
: SwapXY
? QuadDims.yx / SourceRect
: QuadDims.xy / SourceRect;
coord = PrepareVector
? coord
: coord - 1.0f / SourceDims; // alignment correction (raster graphics)
float range = min(QuadDims.x, QuadDims.y) * 0.5;
float radius = range * max(radiusAmount, 0.0025f);
float smooth = 1.0 / (range * max(smoothAmount, 0.0025f));
// compute box
float box = roundBox(CanvasDims * (coord * 2.0f), CanvasDims * RatioCorrection, radius);
// apply smooth
box *= smooth;
box += 1.0f - pow(smooth * 0.5f, 0.5f);
float border = smoothstep(1.0f, 0.0f, box);
return saturate(border);
}
// www.francois-tarlier.com/blog/cubic-lens-distortion-shader/
float2 GetDistortedCoords(float2 centerCoord, float amount)
{
// lens distortion coefficient
float k = amount;
// cubic distortion value
float kcube = amount * 2.0f;
// compute cubic distortion factor
float r2 = centerCoord.x * centerCoord.x + centerCoord.y * centerCoord.y;
float f = kcube == 0.0f
? 1.0f + r2 * k
: 1.0f + r2 * (k + kcube * sqrt(r2));
// fit screen bounds
f /= 1.0f + amount * 0.5f;
// apply cubic distortion factor
centerCoord *= f;
return centerCoord;
}
float2 GetCoords(float2 coord, float2 centerOffset, float distortionAmount)
{
float2 RatioCorrection = GetRatioCorrection();
// center coordinates
coord -= centerOffset;
// apply ratio difference between screen and quad
coord /= RatioCorrection;
// distort coordinates
coord = GetDistortedCoords(coord, distortionAmount);
// revert ratio difference between screen and quad
coord *= RatioCorrection;
// un-center coordinates
coord += centerOffset;
return coord;
}
float2 GetAdjustedCoords(float2 coord, float2 centerOffset, float distortionAmount)
{
float2 RatioCorrection = GetRatioCorrection();
// center coordinates
coord -= centerOffset;
// apply ratio difference between screen and quad
coord /= RatioCorrection;
// apply screen scale
coord /= ScreenScale;
// distort coordinates
coord = GetDistortedCoords(coord, distortionAmount);
// revert ratio difference between screen and quad
coord *= RatioCorrection;
// un-center coordinates
coord += centerOffset;
// apply screen offset
coord += (centerOffset * 2.0) * ScreenOffset;
return coord;
}
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount * 0.25f); // reduced amount
float2 DistortionCoord = Input.TexCoord;
DistortionCoord = GetCoords(DistortionCoord, HalfSourceRect, CurvatureAmount * 0.25f); // reduced amount
float2 BaseCoord = Input.TexCoord;
BaseCoord = GetAdjustedCoords(BaseCoord, HalfSourceRect, CurvatureAmount * 0.25f); // reduced amount
float2 DistortionCoordCentered = DistortionCoord;
DistortionCoordCentered -= HalfSourceRect;
float2 BaseCoordCentered = BaseCoord;
BaseCoordCentered -= HalfSourceRect;
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
BaseColor.a = 1.0f;
if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f)
{
BaseColor.rgb = 0.0f;
}
// Mask Simulation (may not affect bloom)
if (!PrepareBloom && ShadowAlpha > 0.0f)
{
float2 shadowDims = ShadowDims;
shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
// shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
// ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
float4 ShadowColor = tex2D(ShadowSampler, ShadowCoord);
float3 ShadowMaskColor = lerp(1.0f, ShadowColor.rgb, ShadowAlpha);
float ShadowMaskClear = (1.0f - ShadowColor.a) * ShadowAlpha;
// apply shadow mask color
BaseColor.rgb *= ShadowMaskColor;
// clear shadow mask by background color
BaseColor.rgb = lerp(BaseColor.rgb, BackColor, ShadowMaskClear);
}
// Color Compression (may not affect bloom)
if (!PrepareBloom)
{
// increasing the floor of the signal without affecting the ceiling
BaseColor.rgb = Floor + (1.0f - Floor) * BaseColor.rgb;
}
// Color Power (may affect bloom)
BaseColor.r = pow(BaseColor.r, Power.r);
BaseColor.g = pow(BaseColor.g, Power.g);
BaseColor.b = pow(BaseColor.b, Power.b);
// Scanline Simulation (may not affect bloom)
if (!PrepareBloom)
{
// Scanline Simulation (may not affect vector screen)
if (!PrepareVector && ScanlineAlpha > 0.0f)
{
float ScanCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
float ScanCoordJitter = ScanlineOffset * PHI;
float ScanSine = sin(ScanCoord + ScanCoordJitter);
float ScanSineScaled = pow(ScanSine * ScanSine, ScanlineHeight);
float ScanBrightness = ScanSineScaled * ScanlineBrightScale + 1.0f + ScanlineBrightOffset;
BaseColor.rgb *= lerp(1.0f, ScanBrightness * 0.5f, ScanlineAlpha);
}
// Hum Bar Simulation (may not affect vector screen)
if (!PrepareVector && HumBarAlpha > 0.0f)
{
float HumTimeStep = frac(TimeMilliseconds * HumBarHertzRate);
float HumBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumTimeStep) * HumBarAlpha;
BaseColor.rgb *= HumBrightness;
}
}
// Output
float4 Output = PrepareVector
? BaseColor * (Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f))
: BaseColor * Input.Color;
Output.a = 1.0f;
// Vignetting Simulation (may not affect bloom)
if (!PrepareBloom)
{
float2 VignetteCoord = DistortionCoordCentered;
float VignetteFactor = GetVignetteFactor(VignetteCoord, VignettingAmount);
Output.rgb *= VignetteFactor;
}
// Light Reflection Simulation (may not affect bloom)
if (!PrepareBloom)
{
float3 LightColor = float3(1.0f, 0.90f, 0.80f);
float2 SpotCoord = DistortionCoordCentered;
float2 NoiseCoord = DistortionCoordCentered;
float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount);
float NoiseFactor = GetNoiseFactor(SpotAddend, random(NoiseCoord));
Output.rgb += SpotAddend * NoiseFactor * LightColor;
}
// Round Corners Simulation (may affect bloom)
float2 RoundCornerCoord = DistortionCoordCentered;
float roundCornerFactor = GetRoundCornerFactor(RoundCornerCoord, RoundCornerAmount, SmoothBorderAmount);
Output.rgb *= roundCornerFactor;
return Output;
}
//-----------------------------------------------------------------------------
// Scanline & Shadowmask Effect
//-----------------------------------------------------------------------------
technique DefaultTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
}

View File

@ -202,8 +202,9 @@ float random(float2 seed)
uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 SourceRect;
uniform float2 SourceDims;
// level dimensions not necessary anymore?
uniform float2 Level0Size;
uniform float4 Level12Size;
uniform float4 Level34Size;
@ -211,6 +212,8 @@ uniform float4 Level56Size;
uniform float4 Level78Size;
uniform float4 Level9ASize;
uniform bool VectorScreen = false;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@ -223,15 +226,20 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
float2 TexCoord = Input.Position.xy / ScreenDims;
float2 TexCoord = Input.TexCoord;
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.TexCoord0 = TexCoord;
Output.TexCoord12 = TexCoord.xyxy + (0.5f / Level12Size);
Output.TexCoord34 = TexCoord.xyxy + (0.5f / Level34Size);
Output.TexCoord56 = TexCoord.xyxy + (0.5f / Level56Size);
Output.TexCoord78 = TexCoord.xyxy + (0.5f / Level78Size);
Output.TexCoord9A = TexCoord.xyxy + (0.5f / Level9ASize);
Output.TexCoord0 = TexCoord.xy; // + (0.5f / Level0Size);
TexCoord += VectorScreen
? 0.5f / TargetDims.xy
: 0.5f / SourceDims.xy;
Output.TexCoord12 = TexCoord.xyxy; // + (0.5f / Level12Size);
Output.TexCoord34 = TexCoord.xyxy; // + (0.5f / Level34Size);
Output.TexCoord56 = TexCoord.xyxy; // + (0.5f / Level56Size);
Output.TexCoord78 = TexCoord.xyxy; // + (0.5f / Level78Size);
Output.TexCoord9A = TexCoord.xyxy; // + (0.5f / Level9ASize);
return Output;
}
@ -247,7 +255,7 @@ uniform float2 Level56Weight;
uniform float2 Level78Weight;
uniform float2 Level9AWeight;
uniform int BloomBlendMode = 0; // 0 addition, 1 darken
uniform int BloomBlendMode = 0; // 0 brighten, 1 darken
uniform float BloomScale;
uniform float3 BloomOverdrive;
@ -273,7 +281,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 blend;
// addition
// brighten
if (BloomBlendMode == 0)
{
texel0 *= Level0Weight;

View File

@ -52,12 +52,7 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
uniform float2 SourceDims;
uniform float2 SourceRect;
uniform float2 TargetDims;
uniform float2 QuadDims;
uniform bool SwapXY = false;
uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f);
uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f);
@ -68,48 +63,41 @@ VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 HalfSourceRect = SourceRect * 0.5f;
float2 QuadRatio =
float2(1.0f, SwapXY
? QuadDims.y / QuadDims.x
: QuadDims.x / QuadDims.y);
// imaginary texel dimensions independed from quad dimensions, but dependend on quad ratio
float2 FixedTexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // toom
Output.Position.xy *= 2.0f; // zoom
float2 TexCoord = Input.TexCoord;
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.Color = Input.Color;
// imaginary texel dimensions independed from screen dimension, but ratio
float2 TexelDims = (1.0f / 1024);
Output.TexCoordX = TexCoord.xxx;
Output.TexCoordY = TexCoord.yyy;
// center coordinates
Output.TexCoordX -= HalfSourceRect.xxx;
Output.TexCoordY -= HalfSourceRect.yyy;
Output.TexCoordX -= 0.5f;
Output.TexCoordY -= 0.5f;
// radial converge offset to "translate" the most outer pixel as thay would be translated by the linar converge with the same amount
float2 radialConvergeOffset = 2.0f / SourceRect;
float2 radialConvergeOffset = 2.0f;
// radial converge
Output.TexCoordX *= 1.0f + RadialConvergeX * FixedTexelDims.xxx * radialConvergeOffset.xxx;
Output.TexCoordY *= 1.0f + RadialConvergeY * FixedTexelDims.yyy * radialConvergeOffset.yyy;
Output.TexCoordX *= 1.0f + RadialConvergeX * TexelDims.xxx * radialConvergeOffset.xxx;
Output.TexCoordY *= 1.0f + RadialConvergeY * TexelDims.yyy * radialConvergeOffset.yyy;
// un-center coordinates
Output.TexCoordX += HalfSourceRect.xxx;
Output.TexCoordY += HalfSourceRect.yyy;
Output.TexCoordX += 0.5f;
Output.TexCoordY += 0.5f;
// linear converge
Output.TexCoordX += ConvergeX * FixedTexelDims.xxx;
Output.TexCoordY += ConvergeY * FixedTexelDims.yyy;
Output.TexCoordX += ConvergeX * TexelDims.xxx;
Output.TexCoordY += ConvergeY * TexelDims.yyy;
Output.Color = Input.Color;
return Output;
}

View File

@ -89,6 +89,8 @@ uniform float2 ScreenDims; // size of the window or fullscreen
uniform float2 TargetDims; // size of the target surface
uniform float2 QuadDims; // size of the screen quad
uniform bool VectorScreen;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@ -101,7 +103,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
Output.TexCoord = Input.Position.xy / ScreenDims;
Output.TexCoord = Input.TexCoord;
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
return Output;
@ -117,19 +119,9 @@ uniform float SmoothBorderAmount = 0.0f;
uniform float VignettingAmount = 0.0f;
uniform float ReflectionAmount = 0.0f;
uniform bool SwapXY = false;
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
float2 GetRatioCorrection()
{
float ScreenRatio = ScreenDims.x / ScreenDims.y;
float QuadRatio = QuadDims.x / QuadDims.y;
float ScreenQuadRatio = QuadRatio / ScreenRatio;
return ScreenQuadRatio > 1.0f
? float2(1.0, 1.0f / ScreenQuadRatio)
: float2(ScreenQuadRatio, 1.0);
}
float GetNoiseFactor(float3 n, float random)
{
// smaller n become more noisy
@ -152,25 +144,42 @@ float GetVignetteFactor(float2 coord, float amount)
float GetSpotAddend(float2 coord, float amount)
{
float2 RatioCorrection = GetRatioCorrection();
// normalized screen quad ratio
float2 QuadRatio = float2 (1.0f, QuadDims.y / QuadDims.x);
float2 SpotCoord = coord;
// hack for vector screen
if (VectorScreen)
{
// upper right quadrant
float2 spotOffset =
RotationType == 1 // 90°
? float2(-0.25f, -0.25f)
: RotationType == 2 // 180°
? float2(0.25f, -0.25f)
: RotationType == 3 // 27
: RotationType == 3 // 270° else
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f);
float2 SpotCoord = coord;
SpotCoord += spotOffset * RatioCorrection;
SpotCoord *= QuadRatio;
SpotCoord /= RatioCorrection;
// normalized screen canvas ratio
float2 CanvasRatio = SwapXY
? float2(QuadDims.x / QuadDims.y, 1.0f)
: float2(1.0f, QuadDims.y / QuadDims.x);
SpotCoord += spotOffset;
SpotCoord *= CanvasRatio;
}
else
{
// upper right quadrant
float2 spotOffset = float2(-0.25f, 0.25f);
// normalized screen canvas ratio
float2 CanvasRatio = SwapXY
? float2(1.0f, QuadDims.x / QuadDims.y)
: float2(1.0f, QuadDims.y / QuadDims.x);
SpotCoord += spotOffset;
SpotCoord *= CanvasRatio;
}
float SpotBlur = amount;
@ -188,17 +197,20 @@ float GetSpotAddend(float2 coord, float amount)
float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount)
{
float2 RatioCorrection = GetRatioCorrection();
// reduce smooth amount down to radius amount
smoothAmount = min(smoothAmount, radiusAmount);
float range = min(QuadDims.x, QuadDims.y) * 0.5;
float2 quadDims = QuadDims;
quadDims = !VectorScreen && SwapXY
? quadDims.yx
: quadDims.xy;
float range = min(quadDims.x, quadDims.y) * 0.5;
float radius = range * max(radiusAmount, 0.0025f);
float smooth = 1.0 / (range * max(smoothAmount, 0.0025f));
// compute box
float box = roundBox(ScreenDims * (coord * 2.0f), ScreenDims * RatioCorrection, radius);
float box = roundBox(quadDims * (coord * 2.0f), quadDims, radius);
// apply smooth
box *= smooth;
@ -235,20 +247,12 @@ float2 GetDistortedCoords(float2 centerCoord, float amount)
float2 GetCoords(float2 coord, float distortionAmount)
{
float2 RatioCorrection = GetRatioCorrection();
// center coordinates
coord -= 0.5f;
// apply ratio difference between screen and quad
coord /= RatioCorrection;
// distort coordinates
coord = GetDistortedCoords(coord, distortionAmount);
// revert ratio difference between screen and quad
coord *= RatioCorrection;
// un-center coordinates
coord += 0.5f;
@ -257,21 +261,18 @@ float2 GetCoords(float2 coord, float distortionAmount)
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 TexCoord = Input.TexCoord;
float2 BaseCoord = TexCoord;
// Screen Curvature
BaseCoord = GetCoords(BaseCoord, CurvatureAmount * 0.25f); // reduced amount
float2 TexCoord = GetCoords(Input.TexCoord, CurvatureAmount * 0.25f); // reduced amount
float2 BaseCoordCentered = BaseCoord;
BaseCoordCentered -= 0.5f;
float2 TexCoordCentered = TexCoord;
TexCoordCentered -= 0.5f;
// Color
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
float4 BaseColor = tex2D(DiffuseSampler, TexCoord);
BaseColor.a = 1.0f;
// Vignetting Simulation
float2 VignetteCoord = BaseCoordCentered;
float2 VignetteCoord = TexCoordCentered;
float VignetteFactor = GetVignetteFactor(VignetteCoord, VignettingAmount);
BaseColor.rgb *= VignetteFactor;
@ -279,15 +280,15 @@ float4 ps_main(PS_INPUT Input) : COLOR
// Light Reflection Simulation
float3 LightColor = float3(1.0f, 0.90f, 0.80f); // color temperature 5.000 Kelvin
float2 SpotCoord = BaseCoordCentered;
float2 NoiseCoord = BaseCoordCentered;
float2 SpotCoord = TexCoordCentered;
float2 NoiseCoord = TexCoordCentered;
float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount);
float NoiseFactor = GetNoiseFactor(SpotAddend, random(NoiseCoord));
BaseColor.rgb += SpotAddend * NoiseFactor * LightColor;
// Round Corners Simulation
float2 RoundCornerCoord = BaseCoordCentered;
float2 RoundCornerCoord = TexCoordCentered;
float roundCornerFactor = GetRoundCornerFactor(RoundCornerCoord, RoundCornerAmount, SmoothBorderAmount);
BaseColor.rgb *= roundCornerFactor;

View File

@ -53,15 +53,25 @@ struct PS_INPUT
uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 SourceRect;
uniform float2 QuadDims;
uniform bool PrepareVector;
uniform int BloomLevel;
uniform bool VectorScreen;
static const float2 Coord0Offset = float2(-0.5f, -0.5f);
static const float2 Coord1Offset = float2( 0.5f, -0.5f);
static const float2 Coord2Offset = float2(-0.5f, 0.5f);
static const float2 Coord3Offset = float2( 0.5f, 0.5f);
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 TargetTexelDims = 1.0f / TargetDims;
float2 HalfTargetTexelDims = 0.5f / TargetDims;
HalfTargetTexelDims *= VectorScreen
? (ScreenDims / QuadDims)
: 1.0f;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
@ -71,15 +81,13 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
float2 TexCoord = Input.Position.xy / ScreenDims;
TexCoord += PrepareVector
? 0.5f / TargetDims // half texel offset correction (DX9) - only for vector grpahics
: 0.0f;
float2 TexCoord = Input.TexCoord;
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelDims;
Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelDims;
Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelDims;
Output.TexCoord23.zw = TexCoord + float2( 0.5f, 0.5f) * TargetTexelDims;
Output.TexCoord01.xy = TexCoord + Coord0Offset * HalfTargetTexelDims;
Output.TexCoord01.zw = TexCoord + Coord1Offset * HalfTargetTexelDims;
Output.TexCoord23.xy = TexCoord + Coord2Offset * HalfTargetTexelDims;
Output.TexCoord23.zw = TexCoord + Coord3Offset * HalfTargetTexelDims;
return Output;
}

View File

@ -51,8 +51,6 @@ struct PS_INPUT
uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 SourceRect;
uniform float2 QuadDims;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@ -78,28 +76,21 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Defocus Pixel Shader
//-----------------------------------------------------------------------------
float2 Coord1Offset = float2( 0.75f, 0.50f);
float2 Coord2Offset = float2( 0.25f, 1.00f);
float2 Coord3Offset = float2(-0.50f, 0.75f);
float2 Coord4Offset = float2(-1.00f, 0.25f);
float2 Coord5Offset = float2(-0.75f, -0.50f);
float2 Coord6Offset = float2(-0.25f, -1.00f);
float2 Coord7Offset = float2( 0.50f, -0.75f);
float2 Coord8Offset = float2( 1.00f, -0.25f);
uniform float2 Defocus = float2(0.0f, 0.0f);
uniform bool SwapXY = false;
static const float2 Coord1Offset = float2( 0.75f, 0.50f);
static const float2 Coord2Offset = float2( 0.25f, 1.00f);
static const float2 Coord3Offset = float2(-0.50f, 0.75f);
static const float2 Coord4Offset = float2(-1.00f, 0.25f);
static const float2 Coord5Offset = float2(-0.75f, -0.50f);
static const float2 Coord6Offset = float2(-0.25f, -1.00f);
static const float2 Coord7Offset = float2( 0.50f, -0.75f);
static const float2 Coord8Offset = float2( 1.00f, -0.25f);
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 QuadRatio =
float2(1.0f, SwapXY
? QuadDims.y / QuadDims.x
: QuadDims.x / QuadDims.y);
// imaginary texel dimensions independed from quad dimensions, but dependend on quad ratio
float2 TexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
// imaginary texel dimensions independed from screen dimension, but ratio
float2 TexelDims = (1.0f / 1024);
float2 DefocusTexelDims = Defocus * TexelDims;

View File

@ -44,7 +44,7 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
// YIQ Decode Vertex Shader
// YIQ Vertex Shader
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;

View File

@ -49,15 +49,17 @@ struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
float2 ScreenCoord : TEXCOORD1;
float2 SourceCoord : TEXCOORD0;
float2 TexCoord : TEXCOORD1;
float2 ScreenCoord : TEXCOORD2;
};
struct PS_INPUT
{
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
float2 ScreenCoord : TEXCOORD1;
float2 SourceCoord : TEXCOORD0;
float2 TexCoord : TEXCOORD1;
float2 ScreenCoord : TEXCOORD2;
};
//-----------------------------------------------------------------------------
@ -71,10 +73,10 @@ static const float PHI = 1.618034f;
// Scanline & Shadowmask Vertex Shader
//-----------------------------------------------------------------------------
uniform float2 ScreenDims; // size of the window or fullscreen
uniform float2 SourceDims; // size of the texture in power-of-two size
uniform float2 SourceRect; // size of the uv rectangle
uniform float2 TargetDims; // size of the target surface
uniform float2 ScreenDims;
uniform float2 SourceDims;
uniform float2 TargetDims;
uniform float2 QuadDims;
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
@ -82,33 +84,27 @@ uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
uniform bool SwapXY = false;
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
uniform bool PrepareVector = false;
uniform bool VectorScreen = false;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
float2 ScreenCoordOffset = 0.0f;
ScreenCoordOffset += shadowUVOffset;
Output.ScreenCoord = Input.Position.xy;
Output.ScreenCoord += ScreenCoordOffset;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.TexCoord = PrepareVector
? Input.Position.xy / ScreenDims
: Input.TexCoord;
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.TexCoord = Input.TexCoord;
Output.TexCoord += PrepareBloom
? 0.0f / TargetDims // use half texel offset (DX9) to do the blur for first bloom layer
: 0.5f / TargetDims; // fix half texel offset correction (DX9)
Output.ScreenCoord = Input.Position.xy / ScreenDims;
Output.SourceCoord = Input.TexCoord;
Output.SourceCoord += 0.5f / TargetDims;
Output.Color = Input.Color;
@ -119,7 +115,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Scanline & Shadowmask Pixel Shader
//-----------------------------------------------------------------------------
uniform float HumBarHertzRate = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform float HumBarDesync = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform float HumBarAlpha = 0.0f;
uniform float TimeMilliseconds = 0.0f;
@ -129,14 +125,15 @@ uniform float2 ScreenOffset = float2(0.0f, 0.0f);
uniform float ScanlineAlpha = 0.0f;
uniform float ScanlineScale = 1.0f;
uniform float ScanlineHeight = 1.0f;
uniform float ScanlineVariation = 1.0f;
uniform float ScanlineOffset = 1.0f;
uniform float ScanlineBrightScale = 1.0f;
uniform float ScanlineBrightOffset = 1.0f;
uniform float ScanlineOffset = 1.0f;
uniform float ScanlineHeight = 1.0f;
uniform float3 BackColor = float3(0.0f, 0.0f, 0.0f);
uniform int ShadowTileMode = 0; // 0 based on screen dimension, 1 based on source dimension
uniform int ShadowTileMode = 0; // 0 based on screen (quad) dimension, 1 based on source dimension
uniform float ShadowAlpha = 0.0f;
uniform float2 ShadowCount = float2(6.0f, 6.0f);
uniform float2 ShadowUV = float2(0.25f, 0.25f);
@ -161,60 +158,74 @@ float2 GetAdjustedCoords(float2 coord, float2 centerOffset)
return coord;
}
// vector screen has the same quad texture coordinates for every screen orientation, raster screen differs
float2 GetShadowCoord(float2 QuadCoord, float2 SourceCoord)
{
float2 QuadTexel = 1.0f / QuadDims;
float2 SourceTexel = 1.0f / SourceDims;
float2 canvasCoord = ShadowTileMode == 0
? QuadCoord + ShadowUVOffset / QuadDims
: SourceCoord + ShadowUVOffset / SourceDims;
float2 canvasTexelDims = ShadowTileMode == 0
? QuadTexel
: SourceTexel;
float2 shadowDims = ShadowDims;
float2 shadowUV = ShadowUV;
float2 shadowCount = ShadowCount;
// swap x/y vector and raster in screen mode (not source mode)
canvasCoord = ShadowTileMode == 0 && SwapXY
? canvasCoord.yx
: canvasCoord.xy;
// swap x/y vector and raster in screen mode (not source mode)
shadowCount = ShadowTileMode == 0 && SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = canvasTexelDims * shadowCount;
// swap x/y vector in screen mode (not raster and not source mode)
shadowTile = VectorScreen && ShadowTileMode == 0 && SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 shadowFrac = frac(canvasCoord / shadowTile);
// swap x/y raster in screen mode (not vector and not source mode)
shadowFrac = !VectorScreen && ShadowTileMode == 0 && SwapXY
? shadowFrac.yx
: shadowFrac.xy;
float2 shadowCoord = (shadowFrac * shadowUV);
shadowCoord += 0.5f / shadowDims; // half texel offset
return shadowCoord;
}
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
float2 SourceRes = SourceDims * SourceRect;
float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
float2 BaseCoord = GetAdjustedCoords(Input.TexCoord, HalfSourceRect);
float2 ScreenCoord = Input.ScreenCoord;
float2 TexCoord = GetAdjustedCoords(Input.TexCoord, 0.5f);
float2 SourceCoord = GetAdjustedCoords(Input.SourceCoord, 0.5f);
// Color
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
float4 BaseColor = tex2D(DiffuseSampler, TexCoord);
BaseColor.a = 1.0f;
if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f)
// keep border
if (!PrepareBloom)
{
BaseColor.rgb = 0.0f;
// clip border
clip(TexCoord < 0.0f || TexCoord > 1.0f ? -1 : 1);
}
// Mask Simulation (may not affect bloom)
if (!PrepareBloom && ShadowAlpha > 0.0f)
{
float2 shadowDims = ShadowDims;
shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
// shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
// ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
float2 ShadowCoord = GetShadowCoord(ScreenCoord, SourceCoord);
float4 ShadowColor = tex2D(ShadowSampler, ShadowCoord);
float3 ShadowMaskColor = lerp(1.0f, ShadowColor.rgb, ShadowAlpha);
@ -242,33 +253,33 @@ float4 ps_main(PS_INPUT Input) : COLOR
if (!PrepareBloom)
{
// Scanline Simulation (may not affect vector screen)
if (!PrepareVector && ScanlineAlpha > 0.0f)
if (!VectorScreen && ScanlineAlpha > 0.0f)
{
float ScanCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
float ScanCoordJitter = ScanlineOffset * PHI;
float ScanSine = sin(ScanCoord + ScanCoordJitter);
float ScanSineScaled = pow(ScanSine * ScanSine, ScanlineHeight);
float ScanBrightness = ScanSineScaled * ScanlineBrightScale + 1.0f + ScanlineBrightOffset;
float BrightnessOffset = (ScanlineBrightOffset * ScanlineAlpha);
float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0f - ScanlineAlpha);
BaseColor.rgb *= lerp(1.0f, ScanBrightness * 0.5f, ScanlineAlpha);
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
float ScanlineCoord = SourceCoord.y * SourceDims.y * ScanlineScale * PI;
float ScanlineCoordJitter = ScanlineOffset * PHI;
float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
float ScanlineWide = ScanlineHeight + ScanlineVariation * max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);
float ScanlineAmount = pow(ScanlineSine * ScanlineSine, ScanlineWide);
float ScanlineBrightness = ScanlineAmount * BrightnessScale + BrightnessOffset * BrightnessScale;
BaseColor.rgb *= lerp(1.0f, ScanlineBrightness, ScanlineAlpha);
}
// Hum Bar Simulation (may not affect vector screen)
if (!PrepareVector && HumBarAlpha > 0.0f)
if (!VectorScreen && HumBarAlpha > 0.0f)
{
float HumTimeStep = frac(TimeMilliseconds * HumBarHertzRate);
float HumBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumTimeStep) * HumBarAlpha;
BaseColor.rgb *= HumBrightness;
float HumBarStep = frac(TimeMilliseconds * HumBarDesync);
float HumBarBrightness = 1.0 - frac(SourceCoord.y + HumBarStep) * HumBarAlpha;
BaseColor.rgb *= HumBarBrightness;
}
}
// Output
float4 Output = PrepareVector
? BaseColor * (Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f))
: BaseColor * Input.Color;
Output.a = 1.0f;
return Output;
return BaseColor;
}
//-----------------------------------------------------------------------------

View File

@ -1,7 +1,11 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
// copyright-holders:Ryan Holtz,Themaister,ImJezze
//-----------------------------------------------------------------------------
// Prescale Effect
// Pre-scale Effect
//
// Uses the hardware bilinear interpolator to avoid having to sample 4 times manually.
//
// https://github.com/libretro/common-shaders/blob/master/retro/shaders/sharp-bilinear.cg
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@ -13,9 +17,9 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = NONE;
MinFilter = NONE;
MagFilter = NONE;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
@ -45,11 +49,12 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
// Prescale Vertex Shader
// Pre-scale Vertex Shader
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 SourceDims;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@ -68,16 +73,29 @@ VS_OUTPUT vs_main(VS_INPUT Input)
}
//-----------------------------------------------------------------------------
// Prescale Pixel Shader
// Pre-scale Pixel Shader
//-----------------------------------------------------------------------------
float4 ps_main(PS_INPUT Input) : COLOR
{
return tex2D(DiffuseSampler, Input.TexCoord);
float2 Scale = TargetDims / SourceDims;
float2 TexelDims = Input.TexCoord * SourceDims;
float2 i = floor(TexelDims);
float2 s = frac(TexelDims);
// Figure out where in the texel to sample to get the correct pre-scaled bilinear.
float2 CenterDistance = s - 0.5f;
float2 RegionRange = 0.5f - 0.5f / Scale;
float2 f = (CenterDistance - clamp(CenterDistance, -RegionRange, RegionRange)) * Scale + 0.5f;
float2 TexCoord = (i + f) / SourceDims;
return tex2D(DiffuseSampler, TexCoord);
}
//-----------------------------------------------------------------------------
// Prescale Technique
// Pre-scale Technique
//-----------------------------------------------------------------------------
technique DefaultTechnique

View File

@ -46,19 +46,18 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
// Primary Vertex Shader
// Primary Vertex Shaders
//-----------------------------------------------------------------------------
static const float Epsilon = 1.0e-7f;
uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 QuadDims;
uniform bool PostPass;
uniform bool VectorScreen;
uniform float Brighten;
VS_OUTPUT vs_main(VS_INPUT Input)
VS_OUTPUT vs_screen_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@ -68,14 +67,44 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
float2 targetDims = TargetDims + Epsilon; // bug: with exact target dimensions the font disappears
Output.TexCoord = Input.TexCoord;
// Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.TexCoord = PostPass
? Input.Position.xy / ScreenDims
: Input.TexCoord;
Output.TexCoord += PostPass
? 0.5f / targetDims // half texel offset correction (DX9)
: 0.0f;
Output.Color = Input.Color;
return Output;
}
VS_OUTPUT vs_vector_buffer_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.TexCoord = Input.TexCoord;
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.Color = Input.Color;
return Output;
}
VS_OUTPUT vs_ui_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.TexCoord = Input.TexCoord;
// Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
Output.Color = Input.Color;
@ -83,28 +112,64 @@ VS_OUTPUT vs_main(VS_INPUT Input)
}
//-----------------------------------------------------------------------------
// Primary Pixel Shader
// Primary Pixel Shaders
//-----------------------------------------------------------------------------
float4 ps_main(PS_INPUT Input) : COLOR
float4 ps_screen_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
BaseTexel *= Input.Color + float4(Brighten, Brighten, Brighten, 0.0f);
return BaseTexel;
}
float4 ps_vector_buffer_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
return BaseTexel;
}
float4 ps_ui_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
BaseTexel *= Input.Color;
return BaseTexel;
}
//-----------------------------------------------------------------------------
// Primary Technique
// Primary Techniques
//-----------------------------------------------------------------------------
technique DefaultTechnique
technique ScreenTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_2_0 vs_main();
PixelShader = compile ps_2_0 ps_main();
VertexShader = compile vs_2_0 vs_screen_main();
PixelShader = compile ps_2_0 ps_screen_main();
}
}
technique VectorBufferTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_2_0 vs_vector_buffer_main();
PixelShader = compile ps_2_0 ps_vector_buffer_main();
}
}
technique UiTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_2_0 vs_ui_main();
PixelShader = compile ps_2_0 ps_ui_main();
}
}

View File

@ -36,6 +36,8 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
uniform float2 QuadDims;
uniform float2 TimeParams;
uniform float3 LengthParams;
@ -47,9 +49,9 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.Position.xy *= 2.0f * (ScreenDims / QuadDims); // zoom
Output.TexCoord = Input.Position.xy / ScreenDims;
Output.TexCoord = Input.TexCoord;
Output.Color = Input.Color;
@ -75,7 +77,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
lengthModulate = lerp(lengthModulate, 4.0f, minLength * 0.5f);
lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y);
float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f);
float4 outColor = float4(lengthModulate, lengthModulate, lengthModulate, 1.0f);
outColor *= Input.Color;
return outColor;
}

55
ini/gameboy.ini Normal file
View File

@ -0,0 +1,55 @@
#
# DIRECT3D POST-PROCESSING OPTIONS
#
shadow_mask_tile_mode 1
shadow_mask_alpha 0.25
shadow_mask_texture monochrome-matrix.png
shadow_mask_x_count 2
shadow_mask_y_count 2
shadow_mask_usize 0.5
shadow_mask_vsize 0.5
shadow_mask_uoffset 0.0
shadow_mask_voffset 0.0
curvature 0.0
round_corner 0.0
smooth_border 0.0
reflection 0.0
vignetting 0.0
scanline_alpha 0.0
defocus 0.0,0.0
converge_x 0.0,0.0,0.0
converge_y 0.0,0.0,0.0
radial_converge_x 0.0,0.0,0.0
radial_converge_y 0.0,0.0,0.0
red_ratio 1.0,0.0,0.0
grn_ratio 0.0,1.0,0.0
blu_ratio 0.0,0.0,1.0
saturation 1.0
offset 0.0,0.0,0.0
scale 1.0,1.0,1.0
power 1.0,1.0,1.0
floor 0.0,0.0,0.0
phosphor_life 0.5,0.5,0.5
#
# NTSC POST-PROCESSING OPTIONS
#
yiq_enable 0
#
# BLOOM POST-PROCESSING OPTIONS
#
bloom_blend_mode 1
bloom_scale 1.0
bloom_overdrive 0.0,0.0,0.0
bloom_lvl0_weight 1.0
bloom_lvl1_weight 0.64
bloom_lvl2_weight 0.32
bloom_lvl3_weight 0.16
bloom_lvl4_weight 0.08
bloom_lvl5_weight 0.04
bloom_lvl6_weight 0.04
bloom_lvl7_weight 0.02
bloom_lvl8_weight 0.02
bloom_lvl9_weight 0.01
bloom_lvl10_weight 0.01

55
ini/gba.ini Normal file
View File

@ -0,0 +1,55 @@
#
# DIRECT3D POST-PROCESSING OPTIONS
#
shadow_mask_tile_mode 1
shadow_mask_alpha 0.75
shadow_mask_texture slot-mask-aligned.png
shadow_mask_x_count 2
shadow_mask_y_count 2
shadow_mask_usize 0.1875
shadow_mask_vsize 0.1875
shadow_mask_uoffset 0.0
shadow_mask_voffset 0.0
curvature 0.0
round_corner 0.0
smooth_border 0.0
reflection 0.0
vignetting 0.0
scanline_alpha 0.0
defocus 0.0,0.0
converge_x 0.0,0.0,0.0
converge_y 0.0,0.0,0.0
radial_converge_x 0.0,0.0,0.0
radial_converge_y 0.0,0.0,0.0
red_ratio 1.0,0.0,0.0
grn_ratio 0.0,1.0,0.0
blu_ratio 0.0,0.0,1.0
saturation 1.0
offset 0.0,0.0,0.0
scale 1.0,1.0,1.0
power 1.0,1.0,1.0
floor 0.0,0.0,0.0
phosphor_life 0.5,0.5,0.5
#
# NTSC POST-PROCESSING OPTIONS
#
yiq_enable 0
#
# BLOOM POST-PROCESSING OPTIONS
#
bloom_blend_mode 0
bloom_scale 0.25
bloom_overdrive 0.0,0.0,0.0
bloom_lvl0_weight 1.0
bloom_lvl1_weight 0.64
bloom_lvl2_weight 0.32
bloom_lvl3_weight 0.16
bloom_lvl4_weight 0.08
bloom_lvl5_weight 0.04
bloom_lvl6_weight 0.04
bloom_lvl7_weight 0.02
bloom_lvl8_weight 0.02
bloom_lvl9_weight 0.01
bloom_lvl10_weight 0.01

61
ini/raster.ini Normal file
View File

@ -0,0 +1,61 @@
#
# DIRECT3D POST-PROCESSING OPTIONS
#
shadow_mask_tile_mode 0
shadow_mask_alpha 0.35
shadow_mask_texture shadow-mask.png
shadow_mask_x_count 6
shadow_mask_y_count 4
shadow_mask_usize 0.1875
shadow_mask_vsize 0.25
shadow_mask_uoffset 0.0
shadow_mask_voffset 0.0
curvature 0.0
round_corner 0.0
smooth_border 0.0
reflection 0.0
vignetting 0.0
scanline_alpha 0.50
scanline_size 1.0
scanline_height 1.0
scanline_variation 1.0
scanline_bright_scale 2.0
scanline_bright_offset 0.0
scanline_jitter 0.0
defocus 1.0,0.0
converge_x 0.0,0.0,0.0
converge_y 0.0,0.0,0.0
radial_converge_x 0.0,0.0,0.0
radial_converge_y 0.0,0.0,0.0
red_ratio 1.05,0.00,0.10
grn_ratio -0.10,1.00,0.25
blu_ratio -0.25,0.25,1.25
saturation 1.25
offset -0.30,-0.20,-0.05
scale 1.15,1.05,0.90
power 0.90,0.90,1.15
floor 0.05,0.05,0.05
phosphor_life 0.5,0.5,0.5
#
# NTSC POST-PROCESSING OPTIONS
#
yiq_enable 0
#
# BLOOM POST-PROCESSING OPTIONS
#
bloom_blend_mode 0
bloom_scale 0.35
bloom_overdrive 1.00,1.00,1.00
bloom_lvl0_weight 1.00
bloom_lvl1_weight 0.64
bloom_lvl2_weight 0.32
bloom_lvl3_weight 0.16
bloom_lvl4_weight 0.08
bloom_lvl5_weight 0.04
bloom_lvl6_weight 0.04
bloom_lvl7_weight 0.02
bloom_lvl8_weight 0.02
bloom_lvl9_weight 0.01
bloom_lvl10_weight 0.01

70
ini/vector.ini Normal file
View File

@ -0,0 +1,70 @@
#
# CORE VECTOR OPTIONS
#
antialias 1
beam_width_min 0.50
beam_width_max 4.00
beam_intensity_weight 0.75
flicker 0.15
#
# DIRECT3D POST-PROCESSING OPTIONS
#
shadow_mask_tile_mode 0
shadow_mask_alpha 0.5
shadow_mask_texture shadow-mask.png
shadow_mask_x_count 6
shadow_mask_y_count 4
shadow_mask_usize 0.1875
shadow_mask_vsize 0.25
shadow_mask_uoffset 0.0
shadow_mask_voffset 0.0
curvature 0.0
round_corner 0.0
smooth_border 0.0
reflection 0.0
vignetting 0.0
scanline_alpha 0.0
defocus 0.0,0.0
converge_x 0.0,0.0,0.0
converge_y 0.0,0.0,0.0
radial_converge_x 0.0,0.0,0.0
radial_converge_y 0.0,0.0,0.0
red_ratio 1.0,0.0,0.1
grn_ratio 0.0,1.0,0.0
blu_ratio 0.0,0.0,1.0
saturation 1.0
offset 0.0,0.0,0.0
scale 1.0,1.0,1.0
power 1.0,1.0,1.0
floor 0.0,0.0,0.0
phosphor_life 0.5,0.5,0.5
#
# NTSC POST-PROCESSING OPTIONS
#
yiq_enable 0
#
# VECTOR POST-PROCESSING OPTIONS
#
vector_length_scale 0.8
vector_length_ratio 500.0
#
# BLOOM POST-PROCESSING OPTIONS
#
bloom_blend_mode 0
bloom_scale 1.50
bloom_overdrive 1.50,1.50,1.50
bloom_lvl0_weight 1.00
bloom_lvl1_weight 0.64
bloom_lvl2_weight 0.32
bloom_lvl3_weight 0.16
bloom_lvl4_weight 0.24
bloom_lvl5_weight 0.32
bloom_lvl6_weight 0.48
bloom_lvl7_weight 0.32
bloom_lvl8_weight 0.24
bloom_lvl9_weight 0.16
bloom_lvl10_weight 0.08

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2619,6 +2619,8 @@ if (BUSES["SVI_SLOT"]~=null) then
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv801.h",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv803.cpp",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv803.h",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv805.cpp",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv805.h",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv806.cpp",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv806.h",
MAME_DIR .. "src/devices/bus/svi3x8/slot/sv807.cpp",

View File

@ -1709,6 +1709,8 @@ if (MACHINES["PCI"]~=null) then
MAME_DIR .. "src/devices/machine/lpc-pit.h",
MAME_DIR .. "src/devices/machine/vrc4373.cpp",
MAME_DIR .. "src/devices/machine/vrc4373.h",
MAME_DIR .. "src/devices/machine/gt64xxx.cpp",
MAME_DIR .. "src/devices/machine/gt64xxx.h",
}
end

View File

@ -40,7 +40,7 @@ end
}
project("tests")
project("mametests")
uuid ("66d4c639-196b-4065-a411-7ee9266564f5")
kind "ConsoleApp"
@ -70,11 +70,13 @@ project("tests")
includedirs {
MAME_DIR .. "3rdparty/googletest/googletest/include",
MAME_DIR .. "src/osd",
MAME_DIR .. "src/emu",
MAME_DIR .. "src/lib/util",
}
files {
MAME_DIR .. "tests/main.cpp",
MAME_DIR .. "tests/lib/util/corestr.cpp",
MAME_DIR .. "tests/emu/attotime.cpp",
}

View File

@ -28,6 +28,7 @@ end
links {
"utils",
"expat",
"7z",
"ocore_" .. _OPTIONS["osd"],
}

View File

@ -12,18 +12,31 @@
#include "trident.h"
#include "debugger.h"
const device_type TRIDENT_VGA = &device_creator<trident_vga_device>;
const device_type TRIDENT_VGA = &device_creator<tgui9860_device>;
const device_type TVGA9000_VGA = &device_creator<tvga9000_device>;
#define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0)
#define LOG (1)
#define LOG_ACCEL (1)
trident_vga_device::trident_vga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: svga_device(mconfig, TRIDENT_VGA, "Trident TGUI9680", tag, owner, clock, "trident_vga", __FILE__)
trident_vga_device::trident_vga_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: svga_device(mconfig, type, name, tag, owner, clock, shortname, source)
{
}
tgui9860_device::tgui9860_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: trident_vga_device(mconfig, TRIDENT_VGA, "Trident TGUI9680", tag, owner, clock, "trident_vga", __FILE__)
{
m_version = 0xd3; // 0xd3 identifies at TGUI9660XGi (set to 0xe3 to identify at TGUI9440AGi)
}
tvga9000_device::tvga9000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: trident_vga_device(mconfig, TVGA9000_VGA, "Trident TVGA9000", tag, owner, clock, "tvga9000_vga", __FILE__)
{
m_version = 0x43;
}
UINT8 trident_vga_device::READPIXEL8(INT16 x, INT16 y)
{
return (vga.memory[((y & 0xfff)*offset() + (x & 0xfff)) % vga.svga_intf.vram_size]);
@ -174,7 +187,7 @@ void trident_vga_device::device_start()
void trident_vga_device::device_reset()
{
svga_device::device_reset();
svga.id = 0xd3; // 0xd3 identifies at TGUI9660XGi (set to 0xe3 to identify at TGUI9440AGi)
svga.id = m_version;
tri.revision = 0x01; // revision identifies as TGUI9680
tri.new_mode = false; // start up in old mode
tri.dac_active = false;
@ -377,11 +390,14 @@ void trident_vga_device::trident_define_video_mode()
switch((tri.pixel_depth & 0x0c) >> 2)
{
case 0:
default: if(!(tri.pixel_depth & 0x10)) svga.rgb8_en = 1; break;
default: if(!(tri.pixel_depth & 0x10) || (tri.cr1e & 0x80)) svga.rgb8_en = 1; break;
case 1: if((tri.dac & 0xf0) == 0x30) svga.rgb16_en = 1; else svga.rgb15_en = 1; break;
case 2: svga.rgb32_en = 1; break;
}
if((tri.cr1e & 0x80) && (svga.id == 0x43))
divisor = 2;
recompute_params_clock(divisor, xtal);
}

View File

@ -16,7 +16,7 @@ class trident_vga_device : public svga_device
{
public:
// construction/destruction
trident_vga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
trident_vga_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
virtual READ8_MEMBER(port_03c0_r) override;
virtual WRITE8_MEMBER(port_03c0_w) override;
@ -113,6 +113,7 @@ protected:
INT16 accel_mem_y;
UINT32 accel_transfer;
} tri;
UINT8 m_version;
private:
UINT8 trident_seq_reg_read(UINT8 index);
void trident_seq_reg_write(UINT8 index, UINT8 data);
@ -146,8 +147,20 @@ private:
UINT32 handle_rop(UINT32 src, UINT32 dst);
};
class tgui9860_device : public trident_vga_device
{
public:
tgui9860_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
class tvga9000_device : public trident_vga_device
{
public:
tvga9000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
// device type definition
extern const device_type TRIDENT_VGA;
extern const device_type TVGA9000_VGA;
#endif /* TRIDENT_H_ */

View File

@ -11,6 +11,7 @@
SLOT_INTERFACE_START( svi_slot_cards )
SLOT_INTERFACE("sv801", SV801)
SLOT_INTERFACE("sv803", SV803)
SLOT_INTERFACE("sv805", SV805)
SLOT_INTERFACE("sv806", SV806)
SLOT_INTERFACE("sv807", SV807)
SLOT_INTERFACE_END

View File

@ -14,6 +14,7 @@
#include "emu.h"
#include "sv801.h"
#include "sv803.h"
#include "sv805.h"
#include "sv806.h"
#include "sv807.h"

View File

@ -96,6 +96,7 @@ public:
void add_card(device_svi_slot_interface *card);
// from slot
DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); };
DECLARE_WRITE_LINE_MEMBER( romdis_w ) { m_romdis_handler(state); };
DECLARE_WRITE_LINE_MEMBER( ramdis_w ) { m_ramdis_handler(state); };

View File

@ -0,0 +1,109 @@
// license:GPL-2.0+
// copyright-holders:Dirk Best
/***************************************************************************
SV-805 RS-232 Interface for SVI 318/328
***************************************************************************/
#include "sv805.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type SV805 = &device_creator<sv805_device>;
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( sv805 )
MCFG_DEVICE_ADD("uart", INS8250, XTAL_3_072MHz)
MCFG_INS8250_OUT_INT_CB(WRITELINE(sv805_device, uart_intr_w))
MCFG_INS8250_OUT_TX_CB(DEVWRITELINE("rs232", rs232_port_device, write_txd))
MCFG_INS8250_OUT_DTR_CB(DEVWRITELINE("rs232", rs232_port_device, write_dtr))
MCFG_INS8250_OUT_RTS_CB(DEVWRITELINE("rs232", rs232_port_device, write_rts))
MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, nullptr)
MCFG_RS232_RXD_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, rx_w))
MCFG_RS232_DCD_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, dcd_w))
MCFG_RS232_DSR_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, dsr_w))
MCFG_RS232_CTS_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, cts_w))
MACHINE_CONFIG_END
machine_config_constructor sv805_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( sv805 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sv806_device - constructor
//-------------------------------------------------
sv805_device::sv805_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, SV805, "SV-805 RS-232 Interface", tag, owner, clock, "sv805", __FILE__),
device_svi_slot_interface(mconfig, *this),
m_uart(*this, "uart"),
m_rs232(*this, "rs232")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sv805_device::device_start()
{
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
READ8_MEMBER( sv805_device::iorq_r )
{
switch (offset)
{
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
case 0x2f:
return m_uart->ins8250_r(space, offset & 0x07);
}
return 0xff;
}
WRITE8_MEMBER( sv805_device::iorq_w )
{
switch (offset)
{
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
case 0x2f:
m_uart->ins8250_w(space, offset & 0x07, data);
}
}
WRITE_LINE_MEMBER( sv805_device::uart_intr_w )
{
m_bus->int_w(state);
}

View File

@ -0,0 +1,49 @@
// license:GPL-2.0+
// copyright-holders:Dirk Best
/***************************************************************************
SV-805 RS-232 Interface for SVI 318/328
***************************************************************************/
#pragma once
#ifndef __SVI3X8_SLOT_SV805_H__
#define __SVI3X8_SLOT_SV805_H__
#include "emu.h"
#include "slot.h"
#include "machine/ins8250.h"
#include "bus/rs232/rs232.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> sv805_device
class sv805_device : public device_t, public device_svi_slot_interface
{
public:
// construction/destruction
sv805_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual DECLARE_READ8_MEMBER( iorq_r ) override;
virtual DECLARE_WRITE8_MEMBER( iorq_w ) override;
DECLARE_WRITE_LINE_MEMBER( uart_intr_w );
protected:
virtual machine_config_constructor device_mconfig_additions() const override;
virtual void device_start() override;
private:
required_device<ins8250_device> m_uart;
required_device<rs232_port_device> m_rs232;
};
// device type definition
extern const device_type SV805;
#endif // __SVI3X8_SLOT_SV805_H__

View File

@ -2245,43 +2245,46 @@ rpk_socket::rpk_socket(const char* id, int length, UINT8* contents)
/*
Locate a file in the ZIP container
*/
const zip_file::file_header* rpk_reader::find_file(zip_file &zip, const char *filename, UINT32 crc)
int rpk_reader::find_file(util::archive_file &zip, const char *filename, UINT32 crc)
{
const zip_file::file_header *header;
for (header = zip.first_file(); header != nullptr; header = zip.next_file())
for (int header = zip.first_file(); header >= 0; header = zip.next_file())
{
// Ignore directories
if (!zip.current_is_directory())
{
// We don't check for CRC == 0.
if (crc != 0)
{
// if the CRC and name both match, we're good
// if the CRC matches and the name doesn't, we're still good
if (header->crc == crc)
if (zip.current_crc() == crc)
return header;
}
else
{
if (core_stricmp(header->filename, filename)==0)
if (core_stricmp(zip.current_name().c_str(), filename) == 0)
{
return header;
}
}
}
return nullptr;
}
return -1;
}
/*
Load a rom resource and put it in a pcb socket instance.
*/
rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_resource_node, const char* socketname)
rpk_socket* rpk_reader::load_rom_resource(util::archive_file &zip, xml_data_node* rom_resource_node, const char* socketname)
{
const char* file;
const char* crcstr;
const char* sha1;
zip_file::error ziperr;
util::archive_file::error ziperr;
UINT32 crc;
int length;
UINT8* contents;
const zip_file::file_header *header;
int header;
// find the file attribute (required)
file = xml_get_attribute_string(rom_resource_node, "file", nullptr);
@ -2301,9 +2304,9 @@ rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_reso
crc = strtoul(crcstr, nullptr, 16);
header = find_file(zip, file, crc);
}
if (header == nullptr) throw rpk_exception(RPK_INVALID_FILE_REF, "File not found or CRC check failed");
if (header < 0) throw rpk_exception(RPK_INVALID_FILE_REF, "File not found or CRC check failed");
length = header->uncompressed_length;
length = zip.current_uncompressed_length();
// Allocate storage
contents = global_alloc_array_clear<UINT8>(length);
@ -2311,9 +2314,9 @@ rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_reso
// and unzip file from the zip file
ziperr = zip.decompress(contents, length);
if (ziperr != zip_file::error::NONE)
if (ziperr != util::archive_file::error::NONE)
{
if (ziperr == zip_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED);
if (ziperr == util::archive_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED);
else throw rpk_exception(RPK_ZIP_ERROR);
}
@ -2414,15 +2417,14 @@ rpk_socket* rpk_reader::load_ram_resource(emu_options &options, xml_data_node* r
rpk* rpk_reader::open(emu_options &options, const char *filename, const char *system_name)
{
zip_file::error ziperr;
util::archive_file::error ziperr;
const zip_file::file_header *header;
const char *pcb_type;
const char *id;
const char *uses_name;
const char *resource_name;
zip_file::ptr zipfile;
util::archive_file::ptr zipfile;
std::vector<char> layout_text;
xml_data_node *layout_xml = nullptr;
@ -2442,25 +2444,24 @@ rpk* rpk_reader::open(emu_options &options, const char *filename, const char *sy
try
{
/* open the ZIP file */
ziperr = zip_file::open(filename, zipfile);
if (ziperr != zip_file::error::NONE) throw rpk_exception(RPK_NOT_ZIP_FORMAT);
ziperr = util::archive_file::open_zip(filename, zipfile);
if (ziperr != util::archive_file::error::NONE) throw rpk_exception(RPK_NOT_ZIP_FORMAT);
/* find the layout.xml file */
header = find_file(*zipfile, "layout.xml", 0);
if (header == nullptr) throw rpk_exception(RPK_MISSING_LAYOUT);
if (find_file(*zipfile, "layout.xml", 0) < 0) throw rpk_exception(RPK_MISSING_LAYOUT);
/* reserve space for the layout file contents (+1 for the termination) */
layout_text.resize(header->uncompressed_length + 1);
layout_text.resize(zipfile->current_uncompressed_length() + 1);
/* uncompress the layout text */
ziperr = zipfile->decompress(&layout_text[0], header->uncompressed_length);
if (ziperr != zip_file::error::NONE)
ziperr = zipfile->decompress(&layout_text[0], zipfile->current_uncompressed_length());
if (ziperr != util::archive_file::error::NONE)
{
if (ziperr == zip_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED);
if (ziperr == util::archive_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED);
else throw rpk_exception(RPK_ZIP_ERROR);
}
layout_text[header->uncompressed_length] = '\0'; // Null-terminate
layout_text[zipfile->current_uncompressed_length()] = '\0'; // Null-terminate
/* parse the layout text */
layout_xml = xml_string_read(&layout_text[0], nullptr);

View File

@ -454,8 +454,8 @@ public:
rpk *open(emu_options &options, const char *filename, const char *system_name);
private:
const zip_file::file_header* find_file(zip_file &zip, const char *filename, UINT32 crc);
rpk_socket* load_rom_resource(zip_file &zip, xml_data_node* rom_resource_node, const char* socketname);
int find_file(util::archive_file &zip, const char *filename, UINT32 crc);
rpk_socket* load_rom_resource(util::archive_file &zip, xml_data_node* rom_resource_node, const char* socketname);
rpk_socket* load_ram_resource(emu_options &options, xml_data_node* ram_resource_node, const char* socketname, const char* system_name);
const pcb_type* m_types;
};

View File

@ -365,7 +365,7 @@ floppy_image_format_t *floppy_image_device::identify(std::string filename)
util::core_file::ptr fd;
std::string revised_path;
osd_file::error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
osd_file::error err = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path);
if(err != osd_file::error::NONE) {
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file");
return nullptr;
@ -1004,7 +1004,7 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist
std::string tmp_path;
util::core_file::ptr tmp_file;
/* attempt to open the file for writing but *without* create */
filerr = zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
filerr = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
if(filerr == osd_file::error::NONE)
tmp_file.reset();
else
@ -1048,7 +1048,7 @@ void ui_menu_control_floppy_image::handle()
state = START_FILE;
handle();
} else {
zippath_combine(output_filename, current_directory.c_str(), current_file.c_str());
util::zippath_combine(output_filename, current_directory.c_str(), current_file.c_str());
output_format = format_array[submenu_result];
do_load_create();
ui_menu::stack_pop(machine());

View File

@ -0,0 +1,600 @@
// license:BSD-3-Clause
// copyright-holders: Aaron Giles, Ted Green
#include "gt64xxx.h"
/*************************************
*
* Debugging constants
*
*************************************/
#define LOG_GALILEO (0)
#define LOG_REG (0)
#define LOG_TIMERS (0)
#define LOG_DMA (0)
const device_type GT64XXX = &device_creator<gt64xxx_device>;
DEVICE_ADDRESS_MAP_START(config_map, 32, gt64xxx_device)
AM_INHERIT_FROM(pci_device::config_map)
ADDRESS_MAP_END
// cpu i/f map
DEVICE_ADDRESS_MAP_START(cpu_map, 32, gt64xxx_device)
AM_RANGE(0x00000000, 0x00000cff) AM_READWRITE( cpu_if_r, cpu_if_w)
ADDRESS_MAP_END
gt64xxx_device::gt64xxx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: pci_host_device(mconfig, GT64XXX, "Galileo GT-64XXX System Controller", tag, owner, clock, "gt64xxx", __FILE__),
m_be(0), m_autoconfig(0), m_irq_num(-1),
m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32)
{
}
const address_space_config *gt64xxx_device::memory_space_config(address_spacenum spacenum) const
{
return (spacenum == AS_PROGRAM) ? pci_bridge_device::memory_space_config(spacenum) : (spacenum == AS_DATA) ? &m_mem_config : (spacenum == AS_IO) ? &m_io_config : NULL;
}
void gt64xxx_device::device_start()
{
pci_host_device::device_start();
m_cpu = machine().device<mips3_device>(cpu_tag);
m_cpu_space = &m_cpu->space(AS_PROGRAM);
memory_space = &space(AS_DATA);
io_space = &space(AS_IO);
memory_window_start = 0;
memory_window_end = 0xffffffff;
memory_offset = 0;
io_window_start = 0;
io_window_end = 0xffffffff;
io_offset = 0x00000000;
status = 0x0;
// ROM size = 4 MB
m_cpu_space->install_rom (0x1fc00000, 0x1fffffff, m_region->base());
// MIPS drc
m_cpu->add_fastram(0x1fc00000, 0x1fffffff, TRUE, m_region->base());
}
void gt64xxx_device::device_reset()
{
pci_device::device_reset();
// Configuration register defaults
m_reg[GREG_CPU_CONFIG] = m_be ? 0 : (1<<12);
m_reg[GREG_RAS_1_0_LO] = 0x0;
m_reg[GREG_RAS_1_0_HI] = 0x7;
m_reg[GREG_RAS_3_2_LO] = 0x8;
m_reg[GREG_RAS_3_2_HI] = 0xf;
m_reg[GREG_CS_2_0_LO] = 0xe0;
m_reg[GREG_CS_2_0_HI] = 0x70;
m_reg[GREG_CS_3_BOOT_LO] = 0xf8;
m_reg[GREG_CS_3_BOOT_HI] = 0x7f;
m_reg[GREG_PCI_IO_LO] = 0x80;
m_reg[GREG_PCI_IO_HI] = 0xf;
m_reg[GREG_PCI_MEM0_LO] = 0x90;
m_reg[GREG_PCI_MEM0_HI] = 0x1f;
m_reg[GREG_INTERNAL_SPACE] = 0xa0;
m_reg[GREG_PCI_MEM1_LO] = 0x790;
m_reg[GREG_PCI_MEM1_HI] = 0x1f;
m_reg[GREG_RAS0_LO] = 0x0;
m_reg[GREG_RAS0_HI] = 0x7;
m_reg[GREG_RAS1_LO] = 0x8;
m_reg[GREG_RAS1_HI] = 0xf;
m_reg[GREG_RAS2_LO] = 0x10;
m_reg[GREG_RAS2_HI] = 0x17;
m_reg[GREG_RAS3_LO] = 0x18;
m_reg[GREG_RAS3_HI] = 0x1f;
m_reg[GREG_CS0_LO] = 0xc0;
m_reg[GREG_CS0_HI] = 0xc7;
m_reg[GREG_CS1_LO] = 0xc8;
m_reg[GREG_CS1_HI] = 0xcf;
m_reg[GREG_CS2_LO] = 0xd0;
m_reg[GREG_CS2_HI] = 0xdf;
m_reg[GREG_CS3_LO] = 0xf0;
m_reg[GREG_CS3_HI] = 0xfb;
m_reg[GREG_CSBOOT_LO] = 0xfc;
m_reg[GREG_CSBOOT_HI] = 0xff;
m_reg[GREG_PCI_COMMAND] = m_be ? 0 : 1;
map_cpu_space();
regenerate_config_mapping();
}
void gt64xxx_device::map_cpu_space()
{
UINT32 winStart, winEnd;
// ROM region starts at 0x1fc00000
m_cpu_space->unmap_readwrite(0x00000000, 0x1fbfffff);
m_cpu_space->unmap_readwrite(0x20000000, 0xffffffff);
// Clear fastram regions in cpu after rom
m_cpu->clear_fastram(1);
// CPU Regs
winStart = m_reg[GREG_INTERNAL_SPACE]<<21;
winEnd = winStart + sizeof(m_reg) - 1;
m_cpu_space->install_device(winStart, winEnd, *static_cast<gt64xxx_device *>(this), &gt64xxx_device::cpu_map);
if (LOG_GALILEO)
logerror("%s: map_cpu_space cpu_reg start: %08X end: %08X\n", tag(), winStart, winEnd);
// Ras0
winStart = (m_reg[GREG_RAS_1_0_LO]<<21) | (m_reg[GREG_RAS0_LO]<<20);
winEnd = (m_reg[GREG_RAS_1_0_LO]<<21) | (m_reg[GREG_RAS0_HI]<<20) | 0xfffff;
m_ram[0].resize((winEnd+1-winStart)/4);
m_cpu_space->install_ram(winStart, winEnd, &m_ram[0][0]);
m_cpu->add_fastram(winStart, m_ram[0].size()*sizeof(m_ram[0][0]), FALSE, &m_ram[0][0]);
if (LOG_GALILEO)
logerror("%s: map_cpu_space ras0 start: %08X end: %08X\n", tag(), winStart, winEnd);
// PCI IO Window
winStart = m_reg[GREG_PCI_IO_LO]<<21;
winEnd = (m_reg[GREG_PCI_IO_LO]<<21) | (m_reg[GREG_PCI_IO_HI]<<21) | 0x1fffff;
m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_io_r), this));
m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_io_w), this));
if (LOG_GALILEO)
logerror("%s: map_cpu_space pci_io start: %08X end: %08X\n", tag(), winStart, winEnd);
// PCI MEM0 Window
winStart = m_reg[GREG_PCI_MEM0_LO]<<21;
winEnd = (m_reg[GREG_PCI_MEM0_LO]<<21) | (m_reg[GREG_PCI_MEM0_HI]<<21) | 0x1fffff;
m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_mem0_r), this));
m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_mem0_w), this));
if (LOG_GALILEO)
logerror("%s: map_cpu_space pci_mem0 start: %08X end: %08X\n", tag(), winStart, winEnd);
// PCI MEM1 Window
winStart = m_reg[GREG_PCI_MEM1_LO]<<21;
winEnd = (m_reg[GREG_PCI_MEM1_LO]<<21) | (m_reg[GREG_PCI_MEM1_HI]<<21) | 0x1fffff;
m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_mem1_r), this));
m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_mem1_w), this));
if (LOG_GALILEO)
logerror("%s: map_cpu_space pci_mem1 start: %08X end: %08X\n", tag(), winStart, winEnd);
}
void gt64xxx_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space)
{
/*
UINT32 winStart, winEnd, winSize;
// PCI Target Window 1
if (m_cpu_regs[NREG_PCITW1]&0x1000) {
winStart = m_cpu_regs[NREG_PCITW1]&0xffe00000;
winEnd = winStart | (~(0xf0000000 | (((m_cpu_regs[NREG_PCITW1]>>13)&0x7f)<<21)));
winSize = winEnd - winStart + 1;
memory_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::target1_r), this));
memory_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::target1_w), this));
if (LOG_GALILEO)
logerror("%s: map_extra Target Window 1 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_target1_laddr);
}
*/
}
void gt64xxx_device::reset_all_mappings()
{
pci_device::reset_all_mappings();
}
// PCI bus control
READ32_MEMBER (gt64xxx_device::pci_config_r)
{
UINT32 result = 0;
if (LOG_GALILEO)
logerror("%06X:galileo pci_config_r from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask);
return result;
}
WRITE32_MEMBER (gt64xxx_device::pci_config_w)
{
if (LOG_GALILEO)
logerror("%06X:galileo pci_config_w to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
}
// PCI Master Window 0
READ32_MEMBER (gt64xxx_device::master_mem0_r)
{
UINT32 result = this->space(AS_DATA).read_dword((m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pci mem0 read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), result, mem_mask);
return result;
}
WRITE32_MEMBER (gt64xxx_device::master_mem0_w)
{
this->space(AS_DATA).write_dword((m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), data, mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pci mem0 write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), data, mem_mask);
}
// PCI Master Window 1
READ32_MEMBER (gt64xxx_device::master_mem1_r)
{
UINT32 result = this->space(AS_DATA).read_dword((m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pci mem1 read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), result, mem_mask);
return result;
}
WRITE32_MEMBER (gt64xxx_device::master_mem1_w)
{
this->space(AS_DATA).write_dword((m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), data, mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pci mem1 write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), data, mem_mask);
}
// PCI Master IO
READ32_MEMBER (gt64xxx_device::master_io_r)
{
UINT32 result = this->space(AS_IO).read_dword((m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pci io read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), result, mem_mask);
return result;
}
WRITE32_MEMBER (gt64xxx_device::master_io_w)
{
this->space(AS_IO).write_dword((m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), data, mem_mask);
if (LOG_GALILEO)
logerror("%06X:galileo pciio write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), data, mem_mask);
}
// CPU I/F
READ32_MEMBER (gt64xxx_device::cpu_if_r)
{
UINT32 result = m_reg[offset];
/* switch off the offset for special cases */
switch (offset)
{
case GREG_TIMER0_COUNT:
case GREG_TIMER1_COUNT:
case GREG_TIMER2_COUNT:
case GREG_TIMER3_COUNT:
{
int which = offset % 4;
galileo_timer *timer = &m_timer[which];
result = timer->count;
if (timer->active)
{
UINT32 elapsed = (timer->timer->elapsed() * m_clock).as_double();
result = (result > elapsed) ? (result - elapsed) : 0;
}
/* eat some time for those which poll this register */
space.device().execute().eat_cycles(100);
if (LOG_TIMERS)
logerror("%08X:hires_timer_r = %08X\n", space.device().safe_pc(), result);
break;
}
case GREG_PCI_COMMAND:
// code at 40188 loops until this returns non-zero in bit 0
//result = 0x0001;
break;
case GREG_CONFIG_DATA:
result = config_data_r(space, offset);
break;
case GREG_CONFIG_ADDRESS:
result = config_address_r(space, offset);
break;
case GREG_INT_STATE:
case GREG_INT_MASK:
case GREG_TIMER_CONTROL:
// if (LOG_GALILEO)
// logerror("%08X:Galileo read from offset %03X = %08X\n", space.device().safe_pc(), offset*4, result);
break;
default:
logerror("%08X:Galileo read from offset %03X = %08X\n", space.device().safe_pc(), offset*4, result);
break;
}
if (m_be) result = FLIPENDIAN_INT32(result);
return result;
}
WRITE32_MEMBER(gt64xxx_device::cpu_if_w)
{
if (m_be) {
data = FLIPENDIAN_INT32(data);
mem_mask = FLIPENDIAN_INT32(mem_mask);
}
UINT32 oldata = m_reg[offset];
COMBINE_DATA(&m_reg[offset]);
/* switch off the offset for special cases */
switch (offset)
{
case GREG_RAS_1_0_LO:
case GREG_RAS_1_0_HI:
case GREG_RAS_3_2_LO:
case GREG_RAS_3_2_HI:
case GREG_CS_2_0_LO:
case GREG_CS_2_0_HI:
case GREG_CS_3_BOOT_LO:
case GREG_CS_3_BOOT_HI:
case GREG_PCI_IO_LO:
case GREG_PCI_IO_HI:
case GREG_PCI_MEM0_LO:
case GREG_PCI_MEM0_HI:
case GREG_INTERNAL_SPACE:
case GREG_PCI_MEM1_LO:
case GREG_PCI_MEM1_HI:
map_cpu_space();
if (LOG_GALILEO)
logerror("%08X:Galileo Memory Map data write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
break;
case GREG_DMA0_CONTROL:
case GREG_DMA1_CONTROL:
case GREG_DMA2_CONTROL:
case GREG_DMA3_CONTROL:
{
int which = offset % 4;
if (LOG_DMA)
logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
/* keep the read only activity bit */
m_reg[offset] &= ~0x4000;
m_reg[offset] |= (oldata & 0x4000);
/* fetch next record */
if (data & 0x2000)
dma_fetch_next(space, which);
m_reg[offset] &= ~0x2000;
/* if enabling, start the DMA */
if (!(oldata & 0x1000) && (data & 0x1000))
perform_dma(space, which);
break;
}
case GREG_TIMER0_COUNT:
case GREG_TIMER1_COUNT:
case GREG_TIMER2_COUNT:
case GREG_TIMER3_COUNT:
{
int which = offset % 4;
galileo_timer *timer = &m_timer[which];
if (which != 0)
data &= 0xffffff;
if (!timer->active)
timer->count = data;
if (LOG_TIMERS)
logerror("%08X:timer/counter %d count = %08X [start=%08X]\n", space.device().safe_pc(), offset % 4, data, timer->count);
break;
}
case GREG_TIMER_CONTROL:
{
int which, mask;
if (LOG_TIMERS)
logerror("%08X:timer/counter control = %08X\n", space.device().safe_pc(), data);
for (which = 0, mask = 0x01; which < 4; which++, mask <<= 2)
{
galileo_timer *timer = &m_timer[which];
if (!timer->active && (data & mask))
{
timer->active = 1;
if (timer->count == 0)
{
timer->count = m_reg[GREG_TIMER0_COUNT + which];
if (which != 0)
timer->count &= 0xffffff;
}
timer->timer->adjust(TIMER_PERIOD * timer->count, which);
if (LOG_TIMERS)
logerror("Adjusted timer to fire in %f secs\n", (TIMER_PERIOD * timer->count).as_double());
}
else if (timer->active && !(data & mask))
{
UINT32 elapsed = (timer->timer->elapsed() * m_clock).as_double();
timer->active = 0;
timer->count = (timer->count > elapsed) ? (timer->count - elapsed) : 0;
timer->timer->adjust(attotime::never, which);
if (LOG_TIMERS)
logerror("Disabled timer\n");
}
}
break;
}
case GREG_INT_STATE:
if (LOG_GALILEO)
logerror("%08X:Galileo write to IRQ clear = %08X & %08X\n", offset*4, data, mem_mask);
m_reg[offset] = oldata & data;
update_irqs();
break;
case GREG_CONFIG_DATA:
pci_host_device::config_data_w(space, offset, data);
if (LOG_GALILEO)
logerror("%08X:Galileo PCI config data write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
break;
case GREG_CONFIG_ADDRESS:
pci_host_device::config_address_w(space, offset, data);
if (LOG_GALILEO)
logerror("%08X:Galileo PCI config address write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
break;
case GREG_DMA0_COUNT: case GREG_DMA1_COUNT: case GREG_DMA2_COUNT: case GREG_DMA3_COUNT:
case GREG_DMA0_SOURCE: case GREG_DMA1_SOURCE: case GREG_DMA2_SOURCE: case GREG_DMA3_SOURCE:
case GREG_DMA0_DEST: case GREG_DMA1_DEST: case GREG_DMA2_DEST: case GREG_DMA3_DEST:
case GREG_DMA0_NEXT: case GREG_DMA1_NEXT: case GREG_DMA2_NEXT: case GREG_DMA3_NEXT:
case GREG_INT_MASK:
if (LOG_GALILEO)
logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
break;
default:
logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
break;
}
}
/*************************************
*
* Galileo timers & interrupts
*
*************************************/
void gt64xxx_device::update_irqs()
{
int state = CLEAR_LINE;
/* if any unmasked interrupts are live, we generate */
if (m_reg[GREG_INT_STATE] & m_reg[GREG_INT_MASK])
state = ASSERT_LINE;
if (m_irq_num != -1)
m_cpu->set_input_line(m_irq_num, state);
if (LOG_GALILEO)
logerror("Galileo IRQ %s\n", (state == ASSERT_LINE) ? "asserted" : "cleared");
}
TIMER_CALLBACK_MEMBER(gt64xxx_device::timer_callback)
{
int which = param;
galileo_timer *timer = &m_timer[which];
if (LOG_TIMERS)
logerror("timer %d fired\n", which);
/* copy the start value from the registers */
timer->count = m_reg[GREG_TIMER0_COUNT + which];
if (which != 0)
timer->count &= 0xffffff;
/* if we're a timer, adjust the timer to fire again */
if (m_reg[GREG_TIMER_CONTROL] & (2 << (2 * which)))
timer->timer->adjust(TIMER_PERIOD * timer->count, which);
else
timer->active = timer->count = 0;
/* trigger the interrupt */
m_reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which);
update_irqs();
}
/*************************************
*
* Galileo DMA handler
*
*************************************/
int gt64xxx_device::dma_fetch_next(address_space &space, int which)
{
offs_t address = 0;
UINT32 data;
/* no-op for unchained mode */
if (!(m_reg[GREG_DMA0_CONTROL + which] & 0x200))
address = m_reg[GREG_DMA0_NEXT + which];
/* if we hit the end address, signal an interrupt */
if (address == 0)
{
if (m_reg[GREG_DMA0_CONTROL + which] & 0x400)
{
m_reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which);
update_irqs();
}
m_reg[GREG_DMA0_CONTROL + which] &= ~0x5000;
return 0;
}
/* fetch the byte count */
data = space.read_dword(address); address += 4;
m_reg[GREG_DMA0_COUNT + which] = data;
/* fetch the source address */
data = space.read_dword(address); address += 4;
m_reg[GREG_DMA0_SOURCE + which] = data;
/* fetch the dest address */
data = space.read_dword(address); address += 4;
m_reg[GREG_DMA0_DEST + which] = data;
/* fetch the next record address */
data = space.read_dword(address); address += 4;
m_reg[GREG_DMA0_NEXT + which] = data;
return 1;
}
void gt64xxx_device::perform_dma(address_space &space, int which)
{
do
{
offs_t srcaddr = m_reg[GREG_DMA0_SOURCE + which];
offs_t dstaddr = m_reg[GREG_DMA0_DEST + which];
UINT32 bytesleft = m_reg[GREG_DMA0_COUNT + which] & 0xffff;
int srcinc, dstinc;
m_dma_active = which;
m_reg[GREG_DMA0_CONTROL + which] |= 0x5000;
/* determine src/dst inc */
switch ((m_reg[GREG_DMA0_CONTROL + which] >> 2) & 3)
{
default:
case 0: srcinc = 1; break;
case 1: srcinc = -1; break;
case 2: srcinc = 0; break;
}
switch ((m_reg[GREG_DMA0_CONTROL + which] >> 4) & 3)
{
default:
case 0: dstinc = 1; break;
case 1: dstinc = -1; break;
case 2: dstinc = 0; break;
}
if (LOG_DMA)
logerror("Performing DMA%d: src=%08X dst=%08X bytes=%04X sinc=%d dinc=%d\n", which, srcaddr, dstaddr, bytesleft, srcinc, dstinc);
/* standard transfer */
while (bytesleft > 0)
{
space.write_byte(dstaddr, space.read_byte(srcaddr));
srcaddr += srcinc;
dstaddr += dstinc;
bytesleft--;
}
/* not verified, but seems logical these should be updated byte the end */
m_reg[GREG_DMA0_SOURCE + which] = srcaddr;
m_reg[GREG_DMA0_DEST + which] = dstaddr;
m_reg[GREG_DMA0_COUNT + which] = (m_reg[GREG_DMA0_COUNT + which] & ~0xffff) | bytesleft;
m_dma_active = -1;
/* if we did not hit zero, punt and return later */
if (bytesleft != 0)
return;
/* interrupt? */
if (!(m_reg[GREG_DMA0_CONTROL + which] & 0x400))
{
m_reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which);
update_irqs();
}
} while (dma_fetch_next(space, which));
m_reg[GREG_DMA0_CONTROL + which] &= ~0x5000;
}

View File

@ -0,0 +1,259 @@
// license:BSD-3-Clause
// copyright-holders: Aaron Giles, Ted Green
// Galileo GT-64xxx System Controller
// Skeleton code based off seattle machine driver.
// TODO:
// Testing
// Need PCI to be able to have a target delay a dma transfer
// Add PCI target maps
// Add PCI Func 1 calls
// Configurable byte swapping on cpu and pci busses.
#ifndef GT64XXX_H
#define GT64XXX_H
#include "pci.h"
#include "cpu/mips/mips3.h"
// Supports R4600/4650/4700/R5000 CPUs
#define MCFG_GT64010_ADD(_tag, _cpu_tag, _clock) \
MCFG_PCI_HOST_ADD(_tag, GT64XXX, 0x014611ab, 0x03, 0x00000000) \
downcast<gt64xxx_device *>(device)->set_cpu_tag(_cpu_tag); \
downcast<gt64xxx_device *>(device)->set_clock(_clock);
// Supports the following 32-bit bus CPUs:
// IDT RC4640 and RC4650 (in 32-bit mode)
// QED RM523X
// NEC/Toshiba VR4300
#define MCFG_GT64111_ADD(_tag, _cpu_tag, _clock) \
MCFG_PCI_DEVICE_ADD(_tag, GT64XXX, 0x414611ab, 0x10, 0x058000, 0x00000000) \
downcast<gt64xxx_device *>(device)->set_cpu_tag(_cpu_tag); \
downcast<gt64xxx_device *>(device)->set_clock(_clock);
#define MCFG_GT64XXX_SET_BE_CPU(_be) \
downcast<gt64xxx_device *>(device)->set_be(_be);
#define MCFG_GT64XXX__IRQ_ADD(_irq_num) \
downcast<gt64xxx_device *>(device)->set_irq_info(_irq_num);
/*************************************
*
* Galileo constants
*
*************************************/
//#define SYSTEM_CLOCK 50000000
#define TIMER_PERIOD attotime::from_hz(m_clock)
/* Galileo registers - 0x000-0x3ff */
#define GREG_CPU_CONFIG (0x000/4)
#define GREG_RAS_1_0_LO (0x008/4)
#define GREG_RAS_1_0_HI (0x010/4)
#define GREG_RAS_3_2_LO (0x018/4)
#define GREG_RAS_3_2_HI (0x020/4)
#define GREG_CS_2_0_LO (0x028/4)
#define GREG_CS_2_0_HI (0x030/4)
#define GREG_CS_3_BOOT_LO (0x038/4)
#define GREG_CS_3_BOOT_HI (0x040/4)
#define GREG_PCI_IO_LO (0x048/4)
#define GREG_PCI_IO_HI (0x050/4)
#define GREG_PCI_MEM0_LO (0x058/4)
#define GREG_PCI_MEM0_HI (0x060/4)
#define GREG_INTERNAL_SPACE (0x068/4)
#define GREG_BUSERR_LO (0x070/4)
#define GREG_BUSERR_HI (0x078/4)
// GT-64111 only
#define GREG_PCI_MEM1_LO (0x080/4)
#define GREG_PCI_MEM1_HI (0x088/4)
/* Galileo registers - 0x400-0x7ff */
#define GREG_RAS0_LO (0x400/4)
#define GREG_RAS0_HI (0x404/4)
#define GREG_RAS1_LO (0x408/4)
#define GREG_RAS1_HI (0x40c/4)
#define GREG_RAS2_LO (0x410/4)
#define GREG_RAS2_HI (0x414/4)
#define GREG_RAS3_LO (0x418/4)
#define GREG_RAS3_HI (0x41c/4)
#define GREG_CS0_LO (0x420/4)
#define GREG_CS0_HI (0x424/4)
#define GREG_CS1_LO (0x428/4)
#define GREG_CS1_HI (0x42c/4)
#define GREG_CS2_LO (0x430/4)
#define GREG_CS2_HI (0x434/4)
#define GREG_CS3_LO (0x438/4)
#define GREG_CS3_HI (0x43c/4)
#define GREG_CSBOOT_LO (0x440/4)
#define GREG_CSBOOT_HI (0x444/4)
#define GREG_DRAM_CONFIG (0x448/4)
#define GREG_DRAM_BANK0 (0x44c/4)
#define GREG_DRAM_BANK1 (0x450/4)
#define GREG_DRAM_BANK2 (0x454/4)
#define GREG_DRAM_BANK3 (0x458/4)
#define GREG_DEVICE_BANK0 (0x45c/4)
#define GREG_DEVICE_BANK1 (0x460/4)
#define GREG_DEVICE_BANK2 (0x464/4)
#define GREG_DEVICE_BANK3 (0x468/4)
#define GREG_DEVICE_BOOT (0x46c/4)
#define GREG_ADDRESS_ERROR (0x470/4)
/* Galileo registers - 0x800-0xbff */
#define GREG_DMA0_COUNT (0x800/4)
#define GREG_DMA1_COUNT (0x804/4)
#define GREG_DMA2_COUNT (0x808/4)
#define GREG_DMA3_COUNT (0x80c/4)
#define GREG_DMA0_SOURCE (0x810/4)
#define GREG_DMA1_SOURCE (0x814/4)
#define GREG_DMA2_SOURCE (0x818/4)
#define GREG_DMA3_SOURCE (0x81c/4)
#define GREG_DMA0_DEST (0x820/4)
#define GREG_DMA1_DEST (0x824/4)
#define GREG_DMA2_DEST (0x828/4)
#define GREG_DMA3_DEST (0x82c/4)
#define GREG_DMA0_NEXT (0x830/4)
#define GREG_DMA1_NEXT (0x834/4)
#define GREG_DMA2_NEXT (0x838/4)
#define GREG_DMA3_NEXT (0x83c/4)
#define GREG_DMA0_CONTROL (0x840/4)
#define GREG_DMA1_CONTROL (0x844/4)
#define GREG_DMA2_CONTROL (0x848/4)
#define GREG_DMA3_CONTROL (0x84c/4)
#define GREG_TIMER0_COUNT (0x850/4)
#define GREG_TIMER1_COUNT (0x854/4)
#define GREG_TIMER2_COUNT (0x858/4)
#define GREG_TIMER3_COUNT (0x85c/4)
#define GREG_DMA_ARBITER (0x860/4)
#define GREG_TIMER_CONTROL (0x864/4)
/* Galileo registers - 0xc00-0xfff */
#define GREG_PCI_COMMAND (0xc00/4)
#define GREG_PCI_TIMEOUT (0xc04/4)
#define GREG_PCI_RAS_1_0 (0xc08/4)
#define GREG_PCI_RAS_3_2 (0xc0c/4)
#define GREG_PCI_CS_2_0 (0xc10/4)
#define GREG_PCI_CS_3_BOOT (0xc14/4)
#define GREG_INT_STATE (0xc18/4)
#define GREG_INT_MASK (0xc1c/4)
#define GREG_PCI_INT_MASK (0xc24/4)
#define GREG_CONFIG_ADDRESS (0xcf8/4)
#define GREG_CONFIG_DATA (0xcfc/4)
/* Galileo interrupts */
#define GINT_SUMMARY_SHIFT (0)
#define GINT_MEMOUT_SHIFT (1)
#define GINT_DMAOUT_SHIFT (2)
#define GINT_CPUOUT_SHIFT (3)
#define GINT_DMA0COMP_SHIFT (4)
#define GINT_DMA1COMP_SHIFT (5)
#define GINT_DMA2COMP_SHIFT (6)
#define GINT_DMA3COMP_SHIFT (7)
#define GINT_T0EXP_SHIFT (8)
#define GINT_T1EXP_SHIFT (9)
#define GINT_T2EXP_SHIFT (10)
#define GINT_T3EXP_SHIFT (11)
#define GINT_MASRDERR_SHIFT (12)
#define GINT_SLVWRERR_SHIFT (13)
#define GINT_MASWRERR_SHIFT (14)
#define GINT_SLVRDERR_SHIFT (15)
#define GINT_ADDRERR_SHIFT (16)
#define GINT_MEMERR_SHIFT (17)
#define GINT_MASABORT_SHIFT (18)
#define GINT_TARABORT_SHIFT (19)
#define GINT_RETRYCTR_SHIFT (20)
/*************************************
* Structures
*************************************/
struct galileo_timer
{
emu_timer * timer;
UINT32 count;
UINT8 active;
};
class gt64xxx_device : public pci_host_device {
public:
gt64xxx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual void reset_all_mappings() override;
virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space) override;
void set_cpu_tag(const char *tag) { cpu_tag = tag;}
void set_cpu_tag(const UINT32 clock) { m_clock = clock;}
void set_clock(const UINT32 clock) {m_clock = clock;}
void set_be(const int be) {m_be = be;}
void set_autoconfig(const int autoconfig) {m_autoconfig = autoconfig;}
void set_irq_info(const int irq_num) {m_irq_num = irq_num;}
virtual DECLARE_ADDRESS_MAP(config_map, 32) override;
// pci bus
DECLARE_READ32_MEMBER( pci_config_r);
DECLARE_WRITE32_MEMBER( pci_config_w);
// cpu bus
DECLARE_READ32_MEMBER (cpu_if_r);
DECLARE_WRITE32_MEMBER(cpu_if_w);
DECLARE_READ32_MEMBER (master_mem0_r);
DECLARE_WRITE32_MEMBER(master_mem0_w);
DECLARE_READ32_MEMBER (master_mem1_r);
DECLARE_WRITE32_MEMBER(master_mem1_w);
DECLARE_READ32_MEMBER (master_io_r);
DECLARE_WRITE32_MEMBER(master_io_w);
// devices
DECLARE_READ32_MEMBER (ras_1_0_r);
DECLARE_WRITE32_MEMBER(ras_1_0_w);
DECLARE_READ32_MEMBER (ras_3_2_r);
DECLARE_WRITE32_MEMBER(ras_3_2_w);
DECLARE_READ32_MEMBER (cs_2_0_r);
DECLARE_WRITE32_MEMBER(cs_2_0_w);
DECLARE_READ32_MEMBER (cs_boot_3_r);
DECLARE_WRITE32_MEMBER(cs_boot_3_w);
protected:
address_space *m_cpu_space;
virtual const address_space_config *memory_space_config(address_spacenum spacenum) const override;
virtual void device_start() override;
virtual void device_reset() override;
private:
mips3_device *m_cpu;
const char *cpu_tag;
UINT32 m_clock;
int m_be, m_autoconfig;
int m_irq_num;
address_space_config m_mem_config, m_io_config;
DECLARE_ADDRESS_MAP(cpu_map, 32);
void map_cpu_space();
/* raw register data */
UINT32 m_reg[0xd00/4];
/* timer info */
galileo_timer m_timer[4];
/* DMA info */
INT8 m_dma_active;
// Ram
std::vector<UINT32> m_ram[4];
TIMER_CALLBACK_MEMBER(timer_callback);
void update_irqs();
int dma_fetch_next(address_space &space, int which);
void perform_dma(address_space &space, int which);
};
extern const device_type GT64XXX;
#endif

View File

@ -316,7 +316,7 @@ WRITE8_MEMBER( ins8250_uart_device::ins8250_w )
bits 5 - 0, you could cause an interrupt if the appropriate IER bit
is set.
*/
m_regs.lsr = (m_regs.lsr & 0x40) | (data & ~0x40);
m_regs.lsr = (m_regs.lsr & 0x60) | (data & ~0x60);
tmp = 0;
tmp |= ( m_regs.lsr & 0x01 ) ? COM_INT_PENDING_RECEIVED_DATA_AVAILABLE : 0;

View File

@ -1913,7 +1913,8 @@ void h63484_device::video_registers_w(int offset)
READ16_MEMBER( h63484_device::status_r )
{
return m_sr;
// kothello is coded so that upper byte of this should be 0xff (tests with jc opcode). Maybe it's just unconnected?
return m_sr | 0xff00;
}
READ16_MEMBER( h63484_device::data_r )

View File

@ -15,7 +15,6 @@
#include "audit.h"
#include "info.h"
#include "unzip.h"
#include "un7z.h"
#include "validity.h"
#include "sound/samples.h"
#include "cliopts.h"
@ -266,7 +265,7 @@ int cli_frontend::execute(int argc, char **argv)
m_result = MAMERR_FATALERROR;
}
_7z_file::cache_clear();
util::archive_file::cache_clear();
global_free(manager);
return m_result;
@ -1000,7 +999,7 @@ void cli_frontend::verifyroms(const char *gamename)
}
// clear out any cached files
zip_file::cache_clear();
util::archive_file::cache_clear();
// return an error if none found
if (matched == 0)
@ -1092,7 +1091,7 @@ void cli_frontend::verifysamples(const char *gamename)
}
// clear out any cached files
zip_file::cache_clear();
util::archive_file::cache_clear();
// return an error if none found
if (matched == 0)
@ -1407,7 +1406,7 @@ void cli_frontend::verifysoftware(const char *gamename)
}
// clear out any cached files
zip_file::cache_clear();
util::archive_file::cache_clear();
// return an error if none found
if (matched == 0)
@ -1529,7 +1528,7 @@ void cli_frontend::verifysoftlist(const char *gamename)
}
// clear out any cached files
zip_file::cache_clear();
util::archive_file::cache_clear();
// return an error if none found
if (matched == 0)
@ -1758,28 +1757,32 @@ void media_identifier::identify(const char *filename)
}
// if that failed, and the filename ends with .zip, identify as a ZIP file
if (core_filename_ends_with(filename, ".7z"))
if (core_filename_ends_with(filename, ".7z") || core_filename_ends_with(filename, ".zip"))
{
// first attempt to examine it as a valid _7Z file
_7z_file::ptr _7z;
_7z_file::error _7zerr = _7z_file::open(filename, _7z);
if (_7zerr == _7z_file::error::NONE && _7z != nullptr)
util::archive_file::ptr archive;
util::archive_file::error err;
if (core_filename_ends_with(filename, ".7z"))
err = util::archive_file::open_7z(filename, archive);
else
err = util::archive_file::open_zip(filename, archive);
if ((err == util::archive_file::error::NONE) && archive)
{
std::vector<std::uint8_t> data;
// loop over entries in the .7z, skipping empty files and directories
for (int i = _7z->first_file(); i >= 0; i = _7z->next_file())
for (int i = archive->first_file(); i >= 0; i = archive->next_file())
{
const std::uint64_t length(_7z->current_uncompressed_length());
if ((length != 0) && (std::uint32_t(length) == length))
const std::uint64_t length(archive->current_uncompressed_length());
if (!archive->current_is_directory() && (length != 0) && (std::uint32_t(length) == length))
{
// decompress data into RAM and identify it
try
{
data.resize(std::size_t(length));
_7zerr = _7z->decompress(&data[0], std::uint32_t(length));
if (_7zerr == _7z_file::error::NONE)
identify_data(_7z->current_name().c_str(), &data[0], length);
err = archive->decompress(&data[0], std::uint32_t(length));
if (err == util::archive_file::error::NONE)
identify_data(archive->current_name().c_str(), &data[0], length);
}
catch (...)
{
@ -1791,31 +1794,8 @@ void media_identifier::identify(const char *filename)
}
// clear out any cached files
_7z.reset();
_7z_file::cache_clear();
}
else if (core_filename_ends_with(filename, ".zip"))
{
// first attempt to examine it as a valid ZIP file
zip_file::ptr zip = nullptr;
zip_file::error ziperr = zip_file::open(filename, zip);
if (ziperr == zip_file::error::NONE && zip != nullptr)
{
// loop over entries in the ZIP, skipping empty files and directories
for (const zip_file::file_header *entry = zip->first_file(); entry != nullptr; entry = zip->next_file())
if (entry->uncompressed_length != 0)
{
// decompress data into RAM and identify it
dynamic_buffer data(entry->uncompressed_length);
ziperr = zip->decompress(&data[0], entry->uncompressed_length);
if (ziperr == zip_file::error::NONE)
identify_data(entry->filename, &data[0], entry->uncompressed_length);
}
}
// clear out any cached files
zip.reset();
zip_file::cache_clear();
archive.reset();
util::archive_file::cache_clear();
}
// otherwise, identify as a raw file

View File

@ -1872,6 +1872,7 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
for (i = offset; i <= endoffset; i += 16)
{
output.clear();
output.rdbuf()->clear();
/* print the address */
util::stream_format(output, "%0*X: ", space->logaddrchars(), (UINT32)space->byte_to_address(i));
@ -2306,6 +2307,7 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
{
active_cheat++;
output.clear();
output.rdbuf()->clear();
stream_format(
output,
" <cheat desc=\"Possibility %d : %0*X (%0*X)\">\n"
@ -2516,6 +2518,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
offs_t tempaddr;
int numbytes = 0;
output.clear();
output.rdbuf()->clear();
/* print the address */
stream_format(output, "%0*X: ", space->logaddrchars(), (UINT32)space->byte_to_address(pcbyte));

View File

@ -240,6 +240,7 @@ void debug_view_breakpoints::view_update()
if (m_visible.y > 0)
{
linebuf.clear();
linebuf.rdbuf()->clear();
linebuf << "ID";
if (m_sortType == &cIndexAscending) linebuf.put('\\');
else if (m_sortType == &cIndexDescending) linebuf.put('/');
@ -282,6 +283,7 @@ void debug_view_breakpoints::view_update()
device_debug::breakpoint *const bp = m_buffer[bpi];
linebuf.clear();
linebuf.rdbuf()->clear();
util::stream_format(linebuf, "%2X", bp->index());
pad_ostream_to_length(linebuf, tableBreaks[0]);
linebuf.put(bp->enabled() ? 'X' : 'O');

View File

@ -266,6 +266,7 @@ void debug_view_watchpoints::view_update()
if (m_visible.y > 0)
{
linebuf.clear();
linebuf.rdbuf()->clear();
linebuf << "ID";
if (m_sortType == &cIndexAscending) linebuf.put('\\');
else if (m_sortType == &cIndexDescending) linebuf.put('/');
@ -317,6 +318,7 @@ void debug_view_watchpoints::view_update()
device_debug::watchpoint *const wp = m_buffer[wpi];
linebuf.clear();
linebuf.rdbuf()->clear();
util::stream_format(linebuf, "%2X", wp->index());
pad_ostream_to_length(linebuf, tableBreaks[0]);
linebuf.put(wp->enabled() ? 'X' : 'O');

View File

@ -158,7 +158,7 @@ void device_image_interface::device_compute_hash(hash_collection &hashes, const
image_error_t device_image_interface::set_image_filename(const char *filename)
{
m_image_name = filename;
zippath_parent(m_working_directory, filename);
util::zippath_parent(m_working_directory, filename);
m_basename.assign(m_image_name);
size_t loc1 = m_image_name.find_last_of('\\');
@ -319,7 +319,7 @@ bool device_image_interface::try_change_working_directory(const char *subdir)
/* did we successfully identify the directory? */
if (success)
zippath_combine(m_working_directory, m_working_directory.c_str(), subdir);
util::zippath_combine(m_working_directory, m_working_directory.c_str(), subdir);
return success;
}
@ -611,7 +611,7 @@ image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, cons
std::string revised_path;
/* attempt to read the file */
auto const filerr = zippath_fopen(path, open_flags, m_file, revised_path);
auto const filerr = util::zippath_fopen(path, open_flags, m_file, revised_path);
/* did the open succeed? */
switch(filerr)
@ -663,7 +663,7 @@ int device_image_interface::reopen_for_write(const char *path)
std::string revised_path;
/* attempt to open the file for writing*/
auto const filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path);
auto const filerr = util::zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path);
/* did the open succeed? */
switch(filerr)

View File

@ -56,6 +56,7 @@ enum
XTAL_2_4576MHz = 2457600, /* Atari ST MFP, NEC PC-98xx */
XTAL_2_5MHz = 2500000, /* Janken Man units */
XTAL_3MHz = 3000000, /* Probably only used to drive 68705 or similar MCUs on 80's Taito PCBs */
XTAL_3_072MHz = 3072000, /* INS 8520 input clock rate */
XTAL_3_12MHz = 3120000, /* SP0250 clock on Gottlieb games */
XTAL_3_5MHz = 3500000, /* Reported by Commodore 65 document, true xtal unchecked on PCB */
XTAL_3_52128MHz = 3521280, /* RCA COSMAC VIP */

View File

@ -10,7 +10,6 @@
#include "emu.h"
#include "unzip.h"
#include "un7z.h"
#include "fileio.h"
@ -146,8 +145,6 @@ emu_file::emu_file(UINT32 openflags)
m_openflags(openflags),
m_zipfile(nullptr),
m_ziplength(0),
m__7zfile(),
m__7zlength(0),
m_remove_on_close(false),
m_restrict_to_mediapath(false)
{
@ -164,8 +161,6 @@ emu_file::emu_file(const char *searchpath, UINT32 openflags)
m_openflags(openflags),
m_zipfile(nullptr),
m_ziplength(0),
m__7zfile(),
m__7zlength(0),
m_remove_on_close(false),
m_restrict_to_mediapath(false)
{
@ -228,12 +223,6 @@ hash_collection &emu_file::hashes(const char *types)
return m_hashes;
// if we have ZIP data, just hash that directly
if (!m__7zdata.empty())
{
m_hashes.compute(&m__7zdata[0], m__7zdata.size(), needed.c_str());
return m_hashes;
}
if (!m_zipdata.empty())
{
m_hashes.compute(&m_zipdata[0], m_zipdata.size(), needed.c_str());
@ -338,7 +327,7 @@ osd_file::error emu_file::open_next()
while (m_iterator.next(m_fullpath, m_filename.c_str()))
{
// attempt to open the file directly
filerr = util::core_file::open(m_fullpath.c_str(), m_openflags, m_file);
filerr = util::core_file::open(m_fullpath, m_openflags, m_file);
if (filerr == osd_file::error::NONE)
break;
@ -386,11 +375,9 @@ osd_file::error emu_file::open_ram(const void *data, UINT32 length)
void emu_file::close()
{
// close files and free memory
m__7zfile.reset();
m_zipfile.reset();
m_file.reset();
m__7zdata.clear();
m_zipdata.clear();
if (m_remove_on_close)
@ -423,10 +410,7 @@ osd_file::error emu_file::compress(int level)
bool emu_file::compressed_file_ready(void)
{
// load the ZIP file now if we haven't yet
if (m__7zfile != nullptr && load__7zped_file() != osd_file::error::NONE)
return true;
if (m_zipfile != nullptr && load_zipped_file() != osd_file::error::NONE)
if (m_zipfile && (load_zipped_file() != osd_file::error::NONE))
return true;
return false;
@ -493,9 +477,6 @@ bool emu_file::eof()
UINT64 emu_file::size()
{
// use the ZIP length if present
if (m__7zfile != nullptr)
return m__7zlength;
if (m_zipfile != nullptr)
return m_ziplength;
@ -676,44 +657,37 @@ osd_file::error emu_file::attempt_zipped()
m_fullpath = m_fullpath.substr(0, dirsep).append(".zip");
// attempt to open the ZIP file
zip_file::ptr zip;
zip_file::error ziperr = zip_file::open(m_fullpath, zip);
util::archive_file::ptr zip;
util::archive_file::error ziperr = util::archive_file::open_zip(m_fullpath, zip);
// chop the .zip back off the filename before continuing
m_fullpath = m_fullpath.substr(0, dirsep);
// if we failed to open this file, continue scanning
if (ziperr != zip_file::error::NONE)
if (ziperr != util::archive_file::error::NONE)
continue;
int header = -1;
// see if we can find a file with the right name and (if available) crc
const zip_file::file_header *header;
for (header = zip->first_file(); header != nullptr; header = zip->next_file())
if (zip_filename_match(*header, filename) && (!(m_openflags & OPEN_FLAG_HAS_CRC) || header->crc == m_crc))
break;
if (m_openflags & OPEN_FLAG_HAS_CRC) header = zip->search(m_crc, filename);
// if that failed, look for a file with the right crc, but the wrong filename
if (header == nullptr && (m_openflags & OPEN_FLAG_HAS_CRC))
for (header = zip->first_file(); header != nullptr; header = zip->next_file())
if (header->crc == m_crc && !zip_header_is_path(*header))
break;
if (header < 0 && (m_openflags & OPEN_FLAG_HAS_CRC)) header = zip->search(m_crc);
// if that failed, look for a file with the right name; reporting a bad checksum
// is more helpful and less confusing than reporting "rom not found"
if (header == nullptr)
for (header = zip->first_file(); header != nullptr; header = zip->next_file())
if (zip_filename_match(*header, filename))
break;
if (header < 0) header = zip->search(filename);
// if we got it, read the data
if (header != nullptr)
if (header >= 0)
{
m_zipfile = std::move(zip);
m_ziplength = header->uncompressed_length;
m_ziplength = m_zipfile->current_uncompressed_length();
// build a hash with just the CRC
m_hashes.reset();
m_hashes.add_crc(header->crc);
m_hashes.add_crc(m_zipfile->current_crc());
return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load_zipped_file();
}
@ -723,64 +697,6 @@ osd_file::error emu_file::attempt_zipped()
}
//-------------------------------------------------
// load_zipped_file - load a ZIPped file
//-------------------------------------------------
osd_file::error emu_file::load_zipped_file()
{
assert(m_file == nullptr);
assert(m_zipdata.empty());
assert(m_zipfile != nullptr);
// allocate some memory
m_zipdata.resize(m_ziplength);
// read the data into our buffer and return
zip_file::error ziperr = m_zipfile->decompress(&m_zipdata[0], m_zipdata.size());
if (ziperr != zip_file::error::NONE)
{
m_zipdata.clear();
return osd_file::error::FAILURE;
}
// convert to RAM file
osd_file::error filerr = util::core_file::open_ram(&m_zipdata[0], m_zipdata.size(), m_openflags, m_file);
if (filerr != osd_file::error::NONE)
{
m_zipdata.clear();
return osd_file::error::FAILURE;
}
// close out the ZIP file
m_zipfile.reset();
return osd_file::error::NONE;
}
//-------------------------------------------------
// zip_filename_match - compare zip filename
// to expected filename, ignoring any directory
//-------------------------------------------------
bool emu_file::zip_filename_match(const zip_file::file_header &header, const std::string &filename)
{
const char *zipfile = header.filename + header.filename_length - filename.length();
return (zipfile >= header.filename && core_stricmp(filename.c_str(),zipfile) == 0 && (zipfile == header.filename || zipfile[-1] == '/'));
}
//-------------------------------------------------
// zip_header_is_path - check whether filename
// in header is a path
//-------------------------------------------------
bool emu_file::zip_header_is_path(const zip_file::file_header &header)
{
const char *zipfile = header.filename + header.filename_length - 1;
return (zipfile >= header.filename && zipfile[0] == '/');
}
//-------------------------------------------------
// attempt__7zped - attempt to open a .7z file
//-------------------------------------------------
@ -810,14 +726,14 @@ osd_file::error emu_file::attempt__7zped()
m_fullpath = m_fullpath.substr(0, dirsep).append(".7z");
// attempt to open the _7Z file
_7z_file::ptr _7z;
_7z_file::error _7zerr = _7z_file::open(m_fullpath, _7z);
util::archive_file::ptr _7z;
util::archive_file::error _7zerr = util::archive_file::open_7z(m_fullpath, _7z);
// chop the ._7z back off the filename before continuing
m_fullpath = m_fullpath.substr(0, dirsep);
// if we failed to open this file, continue scanning
if (_7zerr != _7z_file::error::NONE)
if (_7zerr != util::archive_file::error::NONE)
continue;
int fileno = -1;
@ -826,21 +742,21 @@ osd_file::error emu_file::attempt__7zped()
if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z->search(m_crc, filename);
// if that failed, look for a file with the right crc, but the wrong filename
if ((fileno == -1) && (m_openflags & OPEN_FLAG_HAS_CRC)) fileno = _7z->search(m_crc);
if ((fileno < 0) && (m_openflags & OPEN_FLAG_HAS_CRC)) fileno = _7z->search(m_crc);
// if that failed, look for a file with the right name; reporting a bad checksum
// is more helpful and less confusing than reporting "rom not found"
if (fileno == -1) fileno = _7z->search(filename);
if (fileno < 0) fileno = _7z->search(filename);
if (fileno != -1)
if (fileno >= 0)
{
m__7zfile = std::move(_7z);
m__7zlength = m__7zfile->current_uncompressed_length();
m_zipfile = std::move(_7z);
m_ziplength = m_zipfile->current_uncompressed_length();
// build a hash with just the CRC
m_hashes.reset();
m_hashes.add_crc(m__7zfile->current_crc());
return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load__7zped_file();
m_hashes.add_crc(m_zipfile->current_crc());
return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load_zipped_file();
}
// close up the _7Z file and try the next level
@ -850,35 +766,35 @@ osd_file::error emu_file::attempt__7zped()
//-------------------------------------------------
// load__7zped_file - load a _7Zped file
// load_zipped_file - load a ZIPped file
//-------------------------------------------------
osd_file::error emu_file::load__7zped_file()
osd_file::error emu_file::load_zipped_file()
{
assert(m_file == nullptr);
assert(m__7zdata.empty());
assert(m__7zfile);
assert(m_zipdata.empty());
assert(m_zipfile);
// allocate some memory
m__7zdata.resize(m__7zlength);
m_zipdata.resize(m_ziplength);
// read the data into our buffer and return
_7z_file::error _7zerr = m__7zfile->decompress(&m__7zdata[0], m__7zdata.size());
if (_7zerr != _7z_file::error::NONE)
auto const ziperr = m_zipfile->decompress(&m_zipdata[0], m_zipdata.size());
if (ziperr != util::archive_file::error::NONE)
{
m__7zdata.clear();
m_zipdata.clear();
return osd_file::error::FAILURE;
}
// convert to RAM file
osd_file::error filerr = util::core_file::open_ram(&m__7zdata[0], m__7zdata.size(), m_openflags, m_file);
osd_file::error filerr = util::core_file::open_ram(&m_zipdata[0], m_zipdata.size(), m_openflags, m_file);
if (filerr != osd_file::error::NONE)
{
m__7zdata.clear();
m_zipdata.clear();
return osd_file::error::FAILURE;
}
// close out the _7Z file
m__7zfile.reset();
// close out the ZIP file
m_zipfile.reset();
return osd_file::error::NONE;
}

View File

@ -15,7 +15,6 @@
#include "corefile.h"
#include "hash.h"
#include "unzip.h"
// some systems use macros for getc/putc rather than functions
#ifdef getc
@ -27,7 +26,7 @@
//**************************************************************************
// forward declarations
class _7z_file;
namespace util { class archive_file; }
// ======================> path_iterator
@ -146,12 +145,8 @@ private:
// internal helpers
osd_file::error attempt_zipped();
osd_file::error load_zipped_file();
bool zip_filename_match(const zip_file::file_header &header, const std::string &filename);
bool zip_header_is_path(const zip_file::file_header &header);
osd_file::error attempt__7zped();
osd_file::error load__7zped_file();
osd_file::error load_zipped_file();
// internal state
std::string m_filename; // original filename provided
@ -163,14 +158,10 @@ private:
UINT32 m_openflags; // flags we used for the open
hash_collection m_hashes; // collection of hashes
zip_file::ptr m_zipfile; // ZIP file pointer
std::unique_ptr<util::archive_file> m_zipfile; // ZIP file pointer
dynamic_buffer m_zipdata; // ZIP file data
UINT64 m_ziplength; // ZIP file length
std::unique_ptr<_7z_file> m__7zfile; // 7Z file pointer
dynamic_buffer m__7zdata; // 7Z file data
UINT64 m__7zlength; // 7Z file length
bool m_remove_on_close; // flag: remove the file when closing
bool m_restrict_to_mediapath; // flag: restrict to paths inside the media-path
};

View File

@ -440,7 +440,7 @@ int running_machine::run(bool firstrun)
// call all exit callbacks registered
call_notifiers(MACHINE_NOTIFY_EXIT);
zip_file::cache_clear();
util::archive_file::cache_clear();
// close the logfile
m_logfile.reset();

View File

@ -1768,29 +1768,39 @@ void render_target::add_container_primitives(render_primitive_list &list, const
// set the palette
prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
// determine UV coordinates and apply clipping
// determine UV coordinates
prim->texcoords = oriented_texcoords[finalorient];
// apply clipping
clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
// apply the final orientation from the quad flags and then build up the final flags
prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) |
PRIMFLAG_TEXORIENT(finalorient) |
PRIMFLAG_TEXFORMAT(curitem->texture()->format());
if (blendmode != -1)
prim->flags |= PRIMFLAG_BLENDMODE(blendmode);
else
prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK))
| PRIMFLAG_TEXORIENT(finalorient)
| PRIMFLAG_TEXFORMAT(curitem->texture()->format());
prim->flags |= blendmode != -1
? PRIMFLAG_BLENDMODE(blendmode)
: PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
}
else
{
if (curitem->flags() & PRIMFLAG_VECTORBUF_MASK)
{
// determine UV coordinates
prim->texcoords = oriented_texcoords[0];
}
// adjust the color for brightness/contrast/gamma
prim->color.r = container.apply_brightness_contrast_gamma_fp(prim->color.r);
prim->color.g = container.apply_brightness_contrast_gamma_fp(prim->color.g);
prim->color.b = container.apply_brightness_contrast_gamma_fp(prim->color.b);
// no texture -- set the basic flags
// no texture
prim->texture.base = nullptr;
prim->flags = (curitem->flags() &~ PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
// set the basic flags
prim->flags = (curitem->flags() & ~PRIMFLAG_BLENDMODE_MASK)
| PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
// apply clipping
clipped = render_clip_quad(&prim->bounds, &cliprect, nullptr);

View File

@ -336,6 +336,8 @@ public:
// getters
render_primitive *next() const { return m_next; }
bool packable(const INT32 pack_size) const { return (flags & PRIMFLAG_PACKABLE) && texture.base != nullptr && texture.width <= pack_size && texture.height <= pack_size; }
float get_quad_width() const { return bounds.x1 - bounds.x0; }
float get_quad_height() const { return bounds.y1 - bounds.y0; }
// reset to prepare for re-use
void reset();

Some files were not shown because too many files have changed in this diff Show More