@@ -210,11 +210,11 @@ public void ApplySharedState(in SimulationState.Snapshot snapshot)
210210
211211 private volatile bool _isRunning ;
212212 private int _numMechs ;
213- private Dictionary < int , byte [ ] > _frameBuffer = new ( ) ;
214- private Dictionary < int , Dictionary < byte , byte > > _dmdLevels = new ( ) ;
215-
213+ private Dictionary < int , byte [ ] > _frameBuffer = new ( ) ;
214+
216215 private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
217216 private static readonly Color Tint = new ( 1 , 0.18f , 0 ) ;
217+ private static readonly Color UnlitTint = new ( Tint . r * 0.18f , Tint . g * 0.18f , Tint . b * 0.18f , 1f ) ;
218218
219219 private readonly Queue < Action > _dispatchQueue = new ( ) ;
220220 private readonly List < Action > _pendingDispatchCallbacks = new ( ) ;
@@ -430,7 +430,6 @@ private void OnDestroy()
430430 _pinMame . IsKeyPressed -= IsKeyPressed ;
431431 }
432432 _frameBuffer . Clear ( ) ;
433- _dmdLevels . Clear ( ) ;
434433 lock ( _outputStateLock ) {
435434 _sharedCoilStates . Clear ( ) ;
436435 _sharedLampStates . Clear ( ) ;
@@ -861,11 +860,10 @@ private void OnDisplayRequested(int index, int displayCount, PinMameDisplayLayou
861860 if ( displayLayout . IsDmd ) {
862861 EnqueueMainThreadDispatch ( ( ) =>
863862 OnDisplaysRequested ? . Invoke ( this , new RequestedDisplays (
864- new DisplayConfig ( $ "{ DmdPrefix } { index } ", displayLayout . Width , displayLayout . Height ) ) ) ) ;
863+ new DisplayConfig ( $ "{ DmdPrefix } { index } ", displayLayout . Width , displayLayout . Height , false , Tint , UnlitTint ) ) ) ) ;
865864
866865 lock ( _displayStateLock ) {
867866 _frameBuffer [ index ] = new byte [ displayLayout . Width * displayLayout . Height ] ;
868- _dmdLevels [ index ] = displayLayout . Levels ;
869867 }
870868
871869 } else {
@@ -895,31 +893,14 @@ private void OnDisplayUpdated(int index, IntPtr framePtr, PinMameDisplayLayout d
895893 private void UpdateDmd ( int index , PinMameDisplayLayout displayLayout , IntPtr framePtr )
896894 {
897895 byte [ ] frameBuffer ;
898- Dictionary < byte , byte > levels ;
899896 lock ( _displayStateLock ) {
900897 if ( ! _frameBuffer . TryGetValue ( index , out frameBuffer ) ) {
901898 Logger . Warn ( $ "[PinMAME] Dropping DMD frame for unknown index { index } (layout: { displayLayout } ).") ;
902899 return ;
903900 }
904- if ( ! _dmdLevels . TryGetValue ( index , out levels ) || levels == null ) {
905- Logger . Warn ( $ "[PinMAME] Dropping DMD frame for index { index } because display levels are not initialized yet.") ;
906- return ;
907- }
908901 }
909902
910- unsafe {
911- var ptr = ( byte * ) framePtr ;
912- for ( var y = 0 ; y < displayLayout . Height ; y ++ ) {
913- for ( var x = 0 ; x < displayLayout . Width ; x ++ ) {
914- var pos = y * displayLayout . Width + x ;
915- if ( ! levels . ContainsKey ( ptr [ pos ] ) ) {
916- Logger . Error ( $ "Display { index } : Provided levels ({ BitConverter . ToString ( levels . Keys . ToArray ( ) ) } ) don't contain level { BitConverter . ToString ( new [ ] { ptr [ pos ] } ) } .") ;
917- levels [ ptr [ pos ] ] = 0x4 ;
918- }
919- frameBuffer [ pos ] = levels [ ptr [ pos ] ] ;
920- }
921- }
922- }
903+ Marshal . Copy ( framePtr , frameBuffer , 0 , frameBuffer . Length ) ;
923904
924905 EnqueueMainThreadDispatch ( ( ) => OnDisplayUpdateFrame ? . Invoke ( this ,
925906 new DisplayFrameData ( $ "{ DmdPrefix } { index } ", GetDisplayFrameFormat ( displayLayout ) , frameBuffer ) ) ) ;
@@ -942,11 +923,11 @@ private void UpdateSegDisp(int index, PinMameDisplayLayout displayLayout, IntPtr
942923 new DisplayFrameData ( $ "{ SegDispPrefix } { index } ", GetDisplayFrameFormat ( displayLayout ) , frameBuffer ) ) ) ;
943924 }
944925
945- public static DisplayFrameFormat GetDisplayFrameFormat ( PinMameDisplayLayout layout )
946- {
947- if ( layout . IsDmd ) {
948- return layout . Depth == 4 ? DisplayFrameFormat . Dmd4 : DisplayFrameFormat . Dmd2 ;
949- }
926+ public static DisplayFrameFormat GetDisplayFrameFormat ( PinMameDisplayLayout layout )
927+ {
928+ if ( layout . IsDmd ) {
929+ return DisplayFrameFormat . Dmd8 ;
930+ }
950931
951932 switch ( layout . Type ) {
952933 case PinMameDisplayType . Seg8 : // 7 segments and comma
0 commit comments