Skip to content

Commit 8d9d1af

Browse files
committed
pwm: Send legacy frames to colorizer but never render them.
1 parent c6ad54f commit 8d9d1af

File tree

19 files changed

+67
-35
lines changed

19 files changed

+67
-35
lines changed

LibDmd.Test/Stubs/SourceGray2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SourceGray2 : IGray2Source, ITestSource<DmdFrame>
1515

1616
private readonly Subject<DmdFrame> _frames = new Subject<DmdFrame>();
1717

18-
public IObservable<DmdFrame> GetGray2Frames(bool dedupe) => _frames;
18+
public IObservable<DmdFrame> GetGray2Frames(bool dedupe, bool skipIdentificationFrames) => _frames;
1919

2020
public void AddFrame(DmdFrame frame)
2121
{

LibDmd.Test/Stubs/SourceGray4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SourceGray4 : IGray4Source, ITestSource<DmdFrame>
1515

1616
private readonly Subject<DmdFrame> _frames = new Subject<DmdFrame>();
1717

18-
public IObservable<DmdFrame> GetGray4Frames(bool dedupe) => _frames;
18+
public IObservable<DmdFrame> GetGray4Frames(bool dedupe, bool skipIdentificationFrames) => _frames;
1919

2020
public void AddFrame(DmdFrame frame)
2121
{

LibDmd/DmdDevice/DmdDevice.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,21 @@ public void RenderGray4(DmdFrame frame)
298298
/// Gray8 frames exist because PinMAME does some clever PWM simulation on some games which ends up in 8-bit shadings.
299299
/// </remarks>
300300
/// <param name="frame">New gray8 frame</param>
301-
public void RenderGray8(DmdFrame frame)
301+
public void RenderGray8(DmdFrame frame, DmdFrame identifyFrame)
302302
{
303303
AnalyticsSetDmd();
304304
if (!_isOpen) {
305305
Init();
306306
}
307307
_passthroughGray8Source.NextFrame(frame);
308+
switch (identifyFrame.BitLength) {
309+
case 2:
310+
_passthroughGray2Source.NextFrame(identifyFrame);
311+
break;
312+
case 4:
313+
_passthroughGray4Source.NextFrame(identifyFrame);
314+
break;
315+
}
308316
}
309317

310318
/// <summary>

LibDmd/DmdDevice/IDmdDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IDmdDevice
1414
void LoadPalette(uint palIndex);
1515
void SetPalette(Color[] colors);
1616
void RenderRgb24(DmdFrame frame);
17-
void RenderGray8(DmdFrame frame);
17+
void RenderGray8(DmdFrame frame, DmdFrame identifyFrame = null);
1818
void RenderGray4(DmdFrame frame);
1919
void RenderGray2(DmdFrame frame);
2020
void RenderAlphaNumeric(NumericalLayout numericalLayout, ushort[] readUInt16Array, ushort[] ushorts);

LibDmd/Frame/DmdFrame.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public class DmdFrame : BaseFrame, ICloneable, IEqualityComparer<DmdFrame>
2828
/// </summary>
2929
public byte[] Data { get; protected set; }
3030

31+
/// <summary>
32+
/// These frames are used for colorization and should never be rendered (if they exist, that means
33+
/// there's a gray-8 frame to be rendered).
34+
/// </summary>
35+
public bool IsIdentifyFrame { get; protected set; }
36+
3137
/// <summary>
3238
/// The bit length of each pixel.
3339
/// </summary>
@@ -132,6 +138,7 @@ public DmdFrame Update(DmdFrame frame)
132138
Dimensions = frame.Dimensions;
133139
Data = frame.Data;
134140
BitLength = frame.BitLength;
141+
IsIdentifyFrame = false;
135142

136143
#if DEBUG
137144
AssertData();
@@ -143,18 +150,20 @@ public DmdFrame Update(byte[] data, int bitLength)
143150
{
144151
Data = data;
145152
BitLength = bitLength;
153+
IsIdentifyFrame = false;
146154

147155
#if DEBUG
148156
AssertData();
149157
#endif
150158
return this;
151159
}
152160

153-
public DmdFrame Update(Dimensions dim, byte[] data, int bitLength)
161+
public DmdFrame Update(Dimensions dim, byte[] data, int bitLength, bool isIdentifyFrame = false)
154162
{
155163
Dimensions = dim;
156164
Data = data;
157165
BitLength = bitLength;
166+
IsIdentifyFrame = isIdentifyFrame;
158167

159168
#if DEBUG
160169
AssertData();
@@ -166,6 +175,7 @@ public DmdFrame Update(Dimensions dim, byte[] data)
166175
{
167176
Dimensions = dim;
168177
Data = data;
178+
IsIdentifyFrame = false;
169179

170180
#if DEBUG
171181
AssertData();

LibDmd/Input/FileSystem/DumpSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public DumpSource(string filename)
3636
}
3737
}
3838

39-
public IObservable<DmdFrame> GetGray2Frames(bool dedupe)
39+
public IObservable<DmdFrame> GetGray2Frames(bool dedupe, bool skipIdentificationFrames)
4040
{
4141
const Int32 bufferSize = 128;
4242
_gameName.OnNext(Path.GetFileNameWithoutExtension(_filename).TrimEnd('-'));

LibDmd/Input/FileSystem/ImageSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ImageSourceGray2 : ImageSource, IGray2Source
1313
{
1414
readonly DmdFrame _dmdFrame = new DmdFrame();
1515

16-
public IObservable<DmdFrame> GetGray2Frames(bool dedupe) => _frames;
16+
public IObservable<DmdFrame> GetGray2Frames(bool dedupe, bool skipIdentificationFrames) => _frames;
1717

1818
private readonly BehaviorSubject<DmdFrame> _frames;
1919

@@ -27,7 +27,7 @@ public class ImageSourceGray4 : ImageSource, IGray4Source
2727
{
2828
DmdFrame _dmdFrame = new DmdFrame();
2929

30-
public IObservable<DmdFrame> GetGray4Frames(bool dedupe) => _frames;
30+
public IObservable<DmdFrame> GetGray4Frames(bool dedupe, bool skipIdentificationFrames) => _frames;
3131

3232
private readonly BehaviorSubject<DmdFrame> _frames;
3333

LibDmd/Input/FileSystem/PassthroughSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public PassthroughSource(string name)
3030
Name = name;
3131
}
3232

33-
public IObservable<DmdFrame> GetGray2Frames(bool dedupe)
33+
public IObservable<DmdFrame> GetGray2Frames(bool dedupe, bool skipIdentificationFrames)
3434
{
3535
return FramesGray2;
3636
}
3737

38-
public IObservable<DmdFrame> GetGray4Frames(bool dedupe)
38+
public IObservable<DmdFrame> GetGray4Frames(bool dedupe, bool skipIdentificationFrames)
3939
{
4040
return FramesGray4;
4141
}

LibDmd/Input/FutureDmd/FutureDmdSink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public FutureDmdSink(double framesPerSecond)
4848
Thread.Sleep(250);
4949
}
5050

51-
public IObservable<DmdFrame> GetGray4Frames(bool dedupe)
51+
public IObservable<DmdFrame> GetGray4Frames(bool dedupe, bool skipIdentificationFrames)
5252
{
5353
return _framesGray4;
5454
}

LibDmd/Input/IGray2Source.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public interface IGray2Source : ISource
1616
/// between 0 and 3 for every pixel.
1717
/// </summary>
1818
/// <param name="dedupe"></param>
19+
/// <param name="skipIdentificationFrames"></param>
1920
/// <remarks>When disposed, frame production must stop.</remarks>
20-
IObservable<DmdFrame> GetGray2Frames(bool dedupe);
21+
IObservable<DmdFrame> GetGray2Frames(bool dedupe, bool skipIdentificationFrames);
2122
}
2223
}

0 commit comments

Comments
 (0)