-Cleanup strings

-Fix load saves from original interpreter
-Add all background merge functions

svn-id: r29467
This commit is contained in:
Vincent Hamm 2007-11-10 17:15:48 +00:00
parent 83eec141c8
commit faf78d582a
25 changed files with 457 additions and 337 deletions

View File

@ -85,7 +85,7 @@ int loadCVT(uint8 **ptr) {
extern int lastFileSize;
int loadBackground(char *name, int idx) {
int loadBackground(const char *name, int idx) {
uint8 *ptr;
uint8 *ptr2;
uint8 *ptrToFree;
@ -109,15 +109,14 @@ int loadBackground(char *name, int idx) {
}
ptrToFree = gfxModuleData.pPage10;
if (loadFileSub1(&ptrToFree, (uint8 *) name, NULL) < 0) {
if (loadFileSub1(&ptrToFree, name, NULL) < 0) {
if (ptrToFree != gfxModuleData.pPage10)
free(ptrToFree);
return (-18);
}
if (lastFileSize == 32078 || lastFileSize == 32080
|| lastFileSize == 32034) {
if (lastFileSize == 32078 || lastFileSize == 32080 || lastFileSize == 32034) {
colorMode = 0;
} else {
colorMode = 1;
@ -126,7 +125,7 @@ int loadBackground(char *name, int idx) {
ptr = ptrToFree;
ptr2 = ptrToFree;
if (!strcmpuint8(name, "LOGO.PI1")) {
if (!strcmp(name, "LOGO.PI1")) {
bgVar3 = bgVar2;
bgVar1 = 1;
bgVar2 = 1;
@ -137,7 +136,7 @@ int loadBackground(char *name, int idx) {
}
}
if (!strcmpuint8(ptr, "PAL")) {
if (!strcmp((char*)ptr, "PAL")) {
printf("Pal loading unsupported !\n");
exit(1);
} else {

View File

@ -38,7 +38,7 @@ extern int CVTLoaded;
extern uint8 *backgroundPtrtable[8];
extern backgroundTableStruct backgroundTable[8];
int loadBackground(char *name, int idx);
int loadBackground(const char *name, int idx);
} // End of namespace Cruise

View File

@ -35,8 +35,7 @@ void resetBackgroundIncrustList(backgroundIncrustStruct *pHead) {
}
// blit background to another one
void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char *ptr2,
int16 scale, char *destBuffer, char *dataPtr) {
void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char *ptr2, int16 scale, char *destBuffer, char *dataPtr) {
if (*dataPtr == 0) {
ASSERT(0);
}
@ -44,7 +43,50 @@ void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char *ptr2,
buildPolyModel(X, Y, scale, ptr2, destBuffer, dataPtr);
}
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx, backgroundIncrustStruct *pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 param4) {
void backupBackground(backgroundIncrustStruct *pIncrust, int X, int Y, int width, int height, uint8* pBackground)
{
pIncrust->saveWidth = width;
pIncrust->saveHeight = height;
pIncrust->saveSize = width*height;
pIncrust->savedX = X;
pIncrust->savedY = Y;
pIncrust->ptr = (uint8*)malloc(width*height);
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
{
pIncrust->ptr[i*width+j] = pBackground[(i+Y)*320+j+Y];
}
}
}
void restoreBackground(backgroundIncrustStruct *pIncrust)
{
if(pIncrust->type != 1)
return;
if(pIncrust->ptr == NULL)
return;
uint8* pBackground = backgroundPtrtable[pIncrust->backgroundIdx];
if(pBackground == NULL)
return;
int X = pIncrust->savedX;
int Y = pIncrust->savedY;
int width = pIncrust->saveWidth;
int height = pIncrust->saveHeight;
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
{
pBackground[(i+Y)*320+j+Y] = pIncrust->ptr[i*width+j];
}
}
}
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx, backgroundIncrustStruct *pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 saveBuffer) {
uint8 *backgroundPtr;
uint8 *ptr;
objectParamsQuery params;
@ -60,8 +102,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
return NULL;
}
if (filesDatabase[params.fileIdx].subData.resourceType != 4
&& filesDatabase[params.fileIdx].subData.resourceType != 8) {
if (filesDatabase[params.fileIdx].subData.resourceType != 4 && filesDatabase[params.fileIdx].subData.resourceType != 8) {
return NULL;
}
@ -80,9 +121,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
currentHead2 = currentHead->next;
}
newElement =
(backgroundIncrustStruct *)
mallocAndZero(sizeof(backgroundIncrustStruct));
newElement = (backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));
if (!newElement)
return NULL;
@ -98,7 +137,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
currentHead2->prev = newElement;
newElement->objectIdx = objectIdx;
newElement->type = param4;
newElement->type = saveBuffer;
newElement->backgroundIdx = backgroundIdx;
newElement->overlayIdx = overlayIdx;
newElement->scriptNumber = scriptNumber;
@ -107,7 +146,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
newElement->Y = params.Y;
newElement->scale = params.scale;
newElement->field_E = params.fileIdx;
newElement->aniX = filesDatabase[params.fileIdx].subData.index;
newElement->spriteId = filesDatabase[params.fileIdx].subData.index;
newElement->ptr = NULL;
strcpy(newElement->name, filesDatabase[params.fileIdx].subData.name);
@ -115,19 +154,31 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
int width = filesDatabase[params.fileIdx].width;
int height = filesDatabase[params.fileIdx].height;
if(saveBuffer == 1) {
backupBackground(newElement, newElement->X, newElement->Y, width, height, backgroundPtr);
}
drawSprite(width, height, NULL, (char *)filesDatabase[params.fileIdx].subData.ptr, newElement->Y, newElement->X, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptrMask);
// ASSERT(0);
} else { // poly
/* if (param4 == 1)
* {
* int var_A;
* int var_8;
* int var_6;
* char* var_10;
*
* mainDrawSub1Sub1(lvar[3], newElement->X, newElement->Y, &var_A, &var_8, &var_6, &var_10, lvar[4], filesDatabase[lvar[3]].subData.ptr);
* ASSERT(0);
* } */
if (saveBuffer == 1) {
int newX;
int newY;
int newScale;
char *newFrame;
int sizeTable[4]; // 0 = left, 1 = right, 2 = bottom, 3 = top
// this function checks if the dataPtr is not 0, else it retrives the data for X, Y, scale and DataPtr again (OLD: mainDrawSub1Sub1)
flipPoly(params.fileIdx, (int16*)filesDatabase[params.fileIdx].subData.ptr, params.scale, &newFrame, newElement->X, newElement->Y, &newX, &newY, &newScale);
// this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2)
getPolySize(newX, newY, newScale, sizeTable, (unsigned char*)newFrame);
int width = (sizeTable[1]+2) - (sizeTable[0]-2) + 1;
int height = sizeTable[3]-sizeTable[2]+1;
backupBackground(newElement, newElement->X, newElement->Y, width, height, backgroundPtr);
}
addBackgroundIncrustSub1(params.fileIdx, newElement->X, newElement->Y, NULL, params.scale, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptr);
}
@ -137,56 +188,104 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
void loadBackgroundIncrustFromSave(Common::File& currentSaveFile) {
int16 numEntry;
backgroundIncrustStruct *ptr1;
backgroundIncrustStruct *ptr2;
int32 i;
numEntry = currentSaveFile.readSint16LE();
ptr1 = &backgroundIncrustHead;
ptr2 = &backgroundIncrustHead;
backgroundIncrustStruct *pl = &backgroundIncrustHead;
backgroundIncrustStruct *pl1 = &backgroundIncrustHead;
for (i = 0; i < numEntry; i++) {
backgroundIncrustStruct *current = (backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));
backgroundIncrustStruct *pl2 = (backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));
currentSaveFile.skip(2);
currentSaveFile.skip(2);
current->objectIdx = currentSaveFile.readSint16LE();
current->type = currentSaveFile.readSint16LE();
current->overlayIdx = currentSaveFile.readSint16LE();
current->X = currentSaveFile.readSint16LE();
current->Y = currentSaveFile.readSint16LE();
current->field_E = currentSaveFile.readSint16LE();
current->scale = currentSaveFile.readSint16LE();
current->backgroundIdx = currentSaveFile.readSint16LE();
current->scriptNumber = currentSaveFile.readSint16LE();
current->scriptOverlayIdx = currentSaveFile.readSint16LE();
pl2->objectIdx = currentSaveFile.readSint16LE();
pl2->type = currentSaveFile.readSint16LE();
pl2->overlayIdx = currentSaveFile.readSint16LE();
pl2->X = currentSaveFile.readSint16LE();
pl2->Y = currentSaveFile.readSint16LE();
pl2->field_E = currentSaveFile.readSint16LE();
pl2->scale = currentSaveFile.readSint16LE();
pl2->backgroundIdx = currentSaveFile.readSint16LE();
pl2->scriptNumber = currentSaveFile.readSint16LE();
pl2->scriptOverlayIdx = currentSaveFile.readSint16LE();
currentSaveFile.skip(4);
current->field_1C = currentSaveFile.readSint32LE();
current->size = currentSaveFile.readSint16LE();
current->field_22 = currentSaveFile.readSint16LE();
current->field_24 = currentSaveFile.readSint16LE();
currentSaveFile.read(current->name, 13);
pl2->saveWidth = currentSaveFile.readSint16LE()*2;
pl2->saveHeight = currentSaveFile.readSint16LE();
pl2->saveSize = currentSaveFile.readUint16LE();
pl2->savedX = currentSaveFile.readSint16LE();
pl2->savedY = currentSaveFile.readSint16LE();
currentSaveFile.read(pl2->name, 13);
currentSaveFile.skip(1);
current->aniX = currentSaveFile.readSint16LE();
pl2->spriteId = currentSaveFile.readSint16LE();
currentSaveFile.skip(2);
if (current->size) {
current->ptr = (uint8 *) mallocAndZero(current->size);
currentSaveFile.read(current->ptr, current->size);
if (pl2->saveSize) {
/*pl2->ptr = (uint8 *) mallocAndZero(pl2->size);
currentSaveFile.read(pl2->ptr, pl2->size);*/
currentSaveFile.skip(pl2->saveSize);
int width = pl2->saveWidth;
int height = pl2->saveHeight;
pl2->ptr = (uint8*)malloc(width * height);
memset(pl2->ptr, 0, width * height);
// TODO: convert graphic format here
}
current->next = NULL;
ptr2 = current;
current->prev = backgroundIncrustHead.prev;
backgroundIncrustHead.prev = current;
ptr2 = current->next;
pl2->next = NULL;
pl->next = pl2;
pl2->prev = pl1->prev;
pl1->prev = pl2;
pl = pl2;
}
}
void regenerateBackgroundIncrust(backgroundIncrustStruct *pHead) {
printf("Need to regenerate backgroundIncrust\n");
lastAni[0] = 0;
backgroundIncrustStruct* pl = pHead->next;
while(pl) {
backgroundIncrustStruct* pl2 = pl->next;
bool bLoad = false;
int frame = pl->field_E;
int screen = pl->backgroundIdx;
if((filesDatabase[frame].subData.ptr == NULL) || (strcmp(pl->name, filesDatabase[frame].subData.name))) {
frame = 257 - 1;
if(loadFile( pl->name, frame, pl->spriteId ) >= 0) {
bLoad = true;
}
else
{
frame = -1;
}
}
if( frame >= -1 )
{
if (filesDatabase[frame].subData.resourceType == 4) { // sprite
int width = filesDatabase[frame].width;
int height = filesDatabase[frame].height;
drawSprite(width, height, NULL, (char *)filesDatabase[frame].subData.ptr, pl->Y, pl->X, (char*)backgroundPtrtable[pl->backgroundIdx], (char *)filesDatabase[frame].subData.ptrMask);
} else { // poly
addBackgroundIncrustSub1(frame, pl->X, pl->Y, NULL, pl->scale, (char*)backgroundPtrtable[pl->backgroundIdx], (char *)filesDatabase[frame].subData.ptr);
}
}
pl = pl2;
}
lastAni[0] = 0;
}
void freeBackgroundIncrustList(backgroundIncrustStruct *pHead) {
@ -223,9 +322,7 @@ void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHe
pCurrent = pHead->next;
while (pCurrent) {
if ((pCurrent->overlayIdx == overlay || overlay == -1) &&
(pCurrent->objectIdx == idx || idx == -1) &&
(pCurrent->X == var_4) && (pCurrent->Y == var_6)) {
if ((pCurrent->overlayIdx == overlay || overlay == -1) && (pCurrent->objectIdx == idx || idx == -1) && (pCurrent->X == var_4) && (pCurrent->Y == var_6)) {
pCurrent->type = - 1;
}
@ -265,4 +362,32 @@ void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHe
}
}
void unmergeBackgroundIncrust(backgroundIncrustStruct * pHead, int ovl, int idx)
{
backgroundIncrustStruct *pl;
backgroundIncrustStruct *pl2;
objectParamsQuery params;
getMultipleObjectParam(ovl, idx, &params);
int x = params.X;
int y = params.Y;
pl = pHead;
pl2 = pl;
pl = pl2->next;
while(pl)
{
pl2 = pl;
if((pl->overlayIdx == ovl) || (ovl == -1))
if((pl->objectIdx == idx) || (idx == -1))
if((pl->X == x) && (pl->Y == y))
restoreBackground(pl);
pl = pl2->next;
}
}
} // End of namespace Cruise

View File

@ -43,24 +43,24 @@ struct backgroundIncrustStruct {
uint16 scriptNumber;
uint16 scriptOverlayIdx;
uint8 *ptr;
int32 field_1C;
int16 size;
uint16 field_22;
uint16 field_24;
int16 saveWidth;
int16 saveHeight;
uint16 saveSize;
int16 savedX;
int16 savedY;
char name[13];
uint16 aniX;
uint16 spriteId;
};
extern backgroundIncrustStruct backgroundIncrustHead;
void resetBackgroundIncrustList(backgroundIncrustStruct * pHead);
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 param2,
backgroundIncrustStruct * pHead, int16 scriptNumber, int16 scriptOverlay,
int16 backgroundIdx, int16 param4);
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 param2, backgroundIncrustStruct * pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 param4);
void loadBackgroundIncrustFromSave(Common::File& currentSaveFile);
void regenerateBackgroundIncrust(backgroundIncrustStruct * pHead);
void freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead);
void unmergeBackgroundIncrust(backgroundIncrustStruct * pHead, int ovl, int idx);
} // End of namespace Cruise

View File

@ -130,12 +130,12 @@ void resetFileEntryRange(int param1, int param2) {
}
}
int getProcParam(int overlayIdx, int param2, uint8 *name) {
int getProcParam(int overlayIdx, int param2, const char *name) {
int numSymbGlob;
int i;
exportEntryStruct *arraySymbGlob;
uint8 *exportNamePtr;
uint8 exportName[80];
char *exportNamePtr;
char exportName[80];
if (!overlayTable[overlayIdx].alreadyLoaded)
return 0;
@ -152,10 +152,9 @@ int getProcParam(int overlayIdx, int param2, uint8 *name) {
for (i = 0; i < numSymbGlob; i++) {
if (arraySymbGlob[i].var4 == param2) {
strcpyuint8(exportName,
arraySymbGlob[i].offsetToName + exportNamePtr);
strcpy(exportName, arraySymbGlob[i].offsetToName + exportNamePtr);
if (!strcmpuint8(exportName, name)) {
if (!strcmp(exportName, name)) {
return (arraySymbGlob[i].idx);
}
}
@ -330,7 +329,7 @@ void removeExtention(const char *name, char *buffer) { // not like in original
int lastFileSize;
int loadFileSub1(uint8 **ptr, uint8 *name, uint8 *ptr2) {
int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) {
int i;
char buffer[256];
int fileIdx;
@ -339,7 +338,7 @@ int loadFileSub1(uint8 **ptr, uint8 *name, uint8 *ptr2) {
for (i = 0; i < 64; i++) {
if (mediumVar[i].ptr) {
if (!strcmpuint8(mediumVar[i].name, name)) {
if (!strcmp(mediumVar[i].name, name)) {
printf("Unsupported code in loadFIleSub1 !\n");
exit(1);
}
@ -353,7 +352,7 @@ int loadFileSub1(uint8 **ptr, uint8 *name, uint8 *ptr2) {
// if (useH32)
{
strcatuint8(buffer, ".H32");
strcat(buffer, ".H32");
}
/* else
* if (useAdlib)
@ -365,10 +364,10 @@ int loadFileSub1(uint8 **ptr, uint8 *name, uint8 *ptr2) {
* strcatuint8(buffer,".HP");
* } */
} else {
strcpyuint8(buffer, name);
strcpy(buffer, name);
}
fileIdx = findFileInDisks((uint8 *) buffer);
fileIdx = findFileInDisks(buffer);
if (fileIdx < 0)
return (-18);
@ -478,7 +477,7 @@ int initAllData(void) {
resetActorPtr(&actorHead);
resetBackgroundIncrustList(&backgroundIncrustHead);
bootOverlayNumber = loadOverlay((const uint8 *) "AUTO00");
bootOverlayNumber = loadOverlay("AUTO00");
#ifdef DUMP_SCRIPT
loadOverlay("TITRE");
@ -573,7 +572,7 @@ int initAllData(void) {
scriptFunc2(bootOverlayNumber, &procHead, 1, 0);
}
strcpyuint8(systemStrings.bootScriptName, "AUTO00");
strcpy(systemStrings.bootScriptName, "AUTO00");
return (bootOverlayNumber);
}
@ -627,7 +626,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) {
while (currentObject) {
if (currentObject->overlay >= 0 && overlayTable[currentObject->overlay].alreadyLoaded && (currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK || currentObject->type == OBJ_TYPE_EXIT || currentObject->type == OBJ_TYPE_VIRTUEL)) {
char* pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->arrayNameObj);
const char* pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->arrayNameObj);
if (pObjectName) {
strcpy(objectName, pObjectName);
@ -764,9 +763,9 @@ void *allocAndZero(int size) {
return ptr;
}
char *getObjectName(int index, uint8 *string) {
const char *getObjectName(int index, const char *string) {
int i;
char *ptr = (char *)string;
const char *ptr = string;
if (!string)
return NULL;
@ -920,7 +919,7 @@ bool findRelation(int objOvl, int objIdx, int x, int y) {
testState = ptrHead->obj1OldState;
if ((first) && (ovl3->arrayNameObj) && ((testState ==-1) || (testState == objectState))) {
char *ptrName = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj);
const char *ptrName = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj);
menuTable[0] = createMenu(x, y, ptrName);
first = false;
@ -928,7 +927,7 @@ bool findRelation(int objOvl, int objIdx, int x, int y) {
}
if ((ovl2) && (ptrHead->verbNumber>=0)) {
if (ovl2->nameVerbGlob) {
char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob);
const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob);
strcpy(verbe_name, ptr);
if ( (!first) && ((testState==-1) || (testState==objectState))) {
@ -1478,7 +1477,7 @@ void mainLoop(void) {
int enableUser = 0;
scriptNameBuffer[0] = 0;
strcpy(currentOverlay, "");
systemStrings.bootScriptName[0] = 0;
initVar4[0] = 0;
currentActiveMenu = -1;
@ -1493,7 +1492,7 @@ void mainLoop(void) {
initAllData();
// debug code: automaticaly load savegame 0 at startup
loadSavegameData(0);
// loadSavegameData(0);
{
int playerDontAskQuit = 1;

View File

@ -91,23 +91,21 @@ void *mallocAndZero(int32 size);
uint8 *mainProc14(uint16 overlay, uint16 idx);
void printInfoBlackBox(const char *string);
void waitForPlayerInput(void);
int loadCtp(uint8 * ctpName);
int loadCtp(const char * ctpName);
void loadPakedFileToMem(int fileIdx, uint8 * buffer);
int loadScriptSub1(int scriptIdx, int param);
void resetFileEntryRange(int param1, int param2);
int getProcParam(int overlayIdx, int param2, uint8 * name);
void changeScriptParamInList(int param1, int param2,
scriptInstanceStruct * pScriptInstance, int newValue, int param3);
int getProcParam(int overlayIdx, int param2, const char * name);
void changeScriptParamInList(int param1, int param2, scriptInstanceStruct * pScriptInstance, int newValue, int param3);
uint8 *getDataFromData3(ovlData3Struct * ptr, int param);
int32 prepareWordRender(int32 param, int32 var1, int16 * out2, uint8 * ptr3,
const uint8 * string);
int32 prepareWordRender(int32 param, int32 var1, int16 * out2, uint8 * ptr3, const uint8 * string);
void removeExtention(const char *name, char *buffer);
void resetRaster(uint8 * rasterPtr, int32 rasterSize);
void resetPtr2(scriptInstanceStruct * ptr);
void getFileExtention(const char *name, char *buffer);
void *allocAndZero(int size);
void freeStuff2(void);
char *getObjectName(int index, uint8 * string);
const char *getObjectName(int index, const char * string);
void mainLoop(void);
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
bool testMask(int x, int y, unsigned char* pData, int stride);

View File

@ -289,7 +289,7 @@ int getNode(int nodeResult[2], int nodeId){
return 0;
}
int loadCtp(uint8 *ctpName) {
int loadCtp(const char *ctpName) {
int walkboxCounter; // si
uint8 *ptr;
uint8 *dataPointer; // ptr2
@ -363,7 +363,7 @@ int loadCtp(uint8 *ctpName) {
free(ptr);
strcpyuint8(currentCtpName, ctpName);
strcpy(currentCtpName, ctpName);
numberOfWalkboxes = segementSizeTable[6] / 2; // get the number of walkboxes

View File

@ -51,7 +51,7 @@ extern ctpVar19Struct *ctpVar15;
extern uint8 *ctpVar17;
extern ctpVar19Struct *ctpVar19;
int loadCtp(uint8 * ctpName);
int loadCtp(const char * ctpName);
int ctpProc2(int varX, int varY, int paramX, int paramY);
int getNode(int nodeResult[2], int nodeId);

View File

@ -27,10 +27,6 @@
namespace Cruise {
void loadSetEntry(uint8 * name, uint8 * ptr, int currentEntryIdx,
int currentDestEntry);
void loadFNTSub(uint8 * ptr, int destIdx);
enum fileTypeEnum {
type_UNK,
type_SPL,
@ -232,12 +228,12 @@ int createResFileEntry(int width, int height, int resType) {
return entryNumber;
}
fileTypeEnum getFileType(uint8 *name) {
fileTypeEnum getFileType(const char *name) {
char extentionBuffer[16];
fileTypeEnum newFileType = type_UNK;
getFileExtention((char *)name, extentionBuffer);
getFileExtention(name, extentionBuffer);
if (!strcmp(extentionBuffer, ".SPL")) {
newFileType = type_SPL;
@ -259,7 +255,46 @@ int getNumMaxEntiresInSet(uint8 *ptr) {
return numEntries;
}
int loadFileMode2(uint8 *name, int startIdx, int currentEntryIdx, int numIdx) {
int loadFile(const char* name, int idx, int destIdx)
{
uint8 *ptr = NULL;
fileTypeEnum fileType;
fileType = getFileType(name);
loadFileSub1(&ptr, name, NULL);
switch (fileType) {
case type_SET:
{
int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr);
if (idx > numMaxEntriesInSet) {
return 0; // exit if limit is reached
}
return loadSetEntry(name, ptr, idx, destIdx );
break;
}
case type_FNT:
{
return loadFNTSub(ptr, idx);
break;
}
case type_UNK:
{
break;
}
case type_SPL:
{
break;
}
}
return -1;
}
int loadFileRange(const char *name, int startIdx, int currentEntryIdx, int numIdx) {
uint8 *ptr = NULL;
fileTypeEnum fileType;
@ -274,11 +309,10 @@ int loadFileMode2(uint8 *name, int startIdx, int currentEntryIdx, int numIdx) {
int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr);
for (i = 0; i < numIdx; i++) {
if ((currentEntryIdx + i) > numMaxEntriesInSet) {
if ((startIdx + i) > numMaxEntriesInSet) {
return 0; // exit if limit is reached
}
loadSetEntry(name, ptr, currentEntryIdx + i,
startIdx + i);
loadSetEntry(name, ptr, startIdx + i, currentEntryIdx + i );
}
break;
@ -300,7 +334,7 @@ int loadFileMode2(uint8 *name, int startIdx, int currentEntryIdx, int numIdx) {
return 0;
}
int loadFullBundle(uint8 *name, int startIdx) {
int loadFullBundle(const char *name, int startIdx) {
uint8 *ptr = NULL;
fileTypeEnum fileType;
@ -340,7 +374,7 @@ int loadFullBundle(uint8 *name, int startIdx) {
return 0;
}
void loadFNTSub(uint8 *ptr, int destIdx) {
int loadFNTSub(uint8 *ptr, int destIdx) {
uint8 *ptr2 = ptr;
uint8 *destPtr;
int fileIndex;
@ -384,16 +418,18 @@ void loadFNTSub(uint8 *ptr, int destIdx) {
currentPtr += 8;
}
}
return 1;
}
void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx, int currentDestEntry) {
int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentDestEntry) {
uint8 *ptr2;
uint8 *ptr3;
int offset;
int sec = 0;
uint16 numIdx;
if (!strcmpuint8(ptr, "SEC")) {
if (!strcmp((char*)ptr, "SEC")) {
sec = 1;
}
@ -433,7 +469,7 @@ void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx, int currentDestE
}
if (fileIndex < 0) {
return; // TODO: buffer is not freed
return -1; // TODO: buffer is not freed
}
ptr5 = ptr3 + localBuffer.field_0 + numIdx * 16;
@ -470,7 +506,7 @@ void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx, int currentDestE
if (sec == 0) {
// TODO sec type 5 needs special conversion. cut out 2 bytes at every width/5 position.
ASSERT(0);
return;
return -1;
}
filesDatabase[fileIndex].subData.resourceType = 4;
@ -495,7 +531,7 @@ void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx, int currentDestE
}
}
strcpyuint8(filesDatabase[fileIndex].subData.name, name);
strcpy(filesDatabase[fileIndex].subData.name, name);
// create the mask
switch(localBuffer.type)
@ -530,7 +566,7 @@ void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx, int currentDestE
// TODO: free
return;
return 1;
}
} // End of namespace Cruise

View File

@ -28,11 +28,13 @@
namespace Cruise {
int loadData(uint8 * name, int startIdx);
int loadFileMode2(uint8 * name, int param, int startIdx, int numIdx);
int loadFileSub1(uint8 ** ptr, uint8 * name, uint8 * ptr2);
int loadFullBundle(uint8 * name, int startIdx);
int loadFNTSub(uint8 *ptr, int destIdx);
int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentDestEntry);
int loadFile(const char* name, int idx, int destIdx);
int loadData(const char * name, int startIdx);
int loadFileRange(const char * name, int param, int startIdx, int numIdx);
int loadFileSub1(uint8 ** ptr, const char * name, uint8 * ptr2);
int loadFullBundle(const char * name, int startIdx);
} // End of namespace Cruise

View File

@ -735,8 +735,8 @@ int decompSwapStack(void) {
stack1 = popDecomp();
stack2 = popDecomp();
strcpyuint8(buffer1, stack1);
strcpyuint8(buffer2, stack2);
strcpy(buffer1, stack1);
strcpy(buffer2, stack2);
pushDecomp(buffer1);
pushDecomp(buffer2);

View File

@ -107,17 +107,17 @@ int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth,
}
}
void loadFNT(const void *fileNameChar) {
void loadFNT(const char *fileName) {
uint8 header[6];
int32 fontSize;
int32 data2;
uint8 data3[6];
const uint8 *fileName = (const uint8 *)fileNameChar;
_systemFNT = NULL;
Common::File fontFileHandle;
if (!fontFileHandle.exists((const char *)fileName)) {
if (!fontFileHandle.exists(fileName)) {
return;
}
@ -125,7 +125,7 @@ void loadFNT(const void *fileNameChar) {
fontFileHandle.read(header, 4);
if (strcmpuint8(header, "FNT") == 0) {
if (strcmp((char*)header, "FNT") == 0) {
fontFileHandle.read(&fontSize, 4);
flipLong(&fontSize);
@ -182,7 +182,7 @@ void loadSystemFont(void) {
main5 = 0;
var22 = 0;
initVar2 = 0;
initVar3 = 0;
switchPal = 0;
currentActiveBackgroundPlane = 0;
//changeCursor();

View File

@ -28,7 +28,7 @@
namespace Cruise {
void loadFNT(const void *fileName);
void loadFNT(const char *fileName);
void loadSystemFont(void);
//////////////////////////////////////////////////

View File

@ -33,34 +33,28 @@ namespace Cruise {
opcodeFunction opcodeTablePtr[256];
int16 Op_LoadOverlay(void) {
uint8 *originalScriptName;
uint8 scriptName[38];
int returnValue;
char *pOverlayName;
char overlayName[38] = "";
int overlayLoadResult;
scriptName[0] = 0;
pOverlayName = (char *) popPtr();
originalScriptName = (uint8 *) popPtr();
if(strlen(pOverlayName) == 0)
return 0;
if (originalScriptName) {
strcpyuint8(scriptName, originalScriptName);
}
if (!scriptName[0] || !originalScriptName) {
return (0);
}
strToUpper(scriptName);
strcpy(overlayName, pOverlayName);
strToUpper(overlayName);
//gfxModuleData.field_84();
//gfxModuleData.field_84();
returnValue = loadOverlay(scriptName);
overlayLoadResult = loadOverlay(overlayName);
updateAllScriptsImports();
strcpyuint8(scriptNameBuffer, scriptName);
strcpy(currentOverlay, overlayName);
return (returnValue);
return(overlayLoadResult);
}
int16 Op_strcpy(void) {
@ -245,21 +239,17 @@ int16 Op_freeBackgroundInscrustList(void) {
return (0);
}
int16 Op_removeBackground(void) {
int backgroundIdx = popVar();
int ovl;
ovl = popVar();
printf("Op_removeBackground: remove background %d\n", backgroundIdx);
return (0);
}
int16 Op_UnmergeBackgroundIncrust(void) {
int backgroundIdx = popVar();
int ovl;
int obj = popVar();
int ovl = popVar();
if (!ovl) {
ovl = currentScriptPtr->overlayNumber;
}
unmergeBackgroundIncrust(&backgroundIncrustHead, ovl, obj);
ovl = popVar();
printf("Op_UnmergeBackgroundIncrust: unmerge background %d\n", backgroundIdx);
return (0);
}
@ -287,20 +277,20 @@ int16 Op_RemoveMessage(void) {
int16 Op_isFileLoaded(void) {
int16 i;
uint8 name[36] = "";
uint8 *ptr;
char name[36] = "";
char *ptr;
ptr = (uint8 *) popPtr();
ptr = (char *) popPtr();
if (!ptr) {
return -1;
}
strcpyuint8(name, ptr);
strcpy(name, ptr);
strToUpper(name);
for (i = 0; i < 257; i++) {
if (!strcmpuint8(name, filesDatabase[i].subData.name)) {
if (!strcmp(name, filesDatabase[i].subData.name)) {
return (i);
}
}
@ -347,12 +337,12 @@ int16 Op_RemoveProc(void) {
}
int16 Op_FreeOverlay(void) {
uint8 localName[36] = "";
uint8 *namePtr;
char localName[36] = "";
char *namePtr;
namePtr = (uint8 *) popPtr();
namePtr = (char *) popPtr();
strcpyuint8(localName, namePtr);
strcpy(localName, namePtr);
if (localName[0]) {
strToUpper(localName);
@ -363,13 +353,13 @@ int16 Op_FreeOverlay(void) {
}
int16 Op_2B(void) {
uint8 name[36] = "";
uint8 *ptr;
char name[36] = "";
char *ptr;
int param;
ptr = (uint8 *) popPtr();
ptr = (char *)popPtr();
strcpyuint8(name, ptr);
strcpy(name, ptr);
param = getProcParam(popVar(), 20, name);
@ -424,13 +414,13 @@ int16 Op_62(void) {
int16 Op_LoadBackground(void) {
int result = 0;
uint8 bgName[36] = "";
uint8 *ptr;
char bgName[36] = "";
char *ptr;
int bgIdx;
ptr = (uint8 *) popPtr();
ptr = (char *) popPtr();
strcpyuint8(bgName, ptr);
strcpy(bgName, ptr);
bgIdx = popVar();
@ -440,7 +430,7 @@ int16 Op_LoadBackground(void) {
gfxModuleData_gfxWaitVSync();
gfxModuleData_gfxWaitVSync();
result = loadBackground((char *)bgName, bgIdx);
result = loadBackground(bgName, bgIdx);
}
changeCursor(CURSOR_NORMAL);
@ -468,12 +458,12 @@ int16 Op_loadFile(void) {
int param1;
int param2;
int param3;
uint8 name[36] = "";
uint8 *ptr;
char name[36] = "";
char *ptr;
ptr = (uint8 *) popPtr();
ptr = (char *) popPtr();
strcpyuint8(name, ptr);
strcpy(name, ptr);
param1 = popVar();
param2 = popVar();
@ -485,11 +475,11 @@ int16 Op_loadFile(void) {
gfxModuleData_gfxWaitVSync();
gfxModuleData_gfxWaitVSync();
saveVar6[0] = 0;
lastAni[0] = 0;
loadFileMode2(name, param3, param2, param1);
loadFileRange(name, param2, param3, param1);
saveVar6[0] = 0;
lastAni[0] = 0;
}
changeCursor(CURSOR_NORMAL);
@ -500,13 +490,13 @@ int16 Op_LoadAbs(void) {
int param1;
// int param2;
// int param3;
uint8 name[36] = "";
uint8 *ptr;
char name[36] = "";
char *ptr;
int result = 0;
ptr = (uint8 *) popPtr();
ptr = (char *) popPtr();
strcpyuint8(name, ptr);
strcpy(name, ptr);
param1 = popVar();
@ -545,12 +535,11 @@ int16 Op_FadeOut(void) {
return 0;
}
int16 isOverlayLoaded(uint8 * name) {
int16 isOverlayLoaded(const char * name) {
int16 i;
for (i = 1; i < numOfLoadedOverlay; i++) {
if (!strcmpuint8(overlayTable[i].overlayName, name)
&& overlayTable[i].alreadyLoaded) {
if (!strcmp(overlayTable[i].overlayName, name) && overlayTable[i].alreadyLoaded) {
return i;
}
}
@ -559,12 +548,12 @@ int16 isOverlayLoaded(uint8 * name) {
}
int16 Op_FindOverlay(void) {
uint8 name[36] = "";
uint8 *ptr;
char name[36] = "";
char *ptr;
ptr = (uint8 *) popPtr();
ptr = (char *) popPtr();
strcpyuint8(name, ptr);
strcpy(name, ptr);
strToUpper(name);
return (isOverlayLoaded(name));
@ -706,7 +695,7 @@ int16 Op_loadAudioResource(void) {
}
int16 Op_LoadCt(void) {
return loadCtp((uint8 *) popPtr());
return loadCtp((char*)popPtr());
}
int16 Op_loadMusic(void) {
@ -807,13 +796,33 @@ int16 Op_SetActiveBackgroundPlane(void) {
if (newPlane >= 0 && newPlane < 8) {
if (backgroundPtrtable[newPlane]) {
currentActiveBackgroundPlane = newPlane;
initVar3 = 1;
switchPal = 1;
}
}
return currentPlane;
}
int16 Op_removeBackground(void) {
int backgroundIdx = popVar();
if(backgroundIdx > 0 && backgroundIdx < 8) {
if(backgroundPtrtable[backgroundIdx])
free(backgroundPtrtable[backgroundIdx]);
if(currentActiveBackgroundPlane == backgroundIdx)
currentActiveBackgroundPlane = 0;
strcpy(backgroundTable[backgroundIdx].name, "");
}
else
{
strcpy(backgroundTable[0].name, "");
}
return (0);
}
int op6AVar;
int16 Op_6A(void) {
@ -1376,7 +1385,7 @@ int16 Op_InitializeState2(void) {
if (!var1)
var1 = currentScriptPtr->overlayNumber;
return getProcParam(var1, var0, (uint8 *) ptr);
return getProcParam(var1, var0, ptr);
}
int16 Op_2A(void) {
@ -1395,7 +1404,7 @@ int16 Op_2A(void) {
if (!overlayIdx)
overlayIdx = currentScriptPtr->overlayNumber;
return getProcParam(overlayIdx, 40, (uint8 *) var_26);
return getProcParam(overlayIdx, 40, var_26);
}
int16 Op_SetObjectAtNode(void) {

View File

@ -27,34 +27,33 @@
namespace Cruise {
exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx,
char *buffer) {
exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, char *buffer) {
char localBuffer[256];
uint8 functionName[256];
uint8 overlayName[256];
char functionName[256];
char overlayName[256];
char *dotPtr;
char *ptr2;
int idx;
int numSymbGlob;
exportEntryStruct *currentExportEntry;
uint8 *entity1Name;
char *entity1Name;
int i;
*out1 = 0;
*pExportedFuncionIdx = 0;
strcpyuint8(localBuffer, buffer);
strcpy(localBuffer, buffer);
dotPtr = strchr(localBuffer, '.');
if (dotPtr) {
strcpyuint8(functionName, dotPtr + 1);
strcpy(functionName, dotPtr + 1);
*dotPtr = 0;
strcpyuint8(overlayName, localBuffer);
strcpy(overlayName, localBuffer);
} else {
overlayName[0] = 0;
strcpyuint8(functionName, buffer);
strcpy(functionName, buffer);
}
ptr2 = strchr((char *)functionName, ':');
@ -89,13 +88,13 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx,
return (0);
for (i = 0; i < numSymbGlob; i++) {
uint8 exportedName[256];
uint8 *name = entity1Name + currentExportEntry->offsetToName;
char exportedName[256];
char *name = entity1Name + currentExportEntry->offsetToName;
strcpyuint8(exportedName, name);
strcpy(exportedName, name);
strToUpper(exportedName);
if (!strcmpuint8(functionName, exportedName)) {
if (!strcmp(functionName, exportedName)) {
*pExportedFuncionIdx = idx;
return (currentExportEntry);
@ -144,7 +143,7 @@ int updateScriptImport(int ovlIdx) {
if (var_32) {
do {
importScriptStruct *ptrImportData;
uint8 *ptrImportName;
const char *ptrImportName;
uint8 *ptrData;
int var_22 = 0;
@ -156,7 +155,7 @@ int updateScriptImport(int ovlIdx) {
}
ptrImportData = (importScriptStruct *) (pScript->dataPtr + pScript->offsetToImportData); // import data
ptrImportName = pScript->dataPtr + pScript->offsetToImportName; // import name
ptrImportName = (const char*)(pScript->dataPtr + pScript->offsetToImportName); // import name
ptrData = pScript->dataPtr;
var_22 = 0;
@ -165,22 +164,15 @@ int updateScriptImport(int ovlIdx) {
int counter = pScript->numRelocGlob;
do {
int param2 =
ptrImportData->type;
int param2 = ptrImportData->type;
if (param2 != 70) {
exportEntryStruct
* ptrDest2;
exportEntryStruct * ptrDest2;
int out1;
int out2;
strcpyuint8(buffer,
ptrImportName +
ptrImportData->
offsetToName);
ptrDest2 =
parseExport(&out1,
&out2, buffer);
strcpy(buffer, ptrImportName + ptrImportData->offsetToName);
ptrDest2 = parseExport(&out1, &out2, buffer);
if (ptrDest2 && out2) {
int temp =
@ -258,7 +250,7 @@ int updateScriptImport(int ovlIdx) {
int linkType;
int linkEntryIdx;
strcpyuint8(buffer,
strcpy(buffer,
ovlData->arrayNameRelocGlob +
ovlData->arrayRelocGlob[i].nameOffset);

View File

@ -38,11 +38,10 @@ int upscaleValue(int value, int scale);
void pixel(int x, int y, char color);
void mainDraw(int16 param);
void flipScreen(void);
void buildPolyModel(int X, int Y, int scale, char *ptr2, char *destBuffer,
char *dataPtr);
void drawSprite(int objX1, int var_6, cellStruct * currentObjPtr,
char *data1, int objY2, int objX2, char *output, char *data2);
void buildPolyModel(int X, int Y, int scale, char *ptr2, char *destBuffer, char *dataPtr);
void drawSprite(int objX1, int var_6, cellStruct * currentObjPtr, char *data1, int objY2, int objX2, char *output, char *data2);
void flipPoly(int fileId, int16 *dataPtr, int scale, char** newFrame, int X, int Y, int *outX, int *outY, int *outScale);
void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsigned char *dataPtr);
bool findPoly(char* dataPtr, int x, int y, int zoom, int mouseX, int mouseY);
unsigned char *drawPolyMode2(unsigned char *dataPointer, int linesToDraw);
} // End of namespace Cruise

View File

@ -43,11 +43,11 @@ void initOverlayTable(void) {
numOfLoadedOverlay = 1;
}
int loadOverlay(const uint8 *scriptName) {
int loadOverlay(const char *scriptName) {
int newNumberOfScript;
bool scriptNotLoadedBefore;
int scriptIdx;
uint8 fileName[50];
char fileName[50];
int fileIdx;
int unpackedSize;
char *unpackedBuffer;
@ -80,7 +80,7 @@ int loadOverlay(const uint8 *scriptName) {
if (!overlayTable[scriptIdx].ovlData)
return (-2);
strcpyuint8(overlayTable[scriptIdx].overlayName, scriptName);
strcpy(overlayTable[scriptIdx].overlayName, scriptName);
overlayTable[scriptIdx].alreadyLoaded = 1;
@ -88,9 +88,9 @@ int loadOverlay(const uint8 *scriptName) {
overlayTable[scriptIdx].ovlData->scriptNumber = scriptIdx;
strcpyuint8(fileName, scriptName);
strcpy(fileName, scriptName);
strcatuint8(fileName, ".OVL");
strcat(fileName, ".OVL");
printf("Attempting to load overlay file %s...\n", fileName);
@ -192,15 +192,13 @@ int loadOverlay(const uint8 *scriptName) {
}
if (ovlData->exportNamesSize) { // export names
ovlData->arrayNameSymbGlob =
(uint8 *) mallocAndZero(ovlData->exportNamesSize);
ovlData->arrayNameSymbGlob = (char *) mallocAndZero(ovlData->exportNamesSize);
if (!ovlData->arrayNameSymbGlob) {
return (-2);
}
memcpy(ovlData->arrayNameSymbGlob, scriptPtr,
ovlData->exportNamesSize);
memcpy(ovlData->arrayNameSymbGlob, scriptPtr, ovlData->exportNamesSize);
scriptPtr += ovlData->exportNamesSize;
}
@ -231,8 +229,7 @@ int loadOverlay(const uint8 *scriptName) {
}
if (ovlData->nameExportSize) { // import name
ovlData->arrayNameRelocGlob =
(uint8 *) mallocAndZero(ovlData->nameExportSize);
ovlData->arrayNameRelocGlob = (char *) mallocAndZero(ovlData->nameExportSize);
if (!ovlData->arrayNameRelocGlob) {
return (-2);
@ -521,9 +518,9 @@ int loadOverlay(const uint8 *scriptName) {
//uint8 fileName[50];
//char* unpackedBuffer;
strcpyuint8(fileName, scriptName);
strcpy(fileName, scriptName);
strcatuint8(fileName, ".FR");
strcat(fileName, ".FR");
fileIdx = findFileInDisks(fileName);
@ -564,9 +561,7 @@ int loadOverlay(const uint8 *scriptName) {
flipShort(&ovlData->specialString1Length); // recheck if needed
if (ovlData->specialString1Length) {
ovlData->nameVerbGlob =
(uint8 *) mallocAndZero(ovlData->
specialString1Length);
ovlData->nameVerbGlob = (char *) mallocAndZero(ovlData->specialString1Length);
if (!ovlData->nameVerbGlob) {
/* releaseScript(scriptIdx,scriptName);
@ -589,9 +584,7 @@ int loadOverlay(const uint8 *scriptName) {
flipShort(&ovlData->specialString2Length); // recheck if needed
if (ovlData->specialString2Length) {
ovlData->arrayNameObj =
(uint8 *) mallocAndZero(ovlData->
specialString2Length);
ovlData->arrayNameObj = (char *) mallocAndZero(ovlData->specialString2Length);
if (!ovlData->arrayNameObj) {
/* releaseScript(scriptIdx,scriptName);
@ -717,11 +710,11 @@ int releaseOverlay(const char *name) {
return 0;
}
int32 findOverlayByName2(const uint8 *name) {
int32 findOverlayByName2(const char *name) {
int i;
for (i = 1; i < numOfLoadedOverlay; i++) {
if (!strcmpuint8(overlayTable[i].overlayName, name))
if (!strcmp(overlayTable[i].overlayName, name))
return (i);
}

View File

@ -135,10 +135,10 @@ struct ovlDataStruct {
importDataStruct *arrayRelocGlob;
linkDataStruct *arrayMsgRelHeader;
uint8 *nameVerbGlob;
uint8 *arrayNameObj;
uint8 *arrayNameRelocGlob;
uint8 *arrayNameSymbGlob;
char *nameVerbGlob;
char *arrayNameObj;
char *arrayNameRelocGlob;
char *arrayNameSymbGlob;
uint8 *data4Ptr;
uint8 *ptr8;
@ -178,8 +178,8 @@ extern overlayStruct overlayTable[90];
extern int numOfLoadedOverlay;
void initOverlayTable(void);
int loadOverlay(const uint8 * scriptName);
int32 findOverlayByName2(const uint8 * name);
int loadOverlay(const char * scriptName);
int32 findOverlayByName2(const char * name);
int findOverlayByName(const char *overlayName);
int releaseOverlay(const char *name);

View File

@ -248,7 +248,7 @@ int loadSavegameData(int saveGameIdx) {
animationStart = false;
currentActiveBackgroundPlane = currentSaveFile.readSint16LE();
initVar3 = currentSaveFile.readSint16LE();
switchPal = currentSaveFile.readSint16LE();
initVar2 = currentSaveFile.readSint16LE();
var22 = currentSaveFile.readSint16LE();
main5 = currentSaveFile.readSint16LE();
@ -350,7 +350,7 @@ int loadSavegameData(int saveGameIdx) {
for (int j = 1; j < numOfLoadedOverlay; j++) {
if (overlayTable[j].alreadyLoaded) {
overlayTable[j].alreadyLoaded = 0;
loadOverlay((uint8 *) overlayTable[j].overlayName);
loadOverlay(overlayTable[j].overlayName);
if (overlayTable[j].alreadyLoaded) {
ovlDataStruct *ovlData = overlayTable[j].ovlData;
@ -379,26 +379,18 @@ int loadSavegameData(int saveGameIdx) {
updateAllScriptsImports();
saveVar6[0] = 0;
lastAni[0] = 0;
initVar1Save = initVar1;
for (int j = 0; j < 257; j++) {
if (filesDatabase[j].subData.ptr) {
int i;
for (int i = 0; i < 257; i++) {
if (filesDatabase[i].subData.ptr) {
int j;
int k;
for (i = j + 1; i < 257; i++) {
if (filesDatabase[i].subData.ptr) {
if (strcmpuint8(filesDatabase[j].subData.name, filesDatabase[i].subData.name)) {
break;
}
} else {
break;
}
}
for (j = i + 1; j < 257 && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j-i)); j++);
for (k = j; k < i; k++) {
for (k = i; k < j; k++) {
if (filesDatabase[k].subData.ptrMask)
initVar1 = 0;
@ -406,27 +398,26 @@ int loadSavegameData(int saveGameIdx) {
filesDatabase[k].subData.ptrMask = NULL;
}
if (i < 2) {
if (j < 2) {
printf("Unsupported mono file load!\n");
exit(1);
ASSERT(0);
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
} else {
loadFileMode2((uint8 *) filesDatabase[j].subData.name, filesDatabase[j].subData.index, j, i - j);
j = i - 1;
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
i = j - 1;
}
initVar1 = initVar1Save;
}
}
saveVar6[0] = 0;
lastAni[0] = 0;
currentcellHead = cellHead.next;
while (currentcellHead) {
if (currentcellHead->type == 5) {
uint8 *ptr = mainProc14(currentcellHead->overlay,
currentcellHead->idx);
uint8 *ptr = mainProc14(currentcellHead->overlay, currentcellHead->idx);
ASSERT(0);
@ -434,6 +425,7 @@ int loadSavegameData(int saveGameIdx) {
ASSERT(0);
//*(int16*)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentcellHead->datas+0xE));
} else {
ASSERT(0);
//*(int16*)(currentcellHead->datas+0x2E) = 0;
}
}
@ -443,7 +435,7 @@ int loadSavegameData(int saveGameIdx) {
//TODO: here, restart music
if (strlen((char *)currentCtpName)) {
if (strlen(currentCtpName)) {
ctpVar1 = 1;
loadCtp(currentCtpName);
ctpVar1 = 0;

View File

@ -27,16 +27,4 @@
namespace Cruise {
void strcpyuint8(void *dest, const void *source) {
strcpy((char *)dest, (const char *)source);
}
void strcatuint8(void *dest, const void *source) {
strcat((char *)dest, (const char *)source);
}
uint8 strcmpuint8(const void *string1, const void *string2) {
return strcmp((const char *)string1, (const char *)string2);
}
} // End of namespace Cruise

View File

@ -28,12 +28,6 @@
namespace Cruise {
// TODO: Get rid of these and this file (either use strcpy directly, or switch to Common::String)
void strcpyuint8(void *dest, const void *source);
void strcatuint8(void *dest, const void *source);
uint8 strcmpuint8(const void *string1, const void *string2);
} // End of namespace Cruise
#endif

View File

@ -36,7 +36,7 @@ uint8 colorOfSelectedSaveDrive = 5;
int16 initVar1;
int16 initVar2;
int16 initVar3;
int16 switchPal;
uint8 initVar4[90];
int16 currentActiveBackgroundPlane;
@ -54,7 +54,7 @@ int32 volumeDataLoaded = 0;
int16 numOfDisks;
uint8 scriptNameBuffer[15];
char currentOverlay[15];
int16 currentActiveMenu;
int16 autoMsg;
menuElementSubStruct* linkedRelation;
@ -147,7 +147,7 @@ int16 palette[256 * 3];
systemStringsStruct systemStrings;
uint8 currentCtpName[40];
char currentCtpName[40];
int16 saveVar1;
uint8 saveVar2[97]; // recheck size
@ -156,7 +156,7 @@ int16 numberOfWalkboxes; // saveVar3
int16 walkboxType[15]; // saveVar4
int16 walkboxChange[15]; // saveVar5
uint8 saveVar6[16];
uint8 lastAni[16];
int32 loadFileVar1;

View File

@ -61,7 +61,7 @@ extern uint8 colorOfSelectedSaveDrive;
extern int16 initVar1;
extern int16 initVar2;
extern int16 initVar3;
extern int16 switchPal;
extern uint8 initVar4[90];
extern int16 currentActiveBackgroundPlane;
@ -69,7 +69,7 @@ extern int16 main5;
extern int16 var22;
struct mediumVarStruct {
uint8 name[15];
char name[15];
int32 size;
int32 sourceSize;
uint8 *ptr;
@ -89,7 +89,7 @@ struct filesData2Struct {
};
struct fileName {
uint8 name[13];
char name[13];
};
struct setHeaderEntry {
@ -111,7 +111,7 @@ struct volumeDataStruct {
};
struct fileEntry {
uint8 name[14];
char name[14];
int32 offset;
int32 size;
int32 extSize;
@ -138,8 +138,8 @@ struct dataFileEntry {
struct systemStringsStruct {
int8 param;
uint8 string[12];
uint8 bootScriptName[8];
char string[12];
char bootScriptName[8];
};
extern filesDataStruct filesData[90];
@ -153,7 +153,7 @@ extern int32 volumeDataLoaded;
extern int16 numOfDisks;
extern uint8 scriptNameBuffer[15];
extern char currentOverlay[15];
extern int16 currentActiveMenu;
extern int16 autoMsg;
extern menuElementSubStruct* linkedRelation;
@ -244,7 +244,7 @@ extern int16 palette[256 * 3];
extern systemStringsStruct systemStrings;
extern uint8 currentCtpName[40];
extern char currentCtpName[40];
extern int16 saveVar1;
extern uint8 saveVar2[97]; // recheck size
@ -253,7 +253,7 @@ extern int16 numberOfWalkboxes; // saveVar3
extern int16 walkboxType[15]; // saveVar4 // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone
extern int16 walkboxChange[15]; // saveVar5 // walkbox can change its type: 0x00 - not changeable, 0x01 - changeable
// Assumption: To change the type: walkboxType[i] -= walkboxChane[i] and vice versa
extern uint8 saveVar6[16];
extern uint8 lastAni[16];
extern int32 loadFileVar1;

View File

@ -69,7 +69,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
askDisk(-1);
strcpyuint8(buffer, entry->ident);
strcpy(buffer, entry->ident);
currentVolumeFile.open(buffer);
@ -121,7 +121,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
return 0;
}
int searchFileInVolCnf(uint8 *fileName, int32 diskNumber) {
int searchFileInVolCnf(const char *fileName, int32 diskNumber) {
int foundDisk = -1;
int i;
@ -131,8 +131,7 @@ int searchFileInVolCnf(uint8 *fileName, int32 diskNumber) {
int numOfEntry = volumeData[i].size / 13;
for (j = 0; j < numOfEntry; j++) {
if (!strcmpuint8(volumeData[i].ptr[j].name,
fileName)) {
if (!strcmp(volumeData[i].ptr[j].name, fileName)) {
return (i);
}
}
@ -142,7 +141,7 @@ int searchFileInVolCnf(uint8 *fileName, int32 diskNumber) {
return (foundDisk);
}
int32 findFileInDisksSub1(uint8 *fileName) {
int32 findFileInDisksSub1(const char *fileName) {
int foundDisk = -1;
int i;
@ -151,7 +150,7 @@ int32 findFileInDisksSub1(uint8 *fileName) {
int numOfEntry = volumeData[i].size / 13;
for (j = 0; j < numOfEntry; j++) {
if (!strcmpuint8(volumeData[i].ptr[j].name, fileName)) {
if (!strcmp(volumeData[i].ptr[j].name, fileName)) {
return (i);
}
}
@ -160,7 +159,7 @@ int32 findFileInDisksSub1(uint8 *fileName) {
return (foundDisk);
}
void strToUpper(uint8 *fileName) {
void strToUpper(char *fileName) {
char character;
do {
@ -190,7 +189,7 @@ void freeDisk(void) {
*/
}
int16 findFileInList(uint8 *fileName) {
int16 findFileInList(char *fileName) {
int i;
if (!currentVolumeFile.isOpen()) {
@ -204,7 +203,7 @@ int16 findFileInList(uint8 *fileName) {
}
for (i = 0; i < volumeNumEntry; i++) {
if (!strcmpuint8(volumePtrToFileDescriptor[i].name, fileName)) {
if (!strcmp(volumePtrToFileDescriptor[i].name, fileName)) {
return (i);
}
}
@ -213,9 +212,8 @@ int16 findFileInList(uint8 *fileName) {
}
void askDisk(int16 discNumber) {
char diskNumberString[256];
uint8 fileName[256];
uint8 string[256];
char fileName[256];
char string[256];
char messageDrawn = 0;
if (discNumber != -1) {
@ -223,13 +221,9 @@ void askDisk(int16 discNumber) {
}
// skip drive selection stuff
strcpyuint8(fileName, "VOL.");
sprintf(diskNumberString, "%d", currentDiskNumber);
strcatuint8(fileName, diskNumberString);
sprintf(fileName, "VOL.%d", currentDiskNumber);
strcpyuint8(string, "INSERER LE DISQUE ");
strcatuint8(string, diskNumberString);
strcatuint8(string, " EN ");
sprintf(string, "INSERER LE DISQUE %d EN ", currentDiskNumber);
//while (Common::File::exists((const char*)fileName))
{
@ -242,7 +236,7 @@ void askDisk(int16 discNumber) {
changeCursor(currentCursor);
}
int16 findFileInDisks(uint8 *fileName) {
int16 findFileInDisks(char *fileName) {
int disk;
int fileIdx;
@ -449,7 +443,7 @@ int16 readVolCnf(void) {
///////////////////////////::
void drawMsgString(uint8 *string) {
void drawMsgString(const char *string) {
//printf("%s\n",string);
}

View File

@ -29,14 +29,14 @@
namespace Cruise {
int16 readVolCnf(void);
int16 findFileInDisks(uint8 * fileName);
int16 findFileInDisks(char * fileName);
void freeDisk(void);
int16 findFileInList(uint8 * fileName);
int16 findFileInList(const char * fileName);
////////////////
void strToUpper(uint8 * fileName);
void drawMsgString(uint8 * string);
void strToUpper(char * fileName);
void drawMsgString(const char * string);
void askDisk(int16 discNumber);
void setObjectPosition(int16 param1, int16 param2, int16 param3, int16 param4);