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
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* cinE Engine is (C) 2004-2005 by CinE Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "cruise/cruise_main.h"
namespace Cruise {
uint16 var0 = 0;
uint16 fadeVar;
uint16 main15;
int16 readB16(void* ptr)
{
int16 temp;
temp = *(int16*)ptr;
flipShort(&temp);
return temp;
}
void freeObject(cellStruct* objPtr)
{
if(objPtr)
{
/* if(objPtr->next)
free(objPtr->next); */
//free(objPtr);
}
}
void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int backgroundPlane, int arg)
{
cellStruct* currentObj = objPtr->next;
cellStruct* previous;
while(currentObj)
{
cellStruct* si;
si = currentObj;
if( (si->overlay == ovlNumber || ovlNumber == -1) &&
(si->idx == objectIdx || objectIdx == -1) &&
(si->type == arg || arg == -1) &&
(si->backgroundPlane == backgroundPlane || backgroundPlane == -1) )
{
si->type = -1;
}
currentObj = si->next;
}
previous = objPtr;
currentObj = objPtr->next;
while(currentObj)
{
cellStruct* si;
si = currentObj;
if(si->type == -1)
{
cellStruct* dx;
previous->next = si->next;
dx = si->next;
if(!si->next)
{
dx = objPtr;
}
dx->prev = si->prev;
freeObject(si);
free(si);
currentObj = dx;
}
else
{
currentObj = si->next;
previous = si;
}
}
}
char* getText(int textIndex, int overlayIndex)
{
if(!overlayTable[overlayIndex].ovlData)
{
return NULL;
}
if(!overlayTable[overlayIndex].ovlData->stringTable)
{
return NULL;
}
return overlayTable[overlayIndex].ovlData->stringTable[textIndex].string;
}
void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6)
{
char* ax;
cellStruct* savePObject = pObject;
cellStruct* cx;
cellStruct* pNewElement;
cellStruct* si = pObject->next;
cellStruct* var_2;
while(si)
{
pObject = si;
si = si->next;
}
var_2 = si;
pNewElement = (cellStruct*)malloc(sizeof(cellStruct));
pNewElement->next = pObject->next;
pObject->next = pNewElement;
pNewElement->idx = oldVar8;
pNewElement->type = 5;
pNewElement->backgroundPlane = backgroundPlane;
pNewElement->overlay = overlayIdx;
pNewElement->field_A = oldVar6;
pNewElement->field_C = oldVar4;
pNewElement->spriteIdx = oldVar2;
pNewElement->field_10 = color;
pNewElement->freeze = 0;
pNewElement->field_16 = scriptNumber;
pNewElement->field_18 = scriptOverlayNumber;
pNewElement->gfxPtr = NULL;
if(var_2)
{
cx = var_2;
}
else
{
cx = savePObject;
}
pNewElement->prev = cx->prev;
cx->prev = pNewElement;
ax = getText(oldVar8, overlayIdx);
if(ax)
{
pNewElement->gfxPtr = renderText(oldVar2, (uint8*)ax);
}
}
} // End of namespace Cruise
|