@@ -70,8 +70,6 @@ public bool IsSelected
7070 private bool newSprite = true ;
7171 private Sprite _SpriteData = null ;
7272
73- private byte [ ] ZX2NextColors = new byte [ ] { 0 , 2 , 160 , 162 , 20 , 22 , 180 , 227 , 0 , 3 , 224 , 226 , 28 , 31 , 252 , 255 } ;
74-
7573 #endregion
7674
7775
@@ -292,185 +290,75 @@ private void CmbMode_SelectionChanged(object? sender, SelectionChangedEventArgs
292290
293291 private void ChangeMode ( GraphicsModes oldMode , GraphicsModes newMode )
294292 {
295- // TODO: Improve conversion...
296293 if ( oldMode == newMode )
297294 {
298295 return ;
299296 }
300297 if ( oldMode == GraphicsModes . Monochrome )
301298 {
302- switch ( newMode )
299+ foreach ( var frame in SpriteData . Patterns )
303300 {
304- case GraphicsModes . ZXSpectrum :
301+ if ( frame . Attributes == null )
302+ {
303+ int cW = SpriteData . Width / 8 ;
304+ int cH = SpriteData . Height / 8 ;
305+ frame . Attributes = new AttributeColor [ cW * cH ] ;
306+ }
307+
308+ for ( int n = 0 ; n < frame . Attributes . Length ; n ++ )
309+ {
310+ frame . Attributes [ n ] = new AttributeColor ( )
305311 {
306- foreach ( var frame in SpriteData . Patterns )
307- {
308- if ( frame . Attributes == null )
309- {
310- int cW = SpriteData . Width / 8 ;
311- int cH = SpriteData . Height / 8 ;
312- frame . Attributes = new AttributeColor [ cW * cH ] ;
313- for ( int n = 0 ; n < frame . Attributes . Length ; n ++ )
314- {
315- frame . Attributes [ n ] = new AttributeColor ( )
316- {
317- Ink = 0 ,
318- Paper = 7
319- } ;
320- }
321- }
322- /*
323- for (int n = 0; n < frame.RawData.Length; n++)
324- {
325- var o = frame.RawData[n];
326- if (o == 0)
327- {
328- frame.RawData[n] = 1;
329- }
330- else
331- {
332- frame.RawData[n] = 0;
333- }
334- }
335- */
336- }
312+ Ink = 0 ,
313+ Paper = 7
314+ } ;
315+ }
316+
317+ for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
318+ {
319+ var o = frame . RawData [ n ] ;
320+ if ( o == 0 )
321+ {
322+ frame . RawData [ n ] = 0 ;
337323 }
338- break ;
339- case GraphicsModes . Next :
324+ else
340325 {
341- foreach ( var frame in SpriteData . Patterns )
342- {
343- for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
344- {
345- var o = frame . RawData [ n ] ;
346- if ( o == 0 )
347- {
348- frame . RawData [ n ] = 227 ;
349- }
350- else
351- {
352- frame . RawData [ n ] = 0 ;
353- }
354- }
355- }
326+ frame . RawData [ n ] = 7 ;
356327 }
357- break ;
328+ }
329+
358330 }
359331 }
360- else if ( oldMode == GraphicsModes . ZXSpectrum )
332+ else
361333 {
362- switch ( newMode )
334+ foreach ( var frame in SpriteData . Patterns )
363335 {
364- case GraphicsModes . Monochrome :
365- {
366- foreach ( var frame in SpriteData . Patterns )
367- {
368- if ( frame . Attributes == null )
369- {
370- int cW = SpriteData . Width / 8 ;
371- int cH = SpriteData . Height / 8 ;
372- frame . Attributes = new AttributeColor [ cW * cH ] ;
373- for ( int n = 0 ; n < frame . Attributes . Length ; n ++ )
374- {
375- frame . Attributes [ n ] = new AttributeColor ( )
376- {
377- Ink = 0 ,
378- Paper = 7
379- } ;
380- }
381- }
382- for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
383- {
384- var o = frame . RawData [ n ] ;
385- if ( o == 0 )
386- {
387- frame . RawData [ n ] = 1 ;
388- }
389- else
390- {
391- frame . RawData [ n ] = 0 ;
392- }
393- }
394- }
395- }
396- break ;
397- case GraphicsModes . Next :
336+ if ( frame . Attributes == null )
337+ {
338+ int cW = SpriteData . Width / 8 ;
339+ int cH = SpriteData . Height / 8 ;
340+ frame . Attributes = new AttributeColor [ cW * cH ] ;
341+ }
342+ for ( int n = 0 ; n < frame . Attributes . Length ; n ++ )
398343 {
399- foreach ( var frame in SpriteData . Patterns )
344+ frame . Attributes [ n ] = new AttributeColor ( )
400345 {
401- for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
402- {
403- var o = frame . RawData [ n ] ;
404- if ( o == 0 )
405- {
406- frame . RawData [ n ] = 227 ;
407- }
408- else
409- {
410- frame . RawData [ n ] = 0 ;
411- }
412- }
413- }
346+ Ink = 0 ,
347+ Paper = 7
348+ } ;
414349 }
415- break ;
416- }
417- }
418- else if ( oldMode == GraphicsModes . Next )
419- {
420- switch ( newMode )
421- {
422- case GraphicsModes . Monochrome :
350+ for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
351+ {
352+ var o = frame . RawData [ n ] ;
353+ if ( o == 0 )
423354 {
424- foreach ( var frame in SpriteData . Patterns )
425- {
426- for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
427- {
428- var o = frame . RawData [ n ] ;
429- if ( o == 0 )
430- {
431- frame . RawData [ n ] = 1 ;
432- }
433- else
434- {
435- frame . RawData [ n ] = 0 ;
436- }
437- }
438- }
355+ frame . RawData [ n ] = 0 ;
439356 }
440- break ;
441- case GraphicsModes . ZXSpectrum :
357+ else
442358 {
443- foreach ( var frame in SpriteData . Patterns )
444- {
445- if ( frame . Attributes == null )
446- {
447- int cW = SpriteData . Width / 8 ;
448- int cH = SpriteData . Height / 8 ;
449- frame . Attributes = new AttributeColor [ cW * cH ] ;
450- for ( int n = 0 ; n < frame . Attributes . Length ; n ++ )
451- {
452- frame . Attributes [ n ] = new AttributeColor ( )
453- {
454- Ink = 0 ,
455- Paper = 7
456- } ;
457- }
458- }
459- for ( int n = 0 ; n < frame . RawData . Length ; n ++ )
460- {
461- var o = frame . RawData [ n ] ;
462- if ( o == 0 )
463- {
464- frame . RawData [ n ] = 0 ;
465- }
466- else
467- {
468- frame . RawData [ n ] = 1 ;
469- }
470- }
471- }
359+ frame . RawData [ n ] = 1 ;
472360 }
473- break ;
361+ }
474362 }
475363 }
476364 }
0 commit comments