#include "common.h" u32 g_currentFloorRoomRawDataSize = 0; u32 g_currentFloorCameraRawDataSize; std::vector g_currentFloorCameraData; void LoadEtage(int floorNumber) { int i; int expectedNumberOfRoom; int expectedNumberOfCamera; if(g_currentFloorCameraRawData) { free(g_currentFloorCameraRawData); free(g_currentFloorRoomRawData); } //stopSounds(); HQR_Reset(HQ_Bodys); HQR_Reset(HQ_Anims); g_currentFloor = floorNumber; if(g_gameId <= AITD3) { std::string floorFileName = std::format("ETAGE{:02d}", floorNumber); if (fileExists((floorFileName+".PAK").c_str())) { g_currentFloorRoomRawDataSize = getPakSize(floorFileName.c_str(), 0); g_currentFloorCameraRawDataSize = getPakSize(floorFileName.c_str(), 1); g_currentFloorRoomRawData = CheckLoadMallocPak(floorFileName.c_str(), 0); g_currentFloorCameraRawData = CheckLoadMallocPak(floorFileName.c_str(), 1); } } NumCamera = -1; FlagChangeSalle = 1; FlagChangeEtage = 0; ////////////////////////////////// roomDataTable.clear(); expectedNumberOfRoom = getNumberOfRoom(); assert(expectedNumberOfRoom); roomDataTable.reserve(expectedNumberOfRoom); for(i=0;iworldX = READ_LE_S16(roomData+4); currentRoomDataPtr->worldY = READ_LE_S16(roomData+6); currentRoomDataPtr->worldZ = READ_LE_S16(roomData+8); currentRoomDataPtr->numCameraInRoom = READ_LE_U16(roomData+0xA); currentRoomDataPtr->cameraIdxTable.reserve(currentRoomDataPtr->numCameraInRoom); for(j=0;jnumCameraInRoom;j++) { currentRoomDataPtr->cameraIdxTable.push_back(READ_LE_U16(roomData+0xC+2*j)); } // hard col read hardColData = roomData + READ_LE_U16(roomData); currentRoomDataPtr->numHardCol = READ_LE_U16(hardColData); hardColData+=2; { currentRoomDataPtr->hardColTable.resize(currentRoomDataPtr->numHardCol); for(j=0;jnumHardCol;j++) { ZVStruct* zvData = ¤tRoomDataPtr->hardColTable[j].zv; zvData->ZVX1 = READ_LE_S16(hardColData+0x00); zvData->ZVX2 = READ_LE_S16(hardColData+0x02); zvData->ZVY1 = READ_LE_S16(hardColData+0x04); zvData->ZVY2 = READ_LE_S16(hardColData+0x06); zvData->ZVZ1 = READ_LE_S16(hardColData+0x08); zvData->ZVZ2 = READ_LE_S16(hardColData+0x0A); currentRoomDataPtr->hardColTable[j].parameter = READ_LE_U16(hardColData+0x0C); currentRoomDataPtr->hardColTable[j].type = READ_LE_U16(hardColData+0x0E); hardColData+=0x10; } } // sce zone read sceZoneData = roomData + READ_LE_U16(roomData+2); currentRoomDataPtr->numSceZone = READ_LE_U16(sceZoneData); sceZoneData+=2; { currentRoomDataPtr->sceZoneTable.resize(currentRoomDataPtr->numSceZone); for(j=0;jnumSceZone;j++) { ZVStruct* zvData; zvData = ¤tRoomDataPtr->sceZoneTable[j].zv; zvData->ZVX1 = READ_LE_S16(sceZoneData+0x00); zvData->ZVX2 = READ_LE_S16(sceZoneData+0x02); zvData->ZVY1 = READ_LE_S16(sceZoneData+0x04); zvData->ZVY2 = READ_LE_S16(sceZoneData+0x06); zvData->ZVZ1 = READ_LE_S16(sceZoneData+0x08); zvData->ZVZ2 = READ_LE_S16(sceZoneData+0x0A); currentRoomDataPtr->sceZoneTable[j].parameter = READ_LE_U16(sceZoneData+0x0C); currentRoomDataPtr->sceZoneTable[j].type = READ_LE_U16(sceZoneData+0x0E); sceZoneData+=0x10; } } } /////////////////////////////////// ///////////////////////////////////////////////// // camera stuff if(g_currentFloorCameraRawData == nullptr) { char buffer[256]; if(g_gameId == AITD3) { sprintf(buffer,"CAMERA%02d",floorNumber); } else { sprintf(buffer,"CAMSAL%02d",floorNumber); } expectedNumberOfCamera = PAK_getNumFiles(buffer); } else { int maxExpectedNumberOfCamera = ((READ_LE_U32(g_currentFloorCameraRawData))/4); expectedNumberOfCamera = 0; int minOffset = 0; for(int i=0; i minOffset) { minOffset = offset; expectedNumberOfCamera++; } else { break; } } } g_currentFloorCameraData.clear(); g_currentFloorCameraData.resize(expectedNumberOfCamera); for(i=0;iviewedRoomIdx = READ_LE_U16(currentCameraData+0x00); pCurrentCameraViewedRoom->offsetToMask = READ_LE_U16(currentCameraData+0x02); pCurrentCameraViewedRoom->offsetToCover = READ_LE_U16(currentCameraData+0x04); if(g_gameId == AITD1) { pCurrentCameraViewedRoom->offsetToHybrids = 0; pCurrentCameraViewedRoom->offsetCamOptims = 0; pCurrentCameraViewedRoom->lightX = READ_LE_U16(currentCameraData+0x06); pCurrentCameraViewedRoom->lightY = READ_LE_U16(currentCameraData+0x08); pCurrentCameraViewedRoom->lightZ = READ_LE_U16(currentCameraData+0x0A); } else { pCurrentCameraViewedRoom->offsetToHybrids = READ_LE_U16(currentCameraData+0x06); pCurrentCameraViewedRoom->offsetCamOptims = READ_LE_U16(currentCameraData+0x08); pCurrentCameraViewedRoom->lightX = READ_LE_U16(currentCameraData+0x0A); pCurrentCameraViewedRoom->lightY = READ_LE_U16(currentCameraData+0x0C); pCurrentCameraViewedRoom->lightZ = READ_LE_U16(currentCameraData+0x0E); } // load camera mask unsigned char* pMaskData = NULL; if(g_gameId >= JACK) { pMaskData = backupDataPtr + g_currentFloorCameraData[i].viewedRoomTable[k].offsetToMask; // for this camera, how many masks zone int numMasks = READ_LE_U16(pMaskData); pMaskData+=2; pCurrentCameraViewedRoom->masks.reserve(numMasks); for(int k=0; k< numMasks; k++) { cameraMaskStruct* pCurrentCameraMask = &pCurrentCameraViewedRoom->masks.emplace_back(); // for this overlay zone, how many pCurrentCameraMask->numTestRect = READ_LE_U16(pMaskData); pMaskData+=2; pCurrentCameraMask->rectTests.reserve(pCurrentCameraMask->numTestRect); for(int j=0; jnumTestRect; j++) { rectTestStruct* pCurrentRectTest = &pCurrentCameraMask->rectTests.emplace_back(); pCurrentRectTest->zoneX1 = READ_LE_S16(pMaskData); pCurrentRectTest->zoneZ1 = READ_LE_S16(pMaskData+2); pCurrentRectTest->zoneX2 = READ_LE_S16(pMaskData+4); pCurrentRectTest->zoneZ2 = READ_LE_S16(pMaskData+6); pMaskData+=8; } } } // load camera cover { unsigned char* pZoneData = backupDataPtr + g_currentFloorCameraData[i].viewedRoomTable[k].offsetToCover; if(pMaskData) { assert(pZoneData == pMaskData); } //pZoneData = currentCameraData; int numCoverZones = READ_LE_U16(pZoneData); pZoneData += 2; pCurrentCameraViewedRoom->coverZones.resize(numCoverZones); for(int j=0;j< numCoverZones;j++) { int pointIdx; int numPoints; pCurrentCameraViewedRoom->coverZones[j].numPoints = numPoints = READ_LE_U16(pZoneData); pZoneData+=2; pCurrentCameraViewedRoom->coverZones[j].pointTable = (cameraZonePointStruct*)malloc(sizeof(cameraZonePointStruct)*(numPoints+1)); for(pointIdx = 0; pointIdx < pCurrentCameraViewedRoom->coverZones[j].numPoints; pointIdx++) { pCurrentCameraViewedRoom->coverZones[j].pointTable[pointIdx].x = READ_LE_U16(pZoneData); pZoneData+=2; pCurrentCameraViewedRoom->coverZones[j].pointTable[pointIdx].y = READ_LE_U16(pZoneData); pZoneData+=2; } pCurrentCameraViewedRoom->coverZones[j].pointTable[numPoints].x = pCurrentCameraViewedRoom->coverZones[j].pointTable[0].x; // copy first point to last position pCurrentCameraViewedRoom->coverZones[j].pointTable[numPoints].y = pCurrentCameraViewedRoom->coverZones[j].pointTable[0].y; } } // load hybrids if(pCurrentCameraViewedRoom->offsetToHybrids) { unsigned char* pHybridData = backupDataPtr + pCurrentCameraViewedRoom->offsetToHybrids; int numHybrids = READ_LE_U16(pHybridData); pHybridData += 2; pCurrentCameraViewedRoom->hybrids.reserve(numHybrids); for (int i = 0; i < numHybrids; i++) { auto& hybrid = pCurrentCameraViewedRoom->hybrids.emplace_back(); int numRect = READ_LE_U16(pHybridData); pHybridData += 2; hybrid.rects.reserve(numRect); for (int j = 0; j < numRect; j++) { auto& rect = hybrid.rects.emplace_back(); rect.zoneX1 = READ_LE_S16(pHybridData); pHybridData += 2; rect.zoneZ1 = READ_LE_S16(pHybridData); pHybridData += 2; rect.zoneX2 = READ_LE_S16(pHybridData); pHybridData += 2; rect.zoneZ2 = READ_LE_S16(pHybridData); pHybridData += 2; } } if (pCurrentCameraViewedRoom->offsetCamOptims) { assert(backupDataPtr + pCurrentCameraViewedRoom->offsetCamOptims == pHybridData); } } if(g_gameId == AITD1) currentCameraData+=0x0C; else currentCameraData+=0x10; if(g_gameId == TIMEGATE) { currentCameraData+=6; } } } else { break; } } // globalCameraDataTable = (cameraDataStruct*)realloc(globalCameraDataTable,sizeof(cameraDataStruct)*numGlobalCamera); /* roomCameraData+=0x14; }*/ }