Ticket #8911: cruise_64bits.patch
File cruise_64bits.patch, 14.3 KB (added by , 16 years ago) |
---|
-
engines/cruise/cruise_main.cpp
243 243 return NULL; 244 244 } 245 245 246 return ((ovlData3Struct *) (ovlData->ptr1 + param * 0x1C));246 return &ovlData->ptr1[param]; 247 247 } 248 248 249 249 void scriptFunc2(int scriptNumber, scriptInstanceStruct * scriptHandle, -
engines/cruise/vars.h
91 91 }; 92 92 93 93 struct setHeaderEntry { 94 int16 field_0; // offset ptr part 1 95 int16 field_2; // offset ptr part 2 94 int32 field_0; // offset ptr 96 95 int16 width; 97 96 int16 height; 98 97 int16 type; // resource type, ie. sprites 0,1,4,5 and 8 -
engines/cruise/overlay.cpp
131 131 132 132 ovlData = overlayTable[scriptIdx].ovlData; 133 133 134 memcpy(ovlData, scriptPtr, sizeof(ovlDataStruct));135 136 134 ovlData->arrayProc = NULL; 137 135 ovlData->ptr1 = NULL; 138 136 ovlData->arrayObject = NULL; … … 233 231 } 234 232 235 233 if (ovlData->numMsgRelHeader) { // link data 234 int i; 236 235 ASSERT(sizeof(linkDataStruct) == 0x22); 237 236 238 237 ovlData->arrayMsgRelHeader = (linkDataStruct *) mallocAndZero(ovlData->numMsgRelHeader * sizeof(linkDataStruct)); … … 241 240 return (-2); 242 241 } 243 242 244 memcpy(ovlData->arrayMsgRelHeader, scriptPtr, ovlData->numMsgRelHeader * sizeof(linkDataStruct)); 245 scriptPtr += ovlData->numMsgRelHeader * sizeof(linkDataStruct); 246 flipGen(ovlData->arrayMsgRelHeader, ovlData->numMsgRelHeader * sizeof(linkDataStruct)); 243 for (i = 0; i < ovlData->numMsgRelHeader; i++) { 244 ovlData->arrayMsgRelHeader[i].type = readB16(scriptPtr); 245 ovlData->arrayMsgRelHeader[i].id = readB16(scriptPtr + 2); 246 ovlData->arrayMsgRelHeader[i].offsetVerbeName = readB16(scriptPtr + 4); 247 ovlData->arrayMsgRelHeader[i].verbOverlay = readB16(scriptPtr + 6); 248 ovlData->arrayMsgRelHeader[i].verbNumber = readB16(scriptPtr + 8); 249 250 ovlData->arrayMsgRelHeader[i].obj1Overlay = readB16(scriptPtr + 10); 251 ovlData->arrayMsgRelHeader[i].obj1Number = readB16(scriptPtr + 12); 252 ovlData->arrayMsgRelHeader[i].obj2Overlay = readB16(scriptPtr + 14); 253 ovlData->arrayMsgRelHeader[i].obj2Number = readB16(scriptPtr + 16); 254 255 ovlData->arrayMsgRelHeader[i].trackX = readB16(scriptPtr + 18); 256 ovlData->arrayMsgRelHeader[i].trackY = readB16(scriptPtr + 20); 257 258 ovlData->arrayMsgRelHeader[i].obj1NewState = readB16(scriptPtr + 22); 259 ovlData->arrayMsgRelHeader[i].obj2NewState = readB16(scriptPtr + 24); 260 261 ovlData->arrayMsgRelHeader[i].obj1OldState = readB16(scriptPtr + 26); 262 ovlData->arrayMsgRelHeader[i].obj2OldState = readB16(scriptPtr + 28); 263 264 ovlData->arrayMsgRelHeader[i].trackDirection = readB16(scriptPtr + 30); 265 ovlData->arrayMsgRelHeader[i].dialog = readB16(scriptPtr + 32); 266 267 scriptPtr += 34; 268 } 247 269 } 248 270 249 271 if (ovlData->numProc) { // script … … 251 273 int i; 252 274 253 275 ovlData->arrayProc = 254 (ovlData3Struct *) mallocAndZero(ovlData->numProc * 255 sizeof(ovlData3Struct)); 276 (ovlData3Struct *) mallocAndZero(ovlData->numProc * sizeof(ovlData3Struct)); 256 277 257 278 if (!ovlData->arrayProc) { 258 /* releaseScript(scriptIdx,scriptName);259 260 if (freeIsNeeded) {261 freePtr(unpackedBuffer);262 } */263 264 279 return (-2); 265 280 } 266 281 267 memcpy(ovlData->arrayProc, scriptPtr, 268 ovlData->numProc * sizeof(ovlData3Struct)); 269 scriptPtr += ovlData->numProc * 0x1C; 282 for (i = 0; i < ovlData->numProc; i++) { 283 ovlData->arrayProc[i].dataPtr = NULL; 284 ovlData->arrayProc[i].sizeOfData = readB16(scriptPtr + 4); 285 ovlData->arrayProc[i].offsetToSubData3 = readB16(scriptPtr + 6); 286 ovlData->arrayProc[i].offsetToImportData = readB16(scriptPtr + 8); 287 ovlData->arrayProc[i].offsetToSubData2 = readB16(scriptPtr + 10); 288 ovlData->arrayProc[i].offsetToImportName = readB16(scriptPtr + 12); 289 ovlData->arrayProc[i].offsetToSubData5 = readB16(scriptPtr + 14); 290 ovlData->arrayProc[i].sysKey = readB16(scriptPtr + 16); 291 ovlData->arrayProc[i].var12 = readB16(scriptPtr + 18); 292 ovlData->arrayProc[i].numRelocGlob = readB16(scriptPtr + 20); 293 ovlData->arrayProc[i].subData2Size = readB16(scriptPtr + 22); 294 ovlData->arrayProc[i].var18 = readB16(scriptPtr + 24); 295 ovlData->arrayProc[i].var1A = readB16(scriptPtr + 26); 296 297 scriptPtr += 28; 298 } 270 299 271 flipGen(ovlData->arrayProc,272 ovlData->numProc * sizeof(ovlData3Struct));273 274 300 tempPtr = ovlData->arrayProc; 275 301 276 302 for (i = 0; i < ovlData->numProc; i++) { 277 uint8 *ptr = tempPtr->dataPtr = 278 (uint8 *) mallocAndZero(tempPtr->sizeOfData); 303 uint8 *ptr = tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData); 279 304 280 305 if (!ptr) { 281 /* releaseScript(scriptIdx,scriptName);282 *283 * if (freeIsNeeded)284 * {285 * freePtr(unpackedBuffer);286 * } */287 288 306 return (-2); 289 307 } 290 308 … … 297 315 } 298 316 299 317 if (tempPtr->offsetToSubData2) { 300 flipGen(ptr + tempPtr->offsetTo ImportData,318 flipGen(ptr + tempPtr->offsetToSubData2, 301 319 tempPtr->subData2Size * 10); 302 320 } 303 321 … … 310 328 int i; 311 329 312 330 ovlData->ptr1 = 313 ( uint8 *) mallocAndZero(ovlData->numRel * 0x1C);331 (ovlData3Struct *) mallocAndZero(ovlData->numRel * sizeof(ovlData3Struct)); 314 332 315 333 if (!ovlData->ptr1) { 316 334 return (-2); 317 335 } 318 336 319 memcpy(ovlData->ptr1, scriptPtr, ovlData->numRel * 0x1C); 320 scriptPtr += ovlData->numRel * 0x1C; 321 flipGen(ovlData->ptr1, ovlData->numRel * 0x1C); 337 for (i = 0; i < ovlData->numRel; i++) { 322 338 339 ovlData->ptr1[i].dataPtr = NULL; 340 ovlData->ptr1[i].sizeOfData = readB16(scriptPtr + 4); 341 ovlData->ptr1[i].offsetToSubData3 = readB16(scriptPtr + 6); 342 ovlData->ptr1[i].offsetToImportData = readB16(scriptPtr + 8); 343 ovlData->ptr1[i].offsetToSubData2 = readB16(scriptPtr + 10); 344 ovlData->ptr1[i].offsetToImportName = readB16(scriptPtr + 12); 345 ovlData->ptr1[i].offsetToSubData5 = readB16(scriptPtr + 14); 346 ovlData->ptr1[i].sysKey = readB16(scriptPtr + 16); 347 ovlData->ptr1[i].var12 = readB16(scriptPtr + 18); 348 ovlData->ptr1[i].numRelocGlob = readB16(scriptPtr + 20); 349 ovlData->ptr1[i].subData2Size = readB16(scriptPtr + 22); 350 ovlData->ptr1[i].var18 = readB16(scriptPtr + 24); 351 ovlData->ptr1[i].var1A = readB16(scriptPtr + 26); 352 353 scriptPtr += 28; 354 } 355 323 356 tempPtr = (ovlData3Struct *) ovlData->ptr1; 324 357 325 358 for (i = 0; i < ovlData->numRel; i++) { … … 327 360 (uint8 *) mallocAndZero(tempPtr->sizeOfData); 328 361 329 362 if (!ptr) { 330 /* releaseScript(scriptIdx,scriptName);331 *332 * if (freeIsNeeded)333 * {334 * freePtr(unpackedBuffer);335 * } */336 337 363 return (-2); 338 364 } 339 365 … … 346 372 } 347 373 348 374 if (tempPtr->offsetToSubData2) { 349 flipGen(ptr + tempPtr->offsetTo ImportData,375 flipGen(ptr + tempPtr->offsetToSubData2, 350 376 tempPtr->subData2Size * 10); 351 377 } 352 378 … … 378 404 sizeof(objDataStruct)); 379 405 380 406 if (!ovlData->arrayObject) { 381 /* releaseScript(scriptIdx,scriptName);382 383 if (freeIsNeeded) {384 freePtr(unpackedBuffer);385 } */386 387 407 return (-2); 388 408 } 389 409 390 410 for (i = 0; i < ovlData->numObj; i++) { 391 ovlData->arrayObject[i]._type = *(int16 *) scriptPtr; 392 scriptPtr += 2; 393 flipShort(&ovlData->arrayObject[i]._type); 394 395 int16 tempClass = *(int16 *) scriptPtr; 396 flipShort(&tempClass); 397 ovlData->arrayObject[i]._class = (eClass)tempClass; 398 scriptPtr += 2; 399 400 ovlData->arrayObject[i]._nameOffset = *(int16 *) scriptPtr; 401 scriptPtr += 2; 402 flipShort(&ovlData->arrayObject[i]._nameOffset); 403 404 ovlData->arrayObject[i]._numStates = *(int16 *) scriptPtr; 405 scriptPtr += 2; 406 flipShort(&ovlData->arrayObject[i]._numStates); 407 408 ovlData->arrayObject[i]._varTableIdx = *(int16 *) scriptPtr; 409 scriptPtr += 2; 410 flipShort(&ovlData->arrayObject[i]._varTableIdx); 411 412 ovlData->arrayObject[i]._firstStateIdx = *(int16 *) scriptPtr; 413 scriptPtr += 2; 414 flipShort(&ovlData->arrayObject[i]._firstStateIdx); 415 416 ovlData->arrayObject[i]._stateTableIdx = *(int16 *) scriptPtr; 417 scriptPtr += 2; 418 flipShort(&ovlData->arrayObject[i]._stateTableIdx); 411 ovlData->arrayObject[i]._type = readB16(scriptPtr); 412 ovlData->arrayObject[i]._class = (eClass) readB16(scriptPtr + 2); 413 ovlData->arrayObject[i]._nameOffset = readB16(scriptPtr + 4); 414 ovlData->arrayObject[i]._numStates = readB16(scriptPtr + 6); 415 ovlData->arrayObject[i]._varTableIdx = readB16(scriptPtr + 8); 416 ovlData->arrayObject[i]._firstStateIdx = readB16(scriptPtr + 10); 417 ovlData->arrayObject[i]._stateTableIdx =readB16(scriptPtr + 12); 418 419 scriptPtr += 14; 419 420 } 420 421 421 // alloc te states for object with multiple states422 // allocate states for object with multiple states 422 423 423 424 if (scriptNotLoadedBefore) { 424 425 overlayTable[scriptIdx].state = stateID; … … 430 431 ovlData->arrayObjVar = 431 432 (objectParams *) mallocAndZero(ovlData->size9 * 432 433 sizeof(objectParams)); 433 memset(ovlData->arrayObjVar, 0,434 ovlData->size9 * sizeof(objectParams));435 434 436 435 if (!ovlData->arrayObjVar) { 437 /* releaseScript(scriptIdx,scriptName);438 439 if (freeIsNeeded) {440 freePtr(unpackedBuffer);441 } */442 443 436 return (-2); 444 437 } 445 438 } 446 439 447 440 if (ovlData->size8) { 441 int i; 448 442 ovlData->arrayStates = 449 443 (objectParams *) mallocAndZero(ovlData->size8 * 450 444 sizeof(objectParams)); 451 445 452 446 if (!ovlData->arrayStates) { 453 /* releaseScript(scriptIdx,scriptName);454 455 if (freeIsNeeded) {456 freePtr(unpackedBuffer);457 } */458 459 447 return (-2); 460 448 } 461 449 462 memcpy(ovlData->arrayStates, scriptPtr, ovlData->size8 * 12); // TODO: made read item by item 463 scriptPtr += ovlData->size8 * 12; 464 flipGen(ovlData->arrayStates, ovlData->size8 * 12); 450 for (i = 0; i < ovlData->size8; i++) { 451 ovlData->arrayStates[i].X = readB16(scriptPtr); 452 ovlData->arrayStates[i].Y = readB16(scriptPtr + 2); 453 ovlData->arrayStates[i].Z = readB16(scriptPtr + 4); 454 ovlData->arrayStates[i].frame = readB16(scriptPtr + 6); 455 ovlData->arrayStates[i].scale = readB16(scriptPtr + 8); 456 ovlData->arrayStates[i].state = readB16(scriptPtr + 10); 457 458 scriptPtr += 12; 459 } 465 460 } 466 461 467 462 if (ovlData->numStrings) { … … 472 467 sizeof(stringEntryStruct)); 473 468 474 469 for (i = 0; i < ovlData->numStrings; i++) { 475 ovlData->stringTable[i].idx = *(int16 *) scriptPtr; 476 flipShort(&ovlData->stringTable[i].idx); 470 ovlData->stringTable[i].idx = readB16(scriptPtr); 477 471 scriptPtr += 2; 478 472 } 479 473 } 480 474 481 /* if (freeIsNeeded) {482 freePtr(unpackedBuffer);483 } */484 485 475 if (ovlData->sizeOfData4) { 486 476 ovlData->data4Ptr = 487 477 (uint8 *) mallocAndZero(ovlData->sizeOfData4); 488 memset(ovlData->data4Ptr, 0, ovlData->sizeOfData4);489 478 490 479 if (!ovlData->data4Ptr) { 491 //releaseScript(scriptIdx,scriptName);492 480 return (-2); 493 481 } 494 482 } -
engines/cruise/various.cpp
39 39 return temp; 40 40 } 41 41 42 int32 readB32(void *ptr) { 43 int32 temp; 44 45 temp = *(int32 *) ptr; 46 flipLong(&temp); 47 48 return temp; 49 } 50 42 51 char *getText(int textIndex, int overlayIndex) { 43 52 if (!overlayTable[overlayIndex].ovlData) { 44 53 return NULL; -
engines/cruise/dataLoader.cpp
440 440 441 441 ptr4 = ptr + offset + 6; 442 442 443 memcpy(&localBuffer, ptr4, sizeof(setHeaderEntry)); 443 localBuffer.field_0 = readB32(ptr4); 444 localBuffer.width = readB16(ptr4 + 4); 445 localBuffer.height = readB16(ptr4 + 6); 446 localBuffer.type = readB16(ptr4 + 8); 447 localBuffer.transparency = readB16(ptr4 + 10); 448 localBuffer.field_C = readB16(ptr4 + 12); 449 localBuffer.field_E = readB16(ptr4 + 14); 444 450 445 flipLong((int32 *) & localBuffer.field_0);446 flipGen(&localBuffer.width, 12);447 448 451 if (sec == 1) { 449 452 localBuffer.width = localBuffer.width - (localBuffer.type * 2); // Type 1: Width - (1*2) , Type 5: Width - (5*2) 450 453 } -
engines/cruise/ctp.cpp
153 153 int16* a2; 154 154 155 155 a1 = a2 = (int16*)str; 156 a2 += 4+sizeof(int16*); // skip header157 156 a2 += sizeof(int16*) + 6; // skip header 157 158 158 int16* XArray = XMIN_XMAX; 159 159 int minY = *XArray++; 160 160 … … 178 178 179 179 adrStructPoly = (uint8*)a2; 180 180 181 *(uint16**)a2 = (uint16*)-1; 182 181 *(uint16**)a2 = (uint16*)-1; //chained list terminator 182 183 183 a1+=sizeof(int16*); 184 184 *a1++=num; 185 185 *a1++=walkboxColor[num]; … … 339 339 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0 ); 340 340 } 341 341 342 polyStructExp = adrStructPoly += 4;342 polyStructExp = adrStructPoly += sizeof(int16 *); 343 343 344 344 for(int i= numberOfWalkboxes-1; i >=0; i--) { 345 345 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20 ); 346 346 } 347 347 348 int ctSize = (adrStructPoly - ptr) + 4; // for now, the +4is a safe zone348 int ctSize = (adrStructPoly - ptr) + sizeof(int16 *); // for now, the +sizeof(int16 *) is a safe zone 349 349 adrStructPoly = polyStructNorm = polyStruct = (uint8 *) malloc(ctSize); 350 350 351 351 for(int i= numberOfWalkboxes-1; i >=0; i--) { 352 352 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0); 353 353 } 354 354 355 polyStructExp = adrStructPoly += 4;355 polyStructExp = adrStructPoly += sizeof(int16 *); 356 356 357 357 for(int i= numberOfWalkboxes-1; i >=0; i--) { 358 358 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20); -
engines/cruise/overlay.h
129 129 struct ovlDataStruct { 130 130 131 131 ovlData3Struct *arrayProc; 132 uint8*ptr1;132 ovlData3Struct *ptr1; 133 133 objDataStruct *arrayObject; 134 134 objectParams *arrayStates; 135 135 objectParams *arrayObjVar; -
engines/cruise/various.h
34 34 extern uint16 PCFadeFlag; 35 35 36 36 int16 readB16(void *ptr); 37 int32 readB32(void *ptr); 37 38 38 39 int16 objInit(int ovlIdx, int param1, int param2); 39 40 char *getText(int textIndex, int overlayIndex);