-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCode1f9e6.cpp
More file actions
357 lines (345 loc) · 8.94 KB
/
Code1f9e6.cpp
File metadata and controls
357 lines (345 loc) · 8.94 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
#include "stdafx.h"
#include "UI.h"
#include <stdio.h>
//#include "Objects.h"
#include "Dispatch.h"
#include "CSB.h"
#include "Data.h"
void DisableTraceIfEnciphered();
void PlayFile_Close();
void RecordFile_Close();
bool IsPlayFileOpen();
bool IsRecordFileRecording();
void RecordFile_Open();
void RecordFile_Record(i32 x, i32 y, i32 z);
extern bool RepeatGame;
extern bool GameIsComplete;
// *********************************************************
//
// *********************************************************
// TAG01dc4e
i16 Darken(i16 color)
{
if (color & 0x007) color -= 0x001;
if (color & 0x070) color -= 0x010;
if (color & 0x700) color -= 0x100;
return color;
}
// *********************************************************
//
// *********************************************************
// TAG01f990
void DisplayHeroName(i16 P1,i16 P2,i16 P3,char *heroName)
{
aReg A2, A3;
char b_50[50];
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ASSERT(1,"impossible");
A3 = (aReg)heroName;
A2 = (aReg)b_50;
while ( ((*A2)=*(A3++)) != 0)
{
//
if ( (*A2 >= 'A') && (*A2 <= 'Z'))
{
*A2 -= 0x40;
};
A2++;
//
};
TextOutToScreen(P1, P2, P3, 12, b_50);
}
extern ui32 VBLCount;
// *********************************************************
//
// *********************************************************
// TAG01f9e6
RESTARTABLE _ShowCredits(const i32 P1) //()
{ // The game is lost! Or won!!!
static dReg D0, D4, D5, D6, D7;
static aReg A0, A2, A3;
static CHARDESC *pcA0;
static i16 LOCAL_142;
static i16 LOCAL_132;
static i8 LOCAL_130[130-110];
static PALETTE LOCAL_110;
static PALETTE LOCAL_78; //32bytes
static PALETTE LOCAL_46;
static pnt LOCAL_14;
static pnt LOCAL_10;
static CHARDESC *LOCAL_6;
static i8 LOCAL_1;
static i32 before, after;
static i32 i;
static bool recording;
RESTARTMAP
RESTART(1)
RESTART(2)
RESTART(3)
RESTART(4)
RESTART(5)
RESTART(6)
RESTART(7)
RESTART(8)
RESTART(9)
RESTART(10)
RESTART(11)
RESTART(12)
RESTART(13)
RESTART(14)
RESTART(15)
RESTART(16)
RESTART(17)
RESTART(18)
RESTART(19)
RESTART(20)
RESTART(21)
RESTART(22)
RESTART(23)
RESTART(24)
RESTART(25)
END_RESTARTMAP
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LOCAL_132 = 1;
LOCAL_14 = NULL;
A2 = NULL;
SetCursorShape(0);
STHideCursor(HC50);
d.PrimaryButtonList = NULL;
d.SecondaryButtonList = NULL;
d.pKeyXlate1 = NULL;
d.pKeyXlate2 = NULL;
if (P1)
{
if (d.Word11694 == 0)
{
QueueSound(6, d.partyX, d.partyY, 0);//Dying sound
VBLDelay(_1_,240); // About 4 seconds
};
};
InsertDisk(0, 0);
openGraphicsFile();
A3 = (aReg)d.pWallBitmaps[2];
if (P1)
{
A2 = A3;
A3 += 560;
ReadAndExpandGraphic(6, (ui8 *)A2, 0, 0);
if (d.Word11694)
{
LOCAL_14 = A3;
A3 += 1376;
ReadAndExpandGraphic(208, (ui8 *)LOCAL_14, 0, 0);
};
};
ReadAndExpandGraphic(0x8005, (ui8 *)A3, 0, 0);
LOCAL_10 = A3;
closeGraphicsFile();
if (d.DynamicPaletteSwitching)
{
MemMove((ui8 *)&d.Palette11978, (ui8 *)&LOCAL_78, 32);
for (D6W=0; D6W<=7; D6W++)
{
wvbl(_2_);
for (D7W=0; D7W<16; D7W++)
{
D0W = Darken(d.Palette11946.color[D7W]);
d.Palette11946.color[D7W] = D0W;
D0W = Darken(d.Palette11978.color[D7W]);
d.Palette11978.color[D7W] = D0W;
//
};
//
};
wvbl(_3_);
MemMove((ui8 *)&LOCAL_78, (ui8 *)&d.Palette11978, 32);
}
else
{
FadeToPalette(_4_,&d.Palette11914);
};
if (P1)
{
if (d.Word11694)
{
Flood(d.LogicalScreenBase, 12, 0xfa0);
for (D7W=0; D7W<d.NumCharacter; D7W++)
{
D6L = 48 * D7W;
pcA0 = &d.CH16482[D7W];
LOCAL_6 = pcA0;
BLT2Screen((ui8 *)LOCAL_14, (RectPos *)d.Word132, 32, 10);
BLT2Screen((ui8 *)LOCAL_6->portrait, (RectPos *)d.Word140, 16, 1);
DisplayHeroName(87, D6W=sw(D6W+14), 9, LOCAL_6->name);
LOCAL_142 = StrLen(LOCAL_6->name);
D5W = sw(6 * LOCAL_142 + 87);
A0 = (aReg)LOCAL_6->name;
LOCAL_1 = *(A0+9);
if (LOCAL_1 != 44)
{
if (LOCAL_1 != 59)
{
if (LOCAL_1 != 45)
{
D5W += 5;
};
};
};
DisplayHeroName(D5W, D6W++, 9, LOCAL_6->title);
for (D5W=0; D5W<=3; D5W++)
{
D0W = sw(DetermineMastery(D7W, D5W | 0xc000));
D4W = sw(Smaller(16, D0W));
if (D4W == 1) continue;
if (D4W == 0) die (0x8d49,"Mastery = 0");
StrCpy((char *)LOCAL_130, d.Pointer16770[D4W]);
StrCat((char *)LOCAL_130, " ");
StrCat((char *)LOCAL_130, d.Pointer16596[D5W]);
DisplayHeroName(105, D6W=sw(D6W+8), 13, (char *)LOCAL_130);
//
};
d.Word132[3] += 48;
d.Word132[2] += 48;
d.Word140[3] += 48;
d.Word140[2] += 48;
//
};
d.DynamicPaletteSwitching = 0;
videoMode = VM_CAST;
FadeToPalette(_5_,&LOCAL_78); //Show Champion's Levels
for (i=0;(i<2000)&&(RepeatGame) || (!RepeatGame); i++)
{
wvbl(_24_)
};
GameIsComplete = true;
RETURN;
};
tag01fd10:
ClearMemory(d.LogicalScreenBase, 32000);
BLT2Screen((ui8 *)A2, (RectPos *)d.Word108, 40, -1);
fillMemory((i16 *)&LOCAL_110, 16, 2, 2);
MemMove((ui8 *)&LOCAL_110, (ui8 *)&LOCAL_46, 32);
ForceScreenDraw();
LOCAL_46.color[15] = 0x777;
videoMode = VM_THEEND;
FadeToPalette(_6_,&LOCAL_46);
if (LOCAL_132)
{
VBLDelay(_7_,300); // About 5 seconds
};
if (d.CanRestartFromSavegame)
{
d.UseByteCoordinates = 0;
FillRectangle(d.LogicalScreenBase, (RectPos *)d.Word116, 1, 160);
ForceScreenDraw();
wvbl(_21_);
FillRectangle(d.LogicalScreenBase, (RectPos *)d.Word124, 0, 160);
TextOutToScreen(110, 0x9a, 4, 0, "RESTART THIS GAME");
LOCAL_46.color[1] = 0x437;
LOCAL_46.color[4] = 0x777;
d.PrimaryButtonList = d.Buttons16956;
d.PrimaryButtonList->word0 = 0xd7;
d.PrimaryButtonList->xMin = 0x67;
d.PrimaryButtonList->xMax = 0xd9;
d.PrimaryButtonList->yMin = 0x91;
d.PrimaryButtonList->yMax = 0x9f;
DiscardAllInput();
STShowCursor(HC50);
if (IsPlayFileOpen()) PlayFile_Close();
FadeToPalette(_8_,&LOCAL_46);
for (D7W=900; (--D7W!=0)&&(d.PartyHasDied==0);)
{
do
{
HandleMouseEvents(_22_,-999887); //initialize
// Sets DiskMenuNeeded = false
// Sets lastTime = 0;
} while (intResult & 1);
do
{
HandleMouseEvents(_15_,0); //'Restart' sets d.PartyHasDied=1
} while (intResult & 1);
if (DiskMenuNeeded)
{
DisplayDiskMenu(_23_);
};
wvbl(_9_);
//
};
HandleMouseEvents(_16_,-999887); //initialize
STHideCursor(HC33);
ForceScreenDraw();
if (d.PartyHasDied) // Did we time out?
{ //No. The player pressed 'Restart This Game'
recording = IsRecordFileRecording();
FadeToPalette(_10_,&LOCAL_110);
ClearMemory(d.LogicalScreenBase, 32000);
FadeToPalette(_11_,&d.Palette552[0]);
MemMove((ui8 *)&d.Palette552[0], (ui8 *)&d.Palette11946, 32);
d.gameState = GAMESTATE_ResumeSavedGame;
if (recording)
{
RecordFile_Close();
scrollingText.ResetTime(0);
d.Time = 0;
parameterMessageSequence = 0;
do
{
HandleMouseEvents(_17_,-999887);
} while (intResult & 1);
};
Cleanup(false);
if (recording)
{
UI_BeginRecordOK(true);
RecordFile_Open();
RecordFile_Record(0x100,0x54,0xc9);
};
d.Initialize();
GameSetup(_25_, 0);
//STShowCursor(HC50);
//STHideCursor(HC33);
//SmartDiscard(true);
//D0W = i16Result;
//DisableTraceIfEnciphered();
//if (D0W != -1)
{
TAG021028(_18_);
d.PartyHasDied = 0;
STShowCursor(HC33);
DiscardAllInput();
RETURN;
};
};
};
FadeToPalette(_12_,&LOCAL_110);
};
ExpandGraphic(LOCAL_10, d.LogicalScreenBase, 0, 0);
FadeToPalette(_13_,&d.Palette328);
i=0;
do
{
i++;
if (d.MouseSwitches != 0) break;
wvbl(_19_);//NotImplemented(0x1fea0);//pumper();
D0W = (I16)UI_CONSTAT();
} while ((D0W == 0)&&(!RepeatGame) || (i<2000)&&(RepeatGame));
// A mouse click gets us out of the credits screen to here.
if (d.CanRestartFromSavegame)
{
if (P1)
{
LOCAL_132 = 0;
FadeToPalette(_14_,&LOCAL_110);
STShowCursor(HC33);
STHideCursor(HC50);
goto tag01fd10;
};
}; if (!RepeatGame) UI_PushMessage(UIM_TERMINATE);
for(i=0;(i<2000)&&(RepeatGame) || (!RepeatGame); i++)
{
wvbl(_20_);
};
RETURN;
//return DoesNotExist;
}