-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathChaos.cpp
More file actions
5336 lines (5035 loc) · 130 KB
/
Chaos.cpp
File metadata and controls
5336 lines (5035 loc) · 130 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
// *********************************************************
// This collection of code is a translation of the
// 'Create New Adventure' function. It reads an
// old Dungeon Master or Prison save file and creates
// a new Chaos Strikes Back save file.
// *********************************************************
#include "stdafx.h"
//#include "Objects.h"
#include "Dispatch.h"
#include "UI.h"
#include "CSB.h"
#include "Data.h"
#include <stdio.h>
static void DontDoThis(i32 n)
{
char msg[1000];
sprintf(msg, "Don't Do This #0x%x\n"
"The UTILITY functions are designed to create a\n"
" Chaos Strikes Back game from a Prison SAVEGAME\n"
" and a 'mini.dat' file. It will not import nor\n"
" edit characters nor anything else. You load a\n"
" prison savegame, press 'Make New Adventure' twice\n"
" choose a name for the new adventure, and quit.\n"
" You can then RESTART at the prison door and\n"
" and select your new game to play. You will\n"
" start naked in a dark room filled with worms.\n"
" If you try to use this program in any other \n"
" way you will probably be unhappy with the\n"
" results. But you need not complain. I won't listen.", n);
UI_MessageBox(msg, "Error",MESSAGE_OK);
}
#define CHAOSFILL(a,b) i8 fill##a[a-b];
i32 ReadExtendedFeatures(i32 handle);
ui32 FormChecksum(ui8 *buf, i32 num);
void info(char *, unsigned int);
ui16 countDSAs();
void WriteDSAs(i32 handle);
void WriteDSALevelIndex(i32 handle);
//extern bool ForcedScreenDraw;
extern i32 keyboardMode;
extern char ExtendedFeaturesVersion;
extern bool indirectText;
extern bool bigActuators;
extern bool sequencedTimers;
extern bool extendedTimers;
extern bool DefaultDirectXOption;
extern ui32 cellflagArraySize;
extern DSAINDEX DSAIndex;
#pragma pack(1)
void _CALL0(CODESTATE s);
void _CALL1(CODESTATE s,i32 a);
void _CALL2(CODESTATE s,i32 a,i32 b);
void _CALL3(CODESTATE s,i32 a,i32 b,i32);
void _CALL4(CODESTATE s,i32 a,i32 b,i32 c,i32 d);
void _CALL5(CODESTATE s,i32 a,i32 b,i32 c,i32 d,i32 e);
void _CALL6(CODESTATE s,i32 a,i32 b,i32 c,i32 d,i32 e,i32 f);
void _CALL7(CODESTATE s,i32 a,i32 b,i32 c,i32 d,i32 e,i32 f,i32 g);
void _CALL8(CODESTATE s,i32 a,i32 b,i32 c,i32 d,i32 e,i32 f,i32 g,i32 h);
void _CALL9(CODESTATE s,i32 a,i32 b,i32 c,i32 d,i32 e,i32 f,i32 g,i32 h,i32 i);
struct DlgButton
{
i8 byte0;
i8 byte1;
wordRectPos rectPos2;
i8 byte10;
i8 byte11;
};
struct S12406
{
i8 byte0;
i8 byte1;
DlgButton *pDlgButton2; // An array of DlgButton
pnt pnt6;
pnt pnt10;
};
struct STRUCT6
{
i32 int0;
i16 word4;
};
struct STRUCT12
{
i32 long0;
i16 word4;
i16 word6;
void (*fnc8)(pnt);
};
#define size3764 880
struct E
{
// PALETTE palette24862; (Use palette24862)
//pnt Byte24830[16];(use byte24830)
i16 Word24814;
pnt Pnt24812;
i16 Word24808;
i16 Word24806;
i16 Word24804;
i16 Word24802;
i16 Word24800;
i16 Word24798;
i16 Word24796;
i16 Word24794;
//i8 Byte24792;
//i8 adjust24792;
pnt Pnt24792;
i32 Long24300;
pnt Pnt24296[100];
pnt Pnt23896[100];
i16 Word23496;
char Byte23494[1];
CHAOSFILL(23493,23414)
//RectPos rectPos23414; (use rectPos23414)
i16 Word23398;
i16 Word23396;
ui8 Byte23394[10608];//bitmap 102 lines by 104 bytes
//pnt UtilityDiskMessages; //12786
//pnt Pnt12782; // to
//pnt Pnt12678; // 12618
//i32 Long12658; // are
//i32 Long12654; // 42 string pointers.
// // (use UtilityDiskMessages[i])
//pnt Pnt12446;//use pnt12446;
//i8 Byte12406;(use s12406)
// never referenced i8 Byte12392;
//pnt Pnt12364;(use pnt12364);
i8 Byte12336[6]; //actually i32 and i16
//pnt Pnt12246;(use pnt12246)
//pnt Pnt12242;(use pnt12242)
//pnt Pnt12238;(use pnt12238)
//pnt Pnt12226;(use pnt12226)
//pnt Pnt12222;(use pnt12222)
i16 Word12196;
i16 GameFile;//12194;
i16 Word12184;
PALETTE palette10938;
i32 Long9220;
i16 FirstQueuedMouseEvent;//9216;
i16 LastQueuedMouseEvent;//9214;
i8 Byte9212;
i8 Byte9211;
i16 Word9210;
i16 Word9208;
i16 Word9206;
i16 Word9204;
i8 Byte9202[30];// 5 * (i32+i16) ???
i8 Byte9172[6];//i32 and i16??
//pnt Pnt9142;//use pPnt9142
//i16 Word9138[7];//use word9138
i16 Word9124;
i16 Word9122;
i16 Word9120;
i16 Word9116;
i16 Word9110;
i16 Word9108;
i16 Word9106;
i16 Word9104;
i16 Word9102;
i16 Word9098;
i16 Word8842[1];
//never referenced i8 Byte8586[1];
i16 Word8330[1];
i16 Word8328[1];
i16 Word8074;
i16 Word8072;
i16 Word8070;
i16 Word8068;
i16 Word8066;
pnt Pnt8064;
pnt Pnt8060;
i16 Word8056;
i16 Word8054;
ui8 *PhysicalBase;//8052;
i16 Word8048;
i16 Word7062;
i16 ActualCharacter; // Word7060
i8 CharacterImages[4*464]; // Byte7058
i8 Byte5202[24];
i16 Word5178;
wordRectPos wRectPos5176;
i16 Word5168;
i16 EditBoxSelected; //Word5166 //either NAME or TITLE
i16 EditBoxPosition; //Word5164
//wordRectPos wRectPos5162;(use wRectPos5162)
//wordRectPos wRectPos5154;(use wRectPos5154)
//wordRectPos wRectPos5146;(use wRectPos5146)
//wordRectPos wRectPos5138[4];(use wRectPos5138)
//wordRectPos wRectPos5106[4];(use wRectPos5106)
//wordRectPos wRectPos5066;(use wRectPos5066)
//wordREctPos wRectPos5058;(use wREctPos5058)
//DlgButton dlgButton5050[4];//(use dlgButton5050)
i8 Byte4930[1];
CHAOSFILL(4929,4712)
//i8 Byte4712[16];(use byte4712)
i16 Word4696;
i8 Byte4694[464];
CHAOSFILL(4230,4228)
i8 Byte4228[464];
i8 Byte3764[size3764];
i16 Word3122;
i16 Word826[5];
i16 Word816[16];
i16 Word784[17];
i16 Word750[8];
i16 Word734[6];
i16 Word722[6];
i16 *Pnt714[7];
i16 Word686;
i16 *pw664;
pnt Pnt660;
i16 *pw656;
i16 *pw652;
pnt pAllocDBank434;
pnt Pnt430;
i16 Word426;
i16 Word424;
pnt pDBank422;
i16 Word418;
i32 DBankLen416;
i8 Byte412[8];
};
E e;
unsigned char SelectedColor;
PALETTE palette24862 = {
0x0000,0x0333,0x0444,0x0310,0x0066,0x0420,0x0040,0x0060,
0x0700,0x0750,0x0643,0x0770,0x0222,0x0555,0x0007,0x0777};
i8 byte24830[16] ALIGN4 = {4,6,4,8,16,4,4,4,4,8,4,0,0,0,8,4};
wordRectPos rectPos23414 = { 0, 193, 0, 101};
wordRectPos rectPos23406 = {62, 255, 48, 149};
static i32 textArraySize; //Number of words
static char *textArray;
static DB2 *DB2Address;
static i32 DB2Size;
static i32 compressedTextSize;
char *compressedText = NULL;
const char *positions = "CSBGAME\nCSBGAME2\nCSBGAME3\nCSBGAME4\nCANCEL";
// ARGHH!
const char *filenames[] ={
"CSBGAME.DAT",
"CSBGAME2.DAT",
"CSBGAME3.DAT",
"CSBGAME4.DAT",
};
const char* UtilityDiskMessages[43] =
{
"\nPLEASE PUT A\nSAVE GAME DISK IN @", //0
"\nPUT PORTRAIT DISK\nIN @", //1
"\nPUT A BLANK DISK\nIN @", //2
"", //3
"", //4
"", //5
"\n\nREPLACE EXISTING SAVED GAME?", //6
"", //7
"\n\nREPLACE $'s PORTRAIT?", //8
"\n\nPLEASE WAIT . . .\nLOADING SAVED GAME",//9
"\n\nPLEASE WAIT . . .\nSAVING GAME", //10
"", //11
"\n\nCAN'T FIND SAVED GAME", //12
"", //13
"\nSAVED GAME ERROR", //14
"\nERROR WHILE\nSAVING GAME", //15
"", //16
"", //17
"", //18
"", //19
"\nEACH CHAMPION MUST\nHAVE A UNIQUE FIRST NAME!",//20
"", //21
"\n\nPLEASE WAIT . .\nLOADING SAVED ADVENTURE", //22
"\n\nPLEASE WAIT . .\nSAVING NEW ADVENTURE", //23
"CAN'T FIND\nNEW ADVENTURE\nMINI.DAT", //24
"\nTHE NEW ADVENTURE\nIS DAMAGED", //25
"", //26
"", //27
"\nERROR WHILE SAVING\nNEW ADVENTURE", //28
"THE NEW ADVENTURE\nCAN ONLY BE MADE AFTER\nA SAVED GAME IS LOADED.", //29
"\nCAN'T MAKE NEW ADVENTURE\nFROM THIS SAVED GAME.\nALREADY UTILIZED.",//30
"LOAD WHICH SAVED GAME?", //31
"OK", //32
"OK\nCANCEL", //33
"SAVE\nFORMAT\nCANCEL", //34
"MAKE NEW ADVENTURE\nFORMAT\nCANCEL", //35
"YES\nNO", //36
"", //37
"", //38
"DUNGEON MASTER\nCHAOS STRIKES BACK\nCANCEL", //39
"", //40
"", //41
"\nPLEASE CHOOSE A\nSAVE GAME SLOT", //42
};
#ifdef _MSVC_INTEL
#pragma warning (disable:4305)
#pragma warning (disable:4309)
#endif
i8 byte12618[] ALIGN4 = {01,00,00,13,00,00,00,00};
DlgButton dlgButton_12610[] = {
{0x01,0x00,{0x0050,0x00ed,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00},
{0x01,0x00,{0x0050,0x0094,0x0080,0x0088},0x00,0x01},
{0x02,0x00,{0x00a5,0x00ed,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00},
{0x01,0x00,{0x0050,0x0094,0x006c,0x0074},0x00,0x01},
{0x02,0x00,{0x00a5,0x00ed,0x006c,0x0074},0x00,0x01},
{0x03,0x00,{0x007b,0x00c4,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00},
{0x01,0x00,{0x0050,0x00ed,0x006c,0x0074},0x00,0x01},
{0x02,0x00,{0x0050,0x0094,0x0080,0x0088},0x00,0x01},
{0x03,0x00,{0x00a5,0x00ed,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00},
{0x01,0x00,{0x0050,0x00ed,0x0058,0x0060},0x00,0x01},
{0x02,0x00,{0x0050,0x00ed,0x006c,0x0074},0x00,0x01},
{0x03,0x00,{0x0050,0x00ed,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00} };
DlgButton four_dlgButon[]={
{0x01,0x00,{0x0050,0x0094,0x0070,0x0078},0x00,0x01},
{0x02,0x00,{0x00a5,0x00ed,0x0070,0x0078},0x00,0x01},
{0x03,0x00,{0x0050,0x0094,0x0080,0x0088},0x00,0x01},
{0x04,0x00,{0x00a5,0x00ed,0x0080,0x0088},0x00,0x01},
{0x00,0x00,{0x0000,0x0000,0x0000,0x0000},0x00,0x00}};
#ifdef _MSVC_INTEL
#pragma warning (default:4305)
#pragma warning (default:4309)
#endif
S12406 s12406[] = {
{ 00,00, &dlgButton_12610[0], byte12618, NULL },
{ 00,00, &dlgButton_12610[2], NULL, NULL },
{ 00,00, &dlgButton_12610[5], NULL, NULL },
{ 00,00, &dlgButton_12610[9], NULL, NULL },
{ 00,00, &dlgButton_12610[13], NULL, NULL } };
S12406 fourbuttons[]={
{ 00,00, &four_dlgButon[0], NULL, NULL } };
const char *pnt12246 = "DMGAME.DAT";
const char *pnt12242 = "DMGAME.BAK";
const char *pnt12238 = "CSBGAME.DAT";
const char *pnt12234 = "CSBGAME.BAK";
const char *pnt12222 = "DRIVE B:";
const char *pnt12226 = "DRIVE A:";
S12406 *pS12406_9166[6] = {NULL,NULL,NULL,NULL,NULL,NULL};//guessed size!
S12406 **ppS12406_9142 = pS12406_9166;
i16 word9138[] = {
0x4737, //turn right
0x4838, //forward
0x4b34, //slide left
0x4d36, //slide right
0x5032, //backup
0x5230, //turn left
0x532e};//delete
ui32 FrameImage[246] = //byte8046
{
0xffff0000,0xffff0000,0xffff0000,0xffff0000,
0xfff00000,0xfff00000,0xbfff3fff,0x80000000,
0xffffffff,0x00000000,0xfff0fff0,0x00000000,
0xdfff5fff,0x80000000,0xffffffff,0x00000000,
0xfff0ffd0,0x00200000,0xefff6fff,0x80000000,
0xffffffff,0x00000000,0xfff0ff90,0x00600000,
0xf7ff77ff,0x80000000,0xffffffff,0x00000000,
0xfff0ff10,0x00e00000,0xfbff7bff,0x80000000,
0xffffffff,0x00000000,0xfff0fe10,0x01e00000,
0xfc307c30,0x83ff0030,0x00e400e4,0xffff00e4,
0x03f00010,0xffe00000,0xfc607c60,0x83ff0060,
0x01c801c8,0xffff01c8,0x03f00010,0xffe00000,
0xfc807c80,0x83ff0080,0x03800380,0xffff0380,
0x07f00410,0xffe00400,0xfc007c00,0x83ff0000,
0x07000700,0xffff0700,0x0ff00c10,0xffe00c00,
0xfc007c00,0x83ff0000,0x1e001e00,0xffff1e00,
0x0bf00810,0xffe00800,0xfc007c00,0x83ff0000,
0x7c007c00,0xffff7c00,0x13f01010,0xffe01000,
0xfc007c00,0x83ff0000,0xf800f800,0xfffff800,
0x23f02010,0xffe02000,0xfc017c01,0x83ff0001,
0xf000f000,0xfffff000,0x43f04010,0xffe04000,
0xfc037c03,0x83ff0003,0xe000e000,0xffffe000,
0x03f00010,0xffe00000,0xfc077c07,0x83ff0007,
0x00000000,0xffff0000,0x03f00010,0xffe00000,
0xfc0c7c0c,0x83ff000c,0x00000000,0xffff0000,
0x03f00010,0xffe00000,0xfc187c18,0x83ff0018,
0x00000000,0xffff0000,0x03f00010,0xffe00000,
0xfc207c20,0x83ff0020,0x00000000,0xffff0000,
0x03f00010,0xffe00000,0xfc407c40,0x83ff0040,
0x00000000,0xffff0000,0x03f00010,0xffe00000,
0xfc807c80,0x83ff0080,0x00000000,0xffff0000,
0x03f00010,0xffe00000,0xfc007c00,0x83ff0000,
0x00000000,0xffff0000,0x23f02010,0xffe02000,
0xfc007c00,0x83ff0000,0x00000000,0xffff0000,
0x43f04010,0xffe04000,0xfc007c00,0x83ff0000,
0x00010001,0xffff0001,0x83f08010,0xffe08000,
0xfc007c00,0x83ff0000,0x00030003,0xffff0003,
0x03f00010,0xffe00000,0xfc007c00,0x83ff0000,
0x000e000e,0xffff000e,0x03f00010,0xffe00000,
0xfc007c00,0x83ff0000,0x001c001c,0xffff001c,
0x03f00010,0xffe00000,0xfc207c20,0x83ff0020,
0x00380038,0xffff0038,0x03f00010,0xffe00000,
0xfc407c40,0x83ff0040,0x00780078,0xffff0078,
0x07f00410,0xffe00400,0xfd807d80,0x83ff0180,
0x00700070,0xffff0070,0x0ff00c10,0xffe00c00,
0xff007f00,0x83ff0300,0x00e000e0,0xffff00e0,
0x3bf03810,0xffe03800,0xfe007e00,0x83ff0200,
0x00e000e0,0xffff00e0,0x73f07010,0xffe07000,
0xfc007c00,0x83ff0000,0x81c081c0,0xffff81c0,
0x43f04010,0xffe04000,0xfc037c03,0x83ff0003,
0x07800780,0xffff0780,0x83f08010,0xffe08000,
0xfc0e7c0e,0x83ff000e,0x0f000f00,0xffff0f00,
0x03f00010,0xffe00000,0xffff7c00,0x83ff0000,
0xffff0000,0xffff0000,0xfff00210,0xfde00000,
0xffff7800,0x87ff0000,0xffff0000,0xffff0000,
0xfff00110,0xfee00000,0xffff7000,0x8fff0000,
0xffff0000,0xffff0000,0xfff00090,0xff600000,
0xffff6000,0x9fff0000,0xffff0000,0xffff0000,
0xfff00050,0xffa00000,0xffff4000,0xbfff0000,
0xffff0000,0xffff0000,0xfff00030,0xffc00000,
0xffff7fff,0x80000000,0xffffffff,0x00000000,
0xfff0fff0,0x00000000 };
wordRectPos wRectPos5162 = {0x009d,0x00fc,0x003c,0x0092};
wordRectPos wRectPos5154 = {0x011e,0x012f,0x002b,0x00a9};
wordRectPos wRectPos5146 = {0x011c,0x0131,0x0029,0x00ab};
wordRectPos wRectPos5138[4] =
{
{0x000b,0x002a,0x000e,0x002a},
{0x004e,0x006d,0x000e,0x002a},
{0x0091,0x00b0,0x000e,0x002a},
{0x00d3,0x00f2,0x000e,0x002a} };
wordRectPos wRectPos5106[7] =
{
{0x000b,0x002a,0x000e,0x002a}, //[0]=5106
{0x004e,0x006d,0x000e,0x002a}, //[1]=5098
{0x0091,0x00b0,0x000e,0x002a}, //[2]=5090
{0x00d3,0x00f2,0x000e,0x002a}, //[3]=5082
{0x004d,0x0078,0x0038,0x0060}, //[4]=5074
{0x0053,0x0072,0x003e,0x005a}, //[5]=5066
{0x0000,0x0098,0x0072,0x00af}, //[6]=5058
};
DlgButton dlgButton5050[17] =
{
{0x01,0,{ 4, 48, 3, 42},0,1},//[ 0]=5050
{0x02,0,{ 71,115, 3, 42},0,1},//[ 1]=5038
{0x03,0,{138,182, 3, 42},0,1},//[ 2]=5026
{0x04,0,{205,249, 3, 42},0,1},//[ 3]=5014
{0x05,0,{157,252, 60,146},0,1},//[ 4]=5002
{0x06,0,{157,252, 60,146},0,2},//[ 5]=4990
{0x07,0,{286,303, 43,169},0,1},//[ 6]=4978
{0x08,0,{156,196,159,167},0,1},//[ 7]=4966
{0x09,0,{225,253,159,167},0,1},//[ 8]=4954
{0x64,0,{350,349,250,249},0,0},//[ 9]=4942
{0x0b,0,{ 2, 92,186,194},0,1},//[10]=4930
{0x0c,0,{102,192,186,194},0,1},//[11]=4918
{0x0d,0,{202,316,186,194},0,1},//[12]=4906
{0x0e,0,{ 15, 59, 87, 95},0,1},//[13]=4894
{0x0f,0,{ 15,131,100,108},0,1},//[14]=4882
{0x66,0,{350,349,250,249},0,0},//[15]=4870
{0x11,0,{288,316, 5, 13},0,1},//[16]=4858
};
i8 byte4846[8] ALIGN4 = {0x09,0x00,0x61,0x00,0x01,0x00,0x3b,0x00};
S12406 s12406_4802 =
{
01,00, &dlgButton5050[0], byte4846, NULL
};
const char* pnt4788[] =
{
"FIGHTER",
"NINJA",
"PRIEST",
"WIZARD"
};
const char* pnt4772[16] =
{
"NEOPHYTE ",
"NOVICE ",
"APPRENTICE ",
"JOURNEYMAN ",
"CRAFTSMAN ",
"ARTISAN ",
"ADEPT ",
"EXPERT ",
"` MASTER ",
"a MASTER ",
"b MASTER ",
"c MASTER ",
"d MASTER ",
"e MASTER ",
"ARCHMASTER "
};
i8 byte4712[16] ALIGN4 = {0x00,0x0c,0x01,0x02,
0x0d,0x0f,0x03,0x05,
0x0a,0x08,0x09,0x0b,
0x07,0x06,0x04,0x0e };
i8 Byte1278[420] ALIGN4 = {
0x00,0x06,0x1b,0x0a,0x0f,0x19,0x0c,0x06,0x06,0x0c,0x09,0x04,0x00,0x00,0x00,0x03,
0x0e,0x02,0x1e,0x1e,0x06,0x1e,0x0e,0x1f,0x0e,0x0e,0x06,0x06,0x03,0x00,0x0c,0x0e,
0x0e,0x0e,0x1e,0x0f,0x1e,0x1f,0x1f,0x0f,0x11,0x1f,0x01,0x09,0x08,0x11,0x11,0x0e,
0x1e,0x0e,0x1e,0x0f,0x1f,0x11,0x11,0x11,0x11,0x11,0x1f,0x0f,0x18,0x0f,0x04,0x00,
0x04,0x1f,0x00,0x04,0x18,0x01,0x00,0x06,0x1b,0x1f,0x14,0x1a,0x1a,0x06,0x0c,0x06,
0x06,0x04,0x00,0x00,0x00,0x06,0x13,0x06,0x01,0x01,0x0a,0x10,0x10,0x01,0x11,0x11,
0x06,0x06,0x06,0x0f,0x06,0x13,0x11,0x11,0x11,0x10,0x11,0x10,0x10,0x10,0x11,0x04,
0x01,0x0a,0x08,0x1b,0x19,0x11,0x11,0x11,0x11,0x10,0x04,0x11,0x11,0x11,0x0a,0x11,
0x02,0x0c,0x0c,0x03,0x0e,0x00,0x09,0x11,0x1f,0x0a,0x04,0x03,0x00,0x06,0x12,0x0a,
0x0e,0x04,0x0c,0x0c,0x0c,0x06,0x0f,0x1f,0x00,0x0f,0x00,0x0c,0x15,0x02,0x0e,0x0e,
0x12,0x1e,0x1e,0x02,0x0e,0x0f,0x00,0x00,0x0c,0x00,0x03,0x06,0x17,0x1f,0x1e,0x10,
0x11,0x1e,0x1e,0x13,0x1f,0x04,0x01,0x0c,0x08,0x15,0x15,0x11,0x1e,0x11,0x1e,0x0e,
0x04,0x11,0x11,0x15,0x04,0x0a,0x04,0x0c,0x06,0x03,0x1b,0x00,0x12,0x11,0x00,0x11,
0x07,0x05,0x00,0x06,0x00,0x1f,0x05,0x0b,0x1d,0x00,0x0c,0x06,0x06,0x04,0x06,0x00,
0x06,0x18,0x19,0x02,0x10,0x01,0x1f,0x01,0x11,0x04,0x11,0x01,0x06,0x06,0x06,0x0f,
0x06,0x06,0x16,0x11,0x11,0x10,0x11,0x10,0x10,0x11,0x11,0x04,0x11,0x0a,0x08,0x11,
0x13,0x11,0x10,0x11,0x14,0x01,0x04,0x11,0x0a,0x1b,0x0a,0x04,0x08,0x0c,0x03,0x03,
0x00,0x00,0x09,0x11,0x1f,0x0a,0x04,0x09,0x00,0x00,0x00,0x0a,0x1e,0x13,0x1a,0x00,
0x06,0x0c,0x09,0x04,0x06,0x00,0x06,0x10,0x0e,0x02,0x1f,0x1e,0x02,0x1e,0x0e,0x04,
0x0e,0x0e,0x06,0x02,0x03,0x00,0x0c,0x00,0x10,0x11,0x1e,0x0f,0x1e,0x1f,0x10,0x0f,
0x11,0x1f,0x0e,0x09,0x0f,0x11,0x11,0x0e,0x10,0x0e,0x13,0x1e,0x04,0x0f,0x04,0x11,
0x11,0x04,0x1f,0x0f,0x01,0x0f,0x00,0x00,0x04,0x1f,0x00,0x04,0x18,0x1f,0x00,0x06,
0x00,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x0f,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,
0x00,0x00,0x00,0x00};
ui32 Long954[4] = {
0xfff0fff0, 0xfff8fff8, 0xfffcfffc, 0xfffefffe};
ui32 Long938[4] = {
0x7fff7fff, 0x3fff3fff, 0x1fff1fff, 0x0fff0fff};
void reverseBMP(ui32 *bmp, i32 n)
{
ASSERT(((int)bmp & 3) == 0,"bmp");
for (i32 i=0; i<n; i++)
bmp[i]=LE32(bmp[i]);
}
void InitializeE()
{
memset(&e, 0, sizeof (e));
reverseBMP(FrameImage, 246);
}
void pumper(); // Pump any queued Windows messages
ui8 *MALLOC(i32 size);
void MFREE(ui8 *address);
//i32 DIRECT_CONIN(); // Trap 1 #0x07
//i16 CONSTAT(); // Trap 1 #0x0b
void SetSupervisorMode();
void ClearSupervisorMode();
//void ClearMemory(pnt dest, i16 numByte); // TAG000a84
ui8 *physbase();
void SetDLogicalBase(ui8 *);
//i16 OPEN(char *name, i32 ref);
//i16 CREATE(char *name, i16 flag);
i32 READ(i32 file, i32 len, ui8 *buf);
i32 WRITE(i16 file, i32 len, ui8 *buf);
i16 CLOSE(i32 handle);
void StrCpy(char *dst, const char *src);//TAG003264
i16 StrLen(const char *string);//TAG0032ba
void MemMove(ui8 *src, ui8 *dest, i16 byteCount); //TAG0009dc
//void TextToScreen(i32, i32, i32, i32, pnt);//TAG001c42
i16 Unscramble(ui8 *buf, i32 initialChecksum, i32 numwordM1);
i16 GenChecksum(ui8 *buf, i16 initSum, i32 numword);//TAG01d076
// TAG000c04
static i16 MyWriteScrambled(ui8 *, i16, ui16, ui16 *);//TAG01d0ea
// TAG0000d6
ui32 Times(ui32, ui32);
void TAG00022a(i16);
void TAG0002b0();
void TAG0002c2();
void TAG0002d0();
void TAG00031c();
ui8 *AllocateMemory(i32);//TAG000328
void ReleaseMemory(ui8 *);//TAG0003a0
char *GetSubString(const char *, char *, i16); //TAG000472
void PrintDialogText(const char *, i32, i32, i32); //TAG0004ec
void TAG00054a();
void TAG0006e4();
i16 TAG0008dc(i16);
i16 TAG000952();
void TAG0009a8();
i16 ReadGameFile(ui8 *, i32);//TAG000aee
i16 WriteGameFile(ui8 *, i16);//TAG000b28
//i16 TAG000b94(pnt,i16,i16);(use GenChecksum)
// TAG000bc8
static i16 MyUnscrambleStream(ui8 *buf,i32 size,i16 initialHash,i16 Checksum);
i16 ReadAndChecksum(ui8 *buf, i16 *pChecksum, i32 size);//TAG000c52
static i16 MyWriteAndChecksum(ui8 *, ui16 *, i32);//TAG000c98
i16 ReadGameBlock1(ui8 *);//TAG000cde
i16 UnscrambleBlock1(ui8 *, i16);//TAG000d08
i16 WriteFirstBlock(ui8 *, i16);//TAG000d7c
void TAG00136c();
i16 TAG00142e(ui8 *);
void TAG001676(ui8 *, i16);
void TAG002724();
i16 TestInRectangle(wordRectPos *, i32 x, i32 y);//TAG002c70
void TAG002ca8();
i16 TAG002cdc(DlgButton *, i32, i32, i32);
void EnqueMouseClick(i32, i32, i32);//TAG002d3c
void CheckPendingMouseClick();//TAG002e2c
void TAG002e4a(i32);
i16 TAG002faa(S12406 *P1);
//i16 TAG002faa(pnt);
// TAG003000
S12406 **SetActiveDialog(S12406 **); // Actually an array of (6) &S12406
void TAG003106(i16);
void TAG0031a6(i16);
void TAG00323c();
void TAG00324c();
void TAG003264();
void TAG003294(i16, i16);
void TAG0032b4(i16, i16);
void BitBltSquareImage(pnt, const wordRectPos *, i16, i16); //TAG0033b6
// TAG0033e6
void FillScreenRectangle(wordRectPos *, i16);
void DrawNameTitleCarret(i16, i16); //TAG003406
// TAG0034dc
void ExpandRectangle(wordRectPos *, wordRectPos *, i16, i16);
// TAG0035cc
void DrawDialogBoxOutline(wordRectPos *, i16, i16, i16);
void PrintCharacterName(i16); //TAG003748
void DrawCharacterHeader(i16, i16); //TAG0037ac
void AddDialogButton(DlgButton *, const char*, i16);//TAG003860
void TAG0039a8();
void FillCharacterNameEditBox(const char *, i16, i16);//TAG0039ea
void PrintAttributeValue(const char *, i32, i32); //TAG003a7c
void DrawMagnifiedCharacterImage(); //TAG0036c0
void GetPalleteItemRect(i16, wordRectPos *); //TAG0038ea
void DrawSelectedColor(i16); //TAG003922
void TAG00439e();
//void TAG004a32(char *); //FadeToPalette
// TAG004bbc
void TextOutB(ui8 *dest,
i32 destWidth,
i32 x,
i32 y,
i32 color,
i32 P6,
const char *text);
void TextToScreen(i32, i32, i32, i32, const char *);//TAG004e76
i16 TAG004ec0(i32);
void TAG004ea2(i16 *);
i16 TAG00507e();
i16 TAG0050d2();
i16 TAG005868(i16 *, i16 *, i16 *, i16 *);
void TAG00589e(i16, i16);
//void TAG005c50(i32); //Trap #14
void TAG005c92(pnt);
void TAG005cd6(pnt *);
void TAG005cf6();
void TAG005d12(i16 *, i16 *, i16 *);
void TAG005d8e(i16 *, i16 *, i16 *);
void TAG005df2(i16);
void TAG0061ba(i16, i16);
void TAG0061e2(i16);
void TAG006202(i16, i16 *, i16 *, i16 *);
void TAG00623a(i16, char *, char **);
void TAG00626e(i16, char *, char **);
pnt FormatInteger(pnt, ui32, i16);//TAG0064b4
//void TAG006520(pnt,pnt);StrCpy
//i16 TAG00654e(pnt, pnt);strcmp
//i16 TAG0065bc(pnt);//StrLen
i32 atari_sprintf(char *,const char*, i32, i32, i32=0); //TAG0065e0
i32 GetPixel(pnt, i16, i16, i16);//TAG006700
//void TAG006892(...) //Use TAG0088b2 from Graphics.cpp
//void TAG00716a(pnt, RectPos *, i16 color, i16 dstwidth); (FillRectangle)
ui8 *TAG0073b0(ui8 *);
ui8 *TAG0073d4(ui8 *);
void TAG007416(char *, char *);
void TAG00744c(ui8 *, ui8 *);
void TAG0074ae(char *, i32, char *);
void TAG0074ea(ui8 *, i32, ui8 *);
ui8 *TAG007552(i32, ui8 *, i16 *);
i16 TAG007904(char * *, i32);
ui8 *TAG007a1a(i16);
char *TAG007ac0(ui8 **);
void TAG007b68(ui8 *);
char *TAG007bba(STRUCT6 *);
ui8 *TAG007cc6(i32, i16, char *);
ui8 *TAG007d4c(STRUCT12 *);
void TAG007e16(ui8 *, ui8 *);
i32 TAG007e42(i16, i16);
void TAG007f54();
ui8 *TAG007f64(i32, i16);
i32 TAG007f92(ui8 *);
ui8 *TAG007fe8(ui8 *);
void TAG00801e(ui8 *);
i32 TAG0080e0(ui8 *);
// TAG00858c
void MemoryMove(ui8 *, ui8 *, i16, i16, i32);//like MemMove
//void TAG0086a8(pnt, i32);//ClearMemory
i32 TAG008788(i16, i32, ui32);
void EditCharacterName(char key);
void StorePnt(ui8 *addr, ui8 *data)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
*((ui16 *)(addr)) = (ui16)((ui32)data);
*((ui16 *)(addr+2)) = (ui16)(((ui32)data)>>16);
#endif
}
void StorePnt(aReg addr, aReg data)
{
StorePnt((ui8 *)addr, (ui8 *)data);
}
void StorePnt(aReg addr, ui8 *data)
{
StorePnt((ui8 *)addr, data);
}
ui8 *LoadPnt(ui8 *addr)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
return (ui8 *)((*(ui16 *)(addr)) | ((ui32)((*(ui16 *)(addr+2)))<<16));
#endif
}
ui8 *LoadPnt(aReg addr)
{
return LoadPnt((ui8 *)addr);
}
void StoreLong(ui8 *addr, i32 data)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
*((ui16 *)(addr)) = (ui16)((ui32)data);
*((ui16 *)(addr+2)) = (ui16)(((ui32)data)>>16);
#endif
}
void StoreLong(aReg addr, i32 data)
{
StoreLong((ui8 *)addr, data);
}
i32 LoadLong(ui8 *addr)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
return (i32)((*(ui16 *)(addr)) | ((ui32)((*(ui16 *)(addr+2)))<<16));
#endif
}
i32 LoadLong(aReg addr)
{
return LoadLong((ui8 *)addr);
}
void StorePnt(ui8 *addr, aReg data)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
*((ui16 *)((pnt)addr)) = (ui16)((ui32)data);
*((ui16 *)((pnt)addr+2)) = (ui16)(((ui32)data)>>16);
#endif
}
void Storepi16(i16 **addr, i16 *data)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
*((ui16 *)((pnt)addr)) = (ui16)((ui32)data);
*((ui16 *)((pnt)addr+2)) = (ui16)(((ui32)data)>>16);
#endif
}
i16 *Loadpi16(i16 **addr)
{
//A little explanation is in order here, perhaps.
//Some platforms require that 32-bit words be on 4-byte
//boundaries. In the runtime we moved all 32-bit words
//to conform with this requirement. But here we simply
//fetch and store them by referencing two 16-bit words.
#ifdef _bigEndian
xxxxx
#else
return (i16 *)((*(ui16 *)((pnt)addr)) | ((ui32)((*(ui16 *)((pnt)addr+2)))<<16));
#endif
}
// *********************************************************
//
// *********************************************************
// TAG0000d6
ui32 Times(ui32 P1, ui32 P2)
{
return P1 * P2;
}
// *********************************************************
//
// *********************************************************
void TAG00022a(i16 P1)
{ // Set/unSet VBL interrupt routine?????
//;;;;;;;;;;;;;;;;;;;;;
switch (P1)
{
case 1:
SetSupervisorMode();
//TAG0002b0();
ClearSupervisorMode();
break;
case 2:
SetSupervisorMode();
//TAG0002c2();
ClearSupervisorMode();
break;
}; //switch(P1)
}
// *********************************************************
//
// *********************************************************
void TAG0002d0()
{
i32 i;
//;;;;;;;;;;;;;
e.Word23496 = 0;
for (i=0; i<100; i++)
{
StorePnt((ui8 *)&e.Pnt23896[i], (ui8 *)NULL);
StorePnt((ui8 *)&e.Pnt24296[i], (ui8 *)NULL);
//
};
TAG007e42(100, 50);
}
// *********************************************************
//
// *********************************************************
void TAG00031c()
{
TAG007f54();
}
// *********************************************************
//
// *********************************************************
// TAG000328
ui8 *AllocateMemory(i32 P1)
{
dReg D0;
ui8 *pnt_8;
ui8 *pnt_4;
//;;;;;;;;;;;;;;;;;;;
pnt_4 = TAG007f64(P1, 0x400);
D0B = (UI8)(pnt_4==NULL?1:0);
D0W = sw(-D0B);
if (D0W != 0)
{
die(0,"FATAL ERROR: OUT OF MEMORY\nREBOOT");
for (;;) {};
};
pnt_8 = TAG007fe8(pnt_4);
StorePnt((ui8 *)&e.Pnt23896[e.Word23496], pnt_8);
StorePnt((ui8 *)&e.Pnt24296[e.Word23496], pnt_4);
e.Word23496++;
return pnt_8;
}
// *********************************************************
//
// *********************************************************
// TAG0003a0
void ReleaseMemory(ui8 *P1)
{
ui8 **pntA0, **pntA1;
i16 w_6;
ui8 *pnt_4;
//;;;;;;;;;;;;;;;;;;;;;;;;;;;
pnt_4 = NULL;
for (w_6 = 0; w_6<e.Word23496; w_6++)
{
pntA0 = (ui8 **)&e.Pnt23896[w_6];
if (P1 != *pntA0) continue;
pntA0 = (ui8 **)&e.Pnt24296[w_6];
pnt_4 = *pntA0;
e.Word23496--;
if (w_6 < e.Word23496)
{
pntA0 = (ui8 **)&e.Pnt23896[w_6];
pntA1 = (ui8 **)&e.Pnt23896[e.Word23496];
pntA0 = pntA1;
pntA0 = (ui8 **)&e.Pnt24296[w_6];
pntA1 = (ui8 **)&e.Pnt24296[e.Word23496];
pntA0 = pntA1;
};
pntA0 = (ui8 **)&e.Pnt23896[e.Word23496];
*pntA0 = NULL;
pntA0 = (ui8 **)&e.Pnt24296[e.Word23496];
*pntA0 = NULL;
//
//
};
if (pnt_4 == NULL) return;
TAG00801e(pnt_4);
TAG007f92((ui8 *)pnt_4);
}
// *********************************************************
//