Fix code formatting (partially) and guard defines in includes.
svn-id: r26631
This commit is contained in:
parent
101fbdd64f
commit
ffce26ebfe
57 changed files with 9663 additions and 10110 deletions
File diff suppressed because it is too large
Load diff
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _ACTOR_H_
|
||||
#define _ACTOR_H_
|
||||
#ifndef CRUISE_ACTOR_H
|
||||
#define CRUISE_ACTOR_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
enum animPhase
|
||||
{
|
||||
enum animPhase {
|
||||
ANIM_PHASE_WAIT = 0,
|
||||
ANIM_PHASE_STATIC = 1,
|
||||
ANIM_PHASE_MOVE = 2,
|
||||
|
@ -65,10 +64,13 @@ struct actorStruct {
|
|||
|
||||
typedef struct actorStruct actorStruct;
|
||||
|
||||
int16 mainProc13(int overlayIdx, int param1, actorStruct* pStartEntry, int param2);
|
||||
actorStruct* findActor(int overlayIdx, int param1, actorStruct* pStartEntry, int param2);
|
||||
int16 mainProc13(int overlayIdx, int param1, actorStruct * pStartEntry,
|
||||
int param2);
|
||||
actorStruct *findActor(int overlayIdx, int param1, actorStruct * pStartEntry,
|
||||
int param2);
|
||||
void processAnimation(void);
|
||||
void getPixel(int x, int y);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,19 +33,16 @@ backgroundTableStruct backgroundTable[8];
|
|||
|
||||
char hwPage[64000];
|
||||
|
||||
char* hwMemAddr[] =
|
||||
{
|
||||
char *hwMemAddr[] = {
|
||||
hwPage,
|
||||
};
|
||||
|
||||
short int cvtPalette[0x20];
|
||||
|
||||
int loadMEN(uint8** ptr)
|
||||
{
|
||||
int loadMEN(uint8 **ptr) {
|
||||
char *localPtr = (char *)*ptr;
|
||||
|
||||
if(!strcmp(localPtr,"MEN"))
|
||||
{
|
||||
if (!strcmp(localPtr, "MEN")) {
|
||||
localPtr += 4;
|
||||
|
||||
video4 = *(localPtr++);
|
||||
|
@ -56,26 +53,21 @@ int loadMEN(uint8** ptr)
|
|||
*ptr = (uint8 *) localPtr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CVTLoaded;
|
||||
|
||||
int loadCVT(uint8** ptr)
|
||||
{
|
||||
int loadCVT(uint8 **ptr) {
|
||||
char *localPtr = (char *)*ptr;
|
||||
|
||||
if(!strcmp(localPtr,"CVT"))
|
||||
{
|
||||
if (!strcmp(localPtr, "CVT")) {
|
||||
int i;
|
||||
localPtr += 4;
|
||||
|
||||
for(i=0;i<0x20;i++)
|
||||
{
|
||||
for (i = 0; i < 0x20; i++) {
|
||||
cvtPalette[i] = *(localPtr++);
|
||||
}
|
||||
|
||||
|
@ -84,9 +76,7 @@ int loadCVT(uint8** ptr)
|
|||
CVTLoaded = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
CVTLoaded = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,19 +84,18 @@ int loadCVT(uint8** ptr)
|
|||
|
||||
extern int lastFileSize;
|
||||
|
||||
int loadBackground(char* name, int idx)
|
||||
{
|
||||
int loadBackground(char *name, int idx) {
|
||||
uint8 *ptr;
|
||||
uint8 *ptr2;
|
||||
uint8 *ptrToFree;
|
||||
|
||||
printf("Loading BG: %s\n", name);
|
||||
|
||||
if(!backgroundPtrtable[idx])
|
||||
{
|
||||
if (!backgroundPtrtable[idx]) {
|
||||
//if(!gfxModuleData.useEGA && !gfxModuleData.useVGA)
|
||||
{
|
||||
backgroundPtrtable[idx] = (uint8*)mallocAndZero(320*200/*64000*/);
|
||||
backgroundPtrtable[idx] =
|
||||
(uint8 *) mallocAndZero(320 * 200 /*64000 */ );
|
||||
}
|
||||
/* else
|
||||
{
|
||||
|
@ -114,57 +103,45 @@ int loadBackground(char* name, int idx)
|
|||
} */
|
||||
}
|
||||
|
||||
if(!backgroundPtrtable[idx])
|
||||
{
|
||||
if (!backgroundPtrtable[idx]) {
|
||||
backgroundTable[idx].name[0] = 0;
|
||||
return (-2);
|
||||
}
|
||||
|
||||
ptrToFree = gfxModuleData.pPage10;
|
||||
if(loadFileSub1(&ptrToFree,(uint8*)name,NULL)<0)
|
||||
{
|
||||
if (loadFileSub1(&ptrToFree, (uint8 *) 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
|
||||
{
|
||||
} else {
|
||||
colorMode = 1;
|
||||
}
|
||||
|
||||
ptr = ptrToFree;
|
||||
ptr2 = ptrToFree;
|
||||
|
||||
if(!strcmpuint8(name,"LOGO.PI1"))
|
||||
{
|
||||
if (!strcmpuint8(name, "LOGO.PI1")) {
|
||||
bgVar3 = bgVar2;
|
||||
bgVar1 = 1;
|
||||
bgVar2 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bgVar1)
|
||||
{
|
||||
} else {
|
||||
if (bgVar1) {
|
||||
bgVar2 = bgVar3;
|
||||
bgVar1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcmpuint8(ptr,"PAL"))
|
||||
{
|
||||
if (!strcmpuint8(ptr, "PAL")) {
|
||||
printf("Pal loading unsupported !\n");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!colorMode || ptr2[1] == 5)
|
||||
{
|
||||
} else {
|
||||
if (!colorMode || ptr2[1] == 5) {
|
||||
ptr2 += 2;
|
||||
|
||||
memcpy(palette, ptr2, 0x20);
|
||||
|
@ -175,19 +152,17 @@ int loadBackground(char* name, int idx)
|
|||
loadMEN(&ptr2);
|
||||
loadCVT(&ptr2);
|
||||
|
||||
gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable[idx]);
|
||||
gfxModuleData_field_60((char*)ptrToFree+34, 20, 200, (char*)backgroundPtrtable[idx], 0, 0);
|
||||
gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable
|
||||
[idx]);
|
||||
gfxModuleData_field_60((char *)ptrToFree + 34, 20, 200,
|
||||
(char *)backgroundPtrtable[idx], 0, 0);
|
||||
|
||||
gfxModuleData_setPal((uint8 *) (palette + (idx << 6)));
|
||||
}
|
||||
else
|
||||
if(ptr2[1] == 8)
|
||||
{
|
||||
} else if (ptr2[1] == 8) {
|
||||
int i;
|
||||
ptr2 += 2;
|
||||
|
||||
for(i=0;i<256*3;i++)
|
||||
{
|
||||
for (i = 0; i < 256 * 3; i++) {
|
||||
palette[i] = ptr2[i];
|
||||
}
|
||||
//memcpy(palette,ptr2,256*3);
|
||||
|
@ -202,13 +177,11 @@ int loadBackground(char* name, int idx)
|
|||
//if(ptrToFree != gfxModuleData.pPage10)
|
||||
// free(ptrToFree);
|
||||
|
||||
if(gfxModuleData.useEGA || gfxModuleData.useTandy)
|
||||
{
|
||||
if (gfxModuleData.useEGA || gfxModuleData.useTandy) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if(gfxModuleData.useEGA || gfxModuleData.useTandy)
|
||||
{
|
||||
if (gfxModuleData.useEGA || gfxModuleData.useTandy) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
* $Id$
|
||||
*
|
||||
*/
|
||||
#ifndef _BACKGROUND_H_
|
||||
#define _BACKGROUND_H_
|
||||
|
||||
#ifndef CRUISE_BACKGROUND_H
|
||||
#define CRUISE_BACKGROUND_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct backgroundTableStruct
|
||||
{
|
||||
struct backgroundTableStruct {
|
||||
char name[9];
|
||||
char extention[6];
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ extern uint8* backgroundPtrtable[8];
|
|||
extern backgroundTableStruct backgroundTable[8];
|
||||
|
||||
int loadBackground(char *name, int idx);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,25 +28,24 @@ namespace Cruise {
|
|||
|
||||
backgroundIncrustStruct backgroundIncrustHead;
|
||||
|
||||
void resetBackgroundIncrustList(backgroundIncrustStruct* pHead)
|
||||
{
|
||||
void resetBackgroundIncrustList(backgroundIncrustStruct *pHead) {
|
||||
pHead->next = NULL;
|
||||
pHead->prev = NULL;
|
||||
}
|
||||
|
||||
// blit background to another one
|
||||
void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char* ptr2, int16 scale, char* destBuffer, char* dataPtr)
|
||||
{
|
||||
if(*dataPtr == 0)
|
||||
{
|
||||
void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char *ptr2,
|
||||
int16 scale, char *destBuffer, char *dataPtr) {
|
||||
if (*dataPtr == 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
buildPolyModel(X, Y, scale, ptr2, destBuffer, dataPtr);
|
||||
}
|
||||
|
||||
backgroundIncrustStruct* addBackgroundIncrust(int16 overlayIdx,int16 objectIdx,backgroundIncrustStruct* pHead,int16 scriptNumber,int16 scriptOverlay, int16 backgroundIdx, int16 param4)
|
||||
{
|
||||
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx,
|
||||
int16 objectIdx, backgroundIncrustStruct *pHead, int16 scriptNumber,
|
||||
int16 scriptOverlay, int16 backgroundIdx, int16 param4) {
|
||||
uint8 *backgroundPtr;
|
||||
uint8 *ptr;
|
||||
objectParamsQuery params;
|
||||
|
@ -58,20 +57,18 @@ backgroundIncrustStruct* addBackgroundIncrust(int16 overlayIdx,int16 objectIdx,b
|
|||
|
||||
ptr = filesDatabase[params.fileIdx].subData.ptr;
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
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;
|
||||
}
|
||||
|
||||
backgroundPtr = backgroundPtrtable[backgroundIdx];
|
||||
|
||||
if(!backgroundPtr)
|
||||
{
|
||||
if (!backgroundPtr) {
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -79,13 +76,14 @@ backgroundIncrustStruct* addBackgroundIncrust(int16 overlayIdx,int16 objectIdx,b
|
|||
currentHead = pHead;
|
||||
currentHead2 = currentHead->next;
|
||||
|
||||
while(currentHead2)
|
||||
{
|
||||
while (currentHead2) {
|
||||
currentHead = currentHead2;
|
||||
currentHead2 = currentHead->next;
|
||||
}
|
||||
|
||||
newElement = (backgroundIncrustStruct*)mallocAndZero(sizeof(backgroundIncrustStruct));
|
||||
newElement =
|
||||
(backgroundIncrustStruct *)
|
||||
mallocAndZero(sizeof(backgroundIncrustStruct));
|
||||
|
||||
if (!newElement)
|
||||
return NULL;
|
||||
|
@ -93,8 +91,7 @@ backgroundIncrustStruct* addBackgroundIncrust(int16 overlayIdx,int16 objectIdx,b
|
|||
newElement->next = currentHead->next;
|
||||
currentHead->next = newElement;
|
||||
|
||||
if(!currentHead2)
|
||||
{
|
||||
if (!currentHead2) {
|
||||
currentHead2 = pHead;
|
||||
}
|
||||
|
||||
|
@ -120,31 +117,35 @@ backgroundIncrustStruct* addBackgroundIncrust(int16 overlayIdx,int16 objectIdx,b
|
|||
int width = filesDatabase[params.fileIdx].width;
|
||||
int height = filesDatabase[params.fileIdx].height;
|
||||
|
||||
currentTransparent = filesDatabase[params.fileIdx].subData.transparency;
|
||||
mainDrawSub4(width, height, NULL, (char*)filesDatabase[params.fileIdx].subData.ptr, newElement->Y, newElement->X, (char*)backgroundPtr, (char*)filesDatabase[params.fileIdx].subData.ptr);
|
||||
currentTransparent =
|
||||
filesDatabase[params.fileIdx].subData.transparency;
|
||||
mainDrawSub4(width, height, NULL,
|
||||
(char *)filesDatabase[params.fileIdx].subData.ptr,
|
||||
newElement->Y, newElement->X, (char *)backgroundPtr,
|
||||
(char *)filesDatabase[params.fileIdx].subData.ptr);
|
||||
// ASSERT(0);
|
||||
}
|
||||
else // poly
|
||||
} else // poly
|
||||
{
|
||||
/* if(param4 == 1)
|
||||
{
|
||||
int var_A;
|
||||
int var_8;
|
||||
int var_6;
|
||||
char* var_10;
|
||||
* {
|
||||
* 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);
|
||||
* } */
|
||||
|
||||
mainDrawSub1Sub1(lvar[3], newElement->X, newElement->Y, &var_A, &var_8, &var_6, &var_10, lvar[4], filesDatabase[lvar[3]].subData.ptr);
|
||||
ASSERT(0);
|
||||
}*/
|
||||
|
||||
addBackgroundIncrustSub1(params.fileIdx, newElement->X, newElement->Y, NULL, params.scale, (char*)backgroundPtr, (char*)filesDatabase[params.fileIdx].subData.ptr );
|
||||
addBackgroundIncrustSub1(params.fileIdx, newElement->X,
|
||||
newElement->Y, NULL, params.scale, (char *)backgroundPtr,
|
||||
(char *)filesDatabase[params.fileIdx].subData.ptr);
|
||||
}
|
||||
|
||||
return newElement;
|
||||
}
|
||||
|
||||
void loadBackgroundIncrustFromSave(FILE* fileHandle)
|
||||
{
|
||||
void loadBackgroundIncrustFromSave(FILE *fileHandle) {
|
||||
int16 numEntry;
|
||||
backgroundIncrustStruct *ptr1;
|
||||
backgroundIncrustStruct *ptr2;
|
||||
|
@ -155,9 +156,10 @@ void loadBackgroundIncrustFromSave(FILE* fileHandle)
|
|||
ptr1 = &backgroundIncrustHead;
|
||||
ptr2 = &backgroundIncrustHead;
|
||||
|
||||
for(i=0;i<numEntry;i++)
|
||||
{
|
||||
backgroundIncrustStruct* current = (backgroundIncrustStruct*)mallocAndZero(sizeof(backgroundIncrustStruct));
|
||||
for (i = 0; i < numEntry; i++) {
|
||||
backgroundIncrustStruct *current =
|
||||
(backgroundIncrustStruct *)
|
||||
mallocAndZero(sizeof(backgroundIncrustStruct));
|
||||
|
||||
fseek(fileHandle, 4, SEEK_CUR);
|
||||
|
||||
|
@ -179,8 +181,7 @@ void loadBackgroundIncrustFromSave(FILE* fileHandle)
|
|||
fread(current->name, 14, 1, fileHandle);
|
||||
fread(¤t->var34, 2, 1, fileHandle);
|
||||
|
||||
if(current->size)
|
||||
{
|
||||
if (current->size) {
|
||||
current->ptr = (uint8 *) mallocAndZero(current->size);
|
||||
fread(current->ptr, current->size, 1, fileHandle);
|
||||
}
|
||||
|
@ -193,21 +194,17 @@ void loadBackgroundIncrustFromSave(FILE* fileHandle)
|
|||
}
|
||||
}
|
||||
|
||||
void regenerateBackgroundIncrust(backgroundIncrustStruct* pHead)
|
||||
{
|
||||
void regenerateBackgroundIncrust(backgroundIncrustStruct *pHead) {
|
||||
printf("Need to regenerate backgroundIncrust\n");
|
||||
}
|
||||
|
||||
void freeBackgroundIncrustList(backgroundIncrustStruct* pHead)
|
||||
{
|
||||
void freeBackgroundIncrustList(backgroundIncrustStruct *pHead) {
|
||||
backgroundIncrustStruct *pCurrent = pHead->next;
|
||||
|
||||
while(pCurrent)
|
||||
{
|
||||
while (pCurrent) {
|
||||
backgroundIncrustStruct *pNext = pCurrent->next;
|
||||
|
||||
if(pCurrent->ptr)
|
||||
{
|
||||
if (pCurrent->ptr) {
|
||||
free(pCurrent->ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _BACKGROUNDINCRUST_H_
|
||||
#define _BACKGROUNDINCRUST_H_
|
||||
#ifndef CRUISE_BACKGROUNDINCRUST_H
|
||||
#define CRUISE_BACKGROUNDINCRUST_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -55,7 +55,9 @@ typedef struct backgroundIncrustStruct backgroundIncrustStruct;
|
|||
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(FILE * fileHandle);
|
||||
void regenerateBackgroundIncrust(backgroundIncrustStruct * pHead);
|
||||
void freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
||||
|
@ -63,4 +65,3 @@ void freeBackgroundIncrustList(backgroundIncrustStruct* pHead);
|
|||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,14 +27,12 @@
|
|||
|
||||
namespace Cruise {
|
||||
|
||||
void resetPtr(cellStruct* ptr)
|
||||
{
|
||||
void resetPtr(cellStruct *ptr) {
|
||||
ptr->next = NULL;
|
||||
ptr->prev = NULL;
|
||||
}
|
||||
|
||||
void loadSavegameDataSub2(FILE * f)
|
||||
{
|
||||
void loadSavegameDataSub2(FILE *f) {
|
||||
unsigned short int n_chunks;
|
||||
int i;
|
||||
cellStruct *p;
|
||||
|
@ -48,8 +46,7 @@ void loadSavegameDataSub2(FILE * f)
|
|||
|
||||
p = &cellHead;
|
||||
|
||||
for (i = 0; i < n_chunks; i++)
|
||||
{
|
||||
for (i = 0; i < n_chunks; i++) {
|
||||
t = (cellStruct *) mallocAndZero(sizeof(cellStruct));
|
||||
|
||||
fseek(f, 4, SEEK_CUR);
|
||||
|
@ -63,8 +60,9 @@ void loadSavegameDataSub2(FILE * f)
|
|||
}
|
||||
}
|
||||
|
||||
cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4)
|
||||
{
|
||||
cellStruct *addCell(int16 overlayIdx, int16 param2, cellStruct *pHead,
|
||||
int16 scriptType, int16 scriptNumber, int16 scriptOverlay, int16 param3,
|
||||
int16 param4) {
|
||||
int16 var;
|
||||
|
||||
cellStruct *newElement;
|
||||
|
@ -72,26 +70,23 @@ cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 script
|
|||
cellStruct *currentHead2;
|
||||
cellStruct *currentHead3;
|
||||
|
||||
if(getSingleObjectParam(overlayIdx,param2,2,&var)<0)
|
||||
{
|
||||
if (getSingleObjectParam(overlayIdx, param2, 2, &var) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
currentHead3 = currentHead;
|
||||
currentHead2 = currentHead->next;
|
||||
|
||||
while(currentHead2)
|
||||
{
|
||||
if(currentHead2->type == 3)
|
||||
{
|
||||
while (currentHead2) {
|
||||
if (currentHead2->type == 3) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(currentHead2->type != 5)
|
||||
{
|
||||
if (currentHead2->type != 5) {
|
||||
int16 lvar2;
|
||||
|
||||
getSingleObjectParam(currentHead2->overlay,currentHead2->idx,2,&lvar2);
|
||||
getSingleObjectParam(currentHead2->overlay,
|
||||
currentHead2->idx, 2, &lvar2);
|
||||
|
||||
if (lvar2 > var)
|
||||
break;
|
||||
|
@ -101,8 +96,7 @@ cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 script
|
|||
currentHead2 = currentHead2->next;
|
||||
}
|
||||
|
||||
if(currentHead2)
|
||||
{
|
||||
if (currentHead2) {
|
||||
if ((currentHead2->overlay == overlayIdx) &&
|
||||
(currentHead2->backgroundPlane == param3) &&
|
||||
(currentHead2->idx == param2) &&
|
||||
|
@ -141,13 +135,10 @@ cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 script
|
|||
newElement->animStep = 0;
|
||||
newElement->field_30 = 0;
|
||||
|
||||
if(currentHead)
|
||||
{
|
||||
if (currentHead) {
|
||||
newElement->prev = currentHead->prev;
|
||||
currentHead->prev = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
newElement->prev = pHead->prev;
|
||||
pHead->prev = newElement;
|
||||
}
|
||||
|
@ -155,5 +146,4 @@ cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 script
|
|||
return newElement;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _CELL_H_
|
||||
#define _CELL_H_
|
||||
#ifndef CRUISE_CELL_H
|
||||
#define CRUISE_CELL_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
|
@ -32,8 +32,7 @@ namespace Cruise {
|
|||
|
||||
struct gfxEntryStruct;
|
||||
|
||||
struct cellStruct
|
||||
{
|
||||
struct cellStruct {
|
||||
struct cellStruct *next;
|
||||
struct cellStruct *prev;
|
||||
int16 idx;
|
||||
|
@ -66,8 +65,10 @@ extern cellStruct cellHead;
|
|||
|
||||
void resetPtr(cellStruct * ptr);
|
||||
void loadSavegameDataSub2(FILE * f);
|
||||
cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4);
|
||||
cellStruct *addCell(int16 overlayIdx, int16 param2, cellStruct * pHead,
|
||||
int16 scriptType, int16 scriptNumber, int16 scriptOverlay, int16 param3,
|
||||
int16 param4);
|
||||
|
||||
}
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,15 +45,18 @@ Common::SaveFileManager *g_saveFileMan;
|
|||
CruiseEngine *g_cruise;
|
||||
|
||||
CruiseEngine::CruiseEngine(OSystem * syst) : Engine(syst) {
|
||||
Common::addSpecialDebugLevel(kCruiseDebugScript, "Script", "Script debug level");
|
||||
Common::addSpecialDebugLevel(kCruiseDebugScript, "Script",
|
||||
"Script debug level");
|
||||
|
||||
// Setup mixer
|
||||
if (!_mixer->isReady()) {
|
||||
warning("Sound initialization failed.");
|
||||
}
|
||||
|
||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
||||
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType,
|
||||
ConfMan.getInt("sfx_volume"));
|
||||
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType,
|
||||
ConfMan.getInt("music_volume"));
|
||||
|
||||
g_cruise = this;
|
||||
}
|
||||
|
@ -64,10 +67,10 @@ CruiseEngine::~CruiseEngine() {
|
|||
int CruiseEngine::init() {
|
||||
// Detect game
|
||||
if (!initGame()) {
|
||||
GUIErrorMessage("No valid games were found in the specified directory.");
|
||||
GUIErrorMessage
|
||||
("No valid games were found in the specified directory.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Initialize backend
|
||||
_system->beginGFXTransaction();
|
||||
initCommonGFX(false);
|
||||
|
@ -87,14 +90,14 @@ int CruiseEngine::go() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CruiseEngine::initialize() {
|
||||
|
||||
fadeVar = 0;
|
||||
ptr_something = (ctpVar19Struct*)mallocAndZero(sizeof(ctpVar19Struct)*0x200);
|
||||
ptr_something =
|
||||
(ctpVar19Struct *) mallocAndZero(sizeof(ctpVar19Struct) * 0x200);
|
||||
|
||||
/*volVar1 = 0;
|
||||
fileData1 = 0;*/
|
||||
* fileData1 = 0; */
|
||||
|
||||
/*PAL_fileHandle = -1; */
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef CRUISE_H
|
||||
#define CRUISE_H
|
||||
#ifndef CRUISE_CRUISE_H
|
||||
#define CRUISE_CRUISE_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
|
@ -99,7 +99,6 @@ enum {
|
|||
kCmpLT = (1 << 2)
|
||||
};
|
||||
|
||||
|
||||
extern Common::SaveFileManager * g_saveFileMan; // TEMP
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _CRUISE_H_
|
||||
#define _CRUISE_H_
|
||||
#ifndef CRUISE_CRUISE_MAIN_H
|
||||
#define CRUISE_CRUISE_MAIN_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -66,7 +66,6 @@ namespace Cruise {
|
|||
#define ASSERT_PTR assert
|
||||
#define ASSERT assert
|
||||
|
||||
|
||||
int32 decomp(uint8 * in, uint8 * out, int32 size);
|
||||
|
||||
ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param);
|
||||
|
@ -83,9 +82,11 @@ 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);
|
||||
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,uint8* string);
|
||||
int32 prepareWordRender(int32 param, int32 var1, int16 * out2, uint8 * ptr3,
|
||||
uint8 * string);
|
||||
void removeExtention(const char *name, char *buffer);
|
||||
void resetRaster(uint8 * rasterPtr, int32 rasterSize);
|
||||
void changeCursor(uint16 cursorType);
|
||||
|
@ -95,6 +96,7 @@ void *allocAndZero(int size);
|
|||
void freeStuff2(void);
|
||||
char *getObjectName(int index, uint8 * string);
|
||||
void mainLoop(void);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,13 +43,11 @@ int currentWalkBoxCenterYBis;
|
|||
int ctpVarUnk;
|
||||
uint8 walkboxTable[0x12];
|
||||
|
||||
int ctpProc2(int varX, int varY, int paramX, int paramY)
|
||||
{
|
||||
int ctpProc2(int varX, int varY, int paramX, int paramY) {
|
||||
int diffX = abs(paramX - varX);
|
||||
int diffY = abs(paramY - varY);
|
||||
|
||||
if(diffX > diffY)
|
||||
{
|
||||
if (diffX > diffY) {
|
||||
diffY = diffX;
|
||||
}
|
||||
|
||||
|
@ -58,8 +56,8 @@ int ctpProc2(int varX, int varY, int paramX, int paramY)
|
|||
}
|
||||
|
||||
// this function process path finding coordinates
|
||||
void loadCtpSub2(short int coordCount, short int* ptr) // coordCount = ctp_routeCoordCount, ptr = ctpVar8
|
||||
{
|
||||
void loadCtpSub2(short int coordCount, short int *ptr) {
|
||||
// coordCount = ctp_routeCoordCount, ptr = ctpVar8
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
|
@ -77,7 +75,9 @@ void loadCtpSub2(short int coordCount, short int* ptr) // coordCount = ctp_r
|
|||
while (*(int16 *) cur_ctp_routes > di) // while (coordCount > counter++)
|
||||
{
|
||||
int idx = *(int16 *) (cur_ctp_routes + var4Offset);
|
||||
ptr[offset + idx] = ctpProc2(varX , varY, ctp_routeCoords[idx][0], ctp_routeCoords[idx * 2][1]);
|
||||
ptr[offset + idx] =
|
||||
ctpProc2(varX, varY, ctp_routeCoords[idx][0],
|
||||
ctp_routeCoords[idx * 2][1]);
|
||||
|
||||
var4Offset += 2;
|
||||
di++;
|
||||
|
@ -89,8 +89,7 @@ void loadCtpSub2(short int coordCount, short int* ptr) // coordCount = ctp_r
|
|||
}
|
||||
}
|
||||
|
||||
void getWalkBoxCenter(int boxIdx, uint16* _walkboxTable)
|
||||
{
|
||||
void getWalkBoxCenter(int boxIdx, uint16 *_walkboxTable) {
|
||||
int minX = 1000;
|
||||
int minY = 1000;
|
||||
int maxX = -1;
|
||||
|
@ -99,15 +98,13 @@ void getWalkBoxCenter(int boxIdx, uint16* _walkboxTable)
|
|||
ASSERT(boxIdx <= 15); // max number of walkboxes is 16
|
||||
ASSERT(_walkboxTable[boxIdx * 40]); // we should never have an empty walk box
|
||||
|
||||
if(_walkboxTable[boxIdx * 40] > 0)
|
||||
{
|
||||
if (_walkboxTable[boxIdx * 40] > 0) {
|
||||
int numPoints = _walkboxTable[boxIdx * 40];
|
||||
uint16 *pCurrentPtr = _walkboxTable + (boxIdx * 40) + 1;
|
||||
|
||||
int i;
|
||||
|
||||
for(i = 0; i < numPoints; i++)
|
||||
{
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
int X = *(pCurrentPtr++);
|
||||
int Y = *(pCurrentPtr++);;
|
||||
|
||||
|
@ -130,8 +127,8 @@ void getWalkBoxCenter(int boxIdx, uint16* _walkboxTable)
|
|||
}
|
||||
|
||||
// ax dx bx
|
||||
void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2, uint16* walkboxData)
|
||||
{
|
||||
void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2,
|
||||
uint16 *walkboxData) {
|
||||
int numPoints;
|
||||
int wbSelf1;
|
||||
int wbSelf2;
|
||||
|
@ -145,8 +142,7 @@ void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2, uint16* walkbox
|
|||
|
||||
destination = polyBuffer2;
|
||||
|
||||
for(i = 0; i < numPoints; i++)
|
||||
{
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
int pointX = *(walkboxData++);
|
||||
int pointY = *(walkboxData++);
|
||||
|
||||
|
@ -160,8 +156,7 @@ void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2, uint16* walkbox
|
|||
m_color = 0;
|
||||
ctpVarUnk = 0;
|
||||
|
||||
for(i = 0; i < numPoints; i++)
|
||||
{
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
walkboxTable[i] = i;
|
||||
}
|
||||
|
||||
|
@ -169,8 +164,8 @@ void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2, uint16* walkbox
|
|||
}
|
||||
|
||||
// this process the walkboxes
|
||||
void loadCtpSub1(int boxIdx, int scale, uint16* _walkboxTable, ctpVar19Struct* param4)
|
||||
{
|
||||
void loadCtpSub1(int boxIdx, int scale, uint16 *_walkboxTable,
|
||||
ctpVar19Struct *param4) {
|
||||
int minX = 1000;
|
||||
int minY = 1000;
|
||||
int maxX = -1;
|
||||
|
@ -199,7 +194,9 @@ void loadCtpSub1(int boxIdx, int scale, uint16* _walkboxTable, ctpVar19Struct* p
|
|||
currentWalkBoxCenterYBis = currentWalkBoxCenterY;
|
||||
currentWalkBoxCenterXBis = currentWalkBoxCenterX;
|
||||
// + 512
|
||||
renderCTPWalkBox(currentWalkBoxCenterX, currentWalkBoxCenterY, currentWalkBoxCenterX, scale + 0x200, currentWalkBoxCenterY, _walkboxTable + boxIdx * 40);
|
||||
renderCTPWalkBox(currentWalkBoxCenterX, currentWalkBoxCenterY,
|
||||
currentWalkBoxCenterX, scale + 0x200,
|
||||
currentWalkBoxCenterY, _walkboxTable + boxIdx * 40);
|
||||
|
||||
var_1C = param4;
|
||||
var_12 = var_1C + 1; // next
|
||||
|
@ -209,37 +206,37 @@ void loadCtpSub1(int boxIdx, int scale, uint16* _walkboxTable, ctpVar19Struct* p
|
|||
|
||||
si = &polyBuffer3[1];
|
||||
/* if(*si>=0)
|
||||
{
|
||||
di = si;
|
||||
cx = var_12;
|
||||
|
||||
do
|
||||
{
|
||||
di++;
|
||||
bx = di[-1];
|
||||
ax = di[0];
|
||||
di++;
|
||||
|
||||
var_2 = ax;
|
||||
if(var_C < bx)
|
||||
{
|
||||
var_C = bx;
|
||||
}
|
||||
|
||||
if(var_2 < var_A)
|
||||
{
|
||||
var_A = var_2;
|
||||
}
|
||||
|
||||
*cx = bx;
|
||||
cx++;
|
||||
*cx = var_2;
|
||||
cx++;
|
||||
var_E ++;
|
||||
}while(di);
|
||||
|
||||
var_12 = cx;
|
||||
}*/
|
||||
* {
|
||||
* di = si;
|
||||
* cx = var_12;
|
||||
*
|
||||
* do
|
||||
* {
|
||||
* di++;
|
||||
* bx = di[-1];
|
||||
* ax = di[0];
|
||||
* di++;
|
||||
*
|
||||
* var_2 = ax;
|
||||
* if(var_C < bx)
|
||||
* {
|
||||
* var_C = bx;
|
||||
* }
|
||||
*
|
||||
* if(var_2 < var_A)
|
||||
* {
|
||||
* var_A = var_2;
|
||||
* }
|
||||
*
|
||||
* *cx = bx;
|
||||
* cx++;
|
||||
* *cx = var_2;
|
||||
* cx++;
|
||||
* var_E ++;
|
||||
* }while(di);
|
||||
*
|
||||
* var_12 = cx;
|
||||
* } */
|
||||
|
||||
/*************/
|
||||
{
|
||||
|
@ -249,8 +246,7 @@ void loadCtpSub1(int boxIdx, int scale, uint16* _walkboxTable, ctpVar19Struct* p
|
|||
|
||||
numPoints = *(pCurrentPtr++);
|
||||
|
||||
for(i = 0; i < numPoints; i++)
|
||||
{
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
int X = *(pCurrentPtr++);
|
||||
int Y = *(pCurrentPtr++);
|
||||
|
||||
|
@ -284,8 +280,7 @@ void loadCtpSub1(int boxIdx, int scale, uint16* _walkboxTable, ctpVar19Struct* p
|
|||
}
|
||||
}
|
||||
|
||||
int loadCtp(uint8* ctpName)
|
||||
{
|
||||
int loadCtp(uint8 *ctpName) {
|
||||
int walkboxCounter; // si
|
||||
uint8 *ptr;
|
||||
uint8 *dataPointer; // ptr2
|
||||
|
@ -293,18 +288,15 @@ int loadCtp(uint8* ctpName)
|
|||
short int segementSizeTable[7]; // tempTable
|
||||
char string[32];
|
||||
|
||||
if(ctpVar1 == 0)
|
||||
{
|
||||
if (ctpVar1 == 0) {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
for (i = 0; i < 10; i++) {
|
||||
persoTable[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(!loadFileSub1(&ptr,ctpName,0))
|
||||
{
|
||||
if (!loadFileSub1(&ptr, ctpName, 0)) {
|
||||
free(ptr);
|
||||
return (-18);
|
||||
}
|
||||
|
@ -315,8 +307,7 @@ int loadCtp(uint8* ctpName)
|
|||
memcpy(fileType, dataPointer, 4); // get the file type, first 4 bytes of the CTP file
|
||||
dataPointer += 4;
|
||||
|
||||
if(strcmp(fileType, "CTP "))
|
||||
{
|
||||
if (strcmp(fileType, "CTP ")) {
|
||||
free(ptr);
|
||||
return (0);
|
||||
}
|
||||
|
@ -341,13 +332,10 @@ int loadCtp(uint8* ctpName)
|
|||
dataPointer += segementSizeTable[2];
|
||||
flipGen(ctp_walkboxTable, segementSizeTable[2]);
|
||||
|
||||
if(ctpVar1)
|
||||
{
|
||||
if (ctpVar1) {
|
||||
dataPointer += segementSizeTable[3];
|
||||
dataPointer += segementSizeTable[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
memcpy(walkboxType, dataPointer, segementSizeTable[3]); // get the walkbox type
|
||||
dataPointer += segementSizeTable[3];
|
||||
flipGen(walkboxType, segementSizeTable[3]); // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone
|
||||
|
@ -379,8 +367,7 @@ int loadCtp(uint8* ctpName)
|
|||
|
||||
walkboxCounter = numberOfWalkboxes;
|
||||
|
||||
while((--walkboxCounter) >= 0)
|
||||
{
|
||||
while ((--walkboxCounter) >= 0) {
|
||||
loadCtpSub1(walkboxCounter, 0, ctp_walkboxTable, ctpVar13);
|
||||
}
|
||||
|
||||
|
@ -388,9 +375,9 @@ int loadCtp(uint8* ctpName)
|
|||
|
||||
walkboxCounter = numberOfWalkboxes;
|
||||
|
||||
while(--walkboxCounter)
|
||||
{
|
||||
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20, ctp_walkboxTable, ctpVar13);
|
||||
while (--walkboxCounter) {
|
||||
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20,
|
||||
ctp_walkboxTable, ctpVar13);
|
||||
}
|
||||
|
||||
//ctpVar17 = ctpVar13 - ptr + 4;
|
||||
|
@ -398,21 +385,22 @@ int loadCtp(uint8* ctpName)
|
|||
{
|
||||
int numOfUsedEntries = ctpVar13 - (ctpVar19Struct *) ptr;
|
||||
numOfUsedEntries++; // there is a -1 entry at the end... Original was only mallocing numOfUsedEntries*sizeof(ctpVar19Struct)+4, but this is a bit ugly...
|
||||
ctpVar13 = ctpVar11 = polyStruct = (ctpVar19Struct*)malloc(numOfUsedEntries * sizeof(ctpVar19Struct));
|
||||
ctpVar13 = ctpVar11 = polyStruct =
|
||||
(ctpVar19Struct *) malloc(numOfUsedEntries *
|
||||
sizeof(ctpVar19Struct));
|
||||
}
|
||||
|
||||
walkboxCounter = numberOfWalkboxes;
|
||||
while((--walkboxCounter) >= 0)
|
||||
{
|
||||
while ((--walkboxCounter) >= 0) {
|
||||
loadCtpSub1(walkboxCounter, 0, ctp_walkboxTable, ctpVar13);
|
||||
}
|
||||
|
||||
ctpVar15 = ctpVar13 + 1;
|
||||
|
||||
walkboxCounter = numberOfWalkboxes;
|
||||
while(--walkboxCounter)
|
||||
{
|
||||
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20, ctp_walkboxTable, ctpVar13);
|
||||
while (--walkboxCounter) {
|
||||
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20,
|
||||
ctp_walkboxTable, ctpVar13);
|
||||
}
|
||||
|
||||
ctpVar19 = ctpVar11;
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _CTP_H_
|
||||
#define _CTP_H_
|
||||
#ifndef CRUISE_CTP_H
|
||||
#define CRUISE_CTP_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct ctpVar19SubStruct
|
||||
{
|
||||
struct ctpVar19SubStruct {
|
||||
uint16 boxIdx; //0
|
||||
uint16 type; //2
|
||||
uint16 minX; //4
|
||||
|
@ -39,8 +38,7 @@ struct ctpVar19SubStruct
|
|||
|
||||
typedef struct ctpVar19SubStruct ctpVar19SubStruct;
|
||||
|
||||
struct ctpVar19Struct
|
||||
{
|
||||
struct ctpVar19Struct {
|
||||
struct ctpVar19Struct *field_0; //0
|
||||
ctpVar19SubStruct subStruct;
|
||||
};
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
namespace Cruise {
|
||||
|
||||
void loadSetEntry(uint8* name, uint8* ptr, int currentEntryIdx, int currentDestEntry);
|
||||
void loadSetEntry(uint8 * name, uint8 * ptr, int currentEntryIdx,
|
||||
int currentDestEntry);
|
||||
void loadFNTSub(uint8 * ptr, int destIdx);
|
||||
|
||||
enum fileTypeEnum
|
||||
{
|
||||
enum fileTypeEnum {
|
||||
type_UNK,
|
||||
type_SPL,
|
||||
type_SET,
|
||||
|
@ -43,26 +43,24 @@ int loadSingleFile;
|
|||
|
||||
// TODO: Unify decodeGfxFormat1, decodeGfxFormat4 and decodeGfxFormat5
|
||||
|
||||
void decodeGfxFormat1(dataFileEntry* pCurrentFileEntry)
|
||||
{
|
||||
void decodeGfxFormat1(dataFileEntry *pCurrentFileEntry) {
|
||||
uint8 *buffer;
|
||||
uint8 *dataPtr = pCurrentFileEntry->subData.ptr;
|
||||
|
||||
int spriteSize = pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn * 8;
|
||||
int spriteSize =
|
||||
pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn * 8;
|
||||
int x = 0;
|
||||
|
||||
buffer = (uint8 *) malloc(spriteSize);
|
||||
|
||||
while (x < spriteSize)
|
||||
{
|
||||
while (x < spriteSize) {
|
||||
uint8 c;
|
||||
uint16 p0;
|
||||
|
||||
p0 = (dataPtr[0] << 8) | dataPtr[1];
|
||||
|
||||
/* decode planes */
|
||||
for (c = 0; c < 16; c++)
|
||||
{
|
||||
for (c = 0; c < 16; c++) {
|
||||
buffer[x + c] = ((p0 >> 15) & 1);
|
||||
|
||||
p0 <<= 1;
|
||||
|
@ -76,19 +74,17 @@ void decodeGfxFormat1(dataFileEntry* pCurrentFileEntry)
|
|||
pCurrentFileEntry->subData.ptr = buffer;
|
||||
}
|
||||
|
||||
|
||||
void decodeGfxFormat4(dataFileEntry* pCurrentFileEntry)
|
||||
{
|
||||
void decodeGfxFormat4(dataFileEntry *pCurrentFileEntry) {
|
||||
uint8 *buffer;
|
||||
uint8 *dataPtr = pCurrentFileEntry->subData.ptr;
|
||||
|
||||
int spriteSize = pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn * 2;
|
||||
int spriteSize =
|
||||
pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn * 2;
|
||||
int x = 0;
|
||||
|
||||
buffer = (uint8 *) malloc(spriteSize);
|
||||
|
||||
while (x < spriteSize)
|
||||
{
|
||||
while (x < spriteSize) {
|
||||
uint8 c;
|
||||
uint16 p0;
|
||||
uint16 p1;
|
||||
|
@ -101,9 +97,10 @@ void decodeGfxFormat4(dataFileEntry* pCurrentFileEntry)
|
|||
p3 = (dataPtr[6] << 8) | dataPtr[7];
|
||||
|
||||
/* decode planes */
|
||||
for (c = 0; c < 16; c++)
|
||||
{
|
||||
buffer[x+c] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8);
|
||||
for (c = 0; c < 16; c++) {
|
||||
buffer[x + c] =
|
||||
((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) &
|
||||
4) | ((p3 >> 12) & 8);
|
||||
|
||||
p0 <<= 1;
|
||||
p1 <<= 1;
|
||||
|
@ -119,19 +116,18 @@ void decodeGfxFormat4(dataFileEntry* pCurrentFileEntry)
|
|||
pCurrentFileEntry->subData.ptr = buffer;
|
||||
}
|
||||
|
||||
void decodeGfxFormat5(dataFileEntry* pCurrentFileEntry)
|
||||
{
|
||||
void decodeGfxFormat5(dataFileEntry *pCurrentFileEntry) {
|
||||
uint8 *buffer;
|
||||
uint8 *dataPtr = pCurrentFileEntry->subData.ptr;
|
||||
|
||||
int spriteSize = pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn;
|
||||
int spriteSize =
|
||||
pCurrentFileEntry->height * pCurrentFileEntry->widthInColumn;
|
||||
int x = 0;
|
||||
int range = pCurrentFileEntry->height * pCurrentFileEntry->width;
|
||||
|
||||
buffer = (uint8 *) malloc(spriteSize);
|
||||
|
||||
while (x < spriteSize)
|
||||
{
|
||||
while (x < spriteSize) {
|
||||
uint8 c;
|
||||
uint16 p0;
|
||||
uint16 p1;
|
||||
|
@ -146,9 +142,10 @@ void decodeGfxFormat5(dataFileEntry* pCurrentFileEntry)
|
|||
p4 = (dataPtr[0 + range * 4] << 8) | dataPtr[1 + range * 4];
|
||||
|
||||
/* decode planes */
|
||||
for (c = 0; c < 16; c++)
|
||||
{
|
||||
buffer[x+c] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8) | ((p4 >> 11) & 16);
|
||||
for (c = 0; c < 16; c++) {
|
||||
buffer[x + c] =
|
||||
((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) &
|
||||
4) | ((p3 >> 12) & 8) | ((p4 >> 11) & 16);
|
||||
|
||||
p0 <<= 1;
|
||||
p1 <<= 1;
|
||||
|
@ -165,8 +162,7 @@ void decodeGfxFormat5(dataFileEntry* pCurrentFileEntry)
|
|||
pCurrentFileEntry->subData.ptr = buffer;
|
||||
}
|
||||
|
||||
int updateResFileEntry(int height, int width, int entryNumber, int resType)
|
||||
{
|
||||
int updateResFileEntry(int height, int width, int entryNumber, int resType) {
|
||||
int div = 0;
|
||||
int size;
|
||||
|
||||
|
@ -176,22 +172,21 @@ int updateResFileEntry(int height, int width, int entryNumber, int resType)
|
|||
|
||||
size = height * width; // for sprites: width * height
|
||||
|
||||
if(resType == 4)
|
||||
{
|
||||
if (resType == 4) {
|
||||
div = size / 4;
|
||||
}
|
||||
else if (resType == 5)
|
||||
{
|
||||
} else if (resType == 5) {
|
||||
width = (width * 8) / 5;
|
||||
}
|
||||
|
||||
filesDatabase[entryNumber].subData.ptr = (uint8*)mallocAndZero(size + div);
|
||||
filesDatabase[entryNumber].subData.ptr =
|
||||
(uint8 *) mallocAndZero(size + div);
|
||||
|
||||
if (!filesDatabase[entryNumber].subData.ptr)
|
||||
return (-2);
|
||||
|
||||
filesDatabase[entryNumber].widthInColumn = width;
|
||||
filesDatabase[entryNumber].subData.ptr2 = filesDatabase[entryNumber].subData.ptr+size;
|
||||
filesDatabase[entryNumber].subData.ptr2 =
|
||||
filesDatabase[entryNumber].subData.ptr + size;
|
||||
filesDatabase[entryNumber].width = width / 8;
|
||||
filesDatabase[entryNumber].resType = resType;
|
||||
filesDatabase[entryNumber].height = height;
|
||||
|
@ -200,9 +195,7 @@ int updateResFileEntry(int height, int width, int entryNumber, int resType)
|
|||
return entryNumber;
|
||||
}
|
||||
|
||||
|
||||
int createResFileEntry(int width, int height, int resType)
|
||||
{
|
||||
int createResFileEntry(int width, int height, int resType) {
|
||||
int i;
|
||||
int entryNumber;
|
||||
int div = 0;
|
||||
|
@ -211,14 +204,12 @@ int createResFileEntry(int width, int height, int resType)
|
|||
printf("Executing untested createResFileEntry!\n");
|
||||
exit(1);
|
||||
|
||||
for(i = 0; i < 257; i++)
|
||||
{
|
||||
for (i = 0; i < 257; i++) {
|
||||
if (!filesDatabase[i].subData.ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if(i >= 257)
|
||||
{
|
||||
if (i >= 257) {
|
||||
return (-19);
|
||||
}
|
||||
|
||||
|
@ -228,24 +219,22 @@ int createResFileEntry(int width, int height, int resType)
|
|||
|
||||
size = width * height; // for sprites: width * height
|
||||
|
||||
if(resType == 4)
|
||||
{
|
||||
if (resType == 4) {
|
||||
div = size / 4;
|
||||
}
|
||||
else if (resType == 5)
|
||||
{
|
||||
} else if (resType == 5) {
|
||||
width = (width * 8) / 5;
|
||||
}
|
||||
|
||||
filesDatabase[entryNumber].subData.ptr = (uint8*)mallocAndZero(size + div);
|
||||
filesDatabase[entryNumber].subData.ptr =
|
||||
(uint8 *) mallocAndZero(size + div);
|
||||
|
||||
if(filesDatabase[entryNumber].subData.ptr)
|
||||
{
|
||||
if (filesDatabase[entryNumber].subData.ptr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
filesDatabase[entryNumber].widthInColumn = width;
|
||||
filesDatabase[entryNumber].subData.ptr2 = filesDatabase[entryNumber].subData.ptr + size;
|
||||
filesDatabase[entryNumber].subData.ptr2 =
|
||||
filesDatabase[entryNumber].subData.ptr + size;
|
||||
filesDatabase[entryNumber].width = width / 8;
|
||||
filesDatabase[entryNumber].resType = resType;
|
||||
filesDatabase[entryNumber].height = height;
|
||||
|
@ -254,26 +243,18 @@ int createResFileEntry(int width, int height, int resType)
|
|||
return entryNumber;
|
||||
}
|
||||
|
||||
fileTypeEnum getFileType(uint8* name)
|
||||
{
|
||||
fileTypeEnum getFileType(uint8 *name) {
|
||||
char extentionBuffer[16];
|
||||
|
||||
fileTypeEnum newFileType = type_UNK;
|
||||
|
||||
getFileExtention((char *)name, extentionBuffer);
|
||||
|
||||
if(!strcmp(extentionBuffer,".SPL"))
|
||||
{
|
||||
if (!strcmp(extentionBuffer, ".SPL")) {
|
||||
newFileType = type_SPL;
|
||||
}
|
||||
else
|
||||
if(!strcmp(extentionBuffer,".SET"))
|
||||
{
|
||||
} else if (!strcmp(extentionBuffer, ".SET")) {
|
||||
newFileType = type_SET;
|
||||
}
|
||||
else
|
||||
if(!strcmp(extentionBuffer,".FNT"))
|
||||
{
|
||||
} else if (!strcmp(extentionBuffer, ".FNT")) {
|
||||
newFileType = type_FNT;
|
||||
}
|
||||
|
||||
|
@ -282,16 +263,14 @@ fileTypeEnum getFileType(uint8* name)
|
|||
return newFileType;
|
||||
}
|
||||
|
||||
int getNumMaxEntiresInSet(uint8* ptr)
|
||||
{
|
||||
int getNumMaxEntiresInSet(uint8 *ptr) {
|
||||
uint16 numEntries = *(uint16 *) (ptr + 4);
|
||||
flipShort(&numEntries);
|
||||
|
||||
return numEntries;
|
||||
}
|
||||
|
||||
int loadFileMode2(uint8* name, int startIdx, int currentEntryIdx, int numIdx)
|
||||
{
|
||||
int loadFileMode2(uint8 *name, int startIdx, int currentEntryIdx, int numIdx) {
|
||||
uint8 *ptr = NULL;
|
||||
fileTypeEnum fileType;
|
||||
|
||||
|
@ -299,20 +278,18 @@ int loadFileMode2(uint8* name, int startIdx, int currentEntryIdx, int numIdx)
|
|||
|
||||
loadFileSub1(&ptr, name, NULL);
|
||||
|
||||
switch(fileType)
|
||||
{
|
||||
switch (fileType) {
|
||||
case type_SET:
|
||||
{
|
||||
int i;
|
||||
int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr);
|
||||
|
||||
for(i = 0; i < numIdx; i++)
|
||||
{
|
||||
if ((currentEntryIdx + i) > numMaxEntriesInSet)
|
||||
{
|
||||
for (i = 0; i < numIdx; i++) {
|
||||
if ((currentEntryIdx + i) > numMaxEntriesInSet) {
|
||||
return 0; // exit if limit is reached
|
||||
}
|
||||
loadSetEntry(name, ptr, currentEntryIdx + i, startIdx + i);
|
||||
loadSetEntry(name, ptr, currentEntryIdx + i,
|
||||
startIdx + i);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -334,8 +311,7 @@ int loadFileMode2(uint8* name, int startIdx, int currentEntryIdx, int numIdx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int loadFullBundle(uint8* name, int startIdx)
|
||||
{
|
||||
int loadFullBundle(uint8 *name, int startIdx) {
|
||||
uint8 *ptr = NULL;
|
||||
fileTypeEnum fileType;
|
||||
|
||||
|
@ -343,8 +319,7 @@ int loadFullBundle(uint8* name, int startIdx)
|
|||
|
||||
loadFileSub1(&ptr, name, NULL);
|
||||
|
||||
switch(fileType)
|
||||
{
|
||||
switch (fileType) {
|
||||
case type_SET:
|
||||
{
|
||||
int i;
|
||||
|
@ -352,8 +327,7 @@ int loadFullBundle(uint8* name, int startIdx)
|
|||
|
||||
numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); // get maximum number of sprites/animations in SET file
|
||||
|
||||
for(i = 0; i < numMaxEntriesInSet; i++)
|
||||
{
|
||||
for (i = 0; i < numMaxEntriesInSet; i++) {
|
||||
loadSetEntry(name, ptr, i, startIdx + i);
|
||||
}
|
||||
|
||||
|
@ -377,8 +351,7 @@ int loadFullBundle(uint8* name, int startIdx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void loadFNTSub(uint8* ptr, int destIdx)
|
||||
{
|
||||
void loadFNTSub(uint8 *ptr, int destIdx) {
|
||||
uint8 *ptr2 = ptr;
|
||||
uint8 *destPtr;
|
||||
int fileIndex;
|
||||
|
@ -389,12 +362,9 @@ void loadFNTSub(uint8* ptr, int destIdx)
|
|||
|
||||
flipLong(&loadFileVar1);
|
||||
|
||||
if(destIdx == -1)
|
||||
{
|
||||
if (destIdx == -1) {
|
||||
fileIndex = createResFileEntry(loadFileVar1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fileIndex = updateResFileEntry(loadFileVar1, 1, destIdx, 1);
|
||||
}
|
||||
|
||||
|
@ -405,8 +375,7 @@ void loadFNTSub(uint8* ptr, int destIdx)
|
|||
memcpy(&fontSize, ptr2, 4);
|
||||
flipLong(&fontSize);
|
||||
|
||||
if(destPtr!=NULL)
|
||||
{
|
||||
if (destPtr != NULL) {
|
||||
int32 i;
|
||||
uint8 *currentPtr;
|
||||
|
||||
|
@ -418,8 +387,7 @@ void loadFNTSub(uint8* ptr, int destIdx)
|
|||
|
||||
currentPtr = destPtr + 14;
|
||||
|
||||
for(i = 0; i < *(int16*) (destPtr + 8); i++)
|
||||
{
|
||||
for (i = 0; i < *(int16 *) (destPtr + 8); i++) {
|
||||
flipLong((int32 *) currentPtr);
|
||||
currentPtr += 4;
|
||||
|
||||
|
@ -429,16 +397,15 @@ void loadFNTSub(uint8* ptr, int destIdx)
|
|||
}
|
||||
}
|
||||
|
||||
void loadSetEntry(uint8* name, uint8* ptr, int currentEntryIdx, int currentDestEntry)
|
||||
{
|
||||
void loadSetEntry(uint8 *name, uint8 *ptr, int currentEntryIdx,
|
||||
int currentDestEntry) {
|
||||
uint8 *ptr2;
|
||||
uint8 *ptr3;
|
||||
int offset;
|
||||
int sec = 0;
|
||||
uint16 numIdx;
|
||||
|
||||
if (!strcmpuint8(ptr,"SEC"))
|
||||
{
|
||||
if (!strcmpuint8(ptr, "SEC")) {
|
||||
sec = 1;
|
||||
}
|
||||
|
||||
|
@ -465,60 +432,63 @@ void loadSetEntry(uint8* name, uint8* ptr, int currentEntryIdx, int currentDestE
|
|||
flipLong((int32 *) & localBuffer.field_0);
|
||||
flipGen(&localBuffer.width, 12);
|
||||
|
||||
if ((sec == 1) || (localBuffer.type == 5))
|
||||
{
|
||||
if ((sec == 1) || (localBuffer.type == 5)) {
|
||||
localBuffer.width = localBuffer.width - (localBuffer.type * 2); // Type 1: Width - (1*2) , Type 5: Width - (5*2)
|
||||
}
|
||||
|
||||
resourceSize = localBuffer.width * localBuffer.height;
|
||||
|
||||
if(currentDestEntry == -1)
|
||||
{
|
||||
fileIndex = createResFileEntry(localBuffer.width,localBuffer.height,localBuffer.type);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileIndex = updateResFileEntry(localBuffer.height, localBuffer.width, currentDestEntry, localBuffer.type);
|
||||
if (currentDestEntry == -1) {
|
||||
fileIndex =
|
||||
createResFileEntry(localBuffer.width,
|
||||
localBuffer.height, localBuffer.type);
|
||||
} else {
|
||||
fileIndex =
|
||||
updateResFileEntry(localBuffer.height,
|
||||
localBuffer.width, currentDestEntry,
|
||||
localBuffer.type);
|
||||
}
|
||||
|
||||
if(fileIndex < 0)
|
||||
{
|
||||
if (fileIndex < 0) {
|
||||
return; // TODO: buffer is not freed
|
||||
}
|
||||
|
||||
ptr5 = ptr3 + localBuffer.field_0 + numIdx * 16;
|
||||
|
||||
memcpy(filesDatabase[fileIndex].subData.ptr,ptr5, resourceSize);
|
||||
memcpy(filesDatabase[fileIndex].subData.ptr, ptr5,
|
||||
resourceSize);
|
||||
ptr5 += resourceSize;
|
||||
|
||||
switch(localBuffer.type)
|
||||
{
|
||||
switch (localBuffer.type) {
|
||||
case 0:
|
||||
{
|
||||
filesDatabase[fileIndex].subData.resourceType = 8;
|
||||
filesDatabase[fileIndex].subData.resourceType =
|
||||
8;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
filesDatabase[fileIndex].subData.resourceType = 2;
|
||||
filesDatabase[fileIndex].subData.resourceType =
|
||||
2;
|
||||
decodeGfxFormat1(&filesDatabase[fileIndex]);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
filesDatabase[fileIndex].width *= 2;
|
||||
filesDatabase[fileIndex].subData.resourceType = 4;
|
||||
filesDatabase[fileIndex].subData.resourceType =
|
||||
4;
|
||||
decodeGfxFormat4(&filesDatabase[fileIndex]);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if (sec == 0)
|
||||
{
|
||||
if (sec == 0) {
|
||||
// TODO sec type 5 needs special conversion. cut out 2 bytes at every width/5 position.
|
||||
return;
|
||||
}
|
||||
filesDatabase[fileIndex].subData.resourceType = 4;
|
||||
filesDatabase[fileIndex].subData.resourceType =
|
||||
4;
|
||||
decodeGfxFormat5(&filesDatabase[fileIndex]);
|
||||
break;
|
||||
}
|
||||
|
@ -529,13 +499,15 @@ void loadSetEntry(uint8* name, uint8* ptr, int currentEntryIdx, int currentDestE
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsuported gfx loading type: %d\n", localBuffer.type);
|
||||
printf("Unsuported gfx loading type: %d\n",
|
||||
localBuffer.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
filesDatabase[fileIndex].subData.index = currentDestEntry;
|
||||
filesDatabase[fileIndex].subData.transparency = localBuffer.transparency; /*% 0x10*/;
|
||||
filesDatabase[fileIndex].subData.transparency =
|
||||
localBuffer.transparency; /*% 0x10 */ ;
|
||||
|
||||
strcpyuint8(filesDatabase[fileIndex].subData.name, name);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _DATALOADER_H_
|
||||
#define _DATALOADER_H_
|
||||
#ifndef CRUISE_DATALOADER_H
|
||||
#define CRUISE_DATALOADER_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,8 +29,7 @@ namespace Cruise {
|
|||
uint32 crc; // variable at 5C5A
|
||||
uint32 bitbucket; // dx:bx
|
||||
|
||||
uint16 swap16(uint16 r)
|
||||
{
|
||||
uint16 swap16(uint16 r) {
|
||||
return (r >> 8) | (r << 8);
|
||||
}
|
||||
|
||||
|
@ -148,6 +147,7 @@ int32 decomp(uint8 * in, uint8 * out, int32 size) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int main(void) {
|
||||
FILE * in, * out;
|
||||
|
@ -172,5 +172,4 @@ int main(void) {
|
|||
fclose(in);
|
||||
}*/
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "cruise/cruise.h"
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct CRUISEGameDescription {
|
||||
Common::ADGameDescription desc;
|
||||
|
||||
|
@ -117,6 +118,7 @@ namespace Cruise {
|
|||
|
||||
bool CruiseEngine::initGame() {
|
||||
_gameDescription = (const CRUISEGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
|
||||
|
||||
return (_gameDescription != 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,22 +29,18 @@
|
|||
namespace Cruise {
|
||||
|
||||
// (old: fontProc1(int16 param, uint8* ptr1, uint8* ptr2))
|
||||
int32 getLineHeight(int16 charCount, uint8* fontPtr, uint8* fontPrt_Desc)
|
||||
{
|
||||
int32 getLineHeight(int16 charCount, uint8 * fontPtr, uint8 * fontPrt_Desc) {
|
||||
uint8 *dest;
|
||||
int32 highestChar = 0;
|
||||
int32 i;
|
||||
|
||||
if(!charCount)
|
||||
{
|
||||
if (!charCount) {
|
||||
return (0);
|
||||
}
|
||||
dest = fontPrt_Desc + 6; // fontPtr + 20 // char height
|
||||
|
||||
for(i = 0; i < charCount; i++)
|
||||
{
|
||||
if((*(int16*) dest) > highestChar)
|
||||
{
|
||||
for (i = 0; i < charCount; i++) {
|
||||
if ((*(int16 *) dest) > highestChar) {
|
||||
highestChar = *(int16 *) dest;
|
||||
}
|
||||
dest += 12;
|
||||
|
@ -53,8 +49,8 @@ int32 getLineHeight(int16 charCount, uint8* fontPtr, uint8* fontPrt_Desc)
|
|||
}
|
||||
|
||||
// this function determins how many lines the text will have (old: fontProc2(int32 param1, int32 param2, uint8* ptr, uint8* string))
|
||||
int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8* ptr, uint8* textString)
|
||||
{
|
||||
int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth,
|
||||
uint8 *ptr, uint8 *textString) {
|
||||
uint8 *localString = textString;
|
||||
uint8 *currentStringPtr;
|
||||
uint8 character;
|
||||
|
@ -64,32 +60,25 @@ int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8* ptr,
|
|||
|
||||
uint8 *tempPtr = 0;
|
||||
|
||||
if(!*localString)
|
||||
{
|
||||
if (!*localString) {
|
||||
return (0);
|
||||
}
|
||||
currentStringPtr = localString;
|
||||
character = *localString;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
int32 charData = fontCharacterTable[character];
|
||||
|
||||
if(character == '|')
|
||||
{
|
||||
if (character == '|') {
|
||||
lineLength = rightBorder_X;
|
||||
localString = tempPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(charData >= 0)
|
||||
{ // + 0xA jump to last 2 bytes of the 12 bytes slice = letter width
|
||||
lineLength += wordSpacingWidth + *(int16*) (ptr + 0xA + charData * 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(character == ' ')
|
||||
{
|
||||
} else {
|
||||
if (charData >= 0) { // + 0xA jump to last 2 bytes of the 12 bytes slice = letter width
|
||||
lineLength +=
|
||||
wordSpacingWidth + *(int16 *) (ptr + 0xA +
|
||||
charData * 12);
|
||||
} else {
|
||||
if (character == ' ') {
|
||||
lineLength += wordSpacingWidth + 5;
|
||||
localString = currentStringPtr;
|
||||
}
|
||||
|
@ -98,8 +87,7 @@ int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8* ptr,
|
|||
|
||||
tempPtr = currentStringPtr;
|
||||
|
||||
if(rightBorder_X <= lineLength)
|
||||
{
|
||||
if (rightBorder_X <= lineLength) {
|
||||
var_6 += rightBorder_X;
|
||||
currentStringPtr = localString;
|
||||
tempPtr = localString;
|
||||
|
@ -111,18 +99,14 @@ int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8* ptr,
|
|||
|
||||
} while (character);
|
||||
|
||||
if(lineLength == 0)
|
||||
{
|
||||
if (lineLength == 0) {
|
||||
return (var_6 / rightBorder_X);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return ((var_6 + rightBorder_X) / rightBorder_X);
|
||||
}
|
||||
}
|
||||
|
||||
void loadFNT(const void* fileNameChar)
|
||||
{
|
||||
void loadFNT(const void *fileNameChar) {
|
||||
uint8 header[6];
|
||||
int32 fontSize;
|
||||
int32 data2;
|
||||
|
@ -132,8 +116,7 @@ void loadFNT(const void* fileNameChar)
|
|||
|
||||
Common::File fontFileHandle;
|
||||
|
||||
if(!fontFileHandle.exists((char*)fileName))
|
||||
{
|
||||
if (!fontFileHandle.exists((char *)fileName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -141,8 +124,7 @@ void loadFNT(const void* fileNameChar)
|
|||
|
||||
fontFileHandle.read(header, 4);
|
||||
|
||||
if(strcmpuint8(header, "FNT") == 0)
|
||||
{
|
||||
if (strcmpuint8(header, "FNT") == 0) {
|
||||
fontFileHandle.read(&fontSize, 4);
|
||||
flipLong(&fontSize);
|
||||
|
||||
|
@ -154,8 +136,7 @@ void loadFNT(const void* fileNameChar)
|
|||
|
||||
_systemFNT = (uint8 *) mallocAndZero(fontSize);
|
||||
|
||||
if(_systemFNT != NULL)
|
||||
{
|
||||
if (_systemFNT != NULL) {
|
||||
int32 i;
|
||||
uint8 *currentPtr;
|
||||
|
||||
|
@ -170,8 +151,7 @@ void loadFNT(const void* fileNameChar)
|
|||
|
||||
currentPtr = _systemFNT + 14;
|
||||
|
||||
for(i = 0; i < *(int16*) (_systemFNT + 8); i++)
|
||||
{
|
||||
for (i = 0; i < *(int16 *) (_systemFNT + 8); i++) {
|
||||
flipLong((int32 *) currentPtr);
|
||||
currentPtr += 4;
|
||||
|
||||
|
@ -184,8 +164,7 @@ void loadFNT(const void* fileNameChar)
|
|||
fontFileHandle.close();
|
||||
}
|
||||
|
||||
void loadSystemFont(void)
|
||||
{
|
||||
void loadSystemFont(void) {
|
||||
int32 i;
|
||||
|
||||
video2 = 15;
|
||||
|
@ -193,8 +172,7 @@ void loadSystemFont(void)
|
|||
video3 = 13;
|
||||
colorOfSelectedSaveDrive = 10;
|
||||
|
||||
for(i = 0; i < 64; i++)
|
||||
{
|
||||
for (i = 0; i < 64; i++) {
|
||||
mediumVar[i].ptr = 0;
|
||||
mediumVar[i].field_1C = 0;
|
||||
}
|
||||
|
@ -213,24 +191,21 @@ void loadSystemFont(void)
|
|||
loadFNT("system.fnt");
|
||||
}
|
||||
|
||||
void flipShort(int16* var)
|
||||
{
|
||||
void flipShort(int16 *var) {
|
||||
uint8 *varPtr = (uint8 *) var;
|
||||
uint8 temp = varPtr[0];
|
||||
varPtr[0] = varPtr[1];
|
||||
varPtr[1] = temp;
|
||||
}
|
||||
|
||||
void flipShort(uint16* var)
|
||||
{
|
||||
void flipShort(uint16 *var) {
|
||||
uint8 *varPtr = (uint8 *) var;
|
||||
uint8 temp = varPtr[0];
|
||||
varPtr[0] = varPtr[1];
|
||||
varPtr[1] = temp;
|
||||
}
|
||||
|
||||
void flipLong(int32* var)
|
||||
{
|
||||
void flipLong(int32 *var) {
|
||||
char swap1;
|
||||
char swap2;
|
||||
char *varPtr = (char *)var;
|
||||
|
@ -244,8 +219,7 @@ void flipLong(int32* var)
|
|||
varPtr[2] = swap2;
|
||||
}
|
||||
|
||||
void flipLong(uint32* var)
|
||||
{
|
||||
void flipLong(uint32 *var) {
|
||||
char swap1;
|
||||
char swap2;
|
||||
char *varPtr = (char *)var;
|
||||
|
@ -259,20 +233,18 @@ void flipLong(uint32* var)
|
|||
varPtr[2] = swap2;
|
||||
}
|
||||
|
||||
void flipGen(void* var, int32 length)
|
||||
{
|
||||
void flipGen(void *var, int32 length) {
|
||||
int i;
|
||||
short int *varPtr = (int16 *) var;
|
||||
|
||||
for(i = 0; i < (length / 2); i++)
|
||||
{
|
||||
for (i = 0; i < (length / 2); i++) {
|
||||
flipShort(&varPtr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void renderWord(uint8* fontPtr_Data, uint8* outBufferPtr, int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, int32 stringRenderBufferSize, int32 width, int32 charWidth)
|
||||
{
|
||||
void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr,
|
||||
int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4,
|
||||
int32 stringRenderBufferSize, int32 width, int32 charWidth) {
|
||||
int i;
|
||||
int j;
|
||||
uint8 *fontPtr_Data2 = fontPtr_Data + height * 2;
|
||||
|
@ -282,15 +254,18 @@ void renderWord(uint8* fontPtr_Data, uint8* outBufferPtr, int32 drawPosPixel_X,
|
|||
|
||||
for (i = 0; i < height; i++) // y++
|
||||
{
|
||||
uint16 currentColor1 = (*(fontPtr_Data) << 8) | *(fontPtr_Data + 1);
|
||||
uint16 currentColor2 = (*(fontPtr_Data2) << 8) | *(fontPtr_Data2 + 1);
|
||||
uint16 currentColor1 =
|
||||
(*(fontPtr_Data) << 8) | *(fontPtr_Data + 1);
|
||||
uint16 currentColor2 =
|
||||
(*(fontPtr_Data2) << 8) | *(fontPtr_Data2 + 1);
|
||||
|
||||
fontPtr_Data += 2;
|
||||
fontPtr_Data2 += 2;
|
||||
|
||||
for (j = 0; j < charWidth; j++)
|
||||
{
|
||||
*outBufferPtr = ((currentColor1 >> 15) & 1) | ((currentColor2 >> 14) & 2);
|
||||
for (j = 0; j < charWidth; j++) {
|
||||
*outBufferPtr =
|
||||
((currentColor1 >> 15) & 1) | ((currentColor2 >>
|
||||
14) & 2);
|
||||
outBufferPtr++;
|
||||
|
||||
currentColor1 <<= 1;
|
||||
|
@ -301,8 +276,8 @@ void renderWord(uint8* fontPtr_Data, uint8* outBufferPtr, int32 drawPosPixel_X,
|
|||
}
|
||||
|
||||
// returns character count and pixel size (via pointer) per line of the string (old: prepareWordRender(int32 param, int32 var1, int16* out2, uint8* ptr3, uint8* string))
|
||||
int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, int16* strPixelLength, uint8* ptr3, uint8* textString)
|
||||
{
|
||||
int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth,
|
||||
int16 * strPixelLength, uint8 * ptr3, uint8 * textString) {
|
||||
uint8 *localString = textString;
|
||||
|
||||
int32 counter = 0;
|
||||
|
@ -311,47 +286,39 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, int16* st
|
|||
int32 temp_cc = 0; // var_C // temporary char count save
|
||||
int32 pixelCount = 0; // si
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
uint8 character = *(localString++);
|
||||
int16 charData = fontCharacterTable[character];
|
||||
|
||||
if(character == ' ')
|
||||
{
|
||||
if (character == ' ') {
|
||||
temp_cc = counter;
|
||||
temp_pc = pixelCount;
|
||||
|
||||
if(pixelCount + wordSpacingWidth + 5 >= inRightBorder_X)
|
||||
{
|
||||
if (pixelCount + wordSpacingWidth + 5 >=
|
||||
inRightBorder_X) {
|
||||
finish = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pixelCount += wordSpacingWidth + 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(character == '|' || !character)
|
||||
{
|
||||
} else {
|
||||
if (character == '|' || !character) {
|
||||
finish = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(charData)
|
||||
{
|
||||
if(pixelCount + wordSpacingWidth + *(int16*) ((ptr3 + charData * 12) + 0xA) >= inRightBorder_X)
|
||||
{
|
||||
} else {
|
||||
if (charData) {
|
||||
if (pixelCount + wordSpacingWidth +
|
||||
*(int16 *) ((ptr3 +
|
||||
charData * 12) + 0xA) >=
|
||||
inRightBorder_X) {
|
||||
finish = 1;
|
||||
if(temp_pc)
|
||||
{
|
||||
if (temp_pc) {
|
||||
pixelCount = temp_pc;
|
||||
counter = temp_cc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelCount += wordSpacingWidth + *(int16*) ((ptr3 + charData * 12) + 0xA);
|
||||
} else {
|
||||
pixelCount +=
|
||||
wordSpacingWidth +
|
||||
*(int16 *) ((ptr3 +
|
||||
charData * 12) + 0xA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,9 +330,8 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, int16* st
|
|||
return counter;
|
||||
}
|
||||
|
||||
|
||||
void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int32 inRightBorder_X)
|
||||
{
|
||||
void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color,
|
||||
int32 inRightBorder_X) {
|
||||
uint8 *fontPtr;
|
||||
uint8 *fontPtr_Data; // ptr2
|
||||
uint8 *fontPtr_Desc; // ptr3
|
||||
|
@ -385,27 +351,21 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
int32 renderBufferSize; // var_1E
|
||||
int needFlip;
|
||||
|
||||
if(!buffer || !string)
|
||||
{
|
||||
if (!buffer || !string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontFileIndex != -1)
|
||||
{
|
||||
if (fontFileIndex != -1) {
|
||||
fontPtr = filesDatabase[fontFileIndex].subData.ptr;
|
||||
|
||||
if(!fontPtr)
|
||||
{
|
||||
if (!fontPtr) {
|
||||
fontPtr = _systemFNT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fontPtr = _systemFNT;
|
||||
}
|
||||
|
||||
if(!fontPtr)
|
||||
{
|
||||
if (!fontPtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -417,36 +377,28 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
wordSpacingWidth = *(int16 *) (fontPtr + 10);
|
||||
wordSpacingHeight = *(int16 *) (fontPtr + 12);
|
||||
|
||||
if(inRightBorder_X > 310)
|
||||
{
|
||||
if (inRightBorder_X > 310) {
|
||||
rightBorder_X = 310;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rightBorder_X = inRightBorder_X;
|
||||
}
|
||||
if(x + rightBorder_X > 319)
|
||||
{
|
||||
if (x + rightBorder_X > 319) {
|
||||
x = 319 - rightBorder_X;
|
||||
}
|
||||
if(y < 0)
|
||||
{
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
if(x < 0)
|
||||
{
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
numLines = getTextLineCount(rightBorder_X, wordSpacingWidth, fontPtr_Desc, string); // ok
|
||||
|
||||
if(!numLines)
|
||||
{
|
||||
if (!numLines) {
|
||||
return;
|
||||
}
|
||||
stringHeight = ((wordSpacingHeight + lineHeight + 2) * numLines) + 1;
|
||||
|
||||
if (y + stringHeight > 199)
|
||||
{
|
||||
if (y + stringHeight > 199) {
|
||||
y = 200 - stringHeight;
|
||||
}
|
||||
stringFinished = 0;
|
||||
|
@ -454,18 +406,15 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
stringRenderBufferSize = stringWidth * stringHeight * 4;
|
||||
inRightBorder_X = rightBorder_X;
|
||||
|
||||
if(stringRenderBufferSize > 0x2000)
|
||||
{
|
||||
currentStrRenderBuffer = (uint8*) mallocAndZero(stringRenderBufferSize);
|
||||
if (stringRenderBufferSize > 0x2000) {
|
||||
currentStrRenderBuffer =
|
||||
(uint8 *) mallocAndZero(stringRenderBufferSize);
|
||||
|
||||
if(!currentStrRenderBuffer)
|
||||
{
|
||||
if (!currentStrRenderBuffer) {
|
||||
return;
|
||||
}
|
||||
useDynamicBuffer = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentStrRenderBuffer = (uint8 *) ptr_something;
|
||||
useDynamicBuffer = 0;
|
||||
}
|
||||
|
@ -476,16 +425,14 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
heightOffset = 0;
|
||||
renderBufferSize = stringRenderBufferSize;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
int spacesCount = 0; // si
|
||||
char character = *(string);
|
||||
short int strPixelLength; // var_16;
|
||||
uint8 *ptrStringEnd; // var_4 //ok
|
||||
int drawPosPixel_X; // di
|
||||
|
||||
while(character == ' ')
|
||||
{
|
||||
while (character == ' ') {
|
||||
spacesCount++;
|
||||
character = *(string + spacesCount);
|
||||
}
|
||||
|
@ -493,48 +440,48 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
string += spacesCount;
|
||||
ptrStringEnd = string + prepareWordRender(inRightBorder_X, wordSpacingWidth, &strPixelLength, fontPtr_Desc, string); //ok
|
||||
|
||||
if(inRightBorder_X > strPixelLength)
|
||||
{
|
||||
drawPosPixel_X = (inRightBorder_X - strPixelLength) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inRightBorder_X > strPixelLength) {
|
||||
drawPosPixel_X =
|
||||
(inRightBorder_X - strPixelLength) / 2;
|
||||
} else {
|
||||
drawPosPixel_X = 0;
|
||||
}
|
||||
// drawPosPixel_X = var_8;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
character = *(string++);
|
||||
|
||||
short int data = fontCharacterTable[(int)character];
|
||||
|
||||
if(character)
|
||||
{
|
||||
if(character == ' ' || character == 0x7D)
|
||||
{
|
||||
if (character) {
|
||||
if (character == ' ' || character == 0x7D) {
|
||||
drawPosPixel_X += var1 + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
short int* si = (int16*) (fontPtr_Desc + data * 12);
|
||||
} else {
|
||||
if (data) {
|
||||
short int *si =
|
||||
(int16 *) (fontPtr_Desc +
|
||||
data * 12);
|
||||
//int var_2 = si[5];
|
||||
|
||||
renderWord(fontPtr_Data + si[0], currentStrRenderBuffer, drawPosPixel_X, si[4] - si[3] + lineHeight + heightOffset, si[3], si[2], renderBufferSize / 2, stringWidth * 2, si[5]);
|
||||
renderWord(fontPtr_Data +
|
||||
si[0],
|
||||
currentStrRenderBuffer,
|
||||
drawPosPixel_X,
|
||||
si[4] - si[3] +
|
||||
lineHeight + heightOffset,
|
||||
si[3], si[2],
|
||||
renderBufferSize / 2,
|
||||
stringWidth * 2, si[5]);
|
||||
|
||||
drawPosPixel_X += wordSpacingWidth + si[5];
|
||||
drawPosPixel_X +=
|
||||
wordSpacingWidth + si[5];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
stringFinished = 1;
|
||||
}
|
||||
|
||||
if(ptrStringEnd <= string)
|
||||
{
|
||||
if (ptrStringEnd <= string) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -547,10 +494,8 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
|
||||
needFlip = 0;
|
||||
|
||||
if(buffer == gfxModuleData.pPage00)
|
||||
{
|
||||
if(gfxModuleData.field_1 != 0)
|
||||
{
|
||||
if (buffer == gfxModuleData.pPage00) {
|
||||
if (gfxModuleData.field_1 != 0) {
|
||||
needFlip = 1;
|
||||
gfxModuleData_field_90();
|
||||
}
|
||||
|
@ -558,24 +503,22 @@ void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int
|
|||
gfxModuleData_gfxWaitVSync();
|
||||
}
|
||||
|
||||
gfxModuleData_field_64((char*)currentStrRenderBuffer, stringWidth, stringHeight, (char*)buffer, x, y, 0);
|
||||
gfxModuleData_field_64((char*)currentStrRenderBuffer, stringWidth, stringHeight, (char*)buffer, x, y, color);
|
||||
gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth,
|
||||
stringHeight, (char *)buffer, x, y, 0);
|
||||
gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth,
|
||||
stringHeight, (char *)buffer, x, y, color);
|
||||
|
||||
if(needFlip)
|
||||
{
|
||||
if (needFlip) {
|
||||
gfxModuleData_flip();
|
||||
}
|
||||
|
||||
if(useDynamicBuffer)
|
||||
{
|
||||
if (useDynamicBuffer) {
|
||||
free(currentStrRenderBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// calculates all necessary datas and renders text
|
||||
gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
||||
{
|
||||
gfxEntryStruct *renderText(int inRightBorder_X, uint8 *string) {
|
||||
uint8 *fontPtr;
|
||||
uint8 *fontPtr_Data; // pt2
|
||||
uint8 *fontPtr_Desc; // ptr3
|
||||
|
@ -596,28 +539,21 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
gfxEntryStruct *generatedGfxEntry;
|
||||
|
||||
// check if string is empty
|
||||
if(!string)
|
||||
{
|
||||
if (!string) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check if font has been loaded, else get system font
|
||||
if(fontFileIndex != -1)
|
||||
{
|
||||
if (fontFileIndex != -1) {
|
||||
fontPtr = filesDatabase[fontFileIndex].subData.ptr;
|
||||
|
||||
if(!fontPtr)
|
||||
{
|
||||
if (!fontPtr) {
|
||||
fontPtr = _systemFNT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fontPtr = _systemFNT;
|
||||
}
|
||||
|
||||
if(!fontPtr)
|
||||
{
|
||||
if (!fontPtr) {
|
||||
return NULL;
|
||||
}
|
||||
fontPtr_Data = fontPtr + *(int16 *) (fontPtr + 4); // offset to char data
|
||||
|
@ -629,18 +565,14 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
wordSpacingHeight = *(int16 *) (fontPtr + 12);
|
||||
|
||||
// if right border is higher then screenwidth (+ spacing), adjust border
|
||||
if(inRightBorder_X > 310)
|
||||
{
|
||||
if (inRightBorder_X > 310) {
|
||||
rightBorder_X = 310;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rightBorder_X = inRightBorder_X;
|
||||
}
|
||||
numLines = getTextLineCount(rightBorder_X, wordSpacingWidth, fontPtr_Desc, string); // ok
|
||||
|
||||
if(!numLines)
|
||||
{
|
||||
if (!numLines) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -650,7 +582,8 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
stringRenderBufferSize = stringWidth * stringHeight * 4;
|
||||
inRightBorder_X = rightBorder_X;
|
||||
|
||||
currentStrRenderBuffer = (uint8*) mallocAndZero(stringRenderBufferSize);
|
||||
currentStrRenderBuffer =
|
||||
(uint8 *) mallocAndZero(stringRenderBufferSize);
|
||||
resetRaster(currentStrRenderBuffer, stringRenderBufferSize);
|
||||
|
||||
generatedGfxEntry = (gfxEntryStruct *) malloc(sizeof(gfxEntryStruct));
|
||||
|
@ -663,8 +596,7 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
// var_8 = 0;
|
||||
heightOffset = 0;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
int spacesCount = 0; // si
|
||||
char character = *string;
|
||||
short int strPixelLength; // var_16
|
||||
|
@ -672,8 +604,7 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
int drawPosPixel_X; // di
|
||||
|
||||
// find first letter in string, skip all spaces
|
||||
while(character == ' ')
|
||||
{
|
||||
while (character == ' ') {
|
||||
spacesCount++;
|
||||
character = *(string + spacesCount);
|
||||
}
|
||||
|
@ -684,52 +615,50 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
ptrStringEnd = string + prepareWordRender(inRightBorder_X, wordSpacingWidth, &strPixelLength, fontPtr_Desc, string); //ok
|
||||
|
||||
// determine how much space is left to the right and left (center text)
|
||||
if(inRightBorder_X > strPixelLength)
|
||||
{
|
||||
if (inRightBorder_X > strPixelLength) {
|
||||
//var_8 = (inRightBorder_X - strPixelLength) / 2;
|
||||
drawPosPixel_X = (inRightBorder_X - strPixelLength) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawPosPixel_X =
|
||||
(inRightBorder_X - strPixelLength) / 2;
|
||||
} else {
|
||||
drawPosPixel_X = 0;
|
||||
}
|
||||
//drawPosPixel_X = var_8;
|
||||
|
||||
// draw textline, character wise
|
||||
do
|
||||
{
|
||||
do {
|
||||
character = *(string++);
|
||||
|
||||
short int charData = fontCharacterTable[(int)character]; // get character position
|
||||
|
||||
if(character)
|
||||
{
|
||||
if(character == ' ' || character == 0x7C)
|
||||
{
|
||||
if (character) {
|
||||
if (character == ' ' || character == 0x7C) {
|
||||
drawPosPixel_X += wordSpacingWidth + 5; // if char = "space" adjust word starting postion (don't render space though);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(charData >= 0)
|
||||
{
|
||||
} else {
|
||||
if (charData >= 0) {
|
||||
short int *si = (int16 *) (fontPtr_Desc + charData * 12); // offset font data
|
||||
// int var_2 = si[5]; // don't need this
|
||||
|
||||
// should ist be stringRenderBufferSize/2 for the second last param?
|
||||
renderWord(fontPtr_Data + si[0], currentStrRenderBuffer, drawPosPixel_X, si[4] - si[3] + lineHeight + heightOffset, si[3], si[2], stringRenderBufferSize, stringWidth / 2, si[5]);
|
||||
renderWord(fontPtr_Data +
|
||||
si[0],
|
||||
currentStrRenderBuffer,
|
||||
drawPosPixel_X,
|
||||
si[4] - si[3] +
|
||||
lineHeight + heightOffset,
|
||||
si[3], si[2],
|
||||
stringRenderBufferSize,
|
||||
stringWidth / 2, si[5]);
|
||||
|
||||
drawPosPixel_X += wordSpacingWidth + si[5];
|
||||
drawPosPixel_X +=
|
||||
wordSpacingWidth + si[5];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
stringFinished = 1; // character = 0x00
|
||||
}
|
||||
|
||||
// check if string already reached the end
|
||||
if(ptrStringEnd <= string)
|
||||
{
|
||||
if (ptrStringEnd <= string) {
|
||||
break;
|
||||
}
|
||||
} while (!stringFinished);
|
||||
|
@ -741,5 +670,4 @@ gfxEntryStruct* renderText(int inRightBorder_X, uint8* string)
|
|||
return generatedGfxEntry;
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _FONT_H_
|
||||
#define _FONT_H_
|
||||
#ifndef CRUISE_FONT_H
|
||||
#define CRUISE_FONT_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -40,9 +40,12 @@ void flipGen(void* var, int32 length);
|
|||
int32 getLineHeight(int16 charCount, uint8 * fontPtr, uint8 * fontPrt_Desc); // fontProc1
|
||||
int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8 * ptr, uint8 * textString); // fontProc2
|
||||
|
||||
void renderWord(uint8* fontPtr_Data, uint8* outBufferPtr, int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, int32 stringRenderBufferSize, int32 width , int32 charWidth);
|
||||
void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr,
|
||||
int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4,
|
||||
int32 stringRenderBufferSize, int32 width, int32 charWidth);
|
||||
gfxEntryStruct *renderText(int inRightBorder_X, uint8 * string);
|
||||
void drawString(int32 x, int32 y, uint8* string, uint8* buffer, uint8 color, int32 inRightBorder_X);
|
||||
void drawString(int32 x, int32 y, uint8 * string, uint8 * buffer, uint8 color,
|
||||
int32 inRightBorder_X);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
|
|
@ -191,5 +191,4 @@ int16 fontCharacterTable[256]={
|
|||
-1,
|
||||
};
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,14 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _FONTCHARACTERTABLE_H_
|
||||
#define _FONTCHARACTERTABLE_H_
|
||||
#ifndef CRUISE_FONTCHARACTERTABLE_H
|
||||
#define CRUISE_FONTCHARACTERTABLE_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
extern short int fontCharacterTable[256];
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _FUNCTION_H_
|
||||
#define _FUNCTION_H_
|
||||
#ifndef CRUISE_FUNCTION_H
|
||||
#define CRUISE_FUNCTION_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -36,4 +36,3 @@ int16 subOp23(int param1, int param2);
|
|||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _GFXMODULE_H_
|
||||
#define _GFXMODULE_H_
|
||||
#ifndef CRUISE_GFXMODULE_H
|
||||
#define CRUISE_GFXMODULE_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct gfxModuleDataStruct
|
||||
{
|
||||
struct gfxModuleDataStruct {
|
||||
int field_1;
|
||||
int useTandy;
|
||||
int useEGA;
|
||||
|
@ -38,8 +37,7 @@ struct gfxModuleDataStruct
|
|||
uint8 *pPage10;
|
||||
};
|
||||
|
||||
struct palEntry
|
||||
{
|
||||
struct palEntry {
|
||||
uint8 R;
|
||||
uint8 G;
|
||||
uint8 B;
|
||||
|
@ -58,15 +56,15 @@ void gfxModuleData_setPal(uint8* ptr);
|
|||
void gfxModuleData_field_90(void);
|
||||
void gfxModuleData_gfxWaitVSync(void);
|
||||
void gfxModuleData_flip(void);
|
||||
void gfxModuleData_field_64(char* sourceBuffer, int width, int height, char* dest, int x, int y, int color);
|
||||
void gfxModuleData_field_64(char *sourceBuffer, int width, int height,
|
||||
char *dest, int x, int y, int color);
|
||||
void gfxModuleData_gfxCopyScreen(char *sourcePtr, char *destPtr);
|
||||
void gfxModuleData_field_60(char* sourcePtr, int width, int height, char* destPtr, int x, int y);
|
||||
void gfxModuleData_field_60(char *sourcePtr, int width, int height,
|
||||
char *destPtr, int x, int y);
|
||||
void gfxModuleData_flipScreen(void);
|
||||
void gfxModuleData_setPal256(int16 * ptr);
|
||||
void flip(void);
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
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];
|
||||
|
@ -45,15 +45,12 @@ exportEntryStruct* parseExport(int* out1, int* pExportedFuncionIdx, char* buffer
|
|||
strcpyuint8(localBuffer, buffer);
|
||||
dotPtr = strchr(localBuffer, '.');
|
||||
|
||||
if(dotPtr)
|
||||
{
|
||||
if (dotPtr) {
|
||||
strcpyuint8(functionName, dotPtr + 1);
|
||||
*dotPtr = 0;
|
||||
|
||||
strcpyuint8(overlayName, localBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
overlayName[0] = 0;
|
||||
|
||||
strcpyuint8(functionName, buffer);
|
||||
|
@ -61,8 +58,7 @@ exportEntryStruct* parseExport(int* out1, int* pExportedFuncionIdx, char* buffer
|
|||
|
||||
ptr2 = strchr((char *)functionName, ':');
|
||||
|
||||
if(ptr2)
|
||||
{
|
||||
if (ptr2) {
|
||||
*ptr2 = 0;
|
||||
|
||||
*out1 = 1;
|
||||
|
@ -91,16 +87,14 @@ exportEntryStruct* parseExport(int* out1, int* pExportedFuncionIdx, char* buffer
|
|||
if (!entity1Name)
|
||||
return (0);
|
||||
|
||||
for(i=0;i<numExport;i++)
|
||||
{
|
||||
for (i = 0; i < numExport; i++) {
|
||||
uint8 exportedName[256];
|
||||
uint8 *name = entity1Name + currentExportEntry->offsetToName;
|
||||
|
||||
strcpyuint8(exportedName, name);
|
||||
strToUpper(exportedName);
|
||||
|
||||
if(!strcmpuint8(functionName,exportedName))
|
||||
{
|
||||
if (!strcmpuint8(functionName, exportedName)) {
|
||||
*pExportedFuncionIdx = idx;
|
||||
|
||||
return (currentExportEntry);
|
||||
|
@ -112,9 +106,7 @@ exportEntryStruct* parseExport(int* out1, int* pExportedFuncionIdx, char* buffer
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
int updateScriptImport(int ovlIdx)
|
||||
{
|
||||
int updateScriptImport(int ovlIdx) {
|
||||
char buffer[256];
|
||||
ovlDataStruct *ovlData;
|
||||
int numData3;
|
||||
|
@ -138,36 +130,27 @@ int updateScriptImport(int ovlIdx)
|
|||
param = 0;
|
||||
|
||||
// do it for the 2 first string types
|
||||
do
|
||||
{
|
||||
do {
|
||||
|
||||
int i = 0;
|
||||
|
||||
if(param == 0)
|
||||
{
|
||||
if (param == 0) {
|
||||
var_32 = numData3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var_32 = size5;
|
||||
}
|
||||
|
||||
if(var_32)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (var_32) {
|
||||
do {
|
||||
importScriptStruct *ptrImportData;
|
||||
uint8 *ptrImportName;
|
||||
uint8 *ptrData;
|
||||
|
||||
int var_22 = 0;
|
||||
|
||||
if(param == 0)
|
||||
{
|
||||
if (param == 0) {
|
||||
pScript = getOvlData3Entry(ovlIdx, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pScript = scriptFunc1Sub2(ovlIdx, i);
|
||||
}
|
||||
|
||||
|
@ -177,68 +160,95 @@ int updateScriptImport(int ovlIdx)
|
|||
|
||||
var_22 = 0;
|
||||
|
||||
if(pScript->numImport > 0)
|
||||
{
|
||||
if (pScript->numImport > 0) {
|
||||
int counter = pScript->numImport;
|
||||
|
||||
do
|
||||
{
|
||||
int param2 = ptrImportData->type;
|
||||
do {
|
||||
int param2 =
|
||||
ptrImportData->type;
|
||||
|
||||
if(param2 != 70)
|
||||
{
|
||||
exportEntryStruct* ptrDest2;
|
||||
if (param2 != 70) {
|
||||
exportEntryStruct
|
||||
* ptrDest2;
|
||||
int out1;
|
||||
int out2;
|
||||
|
||||
strcpyuint8(buffer,ptrImportName + ptrImportData->offsetToName);
|
||||
ptrDest2 = parseExport(&out1,&out2,buffer);
|
||||
strcpyuint8(buffer,
|
||||
ptrImportName +
|
||||
ptrImportData->
|
||||
offsetToName);
|
||||
ptrDest2 =
|
||||
parseExport(&out1,
|
||||
&out2, buffer);
|
||||
|
||||
if(ptrDest2 && out2)
|
||||
{
|
||||
int temp = ptrImportData->offset;
|
||||
if (ptrDest2 && out2) {
|
||||
int temp =
|
||||
ptrImportData->
|
||||
offset;
|
||||
if (out1) //is sub function... (ie 'invent.livre:s')
|
||||
{
|
||||
uint8 *ptr = ptrData + temp;
|
||||
|
||||
*(ptr+1) = out2;
|
||||
*(int16*)(ptr+2) = ptrDest2->idx;
|
||||
*(ptr +
|
||||
1)
|
||||
=
|
||||
out2;
|
||||
*(int16
|
||||
*)
|
||||
(ptr
|
||||
+
|
||||
2)
|
||||
=
|
||||
ptrDest2->
|
||||
idx;
|
||||
|
||||
flipShort((int16*)(ptr+2));
|
||||
}
|
||||
else
|
||||
{
|
||||
flipShort
|
||||
(
|
||||
(int16
|
||||
*)
|
||||
(ptr + 2));
|
||||
} else {
|
||||
if (param2 == 20 || param2 == 30 || param2 == 40 || param2 == 50) // this patch a double push
|
||||
{
|
||||
uint8* ptr = ptrData + temp;
|
||||
uint8
|
||||
*
|
||||
ptr
|
||||
=
|
||||
ptrData
|
||||
+
|
||||
temp;
|
||||
|
||||
*(ptr + 1) = 0;
|
||||
*(ptr + 2) = out2; // update the overlay number
|
||||
|
||||
*(int16 *) (ptr + 4) = ptrDest2->idx;
|
||||
|
||||
flipShort((int16*)(ptr+4));
|
||||
}
|
||||
else
|
||||
{
|
||||
flipShort
|
||||
(
|
||||
(int16
|
||||
*)
|
||||
(ptr + 4));
|
||||
} else {
|
||||
int var_4 = ptrDest2->var4;
|
||||
|
||||
if(var_4&1)
|
||||
{
|
||||
param2 = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
param2 = 16;
|
||||
if (var_4 & 1) {
|
||||
param2
|
||||
=
|
||||
8;
|
||||
} else {
|
||||
param2
|
||||
=
|
||||
16;
|
||||
}
|
||||
|
||||
if(var_4>=0 && var_4<=3)
|
||||
{
|
||||
param2 |= 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
param2 |= 6;
|
||||
if (var_4 >= 0 && var_4 <= 3) {
|
||||
param2
|
||||
|=
|
||||
5;
|
||||
} else {
|
||||
param2
|
||||
|=
|
||||
6;
|
||||
}
|
||||
|
||||
*(ptrData + temp) = param2;
|
||||
|
@ -246,7 +256,15 @@ int updateScriptImport(int ovlIdx)
|
|||
|
||||
*(int16 *) (ptrData + temp + 2) = ptrDest2->idx;
|
||||
|
||||
flipShort((int16*)(ptrData + temp + 2));
|
||||
flipShort
|
||||
(
|
||||
(int16
|
||||
*)
|
||||
(ptrData
|
||||
+
|
||||
temp
|
||||
+
|
||||
2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -262,46 +280,60 @@ int updateScriptImport(int ovlIdx)
|
|||
|
||||
} while (++param < 2);
|
||||
|
||||
if(ovlData->importDataPtr && ovlData->importNamePtr && numImport)
|
||||
{
|
||||
if (ovlData->importDataPtr && ovlData->importNamePtr && numImport) {
|
||||
int numImport2 = numImport;
|
||||
int i;
|
||||
|
||||
for(i=0;i<numImport2;i++)
|
||||
{
|
||||
for (i = 0; i < numImport2; i++) {
|
||||
int out1;
|
||||
int foundExportIdx;
|
||||
exportEntryStruct *pFoundExport;
|
||||
int linkType;
|
||||
int linkEntryIdx;
|
||||
|
||||
strcpyuint8(buffer,ovlData->importNamePtr + ovlData->importDataPtr[i].nameOffset);
|
||||
strcpyuint8(buffer,
|
||||
ovlData->importNamePtr +
|
||||
ovlData->importDataPtr[i].nameOffset);
|
||||
|
||||
pFoundExport = parseExport(&out1,&foundExportIdx,buffer);
|
||||
pFoundExport =
|
||||
parseExport(&out1, &foundExportIdx, buffer);
|
||||
|
||||
linkType = ovlData->importDataPtr[i].linkType;
|
||||
linkEntryIdx = ovlData->importDataPtr[i].linkIdx;
|
||||
|
||||
if(pFoundExport && foundExportIdx)
|
||||
{
|
||||
switch(linkType)
|
||||
{
|
||||
if (pFoundExport && foundExportIdx) {
|
||||
switch (linkType) {
|
||||
case 0: // var
|
||||
{
|
||||
ovlData->linkDataPtr[linkEntryIdx].varIdx = foundExportIdx;
|
||||
ovlData->linkDataPtr[linkEntryIdx].varNameOffset = pFoundExport->offsetToName;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
varIdx = foundExportIdx;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
varNameOffset =
|
||||
pFoundExport->offsetToName;
|
||||
break;
|
||||
}
|
||||
case 1: // string
|
||||
{
|
||||
ovlData->linkDataPtr[linkEntryIdx].stringIdx = foundExportIdx;
|
||||
ovlData->linkDataPtr[linkEntryIdx].stringNameOffset = pFoundExport->offsetToName;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
stringIdx = foundExportIdx;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
stringNameOffset =
|
||||
pFoundExport->offsetToName;
|
||||
break;
|
||||
}
|
||||
case 2: // proc
|
||||
{
|
||||
ovlData->linkDataPtr[linkEntryIdx].procIdx = foundExportIdx;
|
||||
ovlData->linkDataPtr[linkEntryIdx].procNameOffset = pFoundExport->offsetToName;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
procIdx = foundExportIdx;
|
||||
ovlData->
|
||||
linkDataPtr[linkEntryIdx].
|
||||
procNameOffset =
|
||||
pFoundExport->offsetToName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -313,14 +345,11 @@ int updateScriptImport(int ovlIdx)
|
|||
}
|
||||
|
||||
// check that the newly loaded isn't used by the already loaded overlays
|
||||
void updateAllScriptsImports(void)
|
||||
{
|
||||
void updateAllScriptsImports(void) {
|
||||
int i;
|
||||
|
||||
for(i=0;i<90;i++)
|
||||
{
|
||||
if(overlayTable[i].ovlData && overlayTable[i].alreadyLoaded)
|
||||
{
|
||||
for (i = 0; i < 90; i++) {
|
||||
if (overlayTable[i].ovlData && overlayTable[i].alreadyLoaded) {
|
||||
updateScriptImport(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _LINKER_H_
|
||||
#define _LINKER_H_
|
||||
#ifndef CRUISE_LINKER_H
|
||||
#define CRUISE_LINKER_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
void updateAllScriptsImports(void);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _MAINDRAW_H_
|
||||
#define _MAINDRAW_H_
|
||||
#ifndef CRUISE_MAINDRAW_H
|
||||
#define CRUISE_MAINDRAW_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -37,12 +37,14 @@ 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 getPolyData(int fileIndex, int X, int Y, int *newScale, int *newY, int *newX, char **newDataPtr, int scale, char* dataPtr);
|
||||
void mainDrawSub4(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 getPolyData(int fileIndex, int X, int Y, int *newScale, int *newY,
|
||||
int *newX, char **newDataPtr, int scale, char *dataPtr);
|
||||
void mainDrawSub4(int objX1, int var_6, cellStruct * currentObjPtr,
|
||||
char *data1, int objY2, int objX2, char *output, char *data2);
|
||||
char *drawPolyMode2(char *si, int cx);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ namespace Cruise {
|
|||
|
||||
menuStruct *menuTable[8];
|
||||
|
||||
menuStruct* createMenu(int X, int Y, const char* menuName)
|
||||
{
|
||||
menuStruct *createMenu(int X, int Y, const char *menuName) {
|
||||
menuStruct *entry;
|
||||
|
||||
entry = (menuStruct *) malloc(sizeof(menuStruct));
|
||||
|
@ -46,52 +45,55 @@ menuStruct* createMenu(int X, int Y, const char* menuName)
|
|||
}
|
||||
|
||||
// TODO: rewrite to remove the goto
|
||||
void addSelectableMenuEntry(int param0, int param1, menuStruct* pMenu, int param2, int color, const char* menuText)
|
||||
{
|
||||
void addSelectableMenuEntry(int param0, int param1, menuStruct *pMenu,
|
||||
int param2, int color, const char *menuText) {
|
||||
menuElementStruct *di;
|
||||
menuElementStruct *var_6;
|
||||
menuElementStruct *pNewElement;
|
||||
menuElementSubStruct *pSubStruct;
|
||||
menuElementSubStruct *pSubStructCurrent;
|
||||
|
||||
if(pMenu->numElements <= 48)
|
||||
{
|
||||
if (pMenu->numElements <= 48) {
|
||||
var_6 = pMenu->ptrNextElement;
|
||||
|
||||
if(var_6)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (var_6) {
|
||||
do {
|
||||
di = var_6;
|
||||
if(param2)
|
||||
{
|
||||
if(!strcmp(var_6->string, menuText))
|
||||
{
|
||||
if (param2) {
|
||||
if (!strcmp(var_6->string, menuText)) {
|
||||
pNewElement = var_6;
|
||||
pSubStruct = (menuElementSubStruct*)allocAndZero(sizeof(menuElementSubStruct));
|
||||
pSubStruct =
|
||||
(menuElementSubStruct *)
|
||||
allocAndZero(sizeof
|
||||
(menuElementSubStruct));
|
||||
ASSERT(pSubStruct);
|
||||
|
||||
pSubStruct->pNext = NULL;
|
||||
pSubStruct->var2 = param0;
|
||||
pSubStruct->var4 = param1;
|
||||
|
||||
pSubStructCurrent = pNewElement->ptrSub;
|
||||
pSubStructCurrent =
|
||||
pNewElement->ptrSub;
|
||||
|
||||
if(!pSubStructCurrent)
|
||||
{
|
||||
pNewElement->ptrSub = pSubStruct;
|
||||
if (!pSubStructCurrent) {
|
||||
pNewElement->ptrSub =
|
||||
pSubStruct;
|
||||
return;
|
||||
}
|
||||
|
||||
if(pSubStructCurrent->pNext)
|
||||
{
|
||||
do
|
||||
{
|
||||
pSubStructCurrent = pSubStructCurrent->pNext;
|
||||
}while(pSubStructCurrent->pNext);
|
||||
if (pSubStructCurrent->pNext) {
|
||||
do {
|
||||
pSubStructCurrent
|
||||
=
|
||||
pSubStructCurrent->
|
||||
pNext;
|
||||
} while
|
||||
(pSubStructCurrent->
|
||||
pNext);
|
||||
}
|
||||
|
||||
pSubStructCurrent->pNext = pSubStruct;
|
||||
pSubStructCurrent->pNext =
|
||||
pSubStruct;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +104,13 @@ void addSelectableMenuEntry(int param0, int param1, menuStruct* pMenu, int param
|
|||
var_6 = di;
|
||||
}
|
||||
|
||||
pNewElement = (menuElementStruct*)allocAndZero(sizeof(menuElementStruct));
|
||||
pNewElement =
|
||||
(menuElementStruct *)
|
||||
allocAndZero(sizeof(menuElementStruct));
|
||||
ASSERT(pNewElement);
|
||||
pSubStruct = (menuElementSubStruct*)allocAndZero(sizeof(menuElementSubStruct));
|
||||
pSubStruct =
|
||||
(menuElementSubStruct *)
|
||||
allocAndZero(sizeof(menuElementSubStruct));
|
||||
ASSERT(pSubStruct);
|
||||
|
||||
pNewElement->string = menuText;
|
||||
|
@ -113,12 +119,9 @@ void addSelectableMenuEntry(int param0, int param1, menuStruct* pMenu, int param
|
|||
pNewElement->color = color;
|
||||
pNewElement->gfx = renderText(160, (uint8 *) menuText);
|
||||
|
||||
if(var_6 == NULL)
|
||||
{
|
||||
if (var_6 == NULL) {
|
||||
pMenu->ptrNextElement = pNewElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var_6->next = pNewElement;
|
||||
}
|
||||
|
||||
|
@ -132,28 +135,28 @@ void addSelectableMenuEntry(int param0, int param1, menuStruct* pMenu, int param
|
|||
}
|
||||
}
|
||||
|
||||
void updateMenuMouse(int mouseX, int mouseY, menuStruct* pMenu)
|
||||
{
|
||||
if(pMenu)
|
||||
{
|
||||
if(pMenu->gfx)
|
||||
{
|
||||
void updateMenuMouse(int mouseX, int mouseY, menuStruct *pMenu) {
|
||||
if (pMenu) {
|
||||
if (pMenu->gfx) {
|
||||
int height = pMenu->gfx->height; // rustine
|
||||
int var_2 = 0;
|
||||
menuElementStruct* pCurrentEntry = pMenu->ptrNextElement;
|
||||
menuElementStruct *pCurrentEntry =
|
||||
pMenu->ptrNextElement;
|
||||
|
||||
while(pCurrentEntry)
|
||||
{
|
||||
while (pCurrentEntry) {
|
||||
pCurrentEntry->varC = 0;
|
||||
|
||||
if(var_2 == 0)
|
||||
{
|
||||
if((mouseX > pCurrentEntry->x) && ((pCurrentEntry->x + 160) >= mouseX))
|
||||
{
|
||||
if((mouseY > pCurrentEntry->y) && ((pCurrentEntry->y + height) >= mouseY))
|
||||
{
|
||||
if (var_2 == 0) {
|
||||
if ((mouseX > pCurrentEntry->x)
|
||||
&& ((pCurrentEntry->x + 160) >=
|
||||
mouseX)) {
|
||||
if ((mouseY > pCurrentEntry->y)
|
||||
&& ((pCurrentEntry->y +
|
||||
height) >=
|
||||
mouseY)) {
|
||||
var_2 = 1;
|
||||
pCurrentEntry->varC = 1;
|
||||
pCurrentEntry->varC =
|
||||
1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,8 +167,7 @@ void updateMenuMouse(int mouseX, int mouseY, menuStruct* pMenu)
|
|||
}
|
||||
}
|
||||
|
||||
int processMenu(menuStruct* pMenu)
|
||||
{
|
||||
int processMenu(menuStruct *pMenu) {
|
||||
int16 mouseX;
|
||||
int16 mouseY;
|
||||
int16 mouseButton;
|
||||
|
@ -179,21 +181,16 @@ int processMenu(menuStruct* pMenu)
|
|||
di = 0;
|
||||
si = 0;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY);
|
||||
|
||||
updateMenuMouse(mouseX, mouseY, pMenu);
|
||||
|
||||
if(mouseButton)
|
||||
{
|
||||
if(di)
|
||||
{
|
||||
if (mouseButton) {
|
||||
if (di) {
|
||||
si = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
di = 1;
|
||||
}
|
||||
|
||||
|
@ -211,15 +208,12 @@ int processMenu(menuStruct* pMenu)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int playerMenu(int menuX, int menuY)
|
||||
{
|
||||
int playerMenu(int menuX, int menuY) {
|
||||
int retourMenu;
|
||||
//int restartGame = 0;
|
||||
|
||||
if(entrerMenuJoueur && affichePasMenuJoueur)
|
||||
{
|
||||
if(var0)
|
||||
{
|
||||
if (entrerMenuJoueur && affichePasMenuJoueur) {
|
||||
if (var0) {
|
||||
systemStrings.param = 0;
|
||||
var24 = 0;
|
||||
var23 = 0;
|
||||
|
@ -256,14 +250,18 @@ int playerMenu(int menuX, int menuY)
|
|||
menuTable[0] = createMenu(menuX, menuY, "Menu Joueur");
|
||||
ASSERT(menuTable[0]);
|
||||
|
||||
addSelectableMenuEntry(0, 3, menuTable[0], 1, -1, "Lecteur de Sauvegarde");
|
||||
if(userEnabled)
|
||||
{
|
||||
addSelectableMenuEntry(0, 4, menuTable[0], 1, -1, "Sauvegarde");
|
||||
addSelectableMenuEntry(0, 3, menuTable[0], 1, -1,
|
||||
"Lecteur de Sauvegarde");
|
||||
if (userEnabled) {
|
||||
addSelectableMenuEntry(0, 4, menuTable[0], 1, -1,
|
||||
"Sauvegarde");
|
||||
}
|
||||
addSelectableMenuEntry(0, 5, menuTable[0], 1, -1, "Chargement");
|
||||
addSelectableMenuEntry(0, 6, menuTable[0], 1, -1, "Recommencer le jeu");
|
||||
addSelectableMenuEntry(0, 7, menuTable[0], 1, -1, "Chargement");
|
||||
addSelectableMenuEntry(0, 5, menuTable[0], 1, -1,
|
||||
"Chargement");
|
||||
addSelectableMenuEntry(0, 6, menuTable[0], 1, -1,
|
||||
"Recommencer le jeu");
|
||||
addSelectableMenuEntry(0, 7, menuTable[0], 1, -1,
|
||||
"Chargement");
|
||||
|
||||
retourMenu = processMenu(menuTable[0]);
|
||||
}
|
||||
|
@ -271,29 +269,24 @@ int playerMenu(int menuX, int menuY)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void freeGfx(gfxEntryStruct* pGfx)
|
||||
{
|
||||
if(pGfx->imagePtr)
|
||||
{
|
||||
void freeGfx(gfxEntryStruct *pGfx) {
|
||||
if (pGfx->imagePtr) {
|
||||
free(pGfx->imagePtr);
|
||||
}
|
||||
|
||||
free(pGfx);
|
||||
}
|
||||
|
||||
void freeMenu(menuStruct* pMenu)
|
||||
{
|
||||
void freeMenu(menuStruct *pMenu) {
|
||||
menuElementStruct *pElement = pMenu->ptrNextElement;
|
||||
|
||||
while(pElement)
|
||||
{
|
||||
while (pElement) {
|
||||
menuElementStruct *next;
|
||||
menuElementSubStruct *pSub = pElement->ptrSub;
|
||||
|
||||
next = pElement->next;
|
||||
|
||||
while(pSub)
|
||||
{
|
||||
while (pSub) {
|
||||
menuElementSubStruct *nextSub;
|
||||
|
||||
nextSub = pSub->pNext;
|
||||
|
@ -303,8 +296,7 @@ void freeMenu(menuStruct* pMenu)
|
|||
pSub = nextSub;
|
||||
}
|
||||
|
||||
if(pElement->gfx)
|
||||
{
|
||||
if (pElement->gfx) {
|
||||
freeGfx(pElement->gfx);
|
||||
}
|
||||
|
||||
|
@ -318,4 +310,3 @@ void freeMenu(menuStruct* pMenu)
|
|||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef CRUISE_MENU_H
|
||||
#define CRUISE_MENU_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct menuStruct
|
||||
{
|
||||
struct menuStruct {
|
||||
const char *stringPtr;
|
||||
gfxEntryStruct *gfx;
|
||||
int x;
|
||||
|
@ -39,11 +41,13 @@ typedef struct menuStruct menuStruct;
|
|||
extern menuStruct *menuTable[8];
|
||||
|
||||
menuStruct *createMenu(int X, int Y, const char *menuName);
|
||||
void addSelectableMenuEntry(int var0, int var1, menuStruct* pMenu, int var2, int color, const char* menuText);
|
||||
void addSelectableMenuEntry(int var0, int var1, menuStruct * pMenu, int var2,
|
||||
int color, const char *menuText);
|
||||
void updateMenuMouse(int mouseX, int mouseY, menuStruct * pMenu);
|
||||
int processMenu(menuStruct * pMenu);
|
||||
void freeMenu(menuStruct * pMenu);
|
||||
int playerMenu(int menuX, int menuY);
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace Cruise {
|
|||
|
||||
int16 main10;
|
||||
|
||||
void getMouseStatus(int16* pMouseVar, int16* pMouseX, int16* pMouseButton, int16* pMouseY)
|
||||
{
|
||||
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton,
|
||||
int16 *pMouseY) {
|
||||
// mouseStatusStruct localStatus;
|
||||
|
||||
// OSystem_GetMouseStatus(&localStatus);
|
||||
|
|
|
@ -22,16 +22,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _MOUSE_H_
|
||||
#define _MOUSE_H_
|
||||
#ifndef CRUISE_MOUSE_H
|
||||
#define CRUISE_MOUSE_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
extern int16 main10;
|
||||
|
||||
void getMouseStatus(int16* pMouseVar, int16* pMouseX, int16* pMouseButton, int16* pMouseY);
|
||||
void getMouseStatus(int16 * pMouseVar, int16 * pMouseX, int16 * pMouseButton,
|
||||
int16 * pMouseY);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace Cruise {
|
|||
|
||||
*/
|
||||
|
||||
objDataStruct* getObjectDataFromOverlay(int ovlIdx,int objIdx)
|
||||
{
|
||||
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx) {
|
||||
objDataStruct *var_6;
|
||||
|
||||
if (ovlIdx < 1 || objIdx < 0)
|
||||
|
@ -57,8 +56,8 @@ objDataStruct* getObjectDataFromOverlay(int ovlIdx,int objIdx)
|
|||
return (&var_6[objIdx]);
|
||||
}
|
||||
|
||||
int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery* returnParam)
|
||||
{
|
||||
int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx,
|
||||
objectParamsQuery *returnParam) {
|
||||
int16 size;
|
||||
int16 var_A;
|
||||
int16 var_14;
|
||||
|
@ -74,8 +73,7 @@ int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery*
|
|||
|
||||
ovlData = overlayTable[overlayIdx].ovlData;
|
||||
|
||||
switch(ptr->var1)
|
||||
{
|
||||
switch (ptr->var1) {
|
||||
case 0:
|
||||
{
|
||||
ptr2 = &ovlData->objData2SourceTable[ptr->var5];
|
||||
|
@ -93,8 +91,7 @@ int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery*
|
|||
var_A = var_14 = ptr2->var5;
|
||||
size = var_A + ptr->var5;
|
||||
|
||||
if(ptr->var5 + var_14<=ovlData->size8)
|
||||
{
|
||||
if (ptr->var5 + var_14 <= ovlData->size8) {
|
||||
var_A = ovlData->objData2SourceTable[ptr->var5 + var_14].var5;
|
||||
}
|
||||
break;
|
||||
|
@ -118,29 +115,24 @@ int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery*
|
|||
return 0;
|
||||
}
|
||||
|
||||
void setObjectPosition(int16 param1,int16 objIdx,int16 param3,int16 param4)
|
||||
{
|
||||
void setObjectPosition(int16 param1, int16 objIdx, int16 param3, int16 param4) {
|
||||
objDataStruct *ptr;
|
||||
objectParams *ptr2;
|
||||
|
||||
ptr = getObjectDataFromOverlay(param1, objIdx);
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
return;
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
//overlayTable[param1].ovlData
|
||||
|
||||
switch(ptr->var1)
|
||||
{
|
||||
switch (ptr->var1) {
|
||||
case 1:
|
||||
{
|
||||
ptr2 = &overlayTable[param1].ovlData->objData2WorkTable[ptr->var4];
|
||||
|
||||
switch(param3)
|
||||
{
|
||||
switch (param3) {
|
||||
case 0: // x
|
||||
{
|
||||
ptr2->X = param4;
|
||||
|
@ -186,8 +178,7 @@ void setObjectPosition(int16 param1,int16 objIdx,int16 param3,int16 param4)
|
|||
}
|
||||
}
|
||||
|
||||
void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
||||
{
|
||||
void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct *objPtr) {
|
||||
int16 var;
|
||||
cellStruct *var8_;
|
||||
cellStruct *var40;
|
||||
|
@ -206,27 +197,20 @@ void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
|||
var3E = NULL;
|
||||
var8_ = objPtr;
|
||||
|
||||
while(currentObjPtr2)
|
||||
{
|
||||
if((currentObjPtr2->overlay == param1) && (currentObjPtr2->idx == param2)) // found
|
||||
{
|
||||
while (currentObjPtr2) {
|
||||
if ((currentObjPtr2->overlay == param1) && (currentObjPtr2->idx == param2)) {// found
|
||||
currentObjPtrPrevious->next = currentObjPtr2->next;
|
||||
|
||||
if(currentObjPtr2->next)
|
||||
{
|
||||
currentObjPtr2->next->prev = currentObjPtr2->prev;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentObjPtr2->next) {
|
||||
currentObjPtr2->next->prev =
|
||||
currentObjPtr2->prev;
|
||||
} else {
|
||||
objPtr->prev = currentObjPtr2->prev;
|
||||
}
|
||||
|
||||
if(var40)
|
||||
{
|
||||
if (var40) {
|
||||
var40->prev = currentObjPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var3E = currentObjPtr2;
|
||||
}
|
||||
|
||||
|
@ -236,28 +220,22 @@ void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
|||
|
||||
var40 = currentObjPtr2;
|
||||
|
||||
if(match == NULL)
|
||||
{
|
||||
if (match == NULL) {
|
||||
match = currentObjPtr2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(currentObjPtr2->type == 5)
|
||||
{
|
||||
} else {
|
||||
if (currentObjPtr2->type == 5) {
|
||||
var2 = 32000;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int16 varC;
|
||||
|
||||
getSingleObjectParam(currentObjPtr2->overlay,currentObjPtr2->idx,2,&varC);
|
||||
getSingleObjectParam(currentObjPtr2->overlay,
|
||||
currentObjPtr2->idx, 2, &varC);
|
||||
|
||||
var2 = varC;
|
||||
}
|
||||
|
||||
if(var>var2)
|
||||
{
|
||||
if (var > var2) {
|
||||
var8_ = currentObjPtr2;
|
||||
}
|
||||
|
||||
|
@ -267,8 +245,7 @@ void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
|||
currentObjPtr2 = currentObjPtr2->next;
|
||||
}
|
||||
|
||||
if(match)
|
||||
{
|
||||
if (match) {
|
||||
cellStruct *temp;
|
||||
|
||||
temp = var8_->next;
|
||||
|
@ -276,13 +253,11 @@ void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
|||
var8_->next = var40;
|
||||
match->next = temp;
|
||||
|
||||
if(objPtr!=var8_)
|
||||
{
|
||||
if (objPtr != var8_) {
|
||||
var40->prev = var8_;
|
||||
}
|
||||
|
||||
if(!temp)
|
||||
{
|
||||
if (!temp) {
|
||||
temp = match;
|
||||
}
|
||||
|
||||
|
@ -290,8 +265,7 @@ void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
|
|||
}
|
||||
}
|
||||
|
||||
int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
|
||||
{
|
||||
int16 Op_InitializeStateSub(int ovlIdx, int objIdx, int param2) {
|
||||
objDataStruct *ptr;
|
||||
// uint16 param;
|
||||
ovlDataStruct *ovlData;
|
||||
|
@ -303,11 +277,11 @@ int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
|
|||
|
||||
ovlData = overlayTable[ovlIdx].ovlData;
|
||||
|
||||
switch(ptr->var1)
|
||||
{
|
||||
switch (ptr->var1) {
|
||||
case 0:
|
||||
{
|
||||
globalVars[overlayTable[ovlIdx].field_14 + ptr->var6] = param2;
|
||||
globalVars[overlayTable[ovlIdx].field_14 + ptr->var6] =
|
||||
param2;
|
||||
Op_InitializeStateSub1(ovlIdx, param2, &cellHead);
|
||||
break;
|
||||
}
|
||||
|
@ -316,13 +290,13 @@ int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
|
|||
objectParams *destEntry;
|
||||
objectParams *sourceEntry;
|
||||
|
||||
if(ptr->var5+param2 > ovlData->size8)
|
||||
{
|
||||
if (ptr->var5 + param2 > ovlData->size8) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
destEntry = &ovlData->objData2WorkTable[ptr->var4];
|
||||
sourceEntry = &ovlData->objData2SourceTable[ptr->var5 + param2];
|
||||
sourceEntry =
|
||||
&ovlData->objData2SourceTable[ptr->var5 + param2];
|
||||
|
||||
memcpy(destEntry, sourceEntry, sizeof(objectParams));
|
||||
|
||||
|
@ -333,7 +307,9 @@ int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported param = %d in Op_InitializeStateSub\n",ptr->var1);
|
||||
printf
|
||||
("Unsupported param = %d in Op_InitializeStateSub\n",
|
||||
ptr->var1);
|
||||
// exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +317,8 @@ int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* returnParam)
|
||||
{
|
||||
int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3,
|
||||
int16 *returnParam) {
|
||||
int var_A = 0;
|
||||
//char* ptr3 = NULL;
|
||||
objDataStruct *ptr;
|
||||
|
@ -356,8 +332,7 @@ int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* ret
|
|||
|
||||
ovlData = overlayTable[overlayIdx].ovlData;
|
||||
|
||||
switch(ptr->var1)
|
||||
{
|
||||
switch (ptr->var1) {
|
||||
case 0:
|
||||
case 3:
|
||||
{
|
||||
|
@ -375,13 +350,13 @@ int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* ret
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported case %d in getSingleObjectParam\n",ptr->var1);
|
||||
printf("Unsupported case %d in getSingleObjectParam\n",
|
||||
ptr->var1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
switch(param3)
|
||||
{
|
||||
switch (param3) {
|
||||
case 0:
|
||||
{
|
||||
*returnParam = ptr2->X;
|
||||
|
@ -414,7 +389,9 @@ int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* ret
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported case %d in getSingleObjectParam case 1\n",param3);
|
||||
printf
|
||||
("Unsupported case %d in getSingleObjectParam case 1\n",
|
||||
param3);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -422,5 +399,4 @@ int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* ret
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _OBJECT_H_
|
||||
#define _OBJECT_H_
|
||||
#ifndef CRUISE_OBJECT_H
|
||||
#define CRUISE_OBJECT_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct gfxEntryStruct
|
||||
{
|
||||
struct gfxEntryStruct {
|
||||
uint8 *imagePtr;
|
||||
int imageSize;
|
||||
int fontIndex;
|
||||
|
@ -40,8 +39,7 @@ typedef struct gfxEntryStruct gfxEntryStruct;
|
|||
|
||||
#define OBJ_SPRITE 4
|
||||
|
||||
struct objectParamsQuery
|
||||
{
|
||||
struct objectParamsQuery {
|
||||
int16 X;
|
||||
int16 Y;
|
||||
int16 baseFileIdx;
|
||||
|
@ -55,8 +53,10 @@ struct objectParamsQuery
|
|||
typedef struct objectParamsQuery objectParamsQuery;
|
||||
|
||||
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
|
||||
int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* returnParam);
|
||||
int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery* returnParam);
|
||||
int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3,
|
||||
int16 * returnParam);
|
||||
int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx,
|
||||
objectParamsQuery * returnParam);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
|
|
@ -29,12 +29,10 @@ namespace Cruise {
|
|||
overlayStruct overlayTable[90];
|
||||
int numOfLoadedOverlay;
|
||||
|
||||
void initOverlayTable(void)
|
||||
{
|
||||
void initOverlayTable(void) {
|
||||
int i;
|
||||
|
||||
for(i=0;i<90;i++)
|
||||
{
|
||||
for (i = 0; i < 90; i++) {
|
||||
overlayTable[i].overlayName[0] = 0;
|
||||
overlayTable[i].ovlData = NULL;
|
||||
overlayTable[i].alreadyLoaded = 0;
|
||||
|
@ -44,8 +42,7 @@ void initOverlayTable(void)
|
|||
numOfLoadedOverlay = 1;
|
||||
}
|
||||
|
||||
int loadOverlay(uint8* scriptName)
|
||||
{
|
||||
int loadOverlay(uint8 *scriptName) {
|
||||
int newNumberOfScript;
|
||||
bool scriptNotLoadedBefore;
|
||||
int scriptIdx;
|
||||
|
@ -64,8 +61,7 @@ int loadOverlay(uint8* scriptName)
|
|||
|
||||
scriptIdx = findOverlayByName((char *)scriptName);
|
||||
|
||||
if(scriptIdx == -4)
|
||||
{
|
||||
if (scriptIdx == -4) {
|
||||
scriptIdx = numOfLoadedOverlay;
|
||||
|
||||
newNumberOfScript++;
|
||||
|
@ -73,12 +69,12 @@ int loadOverlay(uint8* scriptName)
|
|||
scriptNotLoadedBefore = true;
|
||||
}
|
||||
|
||||
if(overlayTable[scriptIdx].alreadyLoaded)
|
||||
{
|
||||
if (overlayTable[scriptIdx].alreadyLoaded) {
|
||||
return (scriptIdx);
|
||||
}
|
||||
|
||||
overlayTable[scriptIdx].ovlData = (ovlDataStruct*) mallocAndZero(sizeof(ovlDataStruct));
|
||||
overlayTable[scriptIdx].ovlData =
|
||||
(ovlDataStruct *) mallocAndZero(sizeof(ovlDataStruct));
|
||||
|
||||
if (!overlayTable[scriptIdx].ovlData)
|
||||
return (-2);
|
||||
|
@ -99,8 +95,7 @@ int loadOverlay(uint8* scriptName)
|
|||
|
||||
fileIdx = findFileInDisks(fileName);
|
||||
|
||||
if(fileIdx<0)
|
||||
{
|
||||
if (fileIdx < 0) {
|
||||
printf("Unable to load overlay %s !\n", scriptName);
|
||||
//releaseScript(scriptName);
|
||||
return (-18);
|
||||
|
@ -111,30 +106,33 @@ int loadOverlay(uint8* scriptName)
|
|||
// TODO: here, can unpack in gfx module buffer
|
||||
unpackedBuffer = (char *)mallocAndZero(unpackedSize);
|
||||
|
||||
if(!unpackedBuffer)
|
||||
{
|
||||
if (!unpackedBuffer) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
if(volumePtrToFileDescriptor[fileIdx].size +2 != unpackedSize)
|
||||
{
|
||||
if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) {
|
||||
char *tempBuffer;
|
||||
uint16 realUnpackedSize;
|
||||
char* pakedBuffer = (char*) mallocAndZero(volumePtrToFileDescriptor[fileIdx].size +2);
|
||||
char *pakedBuffer =
|
||||
(char *)mallocAndZero(volumePtrToFileDescriptor[fileIdx].
|
||||
size + 2);
|
||||
|
||||
loadPakedFileToMem(fileIdx, (uint8 *) pakedBuffer);
|
||||
|
||||
realUnpackedSize = *(int16*)(pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-2);
|
||||
realUnpackedSize =
|
||||
*(int16 *) (pakedBuffer +
|
||||
volumePtrToFileDescriptor[fileIdx].size - 2);
|
||||
flipShort(&realUnpackedSize);
|
||||
|
||||
tempBuffer = (char *)mallocAndZero(realUnpackedSize);
|
||||
|
||||
decomp((uint8*)pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-4,(uint8*)unpackedBuffer+realUnpackedSize,realUnpackedSize);
|
||||
decomp((uint8 *) pakedBuffer +
|
||||
volumePtrToFileDescriptor[fileIdx].size - 4,
|
||||
(uint8 *) unpackedBuffer + realUnpackedSize,
|
||||
realUnpackedSize);
|
||||
|
||||
free(pakedBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
loadPakedFileToMem(fileIdx, (uint8 *) unpackedBuffer);
|
||||
}
|
||||
|
||||
|
@ -180,131 +178,138 @@ int loadOverlay(uint8* scriptName)
|
|||
|
||||
scriptPtr += 92;
|
||||
|
||||
if(ovlData->numExport) // export data
|
||||
{
|
||||
if (ovlData->numExport) { // export data
|
||||
int i;
|
||||
ovlData->exportDataPtr = (exportEntryStruct*)mallocAndZero(ovlData->numExport*sizeof(exportEntryStruct));
|
||||
ovlData->exportDataPtr =
|
||||
(exportEntryStruct *) mallocAndZero(ovlData->numExport *
|
||||
sizeof(exportEntryStruct));
|
||||
|
||||
if(!ovlData->exportDataPtr)
|
||||
{
|
||||
if (!ovlData->exportDataPtr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
for(i=0;i<ovlData->numExport;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numExport; i++) {
|
||||
ovlData->exportDataPtr[i].var0 = readB16(scriptPtr);
|
||||
ovlData->exportDataPtr[i].var2 = readB16(scriptPtr+2);
|
||||
ovlData->exportDataPtr[i].var4 = readB16(scriptPtr+4);
|
||||
ovlData->exportDataPtr[i].var2 =
|
||||
readB16(scriptPtr + 2);
|
||||
ovlData->exportDataPtr[i].var4 =
|
||||
readB16(scriptPtr + 4);
|
||||
ovlData->exportDataPtr[i].idx = readB16(scriptPtr + 6);
|
||||
ovlData->exportDataPtr[i].offsetToName = readB16(scriptPtr+8);
|
||||
ovlData->exportDataPtr[i].offsetToName =
|
||||
readB16(scriptPtr + 8);
|
||||
|
||||
scriptPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
if(ovlData->exportNamesSize) // export names
|
||||
{
|
||||
ovlData->exportNamesPtr = (uint8*)mallocAndZero(ovlData->exportNamesSize);
|
||||
if (ovlData->exportNamesSize) { // export names
|
||||
ovlData->exportNamesPtr =
|
||||
(uint8 *) mallocAndZero(ovlData->exportNamesSize);
|
||||
|
||||
if(!ovlData->exportNamesPtr)
|
||||
{
|
||||
if (!ovlData->exportNamesPtr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->exportNamesPtr, scriptPtr, ovlData->exportNamesSize);
|
||||
memcpy(ovlData->exportNamesPtr, scriptPtr,
|
||||
ovlData->exportNamesSize);
|
||||
scriptPtr += ovlData->exportNamesSize;
|
||||
}
|
||||
|
||||
if(ovlData->numImport) // import data
|
||||
{
|
||||
if (ovlData->numImport) { // import data
|
||||
int i;
|
||||
|
||||
ovlData->importDataPtr = (importDataStruct*)mallocAndZero(ovlData->numImport * sizeof(importDataStruct));
|
||||
ovlData->importDataPtr =
|
||||
(importDataStruct *) mallocAndZero(ovlData->numImport *
|
||||
sizeof(importDataStruct));
|
||||
|
||||
if(!ovlData->importDataPtr)
|
||||
{
|
||||
if (!ovlData->importDataPtr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
for(i=0;i<ovlData->numImport;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numImport; i++) {
|
||||
ovlData->importDataPtr[i].var0 = readB16(scriptPtr);
|
||||
ovlData->importDataPtr[i].var1 = readB16(scriptPtr+2);
|
||||
ovlData->importDataPtr[i].linkType = readB16(scriptPtr+4);
|
||||
ovlData->importDataPtr[i].linkIdx = readB16(scriptPtr+6);
|
||||
ovlData->importDataPtr[i].nameOffset = readB16(scriptPtr+8);
|
||||
ovlData->importDataPtr[i].var1 =
|
||||
readB16(scriptPtr + 2);
|
||||
ovlData->importDataPtr[i].linkType =
|
||||
readB16(scriptPtr + 4);
|
||||
ovlData->importDataPtr[i].linkIdx =
|
||||
readB16(scriptPtr + 6);
|
||||
ovlData->importDataPtr[i].nameOffset =
|
||||
readB16(scriptPtr + 8);
|
||||
|
||||
scriptPtr += 10;
|
||||
}
|
||||
}
|
||||
|
||||
if(ovlData->nameExportSize) // import name
|
||||
{
|
||||
ovlData->importNamePtr = (uint8*)mallocAndZero(ovlData->nameExportSize);
|
||||
if (ovlData->nameExportSize) { // import name
|
||||
ovlData->importNamePtr =
|
||||
(uint8 *) mallocAndZero(ovlData->nameExportSize);
|
||||
|
||||
if(!ovlData->importNamePtr)
|
||||
{
|
||||
if (!ovlData->importNamePtr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->importNamePtr, scriptPtr, ovlData->nameExportSize);
|
||||
memcpy(ovlData->importNamePtr, scriptPtr,
|
||||
ovlData->nameExportSize);
|
||||
scriptPtr += ovlData->nameExportSize;
|
||||
}
|
||||
|
||||
if(ovlData->numLinkData) // link data
|
||||
{
|
||||
if (ovlData->numLinkData) { // link data
|
||||
ASSERT(sizeof(linkDataStruct) == 0x22);
|
||||
|
||||
ovlData->linkDataPtr = (linkDataStruct*)mallocAndZero(ovlData->numLinkData*sizeof(linkDataStruct));
|
||||
ovlData->linkDataPtr =
|
||||
(linkDataStruct *) mallocAndZero(ovlData->numLinkData *
|
||||
sizeof(linkDataStruct));
|
||||
|
||||
if(!ovlData->linkDataPtr)
|
||||
{
|
||||
if (!ovlData->linkDataPtr) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->linkDataPtr, scriptPtr, ovlData->numLinkData*sizeof(linkDataStruct));
|
||||
memcpy(ovlData->linkDataPtr, scriptPtr,
|
||||
ovlData->numLinkData * sizeof(linkDataStruct));
|
||||
scriptPtr += ovlData->numLinkData * sizeof(linkDataStruct);
|
||||
flipGen(ovlData->linkDataPtr,ovlData->numLinkData*sizeof(linkDataStruct));
|
||||
flipGen(ovlData->linkDataPtr,
|
||||
ovlData->numLinkData * sizeof(linkDataStruct));
|
||||
}
|
||||
|
||||
if(ovlData->numScripts1) // script
|
||||
{
|
||||
if (ovlData->numScripts1) { // script
|
||||
ovlData3Struct *tempPtr;
|
||||
int i;
|
||||
|
||||
ovlData->data3Table = (ovlData3Struct*)mallocAndZero(ovlData->numScripts1 * sizeof(ovlData3Struct));
|
||||
ovlData->data3Table =
|
||||
(ovlData3Struct *) mallocAndZero(ovlData->numScripts1 *
|
||||
sizeof(ovlData3Struct));
|
||||
|
||||
if(!ovlData->data3Table)
|
||||
{
|
||||
if (!ovlData->data3Table) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
if(freeIsNeeded) {
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->data3Table, scriptPtr, ovlData->numScripts1 * sizeof(ovlData3Struct));
|
||||
memcpy(ovlData->data3Table, scriptPtr,
|
||||
ovlData->numScripts1 * sizeof(ovlData3Struct));
|
||||
scriptPtr += ovlData->numScripts1 * 0x1C;
|
||||
|
||||
flipGen(ovlData->data3Table,ovlData->numScripts1 * sizeof(ovlData3Struct));
|
||||
flipGen(ovlData->data3Table,
|
||||
ovlData->numScripts1 * sizeof(ovlData3Struct));
|
||||
|
||||
tempPtr = ovlData->data3Table;
|
||||
|
||||
for(i=0;i<ovlData->numScripts1;i++)
|
||||
{
|
||||
uint8* ptr = tempPtr->dataPtr = (uint8*) mallocAndZero(tempPtr->sizeOfData);
|
||||
for (i = 0; i < ovlData->numScripts1; i++) {
|
||||
uint8 *ptr = tempPtr->dataPtr =
|
||||
(uint8 *) mallocAndZero(tempPtr->sizeOfData);
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
*
|
||||
* if(freeIsNeeded)
|
||||
* {
|
||||
* freePtr(unpackedBuffer);
|
||||
* } */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
@ -312,29 +317,28 @@ int loadOverlay(uint8* scriptName)
|
|||
memcpy(ptr, scriptPtr, tempPtr->sizeOfData);
|
||||
scriptPtr += tempPtr->sizeOfData;
|
||||
|
||||
if(tempPtr->offsetToImportData)
|
||||
{
|
||||
flipGen(ptr+tempPtr->offsetToImportData,tempPtr->numImport*10);
|
||||
if (tempPtr->offsetToImportData) {
|
||||
flipGen(ptr + tempPtr->offsetToImportData,
|
||||
tempPtr->numImport * 10);
|
||||
}
|
||||
|
||||
if(tempPtr->offsetToSubData2)
|
||||
{
|
||||
flipGen(ptr+tempPtr->offsetToImportData,tempPtr->subData2Size*10);
|
||||
if (tempPtr->offsetToSubData2) {
|
||||
flipGen(ptr + tempPtr->offsetToImportData,
|
||||
tempPtr->subData2Size * 10);
|
||||
}
|
||||
|
||||
tempPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
if(ovlData->numScripts2)
|
||||
{
|
||||
if (ovlData->numScripts2) {
|
||||
ovlData3Struct *tempPtr;
|
||||
int i;
|
||||
|
||||
ovlData->ptr1 = (uint8*)mallocAndZero(ovlData->numScripts2*0x1C);
|
||||
ovlData->ptr1 =
|
||||
(uint8 *) mallocAndZero(ovlData->numScripts2 * 0x1C);
|
||||
|
||||
if(!ovlData->ptr1)
|
||||
{
|
||||
if (!ovlData->ptr1) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
|
@ -344,18 +348,17 @@ int loadOverlay(uint8* scriptName)
|
|||
|
||||
tempPtr = (ovlData3Struct *) ovlData->ptr1;
|
||||
|
||||
for(i=0;i<ovlData->numScripts2;i++)
|
||||
{
|
||||
uint8* ptr = tempPtr->dataPtr = (uint8*) mallocAndZero(tempPtr->sizeOfData);
|
||||
for (i = 0; i < ovlData->numScripts2; i++) {
|
||||
uint8 *ptr = tempPtr->dataPtr =
|
||||
(uint8 *) mallocAndZero(tempPtr->sizeOfData);
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
*
|
||||
* if(freeIsNeeded)
|
||||
* {
|
||||
* freePtr(unpackedBuffer);
|
||||
* } */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
@ -363,26 +366,24 @@ int loadOverlay(uint8* scriptName)
|
|||
memcpy(ptr, scriptPtr, tempPtr->sizeOfData);
|
||||
scriptPtr += tempPtr->sizeOfData;
|
||||
|
||||
if(tempPtr->offsetToImportData)
|
||||
{
|
||||
flipGen(ptr+tempPtr->offsetToImportData,tempPtr->numImport*10);
|
||||
if (tempPtr->offsetToImportData) {
|
||||
flipGen(ptr + tempPtr->offsetToImportData,
|
||||
tempPtr->numImport * 10);
|
||||
}
|
||||
|
||||
if(tempPtr->offsetToSubData2)
|
||||
{
|
||||
flipGen(ptr+tempPtr->offsetToImportData,tempPtr->subData2Size*10);
|
||||
if (tempPtr->offsetToSubData2) {
|
||||
flipGen(ptr + tempPtr->offsetToImportData,
|
||||
tempPtr->subData2Size * 10);
|
||||
}
|
||||
|
||||
tempPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
if(ovlData->size12)
|
||||
{
|
||||
if (ovlData->size12) {
|
||||
ovlData->ptr8 = (uint8 *) mallocAndZero(ovlData->size12);
|
||||
|
||||
if(!ovlData->ptr8)
|
||||
{
|
||||
if (!ovlData->ptr8) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
|
@ -397,13 +398,13 @@ int loadOverlay(uint8* scriptName)
|
|||
scriptPtr += ovlData->size12;
|
||||
}
|
||||
|
||||
if(ovlData->numObjData)
|
||||
{
|
||||
if (ovlData->numObjData) {
|
||||
int i;
|
||||
ovlData->objDataTable = (objDataStruct*)mallocAndZero(ovlData->numObjData*sizeof(objDataStruct));
|
||||
ovlData->objDataTable =
|
||||
(objDataStruct *) mallocAndZero(ovlData->numObjData *
|
||||
sizeof(objDataStruct));
|
||||
|
||||
if(!ovlData->objDataTable)
|
||||
{
|
||||
if (!ovlData->objDataTable) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
|
@ -414,8 +415,7 @@ int loadOverlay(uint8* scriptName)
|
|||
return (-2);
|
||||
}
|
||||
|
||||
for(i=0;i<ovlData->numObjData;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numObjData; i++) {
|
||||
ovlData->objDataTable[i].var0 = *(int16 *) scriptPtr;
|
||||
scriptPtr += 2;
|
||||
flipShort(&ovlData->objDataTable[i].var0);
|
||||
|
@ -445,8 +445,7 @@ int loadOverlay(uint8* scriptName)
|
|||
flipShort(&ovlData->objDataTable[i].var6);
|
||||
}
|
||||
|
||||
if(scriptNotLoadedBefore)
|
||||
{
|
||||
if (scriptNotLoadedBefore) {
|
||||
//int var1;
|
||||
//int var2;
|
||||
|
||||
|
@ -459,13 +458,14 @@ int loadOverlay(uint8* scriptName)
|
|||
}
|
||||
}
|
||||
|
||||
if(ovlData->size9)
|
||||
{
|
||||
ovlData->objData2WorkTable = (objectParams*)mallocAndZero(ovlData->size9 * sizeof(objectParams));
|
||||
memset(ovlData->objData2WorkTable, 0, ovlData->size9 * sizeof(objectParams));
|
||||
if (ovlData->size9) {
|
||||
ovlData->objData2WorkTable =
|
||||
(objectParams *) mallocAndZero(ovlData->size9 *
|
||||
sizeof(objectParams));
|
||||
memset(ovlData->objData2WorkTable, 0,
|
||||
ovlData->size9 * sizeof(objectParams));
|
||||
|
||||
if(!ovlData->objData2WorkTable)
|
||||
{
|
||||
if (!ovlData->objData2WorkTable) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
|
@ -477,12 +477,12 @@ int loadOverlay(uint8* scriptName)
|
|||
}
|
||||
}
|
||||
|
||||
if(ovlData->size8)
|
||||
{
|
||||
ovlData->objData2SourceTable = (objectParams*)mallocAndZero(ovlData->size8 * sizeof(objectParams));
|
||||
if (ovlData->size8) {
|
||||
ovlData->objData2SourceTable =
|
||||
(objectParams *) mallocAndZero(ovlData->size8 *
|
||||
sizeof(objectParams));
|
||||
|
||||
if(!ovlData->objData2SourceTable)
|
||||
{
|
||||
if (!ovlData->objData2SourceTable) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
|
@ -498,14 +498,14 @@ int loadOverlay(uint8* scriptName)
|
|||
flipGen(ovlData->objData2SourceTable, ovlData->size8 * 12);
|
||||
}
|
||||
|
||||
if(ovlData->numStrings)
|
||||
{
|
||||
if (ovlData->numStrings) {
|
||||
int i;
|
||||
|
||||
ovlData->stringTable = (stringEntryStruct*)mallocAndZero(ovlData->numStrings*sizeof(stringEntryStruct));
|
||||
ovlData->stringTable =
|
||||
(stringEntryStruct *) mallocAndZero(ovlData->numStrings *
|
||||
sizeof(stringEntryStruct));
|
||||
|
||||
for(i=0;i<ovlData->numStrings;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numStrings; i++) {
|
||||
ovlData->stringTable[i].idx = *(int16 *) scriptPtr;
|
||||
flipShort(&ovlData->stringTable[i].idx);
|
||||
scriptPtr += 2;
|
||||
|
@ -517,20 +517,20 @@ int loadOverlay(uint8* scriptName)
|
|||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
|
||||
if(ovlData->sizeOfData4)
|
||||
{
|
||||
ovlData->data4Ptr = (uint8*)mallocAndZero(ovlData->sizeOfData4);
|
||||
if (ovlData->sizeOfData4) {
|
||||
ovlData->data4Ptr =
|
||||
(uint8 *) mallocAndZero(ovlData->sizeOfData4);
|
||||
memset(ovlData->data4Ptr, 0, ovlData->sizeOfData4);
|
||||
|
||||
if(!ovlData->data4Ptr)
|
||||
{
|
||||
if (!ovlData->data4Ptr) {
|
||||
//releaseScript(scriptIdx,scriptName);
|
||||
return (-2);
|
||||
}
|
||||
}
|
||||
|
||||
if(ovlData->specialString1Length /*|| ovlData->specialString2Length*/ || ovlData->stringTable)
|
||||
{
|
||||
if (ovlData->
|
||||
specialString1Length /*|| ovlData->specialString2Length */
|
||||
|| ovlData->stringTable) {
|
||||
int i;
|
||||
//int unpackedSize;
|
||||
//int fileIdx;
|
||||
|
@ -543,8 +543,7 @@ int loadOverlay(uint8* scriptName)
|
|||
|
||||
fileIdx = findFileInDisks(fileName);
|
||||
|
||||
if(fileIdx<0)
|
||||
{
|
||||
if (fileIdx < 0) {
|
||||
//releaseScript(scriptName);
|
||||
return (-18);
|
||||
}
|
||||
|
@ -554,27 +553,32 @@ int loadOverlay(uint8* scriptName)
|
|||
// TODO: here, can unpack in gfx module buffer
|
||||
unpackedBuffer = (char *)mallocAndZero(unpackedSize);
|
||||
|
||||
if(!unpackedBuffer)
|
||||
{
|
||||
if (!unpackedBuffer) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
if(volumePtrToFileDescriptor[fileIdx].size +2 != unpackedSize)
|
||||
{
|
||||
if (volumePtrToFileDescriptor[fileIdx].size + 2 !=
|
||||
unpackedSize) {
|
||||
short int realUnpackedSize;
|
||||
char* pakedBuffer = (char*) mallocAndZero(volumePtrToFileDescriptor[fileIdx].size +2);
|
||||
char *pakedBuffer =
|
||||
(char *)
|
||||
mallocAndZero(volumePtrToFileDescriptor[fileIdx].
|
||||
size + 2);
|
||||
|
||||
loadPakedFileToMem(fileIdx, (uint8 *) pakedBuffer);
|
||||
|
||||
realUnpackedSize = *(int16*)(pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-2);
|
||||
realUnpackedSize =
|
||||
*(int16 *) (pakedBuffer +
|
||||
volumePtrToFileDescriptor[fileIdx].size - 2);
|
||||
flipShort(&realUnpackedSize);
|
||||
|
||||
decomp((uint8*)pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-4,(uint8*)unpackedBuffer+realUnpackedSize,realUnpackedSize);
|
||||
decomp((uint8 *) pakedBuffer +
|
||||
volumePtrToFileDescriptor[fileIdx].size - 4,
|
||||
(uint8 *) unpackedBuffer + realUnpackedSize,
|
||||
realUnpackedSize);
|
||||
|
||||
free(pakedBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
loadPakedFileToMem(fileIdx, (uint8 *) unpackedBuffer);
|
||||
}
|
||||
|
||||
|
@ -584,23 +588,24 @@ int loadOverlay(uint8* scriptName)
|
|||
scriptPtr += 2;
|
||||
flipShort(&ovlData->specialString1Length); // recheck if needed
|
||||
|
||||
if(ovlData->specialString1Length)
|
||||
{
|
||||
ovlData->specialString1 = (uint8*)mallocAndZero(ovlData->specialString1Length);
|
||||
if (ovlData->specialString1Length) {
|
||||
ovlData->specialString1 =
|
||||
(uint8 *) mallocAndZero(ovlData->
|
||||
specialString1Length);
|
||||
|
||||
if(!ovlData->specialString1)
|
||||
{
|
||||
if (!ovlData->specialString1) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
*
|
||||
* if(freeIsNeeded)
|
||||
* {
|
||||
* freePtr(unpackedBuffer);
|
||||
* } */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->specialString1, scriptPtr, ovlData->specialString1Length);
|
||||
memcpy(ovlData->specialString1, scriptPtr,
|
||||
ovlData->specialString1Length);
|
||||
scriptPtr += ovlData->specialString1Length;
|
||||
}
|
||||
|
||||
|
@ -608,59 +613,58 @@ int loadOverlay(uint8* scriptName)
|
|||
scriptPtr += 2;
|
||||
flipShort(&ovlData->specialString2Length); // recheck if needed
|
||||
|
||||
if(ovlData->specialString2Length)
|
||||
{
|
||||
ovlData->specialString2 = (uint8*)mallocAndZero(ovlData->specialString2Length);
|
||||
if (ovlData->specialString2Length) {
|
||||
ovlData->specialString2 =
|
||||
(uint8 *) mallocAndZero(ovlData->
|
||||
specialString2Length);
|
||||
|
||||
if(!ovlData->specialString2)
|
||||
{
|
||||
if (!ovlData->specialString2) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
*
|
||||
* if(freeIsNeeded)
|
||||
* {
|
||||
* freePtr(unpackedBuffer);
|
||||
* } */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->specialString2, scriptPtr, ovlData->specialString2Length);
|
||||
memcpy(ovlData->specialString2, scriptPtr,
|
||||
ovlData->specialString2Length);
|
||||
scriptPtr += ovlData->specialString2Length;
|
||||
}
|
||||
|
||||
for(i=0;i<ovlData->numStrings;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numStrings; i++) {
|
||||
ovlData->stringTable[i].length = *(int16 *) scriptPtr;
|
||||
scriptPtr += 2;
|
||||
flipShort(&ovlData->stringTable[i].length);
|
||||
|
||||
if(ovlData->stringTable[i].length)
|
||||
{
|
||||
ovlData->stringTable[i].string = (char*)mallocAndZero(ovlData->stringTable[i].length);
|
||||
if (ovlData->stringTable[i].length) {
|
||||
ovlData->stringTable[i].string =
|
||||
(char *)mallocAndZero(ovlData->
|
||||
stringTable[i].length);
|
||||
|
||||
if(!ovlData->stringTable[i].string)
|
||||
{
|
||||
if (!ovlData->stringTable[i].string) {
|
||||
/* releaseScript(scriptIdx,scriptName);
|
||||
|
||||
if(freeIsNeeded)
|
||||
{
|
||||
freePtr(unpackedBuffer);
|
||||
} */
|
||||
*
|
||||
* if(freeIsNeeded)
|
||||
* {
|
||||
* freePtr(unpackedBuffer);
|
||||
* } */
|
||||
|
||||
return (-2);
|
||||
}
|
||||
|
||||
memcpy(ovlData->stringTable[i].string,scriptPtr,ovlData->stringTable[i].length);
|
||||
memcpy(ovlData->stringTable[i].string,
|
||||
scriptPtr, ovlData->stringTable[i].length);
|
||||
scriptPtr += ovlData->stringTable[i].length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DUMP_SCRIPT
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<ovlData->numScripts1;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numScripts1; i++) {
|
||||
dumpScript(scriptName, ovlData, i);
|
||||
}
|
||||
}
|
||||
|
@ -675,17 +679,18 @@ int loadOverlay(uint8* scriptName)
|
|||
fHandle = fopen(nameBundle, "w+");
|
||||
ASSERT(fHandle);
|
||||
|
||||
for(i=0;i<ovlData->numLinkData;i++)
|
||||
{
|
||||
for (i = 0; i < ovlData->numLinkData; i++) {
|
||||
linkDataStruct *var_34;
|
||||
var_34 = &ovlData->linkDataPtr[i];
|
||||
|
||||
if(ovlData->specialString2)
|
||||
{
|
||||
fprintf(fHandle,"----- object %02d -----\n", i);
|
||||
if(var_34->stringNameOffset != 0xFFFF)
|
||||
{
|
||||
fprintf(fHandle,"name: %s\n",getObjectName(var_34->stringNameOffset, ovlData->specialString2));
|
||||
if (ovlData->specialString2) {
|
||||
fprintf(fHandle, "----- object %02d -----\n",
|
||||
i);
|
||||
if (var_34->stringNameOffset != 0xFFFF) {
|
||||
fprintf(fHandle, "name: %s\n",
|
||||
getObjectName(var_34->
|
||||
stringNameOffset,
|
||||
ovlData->specialString2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -697,8 +702,7 @@ int loadOverlay(uint8* scriptName)
|
|||
return (scriptIdx);
|
||||
}
|
||||
|
||||
int releaseOverlay(const char* name)
|
||||
{
|
||||
int releaseOverlay(const char *name) {
|
||||
int overlayIdx;
|
||||
ovlDataStruct *ovlDataPtr;
|
||||
|
||||
|
@ -740,12 +744,10 @@ int releaseOverlay(const char* name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32 findOverlayByName2(uint8* name)
|
||||
{
|
||||
int32 findOverlayByName2(uint8 *name) {
|
||||
int i;
|
||||
|
||||
for(i=1;i<numOfLoadedOverlay;i++)
|
||||
{
|
||||
for (i = 1; i < numOfLoadedOverlay; i++) {
|
||||
if (!strcmpuint8(overlayTable[i].overlayName, name))
|
||||
return (i);
|
||||
}
|
||||
|
@ -753,14 +755,11 @@ int32 findOverlayByName2(uint8* name)
|
|||
return (-4);
|
||||
}
|
||||
|
||||
int findOverlayByName(const char* overlayName)
|
||||
{
|
||||
int findOverlayByName(const char *overlayName) {
|
||||
int i;
|
||||
|
||||
for(i=1;i<numOfLoadedOverlay;i++)
|
||||
{
|
||||
if(!strcmp(overlayTable[i].overlayName,overlayName))
|
||||
{
|
||||
for (i = 1; i < numOfLoadedOverlay; i++) {
|
||||
if (!strcmp(overlayTable[i].overlayName, overlayName)) {
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
|
@ -768,5 +767,4 @@ int findOverlayByName(const char* overlayName)
|
|||
return (-4);
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _OVERLAY_H_
|
||||
#define _OVERLAY_H_
|
||||
#ifndef CRUISE_OVERLAY_H
|
||||
#define CRUISE_OVERLAY_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct importScriptStruct
|
||||
{
|
||||
struct importScriptStruct {
|
||||
uint16 var0;
|
||||
uint16 var1;
|
||||
uint16 type;
|
||||
|
@ -38,8 +37,7 @@ struct importScriptStruct
|
|||
|
||||
typedef struct importScriptStruct importScriptStruct;
|
||||
|
||||
struct exportEntryStruct
|
||||
{
|
||||
struct exportEntryStruct {
|
||||
uint16 var0;
|
||||
uint16 var2;
|
||||
uint16 var4;
|
||||
|
@ -49,8 +47,7 @@ struct exportEntryStruct
|
|||
|
||||
typedef struct exportEntryStruct exportEntryStruct;
|
||||
|
||||
struct ovlData3Struct
|
||||
{
|
||||
struct ovlData3Struct {
|
||||
uint8 *dataPtr; //0
|
||||
short int sizeOfData; //4
|
||||
short int offsetToSubData3; //6
|
||||
|
@ -68,8 +65,7 @@ struct ovlData3Struct
|
|||
|
||||
typedef struct ovlData3Struct ovlData3Struct;
|
||||
|
||||
struct stringEntryStruct
|
||||
{
|
||||
struct stringEntryStruct {
|
||||
char *string;
|
||||
short int length;
|
||||
short int idx;
|
||||
|
@ -77,8 +73,7 @@ struct stringEntryStruct
|
|||
|
||||
typedef struct stringEntryStruct stringEntryStruct;
|
||||
|
||||
struct linkDataStruct
|
||||
{
|
||||
struct linkDataStruct {
|
||||
uint16 field_0;
|
||||
uint16 field_2;
|
||||
uint16 field_4;
|
||||
|
@ -101,8 +96,7 @@ struct linkDataStruct
|
|||
|
||||
typedef struct linkDataStruct linkDataStruct;
|
||||
|
||||
struct importDataStruct
|
||||
{
|
||||
struct importDataStruct {
|
||||
uint16 var0; // 0
|
||||
uint16 var1; // 2
|
||||
uint16 linkType; // 4
|
||||
|
@ -112,8 +106,7 @@ struct importDataStruct
|
|||
|
||||
typedef struct importDataStruct importDataStruct;
|
||||
|
||||
struct objDataStruct
|
||||
{
|
||||
struct objDataStruct {
|
||||
int16 var0;
|
||||
int16 var1;
|
||||
int16 var2;
|
||||
|
@ -125,8 +118,7 @@ struct objDataStruct
|
|||
|
||||
typedef struct objDataStruct objDataStruct;
|
||||
|
||||
struct objectParams
|
||||
{
|
||||
struct objectParams {
|
||||
int16 X;
|
||||
int16 Y;
|
||||
int16 baseFileIdx;
|
||||
|
@ -137,8 +129,7 @@ struct objectParams
|
|||
|
||||
typedef struct objectParams objectParams;
|
||||
|
||||
struct ovlDataStruct
|
||||
{
|
||||
struct ovlDataStruct {
|
||||
ovlData3Struct *data3Table;
|
||||
uint8 *ptr1;
|
||||
objDataStruct *objDataTable;
|
||||
|
@ -174,8 +165,7 @@ struct ovlDataStruct
|
|||
|
||||
typedef struct ovlDataStruct ovlDataStruct;
|
||||
|
||||
struct overlayStruct
|
||||
{
|
||||
struct overlayStruct {
|
||||
char overlayName[14];
|
||||
ovlDataStruct *ovlData;
|
||||
short int alreadyLoaded;
|
||||
|
@ -211,7 +201,6 @@ int32 findOverlayByName2(uint8* name);
|
|||
int findOverlayByName(const char *overlayName);
|
||||
int releaseOverlay(const char *name);
|
||||
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,26 +30,21 @@ persoStruct* persoTable[10];
|
|||
|
||||
int16 computedVar14;
|
||||
|
||||
void freePerso(int persoIdx)
|
||||
{
|
||||
if(persoTable[persoIdx])
|
||||
{
|
||||
void freePerso(int persoIdx) {
|
||||
if (persoTable[persoIdx]) {
|
||||
free(persoTable[persoIdx]);
|
||||
persoTable[persoIdx] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void freeAllPerso(void)
|
||||
{
|
||||
void freeAllPerso(void) {
|
||||
int i;
|
||||
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
for (i = 0; i < 10; i++) {
|
||||
freePerso(i);
|
||||
}
|
||||
|
||||
if(polyStruct)
|
||||
{
|
||||
if (polyStruct) {
|
||||
free(polyStruct);
|
||||
}
|
||||
|
||||
|
@ -63,32 +58,35 @@ int pathVar0;
|
|||
|
||||
unsigned int inc_droite2, inc_jo;
|
||||
|
||||
int direction( int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2 )
|
||||
{
|
||||
int direction(int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2) {
|
||||
int h, v, h1, v1;
|
||||
|
||||
h1 = x1-x2; h = abs(h1);
|
||||
v1 = y1-y2; v = abs(v1);
|
||||
h1 = x1 - x2;
|
||||
h = abs(h1);
|
||||
v1 = y1 - y2;
|
||||
v = abs(v1);
|
||||
|
||||
if ( v > h )
|
||||
{
|
||||
if ( h > 30 ) inc_jo = inc_jo1-inc_jo2;
|
||||
else inc_jo = inc_jo2;
|
||||
|
||||
if ( v1 < 0 ) return ( 2 );
|
||||
else return ( 0 );
|
||||
}
|
||||
if (v > h) {
|
||||
if (h > 30)
|
||||
inc_jo = inc_jo1 - inc_jo2;
|
||||
else
|
||||
{
|
||||
inc_jo = inc_jo2;
|
||||
|
||||
if (v1 < 0)
|
||||
return (2);
|
||||
else
|
||||
return (0);
|
||||
} else {
|
||||
inc_jo = inc_jo1;
|
||||
|
||||
if ( h1 < 0 ) return ( 1 );
|
||||
else return ( 3 );
|
||||
if (h1 < 0)
|
||||
return (1);
|
||||
else
|
||||
return (3);
|
||||
}
|
||||
}
|
||||
|
||||
void cor_droite(int x1,int y1,int x2,int y2, int16 cor_joueur[400][2])
|
||||
{
|
||||
void cor_droite(int x1, int y1, int x2, int y2, int16 cor_joueur[400][2]) {
|
||||
int16 *di = (int16 *) cor_joueur;
|
||||
int dx;
|
||||
int dy;
|
||||
|
@ -115,28 +113,23 @@ void cor_droite(int x1,int y1,int x2,int y2, int16 cor_joueur[400][2])
|
|||
|
||||
mD0 = mD1 = 1;
|
||||
|
||||
if(dx<0)
|
||||
{
|
||||
if (dx < 0) {
|
||||
dx = -dx;
|
||||
mD0 = -1;
|
||||
}
|
||||
|
||||
if(dy<0)
|
||||
{
|
||||
if (dy < 0) {
|
||||
dy = -dy;
|
||||
mD1 = -1;
|
||||
}
|
||||
|
||||
if(dx<dy)
|
||||
{
|
||||
if (dx < dy) {
|
||||
mA0 = 0;
|
||||
bp = dx;
|
||||
cx = dy;
|
||||
|
||||
mA1 = mD1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mA1 = 0;
|
||||
bp = dy;
|
||||
cx = dx;
|
||||
|
@ -151,16 +144,12 @@ void cor_droite(int x1,int y1,int x2,int y2, int16 cor_joueur[400][2])
|
|||
ax = x1;
|
||||
bx = y1;
|
||||
|
||||
while(--cx)
|
||||
{
|
||||
if(dx>0)
|
||||
{
|
||||
while (--cx) {
|
||||
if (dx > 0) {
|
||||
ax += mD0;
|
||||
bx += mD1;
|
||||
dx += si;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ax += mA0;
|
||||
bx += mA1;
|
||||
dx += bp;
|
||||
|
@ -175,8 +164,10 @@ void cor_droite(int x1,int y1,int x2,int y2, int16 cor_joueur[400][2])
|
|||
inc_droite2 = (di - (int16 *) cor_joueur) / 2;
|
||||
}
|
||||
|
||||
void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, int16* inc_chemin, int16 cor_joueur[400][2], int16 solution0[NUM_NODES+3][2], int16* inc_jo1, int16* inc_jo2, int16* dir_perso, int16* inc_jo0, int16 num)
|
||||
{
|
||||
void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0,
|
||||
int16 *inc_chemin, int16 cor_joueur[400][2],
|
||||
int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2,
|
||||
int16 *dir_perso, int16 *inc_jo0, int16 num) {
|
||||
int x1, x2, y1, y2;
|
||||
int i, u;
|
||||
|
||||
|
@ -185,21 +176,16 @@ void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, in
|
|||
|
||||
i = *inc_chemin;
|
||||
|
||||
if ( ! *inc_droite )
|
||||
{
|
||||
if (!*inc_droite) {
|
||||
x1 = solution0[i][0];
|
||||
y1 = solution0[i][1];
|
||||
i++;
|
||||
if ( solution0[i][0] != -1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
if (solution0[i][0]!=-2)
|
||||
{
|
||||
if (solution0[i][0] != -1) {
|
||||
do {
|
||||
if (solution0[i][0] != -2) {
|
||||
x2 = solution0[i][0];
|
||||
y2 = solution0[i][1];
|
||||
if ( (x1==x2) && (y1==y2))
|
||||
{
|
||||
if ((x1 == x2) && (y1 == y2)) {
|
||||
resx_y[0] = -1;
|
||||
resx_y[1] = -1;
|
||||
freePerso(num);
|
||||
|
@ -208,16 +194,17 @@ void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, in
|
|||
}
|
||||
cor_droite(x1, y1, x2, y2, cor_joueur);
|
||||
*inc_droite0 = inc_droite2;
|
||||
*dir_perso=resx_y[2]=direction(x1,y1,x2,y2,*inc_jo1,*inc_jo2);
|
||||
*dir_perso = resx_y[2] =
|
||||
direction(x1, y1, x2, y2, *inc_jo1,
|
||||
*inc_jo2);
|
||||
*inc_jo0 = inc_jo;
|
||||
u = 1;
|
||||
}
|
||||
else i++;
|
||||
} else
|
||||
i++;
|
||||
|
||||
} while (solution0[i][0] != -1 && !u);
|
||||
}
|
||||
if ( !u )
|
||||
{
|
||||
if (!u) {
|
||||
resx_y[0] = -1;
|
||||
resx_y[1] = -1;
|
||||
freePerso(num);
|
||||
|
@ -236,11 +223,11 @@ void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, in
|
|||
resx_y[4] = computedVar14;
|
||||
|
||||
u = subOp23(resx_y[3], inc_jo);
|
||||
if (!u) u=1;
|
||||
if (!u)
|
||||
u = 1;
|
||||
*inc_droite += u;
|
||||
|
||||
if ((*inc_droite)>=(*inc_droite0))
|
||||
{
|
||||
if ((*inc_droite) >= (*inc_droite0)) {
|
||||
*inc_droite = 0;
|
||||
resx_y[0] = solution0[*inc_chemin][0];
|
||||
resx_y[1] = solution0[*inc_chemin][1];
|
||||
|
@ -248,13 +235,15 @@ void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, in
|
|||
|
||||
}
|
||||
|
||||
void affiche_chemin(int16 persoIdx, int16* returnVar)
|
||||
{
|
||||
void affiche_chemin(int16 persoIdx, int16 *returnVar) {
|
||||
persoStruct *pPerso = persoTable[persoIdx];
|
||||
|
||||
ASSERT(pPerso);
|
||||
|
||||
processActorWalk(returnVar, &pPerso->inc_droite, &pPerso->inc_droite0, &pPerso->inc_chemin, pPerso->coordinates, pPerso->solution, &pPerso->inc_jo1, &pPerso->inc_jo2, &pPerso->dir_perso, &pPerso->inc_jo0, persoIdx);
|
||||
processActorWalk(returnVar, &pPerso->inc_droite, &pPerso->inc_droite0,
|
||||
&pPerso->inc_chemin, pPerso->coordinates, pPerso->solution,
|
||||
&pPerso->inc_jo1, &pPerso->inc_jo2, &pPerso->dir_perso,
|
||||
&pPerso->inc_jo0, persoIdx);
|
||||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -22,15 +22,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERSO_H_
|
||||
#define _PERSO_H_
|
||||
#ifndef CRUISE_PERSO_H
|
||||
#define CRUISE_PERSO_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
#define NUM_NODES 20
|
||||
|
||||
struct persoStruct
|
||||
{
|
||||
struct persoStruct {
|
||||
int16 inc_droite; // 2
|
||||
int16 inc_droite0; // 2
|
||||
int16 inc_chemin; // 2
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "cruise/cruise_main.h"
|
||||
#include "common/util.h"
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -34,10 +35,6 @@ typedef char ColorP;
|
|||
#define SCREENHEIGHT 200
|
||||
#define MAXPTS 10
|
||||
#define putdot(x,y) {if ((y >= 0) && (y < SCREENHEIGHT)) dots[y][counters[y]++] = x;}
|
||||
#define SWAP(x,y) {int temp = x; x = y; y = temp;}
|
||||
|
||||
int MAX(int x, int y) {if(x>y){return x;}else{return y;}}
|
||||
int MIN(int x, int y) {if(x<y){return x;}else{return y;}}
|
||||
|
||||
void hline(int x1, int x2, int y, char c) {
|
||||
for (; x1 <= x2; x1++) {
|
||||
|
@ -75,6 +72,7 @@ void bsubline_1(int x1, int y1, int x2, int y2, char c) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
void bsubline_2(int x1, int y1, int x2, int y2, char c) {
|
||||
|
||||
int x, y, ddx, ddy, e;
|
||||
|
@ -88,7 +86,6 @@ void bsubline_2(int x1, int y1, int x2, int y2, char c) {
|
|||
SWAP(y1, y2);
|
||||
}
|
||||
|
||||
|
||||
for (y = y1, x = x1; y <= y2; y++) {
|
||||
|
||||
pixel(x, y, c);
|
||||
|
@ -116,7 +113,6 @@ void bsubline_3(int x1, int y1, int x2, int y2, char c) {
|
|||
SWAP(y1, y2);
|
||||
}
|
||||
|
||||
|
||||
for (y = y1, x = x1; y <= y2; y++) {
|
||||
|
||||
pixel(x, y, c);
|
||||
|
@ -188,16 +184,14 @@ void line(int x1, int y1, int x2, int y2, char c) {
|
|||
}
|
||||
}
|
||||
|
||||
void fillpoly(short int* datas, int lineCount, ColorP color)
|
||||
{
|
||||
void fillpoly(short int *datas, int lineCount, ColorP color) {
|
||||
static int dots[SCREENHEIGHT][MAXPTS];
|
||||
static int counters[SCREENHEIGHT];
|
||||
short int x1, y1, x2, y2;
|
||||
int i, j, k, dir = -2;
|
||||
double step, curx;
|
||||
|
||||
switch (lineCount)
|
||||
{
|
||||
switch (lineCount) {
|
||||
case 0: // do nothing
|
||||
return;
|
||||
case 1: // draw pixel
|
||||
|
@ -212,8 +206,7 @@ void fillpoly(short int* datas, int lineCount, ColorP color)
|
|||
|
||||
// Reinit array counters
|
||||
|
||||
for (i = 0; i < SCREENHEIGHT; i++)
|
||||
{
|
||||
for (i = 0; i < SCREENHEIGHT; i++) {
|
||||
counters[i] = 0;
|
||||
}
|
||||
// Drawing lines
|
||||
|
@ -230,17 +223,13 @@ void fillpoly(short int* datas, int lineCount, ColorP color)
|
|||
// line(x1, y1, x2, y2, color);
|
||||
// continue;
|
||||
|
||||
if (y1 == y2)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
// printf("Horizontal line. x1: %i, y1: %i, x2: %i, y2: %i\n", x1, y1, x2, y2);
|
||||
if (dir)
|
||||
{
|
||||
if (dir) {
|
||||
putdot(x1, y1);
|
||||
dir = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
step = (double)(x2 - x1) / (y2 - y1);
|
||||
|
||||
// printf("x1: %i, y1 = %i, x2 = %i, y2 = %i, step: %f\n", x1, y1, x2, y2, step);
|
||||
|
@ -276,11 +265,11 @@ void fillpoly(short int* datas, int lineCount, ColorP color)
|
|||
x2 = datas[0];
|
||||
y2 = datas[1];
|
||||
|
||||
if (((y1 < y2) && (dir == -1)) || ((y1 > y2) && (dir == 1)) || ((y1 == y2) && (dir == 0))) {
|
||||
if (((y1 < y2) && (dir == -1)) || ((y1 > y2) && (dir == 1))
|
||||
|| ((y1 == y2) && (dir == 0))) {
|
||||
// printf("Adding final extra (%i, %i)\n", x1, y1);
|
||||
putdot(x1, y1);
|
||||
}
|
||||
|
||||
// NOTE: all counters should be even now. If not, this is a bad (color) thing :-P
|
||||
|
||||
// Sorting datas
|
||||
|
@ -289,8 +278,7 @@ void fillpoly(short int* datas, int lineCount, ColorP color)
|
|||
// Very bad sorting... but arrays are very small (0, 2 or 4), so it's no quite use...
|
||||
for (j = 0; j < (counters[i] - 1); j++) {
|
||||
for (k = 0; k < (counters[i] - 1); k++) {
|
||||
if (dots[i][k] > dots[i][k + 1])
|
||||
{
|
||||
if (dots[i][k] > dots[i][k + 1]) {
|
||||
int temp;
|
||||
temp = dots[i][k];
|
||||
dots[i][k] = dots[i][k + 1];
|
||||
|
@ -320,4 +308,3 @@ void fillpoly(short int* datas, int lineCount, ColorP color)
|
|||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef CRUISE_POLYS_H
|
||||
#define CRUISE_POLYS_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
typedef char ColorP;
|
||||
|
@ -30,3 +33,5 @@ void fillpoly(short int * datas, int n, ColorP c);
|
|||
void line(int x1, int y1, int x2, int y2, ColorP color);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,65 +26,64 @@
|
|||
|
||||
namespace Cruise {
|
||||
|
||||
void loadSavegameDataSub1(FILE* fileHandle)
|
||||
{
|
||||
void loadSavegameDataSub1(FILE *fileHandle) {
|
||||
int i;
|
||||
|
||||
for(i=1;i<numOfLoadedOverlay;i++)
|
||||
{
|
||||
for (i = 1; i < numOfLoadedOverlay; i++) {
|
||||
filesData[i].field_4 = NULL;
|
||||
filesData[i].field_0 = NULL;
|
||||
filesData2[i].field_0 = 0;
|
||||
|
||||
if(overlayTable[i].alreadyLoaded)
|
||||
{
|
||||
if (overlayTable[i].alreadyLoaded) {
|
||||
fread(&filesData2[i].field_0, 2, 1, fileHandle);
|
||||
|
||||
if(filesData2[i].field_0)
|
||||
{
|
||||
filesData[i].field_0 = (uint8*)mallocAndZero(filesData2[i].field_0);
|
||||
if(filesData[i].field_0)
|
||||
{
|
||||
fread(filesData[i].field_0,filesData2[i].field_0,1,fileHandle);
|
||||
if (filesData2[i].field_0) {
|
||||
filesData[i].field_0 =
|
||||
(uint8 *) mallocAndZero(filesData2[i].
|
||||
field_0);
|
||||
if (filesData[i].field_0) {
|
||||
fread(filesData[i].field_0,
|
||||
filesData2[i].field_0, 1,
|
||||
fileHandle);
|
||||
}
|
||||
}
|
||||
|
||||
fread(&filesData2[i].field_2, 2, 1, fileHandle);
|
||||
|
||||
if(filesData2[i].field_2)
|
||||
{
|
||||
filesData[i].field_4 = (uint8*)mallocAndZero(filesData2[i].field_2*12);
|
||||
if(filesData[i].field_4)
|
||||
{
|
||||
fread(filesData[i].field_4,filesData2[i].field_2*12,1,fileHandle);
|
||||
if (filesData2[i].field_2) {
|
||||
filesData[i].field_4 =
|
||||
(uint8 *) mallocAndZero(filesData2[i].
|
||||
field_2 * 12);
|
||||
if (filesData[i].field_4) {
|
||||
fread(filesData[i].field_4,
|
||||
filesData2[i].field_2 * 12, 1,
|
||||
fileHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadScriptsFromSave(FILE* fileHandle,scriptInstanceStruct* entry)
|
||||
{
|
||||
void loadScriptsFromSave(FILE *fileHandle, scriptInstanceStruct *entry) {
|
||||
short int numScripts;
|
||||
int i;
|
||||
|
||||
fread(&numScripts, 2, 1, fileHandle);
|
||||
|
||||
for(i=0;i<numScripts;i++)
|
||||
{
|
||||
scriptInstanceStruct* ptr = (scriptInstanceStruct*)mallocAndZero(sizeof(scriptInstanceStruct));
|
||||
for (i = 0; i < numScripts; i++) {
|
||||
scriptInstanceStruct *ptr =
|
||||
(scriptInstanceStruct *)
|
||||
mallocAndZero(sizeof(scriptInstanceStruct));
|
||||
|
||||
fread(ptr, 0x1C, 1, fileHandle); // use 0x1C as our scriptInstanceStruct is bigger than in original because of cross platform problems
|
||||
|
||||
fread(&ptr->varA, 2, 1, fileHandle);
|
||||
|
||||
if(ptr->varA)
|
||||
{
|
||||
if (ptr->varA) {
|
||||
ptr->var6 = (uint8 *) mallocAndZero(ptr->varA);
|
||||
|
||||
fread(ptr->var6, ptr->varA, 1, fileHandle);
|
||||
}
|
||||
|
||||
/////////
|
||||
ptr->bitMask = *((int16 *) ptr + 1);
|
||||
/////////
|
||||
|
@ -96,8 +95,7 @@ void loadScriptsFromSave(FILE* fileHandle,scriptInstanceStruct* entry)
|
|||
}
|
||||
}
|
||||
|
||||
void loadSavegameActor(FILE* fileHandle)
|
||||
{
|
||||
void loadSavegameActor(FILE *fileHandle) {
|
||||
short int numEntry;
|
||||
actorStruct *ptr;
|
||||
int i;
|
||||
|
@ -106,9 +104,9 @@ void loadSavegameActor(FILE* fileHandle)
|
|||
|
||||
ptr = &actorHead;
|
||||
|
||||
for(i=0;i<numEntry;i++)
|
||||
{
|
||||
actorStruct* current = (actorStruct*)mallocAndZero(sizeof(actorStruct));
|
||||
for (i = 0; i < numEntry; i++) {
|
||||
actorStruct *current =
|
||||
(actorStruct *) mallocAndZero(sizeof(actorStruct));
|
||||
fseek(fileHandle, 4, SEEK_CUR);
|
||||
fread(current, 0x26, 1, fileHandle);
|
||||
|
||||
|
@ -120,60 +118,52 @@ void loadSavegameActor(FILE* fileHandle)
|
|||
}
|
||||
}
|
||||
|
||||
void loadSavegameDataSub5(FILE* fileHandle)
|
||||
{
|
||||
if(var1)
|
||||
{
|
||||
void loadSavegameDataSub5(FILE *fileHandle) {
|
||||
if (var1) {
|
||||
fread(&saveVar1, 1, 1, fileHandle);
|
||||
|
||||
if(saveVar1)
|
||||
{
|
||||
if (saveVar1) {
|
||||
fread(saveVar2, saveVar1, 1, fileHandle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fread(&saveVar1, 1, 1, fileHandle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loadSavegameDataSub6(FILE* fileHandle)
|
||||
{
|
||||
void loadSavegameDataSub6(FILE *fileHandle) {
|
||||
int32 var;
|
||||
|
||||
fread(&var, 4, 1, fileHandle);
|
||||
flipLong(&var);
|
||||
|
||||
if(var)
|
||||
{
|
||||
if (var) {
|
||||
int i;
|
||||
|
||||
fread(&numberOfWalkboxes, 2, 1, fileHandle);
|
||||
|
||||
if(numberOfWalkboxes)
|
||||
{
|
||||
fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
|
||||
fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
|
||||
if (numberOfWalkboxes) {
|
||||
fread(walkboxType, numberOfWalkboxes * 2, 1,
|
||||
fileHandle);
|
||||
fread(walkboxType, numberOfWalkboxes * 2, 1,
|
||||
fileHandle);
|
||||
}
|
||||
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
for (i = 0; i < 10; i++) {
|
||||
fread(&persoTable[i], 4, 1, fileHandle);
|
||||
|
||||
if(persoTable[i])
|
||||
{
|
||||
if (persoTable[i]) {
|
||||
assert(sizeof(persoStruct) == 0x6AA);
|
||||
persoTable[i] = (persoStruct*)mallocAndZero(sizeof(persoStruct));
|
||||
persoTable[i] =
|
||||
(persoStruct *)
|
||||
mallocAndZero(sizeof(persoStruct));
|
||||
fread(persoTable[i], 0x6AA, 1, fileHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int loadSavegameData(int saveGameIdx)
|
||||
{
|
||||
int loadSavegameData(int saveGameIdx) {
|
||||
char buffer[256];
|
||||
FILE *fileHandle;
|
||||
char saveIdentBuffer[6];
|
||||
|
@ -185,8 +175,7 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
fileHandle = fopen(buffer, "rb");
|
||||
|
||||
if(!fileHandle)
|
||||
{
|
||||
if (!fileHandle) {
|
||||
printInfoBlackBox("Sauvegarde non trouvée...");
|
||||
waitForPlayerInput();
|
||||
return (-1);
|
||||
|
@ -196,12 +185,10 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
fread(saveIdentBuffer, 6, 1, fileHandle);
|
||||
|
||||
if(strcmp(saveIdentBuffer,"SAVPC"))
|
||||
{
|
||||
if (strcmp(saveIdentBuffer, "SAVPC")) {
|
||||
fclose(fileHandle);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
//initVars();
|
||||
|
||||
fread(&var1, 2, 1, fileHandle);
|
||||
|
@ -288,38 +275,34 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
fclose(fileHandle); // finished with loading !!!!! Yatta !
|
||||
|
||||
for(j=0;j<64;j++)
|
||||
{
|
||||
for (j = 0; j < 64; j++) {
|
||||
mediumVar[j].ptr = NULL;
|
||||
}
|
||||
|
||||
for(j=1;j<numOfLoadedOverlay;j++)
|
||||
{
|
||||
if(overlayTable[j].alreadyLoaded)
|
||||
{
|
||||
for (j = 1; j < numOfLoadedOverlay; j++) {
|
||||
if (overlayTable[j].alreadyLoaded) {
|
||||
overlayTable[j].alreadyLoaded = 0;
|
||||
loadOverlay((uint8 *) overlayTable[j].overlayName);
|
||||
|
||||
if(overlayTable[j].alreadyLoaded)
|
||||
{
|
||||
ovlDataStruct* ovlData = overlayTable[j].ovlData;
|
||||
if (overlayTable[j].alreadyLoaded) {
|
||||
ovlDataStruct *ovlData =
|
||||
overlayTable[j].ovlData;
|
||||
|
||||
if(filesData[j].field_0)
|
||||
{
|
||||
if(ovlData->data4Ptr)
|
||||
{
|
||||
if (filesData[j].field_0) {
|
||||
if (ovlData->data4Ptr) {
|
||||
free(ovlData->data4Ptr);
|
||||
}
|
||||
|
||||
ovlData->data4Ptr = (uint8*)filesData[j].field_0;
|
||||
ovlData->sizeOfData4 = filesData2[j].field_0;
|
||||
ovlData->data4Ptr =
|
||||
(uint8 *) filesData[j].field_0;
|
||||
ovlData->sizeOfData4 =
|
||||
filesData2[j].field_0;
|
||||
}
|
||||
|
||||
if(filesData[j].field_4)
|
||||
{
|
||||
if(ovlData->objData2WorkTable)
|
||||
{
|
||||
free(ovlData->objData2WorkTable);
|
||||
if (filesData[j].field_4) {
|
||||
if (ovlData->objData2WorkTable) {
|
||||
free(ovlData->
|
||||
objData2WorkTable);
|
||||
}
|
||||
|
||||
ovlData->objData2WorkTable = (objectParams *) filesData[j].field_4; // TODO: fix !
|
||||
|
@ -336,30 +319,25 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
initVar1Save = initVar1;
|
||||
|
||||
for(j=0;j<257;j++)
|
||||
{
|
||||
if(filesDatabase[j].subData.ptr)
|
||||
{
|
||||
for (j = 0; j < 257; j++) {
|
||||
if (filesDatabase[j].subData.ptr) {
|
||||
int i;
|
||||
int k;
|
||||
|
||||
for(i=j+1;i<257;i++)
|
||||
{
|
||||
if(filesDatabase[i].subData.ptr)
|
||||
{
|
||||
if(strcmpuint8(filesDatabase[j].subData.name,filesDatabase[i].subData.name))
|
||||
{
|
||||
for (i = j + 1; i < 257; i++) {
|
||||
if (filesDatabase[i].subData.ptr) {
|
||||
if (strcmpuint8(filesDatabase[j].
|
||||
subData.name,
|
||||
filesDatabase[i].subData.
|
||||
name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(k=j;k<i;k++)
|
||||
{
|
||||
for (k = j; k < i; k++) {
|
||||
if (filesDatabase[k].subData.ptr2)
|
||||
initVar1 = 0;
|
||||
|
||||
|
@ -367,15 +345,14 @@ int loadSavegameData(int saveGameIdx)
|
|||
filesDatabase[k].subData.ptr2 = NULL;
|
||||
}
|
||||
|
||||
if(i<2)
|
||||
{
|
||||
if (i < 2) {
|
||||
printf("Unsupported mono file load!\n");
|
||||
exit(1);
|
||||
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadFileMode2((uint8*)filesDatabase[j].subData.name,filesDatabase[j].subData.index, j, i-j);
|
||||
} else {
|
||||
loadFileMode2((uint8 *) filesDatabase[j].
|
||||
subData.name,
|
||||
filesDatabase[j].subData.index, j, i - j);
|
||||
j = i - 1;
|
||||
}
|
||||
|
||||
|
@ -387,21 +364,18 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
currentcellHead = cellHead.next;
|
||||
|
||||
while(currentcellHead)
|
||||
{
|
||||
if(currentcellHead->type == 5)
|
||||
{
|
||||
uint8* ptr = mainProc14(currentcellHead->overlay,currentcellHead->idx);
|
||||
while (currentcellHead) {
|
||||
if (currentcellHead->type == 5) {
|
||||
uint8 *ptr =
|
||||
mainProc14(currentcellHead->overlay,
|
||||
currentcellHead->idx);
|
||||
|
||||
ASSERT(0);
|
||||
|
||||
if(ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
ASSERT(0);
|
||||
//*(int16*)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentcellHead->datas+0xE));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//*(int16*)(currentcellHead->datas+0x2E) = 0;
|
||||
}
|
||||
}
|
||||
|
@ -411,20 +385,16 @@ int loadSavegameData(int saveGameIdx)
|
|||
|
||||
//TODO: here, restart music
|
||||
|
||||
if(strlen((char*)currentCtpName))
|
||||
{
|
||||
if (strlen((char *)currentCtpName)) {
|
||||
ctpVar1 = 1;
|
||||
loadCtp(currentCtpName);
|
||||
ctpVar1 = 0;
|
||||
}
|
||||
|
||||
//prepareFadeOut();
|
||||
//gfxModuleData.gfxFunction8();
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
if(strlen((char*)backgroundTable[j].name))
|
||||
{
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (strlen((char *)backgroundTable[j].name)) {
|
||||
loadBackground(backgroundTable[j].name, j);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOADSAVE_H_
|
||||
#define _LOADSAVE_H_
|
||||
#ifndef CRUISE_SAVELOAD_H
|
||||
#define CRUISE_SAVELOAD_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
|
|
@ -31,9 +31,7 @@ scriptInstanceStruct scriptHandle2;
|
|||
|
||||
scriptInstanceStruct *currentScriptPtr;
|
||||
|
||||
|
||||
uint8 getByteFromScript(void)
|
||||
{
|
||||
uint8 getByteFromScript(void) {
|
||||
uint8 var = currentData3DataPtr[currentScriptPtr->var4];
|
||||
|
||||
currentScriptPtr->var4 = currentScriptPtr->var4 + 1;
|
||||
|
@ -41,8 +39,7 @@ uint8 getByteFromScript(void)
|
|||
return (var);
|
||||
}
|
||||
|
||||
short int getShortFromScript(void)
|
||||
{
|
||||
short int getShortFromScript(void) {
|
||||
short int var = *(int16 *) (currentData3DataPtr + currentScriptPtr->var4);
|
||||
|
||||
currentScriptPtr->var4 = currentScriptPtr->var4 + 2;
|
||||
|
@ -52,10 +49,9 @@ short int getShortFromScript(void)
|
|||
return (var);
|
||||
}
|
||||
|
||||
int32 opcodeType0(void) // load opcode
|
||||
{
|
||||
switch(currentScriptOpcodeType)
|
||||
{
|
||||
// load opcode
|
||||
int32 opcodeType0(void) {
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
pushVar(getShortFromScript());
|
||||
|
@ -70,51 +66,40 @@ int32 opcodeType0(void) // load opcode
|
|||
|
||||
int var_E = byte1 & 7;
|
||||
|
||||
if(!var_E)
|
||||
{
|
||||
if (!var_E) {
|
||||
return (-10);
|
||||
}
|
||||
|
||||
if(!byte2)
|
||||
{
|
||||
if (!byte2) {
|
||||
ptr = scriptDataPtrTable[var_E] + short1;
|
||||
}
|
||||
else // TODO:
|
||||
{
|
||||
if(!overlayTable[byte2].alreadyLoaded)
|
||||
} else // TODO:
|
||||
{
|
||||
if (!overlayTable[byte2].alreadyLoaded) {
|
||||
return (-7);
|
||||
}
|
||||
|
||||
if(!overlayTable[byte2].ovlData)
|
||||
{
|
||||
if (!overlayTable[byte2].ovlData) {
|
||||
return (-4);
|
||||
}
|
||||
|
||||
if(var_E == 5)
|
||||
{
|
||||
ptr = overlayTable[byte2].ovlData->data4Ptr + short1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var_E == 5) {
|
||||
ptr =
|
||||
overlayTable[byte2].ovlData->
|
||||
data4Ptr + short1;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(((byte1 & 0x18)>>3)==1)
|
||||
{
|
||||
if (((byte1 & 0x18) >> 3) == 1) {
|
||||
pushVar(loadShort(ptr));
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
if(((byte1 & 0x18)>>3)==2)
|
||||
{
|
||||
} else if (((byte1 & 0x18) >> 3) == 2) {
|
||||
pushVar(*ptr);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unsupported code in opcodeType0 case 1!\n");
|
||||
} else {
|
||||
printf
|
||||
("Unsupported code in opcodeType0 case 1!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -127,13 +112,11 @@ int32 opcodeType0(void) // load opcode
|
|||
int si = getByteFromScript();
|
||||
int var_2 = getShortFromScript();
|
||||
|
||||
if(!si)
|
||||
{
|
||||
if (!si) {
|
||||
si = currentScriptPtr->overlayNumber;
|
||||
}
|
||||
|
||||
if(getSingleObjectParam(si, var_2, di, &var_16))
|
||||
{
|
||||
if (getSingleObjectParam(si, var_2, di, &var_16)) {
|
||||
return -10;
|
||||
}
|
||||
|
||||
|
@ -155,51 +138,40 @@ int32 opcodeType0(void) // load opcode
|
|||
|
||||
uint8 *ptr = 0;
|
||||
|
||||
if(!var_E)
|
||||
{
|
||||
if (!var_E) {
|
||||
return (-10);
|
||||
}
|
||||
|
||||
if(!byte2)
|
||||
{
|
||||
if (!byte2) {
|
||||
ptr = scriptDataPtrTable[var_E] + var_12;
|
||||
}
|
||||
else // TODO:
|
||||
{
|
||||
if(!overlayTable[byte2].alreadyLoaded)
|
||||
} else // TODO:
|
||||
{
|
||||
if (!overlayTable[byte2].alreadyLoaded) {
|
||||
return (-7);
|
||||
}
|
||||
|
||||
if(!overlayTable[byte2].ovlData)
|
||||
{
|
||||
if (!overlayTable[byte2].ovlData) {
|
||||
return (-4);
|
||||
}
|
||||
|
||||
if(var_E == 5)
|
||||
{
|
||||
ptr = overlayTable[byte2].ovlData->data4Ptr + var_12;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var_E == 5) {
|
||||
ptr =
|
||||
overlayTable[byte2].ovlData->
|
||||
data4Ptr + var_12;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(((byte1 & 0x18)>>3)==1)
|
||||
{
|
||||
if (((byte1 & 0x18) >> 3) == 1) {
|
||||
pushVar(loadShort(ptr + saveOpcodeVar * 2)); // TODO: check this !
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
if(((byte1 & 0x18)>>3)==2)
|
||||
{
|
||||
} else if (((byte1 & 0x18) >> 3) == 2) {
|
||||
pushVar(*(ptr + saveOpcodeVar));
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unsupported code in opcodeType0 case 1!\n");
|
||||
} else {
|
||||
printf
|
||||
("Unsupported code in opcodeType0 case 1!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -207,7 +179,8 @@ int32 opcodeType0(void) // load opcode
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported type %d in opcodeType0\n",currentScriptOpcodeType);
|
||||
printf("Unsupported type %d in opcodeType0\n",
|
||||
currentScriptOpcodeType);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -215,13 +188,12 @@ int32 opcodeType0(void) // load opcode
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32 opcodeType1(void) // save opcode
|
||||
{
|
||||
// save opcode
|
||||
int32 opcodeType1(void) {
|
||||
int var = popVar();
|
||||
int offset = 0;
|
||||
|
||||
switch(currentScriptOpcodeType)
|
||||
{
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
return (0); // strange, but happens also in original interpreter
|
||||
|
@ -251,39 +223,33 @@ int32 opcodeType1(void) // save opcode
|
|||
|
||||
var_C = short1;
|
||||
|
||||
if(byte2)
|
||||
{
|
||||
if(!overlayTable[byte2].alreadyLoaded)
|
||||
{
|
||||
if (byte2) {
|
||||
if (!overlayTable[byte2].alreadyLoaded) {
|
||||
return (-7);
|
||||
}
|
||||
|
||||
if(!overlayTable[byte2].ovlData)
|
||||
{
|
||||
if (!overlayTable[byte2].ovlData) {
|
||||
return (-4);
|
||||
}
|
||||
|
||||
if(var_6 == 5)
|
||||
{
|
||||
ptr = overlayTable[byte2].ovlData->data4Ptr + var_C;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var_6 == 5) {
|
||||
ptr =
|
||||
overlayTable[byte2].ovlData->
|
||||
data4Ptr + var_C;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ptr = scriptDataPtrTable[var_6] + var_C;
|
||||
}
|
||||
|
||||
type2 = ((byte1 & 0x18) >> 3);
|
||||
|
||||
switch(type2)
|
||||
{
|
||||
switch (type2) {
|
||||
case 1:
|
||||
{
|
||||
saveShort(ptr+var_A+offset*2,var);
|
||||
saveShort(ptr + var_A + offset * 2,
|
||||
var);
|
||||
return 0;
|
||||
}
|
||||
case 2:
|
||||
|
@ -293,7 +259,8 @@ int32 opcodeType1(void) // save opcode
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported code in opcodeType1 case 1!\n");
|
||||
printf
|
||||
("Unsupported code in opcodeType1 case 1!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -306,8 +273,7 @@ int32 opcodeType1(void) // save opcode
|
|||
int di = getByteFromScript();
|
||||
int var_4 = getShortFromScript();
|
||||
|
||||
if(!di)
|
||||
{
|
||||
if (!di) {
|
||||
di = currentScriptPtr->overlayNumber;
|
||||
}
|
||||
|
||||
|
@ -327,7 +293,8 @@ int32 opcodeType1(void) // save opcode
|
|||
}
|
||||
default:
|
||||
{
|
||||
printf("Unsupported type %d in opcodeType1\n",currentScriptOpcodeType);
|
||||
printf("Unsupported type %d in opcodeType1\n",
|
||||
currentScriptOpcodeType);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -335,9 +302,7 @@ int32 opcodeType1(void) // save opcode
|
|||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int32 opcodeType2(void)
|
||||
{
|
||||
int32 opcodeType2(void) {
|
||||
int offset = saveOpcodeVar;
|
||||
int byte1 = getByteFromScript();
|
||||
int byte2 = getByteFromScript();
|
||||
|
@ -350,13 +315,11 @@ int32 opcodeType2(void)
|
|||
|
||||
ASSERT(byte1 & 7);
|
||||
|
||||
if(!(byte1 & 7))
|
||||
{
|
||||
if (!(byte1 & 7)) {
|
||||
return (-10);
|
||||
}
|
||||
|
||||
if(!byte2)
|
||||
{
|
||||
if (!byte2) {
|
||||
int type2;
|
||||
uint8 *ptr = scriptDataPtrTable[byte1 & 7] + short1;
|
||||
|
||||
|
@ -364,8 +327,7 @@ int32 opcodeType2(void)
|
|||
|
||||
ASSERT(type2 == 1 || type2 == 2);
|
||||
|
||||
switch(type2)
|
||||
{
|
||||
switch (type2) {
|
||||
case 1:
|
||||
{
|
||||
pushPtr(ptr + offset);
|
||||
|
@ -381,9 +343,7 @@ int32 opcodeType2(void)
|
|||
return (-10);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("Unsupported code in opcodeType2 case 1!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -391,25 +351,21 @@ int32 opcodeType2(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32 opcodeType10(void) // break
|
||||
{
|
||||
int32 opcodeType10(void) { // break
|
||||
return (0);
|
||||
}
|
||||
|
||||
int32 opcodeType11(void) // break
|
||||
{
|
||||
int32 opcodeType11(void) { // break
|
||||
return (1);
|
||||
}
|
||||
|
||||
int32 opcodeType4(void) // test
|
||||
{
|
||||
int32 opcodeType4(void) { // test
|
||||
int boolVar = 0;
|
||||
|
||||
var1 = popVar();
|
||||
var2 = popVar();
|
||||
|
||||
switch(currentScriptOpcodeType)
|
||||
{
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
if (var2 != var1)
|
||||
|
@ -454,8 +410,7 @@ int32 opcodeType4(void) // test
|
|||
return (0);
|
||||
}
|
||||
|
||||
int32 opcodeType6(void)
|
||||
{
|
||||
int32 opcodeType6(void) {
|
||||
int si = 0;
|
||||
|
||||
int pop = popVar();
|
||||
|
@ -463,13 +418,11 @@ int32 opcodeType6(void)
|
|||
if (!pop)
|
||||
si = 1;
|
||||
|
||||
if(pop<0)
|
||||
{
|
||||
if (pop < 0) {
|
||||
si |= 4;
|
||||
}
|
||||
|
||||
if(pop>0)
|
||||
{
|
||||
if (pop > 0) {
|
||||
si |= 2;
|
||||
}
|
||||
|
||||
|
@ -478,8 +431,7 @@ int32 opcodeType6(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int32 opcodeType7(void)
|
||||
{
|
||||
int32 opcodeType7(void) {
|
||||
var1 = popVar();
|
||||
var2 = popVar();
|
||||
|
||||
|
@ -489,59 +441,51 @@ int32 opcodeType7(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int32 opcodeType5(void)
|
||||
{
|
||||
int32 opcodeType5(void) {
|
||||
int offset = currentScriptPtr->var4;
|
||||
int short1 = getShortFromScript();
|
||||
int newSi = short1 + offset;
|
||||
int bitMask = currentScriptPtr->bitMask;
|
||||
|
||||
switch(currentScriptOpcodeType)
|
||||
{
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
if(!(bitMask & 1))
|
||||
{
|
||||
if (!(bitMask & 1)) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if(bitMask & 1)
|
||||
{
|
||||
if (bitMask & 1) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if(bitMask & 2)
|
||||
{
|
||||
if (bitMask & 2) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if(bitMask & 3)
|
||||
{
|
||||
if (bitMask & 3) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
if(bitMask & 4)
|
||||
{
|
||||
if (bitMask & 4) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if(bitMask & 5)
|
||||
{
|
||||
if (bitMask & 5) {
|
||||
currentScriptPtr->var4 = newSi;
|
||||
}
|
||||
break;
|
||||
|
@ -559,13 +503,11 @@ int32 opcodeType5(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int32 opcodeType3(void) // math
|
||||
{
|
||||
int32 opcodeType3(void) { // math
|
||||
int pop1 = popVar();
|
||||
int pop2 = popVar();
|
||||
|
||||
switch(currentScriptOpcodeType)
|
||||
{
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
pushVar(pop1 + pop2);
|
||||
|
@ -607,20 +549,16 @@ int32 opcodeType3(void) // math
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32 opcodeType9(void) // stop script
|
||||
{
|
||||
int32 opcodeType9(void) { // stop script
|
||||
//printf("Stop a script of overlay %s\n",overlayTable[currentScriptPtr->overlayNumber].overlayName);
|
||||
currentScriptPtr->scriptNumber = -1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
void setupFuncArray()
|
||||
{
|
||||
void setupFuncArray() {
|
||||
int i;
|
||||
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
for (i = 0; i < 64; i++) {
|
||||
opcodeTypeTable[i] = NULL;
|
||||
}
|
||||
|
||||
|
@ -638,18 +576,15 @@ void setupFuncArray()
|
|||
opcodeTypeTable[12] = opcodeType11;
|
||||
}
|
||||
|
||||
int removeScript(int overlay,int idx,scriptInstanceStruct* headPtr)
|
||||
{
|
||||
int removeScript(int overlay, int idx, scriptInstanceStruct *headPtr) {
|
||||
scriptInstanceStruct *scriptPtr;
|
||||
|
||||
scriptPtr = headPtr->nextScriptPtr;
|
||||
|
||||
if(scriptPtr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(scriptPtr->overlayNumber == overlay && (scriptPtr->scriptNumber == idx || idx == -1))
|
||||
{
|
||||
if (scriptPtr) {
|
||||
do {
|
||||
if (scriptPtr->overlayNumber == overlay
|
||||
&& (scriptPtr->scriptNumber == idx || idx == -1)) {
|
||||
scriptPtr->scriptNumber = -1;
|
||||
}
|
||||
|
||||
|
@ -661,8 +596,9 @@ int removeScript(int overlay,int idx,scriptInstanceStruct* headPtr)
|
|||
return (0);
|
||||
}
|
||||
|
||||
uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHandlePtr,int16 param, int16 arg0, int16 arg1, int16 arg2, scriptTypeEnum scriptType)
|
||||
{
|
||||
uint8 *attacheNewScriptToTail(int16 overlayNumber,
|
||||
scriptInstanceStruct *scriptHandlePtr, int16 param, int16 arg0,
|
||||
int16 arg1, int16 arg2, scriptTypeEnum scriptType) {
|
||||
int useArg3Neg = 0;
|
||||
ovlData3Struct *data3Ptr;
|
||||
scriptInstanceStruct *tempPtr;
|
||||
|
@ -671,35 +607,26 @@ uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHa
|
|||
|
||||
//printf("Starting script %d of overlay %s\n",param,overlayTable[overlayNumber].overlayName);
|
||||
|
||||
if(scriptType<0)
|
||||
{
|
||||
if (scriptType < 0) {
|
||||
useArg3Neg = 1;
|
||||
scriptType = (scriptTypeEnum) - scriptType;
|
||||
}
|
||||
|
||||
if(scriptType == 20)
|
||||
{
|
||||
if (scriptType == 20) {
|
||||
data3Ptr = getOvlData3Entry(overlayNumber, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(scriptType == 30)
|
||||
{
|
||||
} else {
|
||||
if (scriptType == 30) {
|
||||
data3Ptr = scriptFunc1Sub2(overlayNumber, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if(!data3Ptr)
|
||||
{
|
||||
if (!data3Ptr) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if(!data3Ptr->dataPtr)
|
||||
{
|
||||
if (!data3Ptr->dataPtr) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -712,15 +639,16 @@ uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHa
|
|||
oldTail = oldTail->nextScriptPtr;
|
||||
}
|
||||
|
||||
tempPtr = (scriptInstanceStruct*)mallocAndZero(sizeof(scriptInstanceStruct));
|
||||
tempPtr =
|
||||
(scriptInstanceStruct *)
|
||||
mallocAndZero(sizeof(scriptInstanceStruct));
|
||||
|
||||
if (!tempPtr)
|
||||
return (NULL);
|
||||
|
||||
tempPtr->var6 = NULL;
|
||||
|
||||
if(var_C)
|
||||
{
|
||||
if (var_C) {
|
||||
tempPtr->var6 = (uint8 *) mallocAndZero(var_C);
|
||||
}
|
||||
|
||||
|
@ -734,9 +662,7 @@ uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHa
|
|||
if (scriptType == 20) // Obj or not ?
|
||||
{
|
||||
tempPtr->sysKey = useArg3Neg;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tempPtr->sysKey = 1;
|
||||
}
|
||||
|
||||
|
@ -752,8 +678,7 @@ uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHa
|
|||
return (tempPtr->var6);
|
||||
}
|
||||
|
||||
int executeScripts(scriptInstanceStruct* ptr)
|
||||
{
|
||||
int executeScripts(scriptInstanceStruct *ptr) {
|
||||
int numScript2;
|
||||
ovlData3Struct *ptr2;
|
||||
ovlDataStruct *ovlData;
|
||||
|
@ -761,34 +686,25 @@ int executeScripts(scriptInstanceStruct* ptr)
|
|||
|
||||
numScript2 = ptr->scriptNumber;
|
||||
|
||||
if(ptr->type == 20)
|
||||
{
|
||||
if (ptr->type == 20) {
|
||||
ptr2 = getOvlData3Entry(ptr->overlayNumber, numScript2);
|
||||
|
||||
if(!ptr2)
|
||||
{
|
||||
if (!ptr2) {
|
||||
return (-4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ptr->type == 30)
|
||||
{
|
||||
} else {
|
||||
if (ptr->type == 30) {
|
||||
ptr2 = scriptFunc1Sub2(ptr->overlayNumber, numScript2);
|
||||
|
||||
if(!ptr2)
|
||||
{
|
||||
if (!ptr2) {
|
||||
return (-4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return (-6);
|
||||
}
|
||||
}
|
||||
|
||||
if(!overlayTable[ptr->overlayNumber].alreadyLoaded)
|
||||
{
|
||||
if (!overlayTable[ptr->overlayNumber].alreadyLoaded) {
|
||||
return (-7);
|
||||
}
|
||||
|
||||
|
@ -808,10 +724,10 @@ int executeScripts(scriptInstanceStruct* ptr)
|
|||
|
||||
positionInStack = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(currentScriptPtr->var4 == 290 && currentScriptPtr->overlayNumber == 4 && currentScriptPtr->scriptNumber == 0)
|
||||
{
|
||||
do {
|
||||
if (currentScriptPtr->var4 == 290
|
||||
&& currentScriptPtr->overlayNumber == 4
|
||||
&& currentScriptPtr->scriptNumber == 0) {
|
||||
currentScriptPtr->var4 = 923;
|
||||
}
|
||||
opcodeType = getByteFromScript();
|
||||
|
@ -820,9 +736,9 @@ int executeScripts(scriptInstanceStruct* ptr)
|
|||
|
||||
currentScriptOpcodeType = opcodeType & 7;
|
||||
|
||||
if(!opcodeTypeTable[(opcodeType&0xFB)>>3])
|
||||
{
|
||||
printf("Unsupported opcode type %d\n",(opcodeType&0xFB)>>3);
|
||||
if (!opcodeTypeTable[(opcodeType & 0xFB) >> 3]) {
|
||||
printf("Unsupported opcode type %d\n",
|
||||
(opcodeType & 0xFB) >> 3);
|
||||
exit(1);
|
||||
return (-21);
|
||||
}
|
||||
|
@ -831,23 +747,18 @@ int executeScripts(scriptInstanceStruct* ptr)
|
|||
return (0);
|
||||
}
|
||||
|
||||
void manageScripts(scriptInstanceStruct* scriptHandle)
|
||||
{
|
||||
void manageScripts(scriptInstanceStruct *scriptHandle) {
|
||||
scriptInstanceStruct *ptr = scriptHandle;
|
||||
|
||||
if(ptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(!overlayTable[ptr->overlayNumber].executeScripts)
|
||||
{
|
||||
if(ptr->scriptNumber != -1 && ptr->var12 == 0 && ptr->sysKey != 0)
|
||||
{
|
||||
if (ptr) {
|
||||
do {
|
||||
if (!overlayTable[ptr->overlayNumber].executeScripts) {
|
||||
if (ptr->scriptNumber != -1 && ptr->var12 == 0
|
||||
&& ptr->sysKey != 0) {
|
||||
executeScripts(ptr);
|
||||
}
|
||||
|
||||
if(ptr->sysKey == 0)
|
||||
{
|
||||
if (ptr->sysKey == 0) {
|
||||
ptr->sysKey = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _SCRIPT_H_
|
||||
#define _SCRIPT_H_
|
||||
#ifndef CRUISE_SCRIPT_H
|
||||
#define CRUISE_SCRIPT_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
enum scriptTypeEnum
|
||||
{
|
||||
enum scriptTypeEnum {
|
||||
scriptType_Minus20 = -20,
|
||||
scriptType_Minus30 = -30,
|
||||
scriptType_20 = 20,
|
||||
|
@ -37,8 +36,7 @@ enum scriptTypeEnum
|
|||
|
||||
typedef enum scriptTypeEnum scriptTypeEnum;
|
||||
|
||||
struct scriptInstanceStruct
|
||||
{
|
||||
struct scriptInstanceStruct {
|
||||
struct scriptInstanceStruct *nextScriptPtr;
|
||||
int16 var4;
|
||||
uint8 *var6;
|
||||
|
@ -65,7 +63,9 @@ void setupFuncArray(void);
|
|||
uint8 getByteFromScript(void);
|
||||
|
||||
int removeScript(int overlay, int idx, scriptInstanceStruct * headPtr);
|
||||
uint8* attacheNewScriptToTail(int16 overlayNumber,scriptInstanceStruct* scriptHandlePtr,int16 param, int16 arg0, int16 arg1, int16 arg2, scriptTypeEnum scriptType);
|
||||
uint8 *attacheNewScriptToTail(int16 overlayNumber,
|
||||
scriptInstanceStruct * scriptHandlePtr, int16 param, int16 arg0,
|
||||
int16 arg1, int16 arg2, scriptTypeEnum scriptType);
|
||||
void manageScripts(scriptInstanceStruct * scriptHandle);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -31,20 +31,16 @@ stackElementStruct scriptStack[SIZE_STACK];
|
|||
|
||||
// VAR
|
||||
|
||||
void pushVar(int16 var)
|
||||
{
|
||||
if(positionInStack<SIZE_STACK)
|
||||
{
|
||||
void pushVar(int16 var) {
|
||||
if (positionInStack < SIZE_STACK) {
|
||||
scriptStack[positionInStack].data.shortVar = var;
|
||||
scriptStack[positionInStack].type = STACK_SHORT;
|
||||
positionInStack++;
|
||||
}
|
||||
}
|
||||
|
||||
int16 popVar(void)
|
||||
{
|
||||
if(positionInStack<=0)
|
||||
{
|
||||
int16 popVar(void) {
|
||||
if (positionInStack <= 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -57,20 +53,16 @@ int16 popVar(void)
|
|||
|
||||
//// PTR
|
||||
|
||||
void pushPtr(void* ptr)
|
||||
{
|
||||
if(positionInStack<SIZE_STACK)
|
||||
{
|
||||
void pushPtr(void *ptr) {
|
||||
if (positionInStack < SIZE_STACK) {
|
||||
scriptStack[positionInStack].data.ptrVar = ptr;
|
||||
scriptStack[positionInStack].type = STACK_PTR;
|
||||
positionInStack++;
|
||||
}
|
||||
}
|
||||
|
||||
void* popPtr()
|
||||
{
|
||||
if(positionInStack<=0)
|
||||
{
|
||||
void *popPtr() {
|
||||
if (positionInStack <= 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -82,4 +74,3 @@ void* popPtr()
|
|||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
|
|
@ -22,27 +22,24 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _STACK_H_
|
||||
#define _STACK_H_
|
||||
#ifndef CRUISE_STACK_H
|
||||
#define CRUISE_STACK_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
#define SIZE_STACK 0x200
|
||||
|
||||
enum stackElementTypeEnum
|
||||
{
|
||||
enum stackElementTypeEnum {
|
||||
STACK_SHORT,
|
||||
STACK_PTR
|
||||
};
|
||||
|
||||
typedef enum stackElementTypeEnum stackElementTypeEnum;
|
||||
|
||||
struct stackElementStruct
|
||||
{
|
||||
struct stackElementStruct {
|
||||
stackElementTypeEnum type;
|
||||
|
||||
union
|
||||
{
|
||||
union {
|
||||
void *ptrVar;
|
||||
int16 shortVar;
|
||||
} data;
|
||||
|
|
|
@ -26,23 +26,19 @@
|
|||
|
||||
namespace Cruise {
|
||||
|
||||
void strcpyuint8(void* dest, const void* source)
|
||||
{
|
||||
void strcpyuint8(void *dest, const void *source) {
|
||||
strcpy((char *)dest, (const char *)source);
|
||||
}
|
||||
|
||||
void strcatuint8(void* dest, const void* source)
|
||||
{
|
||||
void strcatuint8(void *dest, const void *source) {
|
||||
strcat((char *)dest, (const char *)source);
|
||||
}
|
||||
|
||||
uint8 strcmpuint8(const void* string1, const void* string2)
|
||||
{
|
||||
uint8 strcmpuint8(const void *string1, const void *string2) {
|
||||
return strcmp((char *)string1, (char *)string2);
|
||||
}
|
||||
|
||||
FILE* fopenuint8(void* name, const void* param)
|
||||
{
|
||||
FILE *fopenuint8(void *name, const void *param) {
|
||||
return fopen((char *)name, (const char *)param);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _STRING_SUPPORT_H_
|
||||
#define _STRING_SUPPORT_H_
|
||||
#ifndef CRUISE_STRING_SUPPORT_H
|
||||
#define CRSUIE_STRING_SUPPORT_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ uint16 var0 = 0;
|
|||
uint16 fadeVar;
|
||||
uint16 main15;
|
||||
|
||||
int16 readB16(void* ptr)
|
||||
{
|
||||
int16 readB16(void *ptr) {
|
||||
int16 temp;
|
||||
|
||||
temp = *(int16 *) ptr;
|
||||
|
@ -40,24 +39,21 @@ int16 readB16(void* ptr)
|
|||
return temp;
|
||||
}
|
||||
|
||||
void freeObject(cellStruct* objPtr)
|
||||
{
|
||||
if(objPtr)
|
||||
{
|
||||
void freeObject(cellStruct *objPtr) {
|
||||
if (objPtr) {
|
||||
/* if(objPtr->next)
|
||||
free(objPtr->next); */
|
||||
* free(objPtr->next); */
|
||||
|
||||
//free(objPtr);
|
||||
}
|
||||
}
|
||||
|
||||
void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int backgroundPlane, int arg)
|
||||
{
|
||||
void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct *objPtr,
|
||||
int backgroundPlane, int arg) {
|
||||
cellStruct *currentObj = objPtr->next;
|
||||
cellStruct *previous;
|
||||
|
||||
while(currentObj)
|
||||
{
|
||||
while (currentObj) {
|
||||
cellStruct *si;
|
||||
|
||||
si = currentObj;
|
||||
|
@ -65,8 +61,8 @@ void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int
|
|||
if ((si->overlay == ovlNumber || ovlNumber == -1) &&
|
||||
(si->idx == objectIdx || objectIdx == -1) &&
|
||||
(si->type == arg || arg == -1) &&
|
||||
(si->backgroundPlane == backgroundPlane || backgroundPlane == -1) )
|
||||
{
|
||||
(si->backgroundPlane == backgroundPlane
|
||||
|| backgroundPlane == -1)) {
|
||||
si->type = -1;
|
||||
}
|
||||
|
||||
|
@ -76,21 +72,18 @@ void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int
|
|||
previous = objPtr;
|
||||
currentObj = objPtr->next;
|
||||
|
||||
while(currentObj)
|
||||
{
|
||||
while (currentObj) {
|
||||
cellStruct *si;
|
||||
|
||||
si = currentObj;
|
||||
|
||||
if(si->type == -1)
|
||||
{
|
||||
if (si->type == -1) {
|
||||
cellStruct *dx;
|
||||
previous->next = si->next;
|
||||
|
||||
dx = si->next;
|
||||
|
||||
if(!si->next)
|
||||
{
|
||||
if (!si->next) {
|
||||
dx = objPtr;
|
||||
}
|
||||
|
||||
|
@ -101,32 +94,29 @@ void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int
|
|||
free(si);
|
||||
|
||||
currentObj = dx;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
currentObj = si->next;
|
||||
previous = si;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char* getText(int textIndex, int overlayIndex)
|
||||
{
|
||||
if(!overlayTable[overlayIndex].ovlData)
|
||||
{
|
||||
char *getText(int textIndex, int overlayIndex) {
|
||||
if (!overlayTable[overlayIndex].ovlData) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!overlayTable[overlayIndex].ovlData->stringTable)
|
||||
{
|
||||
if (!overlayTable[overlayIndex].ovlData->stringTable) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return overlayTable[overlayIndex].ovlData->stringTable[textIndex].string;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
@ -135,8 +125,7 @@ void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scri
|
|||
cellStruct *si = pObject->next;
|
||||
cellStruct *var_2;
|
||||
|
||||
while(si)
|
||||
{
|
||||
while (si) {
|
||||
pObject = si;
|
||||
si = si->next;
|
||||
}
|
||||
|
@ -161,12 +150,9 @@ void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scri
|
|||
pNewElement->field_18 = scriptOverlayNumber;
|
||||
pNewElement->gfxPtr = NULL;
|
||||
|
||||
if(var_2)
|
||||
{
|
||||
if (var_2) {
|
||||
cx = var_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cx = savePObject;
|
||||
}
|
||||
|
||||
|
@ -175,13 +161,9 @@ void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scri
|
|||
|
||||
ax = getText(oldVar8, overlayIdx);
|
||||
|
||||
if(ax)
|
||||
{
|
||||
if (ax) {
|
||||
pNewElement->gfxPtr = renderText(oldVar2, (uint8 *) ax);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _VARIOUS_H_
|
||||
#define _VARIOUS_H_
|
||||
#ifndef CRUISE_VARIOUS_H
|
||||
#define CRUISE_VARIOUS_H
|
||||
|
||||
#include "cruise/cell.h"
|
||||
|
||||
|
@ -35,8 +35,11 @@ extern uint16 main15;
|
|||
|
||||
int16 readB16(void *ptr);
|
||||
|
||||
void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6);
|
||||
void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int backgroundPlane, int arg);
|
||||
void createTextObject(int overlayIdx, int oldVar8, cellStruct * pObject,
|
||||
int scriptNumber, int scriptOverlayNumber, int backgroundPlane,
|
||||
int16 color, int oldVar2, int oldVar4, int oldVar6);
|
||||
void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct * objPtr,
|
||||
int backgroundPlane, int arg);
|
||||
int16 Op_InitializeStateSub(int ovlIdx, int param1, int param2);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
|
@ -89,12 +89,10 @@ cellStruct cellHead;
|
|||
|
||||
opcodeTypeFunction opcodeTypeTable[64];
|
||||
|
||||
|
||||
int16 positionInStack;
|
||||
|
||||
actorStruct actorHead;
|
||||
|
||||
|
||||
int16 setup1;
|
||||
|
||||
uint8 *currentData3DataPtr;
|
||||
|
|
|
@ -22,15 +22,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _VARS_H_
|
||||
#define _VARS_H_
|
||||
#ifndef CRUISE_VARS_H
|
||||
#define CRUISE_VARS_H
|
||||
|
||||
#include "common/file.h"
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct menuElementSubStruct
|
||||
{
|
||||
struct menuElementSubStruct {
|
||||
struct menuElementSubStruct *pNext;
|
||||
int16 var2;
|
||||
int16 var4;
|
||||
|
@ -38,8 +37,7 @@ struct menuElementSubStruct
|
|||
|
||||
typedef struct menuElementSubStruct menuElementSubStruct;
|
||||
|
||||
struct menuElementStruct
|
||||
{
|
||||
struct menuElementStruct {
|
||||
struct menuElementStruct *next;
|
||||
const char *string;
|
||||
int x;
|
||||
|
@ -56,7 +54,6 @@ typedef struct menuElementStruct menuElementStruct;
|
|||
typedef int32(*opcodeTypeFunction) (void);
|
||||
typedef int16(*opcodeFunction) (void);
|
||||
|
||||
|
||||
extern uint8 *_systemFNT;
|
||||
extern int16 fontFileIndex;
|
||||
|
||||
|
@ -74,9 +71,7 @@ extern int16 currentActiveBackgroundPlane;
|
|||
extern int16 main5;
|
||||
extern int16 var22;
|
||||
|
||||
|
||||
struct mediumVarStruct
|
||||
{
|
||||
struct mediumVarStruct {
|
||||
uint8 name[16];
|
||||
int16 field_10;
|
||||
int16 field_12;
|
||||
|
@ -90,31 +85,27 @@ struct mediumVarStruct
|
|||
|
||||
typedef struct mediumVarStruct mediumVarStruct;
|
||||
|
||||
struct filesDataStruct
|
||||
{
|
||||
struct filesDataStruct {
|
||||
uint8 *field_0;
|
||||
uint8 *field_4;
|
||||
};
|
||||
|
||||
typedef struct filesDataStruct filesDataStruct;
|
||||
|
||||
struct filesData2Struct
|
||||
{
|
||||
struct filesData2Struct {
|
||||
int16 field_0;
|
||||
int16 field_2;
|
||||
};
|
||||
|
||||
typedef struct filesData2Struct filesData2Struct;
|
||||
|
||||
struct fileName
|
||||
{
|
||||
struct fileName {
|
||||
uint8 name[13];
|
||||
};
|
||||
|
||||
typedef struct fileName fileName;
|
||||
|
||||
struct setHeaderEntry
|
||||
{
|
||||
struct setHeaderEntry {
|
||||
int16 field_0; // offset ptr part 1
|
||||
int16 field_2; // offset ptr part 2
|
||||
int16 width;
|
||||
|
@ -127,8 +118,7 @@ struct setHeaderEntry
|
|||
|
||||
typedef struct setHeaderEntry setHeaderEntry;
|
||||
|
||||
struct volumeDataStruct
|
||||
{
|
||||
struct volumeDataStruct {
|
||||
char ident[10];
|
||||
fileName *ptr;
|
||||
int16 diskNumber;
|
||||
|
@ -137,8 +127,7 @@ struct volumeDataStruct
|
|||
|
||||
typedef struct volumeDataStruct volumeDataStruct;
|
||||
|
||||
struct fileEntry
|
||||
{
|
||||
struct fileEntry {
|
||||
uint8 name[14];
|
||||
int32 offset;
|
||||
int32 size;
|
||||
|
@ -148,8 +137,7 @@ struct fileEntry
|
|||
|
||||
typedef struct fileEntry fileEntry;
|
||||
|
||||
struct dataFileEntrySub
|
||||
{
|
||||
struct dataFileEntrySub {
|
||||
uint8 *ptr;
|
||||
int16 index; // sprite index
|
||||
char name[14];
|
||||
|
@ -162,8 +150,7 @@ struct dataFileEntrySub
|
|||
|
||||
typedef struct dataFileEntrySub dataFileEntrySub;
|
||||
|
||||
struct dataFileEntry
|
||||
{
|
||||
struct dataFileEntry {
|
||||
int16 widthInColumn;
|
||||
int16 width;
|
||||
int16 resType;
|
||||
|
@ -173,8 +160,7 @@ struct dataFileEntry
|
|||
|
||||
typedef struct dataFileEntry dataFileEntry;
|
||||
|
||||
struct systemStringsStruct
|
||||
{
|
||||
struct systemStringsStruct {
|
||||
int8 param;
|
||||
uint8 string[12];
|
||||
uint8 bootScriptName[8];
|
||||
|
@ -202,7 +188,6 @@ extern int16 main22;
|
|||
extern int16 main7;
|
||||
extern int16 main8;
|
||||
|
||||
|
||||
extern int16 currentDiskNumber;
|
||||
|
||||
extern Common::File currentVolumeFile;
|
||||
|
|
|
@ -32,14 +32,12 @@ uint8* PAL_ptr = NULL;
|
|||
int16 numLoadedPal;
|
||||
int16 fileData2;
|
||||
|
||||
void loadPal(volumeDataStruct* entry)
|
||||
{
|
||||
void loadPal(volumeDataStruct *entry) {
|
||||
char name[20];
|
||||
|
||||
return;
|
||||
|
||||
if(PAL_fileHandle)
|
||||
{
|
||||
if (PAL_fileHandle) {
|
||||
fclose(PAL_fileHandle);
|
||||
}
|
||||
|
||||
|
@ -57,16 +55,14 @@ void loadPal(volumeDataStruct* entry)
|
|||
PAL_ptr = (uint8 *) malloc(numLoadedPal * fileData2);
|
||||
}
|
||||
|
||||
int getVolumeDataEntry(volumeDataStruct* entry)
|
||||
{
|
||||
int getVolumeDataEntry(volumeDataStruct *entry) {
|
||||
char buffer[256];
|
||||
int i;
|
||||
|
||||
volumeNumEntry = 0;
|
||||
volumeNumberOfEntry = 0;
|
||||
|
||||
if(currentVolumeFile.isOpen())
|
||||
{
|
||||
if (currentVolumeFile.isOpen()) {
|
||||
freeDisk();
|
||||
}
|
||||
|
||||
|
@ -76,8 +72,7 @@ int getVolumeDataEntry(volumeDataStruct* entry)
|
|||
|
||||
currentVolumeFile.open(buffer);
|
||||
|
||||
if(!currentVolumeFile.isOpen())
|
||||
{
|
||||
if (!currentVolumeFile.isOpen()) {
|
||||
return (-14);
|
||||
}
|
||||
|
||||
|
@ -93,10 +88,10 @@ int getVolumeDataEntry(volumeDataStruct* entry)
|
|||
|
||||
assert(volumeSizeOfEntry == 14 + 4 + 4 + 4 + 4);
|
||||
|
||||
volumePtrToFileDescriptor = (fileEntry*)mallocAndZero(sizeof(fileEntry) * volumeNumEntry);
|
||||
volumePtrToFileDescriptor =
|
||||
(fileEntry *) mallocAndZero(sizeof(fileEntry) * volumeNumEntry);
|
||||
|
||||
for(i=0;i<volumeNumEntry;i++)
|
||||
{
|
||||
for (i = 0; i < volumeNumEntry; i++) {
|
||||
volumePtrToFileDescriptor[i].name[0] = 0;
|
||||
volumePtrToFileDescriptor[i].offset = 0;
|
||||
volumePtrToFileDescriptor[i].size = 0;
|
||||
|
@ -104,17 +99,17 @@ int getVolumeDataEntry(volumeDataStruct* entry)
|
|||
volumePtrToFileDescriptor[i].unk3 = 0;
|
||||
}
|
||||
|
||||
for(i=0;i<volumeNumEntry;i++)
|
||||
{
|
||||
for (i = 0; i < volumeNumEntry; i++) {
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].name, 14);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].offset, 4);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].offset,
|
||||
4);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].size, 4);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].extSize, 4);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].extSize,
|
||||
4);
|
||||
currentVolumeFile.read(&volumePtrToFileDescriptor[i].unk3, 4);
|
||||
}
|
||||
|
||||
for(i=0;i<volumeNumEntry;i++)
|
||||
{
|
||||
for (i = 0; i < volumeNumEntry; i++) {
|
||||
flipLong(&volumePtrToFileDescriptor[i].offset);
|
||||
flipLong(&volumePtrToFileDescriptor[i].size);
|
||||
flipLong(&volumePtrToFileDescriptor[i].extSize);
|
||||
|
@ -125,22 +120,18 @@ int getVolumeDataEntry(volumeDataStruct* entry)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int searchFileInVolCnf(uint8* fileName,int32 diskNumber)
|
||||
{
|
||||
int searchFileInVolCnf(uint8 *fileName, int32 diskNumber) {
|
||||
int foundDisk = -1;
|
||||
int i;
|
||||
|
||||
for(i=0;i<numOfDisks;i++)
|
||||
{
|
||||
if(volumeData[i].diskNumber == diskNumber)
|
||||
{
|
||||
for (i = 0; i < numOfDisks; i++) {
|
||||
if (volumeData[i].diskNumber == diskNumber) {
|
||||
int j;
|
||||
int numOfEntry = volumeData[i].size / 13;
|
||||
|
||||
for(j=0;j<numOfEntry;j++)
|
||||
{
|
||||
if(!strcmpuint8(volumeData[i].ptr[j].name,fileName))
|
||||
{
|
||||
for (j = 0; j < numOfEntry; j++) {
|
||||
if (!strcmpuint8(volumeData[i].ptr[j].name,
|
||||
fileName)) {
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
|
@ -150,20 +141,16 @@ int searchFileInVolCnf(uint8* fileName,int32 diskNumber)
|
|||
return (foundDisk);
|
||||
}
|
||||
|
||||
int32 findFileInDisksSub1(uint8* fileName)
|
||||
{
|
||||
int32 findFileInDisksSub1(uint8 *fileName) {
|
||||
int foundDisk = -1;
|
||||
int i;
|
||||
|
||||
for(i=0;i<numOfDisks;i++)
|
||||
{
|
||||
for (i = 0; i < numOfDisks; i++) {
|
||||
int j;
|
||||
int numOfEntry = volumeData[i].size / 13;
|
||||
|
||||
for(j=0;j<numOfEntry;j++)
|
||||
{
|
||||
if(!strcmpuint8(volumeData[i].ptr[j].name,fileName))
|
||||
{
|
||||
for (j = 0; j < numOfEntry; j++) {
|
||||
if (!strcmpuint8(volumeData[i].ptr[j].name, fileName)) {
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
|
@ -172,16 +159,13 @@ int32 findFileInDisksSub1(uint8* fileName)
|
|||
return (foundDisk);
|
||||
}
|
||||
|
||||
void strToUpper(uint8* fileName)
|
||||
{
|
||||
void strToUpper(uint8 *fileName) {
|
||||
char character;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
character = *fileName;
|
||||
|
||||
if(character>='a' && character<='z')
|
||||
{
|
||||
if (character >= 'a' && character <= 'z') {
|
||||
character &= 0xDF;
|
||||
*fileName = character;
|
||||
}
|
||||
|
@ -191,14 +175,12 @@ void strToUpper(uint8* fileName)
|
|||
} while (character);
|
||||
}
|
||||
|
||||
int16 fileExist(uint8* fileName)
|
||||
{
|
||||
int16 fileExist(uint8 *fileName) {
|
||||
FILE *fHandle;
|
||||
|
||||
fHandle = fopenuint8(fileName, "rb");
|
||||
|
||||
if(fHandle)
|
||||
{
|
||||
if (fHandle) {
|
||||
fclose(fHandle);
|
||||
return (0);
|
||||
}
|
||||
|
@ -206,42 +188,35 @@ int16 fileExist(uint8* fileName)
|
|||
return (1);
|
||||
}
|
||||
|
||||
void freeDisk(void)
|
||||
{
|
||||
if(currentVolumeFile.isOpen())
|
||||
{
|
||||
void freeDisk(void) {
|
||||
if (currentVolumeFile.isOpen()) {
|
||||
currentVolumeFile.close();
|
||||
free(volumePtrToFileDescriptor);
|
||||
}
|
||||
|
||||
/* TODO
|
||||
if(PAL_fileHandle)
|
||||
{
|
||||
freeAllDataPtr();
|
||||
}
|
||||
* if(PAL_fileHandle)
|
||||
* {
|
||||
* freeAllDataPtr();
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
int16 findFileInList(uint8* fileName)
|
||||
{
|
||||
int16 findFileInList(uint8 *fileName) {
|
||||
int i;
|
||||
|
||||
if(!currentVolumeFile.isOpen())
|
||||
{
|
||||
if (!currentVolumeFile.isOpen()) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
strToUpper(fileName);
|
||||
|
||||
if(volumeNumEntry<=0)
|
||||
{
|
||||
if (volumeNumEntry <= 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
for(i=0;i<volumeNumEntry;i++)
|
||||
{
|
||||
if(!strcmpuint8(volumePtrToFileDescriptor[i].name,fileName))
|
||||
{
|
||||
for (i = 0; i < volumeNumEntry; i++) {
|
||||
if (!strcmpuint8(volumePtrToFileDescriptor[i].name, fileName)) {
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
|
@ -249,18 +224,15 @@ int16 findFileInList(uint8* fileName)
|
|||
return (-1);
|
||||
}
|
||||
|
||||
void askDisk(int16 discNumber)
|
||||
{
|
||||
void askDisk(int16 discNumber) {
|
||||
char diskNumberString[256];
|
||||
uint8 fileName[256];
|
||||
uint8 string[256];
|
||||
char messageDrawn = 0;
|
||||
|
||||
if(discNumber != -1)
|
||||
{
|
||||
if (discNumber != -1) {
|
||||
currentDiskNumber = discNumber;
|
||||
}
|
||||
|
||||
// skip drive selection stuff
|
||||
|
||||
strcpyuint8(fileName, "VOL.");
|
||||
|
@ -273,8 +245,7 @@ void askDisk(int16 discNumber)
|
|||
|
||||
// while(fileExist(fileName))
|
||||
{
|
||||
if(!messageDrawn)
|
||||
{
|
||||
if (!messageDrawn) {
|
||||
drawMsgString(string);
|
||||
messageDrawn = 1;
|
||||
}
|
||||
|
@ -283,20 +254,15 @@ void askDisk(int16 discNumber)
|
|||
changeCursor(currentCursor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16 findFileInDisks(uint8* fileName)
|
||||
{
|
||||
int16 findFileInDisks(uint8 *fileName) {
|
||||
int disk;
|
||||
int fileIdx;
|
||||
|
||||
strToUpper(fileName);
|
||||
|
||||
if(!volumeDataLoaded)
|
||||
{
|
||||
if (!volumeDataLoaded) {
|
||||
printf("CNF wasn't loaded, reading now...\n");
|
||||
if(currentVolumeFile.isOpen())
|
||||
{
|
||||
if (currentVolumeFile.isOpen()) {
|
||||
askDisk(-1);
|
||||
freeDisk();
|
||||
}
|
||||
|
@ -305,28 +271,24 @@ int16 findFileInDisks(uint8* fileName)
|
|||
readVolCnf();
|
||||
}
|
||||
|
||||
if(currentVolumeFile.isOpen())
|
||||
{
|
||||
if (currentVolumeFile.isOpen()) {
|
||||
askDisk(-1);
|
||||
}
|
||||
|
||||
fileIdx = findFileInList(fileName);
|
||||
|
||||
if(fileIdx>=0)
|
||||
{
|
||||
if (fileIdx >= 0) {
|
||||
return (fileIdx);
|
||||
}
|
||||
|
||||
disk = searchFileInVolCnf(fileName, currentDiskNumber);
|
||||
|
||||
if(disk>=0)
|
||||
{
|
||||
if (disk >= 0) {
|
||||
int temp;
|
||||
|
||||
printf("File found on disk %d\n", disk);
|
||||
|
||||
if(currentVolumeFile.isOpen())
|
||||
{
|
||||
if (currentVolumeFile.isOpen()) {
|
||||
askDisk(-1);
|
||||
}
|
||||
|
||||
|
@ -343,15 +305,12 @@ int16 findFileInDisks(uint8* fileName)
|
|||
|
||||
return (-1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int temp;
|
||||
|
||||
temp = findFileInDisksSub1(fileName);
|
||||
|
||||
if(temp>=0)
|
||||
{
|
||||
if (temp >= 0) {
|
||||
int temp2;
|
||||
|
||||
askDisk(volumeData[temp].diskNumber);
|
||||
|
@ -364,21 +323,18 @@ int16 findFileInDisks(uint8* fileName)
|
|||
return (temp2);
|
||||
}
|
||||
|
||||
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
int16 readVolCnf(void)
|
||||
{
|
||||
int16 readVolCnf(void) {
|
||||
int i;
|
||||
Common::File fileHandle;
|
||||
short int sizeHEntry;
|
||||
|
||||
volumeDataLoaded = 0;
|
||||
|
||||
for(i=0;i<20;i++)
|
||||
{
|
||||
for (i = 0; i < 20; i++) {
|
||||
volumeData[i].ident[0] = 0;
|
||||
volumeData[i].ptr = NULL;
|
||||
volumeData[i].diskNumber = i + 1;
|
||||
|
@ -387,8 +343,7 @@ int16 readVolCnf(void)
|
|||
|
||||
fileHandle.open("VOL.CNF");
|
||||
|
||||
if(!fileHandle.isOpen())
|
||||
{
|
||||
if (!fileHandle.isOpen()) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -398,8 +353,7 @@ int16 readVolCnf(void)
|
|||
fileHandle.read(&sizeHEntry, 2);
|
||||
flipShort(&sizeHEntry); // size of one header entry - 20 bytes
|
||||
|
||||
for(i=0;i<numOfDisks;i++)
|
||||
{
|
||||
for (i = 0; i < numOfDisks; i++) {
|
||||
// fread(&volumeData[i],20,1,fileHandle);
|
||||
fileHandle.read(&volumeData[i].ident, 10);
|
||||
fileHandle.read(&volumeData[i].ptr, 4);
|
||||
|
@ -411,8 +365,7 @@ int16 readVolCnf(void)
|
|||
flipLong(&volumeData[i].size);
|
||||
}
|
||||
|
||||
for(i=0;i<numOfDisks;i++)
|
||||
{
|
||||
for (i = 0; i < numOfDisks; i++) {
|
||||
fileName *ptr;
|
||||
|
||||
fileHandle.read(&volumeData[i].size, 4);
|
||||
|
@ -422,8 +375,7 @@ int16 readVolCnf(void)
|
|||
|
||||
volumeData[i].ptr = ptr;
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
fileHandle.close();
|
||||
return (-2);
|
||||
}
|
||||
|
@ -438,8 +390,7 @@ int16 readVolCnf(void)
|
|||
//#define dumpResources
|
||||
#ifdef dumpResources
|
||||
|
||||
for(i=0;i<numOfDisks;i++)
|
||||
{
|
||||
for (i = 0; i < numOfDisks; i++) {
|
||||
int j;
|
||||
char nameBuffer[256];
|
||||
fileEntry *buffer;
|
||||
|
@ -461,8 +412,7 @@ int16 readVolCnf(void)
|
|||
|
||||
fread(buffer, numEntry * sizeEntry, 1, fileHandle);
|
||||
|
||||
for(j=0;j<numEntry;j++)
|
||||
{
|
||||
for (j = 0; j < numEntry; j++) {
|
||||
flipLong(&buffer[j].offset);
|
||||
flipLong(&buffer[j].size);
|
||||
flipLong(&buffer[j].unk2);
|
||||
|
@ -477,22 +427,26 @@ int16 readVolCnf(void)
|
|||
|
||||
char nameBuffer[256];
|
||||
|
||||
sprintf(nameBuffer,"D%d.dmp/%s",i+1,buffer[j].name);
|
||||
sprintf(nameBuffer, "D%d.dmp/%s", i + 1,
|
||||
buffer[j].name);
|
||||
|
||||
if(buffer[j].size == buffer[j].unk2)
|
||||
{
|
||||
if (buffer[j].size == buffer[j].unk2) {
|
||||
FILE *fOut = fopen(nameBuffer, "wb+");
|
||||
fwrite(bufferLocal, buffer[j].size, 1, fOut);
|
||||
fclose(fOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* uncompBuffer = (char*)mallocAndZero(buffer[j].unk2+500);
|
||||
} else {
|
||||
char *uncompBuffer =
|
||||
(char *)mallocAndZero(buffer[j].unk2 +
|
||||
500);
|
||||
|
||||
decomp((uint8*)bufferLocal+buffer[j].size-4,(uint8*)uncompBuffer+buffer[j].unk2+500,buffer[j].unk2);
|
||||
decomp((uint8 *) bufferLocal + buffer[j].size -
|
||||
4,
|
||||
(uint8 *) uncompBuffer + buffer[j].unk2 +
|
||||
500, buffer[j].unk2);
|
||||
|
||||
FILE *fOut = fopen(nameBuffer, "wb+");
|
||||
fwrite(uncompBuffer+500,buffer[j].unk2,1,fOut);
|
||||
fwrite(uncompBuffer + 500, buffer[j].unk2, 1,
|
||||
fOut);
|
||||
fclose(fOut);
|
||||
|
||||
//free(uncompBuffer);
|
||||
|
@ -510,8 +464,7 @@ int16 readVolCnf(void)
|
|||
|
||||
///////////////////////////::
|
||||
|
||||
void drawMsgString(uint8* string)
|
||||
{
|
||||
void drawMsgString(uint8 *string) {
|
||||
//printf("%s\n",string);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef _VOLUME_H_
|
||||
#define _VOLUME_H_
|
||||
#ifndef CRUISE_VOLUME_H
|
||||
#define CRUISE_VOLUME_H
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue