Implement more object input

svn-id: r29317
This commit is contained in:
Vincent Hamm 2007-10-29 22:03:55 +00:00
parent 1bf448ac37
commit caa451f5d2
11 changed files with 193 additions and 66 deletions

View File

@ -156,7 +156,8 @@ cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 typ
return newElement;
}
void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6) {
void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x, int y, int width, int16 color, int backgroundPlane, int parentOvl, int parentIdx)
{
char *ax;
cellStruct *savePObject = pObject;
@ -178,17 +179,17 @@ void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scri
pNewElement->next = pObject->next;
pObject->next = pNewElement;
pNewElement->idx = oldVar8;
pNewElement->idx = messageIdx;
pNewElement->type = 5;
pNewElement->backgroundPlane = backgroundPlane;
pNewElement->overlay = overlayIdx;
pNewElement->x = oldVar6;
pNewElement->field_C = oldVar4;
pNewElement->spriteIdx = oldVar2;
pNewElement->x = x;
pNewElement->field_C = y;
pNewElement->spriteIdx = width;
pNewElement->color = color;
pNewElement->freeze = 0;
pNewElement->parent = scriptNumber;
pNewElement->parentOverlay = scriptOverlayNumber;
pNewElement->parent = parentIdx;
pNewElement->parentOverlay = parentOvl;
pNewElement->gfxPtr = NULL;
if (var_2) {
@ -200,10 +201,10 @@ void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scri
pNewElement->prev = cx->prev;
cx->prev = pNewElement;
ax = getText(oldVar8, overlayIdx);
ax = getText(messageIdx, overlayIdx);
if (ax) {
pNewElement->gfxPtr = renderText(oldVar2, (uint8 *) ax);
pNewElement->gfxPtr = renderText(width, (uint8 *) ax);
}
}

View File

@ -67,7 +67,7 @@ extern cellStruct cellHead;
void resetPtr(cellStruct * ptr);
void loadSavegameDataSub2(FILE * f);
cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 type, int16 backgroundPlane, int16 scriptOverlay, int16 scriptNumber, int16 scriptType);
void createTextObject(int overlayIdx, int oldVar8, cellStruct * pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6);
void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x, int y, int width, int16 color, int backgroundPlane, int parentOvl, int parentIdx);
void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane );
void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze );
void sortCells(int16 param1, int16 param2, cellStruct *objPtr);

View File

@ -164,12 +164,12 @@ int getProcParam(int overlayIdx, int param2, uint8 *name) {
return 0;
}
void changeScriptParamInList(int param1, int param2, scriptInstanceStruct *pScriptInstance, int newValue, int param3) {
void changeScriptParamInList(int param1, int param2, scriptInstanceStruct *pScriptInstance, int oldFreeze, int newValue) {
pScriptInstance = pScriptInstance->nextScriptPtr;
while (pScriptInstance) {
if ((pScriptInstance->overlayNumber == param1) || (param1 == -1))
if ((pScriptInstance->scriptNumber == param2) || (param2 == -1))
if ((pScriptInstance->freeze == param3) || (param3 == -1)) {
if ((pScriptInstance->freeze == oldFreeze) || (oldFreeze == -1)) {
pScriptInstance->freeze = newValue;
}
@ -1022,6 +1022,12 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj)
}
}
int findHighColor()
{
printf("Unimplemented findHighColor\n");
return 1;
}
void callRelation(menuElementSubStruct *pMenuElement, int nObj2)
{
if(pMenuElement == NULL)
@ -1038,6 +1044,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2)
if(pHeader->obj2Number == nObj2)
{
// REL
if(pHeader->type == 30)
{
attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL);
@ -1056,7 +1063,11 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2)
}
else if((pHeader->field_12 == 9999) && (pHeader->field_14 == 9999))
{
ASSERT(0);
objectParamsQuery naratorParams;
getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
pTrack->x_dest = naratorParams.X;
pTrack->y_dest = naratorParams.Y;
pTrack->endDirection = pHeader->field_1E;
}
else
{
@ -1069,13 +1080,92 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2)
autoTrack = true;
userEnabled = 0;
changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 9998, 0);
changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 0, 9998);
}
}
}
else
// MSG
else if(pHeader->type == 50)
{
ASSERT(0);
int obj1Ovl = pHeader->obj1Overlay;
if(!obj1Ovl)
obj1Ovl = ovlIdx;
int x = 60;
int y = 40;
if(pHeader->obj1Number >= 0)
{
objectParamsQuery params;
getMultipleObjectParam(obj1Ovl, pHeader->obj1Number, &params);
if(narratorOvl > 0)
{
if((pHeader->field_12 !=-1) && (pHeader->field_14 != -1) && (pHeader->field_12 != 9999) && (pHeader->field_14 != 9999))
{
x = pHeader->field_12 - 100;
y = pHeader->field_14 - 150;
}
else
{
getMultipleObjectParam(narratorOvl, narratorIdx, &params);
x = params.X - 100;
y = params.Y - 150;
}
}
else if(params.scale >= 0)
{
x = params.X - 100;
y = params.Y - 40;
}
if(pHeader->field_16 != -1)
{
ASSERT(0);
}
}
createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), currentActiveBackgroundPlane, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber);
userWait = 1;
autoOvl = ovlIdx;
autoMsg = pHeader->id;
if((narratorOvl > 0) && (pHeader->field_12 != -1) && (pHeader->field_14 != -1))
{
actorStruct* pTrack = findActor(&actorHead, narratorOvl, narratorIdx, 0);
if(pTrack)
{
animationStart = false;
if(pHeader->field_1E == 9999)
{
ASSERT(0);
}
else if((pHeader->field_12 == 9999) && (pHeader->field_14 == 9999))
{
objectParamsQuery naratorParams;
getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
pTrack->x_dest = naratorParams.X;
pTrack->y_dest = naratorParams.Y;
pTrack->endDirection = pHeader->field_1E;
}
else
{
pTrack->x_dest = pHeader->field_12;
pTrack->y_dest = pHeader->field_14;
pTrack->endDirection = pHeader->field_1E;
}
pTrack->flag = 1;
autoTrack = true;
userWait = 0;
userEnabled = 0;
freezeCell(&cellHead, ovlIdx, pHeader->id, 5, -1, 0, 9998);
}
}
}
}
else
@ -1482,12 +1572,12 @@ void mainLoop(void) {
systemStrings.bootScriptName[0] = 0;
initVar4[0] = 0;
currentActiveMenu = -1;
main14 = -1;
autoMsg = -1;
linkedRelation = 0;
main21 = 0;
main22 = 0;
main7 = 0;
main8 = 0;
userWait = 0;
autoTrack = 0;
autoTrack = 0;
if (initAllData()) {
@ -1547,7 +1637,7 @@ void mainLoop(void) {
mainDraw(0);
flipScreen();
if (userEnabled && !main7 && !autoTrack)
if (userEnabled && !userWait && !autoTrack)
{
if(currentActiveMenu == -1)
{
@ -1596,8 +1686,31 @@ void mainLoop(void) {
changeCursor(CURSOR_NORMAL);
}
if (main7) {
ASSERT(0);
if (userWait)
{
int16 button = 0;
while(!button)
{
manageScripts(&relHead);
manageScripts(&procHead);
removeFinishedScripts(&relHead);
removeFinishedScripts(&procHead);
processAnimation();
// not exactly this
manageEvents();
int16 mouseVar;
int16 mouseX;
int16 mouseY;
getMouseStatus(&mouseVar, &mouseX, &button, &mouseY);
}
changeScriptParamInList(-1, -1, &procHead, 9999, 0);
changeScriptParamInList(-1, -1, &relHead, 9999, 0);
userWait = 0;
}
// wait for character to finish auto track
@ -1605,9 +1718,14 @@ void mainLoop(void) {
{
if(mainProc13(narratorOvl, narratorIdx, &actorHead, 0))
{
if(main14 != -1)
if(autoMsg != -1)
{
ASSERT(0);
freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0);
char* pText = getText(autoMsg, autoOvl);
if(strlen(pText))
userWait = 1;
}
changeScriptParamInList(-1, -1, &relHead, 9998, 0);
@ -1619,9 +1737,10 @@ void mainLoop(void) {
userEnabled = false;
}
}
if (main14 != -1) {
ASSERT(0);
else if (autoMsg != -1)
{
removeCell(&cellHead, autoOvl, autoMsg, 5, currentActiveBackgroundPlane );
autoMsg = -1;
}
}
// t_end = t_start+SPEED;

View File

@ -81,7 +81,7 @@ namespace Cruise {
extern gfxEntryStruct* linkedMsgList;
bool delphineUnpack(byte *dst, const byte *src, int len);
int findHighColor();
ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param);
ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param);
int16 loadShort(void *ptr);

View File

@ -405,10 +405,9 @@ int16 Op_changeCutSceneState(void) {
int16 Op_62(void) {
if (currentScriptPtr->var1A == 20) {
changeScriptParamInList(currentScriptPtr->var18, currentScriptPtr->var16, &procHead, 9997, -1);
changeScriptParamInList(currentScriptPtr->var18, currentScriptPtr->var16, &procHead, -1, 9997);
} else if (currentScriptPtr->var1A == 30) {
changeScriptParamInList(currentScriptPtr->var18,
currentScriptPtr->var16, &relHead, 9997, -1);
changeScriptParamInList(currentScriptPtr->var18, currentScriptPtr->var16, &relHead, -1, 9997);
}
return 0;
@ -645,11 +644,9 @@ int16 Op_SetFontFileIndex(void) {
int16 Op_63(void) {
if (currentScriptPtr->var1A == 0x14) {
changeScriptParamInList(currentScriptPtr->var18,
currentScriptPtr->var16, &procHead, 0, -1);
changeScriptParamInList(currentScriptPtr->var18, currentScriptPtr->var16, &procHead, -1, 0);
} else if (currentScriptPtr->var1A == 0x1E) {
changeScriptParamInList(currentScriptPtr->var18,
currentScriptPtr->var16, &relHead, 0, -1);
changeScriptParamInList(currentScriptPtr->var18, currentScriptPtr->var16, &relHead, -1, 0);
}
return 0;
@ -680,19 +677,14 @@ int16 Op_AddMessage(void) {
overlayIdx = currentScriptPtr->overlayNumber;
if (color == -1) {
color = 1;
printf("Unimplemented automatic message color\n");
// ASSERT(0);
//color = calcTabSomething();
color = findHighColor();
} else {
if (CVTLoaded) {
color = cvtPalette[color];
}
}
createTextObject(overlayIdx, var_8, &cellHead,
currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber,
currentActiveBackgroundPlane, color, var_2, var_4, var_6);
createTextObject(&cellHead, overlayIdx, var_8, var_6, var_4, var_2, color, currentActiveBackgroundPlane, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber);
return 0;
}
@ -764,9 +756,9 @@ int16 Op_AutoCell(void) {
if (type) {
if (currentScriptPtr->type == scriptType_PROC) {
changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &procHead, 9996, -1);
changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &procHead, -1, 9996);
} else if (currentScriptPtr->type == scriptType_REL) {
changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &relHead, 9996, -1);
changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &relHead, -1, 9996);
}
}

View File

@ -941,18 +941,35 @@ void mainDraw(int16 param) {
if (currentObjPtr->animType) { // should we resume the script ?
if (currentObjPtr->parentType == 20) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, 0, -1);
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
} else if (currentObjPtr->parentType == 30) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, 0, -1);
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
}
}
}
}
} else {
ASSERT(0);
/* if (currentObjPtr->field_22>newVal)
* {
* } */
if (newVal < currentObjPtr->animEnd) {
if (currentObjPtr->animLoop) {
newVal = currentObjPtr->animStart;
if (currentObjPtr->animLoop>0)
currentObjPtr->animLoop--;
} else {
int16 data2;
data2 = currentObjPtr->animStart;
change = false;
currentObjPtr->animStep = 0;
if (currentObjPtr->animType) { // should we resume the script ?
if (currentObjPtr->parentType == 20) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
} else if (currentObjPtr->parentType == 30) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
}
}
}
}
}
if (currentObjPtr->animWait >= 0) {
@ -961,9 +978,9 @@ void mainDraw(int16 param) {
if ((currentObjPtr->animSignal >= 0) && (currentObjPtr->animSignal == newVal) && (currentObjPtr->animType != 0)) {
if (currentObjPtr->parentType == 20) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, 0, -1);
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
} else if (currentObjPtr->parentType == 30) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, 0, -1);
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
}
currentObjPtr->animType = 0;

View File

@ -238,10 +238,10 @@ int loadSavegameData(int saveGameIdx) {
fread(&setup1, 2, 1, fileHandle);
fread(&fontFileIndex, 2, 1, fileHandle);
fread(&currentActiveMenu, 2, 1, fileHandle);
fread(&main7, 2, 1, fileHandle); // ok
fread(&main17, 2, 1, fileHandle);
fread(&main14, 2, 1, fileHandle);
fread(&main8, 2, 1, fileHandle);
fread(&userWait, 2, 1, fileHandle); // ok
fread(&autoOvl, 2, 1, fileHandle);
fread(&autoMsg, 2, 1, fileHandle);
fread(&autoTrack, 2, 1, fileHandle);
fread(&var39, 2, 1, fileHandle);
fread(&var42, 2, 1, fileHandle);
fread(&var45, 2, 1, fileHandle);

View File

@ -29,7 +29,6 @@ namespace Cruise {
uint16 var0 = 0;
uint16 fadeVar;
uint16 autoTrack;
int16 readB16(void *ptr) {
int16 temp;

View File

@ -32,7 +32,6 @@ namespace Cruise {
extern uint16 var0;
extern uint16 fadeVar;
extern uint16 autoTrack;
int16 readB16(void *ptr);

View File

@ -56,12 +56,12 @@ int16 numOfDisks;
uint8 scriptNameBuffer[15];
int16 currentActiveMenu;
int16 main14;
int16 autoMsg;
menuElementSubStruct* linkedRelation;
int16 main21;
int16 main22;
int16 main7;
int16 main8;
int16 userWait;
int16 autoTrack;
int16 currentDiskNumber = 1;
@ -131,7 +131,7 @@ int16 aniX;
int16 aniY;
bool animationStart;
int16 main17;
int16 autoOvl;
int16 var39;
int16 entrerMenuJoueur;
int16 var41;

View File

@ -158,12 +158,12 @@ extern int16 numOfDisks;
extern uint8 scriptNameBuffer[15];
extern int16 currentActiveMenu;
extern int16 main14;
extern int16 autoMsg;
extern menuElementSubStruct* linkedRelation;
extern int16 main21;
extern int16 main22;
extern int16 main7;
extern int16 main8;
extern int16 userWait;
extern int16 autoTrack;
extern int16 currentDiskNumber;
@ -230,7 +230,7 @@ extern int16 aniX;
extern int16 aniY;
extern bool animationStart;
extern int16 main17;
extern int16 autoOvl;
extern int16 var39;
extern int16 entrerMenuJoueur;
extern int16 var39;