-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDMD.cpp
More file actions
5240 lines (4815 loc) · 168 KB
/
DMD.cpp
File metadata and controls
5240 lines (4815 loc) · 168 KB
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
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// DMD.cpp : implementation file
//
#include "stdafx.h"
#include "defines.h"
#include "HexEditor.h"
#include "DMD.h"
#include "hexeditordoc.h"
#include "hexeditorview.h"
#include "mybutton.h"
#include "nagdlg.h"
#include "version.h"
time_t actTime;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ALLOW_MOUSE_TO_REPEAT (0)
//
// WPC Games
// -----------------------------------------------------------------------
// Addams Family L5, H4
// Addams Family Gold H3
// Attack From Mars 1.13
// Black Rose L3
// Cactus Canyon 1.3 **8 MEG**
// Champion Pub 1.6
// Cirqus Voltaire 1.4 **8 MEG**
// Congo 2.1
// Corvette 2.1
// Creature from the black lagoon L4
// Demolition Man LX4
// Dirty Harry LX2
// Dracula L1
// Dr. Who L2
// Fish Tales L5
// Flintstones LX5
// Gilligans Island L9
// Getaway High Speed II L5
// Hurricane L2
// Indiana Jones L7
// Indianopolis 500 1.1R
// Jackbot 1.0R
// Johnny Mnemonic 1.2R
// Judge Dredd L7
// Junkyard 1.2
// Medievil Madness 1.09H **8 MEG**
// Monster Bash 1.06
// NBA Fastbreak 3.1
// No Fear 2.3X
// No Good Gofers 1.3
// Popeye LX5
// Roadshow L6
// Safe Cracker 1.8G
// Scared Stiff 1.5
// Shadow LX6
// Slugfest L1
// Star Trek Next Generation L7
// Tales of the Arabian Nights 1.4
// Terminator 2 L8
// Theater of Magic 1.3
// Ticket Tac Toe 1.0
// Twilight Zone 9.4H
// White Water L5
// Who Dunnit 1.2
// World Cup Soccer LX2
//
//
// WPC, but no DMD!
// ----------------
// Dr. Dude
// Funhouse
// Harley Davidson
// League Champ
// Party Zone
// Strike Master
// The Machine Bride of Pinbot
//
//
//
//
/////////////////////////////////////////////////////////////////////////////
// DMD dialog
DMD::DMD(CWnd* pParent /*=NULL*/,RegistrySettings *mainptr, int DialogType)
: CDialog(DMD::IDD, pParent)
{
PassedInPointer = mainptr;
NaggedOnce = 0;
dialogType = DialogType;
//{{AFX_DATA_INIT(DMD)
//}}AFX_DATA_INIT
}
DMD::~DMD()
{
}
void DMD::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DMD)
DDX_Control(pDX, IDC_BUTTON_WIPE, m_Wipe);
DDX_Control(pDX, IDC_BUTTON_PREVIOUS_GRAPHICX2, m_PreviousGraphicX2);
DDX_Control(pDX, IDC_BUTTON_NEXT_GRAPHICX2, m_NextGraphicX2);
DDX_Control(pDX, IDC_CHECK_EXPORT, m_Export);
DDX_Control(pDX, IDC_STATIC_DMD3_HEADER, m_Dmd3Title);
DDX_Control(pDX, IDC_STATIC_DMD2_HEADER, m_Dmd2Title);
DDX_Control(pDX, IDC_STATIC_DMD1_HEADER, m_Dmd1Title);
DDX_Control(pDX, IDC_SPIN1, m_Spin);
DDX_Control(pDX, IDC_LIST1, m_PixelColor);
DDX_Control(pDX, IDC_CHECK_XORED, m_Xored);
DDX_Control(pDX, IDC_CHECK_SKIPPED, m_Skipped);
DDX_Control(pDX, IDC_STATIC_DMD1_TEXTBOX, m_Dmd1);
DDX_Control(pDX, IDC_STATIC_DMD2_TEXTBOX, m_Dmd2);
DDX_Control(pDX, IDC_STATIC_DMD3_TEXTBOX, m_Dmd3);
DDX_Control(pDX, IDC_BUTTON_NEXT_GRAPHIC, m_NextGraphic);
DDX_Control(pDX, IDC_BUTTON_PREVIOUS_GRAPHIC, m_PreviousGraphic);
DDX_Control(pDX, IDC_STATIC_USERREG, m_UserReg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DMD, CDialog)
//{{AFX_MSG_MAP(DMD)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_NEXT_GRAPHIC, OnButtonNextGraphic)
ON_BN_CLICKED(IDC_BUTTON_PREVIOUS_GRAPHIC, OnButtonPreviousGraphic)
ON_BN_CLICKED(IDC_CHECK_SKIPPED, OnCheckSkipped)
ON_BN_CLICKED(IDC_CHECK_XORED, OnCheckXored)
ON_BN_CLICKED(IDC_CHECK_EXPORT, OnCheckExport)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
ON_WM_SHOWWINDOW()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_BN_CLICKED(IDC_BUTTON_NEXT_GRAPHICX2, OnButtonNextGraphicx2)
ON_BN_CLICKED(IDC_BUTTON_PREVIOUS_GRAPHICX2, OnButtonPreviousGraphicx2)
ON_BN_CLICKED(IDC_BUTTON_WIPE, OnButtonWipe)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DMD message handlers
BOOL DMD::Create()
{
return CDialog::Create(DMD::IDD);
}
BOOL DMD::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
return CDialog::Create(IDD, pParentWnd);
}
int DMD::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
{
return -1;
}
return 0;
}
void DMD::OnDestroy()
{
CDialog::OnDestroy();
}
void DMD::DebugKeyMsgStrPrint(CString str, int KeyMask)
{
if (debugKeyBitmask & KeyMask)
{
if (AfxMessageBox(str,(MB_OKCANCEL | MB_ICONQUESTION)) == IDCANCEL)
{
// 'Cancel' stops further debug messages
debugKeyBitmask &= ~KeyMask;
}
}
}
void DMD::DebugShiftKeyMsgStrPrint(CString str)
{
DebugKeyMsgStrPrint(str, DEBUG_KEY_BIT_SHIFTKEYS);
}
void DMD::DebugControlKeyMsgStrPrint(CString str)
{
DebugKeyMsgStrPrint(str, DEBUG_KEY_BIT_CONTROLKEYS);
}
BOOL DMD::OnInitDialog()
{
int WindowVerticalShift = 0;
int WindowHorizontalShift = 0;
CDialog::OnInitDialog();
m_PixelColor.AddString("Black&White");
m_PixelColor.AddString("Red");
m_PixelColor.AddString("Yellow");
m_PixelColor.AddString("Green");
m_PixelColor.AddString("Teal");
m_PixelColor.AddString("Blue");
m_PixelColor.AddString("Violet");
m_PixelColor.SetTopIndex(PassedInPointer->PixelColor);
m_Spin.SetPos(PassedInPointer->PixelColor);
/* // default: no checkbox, We now save previous frame pixel data
m_Xored.SetCheck(PassedInPointer->XoredCheckboxState);
m_Skipped.SetCheck(PassedInPointer->SkippedCheckboxState);
*/
CString RegString;
RegString.Format("%s %.1f %s %s",APPLICATION_TITLE,APPLICATION_VERSION,APPLICATION_COPYRIGHT,APPLICATION_AUTHOR);
m_UserReg.SetWindowText(RegString);
switch (dialogType)
{
case DMD_DIALOG_TYPE_GRAPHICS:
SetWindowText("Dot Matrix Display, Full Frame Graphic Data");
GetDlgItem(IDC_STATIC_DMD1_HEADER)->SetWindowText("Medium Pixels Plane");
GetDlgItem(IDC_STATIC_DMD2_HEADER)->SetWindowText("Dim Pixels Plane");
GetDlgItem(IDC_STATIC_DMD3_HEADER)->SetWindowText("Blended Planes");
GetDlgItem(IDC_BUTTON_PREVIOUS_GRAPHIC)->SetWindowText("<- Prev");
GetDlgItem(IDC_BUTTON_NEXT_GRAPHIC)->SetWindowText("Next ->");
GetDlgItem(IDC_CHECK_XORED)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_CHECK_SKIPPED)->ShowWindow(SW_SHOW);
WindowVerticalShift = 30;
WindowHorizontalShift = 20;
break;
case DMD_DIALOG_TYPE_FONTDATA:
SetWindowText("Dot Matrix Display, Font Data");
GetDlgItem(IDC_BUTTON_PREVIOUS_GRAPHIC)->SetWindowText("<--Previous Char");
GetDlgItem(IDC_BUTTON_NEXT_GRAPHIC)->SetWindowText("Next Char -->");
GetDlgItem(IDC_CHECK_XORED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_SKIPPED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_XORED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_SKIPPED)->ShowWindow(SW_HIDE);
WindowVerticalShift = 80;
WindowHorizontalShift = 60;
break;
case DMD_DIALOG_TYPE_ANIDATA:
SetWindowText("Dot Matrix Display, Animation Data");
GetDlgItem(IDC_BUTTON_PREVIOUS_GRAPHIC)->SetWindowText("<--Previous Frame");
GetDlgItem(IDC_BUTTON_NEXT_GRAPHIC)->SetWindowText("Next Frame -->");
GetDlgItem(IDC_CHECK_XORED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_SKIPPED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_XORED)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CHECK_SKIPPED)->ShowWindow(SW_HIDE);
WindowVerticalShift = 130;
WindowHorizontalShift = 100;
break;
default:
AfxMessageBox("Error, unrecognized dialogType!");
break;
}
if ((WindowHorizontalShift != 0) || (WindowVerticalShift != 0))
{
WINDOWPLACEMENT wp;
if (GetWindowPlacement(&wp))
{
SetWindowPos(NULL, (wp.rcNormalPosition.left + WindowHorizontalShift), (wp.rcNormalPosition.top + WindowVerticalShift),0,0,SWP_NOSIZE);
}
}
// m_PreviousGraphicX2.SetWindowText("2<<");
// m_NextGraphicX2.SetWindowText(">>2");
m_PreviousGraphicX2.SetIcon(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON3)));
m_NextGraphicX2.SetIcon(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON2)));
m_Wipe.SetIcon(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON1)));
m_Wipe.EnableWindow(FALSE);
bWiped = FALSE;
#if ALLOW_MOUSE_TO_REPEAT
TimerIDDMD = SetTimer(TIMER_DMD, TIMER_DMD_UPDATE, NULL);
NextDebounce =
PreviousDebounce = 0;
NextDebounceState =
PreviousDebounceState = DEBOUNCE_STATE_IDLE;
#endif
// init clipboard selector
selectedTitleBox = 0;
memset(PreviousPlaneDataPane0,0,sizeof(PreviousPlaneDataPane0));
memset(PreviousPlaneDataPane1,0,sizeof(PreviousPlaneDataPane1));
UpdateControls();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DMD::PaintDMDPanelImage(CPaintDC *pDc, DMDPlanes* pPlanes, unsigned char PaneMask)
{
int i,j,k;
int RowIndex, ColumnIndex;
ThisPixel thisPixel0;
ThisPixel thisPixel1;
unsigned char ReadMask;
unsigned char PLANE_BITS;
unsigned char *Plane_0Ptr = pPlanes->Plane0.Plane_Data;
unsigned char *Plane_0XorFlags = pPlanes->Plane0.Plane_XorFlags;
unsigned char *Plane_0XorBits = pPlanes->Plane0.Plane_XorBits;
unsigned char *Plane_0Skipped = pPlanes->Plane0.Plane_Skipped;
unsigned char *Plane_1Ptr = pPlanes->Plane1.Plane_Data;
unsigned char *Plane_1XorFlags = pPlanes->Plane1.Plane_XorFlags;
unsigned char *Plane_1XorBits = pPlanes->Plane1.Plane_XorBits;
unsigned char *Plane_1Skipped = pPlanes->Plane1.Plane_Skipped;
unsigned char *Plane_0Previous = PreviousPlaneDataPane0;
unsigned char *Plane_1Previous = PreviousPlaneDataPane1;
unsigned char XoredCheck = m_Xored.GetCheck();
unsigned char SkippedCheck = m_Skipped.GetCheck();
BOOL bAnyXoredPixel = FALSE;
BOOL bAnySkippedPixel = FALSE;
const int PixelColorIDs[PIXEL_COLORS][PIXEL_SHADES] =
{
IDB_BITMAP_PIXEL_GREYDIM,
IDB_BITMAP_PIXEL_GREYMEDIUM,
IDB_BITMAP_PIXEL_GREYBRIGHT,
IDB_BITMAP_PIXEL_REDDIM,
IDB_BITMAP_PIXEL_REDMEDIUM,
IDB_BITMAP_PIXEL_REDBRIGHT,
IDB_BITMAP_PIXEL_YELLOWDIM,
IDB_BITMAP_PIXEL_YELLOWMEDIUM,
IDB_BITMAP_PIXEL_YELLOWBRIGHT,
IDB_BITMAP_PIXEL_GREENDIM,
IDB_BITMAP_PIXEL_GREENMEDIUM,
IDB_BITMAP_PIXEL_GREENBRIGHT,
IDB_BITMAP_PIXEL_TEALDIM,
IDB_BITMAP_PIXEL_TEALMEDIUM,
IDB_BITMAP_PIXEL_TEALBRIGHT,
IDB_BITMAP_PIXEL_BLUEDIM,
IDB_BITMAP_PIXEL_BLUEMEDIUM,
IDB_BITMAP_PIXEL_BLUEBRIGHT,
IDB_BITMAP_PIXEL_VIOLETDIM,
IDB_BITMAP_PIXEL_VIOLETMEDIUM,
IDB_BITMAP_PIXEL_VIOLETBRIGHT
};
CDC hOff;
CDC hXored;
CDC hSkipped;
CDC hMedium;
CDC hDim;
CDC hBright;
j = 0;
j += hOff.CreateCompatibleDC(NULL);
j += hXored.CreateCompatibleDC(NULL);
j += hSkipped.CreateCompatibleDC(NULL);
j += hDim.CreateCompatibleDC(NULL);
j += hMedium.CreateCompatibleDC(NULL);
j += hBright.CreateCompatibleDC(NULL);
if (j != 6)
{
AfxMessageBox("Problem loading pixels.");
return;
}
// Init clipboard variables
LPTSTR cbData=NULL;
LPTSTR cbPtr=NULL;
char cbPixel0=0; // temporarily using as a flag to indicate if we want to use clipboard
char cbPixel1;
char cbPixel2;
switch (selectedTitleBox)
{
case 1:
if (PaneMask & DMD_FULLFRAME_PAINT_MEDIUM)
{
cbPixel0++; // flag that we want to use clipboard
}
break;
case 2:
if (PaneMask & DMD_FULLFRAME_PAINT_DIM)
{
cbPixel0++; // flag that we want to use clipboard
}
break;
case 3:
if (PaneMask & DMD_FULLFRAME_PAINT_BLENDED)
{
cbPixel0++; // flag that we want to use clipboard
}
break;
default:
break;
}
if ((cbPixel0 != 0) && (OpenClipboard()) && (EmptyClipboard()))
{
cbPtr = cbData = (LPTSTR)LocalAlloc(LPTR,(((DMD_COLUMNS+2)*DMD_ROWS)+1)); // +2 for the newline & linefeed (/r/n) +1 for trailing NULL
}
CBitmap BMOff;
CBitmap BMXored;
CBitmap BMSkipped;
CBitmap BMDim;
CBitmap BMMedium;
CBitmap BMBright;
i = m_PixelColor.GetTopIndex();
if (i > PIXEL_COLORS)
{
i = PIXEL_COLORS;
}
j = 0;
j += BMOff.LoadBitmap(IDB_BITMAP_PIXEL_BLACK);
if (i == NORMAL_XORED_COLOR)
{
j += BMXored.LoadBitmap(PixelColorIDs[ALTERNATE_XORED_COLOR][PIXEL_SHADE_BRIGHT]);
}
else
{
j += BMXored.LoadBitmap(PixelColorIDs[NORMAL_XORED_COLOR][PIXEL_SHADE_BRIGHT]);
}
if (i == NORMAL_SKIPPED_COLOR)
{
j += BMSkipped.LoadBitmap(PixelColorIDs[ALTERNATE_SKIPPED_COLOR][PIXEL_SHADE_DIM]);
}
else
{
j += BMSkipped.LoadBitmap(PixelColorIDs[NORMAL_SKIPPED_COLOR][PIXEL_SHADE_DIM]);
}
j += BMDim.LoadBitmap(PixelColorIDs[i][PIXEL_SHADE_DIM]);
j += BMMedium.LoadBitmap(PixelColorIDs[i][PIXEL_SHADE_MEDIUM]);
j += BMBright.LoadBitmap(PixelColorIDs[i][PIXEL_SHADE_BRIGHT]);
if (j != 6)
{
AfxMessageBox("Problem loading pixel bitmaps.");
return;
}
j = 0;
CBitmap *old_hOff = hOff.SelectObject(&BMOff);
if (old_hOff)
{
j++;
}
CBitmap *old_hXored = hXored.SelectObject(&BMXored);
if (old_hXored)
{
j++;
}
CBitmap *old_hSkipped = hSkipped.SelectObject(&BMSkipped);
if (old_hSkipped)
{
j++;
}
CBitmap *old_hDim = hDim.SelectObject(&BMDim);
if (old_hDim)
{
j++;
}
CBitmap *old_hMedium = hMedium.SelectObject(&BMMedium);
if (old_hMedium)
{
j++;
}
CBitmap *old_hBright = hBright.SelectObject(&BMBright);
if (old_hBright)
{
j++;
}
if (j != 6)
{
AfxMessageBox("Problem loading pixel bitmap objects.");
return;
}
for (i = 0; i < DMD_ROWS; i++)
{
for (j = 0; j < (DMD_COLUMNS/8); j++)
{
for (ReadMask = 0x01, k = 0; k < 8; k++,ReadMask <<= 1)
{
PLANE_BITS = 0x00;
if (*Plane_0Ptr & ReadMask)
{
PLANE_BITS |= PLANE0_ON;
}
if (*Plane_0Skipped & ReadMask)
{
PLANE_BITS |= PLANE0_SKIPPED;
}
if (*Plane_0XorFlags & ReadMask)
{
if (*Plane_0XorBits & ReadMask)
{
PLANE_BITS |= PLANE0_XORED; // XOR flag <and> XOR bit then flip bit from previous display
}
else
{
PLANE_BITS |= PLANE0_SKIPPED; // XOR flag <and NOT> XOR bit, then treat it as a skip
}
}
if (*Plane_1Ptr & ReadMask)
{
PLANE_BITS |= PLANE1_ON;
}
if (*Plane_1Skipped & ReadMask)
{
PLANE_BITS |= PLANE1_SKIPPED;
}
if (*Plane_1XorFlags & ReadMask)
{
if (*Plane_1XorBits & ReadMask)
{
PLANE_BITS |= PLANE1_XORED; // XOR flag <and> XOR bit then flip bit from previous display
}
else
{
PLANE_BITS |= PLANE1_SKIPPED; // XOR flag <and NOT> XOR bit, then treat it as a skip
}
}
// Quick check if we have any xor or skipped pixels
if ((PLANE_BITS & (PLANE0_SKIPPED | PLANE1_SKIPPED)) && !SkippedCheck)
{
bAnySkippedPixel = TRUE;
}
if ((PLANE_BITS & (PLANE0_XORED | PLANE1_XORED)) && !XoredCheck)
{
bAnyXoredPixel = TRUE;
}
//
ColumnIndex = ((((j * 8) + k)) * PIXEL_WIDTH);
RowIndex = (i * PIXEL_HEIGHT);
//
// Determine what color to show for medium colored plane
//
if (PaneMask & DMD_FULLFRAME_PAINT_DIM)
{
thisPixel0 = ThisPixel_Off;
if (PLANE_BITS & PLANE0_ON)
{
thisPixel0 = ThisPixel_On;
}
else if (PLANE_BITS & PLANE0_SKIPPED)
{
if (SkippedCheck)
{
thisPixel0 = ThisPixel_Skipped;
}
else if (*Plane_0Previous & ReadMask)
{
thisPixel0 = ThisPixel_On;
}
}
else if (PLANE_BITS & PLANE0_XORED)
{
if (XoredCheck)
{
thisPixel0 = ThisPixel_Xored;
}
else if (!(*Plane_0Previous & ReadMask))
{
thisPixel0 = ThisPixel_On;
}
}
switch (thisPixel0)
{
case ThisPixel_Off:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hOff,0,0,SRCCOPY);
cbPixel0 = '0'; // pixel off
break;
case ThisPixel_On:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hMedium,0,0,SRCCOPY);
cbPixel0 = '2'; // medium pixel on
break;
case ThisPixel_Xored:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hXored,0,0,SRCCOPY);
cbPixel0 = 'x'; // xored pixel, user has XOR checkbox checked
break;
case ThisPixel_Skipped:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hSkipped,0,0,SRCCOPY);
cbPixel0 = '_'; // skipped pixel, user has SKIPPED checkbox checked
break;
default:
break;
}
}
RowIndex += ((DMD_ROWS + 1) * PIXEL_HEIGHT);
//
// Determine what color to show for dim plane
//
if (PaneMask & DMD_FULLFRAME_PAINT_MEDIUM)
{
thisPixel1 = ThisPixel_Off;
if (PLANE_BITS & PLANE1_ON)
{
thisPixel1 = ThisPixel_On;
}
else if (PLANE_BITS & PLANE1_SKIPPED)
{
if (SkippedCheck)
{
thisPixel1 = ThisPixel_Skipped;
}
else if (*Plane_1Previous & ReadMask)
{
thisPixel1 = ThisPixel_On;
}
}
else if (PLANE_BITS & PLANE1_XORED)
{
if (XoredCheck)
{
thisPixel1 = ThisPixel_Xored;
}
else if (!(*Plane_1Previous & ReadMask))
{
thisPixel1 = ThisPixel_On;
}
}
switch (thisPixel1)
{
case ThisPixel_Off:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hOff,0,0,SRCCOPY);
cbPixel1 = '0'; // pixel off
break;
case ThisPixel_On:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hDim,0,0,SRCCOPY);
cbPixel1 = '1'; // dim pixel on
break;
case ThisPixel_Xored:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hXored,0,0,SRCCOPY);
cbPixel1 = 'x'; // xored pixel, user has XOR checkbox checked
break;
case ThisPixel_Skipped:
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hSkipped,0,0,SRCCOPY);
cbPixel1 = '_'; // skipped pixel, user has SKIPPED checkbox checked
break;
default:
break;
}
}
// Save "previous" frame data
if (thisPixel0 == ThisPixel_Off)
{
*Plane_0Previous &= ~ReadMask;
}
else if (thisPixel0 == ThisPixel_On)
{
*Plane_0Previous |= ReadMask;
}
if (thisPixel1 == ThisPixel_Off)
{
*Plane_1Previous &= ~ReadMask;
}
else if (thisPixel1 == ThisPixel_On)
{
*Plane_1Previous |= ReadMask;
}
RowIndex += ((DMD_ROWS + 1) * PIXEL_HEIGHT);
//
// Determine what color to show for blended plane
//
if (PaneMask & DMD_FULLFRAME_PAINT_BLENDED)
{
if ((thisPixel0 == ThisPixel_On) && (thisPixel1 == ThisPixel_On))
{
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hBright,0,0,SRCCOPY);
cbPixel2 = '3'; // pixel bright
}
else if (thisPixel0 == ThisPixel_On)
{
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hMedium,0,0,SRCCOPY);
cbPixel2 = '2'; // pixel medium
}
else if (thisPixel1 == ThisPixel_On)
{
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hDim,0,0,SRCCOPY);
cbPixel2 = '1'; // pixel dim
}
else
{
pDc->BitBlt(ColumnIndex,RowIndex,PIXEL_WIDTH,PIXEL_HEIGHT,&hOff,0,0,SRCCOPY);
cbPixel2 = '0'; // pixel off
}
}
// if clipboard operation is in use, push the cbPixel to clipboard ram
if (cbPtr != NULL)
{
switch (selectedTitleBox)
{
case 1:
*cbPtr++ = cbPixel0;
break;
case 2:
*cbPtr++ = cbPixel1;
break;
case 3:
*cbPtr++ = cbPixel2;
break;
default:
break;
}
}
}
Plane_0Ptr++;
Plane_1Ptr++;
Plane_0Skipped++;
Plane_1Skipped++;
Plane_0XorFlags++;
Plane_1XorFlags++;
Plane_0XorBits++;
Plane_1XorBits++;
Plane_0Previous++;
Plane_1Previous++;
}
// Add newline for clipboard operation
if (cbPtr != NULL)
{
*cbPtr++ = '\r';
*cbPtr++ = '\n';
}
}
// Add trailing null for clipboard operations
if (cbPtr != NULL)
{
*cbPtr++ = NULL;
}
hOff.SelectObject(old_hOff);
hXored.SelectObject(old_hXored);
hSkipped.SelectObject(old_hSkipped);
hDim.SelectObject(old_hDim);
hMedium.SelectObject(old_hMedium);
hBright.SelectObject(old_hBright);
// Finish up clipboard operation
if ((cbData != NULL) && (::SetClipboardData( CF_TEXT, cbData ) != NULL ))
{
// ...
CloseClipboard();
}
// We know the "Previous" data has been filled in, so make sure the Wipe button is enabled
m_Wipe.EnableWindow((((bAnySkippedPixel == TRUE) || (bAnyXoredPixel == TRUE)) && (bWiped != TRUE)) ? TRUE : FALSE);
}
void DMD::OnPaint()
{
CPaintDC dc(this); // device context for painting
switch (dialogType)
{
case DMD_DIALOG_TYPE_GRAPHICS:
UpdateCheckboxText();
PaintDMDPanelImage(&dc, &FullFrameImageData.Planes, DMD_FULLFRAME_PAINT_DIM | DMD_FULLFRAME_PAINT_MEDIUM | DMD_FULLFRAME_PAINT_BLENDED);
break;
case DMD_DIALOG_TYPE_FONTDATA:
case DMD_DIALOG_TYPE_ANIDATA:
// Paint image data Panes 1 & 2, Paint blended image pane only if Plane1 status is valid
PaintDMDPanelImage(&dc, &VariableSizedImageData.Planes, DMD_FULLFRAME_PAINT_DIM | DMD_FULLFRAME_PAINT_MEDIUM | (VariableSizedImageData.Planes.Plane1.Plane_Status==PLANE_STATUS_VALID? DMD_FULLFRAME_PAINT_BLENDED:0));
// Paint Pane 3 with the single bi-colored graphic image we loaded at init only if VariableSizedImageData Plane1 is invalid
if (VariableSizedImageData.Planes.Plane1.Plane_Status != PLANE_STATUS_VALID)
{
PaintDMDPanelImage(&dc, &FullFrameImageData.Planes, DMD_FULLFRAME_PAINT_BLENDED);
}
break;
default:
break;
}
}
int DMD::PreAnalyzeVariableSizedImageTable()
{
LPTSTR Ptr;
unsigned long Addr;
int TableCount = 0;
// Standard validations and sanity checks
if (!VariableSizedImageData.TableAddress)
{
TmpStr.Format("Unexpected NULL VariableSizedImageData.TableAddress");
DebugControlKeyMsgStrPrint(TmpStr);
}
if (VariableSizedImageData.TableAddress >= CommonData.ROMSize)
{
TmpStr.Format("Unexpected table address 0x%x is >= ROMSize 0x%x",VariableSizedImageData.TableAddress,CommonData.ROMSize);
DebugControlKeyMsgStrPrint(TmpStr);
}
Ptr = &CommonData.StartPtr[VariableSizedImageData.TableAddress];
// We're now at the start of the table, lets count up the number table entries
while (GetROMAddressFromAddrOf3ByteWPCAddrPage(Ptr,&Addr) == 0)
{
VariableSizedImageData.maxTableIndex++;
if (GetLastImageIndex(NULL, (VariableSizedImageData.maxTableIndex-1)) != 0)
{
VariableSizedImageData.maxTableIndex--;
TmpStr.Format("Stopped looking for image tables due to GetLastImageIndex() error on TableIndex %d",VariableSizedImageData.maxTableIndex);
DebugControlKeyMsgStrPrint(TmpStr);
break;
}
Ptr += 3;
TableCount++;
}
//TmpStr.Format("Determined TableCount: %d",TableCount);
//DebugControlKeyMsgStrPrint(TmpStr);
if (TableCount == 0)
{
TmpStr.Format("Found 0 table entries");
AfxMessageBox(TmpStr);
return -1;
}
// Last 0-based, valid, image table index
VariableSizedImageData.minTableIndex = 0;
VariableSizedImageData.maxTableIndex = (TableCount - 1);
// Backup to the last valid image table, for purposes of debug message/validation
//TmpStr.Format("Last Table: 0x%02x 0x%02x 0x%02x, ROM Addr 0x%x",(*(Ptr-3))&0xFF,(*((Ptr-2)))&0xFF,(*((Ptr-1)))&0xFF,Addr);
//DebugControlKeyMsgStrPrint(TmpStr);
//
if (GetLastImageIndex(&VariableSizedImageData.maxImageIndex, VariableSizedImageData.maxTableIndex) != 0)
{
TmpStr.Format("Error looking up max image index for last table index %d\n",VariableSizedImageData.maxTableIndex);
AfxMessageBox(TmpStr);
return -1;
}
//
if (GetFirstImageIndex(&VariableSizedImageData.minImageIndex, VariableSizedImageData.minTableIndex) != 0)
{
TmpStr.Format("Error looking up min image index for first table index %d\n",VariableSizedImageData.maxTableIndex);
AfxMessageBox(TmpStr);
return -1;
}
//
//TmpStr.Format("Determined maxTableIndex %d, maxImageIndex 0x%02x",VariableSizedImageData.maxTableIndex,(VariableSizedImageData.maxImageIndex&0xFF));
//DebugControlKeyMsgStrPrint(TmpStr);
return 0;
}
int DMD::GetFirstImageIndex(int *pImageIndex, int TableIndex)
{
int ImageIndex = 0;
if (GetNextImageIndex(&ImageIndex, TableIndex) != 0)
{
return -1;
}
if (pImageIndex != NULL)
{
*pImageIndex = ImageIndex;
}
return 0;
}
int DMD::GetLastImageIndex(int *pImageIndex, int TableIndex)
{
int ImageIndex = 0;
int hit = 0;
while (GetNextImageIndex(&ImageIndex, TableIndex) == 0)
{
hit = 1;
}
if (hit == 0)
{
return -1;
}
if (pImageIndex != NULL)
{
*pImageIndex = ImageIndex;
}
return 0;
}
int DMD::GetPrevImageIndex(int *pImageIndex, int TableIndex)
{
unsigned long Addr;
LPTSTR Ptr;
unsigned char ImageIndexMin;
unsigned char ImageIndexMax;
int windUp;
// Standard validations and sanity checks
if (!VariableSizedImageData.TableAddress)
{
return -1;
}
if (VariableSizedImageData.TableAddress >= CommonData.ROMSize)
{
return -1;
}
if ((TableIndex < VariableSizedImageData.minTableIndex) || (TableIndex > VariableSizedImageData.maxTableIndex))
{
return -1;
}
if (pImageIndex == NULL)
{
return -1;
}
if (GetROMAddressOfVariableSizedImageTable(&Addr, TableIndex) != 0)
{
return -1;
}
// Get pointer to area in ROM of actual table
Ptr = &CommonData.StartPtr[Addr];
// Need to start at last min/max pair and work down
windUp = 0;
while (((*Ptr) & 0xFF) != 0x00)
{
Ptr += 2; // walk past the min/max pair
windUp++;
}
// Now reverse back through the min/max pairs...
while (windUp != 0)
{
Ptr -= 2;
windUp--;
ImageIndexMin = (*Ptr)&0xFF;
ImageIndexMax = (*(Ptr+1))&0xFF;
//
if (ImageIndexMin > ImageIndexMax)
{
return -1;
}
if (((*pImageIndex)&0xFF) > (ImageIndexMax&0xFF))
{
*pImageIndex = ImageIndexMax;
return 0;
}
if (((*pImageIndex)&0xFF) > (ImageIndexMin&0xFF))
{
*pImageIndex = (*pImageIndex)-1;
return 0;
}
}
return -1;
}
int DMD::GetNextImageIndex(int *pImageIndex, int TableIndex)
{
unsigned long Addr;
LPTSTR Ptr;
unsigned char ImageIndexMin;
unsigned char ImageIndexMax;
// Standard validations and sanity checks
if (!VariableSizedImageData.TableAddress)
{
return -1;
}
if (VariableSizedImageData.TableAddress >= CommonData.ROMSize)
{
return -1;