-
Notifications
You must be signed in to change notification settings - Fork 1
/
GDT.cs
836 lines (757 loc) · 39.4 KB
/
GDT.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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
namespace CompileTools
{
public class GDT : ConversionMethod
{
public override string Name
{
get { return "GDT"; }
}
public override string[] Outputs
{
get { return new string[] { ".gdt" }; }
}
public override string[] Inputs
{
get { return new string[] { ".bmp" }; }
}
public override bool Verify(Stream input)
{
throw new NotImplementedException();
}
public override void ConvertTo(Stream input, Stream output)
{
// Current encoding functionality: Uses 0x04 (RLE) flag, 0x10 (repeat previous plane), 0x8N (copy nth previous block's analogous plane).
// Things you can do to make images insert a little better:
// 1) Crop the bottom and right black portions of the title images. (just less data for the codec to screw up)
// 2) Play with the dimensions of the images.
// Create new bmp with header
Bitmap bmp = new Bitmap(Bitmap.FromStream(input));
WriteInt16(output, unchecked((short)0xE488));
WriteInt32(output, 0);
WriteInt16(output, (short)bmp.Width);
WriteInt16(output, (short)(bmp.Height / 2));
output.WriteByte(0x11);
List<List<int>> planes = new List<List<int>>();
List<Boolean> planesCopied = new List<Boolean>();
int currentPlane = 0;
// blankPlane will get called a lot, so create it here. (Just an appropriately-sized array of zeroes.)
List<int> blankPlane = new List<int>(Enumerable.Repeat(0x00, bmp.Height / 2));
// Look at the input bmp and consider it in 8-pixel-wide blocks:
for (int width = 0; width < (bmp.Width - 8); width += 8)
{
// First, check if the block is entirely black. If so, we can write "00-00-00" and skip it.
bool allBlack = true;
for (int height = 0; height < bmp.Height && allBlack; height += 2)
{
for (int dw = 0; dw < 8 && allBlack; dw++)
{
if (bmp.GetPixel(width + dw, height).ToArgb() != Color.Black.ToArgb())
{
allBlack = false;
}
}
}
if (allBlack)
{
// Write a blank block, then proceed to the next block
output.WriteByte(0x00);
output.WriteByte(0x00);
output.WriteByte(0x00);
planes.Add(blankPlane);
planes.Add(blankPlane);
planes.Add(blankPlane);
planesCopied.Add(false);
planesCopied.Add(false);
planesCopied.Add(false);
currentPlane += 3;
continue;
}
// If it's not all black, consider it in terms of each plane (B R G)
// plane is which color plane (0, 1, 2); currentPlane is the plane number overall
for (int plane = 0; plane < 3; plane++, currentPlane++)
{
// planeData is the integer representation of each line's data.
List<int> planeData = new List<int>();
//currentPlane++;
Console.WriteLine("Processing plane {0}. {1} plane at {2}", currentPlane, currentPlane % 3, (currentPlane / 3) * 8);
for (int height = 0; height < bmp.Height; height += 2)
{
int data = 0;
for (int dw = 0; dw < 8; dw++) // dw = difference in width; column in the block
{
// If the pixel's color contains a certain threshold of the plane's ideal RGB color, then it's part of that plane data.
// pure color -> ingame color
// #0000FF B -> #0066FF (lighter blue)
// #FF0000 R -> #FF6600 (burnt orange)
// #00FF00 G -> #00FF00 (same green)
if ((bmp.GetPixel(width + dw, height).B > 0) && plane == 0)
// If there's any blue at all, add the data to the blue plane
{
data |= 1 << (7 - dw);
}
if ((bmp.GetPixel(width + dw, height).R > 0) && plane == 1)
// if there's any red at all, add the data to the red plane
{
data |= 1 << (7 - dw);
}
if ((bmp.GetPixel(width + dw, height).G > 102) && plane == 2)
// If there's green, but not the mere 0x66 green mixed in the burnt orange/light blue, add it
{
data |= 1 << (7 - dw);
}
}
planeData.Add(data);
}
// if it's all zeros, just write 0x00 and call it a day
if (planeData.Sum() == 0)
{
Console.WriteLine("Best to just encode 0x00");
output.WriteByte((byte)0x00);
planes.Add(planeData);
planesCopied.Add(false);
continue;
}
// Now, we can compare this data to previous planes and see if we can just copy it.
// You can copy the previous plane (0x10? 0x14?) or the same color plane in the nth previous block (0x80?)
// Use a Hamming distance function. If it's small, you can probably use one of the plane copiers to grab that plane
// and add data with XOR.
int bestPlaneDistance = 99999;
int bestPlaneIndex = 99999;
if (planes.Any())
{
List<int> distances = new List<int>();
// using the 0x8N plane copier, you can only copy one of the most recent 15 planes.
int startPlane = (planes.Count > 15) ? planes.Count - 15 : 0;
for (int comparePlane = startPlane; comparePlane < planes.Count; comparePlane++)
{
if (planesCopied[comparePlane])
{
distances.Add(999);
continue;
}
int distance = 0;
for (int line = 0; line < planeData.Count; line++)
{
if (planes[comparePlane][line] != planeData[line])
{
distance++;
}
}
//Console.WriteLine("Distance from plane {0}: {1}", comparePlane, distance);
distances.Add(distance);
}
bestPlaneDistance = distances.Min();
bestPlaneIndex = startPlane + distances.IndexOf(bestPlaneDistance);
//Console.WriteLine("Best plane to copy would be {0}, which has distance {1}", bestPlaneIndex, bestPlaneDistance);
}
planes.Add(planeData);
int bestPlaneDiff = currentPlane - bestPlaneIndex;
if (bestPlaneDistance == 0 && bestPlaneIndex == planes.Count - 2)
{
Console.WriteLine("Just repeating the previous plane");
output.WriteByte((byte)0x10);
planesCopied.Add(true);
}
// if it's the same plane in a different block, and its diff is 0...
else if (bestPlaneDiff % 3 == 0 && bestPlaneDistance == 0)
{
Console.WriteLine("Copying plane {0}", bestPlaneIndex);
// From the decoder:
// CopyData(block - datab - 1, block, plane, plane);
// copy the same plane from the block (bottom nibble - 1) blocks prior to the current block
int nthPrevBlock = ((currentPlane - bestPlaneIndex) / 3) - 1;
Console.WriteLine(nthPrevBlock);
output.WriteByte((byte)(0x80 + nthPrevBlock));
output.WriteByte((byte)0xFF); // line
output.WriteByte((byte)0x00); // data
planesCopied.Add(true);
}
else
{
// Build an RLE version of the plane.
planesCopied.Add(false);
List<int?> planeRLE = new List<int?>();
int? runLengthData = null;
int runLength = 0;
int row = 0;
foreach (var data in planeData)
{
if (runLengthData == null)
{
runLengthData = data;
runLength = 1;
}
else
{
if (data == runLengthData)
{
runLength++;
}
else
{
// run length of 4 has its own prefix control code, due to collision with 0x04 plane definer.
if (runLength == 4)
{
planeRLE.Add(0xff);
planeRLE.Add(0x84);
planeRLE.Add(runLengthData);
row += 4;
}
else
{
// 0x04 only does run-length encoding on data that has two equal nibbles!! (often 0x00 or 0xFF)
byte dataUpper = (byte)(runLengthData >> 4);
byte dataLower = (byte)(runLengthData & 0xF);
//if (runLengthData >> 4 == (runLengthData & 0xF))
if (dataUpper == dataLower)
{
// Can't have a C byte in the upper byte of the run length.
// (Haven't really checked this yet.)
//byte lengthUpper = (byte)(runLength >> 4);
//if (lengthUpper == (byte)0xC)
//{
// Console.WriteLine("It's a C byte!");
// Console.WriteLine(runLength);
// if (runLength % 2 == 1)
// {
// Console.WriteLine(runLength / 2);
// planeRLE.Add(runLengthData);
// planeRLE.Add(runLength/2);
// planeRLE.Add(runLengthData);
// planeRLE.Add((runLength / 2) + 1);
// row += runLength;
// }
// else
// {
// planeRLE.Add(runLengthData);
// planeRLE.Add(runLength / 2);
// planeRLE.Add(runLengthData);
// planeRLE.Add(runLength / 2);
// row += runLength;
// }
// }
// Length can only go up to 7D; otherwise you need a 7E byte in front.
if (runLength > 0x7D)
{
Console.WriteLine("Length is pretty long, so use 2 bytes for the length");
planeRLE.Add(runLengthData);
planeRLE.Add(0x7e);
planeRLE.Add(runLength);
row += runLength;
Console.Write("{0} {1} {2}", runLengthData, 0x7e, runLength);
Console.WriteLine("");
}
else
{
planeRLE.Add(runLengthData);
planeRLE.Add(runLength);
row += runLength;
Console.Write("{0:X2} {1:X2} ", runLengthData, runLength);
Console.WriteLine("");
}
}
else
{
for (int i = 0; i < runLength; i++)
{
Console.WriteLine("{0:X2} ", runLengthData);
planeRLE.Add(runLengthData);
row += 1;
}
}
}
runLengthData = data;
runLength = 1;
}
}
}
// Add the last run as well, which is not caught in the above loop.
Console.WriteLine("");
planeRLE.Add(runLengthData);
if (runLength > 0x7D)
{
planeRLE.Add(0x7e);
planeRLE.Add(runLength);
}
else
{
planeRLE.Add(runLength);
}
Console.Write("{0:X2} {1:X2} ", runLengthData, runLength);
row += runLength;
Console.WriteLine("length: {0}", row);
// Finally, write the data to the output stream.
Console.WriteLine("writing RLE");
for (var i = 0; i < planeRLE.Count; i++)
{
Console.Write("{0:X2} ", (int)planeRLE[i]);
}
Console.WriteLine("");
output.WriteByte(0x04);
foreach (int d in planeRLE)
{
output.WriteByte((byte)d);
}
}
}
}
for (var i = 0; i < planesCopied.Count; i++)
{
Console.Write("{0}: {1} ", i, planesCopied[i]);
}
if (output.Length == 11)
{
// If it's just a header, it's probably misreading a scanlined image.
Console.WriteLine("Warning: Looks like the output image is blank.");
Console.WriteLine("If the input image has scanlines, try shifting it up or down a line.");
}
}
int height = 0;
bool wtf = false;
public override void ConvertFrom(Stream input, Stream output)
{
// Discarding 6 bytes that appears to always start with 0x88 0xE4
// They probably provide information but this program doesn't know how to deal with them
ReadInt16(input);
ReadInt16(input);
ReadInt16(input);
// Reading the width and height, which is then followed by the end of the "header"
// The last byte appears to always be 0x11
int width = ReadInt16(input);
height = ReadInt16(input);
input.ReadByte();
// The format encodes the image in a series of blocks that are 8 pixels wide and image height tall.
// Each block is seperated into three color planes that hold various instructions on what to draw.
// We initialize the buffer we will be writing to as three dimensional array of integers.
// Each integer represents an 8 pixel draw line at a certain height within a block's color plane.
int numberOfBlocks = width / 8;
pixels = new int[numberOfBlocks, 3, height];
// This is the buffer that will be used to save the file once we are done decoding
Bitmap bmp = new Bitmap(width, height * 2, PixelFormat.Format32bppRgb);
// A try finally is used to make sure we always dump the last image created into the file
// This is done since we don't know how to entirely decode the image at times and the
// program will fail. Dumping the last image allows us to see the progress it made.
try
{
long indexOfPrevPlane = 0;
long endOfPrevPlane = 0;
for (int block = 0; block < numberOfBlocks; block++)
{
for (int plane = 0; plane < 3; plane++)
{
indexOfPrevPlane = input.Position;
// Reads the encoding flag and splits it into nibbles
int data = input.ReadByte();
int datat = data >> 4;
int datab = data & 0x0F;
// Since the each plane is not a continous set of a data we have to keep track
// of the currrent line so we can write data in the correct area as well as keep
// within the bounds of the image
int curLine = 0;
// Use a boolean to notify of known errors that didn't cause the program to crash
bool error = false;
// The format allows an empty (black) plane to be encoded as 0x00
if (data == 0) continue;
wtf = false;
if ((datab & 0x8) == 0x8)
{
// copy the blue plane of this block
CopyData(block, block, 0, plane);
wtf = true;
}
datab &= ~0x8;
if (datat == 0xC)
{
CopyData(block - 1, block, plane, plane);
}
if ((datat & 0x1) == 0x1)
{
// if the flag begins with 0x1, copy the previous plane
// if current plane is the blue plane, that means copy the (green?) plane of the previous block
CopyData(block + (plane == 0 ? -1 : 0), block, (plane + 2) % 3, plane);
wtf = true;
}
datat &= ~0x1;
if (datat == 8)
{
Console.ForegroundColor = ConsoleColor.Yellow;
CopyData(block - datab - 1, block, plane, plane);
while (true)
{
int line = input.ReadByte();
data = input.ReadByte();
if (line >= height)
{
if (line == 0xFF) break;
WriteData(block, plane, line &= ~0x80, data, 1);
break;
}
WriteData(block, plane, line, data, 1);
}
goto print;
}
switch (datab)
{
case 0:
break;
case 2:
Console.ForegroundColor = ConsoleColor.Green;
while (curLine < height)
{
data = input.ReadByte();
datat = (data & 0xF0) >> 4;
datab = data & 0xF;
datab = datab == 0xE ? input.ReadByte() : datab;
if (datat == 0x3)
{
WriteData(block, plane, curLine, input, datab + 1);
}
else if (datat != 0x0)
{
switch (datat)
{
case 2:
data = input.ReadByte();
break;
case 4:
case 5:
case 6:
case 7:
datat -= 0x02;
input.Position -= datat;
data = input.ReadByte();
input.Position += datat - 1;
break;
case 8:
data = 0xFF;
break;
case 0xA:
data = 0xC0;
break;
default:
error = true;
Console.WriteLine("2NR" + datat);
break;
}
WriteData(block, plane, curLine, data, datab + 1);
}
curLine += datab + 1;
}
break;
case 3:
data = input.ReadByte();
WriteData(block, plane, 0, data, height);
break;
case 4:
// description of the 0x04 plane encoding
Console.ForegroundColor = ConsoleColor.Cyan;
while (curLine < height)
{
data = input.ReadByte(); // first byte: direct binary representation of a line
datat = (data & 0xF0) >> 4; // upper nibble
datab = data & 0x0F; // lower nibble
int count = 1;
// Checking if nibbles equal each other
if (datat == datab)
{
count = input.ReadByte();
// WTF shifting thing ???
if ((count & 0xF0) == 0xC0)
{
count -= 0xC0;
if (data == 0xFF)
data = input.ReadByte();
if (data == 0x00)
{
// This obviously doesn't work for the rotate thing
data = (input.ReadByte() << 8) | input.ReadByte();
count *= 2;
}
for (int x = 0; x < count; x++)
{
WriteData(block, plane, curLine + x, data, 1);
datab = (data & 0x1) << 7; // Rotate left 1
data = (data >> 1) | datab;
}
curLine += count;
continue;
}
// Repeat a direct write
if ((count & 0x80) == 0x80)
{
count -= 0x80;
switch (datab)
{
case 0:
data = (input.ReadByte() << 8) | input.ReadByte();
count *= 2;
break;
case 5:
data = 0x55AA;
break;
case 0xA:
data = 0xAA55;
break;
case 0xF:
data = input.ReadByte();
break;
default:
error = true;
Console.WriteLine("4NR" + datab);
break;
}
}
count = count == 0x7E ? input.ReadByte() : count;
}
WriteData(block, plane, curLine, data, count);
curLine += count;
}
break;
case 6:
Console.ForegroundColor = ConsoleColor.Blue;
while (curLine < height)
{
data = input.ReadByte();
datat = (data & 0xF0) >> 4;
datab = data & 0x0F;
if (data == 0)
{
datat = input.ReadByte();
datat = ((datat & 0x80) == 0x80 ? datat - 0x80 : datat) * 2;
data = (input.ReadByte() << 8) | input.ReadByte();
WriteData(block, plane, curLine, data, datat);
goto end6;
}
// Checking for direct write
if (datat == 0)
{
datat = datab == 0xE ? input.ReadByte() : datab;
WriteData(block, plane, curLine, input, datat);
goto end6;
}
// Getting actual length if value is greater than 0xD
if (datat == 0xE)
{
datat = datab;
data = input.ReadByte();
datab = data & 0x0F;
datat = (datat << 4) | (data >> 4);
}
// Finding pattern
switch (datab)
{
case 0:
data = 0x00;
break;
case 1:
data = 0x22;
break;
case 2:
data = 0x55;
break;
case 3:
data = 0x77;
break;
case 4:
data = 0xFF;
break;
case 5:
data = 0xDD;
break;
case 6:
data = 0xAA;
break;
case 7:
data = input.ReadByte();
break;
case 9:
data = 0x2288;
break;
case 0xA:
data = 0x55AA;
break;
case 0xB:
data = 0x77DD;
break;
case 0xD:
data = 0xDD77;
break;
case 0xE:
data = 0xAA55;
break;
case 0xF:
data = input.ReadByte();
for (int x = 0; x < datat; x++)
{
WriteData(block, plane, curLine + x, data, 1);
datab = (data & 0x3) << 6; // Rotate left 2
data = (data >> 2) | datab;
}
goto end6;
default:
error = true;
Console.WriteLine("NR" + datab);
break;
}
WriteData(block, plane, curLine, data, datat);
end6: curLine += datat;
}
break;
default:
error = true;
break;
}
print: endOfPrevPlane = input.Position;
if (error)
Console.ForegroundColor = ConsoleColor.Red;
input.Position = indexOfPrevPlane;
char[] s = ReadStringU(input, (int)(endOfPrevPlane - indexOfPrevPlane)).ToCharArray();
Console.Write("{0:D2} : ", block);
for (int x = 0; x < s.Length; x++)
{
Console.Write("{0:X2} ", (int)s[x]);
}
Console.WriteLine();
input.Position = endOfPrevPlane;
Console.ForegroundColor = ConsoleColor.White;
for (int b = 0; b < numberOfBlocks; b++)
for (int p = 0; p < 3; p++)
for (int l = 0; l < height; l++)
{
data = pixels[b, p, l];
for (int d = 7; d >= 0; d--, data >>= 1)
if (data % 2 == 1)
{
Color oldc = bmp.GetPixel(b * 8 + d, l * 2);
// take the binary or of what's already there and the current plane color
Color newc = Color.FromArgb(oldc.ToArgb() | GetColor(p));
bmp.SetPixel(b * 8 + d, l * 2, newc);
}
}
Directory.CreateDirectory("test/");
Stream output2 = new FileStream("test/b" + block.ToString("D3") + "p" + plane + ".png", FileMode.Create);
bmp.Save(output2, ImageFormat.Png);
output2.Close();
}
}
}
finally
{
for (int b = 0; b < numberOfBlocks; b++)
for (int p = 0; p < 3; p++)
for (int l = 0; l < height; l++)
{
int data = pixels[b, p, l];
for (int d = 7; d >= 0; d--, data >>= 1)
if (data % 2 == 1)
{
Color oldc = bmp.GetPixel(b * 8 + d, l * 2);
Color newc = Color.FromArgb(oldc.ToArgb() | GetColor(p));
bmp.SetPixel(b * 8 + d, l * 2, newc);
}
}
bmp.Save(output, ImageFormat.Png);
}
}
int[,,] pixels;
public int GetColor(int plane)
{
unchecked
{
if (plane == 0)
// Values are used in FromArgb / ToArgb.
// lighter blue
return (int)0xFF0066FF;
if (plane == 1)
// burnt orange
return (int)0xFFFF6600;
if (plane == 2)
// normal green
return (int)0xFF00FF00;
return (int)0xFFFFFFFF;
}
}
public void WriteData(int block, int plane, int line, int data, int count)
{
if (wtf)
// wtf indeed!
{
// hmm. when does this apply? data should be 0xFF at its highest, right?
if ((data & 0xFF00) > 0)
{
for (int l = 0; l < count / 2; l++)
{
pixels[block, plane, line + l * 2] ^= (data & 0xFF00) >> 8;
pixels[block, plane, line + l * 2 + 1] ^= data & 0xFF;
}
if (count % 2 == 1)
pixels[block, plane, line + count - 1] ^= (data & 0xFF00) >> 8;
return;
}
for (int l = 0; l < count; l++)
{
// use the bitwise logical XOR between the data and... what's already there??
// oh yeah, the plane that got copied with CopyData.
pixels[block, plane, line + l] ^= data;
}
}
else
{
if ((data & 0xFF00) > 0)
{
for (int l = 0; l < count / 2; l++)
{
pixels[block, plane, line + l * 2] = (data & 0xFF00) >> 8;
pixels[block, plane, line + l * 2 + 1] = data & 0xFF;
}
if (count % 2 == 1)
pixels[block, plane, line + count - 1] = (data & 0xFF00) >> 8;
return;
}
for (int l = 0; l < count; l++)
{
pixels[block, plane, line + l] = data;
}
}
}
public void WriteData(int block, int plane, int line, Stream input, int count)
{
for (int l = 0; l < count; l++)
{
if (wtf)
{
pixels[block, plane, line + l] ^= input.ReadByte();
}
else
{
pixels[block, plane, line + l] = input.ReadByte();
}
}
}
public void CopyData(int b1, int b2, int p1, int p2)
{
for (int l = 0; l < height; l++)
{
pixels[b2, p2, l] ^= pixels[b1, p1, l];
}
}
public void CopyData(int b1, int b2)
{
for (int p = 0; p < 3; p++)
{
for (int l = 0; l < height; l++)
{
pixels[b2, p, l] = pixels[b1, p, l];
}
}
}
}
}