-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpriteBuilder.cs
816 lines (746 loc) · 47.5 KB
/
SpriteBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
namespace ExileWorldGenerator
{
/// <summary>
/// Immutable class for building a sprite to display
/// </summary>
internal class SpriteBuilder
{
private static readonly byte[] SpriteData = BuildSpriteSheet();
private static readonly byte[] SpriteWidthLookup = BuildSpriteWidthLookup();
private static readonly byte[] SpriteHeightLookup = BuildSpriteHeightLookup();
private static readonly Dictionary<byte, Rectangle> SpritePositions = BuildSpritePositions();
public static readonly byte[] BackgroundSpriteLookup = BuildBackgroundSpriteLookup();
public static readonly byte[] BackgroundYOffsetLookup = BuildBackgroundYOffsetLookup();
public static readonly bool[] FlipSpriteHorizontally = BuildFlipSpriteHorizontally();
public static readonly bool[] FlipSpriteVertically = BuildFlipSpriteVertically();
public static readonly byte[] ObjectSpriteLookup = BuildObjectSpriteLookups();
public static readonly byte[] ObjectPaletteLookup = BuildObjectPaletteLookups();
private static readonly Palette[] DoorPalettes = BuildDoorPalettes();
private static readonly Palette[] SuckerPalettes = BuildSuckerPalettes();
private static readonly Size SquareSize = new Size(16, 32);
private readonly Bitmap _sprite;
private SpriteBuilder(Bitmap sprite)
{
if (sprite == null)
throw new ArgumentNullException(nameof(sprite));
if (sprite.Size != SquareSize)
throw new ArgumentOutOfRangeException(nameof(sprite));
this._sprite = sprite;
}
/// <summary>
/// Returns the bitmap created by the sprite building process
/// </summary>
public Bitmap Result => this._sprite;
/// <summary>
/// Starts a new sprite building process
/// </summary>
/// <param name="waterLevelType">Specifies where the water level is within the sprite</param>
/// <returns>A SpriteBuilder object to which more changes can be made</returns>
public static SpriteBuilder Start(WaterLevelType waterLevelType)
{
Bitmap sprite = new Bitmap(SquareSize.Width, SquareSize.Height);
using (Graphics g = Graphics.FromImage(sprite))
{
using (SolidBrush blackBrush = new SolidBrush(Color.Black))
{
g.FillRectangle(blackBrush, 0, 0, SquareSize.Width, SquareSize.Height);
}
if (waterLevelType != WaterLevelType.AboveWater)
{
using SolidBrush darkBlueBrush = new SolidBrush(Color.FromArgb(0x80, Color.Blue));
var top = (waterLevelType == WaterLevelType.OnWaterLine) ? 3 : 0;
g.FillRectangle(darkBlueBrush, 0, top, SquareSize.Width, SquareSize.Height);
}
if (waterLevelType == WaterLevelType.OnWaterLine)
{
using SolidBrush lightBlueBrush = new SolidBrush(Color.FromArgb(0x80, Color.Cyan));
g.FillRectangle(lightBlueBrush, 0, 2, SquareSize.Width, 1);
}
}
return new SpriteBuilder(sprite);
}
/// <summary>
/// Adds a background sprite
/// </summary>
/// <param name="background">Specifies the background type in the bottom 6 bits</param>
/// <param name="orientation">Specifies the vertical flip and alignment in bit 6, and the horizontal flip and alignment in bit 7</param>
/// <param name="palette">Specifies the palette to use when drawing the sprite</param>
/// <returns>A SpriteBuilder object containing the added background sprite</returns>
[Pure]
public SpriteBuilder AddBackgroundSprite(byte background, byte orientation, Palette palette)
{
Debug.Assert((background & 0b1100_0000) == 0);
Debug.Assert((orientation & 0x3f) == 0);
bool flipHorizontallyAndRightAlign = (orientation & 0x80) != 0;
bool flipVerticallyAndBottomAlign = (orientation & 0x40) != 0;
byte spriteIndex = BackgroundSpriteLookup[background];
byte offsetAlongY = (byte) (BackgroundYOffsetLookup[background] & 0xf0);
var sourceRectangle = SpritePositions[spriteIndex];
bool isSourceFlippedHorizontally = FlipSpriteHorizontally[spriteIndex];
bool isSourceFlippedVertically = FlipSpriteVertically[spriteIndex];
Func<int, int> toX;
if (!flipHorizontallyAndRightAlign && !isSourceFlippedHorizontally)
{
toX = x => x;
}
else if (!flipHorizontallyAndRightAlign) // && isSourceFlippedHorizontally
{
int right = sourceRectangle.Width - 1;
toX = x => right - x;
}
else if (!isSourceFlippedHorizontally) // && flipHorizontallyAndRightAlign
{
int width = SquareSize.Width - 1;
toX = x => width - x;
}
else // if flipHorizontallyAndRightAlign && isSourceFlippedHorizontally
{
var left = SquareSize.Width - sourceRectangle.Width;
toX = x => left + x;
}
if (flipVerticallyAndBottomAlign)
{
offsetAlongY += SpriteHeightLookup[spriteIndex];
offsetAlongY |= 7;
offsetAlongY ^= 0xff;
}
offsetAlongY >>= 3;
Func<int, int> toY;
if (flipVerticallyAndBottomAlign ^ isSourceFlippedVertically)
{
int height = sourceRectangle.Height - 1;
toY = y => (height - y) + offsetAlongY;
}
else
{
toY = y => y + offsetAlongY;
}
var sprite = new Bitmap(this._sprite);
for (int y = 0; y < sourceRectangle.Height; y++)
{
for (int x = 0; x < sourceRectangle.Width; x++)
{
int paletteIndex = GetPixelColour(x + sourceRectangle.X, y + sourceRectangle.Y);
Color pixelColour = palette[paletteIndex];
if (paletteIndex == 0)
{
Debug.Assert(pixelColour == Color.Black);
continue;
}
int x2 = toX(x);
int y2 = toY(y);
sprite.SetPixel(x2, y2, pixelColour);
}
}
return new SpriteBuilder(sprite);
}
/// <summary>
/// Adds a sprite for a foreground object
/// </summary>
/// <param name="objectType">Specifies the type of object</param>
/// <param name="orientation">Specifies the vertical flip and alignment in bit 6, and the horizontal flip and alignment in bit 7</param>
/// <param name="objectData">Specifies any additional data needed to correctly render the sprite. This is dependent on the object type.</param>
/// <returns>A SpriteBuilder object containing the added foreground sprite</returns>
[Pure]
public SpriteBuilder AddObjectFromDataSprite(byte objectType, byte orientation, byte? objectData = null)
{
objectType = (byte) (objectType & 0x7f);
byte spriteIndex = ObjectSpriteLookup[objectType];
Palette palette;
if (objectType == 0xd)
{
if (objectData == null)
throw new InvalidOperationException("objectData is null");
palette = SuckerPalettes[objectData.Value & 0x7f];
}
else
{
var objectPalette = ObjectPaletteLookup[objectType];
palette = Palette.FromByte(objectPalette);
}
var sourceRectangle = SpritePositions[spriteIndex];
bool flipHorizontallyAndRightAlign = (orientation & 0x80) != 0;
bool flipVerticallyAndTopAlign = (orientation & 0x40) != 0;
bool isSourceFlippedHorizontally = FlipSpriteHorizontally[spriteIndex];
bool isSourceFlippedVertically = FlipSpriteVertically[spriteIndex];
Func<int, int> toX;
if (!flipHorizontallyAndRightAlign && !isSourceFlippedHorizontally)
{
toX = x => x;
}
else if (!flipHorizontallyAndRightAlign) // && isSourceFlippedHorizontally
{
int right = sourceRectangle.Width - 1;
toX = x => right - x;
}
else if (!isSourceFlippedHorizontally) // && flipHorizontallyAndRightAlign
{
int width = SquareSize.Width - 1;
toX = x => width - x;
}
else // if flipHorizontallyAndRightAlign && isSourceFlippedHorizontally
{
var left = SquareSize.Width - sourceRectangle.Width;
toX = x => left + x;
}
Func<int, int> toY;
if (!flipVerticallyAndTopAlign && !isSourceFlippedVertically) // so bottom aligned and no flip
{
int yOffset = SquareSize.Height - sourceRectangle.Height;
toY = y => y + yOffset;
}
else if (!isSourceFlippedVertically) // so top align with flip
{
var height = sourceRectangle.Height - 1;
toY = y => height - y;
}
else if (!flipVerticallyAndTopAlign) // so bottom align with flip
{
int bottom = SquareSize.Height - 1;
toY = y => bottom - y;
}
else // so top align with flip
{
toY = y => y;
}
var sprite = new Bitmap(this._sprite);
for (int y = 0; y < sourceRectangle.Height; y++)
{
for (int x = 0; x < sourceRectangle.Width; x++)
{
int paletteIndex = GetPixelColour(x + sourceRectangle.X, y + sourceRectangle.Y);
Color pixelColour = palette[paletteIndex];
if (paletteIndex == 0)
{
Debug.Assert(pixelColour == Color.Black);
continue;
}
int x2 = toX(x);
int y2 = toY(y);
sprite.SetPixel(x2, y2, pixelColour);
}
}
return new SpriteBuilder(sprite);
}
/// <summary>
/// Adds a foreground sprite
/// </summary>
/// <param name="objectType">Specifies the type of object</param>
/// <param name="orientation">Specifies the vertical flip in bit 6, and the horizontal flip in bit 7</param>
/// <param name="offset">Specifies where to position the sprite within the square</param>
/// <returns>A SpriteBuilder object containing the added foreground sprite</returns>
[Pure]
public SpriteBuilder AddObjectSprite(byte objectType, byte orientation, (byte x, byte y) offset)
{
objectType = (byte) (objectType & 0x7f);
byte spriteIndex = ObjectSpriteLookup[objectType];
byte objectPalette = ObjectPaletteLookup[objectType];
var palette = Palette.FromByte(objectPalette);
var sourceRectangle = SpritePositions[spriteIndex];
bool flipHorizontally = (orientation & 0x80) != 0;
bool flipVertically = (orientation & 0x40) != 0;
bool isSourceFlippedHorizontally = FlipSpriteHorizontally[spriteIndex];
bool isSourceFlippedVertically = FlipSpriteVertically[spriteIndex];
Func<int, int> toX;
if (flipHorizontally == isSourceFlippedHorizontally)
{
toX = x => x;
}
else
{
int right = sourceRectangle.Width - 1;
toX = x => right - x;
}
Func<int, int> toY;
if (flipVertically == isSourceFlippedVertically)
{
toY = y => y;
}
else
{
int height = sourceRectangle.Height - 1;
toY = y => height - y;
}
offset.x >>= 4;
offset.y >>= 3;
var sprite = new Bitmap(this._sprite);
for (int y = 0; y < sourceRectangle.Height; y++)
{
for (int x = 0; x < sourceRectangle.Width; x++)
{
int paletteIndex = GetPixelColour(x + sourceRectangle.X, y + sourceRectangle.Y);
Color pixelColour = palette[paletteIndex];
if (paletteIndex == 0)
{
Debug.Assert(pixelColour == Color.Black);
continue;
}
int x2 = toX(x) + offset.x;
int y2 = toY(y) + offset.y;
if (x2 < sprite.Width && y2 < sprite.Height)
{
sprite.SetPixel(x2, y2, pixelColour);
}
}
}
return new SpriteBuilder(sprite);
}
/// <summary>
/// Adds an object that is emerging or is fired from another object
/// </summary>
/// <param name="objectType">The type of object to draw</param>
/// <param name="hasTree">If set, the object will be placed in clear space above or below the tree</param>
/// <param name="orientation">Specifies the vertical alignment in bit 6 (other bits will be ignored)</param>
/// <returns>A SpriteBuilder object containing the added emerging object</returns>
[Pure]
public SpriteBuilder AddEmergingObjectSprite(byte objectType, bool hasTree, byte orientation)
{
objectType = (byte) (objectType & 0x7f);
byte spriteIndex = ObjectSpriteLookup[objectType];
var width = SpriteWidthLookup[spriteIndex];
byte offsetX = (byte) ((width ^ 255) >> 1);
bool alignAtTop = (orientation & 0x40) != 0;
var height = SpriteHeightLookup[spriteIndex];
byte offSetY;
if (objectType == 0x37) // flames
{
Debug.Assert(!alignAtTop);
offSetY = (byte) (255 - height);
}
else if (hasTree)
{
offSetY = alignAtTop ? (byte)(255 - height) : (byte) 0;
}
else
{
offSetY = (byte)((height ^ 255) >> 1);
}
return AddObjectSprite(objectType, 0, (offsetX, offSetY));
}
/// <summary>
/// Adds a sprite for a door
/// </summary>
/// <param name="backgroundObjectType">Specifies the type of door (either 3 for metal door, or 4 for a stone door)</param>
/// <param name="orientation">Specifies the vertical alignment in bit 6, and the horizontal alignment in bit 7</param>
/// <param name="data">Specifies the data associated with the door which indicates the palette to use</param>
/// <returns>A SpriteBuilder object containing the added door sprite</returns>
[Pure]
public SpriteBuilder BuildDoor(byte backgroundObjectType, byte orientation, byte data)
{
Debug.Assert(backgroundObjectType == 3 || backgroundObjectType == 4);
bool rightAlign = (orientation & 0x80) != 0;
bool bottomAlign = (orientation & 0x40) == 0;
var doorIsHorizontal = rightAlign ^ bottomAlign;
byte spriteIndex;
switch (backgroundObjectType)
{
case 3:
spriteIndex = (byte) (doorIsHorizontal ? 0x4a : 0x4b);
break;
case 4:
spriteIndex = (byte) (doorIsHorizontal ? 0x3c : 0x41);
break;
default:
throw new ArgumentOutOfRangeException(nameof(backgroundObjectType));
}
byte key = (byte) ((data >> 4) & 0b111);
Palette palette = DoorPalettes[key];
var sourceRectangle = SpritePositions[spriteIndex];
bool isSourceFlippedHorizontally = FlipSpriteHorizontally[spriteIndex];
bool isSourceFlippedVertically = FlipSpriteVertically[spriteIndex];
Func<int, int> toX;
if (!rightAlign && !isSourceFlippedHorizontally)
{
toX = x => x;
}
else if (!rightAlign) // && isSourceFlippedHorizontally
{
int right = sourceRectangle.Width - 1;
toX = x => right - x;
}
else if (!isSourceFlippedHorizontally) // && flipHorizontallyAndRightAlign
{
int width = SquareSize.Width - 1;
toX = x => width - x;
}
else // if flipHorizontallyAndRightAlign && isSourceFlippedHorizontally
{
var left = SquareSize.Width - sourceRectangle.Width;
toX = x => left + x;
}
Func<int, int> toY;
if (!bottomAlign && !isSourceFlippedVertically)
{
toY = y => y;
}
else if (!isSourceFlippedVertically) // && bottomAlign
{
int yOffset = SquareSize.Height - sourceRectangle.Height;
toY = y => y + yOffset;
}
else if (!bottomAlign) // && isSourceFlippedVertically
{
int bottom = sourceRectangle.Height - 1;
toY = y => bottom - y;
}
else // bottomAlign && isSourceFlippedVertically
{
var height = SquareSize.Height - 1;
toY = y => height - y;
}
var sprite = new Bitmap(this._sprite);
for (int y = 0; y < sourceRectangle.Height; y++)
{
for (int x = 0; x < sourceRectangle.Width; x++)
{
int paletteIndex = GetPixelColour(x + sourceRectangle.X, y + sourceRectangle.Y);
Color pixelColour = palette[paletteIndex];
if (paletteIndex == 0)
{
Debug.Assert(pixelColour == Color.Black);
continue;
}
int x2 = toX(x);
int y2 = toY(y);
sprite.SetPixel(x2, y2, pixelColour);
}
}
return new SpriteBuilder(sprite);
}
/// <summary>
/// Adds an overlay image to the sprite
/// </summary>
/// <param name="bitmap">Specifies the image to add</param>
/// <returns>A SpriteBuilder object containing the added image</returns>
[Pure]
public SpriteBuilder AddBitmap(Bitmap bitmap)
{
var sprite = new Bitmap(this._sprite);
using (Graphics g = Graphics.FromImage(sprite))
{
g.CompositingMode = CompositingMode.SourceOver;
bitmap.MakeTransparent(Color.Black);
g.DrawImage(bitmap, Point.Empty);
}
return new SpriteBuilder(sprite);
}
private static int GetPixelColour(int x, int y)
{
if (x < 0 || x >= 128)
throw new ArgumentOutOfRangeException(nameof(x));
if (y < 0 || y >= 82)
throw new ArgumentOutOfRangeException(nameof(y));
int positionOfData = (x >> 2) + (y << 5);
byte fourPixels = SpriteData[positionOfData];
int pixelNumber = x % 4;
int result = -1;
if (pixelNumber == 0)
{
result = ((fourPixels & 0x80) >> 6) | ((fourPixels & 0x08) >> 3);
}
else if (pixelNumber == 1)
{
result = ((fourPixels & 0x40) >> 5) | ((fourPixels & 0x04) >> 2);
}
else if (pixelNumber == 2)
{
result = ((fourPixels & 0x20) >> 4) | ((fourPixels & 0x02) >> 1);
}
else if (pixelNumber == 3)
{
result = ((fourPixels & 0x10) >> 3) | (fourPixels & 0x01);
}
return result;
}
private static Dictionary<byte, Rectangle> BuildSpritePositions()
{
byte[] spriteOffsetA = BuildSpriteOffsetA();
byte[] spriteOffsetB = BuildSpriteOffsetB();
byte[] spriteHeightLookup = BuildSpriteHeightLookup();
byte[] spriteWidthLookup = BuildSpriteWidthLookup();
var result = new Dictionary<byte, Rectangle>();
for (byte sprite = 0; sprite <= 0x7c; sprite++)
{
byte offsetAlongX = spriteOffsetA[sprite];
int mostSignificantThreeBits = (offsetAlongX & 0b0000_0111) << 4;
int leastSignificantFourBits = offsetAlongX >> 4;
int left = mostSignificantThreeBits | leastSignificantFourBits;
byte offsetAlongY = spriteOffsetB[sprite];
int mostSignificantTwoBits = (offsetAlongY & 0b0000_0011) << 5;
int leastSignificantFiveBits = offsetAlongY >> 3;
int top = mostSignificantTwoBits | leastSignificantFiveBits;
int width = (spriteWidthLookup[sprite] >> 4) + 1;
int height = (spriteHeightLookup[sprite] >> 3) + 1;
result.Add(sprite, new Rectangle(left, top, width, height));
}
return result;
}
private static byte[] BuildSpriteSheet()
{
var result = new byte[]
{
// ReSharper disable once CommentTypo
// sprite sheet is 128 x 81 pixels
// There are 2 bits of colour per pixel, therefore 4 pixels to the byte.
// So each row of the sprite sheet takes 32 bytes
// Each byte has the four pixels interlaced in an abcdabcd format like mode 5.
0xC0,0x00,0x00,0x00,0x32,0x11,0x80,0x10,0x00,0x00,0x00,0x20,0x06,0x08,0x00,0x00,0x01,0x8C,0x00,0x66,0x80,0x00,0x00,0x00,0x01,0x02,0x08,0x64,0x90,0x80,0x00,0x66, // 000
0x8C,0x00,0x00,0x00,0x56,0xA3,0xC0,0xCA,0x00,0x00,0x00,0x07,0x2D,0x66,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x00,0x00,0x00,0x01,0x0B,0x88,0x42,0xF0,0x3E,0x64,0x4C, // 010
0x3C,0x00,0x00,0x00,0x03,0x01,0x19,0x68,0x00,0x00,0x13,0x21,0x2D,0x00,0x00,0x00,0x0B,0x8D,0x00,0x40,0x68,0x00,0x00,0x00,0x02,0xAB,0x00,0xCB,0xF8,0x18,0x90,0x4C, // 020
0xDF,0x00,0x00,0x00,0x46,0x23,0x00,0x1C,0x00,0x00,0x37,0x07,0x06,0x00,0x00,0x00,0xCA,0x35,0x04,0x42,0xFC,0x80,0x00,0x00,0x13,0x19,0x0A,0xE8,0x74,0x99,0x83,0x1E, // 030
0x3C,0xC0,0x00,0x00,0x46,0x23,0x00,0x0A,0x00,0x00,0x1F,0x21,0x00,0x00,0x00,0x00,0xCB,0xBD,0xC5,0x63,0x4F,0xC0,0x00,0x00,0x15,0x9F,0x0B,0xE2,0x33,0x00,0x87,0x78, // 040
0xFF,0x0C,0x00,0x00,0x07,0x83,0x59,0x0E,0x00,0x01,0x3F,0x07,0x00,0x00,0x03,0x0F,0x4B,0xAD,0xF5,0x7B,0x6F,0xE0,0x00,0x00,0x47,0xFF,0x26,0xC0,0x65,0x01,0x96,0xC0, // 050
0xC7,0xF4,0x00,0x00,0x04,0x02,0x11,0x08,0x00,0x03,0x1F,0x07,0x00,0x00,0x0F,0x0F,0x4A,0x25,0xB5,0xDB,0xFF,0xAC,0x00,0x00,0x4F,0xFF,0x4E,0x80,0x61,0x0B,0x1E,0x00, // 060
0xFF,0xEF,0x00,0x00,0x06,0x13,0x11,0x5C,0x00,0x21,0x3F,0x21,0x00,0x01,0x0F,0x0F,0x4B,0xAD,0xA5,0x4B,0x7A,0x9E,0x80,0x00,0x37,0xFB,0xCE,0x80,0xF8,0x01,0x96,0xE0, // 070
0x79,0x79,0xC0,0x00,0x06,0x13,0x11,0x1E,0x00,0x07,0x1F,0x21,0x00,0x03,0x1F,0x2F,0x4B,0xAD,0x85,0x43,0x6F,0x7C,0xC0,0x00,0x13,0xF9,0x8C,0x40,0xE0,0x00,0x87,0x3C, // 080
0x2F,0x3D,0xCC,0x00,0x26,0x03,0x00,0x8C,0x00,0x21,0x3F,0x07,0x00,0x03,0x0E,0x0D,0x4A,0x25,0x04,0x42,0xDF,0x4F,0xCA,0x00,0x13,0xF0,0x8C,0x10,0x80,0x11,0x87,0x1E, // 090
0xFF,0xFF,0x3C,0x00,0x04,0x03,0x28,0x24,0x00,0x07,0x3F,0x07,0x00,0x07,0x0F,0x0F,0x0B,0x8D,0x00,0x40,0xBD,0xEF,0x9E,0x00,0x0D,0xF0,0x8F,0x00,0x0C,0x10,0x80,0x84, // 0a0
0x96,0xC7,0xF7,0x00,0x04,0x06,0x68,0x30,0x00,0x21,0x1F,0x21,0x00,0x06,0x0B,0x0D,0x00,0x00,0x00,0x40,0x9F,0x3E,0x5E,0x80,0x15,0xF1,0xAE,0x00,0xCC,0x32,0x32,0x00, // 0b0
0xFF,0xFF,0xDE,0x80,0x40,0x40,0x40,0x10,0x00,0x07,0x3F,0x21,0x00,0x11,0x44,0x22,0x03,0x0E,0x00,0x42,0xFF,0xA7,0xFC,0x84,0x37,0xEB,0xCC,0x01,0x0E,0x00,0x12,0x08, // 0c0
0xB6,0x1E,0x8F,0x68,0x60,0x60,0x00,0x03,0x00,0x21,0x3F,0x07,0x01,0x0F,0x0F,0x0F,0x0E,0x0B,0x08,0x41,0xA7,0xBF,0x9F,0x68,0x6F,0xEF,0x0F,0x11,0xCA,0x00,0x25,0x0C, // 0d0
0xFF,0xFF,0xFF,0x8E,0x00,0x00,0x00,0xCA,0x00,0x07,0x1F,0x07,0x01,0x0F,0x0F,0x0F,0x88,0x88,0x88,0x62,0x6F,0x9F,0x3F,0xF8,0x07,0xBF,0x0D,0x03,0x2D,0x00,0x48,0x44, // 0e0
0x69,0xC7,0x78,0xBE,0x00,0x11,0x91,0x06,0x00,0x21,0x3F,0x07,0x00,0x80,0x00,0x90,0x00,0x12,0xC0,0x71,0xCF,0xFF,0xEF,0xFE,0x11,0x9B,0x88,0x33,0xED,0x00,0x4B,0x0E, // 0f0
0x6D,0x6F,0x3D,0x8F,0x00,0x23,0xC0,0x0C,0x00,0x21,0x3F,0x21,0x30,0xE8,0x30,0xB9,0x0C,0x25,0xE0,0x50,0x6F,0x8F,0xD6,0xAF,0x01,0x8A,0x08,0x07,0x0F,0x08,0x00,0x00, // 100
0xFF,0xFF,0xFF,0xFF,0x00,0x01,0x19,0x1A,0x11,0x07,0x1F,0x21,0x73,0xFC,0x73,0xBB,0xCE,0x25,0xC0,0x66,0xED,0xAF,0xCF,0xCB,0x00,0x0B,0x8C,0xFF,0x8F,0x1D,0xFF,0xFF, // 110
0x3C,0x9E,0xC7,0x3C,0x00,0x23,0x11,0x2A,0x13,0x07,0x3F,0x07,0x74,0xF2,0x74,0xB0,0xCE,0x00,0x31,0x06,0xCF,0xFF,0x9F,0xDF,0x01,0x09,0x00,0x07,0x0F,0x08,0xDC,0xE0, // 120
0xFF,0xFF,0xFF,0xFF,0x00,0x03,0x59,0x08,0x04,0x21,0x3F,0x07,0x64,0xB2,0x64,0x90,0xED,0xFF,0xE2,0xFF,0x7F,0xBF,0xDF,0x7F,0x22,0x00,0x88,0x33,0x6F,0x11,0xDD,0xFF, // 130
0xE3,0x3D,0x0F,0xE3,0x00,0x01,0x11,0x4C,0x17,0x21,0x1F,0x07,0x64,0x32,0x32,0x07,0xED,0xFF,0x80,0x06,0x7B,0x3E,0x7F,0x1F,0x74,0x11,0xC0,0x03,0x07,0x00,0xDC,0xE0, // 140
0xFF,0xFF,0xFF,0xFF,0x00,0x02,0x11,0x7E,0x0C,0x07,0x3F,0x07,0x64,0x77,0xB0,0x27,0xEB,0xFF,0xEE,0xFF,0x2F,0xE7,0x3F,0xBF,0x40,0x10,0x00,0x11,0x46,0x11,0xDD,0xFF, // 150
0x3C,0x8F,0x79,0x2D,0x00,0x07,0x00,0x3C,0x97,0x07,0x3F,0x21,0x64,0x72,0x80,0x05,0xEB,0x00,0x33,0x06,0x7F,0x3F,0x7E,0xEF,0x60,0x10,0x80,0x01,0x0E,0x00,0xCC,0x00, // 160
0xFF,0xFF,0xFF,0xFF,0x00,0x27,0x00,0x0C,0x0C,0x21,0x1F,0x21,0xFE,0x00,0x20,0x07,0xE7,0x25,0xC0,0x66,0xDF,0xFF,0xCF,0x4F,0x70,0x10,0xC0,0x00,0xCC,0x00,0x11,0xCC, // 170
0xCB,0x6B,0xD6,0xC7,0x08,0x0D,0x00,0x40,0x97,0x21,0x1F,0x07,0xF4,0x20,0x20,0x27,0x6F,0x25,0xE0,0x05,0x9E,0xCF,0xC7,0x6D,0xDC,0x33,0x40,0x11,0x00,0x00,0xD1,0x88, // 180
0x87,0xE7,0x1E,0xDE,0x18,0x81,0x00,0x60,0x0C,0x07,0x3F,0x07,0x00,0x32,0x64,0x05,0x69,0x00,0x00,0x05,0x8F,0x4F,0x5F,0xEF,0x8E,0x23,0x08,0xC1,0x60,0x00,0x00,0x00, // 190
0xFF,0xFF,0xFF,0xFF,0x98,0x10,0x00,0x00,0x0C,0x07,0x3F,0x07,0x64,0x32,0x32,0x06,0x6F,0x88,0x40,0x20,0xDF,0xFE,0xFF,0xB7,0x0D,0x03,0x04,0x61,0xC0,0x8E,0x30,0x80, // 1a0
0xA7,0x1E,0xC7,0x4B,0x90,0x10,0x80,0x00,0x97,0x07,0x1F,0x07,0x64,0x77,0xB0,0x00,0x6F,0x08,0x90,0x22,0xF7,0x3F,0xEF,0x3F,0x8C,0x23,0x04,0x01,0x11,0x4A,0x07,0x0C, // 1b0
0xFF,0xFF,0xFF,0xFF,0x88,0x22,0x00,0x00,0x1F,0x21,0x1F,0x21,0x64,0x72,0x80,0x20,0x6F,0x98,0xB0,0x64,0x5F,0xB7,0x2F,0xEF,0x8F,0xAB,0x08,0x11,0x11,0xED,0xF0,0xF7, // 1c0
0x9E,0xC7,0x79,0x1E,0x08,0x74,0x00,0x88,0x0C,0x21,0x3F,0x21,0xE0,0x00,0x30,0xE2,0x6F,0x78,0x70,0xBC,0x5F,0xAF,0x7B,0x8F,0x8B,0xAB,0x2E,0x9F,0x01,0xBD,0x00,0x00, // 1d0
0xFF,0xFF,0xFF,0xFF,0x88,0x40,0x11,0xC0,0x84,0x07,0x3F,0x07,0xE8,0x20,0x73,0xEE,0x6F,0x7C,0xA0,0x06,0xCF,0xFF,0x6F,0xED,0xCC,0x22,0x3F,0x99,0x99,0x2F,0x73,0xEE, // 1e0
0x7B,0x5A,0x8F,0xC7,0x80,0x60,0x10,0x00,0x1F,0x07,0x1F,0x07,0xC0,0x3A,0x30,0xE0,0x6F,0x3C,0x04,0x9C,0x8F,0x7D,0xCF,0xF7,0x37,0x11,0x11,0xFF,0x99,0x0F,0x30,0xC4, // 1f0
0xE3,0x0F,0x1E,0xE7,0x08,0x70,0x10,0x80,0x00,0x11,0xEE,0x0F,0x01,0x3A,0x04,0x20,0x6F,0xD8,0xA0,0x0E,0xFF,0xC7,0xEF,0x5F,0x07,0x09,0xDD,0x99,0x88,0x9F,0x00,0x00, // 200
0xFF,0xFF,0xFF,0xFF,0x88,0xDC,0x10,0xC0,0x00,0x11,0xEE,0x0F,0x1B,0x3A,0x06,0x0E,0x6F,0x1C,0xC0,0x04,0xD7,0x6F,0x7F,0x4F,0x07,0x0D,0x0C,0x9F,0x00,0xEE,0x73,0xEE, // 210
0x3C,0x9E,0xE3,0x1E,0x0C,0x8E,0x33,0x40,0x00,0x01,0x0E,0x44,0x0A,0x3A,0x04,0x0E,0x6F,0xBC,0x80,0x2A,0x1F,0xFF,0xFD,0xCF,0x07,0x0D,0x08,0x00,0x00,0x5C,0x30,0xCC, // 220
0xFF,0xFF,0xFF,0xFF,0xCC,0x0D,0x23,0x08,0x00,0x11,0xEE,0x0B,0x0B,0x3A,0x02,0x4E,0x6F,0xE8,0x80,0x9F,0xBF,0xBD,0x9F,0xFF,0x0E,0x81,0x08,0x00,0x00,0x2C,0x30,0xC4, // 230
0x4F,0x79,0x0F,0xE3,0xC0,0x8D,0x03,0x04,0x00,0x05,0x0E,0x0F,0x1B,0x3A,0x06,0x0A,0x6F,0x5F,0x48,0x03,0xEF,0x0F,0x9F,0x7B,0x0C,0xC5,0x08,0x00,0x00,0x6E,0x30,0xCC, // 240
0xFF,0xFF,0xFF,0xFF,0x8C,0x8E,0x23,0x00,0x00,0x04,0x00,0x0F,0x0A,0x2A,0x0E,0x0E,0x6F,0x1F,0x0C,0x06,0x7B,0x2F,0xFF,0x2F,0x80,0xC1,0x00,0x00,0x00,0x2C,0x00,0x00, // 250
0x3D,0xBC,0x79,0x0F,0x88,0x8F,0xAB,0x2E,0x00,0x1D,0xEE,0x78,0x09,0x09,0x4E,0x4E,0x6F,0xEF,0x4E,0x40,0x1F,0xFF,0xEB,0x2F,0xC4,0x10,0x00,0x00,0x00,0x5C,0x33,0xCC, // 260
0x3C,0x8F,0x7D,0x3C,0xC8,0x8B,0xAA,0x2E,0x00,0x0D,0x0E,0x08,0x0C,0x03,0x0A,0x0A,0x6F,0x8F,0xDF,0x60,0xFF,0xBD,0x3F,0x6F,0xC0,0x10,0x88,0x00,0x00,0x00,0x30,0xCC, // 270
0xFF,0xFF,0xFF,0xFF,0xCC,0x44,0x33,0x00,0x01,0x08,0x00,0x0F,0x0E,0x07,0x0E,0x0E,0xF0,0xF0,0xF0,0xC0,0xBD,0x1F,0x1F,0xFF,0x00,0x10,0x80,0x00,0x00,0x00,0x30,0xCC, // 280
0xE3,0x1E,0x8F,0xE3,0x48,0x37,0x01,0xCC,0x01,0x5D,0xEE,0x78,0x2F,0x27,0x4E,0x4E,0x6F,0xFF,0xEF,0xEC,0x9F,0x7F,0xDF,0x3D,0x00,0x88,0x00,0x00,0x00,0x00,0x30,0xCC, // 290
0xFF,0xFF,0xFF,0xFF,0x88,0x07,0x01,0x0E,0x03,0x01,0x0E,0x08,0x0D,0x05,0x0A,0x0A,0x6F,0xFF,0xEF,0xEC,0xDF,0xDE,0xFF,0x8F,0x22,0x91,0x40,0x40,0x00,0x00,0x30,0xC4, // 2a0
0x0F,0xC7,0x79,0x2D,0xC4,0x03,0x01,0x0E,0x03,0xC4,0x01,0x0F,0x0F,0x07,0x0E,0x0E,0x6F,0xFF,0xEF,0xDE,0x7F,0x4F,0xCB,0xEF,0x20,0x54,0x40,0x41,0x00,0x00,0x30,0xCC, // 2b0
0xFF,0xFF,0xFF,0xFF,0xCE,0xCB,0x63,0x0E,0x06,0x00,0x03,0xF0,0x0A,0x02,0x0A,0x0A,0x6F,0xFF,0xEF,0xDE,0x6F,0x6F,0x8F,0xBF,0x45,0x42,0x61,0xC3,0xAC,0x85,0x30,0xCC, // 2c0
0x6B,0x79,0x0F,0xC7,0x4A,0xC3,0x61,0x20,0x16,0xD5,0x8F,0x00,0x55,0x55,0x55,0x55,0x6F,0xFF,0xEF,0xBE,0xFF,0xA7,0xFF,0xBD,0x61,0x00,0xA9,0x81,0x7F,0xCE,0x30,0xCC, // 2d0
0x7F,0xFF,0xFF,0xFF,0xCC,0x90,0x40,0x31,0x0E,0x01,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x6F,0xFF,0xEF,0xBE,0x3D,0xBF,0xDF,0x9F,0x20,0xB8,0x01,0x03,0x88,0x07,0x30,0xCC, // 2e0
0xCF,0xC7,0xB5,0x3C,0xC6,0x10,0x88,0x30,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0xF0,0xF0,0xF0,0x7E,0x8F,0xEF,0x4F,0xFF,0x89,0xA4,0x99,0x00,0xCC,0xCE,0x30,0xC4, // 2f0
0xF7,0xFF,0xFF,0xCE,0x00,0x10,0x80,0x00,0x0F,0x0F,0x0F,0x0F,0x0F,0x07,0x0E,0x0F,0x00,0x30,0x00,0x02,0xF0,0xF2,0xF3,0xF4,0xA0,0x90,0x80,0x00,0x77,0xCD,0x30,0xCC, // 300
0xB5,0x0F,0xE3,0x68,0x00,0x00,0x00,0x10,0x0F,0x0F,0x0F,0x0F,0x0F,0x07,0x19,0x1E,0x00,0x31,0x00,0x55,0x60,0xF0,0x70,0xE0,0x51,0x40,0x11,0x22,0x0F,0x0F,0x30,0xCC, // 310
0x79,0xAD,0x7B,0x0C,0x00,0x00,0x00,0x10,0x0C,0x03,0x00,0x00,0x0E,0x02,0x47,0x69,0x00,0x20,0x11,0x20,0x40,0xA0,0x20,0x40,0x12,0x39,0x32,0x31,0xF0,0x6F,0x30,0xC4, // 320
0xFF,0xFF,0x8F,0xC0,0x00,0x00,0x00,0x30,0x3C,0xC3,0xF0,0xF0,0x19,0x55,0x1E,0x83,0x00,0x02,0x00,0xE0,0x00,0x2B,0x04,0x00,0x22,0xC6,0x31,0x3E,0x00,0xF6,0x30,0xCC, // 330
0x2F,0x6B,0xDF,0x88,0x00,0x00,0x00,0x21,0x0F,0x0F,0x0F,0x0F,0x47,0x0F,0x69,0x4F,0x00,0x06,0x01,0x51,0x00,0x22,0x09,0x44,0x10,0x50,0x33,0x3F,0x06,0x6F,0x30,0xCC, // 340
0xEF,0x6B,0x5A,0x80,0x00,0x00,0x00,0x61,0x00,0x06,0x00,0x00,0x0F,0x1E,0x87,0x0F,0x00,0x0E,0xC0,0xC0,0x11,0x7F,0x26,0x44,0x00,0x28,0x33,0x33,0x60,0x0F,0x30,0xCC, // 350
0x7F,0xFF,0xCF,0x00,0x00,0x00,0x00,0x43,0xF0,0x96,0xF0,0xF0,0x0F,0x69,0x0F,0x0E,0x01,0x0D,0xEA,0x82,0x15,0x55,0x67,0x4C,0x10,0x0C,0x11,0x22,0x00,0x44,0x30,0xC4, // 360
0x96,0xC7,0x78,0x00,0x00,0x00,0x00,0x43,0x0F,0x0F,0x0F,0x0F,0x1E,0x83,0x0F,0x1B,0x67,0x0B,0x50,0xC0,0x33,0xDF,0xEF,0xEE,0x00,0x08,0x00,0x00,0x0F,0xCD,0x30,0xCC, // 370
0xFF,0xFF,0xCA,0x00,0x00,0x00,0x00,0xA5,0x00,0x0C,0x00,0x03,0x69,0x4F,0x0E,0x4D,0x46,0x00,0x10,0x22,0xAA,0x9D,0xAA,0xAA,0x00,0x08,0x55,0x00,0x09,0xF0,0x30,0xCC, // 380
0x2D,0x3C,0xE8,0x00,0x00,0x00,0x10,0x87,0xF0,0x3C,0xF0,0xC3,0x87,0x0F,0x1B,0x07,0x4D,0x2E,0x10,0x80,0xEF,0x17,0x23,0xBF,0x65,0x11,0x60,0x00,0x69,0x49,0x30,0xCC, // 390
0xEF,0x1E,0x0C,0x00,0x00,0x00,0x10,0xD7,0x0F,0x0F,0x0F,0x0F,0x0F,0x0E,0x4D,0x0C,0x8F,0x2E,0x30,0x44,0x46,0x0E,0x37,0x99,0x33,0x8A,0xB0,0x88,0x69,0x6E,0x00,0x00, // 3a0
0x7B,0xCF,0xC0,0x00,0x00,0x00,0x30,0x7F,0x0F,0x0F,0x0F,0x0F,0x0F,0x1B,0x07,0x00,0x8F,0x00,0x20,0x00,0x0F,0x07,0x1B,0x06,0x55,0x9D,0x55,0x02,0x0F,0x08,0x70,0xEE, // 3b0
0xEF,0x6F,0x88,0x00,0x00,0x00,0x30,0x7B,0x0A,0x0D,0x0A,0x0D,0x0E,0x4D,0x0C,0x00,0xCE,0x00,0x00,0x44,0x0B,0x06,0x1F,0x0B,0x66,0x0A,0xFA,0x27,0x09,0x01,0x00,0xAC, // 3c0
0x2D,0x5E,0x80,0x00,0x00,0x00,0x21,0x2F,0x55,0x22,0x55,0x22,0x1B,0x07,0x00,0x00,0x20,0x00,0x00,0x22,0x30,0x01,0x08,0x11,0x33,0x8C,0xA0,0xFD,0x09,0x21,0x91,0x3D, // 3d0
0xF3,0xEF,0x00,0x00,0x00,0x00,0x53,0xA7,0x0F,0x0F,0x0F,0x0F,0x4D,0x0C,0x00,0x00,0xE0,0x00,0x00,0x22,0x43,0x0B,0x0C,0x32,0x80,0x19,0x50,0x27,0x69,0x25,0x91,0x0F, // 3e0
0xEF,0x3C,0x00,0x00,0x00,0x00,0x53,0xAF,0x0F,0x0F,0x0F,0x0F,0x07,0x00,0x00,0x00,0xC0,0x00,0x00,0x01,0x04,0x82,0x44,0x20,0x00,0x04,0x55,0x02,0x6F,0x3D,0x80,0x0E, // 3f0
0xB4,0x2E,0x00,0x00,0x00,0x00,0xA7,0xEF,0x05,0x0F,0x0F,0x0A,0x0C,0x00,0x00,0x00,0x80,0x00,0x00,0x88,0x06,0x03,0x00,0x30,0x00,0x24,0x24,0x24,0x6F,0x2C,0x91,0x8C, // 400
0xFF,0x68,0x00,0x00,0x00,0x10,0xA5,0x7F,0x84,0xAA,0x55,0x12,0x08,0x10,0x4C,0x00,0xE8,0x00,0x11,0xC0,0x07,0x0B,0x0C,0x30,0x80,0x24,0xFF,0x24,0x69,0x37,0x3A,0x0C, // 410
0x6B,0x4C,0x00,0x00,0x00,0x01,0x0F,0xFF,0x84,0x00,0x00,0x12,0x08,0x32,0x2E,0x00,0x44,0x00,0x10,0x00,0x00,0x00,0x00,0x66,0x80,0x00,0xF6,0x24,0x09,0x33,0x47,0x07, // 420
0xFF,0xC0,0x00,0x00,0x00,0x10,0x6F,0x8F,0x85,0x0F,0x0F,0x1A,0x2E,0x03,0x2E,0x00,0x00,0x00,0x10,0x80,0x71,0x9A,0x0C,0x47,0x00,0xFB,0x64,0x99,0x09,0x22,0x47,0x09, // 430
0xA5,0x08,0x00,0x00,0x00,0x30,0x7F,0xDF,0x87,0x0B,0x0D,0x1E,0x17,0x01,0x0C,0x00,0x00,0x00,0x10,0xC0,0xA7,0x12,0x28,0x06,0x19,0xFD,0x80,0xF6,0x0F,0x02,0x47,0x2E, // 440
0x5E,0x80,0x00,0x00,0x00,0x30,0x7B,0xF5,0x83,0x49,0x29,0x1C,0x21,0x88,0x6E,0xC1,0x00,0x00,0x33,0x40,0xAA,0x52,0x70,0x46,0x18,0xFF,0x88,0x64,0x0F,0x22,0x23,0xA6, // 450
0x9F,0x00,0x00,0x00,0x00,0x53,0x3F,0x7F,0xC9,0x6C,0x63,0x39,0x47,0x88,0x6A,0xAC,0x08,0x00,0x27,0x00,0xFF,0x12,0xC0,0x47,0x00,0xFA,0x00,0x00,0x09,0x22,0x11,0x0C, // 460
0x78,0x00,0x00,0x00,0x00,0xC3,0x2F,0x4F,0x64,0x3F,0xCF,0x62,0xDF,0x03,0x1F,0xBA,0x04,0x00,0xCF,0x09,0xAF,0x9A,0xD0,0x47,0x4C,0x66,0x00,0x00,0x69,0x22,0x00,0x0A, // 470
0xCE,0x00,0x00,0x00,0x00,0xD3,0x6F,0xE7,0x33,0x04,0x02,0xCC,0x8E,0x02,0x1F,0x9F,0x82,0x00,0x8F,0x09,0xAA,0xCE,0x60,0x45,0x4C,0x00,0x00,0x44,0x69,0x33,0x00,0x0E, // 480
0x68,0x00,0x00,0x00,0x00,0x97,0x7F,0x3F,0xF0,0x0F,0x0F,0x0F,0x8F,0x04,0x17,0x99,0xC8,0x00,0x4F,0x19,0xFF,0xCF,0x08,0x22,0x00,0x00,0x00,0xE8,0x0F,0x08,0x01,0x0F, // 490
0x8C,0x00,0x00,0x00,0x10,0x0F,0xFF,0xFF,0xC3,0x87,0x0F,0x0F,0x8F,0x1D,0x2E,0x8F,0xEC,0x01,0x4E,0x1D,0xAF,0x8D,0x0C,0x13,0x88,0x00,0xDF,0x80,0xF0,0x0F,0x0F,0xF0, // 4a0
0x48,0x00,0x00,0x00,0x10,0x7A,0x6D,0xBF,0xF0,0x0F,0x0F,0x0F,0x65,0x23,0xE6,0x88,0xEE,0xCB,0x2E,0x2E,0xAA,0xEE,0x00,0x03,0x08,0x02,0xFF,0xC0,0x00,0x1C,0x83,0x00, // 4b0
0x88,0x00,0x00,0x00,0x30,0x3F,0x4F,0xAF,0x77,0xFF,0xFF,0xEE,0x23,0x23,0x08,0xF0,0xF0,0xC3,0x0C,0x26,0x77,0xBB,0xCC,0xC5,0x1D,0x85,0x4F,0xE0,0x06,0x1D,0x8B,0x06, // 4c0
0x80,0x00,0x00,0x00,0x61,0xFF,0xDF,0xEF,0x70,0xA5,0x0F,0x0E,0x03,0x19,0x0C,0xFF,0xFF,0x83,0x00,0x01,0x00,0x00,0x00,0x80,0x0C,0x03,0x4F,0x28,0x60,0x1D,0x8B,0x60, // 4d0
0xFF,0xFF,0x00,0x04,0x52,0xCF,0xFF,0x3F,0x70,0xC3,0x0F,0x0E,0x47,0x0C,0x04,0x00,0x00,0x44,0x08,0x01,0x70,0x91,0x08,0xE3,0x1D,0x87,0x4F,0x0C,0x00,0x1C,0x83,0x00, // 4e0
0xFF,0xFF,0x2D,0x2A,0xD3,0xEF,0xCF,0xF7,0x70,0x2D,0x0F,0x0E,0x47,0xC4,0x0C,0x31,0x00,0x61,0x08,0x00,0x87,0x59,0x0C,0x61,0x18,0x87,0x46,0x1F,0x0F,0x0F,0x0F,0x0F, // 4f0
0x00,0x00,0x22,0x11,0x97,0x2F,0x6F,0xCF,0x70,0x87,0x0F,0x0E,0x23,0x80,0x0C,0x31,0x00,0x41,0x00,0x00,0x0F,0x1D,0xCC,0x40,0x10,0x06,0x00,0x17,0xF0,0x80,0x10,0xF0 // 500
};
return result;
}
private static byte[] BuildSpriteOffsetA()
{
var result = new byte[]
{
// format is: b1 b0 p1 p0 0 b4 b3 b2
// where b is the byte offset from the start of the row (32 bytes per row), and p is the pixel offset within the byte (4 pixels per byte)
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x36,0x44,0xC5,0x04,0x66,0x06,0x91,0x41,0x60,0x43,0xD0,0xD4,0xE4,0xE4,0xA4,0x03, // 00
0x97,0x63,0x03,0x05,0x77,0x97,0x65,0x06,0x06,0x06,0x06,0xE6,0xC6,0xD6,0xE6,0xF6, // 10
0x37,0xD6,0x65,0x02,0x03,0x12,0xC2,0x03,0x03,0x03,0x03,0x02,0x02,0x04,0x96,0xC4, // 20
0x04,0x04,0x43,0x43,0x00,0x00,0x05,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0x05,0x05, // 30
0x05,0x00,0xC0,0x00,0x00,0x44,0xC0,0x03,0x03,0x03,0x07,0x07,0x53,0x17,0x02,0xD4, // 40
0x80,0xD4,0x07,0xF6,0xC6,0x87,0x04,0x84,0x47,0x67,0xC6,0xC6,0x96,0x02,0x44,0xD4, // 50
0xC3,0x67,0x36,0x86,0x01,0x51,0x31,0xB1,0xB1,0xC4,0x02,0x67,0x47,0x15,0x55,0x35, // 60
0x05,0x00,0x16,0x37,0xE6,0x76,0x04,0xB6,0xC4,0x47,0x84,0xB6,0xA4 // 70
};
return result;
}
private static byte[] BuildSpriteOffsetB()
{
var result = new byte[]
{
// format is: r4 r3 r2 r1 r0 0 r6 r5
// where r is the row within the sprite sheet
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x42,0x02,0xE9,0x81,0x98,0x98,0xE0,0xE0,0x7A,0x00,0x72,0xE1,0x5A,0x3A,0x81,0x00, // 00
0xE1,0x0A,0x02,0xE9,0x60,0x68,0xE9,0x00,0x00,0x49,0x49,0x50,0x68,0x68,0x58,0x50, // 10
0xD0,0xD9,0xA0,0x00,0x28,0x01,0x01,0x09,0x49,0x89,0xC9,0x01,0x81,0x41,0x81,0x41, // 20
0x80,0x41,0x80,0x20,0x00,0x00,0x00,0x00,0x89,0x80,0x80,0x80,0x31,0x80,0x09,0x89, // 30
0x49,0x80,0x80,0x71,0x01,0xD0,0x00,0x80,0x01,0x41,0x4A,0x89,0xA8,0xE9,0xF9,0xC0, // 40
0x72,0xC0,0x00,0x20,0x00,0xE0,0x00,0x18,0x11,0xE1,0xC0,0xC8,0x51,0xB1,0x78,0x00, // 50
0x2A,0x00,0x02,0x02,0x00,0x00,0x70,0x00,0x60,0xE0,0x4A,0x0A,0xB1,0x99,0x99,0x99, // 60
0x99,0x72,0xC9,0x61,0x59,0xC1,0xD0,0x11,0x88,0x89,0x90,0xE8,0x90 // 70
};
return result;
}
private static bool[] BuildFlipSpriteHorizontally()
{
return BuildSpriteWidthLookup().Select(w => (w & 0x1) != 0).ToArray();
}
private static byte[] BuildSpriteWidthLookup()
{
var result = new byte[]
{
// ReSharper disable once CommentTypo
// Format: wwww000h
// wwww + 1 is the width of the sprite in pixels
// h indicates a horizontal flip is required
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0xC0,0xA0,0x50,0x90,0x40,0x50,0x60,0x40,0x21,0x20,0x20,0x21,0x11,0x11,0x50,0x30, // 00
0x60,0x51,0x50,0x50,0x80,0x50,0x50,0xB0,0xB0,0x80,0x80,0x50,0x90,0x70,0x50,0x30, // 10
0x40,0x20,0x10,0xF1,0xF1,0x71,0x30,0xF0,0xF0,0xF0,0xF0,0xF1,0xF0,0x30,0x60,0x30, // 20
0x30,0xF0,0xF0,0xF1,0xF0,0xF0,0xF0,0xF0,0xF1,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0, // 30
0xF0,0x30,0x60,0xF0,0xF0,0x70,0x00,0xF0,0xF0,0xF0,0xF0,0x30,0x31,0x41,0xF0,0x20, // 40
0x40,0x20,0x50,0x50,0x30,0x70,0xC0,0x40,0x40,0x20,0x60,0x60,0x40,0xF0,0x70,0x20, // 50
0x70,0x90,0xC0,0x30,0x40,0x50,0x60,0x40,0x40,0x30,0xF0,0x20,0x30,0x31,0x70,0xB1, // 60
0xF0,0x70,0x51,0x41,0x50,0x51,0x30,0x80,0x30,0x30,0x50,0x50,0x40 // 70
};
return result;
}
private static bool[] BuildFlipSpriteVertically()
{
return BuildSpriteHeightLookup().Select(h => (h & 0x1) != 0).ToArray();
}
private static byte[] BuildSpriteHeightLookup()
{
var result = new byte[]
{
// ReSharper disable once CommentTypo
// hhhhh00v
// hhhhh + 1 is the sprite height in pixels
// if v=1, the vertical flip flag is inverted when plotting the sprite
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x40,0x80,0x98,0x91,0xA8,0xA0,0xA0,0xA0,0x09,0x08,0x10,0x19,0x19,0x18,0x58,0x18, // 00
0x60,0x78,0x81,0x98,0x78,0x70,0x98,0x90,0x28,0x48,0x78,0x69,0x20,0x28,0x38,0x48, // 10
0x38,0x20,0x08,0xF8,0xF8,0x68,0xF9,0xF9,0xB9,0x79,0x39,0xF8,0x78,0x38,0x38,0x38, // 20
0xF8,0x38,0x78,0xF8,0xF8,0x78,0xF8,0x78,0xF8,0xF8,0xC9,0x78,0x38,0xF8,0x89,0x09, // 30
0x49,0xF8,0xF8,0xF9,0xF9,0x68,0x00,0xF8,0x78,0x38,0x39,0xF9,0xF9,0x28,0x48,0x18, // 40
0x11,0x19,0x20,0x29,0x41,0xF8,0x70,0x30,0x20,0x20,0x19,0x18,0x28,0x60,0x48,0x80, // 50
0x58,0x58,0x39,0x19,0x68,0x68,0x68,0x58,0x68,0x58,0x38,0x38,0x28,0x48,0x48,0x48, // 60
0x48,0x08,0x30,0x20,0x28,0x39,0x70,0x38,0x30,0x20,0x20,0x20,0x20 // 70
};
return result;
}
private static byte[] BuildBackgroundSpriteLookup()
{
var map = new byte[]
{
/* & &7f = sprite
& &80 = not relevant
*/
0xC6,0xCE,0xC6,0xC6,0xC6,0xBB,0xC6,0x18,0x2D,0x70,0x6A,0xC6,0x23,0x39,0xC6,0x62,
0xC0,0x8E,0x39,0x44,0x47,0x26,0x48,0x49,0xDF,0xC6,0x99,0x9A,0x25,0x2B,0x39,0x3B,
0x3C,0x55,0x8E,0x43,0x34,0x35,0x27,0x28,0x29,0x2A,0x42,0xBF,0x40,0x3D,0x38,0x36,
0x37,0x3E,0x33,0x31,0x2F,0x30,0x2C,0x24,0x32,0x41,0x45,0x3A,0x6A,0x23,0x60,0xCC
};
var result = map.Select(item => (byte) (item & 0x7f)).ToArray();
return result;
}
private static byte[] BuildBackgroundYOffsetLookup()
{
var result = new byte[]
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD0,0xC5,0xB0,0xC7,0x00,0x06,0x00,0x00,0xC0, // 00
0xB0,0xA0,0x07,0x08,0x00,0x04,0x80,0xC0,0x70,0x00,0xB0,0x80,0x99,0x08,0x00,0x80, // 10
0xC0,0x00,0xA0,0x03,0x02,0x82,0x01,0x41,0x81,0xC1,0x04,0xF0,0xB0,0x00,0x03,0x02, // 20
0x82,0x70,0x06,0xC0,0xC5,0x04,0x80,0x06,0x80,0x04,0x99,0x30,0xC7,0x06,0xA9,0x00 // 30
};
return result;
}
private static byte[] BuildObjectSpriteLookups()
{
var result = new byte[]
{
0x04, 0x14, 0x04, 0x75, 0x1e, 0x1b, 0x10, 0x10, 0x10, 0x1c, 0x1c, 0x20, 0x70, 0x70, 0x61, 0x52,
0x72, 0x4f, 0x21, 0x08, 0x08, 0x21, 0x21, 0x08, 0x08, 0x21, 0x78, 0x78, 0x13, 0x13, 0x13, 0x5e,
0x5e, 0x15, 0x16, 0x16, 0x16, 0x16, 0x04, 0x52, 0x45, 0x64, 0x64, 0x64, 0x64, 0x64, 0x59, 0x59,
0x59, 0x59, 0x6d, 0x63, 0x63, 0x0b, 0x0f, 0x17, 0x14, 0x17, 0x39, 0x17, 0x4a, 0x4b, 0x3c, 0x41,
0x1a, 0x71, 0x2e, 0x5d, 0x17, 0x20, 0x56, 0x57, 0x47, 0x22, 0x60, 0x7b, 0x76, 0x76, 0x58, 0x58,
0x21, 0x4d, 0x4d, 0x4d, 0x4d, 0x20, 0x4d, 0x4d, 0x22, 0x6b, 0x6c, 0x6c, 0x79, 0x6c, 0x04, 0x7a,
0x63, 0x7c, 0x7c, 0x79, 0x77
};
// overrides for improved display
result[0x13] = 0x0a; // icer bullet
result[0x14] = 0x0a; // tracer bullet
result[0x17] = 0x0a; // red bullet
result[0x18] = 0x0a; // pistol bullet
result[0x2e] = 0x5b; // green/yellow bird
result[0x2f] = 0x5b; // white/yellow bird
result[0x30] = 0x5b; // red/magenta bird
result[0x31] = 0x5b; // invisible bird
result[0x32] = 0x6f; // lightning
return result;
}
private static byte[] BuildObjectPaletteLookups()
{
// bit 7 indicates object can be picked up
var data = new byte[]
{
0x3e, 0x1b, 0x2e, 0xf2, 0x32, 0x32, 0x53, 0x05, 0x0f, 0x14, 0x29, 0xbc, 0x65, 0x65, 0xf7, 0x97,
0xd3, 0xc7, 0xef, 0x7e, 0x5f, 0x3c, 0x5a, 0x11, 0x2d, 0x34, 0xe1, 0x80, 0x55, 0x1b, 0x4c, 0x59,
0x23, 0x72, 0x2e, 0x7b, 0x77, 0x33, 0x39, 0x8b, 0x44, 0x51, 0x0d, 0x46, 0x2b, 0x53, 0x35, 0x3c,
0x02, 0x01, 0x70, 0x9c, 0xcf, 0x00, 0x14, 0x10, 0x4b, 0x10, 0x0c, 0x34, 0x6b, 0x6b, 0x42, 0x42,
0x31, 0x6f, 0x15, 0x2e, 0x12, 0xcb, 0x33, 0xb1, 0x62, 0x00, 0xdb, 0x9f, 0x8f, 0xcf, 0xe5, 0x8e,
0xef, 0xab, 0xad, 0x95, 0x9c, 0x91, 0x92, 0xa6, 0x91, 0xb1, 0x8e, 0xe0, 0xa2, 0xb5, 0xb3, 0xe3,
0xd5, 0xe3, 0xd7, 0xf0, 0xf1
};
return data.Select(p => (byte) (p & 0x7f)).ToArray();
}
private static Palette[] BuildDoorPalettes()
{
var data = new byte[]
{
0x2b, 0x2d, 0x15, 0x1c, 0x42, 0x12, 0x26, 0x4e
};
return data.Select(Palette.FromByte).ToArray();
}
public static byte[] BuildSuckerPalettesAndAction()
{
var result = new byte[] {0x5f, 0xac, 0xbf, 0x3d, 0xf9, 0x58, 0xa2, 0xd8, 0x4b};
return result;
}
private static Palette[] BuildSuckerPalettes()
{
var palettesAndActions = BuildSuckerPalettesAndAction();
return palettesAndActions.Select(p => Palette.FromByte((byte) (p >> 1))).ToArray();
}
}
}