diff --git a/CMakeLists.txt b/CMakeLists.txt index 366313405c..7ae4663cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ message(STATUS "Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_EQUAL "11.0") option(REC2_MATCHING "Matching build" TRUE) else() - set(REC2_MATCHING FALSE CACHE BOOL "Matching build" FORCE) + set(REC2_MATCHING FALSE CACHE BOOL "Matching build") endif() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -149,11 +149,13 @@ if(KEEP_ACTIVE_IN_BACKGROUND) add_compile_definitions(KEEP_ACTIVE_IN_BACKGROUND) endif() -if(MSVC) - add_compile_options(/GL- /W3) - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) -else() - add_compile_options(-Wall -Wno-format-overflow) +if(NOT REC2_MATCHING) + if(MSVC) + add_compile_options(/GL- /W3) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + else() + add_compile_options(-Wall -Wno-format-overflow) + endif() endif() add_subdirectory(src/brender) diff --git a/src/carma2/common/graphics.c b/src/carma2/common/graphics.c index 21db6a8b4f..7454ffc20a 100644 --- a/src/carma2/common/graphics.c +++ b/src/carma2/common/graphics.c @@ -1645,7 +1645,7 @@ void C2_HOOK_FASTCALL SetIntegerMapRenders(void) { } // FUNCTION: CARMA2_HW 0x00517fa0 -void C2_HOOK_FASTCALL VerifyPaletteBlackness(br_pixelmap* pPalette) { +void C2_HOOK_FASTCALL NobbleNonzeroBlacks(br_pixelmap* pPalette) { int modified; int i; br_colour *pixels; diff --git a/src/carma2/common/graphics.h b/src/carma2/common/graphics.h index 74c7536756..c069defc75 100644 --- a/src/carma2/common/graphics.h +++ b/src/carma2/common/graphics.h @@ -254,7 +254,7 @@ void C2_HOOK_FASTCALL InitTargetLock(void); void C2_HOOK_FASTCALL SetIntegerMapRenders(void); -void C2_HOOK_FASTCALL VerifyPaletteBlackness(br_pixelmap* pPalette); +void C2_HOOK_FASTCALL NobbleNonzeroBlacks(br_pixelmap* pPalette); void C2_HOOK_FASTCALL ResetPalette(void); @@ -338,4 +338,4 @@ void C2_HOOK_FASTCALL DRPixelmapCopyMapBlack(br_pixelmap* pDest, br_pixelmap* pS void C2_HOOK_FASTCALL RenderShadows(br_actor* pWorld, tTrack_spec* pTrack_spec, br_actor* pCamera, br_matrix34* pCamera_to_world_transform); -#endif //REC2_GRAPHICS_H \ No newline at end of file +#endif //REC2_GRAPHICS_H diff --git a/src/carma2/common/loading.c b/src/carma2/common/loading.c index c0071b25dc..3c4c5f6175 100644 --- a/src/carma2/common/loading.c +++ b/src/carma2/common/loading.c @@ -3014,7 +3014,7 @@ void C2_HOOK_FASTCALL InitializePalettes(void) { if (gRender_palette == NULL) { FatalError(kFatalError_unableToFindRequiredPalette); } - VerifyPaletteBlackness(gRender_palette); + NobbleNonzeroBlacks(gRender_palette); gOrig_render_palette = BrPixelmapAllocateSub(gRender_palette, 0, 0, gRender_palette->width, gRender_palette->height); gOrig_render_palette->pixels = BrMemAllocate(256 * sizeof(br_uint_32), kMem_misc); memcpy(gOrig_render_palette->pixels, gRender_palette->pixels, 256 * sizeof(br_uint_32)); @@ -3737,7 +3737,7 @@ void C2_HOOK_FASTCALL LoadCar(const char* pCar_name, tDriver pDriver, tCar_spec* C2_HOOK_BUG_ON(sizeof(*pCar_spec) != 6500); memset(pCar_spec, 0, sizeof(*pCar_spec)); - prev_storage = gStorageForCallbacks; + prev_storage = gStorage_for_callbacks; gCurrent_car_spec = pCar_spec; if (pDriver == eDriver_local_human) { @@ -4514,7 +4514,7 @@ void C2_HOOK_FASTCALL LoadCar(const char* pCar_name, tDriver pDriver, tCar_spec* BrMaterialUpdate(material, BR_MATU_ALL); } } - gStorageForCallbacks = prev_storage; + gStorage_for_callbacks = prev_storage; } // FUNCTION: CARMA2_HW 0x0048cda0 @@ -5113,13 +5113,13 @@ void C2_HOOK_FASTCALL SmoothlyLoadIfItsAModel(const char* pPath) { Uppercaseificate(s, pPath); if (strstr(s, ".DAT") != NULL) { - AddSmoothModels(gStorageForCallbacks, pPath); + AddSmoothModels(gStorage_for_callbacks, pPath); } } // FUNCTION: CARMA2_HW 0x004f6520 void C2_HOOK_FASTCALL LoadTrackModels(tBrender_storage *pStorage, const char *pPath) { - gStorageForCallbacks = pStorage; + gStorage_for_callbacks = pStorage; PFForEveryFile(pPath, SmoothlyLoadIfItsAModel); } diff --git a/src/carma2/common/utility.c b/src/carma2/common/utility.c index 524b5f7a93..51a304bc22 100644 --- a/src/carma2/common/utility.c +++ b/src/carma2/common/utility.c @@ -1066,29 +1066,29 @@ int C2_HOOK_FASTCALL LoadTextureTryAllLocations(char* pName, br_pixelmap** pMaps PathCat(path3, path3, pName); PathCat(path2, path1, "TIFFX"); - PFForEveryFile2(path2, (tEnumPathCallback)AddTexturePixTifFileStemToList, &list); + PFForEveryFile2(path2, (tEnumPathCallback)GetFileName, &list); PathCat(path4, path1, "PIX8"); - PFForEveryFile2(path4, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path4, (tEnumPathCallback)GetAdditionalFileName, &list); PathCat(path2, path1, "TIFFRGB"); - PFForEveryFile2(path2, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path2, (tEnumPathCallback)GetAdditionalFileName, &list); PathCat(path4, path1, "PIX16"); - PFForEveryFile2(path4, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path4, (tEnumPathCallback)GetAdditionalFileName, &list); if (list.size == 0) { PathCat(path2, path3, "TIFFX"); - PFForEveryFile2(path2, (tEnumPathCallback)AddTexturePixTifFileStemToList, &list); + PFForEveryFile2(path2, (tEnumPathCallback)GetFileName, &list); PathCat(path4, path3, "PIX8"); - PFForEveryFile2(path4, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path4, (tEnumPathCallback)GetAdditionalFileName, &list); PathCat(path2, path3, "TIFFRGB"); - PFForEveryFile2(path2, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path2, (tEnumPathCallback)GetAdditionalFileName, &list); PathCat(path4, path3, "PIX16"); - PFForEveryFile2(path4, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(path4, (tEnumPathCallback)GetAdditionalFileName, &list); for (i = 0; i < list.size; i++) { pMaps[i] = DRLdImg(path3, list.items[i], gRender_palette, gPixelFlags, &error); diff --git a/src/carma2/common/world.c b/src/carma2/common/world.c index e5e8671dfc..b80012c2d7 100644 --- a/src/carma2/common/world.c +++ b/src/carma2/common/world.c @@ -66,13 +66,13 @@ tWall_texturing_level gWall_texturing_level = eWTL_full; int gRendering_accessories = 1; // GLOBAL: CARMA2_HW 0x006b7820 -tBrender_storage* gStorageForCallbacks; +tBrender_storage* gStorage_for_callbacks; // GLOBAL: CARMA2_HW 0x006aaa20 -br_pixelmap* gAddedPixelmap; +br_pixelmap* gDuplicate_pixelmap; // GLOBAL: CARMA2_HW 0x006aaa2c -int gDisallowDuplicates; +int gDisallow_duplicates; // GLOBAL: CARMA2_HW 0x00660cb8 tRendererShadingType gMaterial_shading_for_callback = kRendererShadingType_Undefined; @@ -602,7 +602,7 @@ void C2_HOOK_FASTCALL ParseSpecialVolume(FILE* pF, tSpecial_volume* pSpec, char* } // FUNCTION: CARMA2_HW 0x005026b0 -int C2_HOOK_FASTCALL AddTexturePixTifFileStemToList(const char *path, tName_list *pList) { +int C2_HOOK_FASTCALL GetFileName(const char *path, tName_list *pList) { tPath_name pathCopy; tPath_name pathUpper; tPath_name dir_path; @@ -623,7 +623,7 @@ int C2_HOOK_FASTCALL AddTexturePixTifFileStemToList(const char *path, tName_list } // FUNCTION: CARMA2_HW 0x00502780 -int C2_HOOK_FASTCALL AddTextureFileStemToList(const char* path, tName_list* pList) { +int C2_HOOK_FASTCALL GetAdditionalFileName(const char* path, tName_list* pList) { tPath_name pathCopy; tPath_name upperPath; tPath_name dir_path; @@ -695,9 +695,9 @@ void C2_HOOK_FASTCALL DisposeStorageSpace(tBrender_storage* pStorage) { tAdd_to_storage_result C2_HOOK_FASTCALL AddPixelmapToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_pm) { int i; - gAddedPixelmap = NULL; + gDuplicate_pixelmap = NULL; if (pStorage_space->pixelmaps_count >= pStorage_space->max_pixelmaps) { - gAddedPixelmap = NULL; + gDuplicate_pixelmap = NULL; return eStorage_not_enough_room; } @@ -705,7 +705,7 @@ tAdd_to_storage_result C2_HOOK_FASTCALL AddPixelmapToStorage(tBrender_storage* p if (pStorage_space->pixelmaps[i]->identifier != NULL && pThe_pm->identifier != NULL && strcmp(pStorage_space->pixelmaps[i]->identifier, pThe_pm->identifier) == 0) { - gAddedPixelmap = pStorage_space->pixelmaps[i]; + gDuplicate_pixelmap = pStorage_space->pixelmaps[i]; return eStorage_duplicate; } } @@ -1342,7 +1342,7 @@ int C2_HOOK_FASTCALL AddPixelmaps(tBrender_storage* pStorage_space, const char* FatalError(kFatalError_InsufficientPixelmapSlots); break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicatePixelmap_S, pixelmaps[i]->identifier); } BrPixelmapFree(pixelmaps[i]); @@ -1372,25 +1372,25 @@ void C2_HOOK_FASTCALL LoadAllImagesInDirectory(tBrender_storage* pStorage_space, TwatPIX16(path); list.size = 0; strcpy(pathCopy, path); - gStorageForCallbacks = pStorage_space; + gStorage_for_callbacks = pStorage_space; if (gDisableTiffConversion) { - PFForEveryFile2(pathCopy, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(pathCopy, (tEnumPathCallback)GetAdditionalFileName, &list); } if (!gDisableTiffConversion) { PathCat(tempPath, pathCopy, "TIFFX"); - PFForEveryFile2(tempPath, (tEnumPathCallback)AddTexturePixTifFileStemToList, &list); + PFForEveryFile2(tempPath, (tEnumPathCallback)GetFileName, &list); } PathCat(tempPath, pathCopy, "PIX8"); - PFForEveryFile2(tempPath, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(tempPath, (tEnumPathCallback)GetAdditionalFileName, &list); if (!gDisableTiffConversion) { PathCat(tempPath, pathCopy, "TIFFRGB"); - PFForEveryFile2(tempPath, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(tempPath, (tEnumPathCallback)GetAdditionalFileName, &list); } PathCat(tempPath, pathCopy, "PIX16"); - PFForEveryFile2(tempPath, (tEnumPathCallback)AddTextureFileStemToList, &list); + PFForEveryFile2(tempPath, (tEnumPathCallback)GetAdditionalFileName, &list); for (i = 0; i < list.size; i++) { PathCat(tempPath, path, list.items[i]); - AddPixelmaps(gStorageForCallbacks, tempPath); + AddPixelmaps(gStorage_for_callbacks, tempPath); } } @@ -1587,6 +1587,7 @@ int C2_HOOK_FASTCALL FindLastOccurrenceOfString_CaseInsensitive(int* offset, con } } +// FUNCTION: CARMA2_HW 0x005010e0 tAdd_to_storage_result C2_HOOK_FASTCALL AddShadeTableToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_st) { int i; @@ -1618,7 +1619,7 @@ void C2_HOOK_FASTCALL LoadIfItsAShadeTable(const char* pPath) { if (strstr(s, ".TAB") == NULL) { return; } - storage_space = gStorageForCallbacks; + storage_space = gStorage_for_callbacks; total = BrPixelmapLoadMany(pPath, temp_array, REC2_ASIZE(temp_array)); if (total == 0) { FatalError(kFatalError_CannotLoadShadeTableFileOrItIsEmpty_S, pPath); @@ -1633,7 +1634,7 @@ void C2_HOOK_FASTCALL LoadIfItsAShadeTable(const char* pPath) { break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicatePixelmap_S, temp_array[i]->identifier); } BrPixelmapFree(temp_array[i]); @@ -1648,7 +1649,7 @@ void C2_HOOK_FASTCALL LoadIfItsAShadeTable(const char* pPath) { // FUNCTION: CARMA2_HW 0x00502b60 void C2_HOOK_FASTCALL LoadAllShadeTablesInDirectory(tBrender_storage* pStorage, const char* pPath) { - gStorageForCallbacks = pStorage; + gStorage_for_callbacks = pStorage; PFForEveryFile(pPath, LoadIfItsAShadeTable); } @@ -1658,14 +1659,14 @@ void C2_HOOK_FASTCALL LoadIfItsAPixelmap(const char* pPath) { Uppercaseificate(s, pPath); if (strstr(s, ".PIX") != NULL) { - AddPixelmaps(gStorageForCallbacks, pPath); + AddPixelmaps(gStorage_for_callbacks, pPath); } } // FUNCTION: CARMA2_HW 0x00502490 void C2_HOOK_FASTCALL LoadAllPixelmapsInDirectory(tBrender_storage* pStorage, const char* pPath) { - gStorageForCallbacks = pStorage; + gStorage_for_callbacks = pStorage; PFForEveryFile(pPath, LoadIfItsAPixelmap); } @@ -1685,11 +1686,11 @@ br_pixelmap* C2_HOOK_FASTCALL LoadSinglePixelmap(tBrender_storage* pStorage, con FatalError(kFatalError_InsufficientPixelmapSlots); break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicatePixelmap_S, map->identifier); } BrPixelmapFree(map); - return gAddedPixelmap; + return gDuplicate_pixelmap; case eStorage_allocated: BrMapAdd(map); return map; @@ -1710,7 +1711,7 @@ void C2_HOOK_FASTCALL LoadIfItsAMaterial(const char* pPath) { } Uppercaseificate(s, pPath); if (strstr(s, ".MAT") != NULL) { - AddMaterials(gStorageForCallbacks, pPath, shading); + AddMaterials(gStorage_for_callbacks, pPath, shading); } } @@ -1718,7 +1719,7 @@ void C2_HOOK_FASTCALL LoadIfItsAMaterial(const char* pPath) { void C2_HOOK_FASTCALL LoadAllMaterialsInDirectory(tBrender_storage* pStorage, const char* pPath, tRendererShadingType pShading) { gMaterial_shading_for_callback = pShading; - gStorageForCallbacks = pStorage; + gStorage_for_callbacks = pStorage; PFForEveryFile(pPath, LoadIfItsAMaterial); gMaterial_shading_for_callback = kRendererShadingType_Undefined; } @@ -1767,7 +1768,7 @@ int C2_HOOK_FASTCALL AddMaterials(tBrender_storage* pStorage_space, const char* FatalError(kFatalError_InsufficientMaterialSlots); break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicateMaterial_S, temp_array[i]->identifier); } BrMaterialFree(temp_array[i]); @@ -1796,7 +1797,7 @@ br_material* C2_HOOK_FASTCALL LoadSingleMaterial(tBrender_storage* pStorage_spac break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicateMaterial_S, temp->identifier); } BrMaterialFree(temp); @@ -1846,7 +1847,7 @@ br_pixelmap* C2_HOOK_FASTCALL LoadSingleShadeTable(tBrender_storage* pStorage_sp break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicatePixelmap_S, temp->identifier); } BrPixelmapFree(temp); @@ -1906,7 +1907,7 @@ int C2_HOOK_FASTCALL AddModels(tBrender_storage* pStorage_space, const char* pPa FatalError(kFatalError_InsufficientModelSlots); break; case eStorage_duplicate: - if (gDisallowDuplicates) { + if (gDisallow_duplicates) { FatalError(kFatalError_DuplicateModel_S, temp_array[i]->identifier); } BrModelFree(temp_array[i]); @@ -1923,20 +1924,20 @@ int C2_HOOK_FASTCALL AddModels(tBrender_storage* pStorage_space, const char* pPa } // FUNCTION: CARMA2_HW 0x00502b20 -void C2_HOOK_FASTCALL LoadIfItsAMode(const char* pPath) { +void C2_HOOK_FASTCALL LoadIfItsAModel(const char* pPath) { char s[256]; Uppercaseificate(s, pPath); if (strstr(s, ".DAT") != NULL) { - AddModels(gStorageForCallbacks, pPath); + AddModels(gStorage_for_callbacks, pPath); } } // FUNCTION: CARMA2_HW 0x00502b00 void C2_HOOK_FASTCALL LoadAllModelsInDirectory(tBrender_storage *pStorage, const char* pPath) { - gStorageForCallbacks = pStorage; - PFForEveryFile(pPath, LoadIfItsAMode); + gStorage_for_callbacks = pStorage; + PFForEveryFile(pPath, LoadIfItsAModel); } // FUNCTION: CARMA2_HW 0x00502cf0 @@ -1956,7 +1957,7 @@ void C2_HOOK_FASTCALL DisallowDuplicates(void) { // FUNCTION: CARMA2_HW 0x00502d70 void C2_HOOK_FASTCALL AllowDuplicates(void) { - gDisallowDuplicates = 0; + gDisallow_duplicates = 0; } // FUNCTION: CARMA2_HW 0x00502d80 diff --git a/src/carma2/common/world.h b/src/carma2/common/world.h index 286028443a..1d5d2b8f82 100644 --- a/src/carma2/common/world.h +++ b/src/carma2/common/world.h @@ -9,7 +9,7 @@ extern int gSize_powerup_queue; extern br_scalar gSight_distance_squared; -extern tBrender_storage* gStorageForCallbacks; +extern tBrender_storage* gStorage_for_callbacks; extern int gGroovidelics_array_size; extern tGroovidelic_spec* gGroovidelics_array; extern const char* gSmashable_track_environment_path; @@ -84,9 +84,9 @@ int C2_HOOK_FASTCALL LoadBunchOfPixies(const char* pathRoot, const char* texture void C2_HOOK_FASTCALL ParseSpecialVolume(FILE* pF, tSpecial_volume* pSpec, char* pScreen_name_str, int soundfx); -int C2_HOOK_FASTCALL AddTexturePixTifFileStemToList(const char *path, tName_list *pList); +int C2_HOOK_FASTCALL GetFileName(const char *path, tName_list *pList); -int C2_HOOK_FASTCALL AddTextureFileStemToList(const char* path, tName_list* pList); +int C2_HOOK_FASTCALL GetAdditionalFileName(const char* path, tName_list* pList); void C2_HOOK_FASTCALL InitialiseStorageSpace(int pUnknown, tBrender_storage* pStorage_space, int pMax_pixelmaps, int pMax_shade_tables, int pMax_materials, int pMax_models, int pMax_sounds); @@ -154,7 +154,7 @@ tAdd_to_storage_result C2_HOOK_FASTCALL AddModelToStorage(tBrender_storage* pSto int C2_HOOK_FASTCALL AddModels(tBrender_storage* pStorage_space, const char* pPath); -void C2_HOOK_FASTCALL LoadIfItsAMode(const char* pPath); +void C2_HOOK_FASTCALL LoadIfItsAModel(const char* pPath); void C2_HOOK_FASTCALL LoadAllModelsInDirectory(tBrender_storage *pStorage, const char* pPath); @@ -396,4 +396,4 @@ float C2_HOOK_FAKE_THISCALL ControlBoundFunkGroovePlus(int pSlot_number, undefin void C2_HOOK_FASTCALL ProcessTrack(br_actor* pWorld, tTrack_spec* pTrack_spec, br_actor* pCamera, br_matrix34* pCamera_to_world_transform); -#endif // REC2_WORLD_H \ No newline at end of file +#endif // REC2_WORLD_H diff --git a/src/carma2/hooks/c2_hooks.h b/src/carma2/hooks/c2_hooks.h index 3038760f05..c1b3f7a1f3 100644 --- a/src/carma2/hooks/c2_hooks.h +++ b/src/carma2/hooks/c2_hooks.h @@ -15,7 +15,7 @@ #define C2_NAKED __attribute__((__naked__)) #endif -#if defined(_MSC_VER) && _MSC_VER < 1200 +#if defined(_MSC_VER) && _MSC_VER < 1300 #define C2_FUNCTION "" #else #define C2_FUNCTION __FUNCTION__ diff --git a/src/carma2/hooks/c2_math.h b/src/carma2/hooks/c2_math.h index 795070f575..2e2144fbd1 100644 --- a/src/carma2/hooks/c2_math.h +++ b/src/carma2/hooks/c2_math.h @@ -3,7 +3,7 @@ #include -#if defined(_MSC_VER) && _MSC_VER < 1200 +#if defined(_MSC_VER) && _MSC_VER < 1300 #include diff --git a/src/carma2/include/rec2_types.h b/src/carma2/include/rec2_types.h index 6a5850c2b1..c251b590ca 100644 --- a/src/carma2/include/rec2_types.h +++ b/src/carma2/include/rec2_types.h @@ -1481,7 +1481,7 @@ typedef struct { } tBrender_storage; typedef struct { - size_t size; + int size; char items[1000][16]; } tName_list; diff --git a/src/carma2/newcommon/10-loading2.c b/src/carma2/newcommon/10-loading2.c index ea9107688b..8a31d488fb 100644 --- a/src/carma2/newcommon/10-loading2.c +++ b/src/carma2/newcommon/10-loading2.c @@ -12,6 +12,7 @@ #include "21-mainloop.h" #include "22-replay.h" #include "27-powerup.h" +#include "28-world3.h" #include "30-opponent.h" #include "32-spark.h" #include "33-depth.h" @@ -27,6 +28,7 @@ #include "59-camera.h" #include "61-pedestrn.h" #include "62-graphics3.h" +#include "63-loading3.h" #include "64-movie.h" #include "69-sound.h" #include "70-packfile.h" @@ -88,11 +90,34 @@ int gDemo_opponents[15]; // GLOBAL: CARMA2_HW 0x00679308 int gCamera_type; -// LoadInRegisteeDir +void C2_HOOK_FASTCALL LoadInRegisteeDir(const char *pRoot, const char *pSubDir, int pInitialize_palettes) { + tPath_name the_path; + tPath_name the_path2; + tTWTVFS twt; + + PathCat(the_path, pRoot, pSubDir); + LoadInFiles(the_path, "PALETTES", DRLoadPalette); + LoadInFiles(the_path, "SHADETAB", DRLoadShadeTable); + + if (pInitialize_palettes) { + InitializePalettes(); + } + + PathCat(the_path2, the_path, "PIXELMAP"); + twt = OpenPackFileAndSetTiffLoading(the_path2); + LoadAllImagesInDirectory(&gMisc_storage_space, the_path2); + ClosePackFileAndSetTiffLoading(twt); -// STUB: CARMA2_HW 0x00486e10 + LoadInFiles(the_path, "MATERIAL", DRLoadMaterials); + LoadInFiles(the_path, "MODELS", DRLoadModels); + LoadInFiles(the_path, "ACTORS", DRLoadActors); + LoadInFiles(the_path, "LIGHTS", DRLoadLights); +} + +// FUNCTION: CARMA2_HW 0x00486e10 void C2_HOOK_FASTCALL LoadInRegistees(void) { - NOT_IMPLEMENTED(); + + LoadInRegisteeDir(gApplication_path, "REG", 1); } void C2_HOOK_FASTCALL LoadBunchOParameters(tSlot_info* pSlot_info) { diff --git a/src/carma2/newcommon/10-loading2.h b/src/carma2/newcommon/10-loading2.h index eff09275e1..064a5f892a 100644 --- a/src/carma2/newcommon/10-loading2.h +++ b/src/carma2/newcommon/10-loading2.h @@ -4,7 +4,7 @@ #include "c2_hooks.h" #include "rec2_types.h" -// LoadInRegisteeDir +extern void C2_HOOK_FASTCALL LoadInRegisteeDir(const char *pRoot, const char *pSubDir, int pInitialize_palettes); extern void C2_HOOK_FASTCALL LoadInRegistees(void); diff --git a/src/carma2/newcommon/18-graphics2.c b/src/carma2/newcommon/18-graphics2.c index 42e40260d7..a8f0dd93d5 100644 --- a/src/carma2/newcommon/18-graphics2.c +++ b/src/carma2/newcommon/18-graphics2.c @@ -1,5 +1,13 @@ #include "18-graphics2.h" +#include "41-utility.h" +#include "52-errors.h" +#include "globvars.h" +#include "platform.h" +#include "rec2_types.h" + +#include + // GLOBAL: CARMA2_HW 0x0074ca28 int gNoTransients; @@ -9,6 +17,51 @@ br_pixelmap* gRender_palette; // GLOBAL: CARMA2_HW 0x0079ec14 int gDim_amount; +// GLOBAL: CARMA2_HW 0x0074a680 +char* gCurrent_palette_pixels; + +// GLOBAL: CARMA2_HW 0x0074cf04 +int gPalette_changed; + +// GLOBAL: CARMA2_HW 0x0074a678 +br_pixelmap* gCurrent_palette; + +// GLOBAL: CARMA2_HW 0x006923ac +br_pixelmap* gOrig_render_palette; + +// GLOBAL: CARMA2_HW 0x0074a67c +br_pixelmap* gFlic_palette; + +// GLOBAL: CARMA2_HW 0x006923c8 +int gFaded_palette; + +// GLOBAL: CARMA2_HW 0x006923c0 +int gPalette_munged; + +// GLOBAL: CARMA2_HW 0x006923b8 +br_colour* gScratch_pixels; + +// GLOBAL: CARMA2_HW 0x006923a8 +br_pixelmap* gScratch_palette; + +// GLOBAL: CARMA2_HW 0x0074a660 +br_pixelmap* gMini_map_glowing_line_palettes[3]; + +// GLOBAL: CARMA2_HW 0x0074a604 +br_pixelmap* gPalette_0074a604; + +// GLOBAL: CARMA2_HW 0x0074a600 +br_pixelmap* gPalette_0074a600; + +// GLOBAL: CARMA2_HW 0x0074a66c +br_pixelmap* gPalette_0074a66c; + +// GLOBAL: CARMA2_HW 0x0074a5fc +br_pixelmap* gPalette_0074a5fc; + +// GLOBAL: CARMA2_HW 0x0074a670 +br_pixelmap* gPalette_0074a670; + // DRSetPaletteEntries // DRSetPalette3 @@ -17,7 +70,41 @@ int gDim_amount; // DRSetPalette -// InitializePalettes +// FUNCTION: CARMA2_HW 0x004b5090 +void C2_HOOK_FASTCALL InitializePalettes(void) { + br_pixelmap* render_palette; + + gCurrent_palette_pixels = BrMemAllocate(256 * sizeof(br_uint_32), kMem_misc); + gPalette_changed = 0; + gCurrent_palette = DRPixelmapAllocate(BR_PMT_RGBX_888, 1, 256, gCurrent_palette_pixels, 0); + gRender_palette = BrTableFind("DRRENDER.PAL"); + if (gRender_palette == NULL) { + FatalError(kFatalError_unableToFindRequiredPalette); + } + NobbleNonzeroBlacks(gRender_palette); + gOrig_render_palette = BrPixelmapAllocateSub(gRender_palette, 0, 0, gRender_palette->width, gRender_palette->height); + gOrig_render_palette->pixels = BrMemAllocate(256 * sizeof(br_uint_32), kMem_misc); + memcpy(gOrig_render_palette->pixels, gRender_palette->pixels, 256 * sizeof(br_uint_32)); + gFlic_palette = BrTableFind("DRACEFLC.PAL"); + if (gFlic_palette == NULL) { + FatalError(kFatalError_unableToFindRequiredPalette); + } + render_palette = gRender_palette; + ((br_uint_32*)render_palette->pixels)[0] = 0; + memcpy(gCurrent_palette_pixels, render_palette->pixels, 256 * sizeof(br_uint_32)); + gPalette_changed = 0; + if (!gFaded_palette) { + PDSetPalette(render_palette); + } + gPalette_munged |= render_palette != gRender_palette; + gScratch_pixels = BrMemAllocate(256 * sizeof(br_uint_32), kMem_misc); + gScratch_palette = DRPixelmapAllocate(BR_PMT_RGBX_888, 1, 256, gScratch_pixels, 0); + gMini_map_glowing_line_palettes[0] = (br_pixelmap*)(intptr_t)-1; /* FIXME: invalid pointer! */ + gMini_map_glowing_line_palettes[1] = gPalette_0074a604; + gMini_map_glowing_line_palettes[2] = gPalette_0074a600; + gPalette_0074a66c = gPalette_0074a5fc; + gPalette_0074a670 = NULL; +} // STUB: CARMA2_HW 0x004b52a0 void C2_HOOK_FASTCALL InitPaletteAnimate(void) { @@ -112,5 +199,11 @@ void C2_HOOK_FASTCALL ClearEntireScreen(void) { // DisableLights -// EnableLights +// FUNCTION: CARMA2_HW 0x0047d6d0 +void C2_HOOK_FASTCALL EnableLights(void) { + int i; + for (i = 0; i < gNumber_of_lights; i++) { + BrLightEnable(gLight_array[i]); + } +} diff --git a/src/carma2/newcommon/18-graphics2.h b/src/carma2/newcommon/18-graphics2.h index 3fc4a97393..72a6f1a205 100644 --- a/src/carma2/newcommon/18-graphics2.h +++ b/src/carma2/newcommon/18-graphics2.h @@ -16,7 +16,7 @@ extern int gDim_amount; // DRSetPalette -// InitializePalettes +extern void C2_HOOK_FASTCALL InitializePalettes(void); extern void C2_HOOK_FASTCALL InitPaletteAnimate(void); @@ -102,6 +102,6 @@ extern void C2_HOOK_FASTCALL ClearEntireScreen(void); // DisableLights -// EnableLights +extern void C2_HOOK_FASTCALL EnableLights(void); #endif // GUARD_18_GRAPHICS2_H diff --git a/src/carma2/newcommon/28-world3.c b/src/carma2/newcommon/28-world3.c index 5fd84cc7e2..5b6ae434dc 100644 --- a/src/carma2/newcommon/28-world3.c +++ b/src/carma2/newcommon/28-world3.c @@ -1,10 +1,34 @@ #include "28-world3.h" +#include "41-utility.h" #include "52-errors.h" +#include "63-loading3.h" +#include "70-packfile.h" +#include "rec2_macros.h" + +#include // GLOBAL: CARMA2_HW 0x006b75c0 br_actor* gAdditional_actors; +// GLOBAL: CARMA2_HW 0x006b7820 +tBrender_storage* gStorage_for_callbacks; + +// GLOBAL: CARMA2_HW 0x006aaa2c +int gDisallow_duplicates; + +// GLOBAL: CARMA2_HW 0x006aaa20 +br_pixelmap* gDuplicate_pixelmap; + +// GLOBAL: CARMA2_HW 0x006aaa28 +br_material* gDuplicate_material; + +// GLOBAL: CARMA2_HW 0x006aaa24 +br_model* gDuplicate_model; + +// GLOBAL: CARMA2_HW 0x00660cb8 +tRendererShadingType gMaterial_shading_for_callback = kRendererShadingType_Undefined; + // TurnOnCloaking // RemoveFromCloakingList @@ -82,14 +106,97 @@ void C2_HOOK_FASTCALL InitialiseStorageSpace(int pUnknown, tBrender_storage* pSt // ClearOutStorageSpace -// AddPixelmapToStorage +// FUNCTION: CARMA2_HW 0x00501020 +tAdd_to_storage_result C2_HOOK_FASTCALL AddPixelmapToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_pm) { + int i; + + gDuplicate_pixelmap = NULL; + if (pStorage_space->pixelmaps_count < pStorage_space->max_pixelmaps) { + for (i = 0; i < pStorage_space->pixelmaps_count; i++) { + if (pStorage_space->pixelmaps[i]->identifier != NULL + && pThe_pm->identifier != NULL + && strcmp(pStorage_space->pixelmaps[i]->identifier, pThe_pm->identifier) == 0) { + gDuplicate_pixelmap = pStorage_space->pixelmaps[i]; + return eStorage_duplicate; + } + } + pStorage_space->pixelmaps[pStorage_space->pixelmaps_count] = pThe_pm; + pStorage_space->pixelmaps_count += 1; + return eStorage_allocated; + } else { + return eStorage_not_enough_room; + } +} -// AddShadeTableToStorage +// FUNCTION: CARMA2_HW 0x005010e0 +tAdd_to_storage_result C2_HOOK_FASTCALL AddShadeTableToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_st) { + int i; -// AddMaterialToStorage + if (pStorage_space->shade_tables_count < pStorage_space->max_shade_tables) { + for (i = 0; i < pStorage_space->shade_tables_count; i++) { + if (pStorage_space->shade_tables[i]->identifier != NULL + && pThe_st->identifier != NULL + && strcmp(pStorage_space->shade_tables[i]->identifier, pThe_st->identifier) == 0) { + return eStorage_duplicate; + } + } + pStorage_space->shade_tables[pStorage_space->shade_tables_count] = pThe_st; + pStorage_space->shade_tables_count += 1; + return eStorage_allocated; + } else { + return eStorage_not_enough_room; + } +} -// AddModelToStorage +// FUNCTION: CARMA2_HW 0x00501190 +tAdd_to_storage_result C2_HOOK_FASTCALL AddMaterialToStorage(tBrender_storage* pStorage_space, br_material* pThe_mat) { + int i; + gDuplicate_material = NULL; + if (pStorage_space->materials_count < pStorage_space->max_materials) { + for (i = 0; i < pStorage_space->materials_count; i++) { + if (pStorage_space->materials[i]->identifier != NULL + && pThe_mat->identifier != NULL + && strcmp(pStorage_space->materials[i]->identifier, pThe_mat->identifier) == 0) { + gDuplicate_material = pStorage_space->materials[i]; + return eStorage_duplicate; + } + } + pStorage_space->materialProps[pStorage_space->materials_count] = 0; /* FIXME */ + pStorage_space->materials[pStorage_space->materials_count] = pThe_mat; + pStorage_space->materials_count += 1; + return eStorage_allocated; + } else { + return eStorage_not_enough_room; + } +} + +// FUNCTION: CARMA2_HW 0x00501260 +tAdd_to_storage_result C2_HOOK_FASTCALL AddModelToStorage(tBrender_storage* pStorage_space, br_model* pThe_mod) { + int i; + + gDuplicate_model = NULL; + if (pStorage_space->materials_count < pStorage_space->max_models) { + if (pStorage_space->flags & 0x1) { /* FIXME: add enum (0x1 -> eStorage_space_flags_No_duplicates*/ + for (i = 0; i < pStorage_space->models_count; i++) { + if (pStorage_space->models[i] != NULL + && pStorage_space->models[i]->identifier != NULL + && pThe_mod->identifier != NULL + && strcmp(pStorage_space->models[i]->identifier, pThe_mod->identifier) == 0) { + gDuplicate_model = pStorage_space->models[i]; + return eStorage_duplicate; + } + } + } + pStorage_space->models[pStorage_space->models_count] = pThe_mod; + pStorage_space->models_count += 1; + return eStorage_allocated; + } else { + return eStorage_not_enough_room; + } +} + +// FUNCTION: CARMA2_HW 0x00501330 tAdd_to_storage_result C2_HOOK_FASTCALL AddSoundToStorage(tBrender_storage* pStorage_space, int pSound_id) { int i; @@ -107,7 +214,48 @@ tAdd_to_storage_result C2_HOOK_FASTCALL AddSoundToStorage(tBrender_storage* pSto } } -// AddPixelmaps +// FUNCTION: CARMA2_HW 0x005024f0 +int C2_HOOK_FASTCALL AddPixelmaps(tBrender_storage* pStorage_space, const char* path) { + int i; + int new_ones; + int total; + tPath_name path_dirname; + char path_stem[32]; + br_pixelmap* temp_array[500]; + + total = 0; + if (gDisableTiffConversion) { + SepDirAndFilename(path, path_dirname, path_stem); + new_ones = LoadBunchOfPixies(path_dirname, path_stem, temp_array, REC2_ASIZE(temp_array)); + } else { + new_ones = DRPixelmapLoadMany(path, temp_array, REC2_ASIZE(temp_array)); + } + if (new_ones == 0) { + FatalError(kFatalError_CantLoadPixelmapFile_S, path); + } + for (i = 0; i < new_ones; i++) { + if (temp_array[i] != NULL) { + EnsurePixelmapAllowed(temp_array[i], 1); + switch (AddPixelmapToStorage(pStorage_space, temp_array[i])) { + case eStorage_allocated: + BrMapAdd(temp_array[i]); + total += 1; + break; + case eStorage_duplicate: + if (gDisallow_duplicates) { + FatalError(kFatalError_DuplicatePixelmap_S, temp_array[i]->identifier); + } else { + BrPixelmapFree(temp_array[i]); + } + break; + case eStorage_not_enough_room: + FatalError(kFatalError_InsufficientPixelmapSlots); + break; + } + } + } + return total; +} // LoadSinglePixelmap @@ -137,39 +285,299 @@ tAdd_to_storage_result C2_HOOK_FASTCALL LoadSingleSound(tBrender_storage* pStora return 0; } -// AddShadeTables +int C2_HOOK_FASTCALL AddShadeTables(tBrender_storage* pStorage_space, const char* pPath) { + br_pixelmap* temp_array[50]; + int total; + int i; -// AddModels + total = BrPixelmapLoadMany(pPath, temp_array, REC2_ASIZE(temp_array)); + if (total == 0) { + FatalError(kFatalError_CannotLoadShadeTableFileOrItIsEmpty_S, pPath); + } + for (i = 0; i < total; i++) { + if (temp_array[i] == NULL) { + continue; + } + switch (AddShadeTableToStorage(pStorage_space, temp_array[i])) { + case eStorage_allocated: + BrTableAdd(temp_array[i]); + break; + case eStorage_duplicate: + if (gDisallow_duplicates) { + FatalError(kFatalError_DuplicatePixelmap_S, temp_array[i]->identifier); + } else { + BrPixelmapFree(temp_array[i]); + } + break; + case eStorage_not_enough_room: + FatalError(kFatalError_InsufficientShadeTableSlots); + break; + } + } + return total; +} -// AddMaterials +// FUNCTION: CARMA2_HW 0x00501e40 +int C2_HOOK_FASTCALL AddModels(tBrender_storage* pStorage_space, const char* pPath) { + int i; + int new_ones; + int total; + br_model* temp_array[2000]; + + new_ones = 0; + total = BrModelLoadMany(pPath, temp_array, REC2_ASIZE(temp_array)); + WhitenVertexRGB(temp_array, total); + if (total == 0) { + FatalError(kFatalError_CannotLoadModelFileOrItIsEmpty_S, pPath); + } + for (i = 0; i < total; i++) { + if (temp_array[i] == NULL) { + continue; + } + switch (AddModelToStorage(pStorage_space, temp_array[i])) { + case eStorage_allocated: + temp_array[i]->flags |= BR_MODF_UPDATEABLE; + BrModelAdd(temp_array[i]); + new_ones++; + break; + case eStorage_duplicate: + if (gDisallow_duplicates) { + FatalError(kFatalError_DuplicateModel_S, temp_array[i]->identifier); + } else { + BrModelFree(temp_array[i]); + } + break; + case eStorage_not_enough_room: + FatalError(kFatalError_InsufficientModelSlots); + break; + } + } + return new_ones; +} + +// FUNCTION: CARMA2_HW 0x00502060 +int C2_HOOK_FASTCALL AddMaterials(tBrender_storage* pStorage_space, const char* pPath, tRendererShadingType pShading) { + int i; + int new_ones; + int total; + br_material* temp_array[500]; + + new_ones = 0; + total = BrMaterialLoadMany(pPath, temp_array, REC2_ASIZE(temp_array)); + if (total == 0) { + FatalError(kFatalError_CannotLoadMaterialFileOrItIsEmpty_S, pPath); + } + GlorifyMaterial(temp_array, total, pShading); + for (i = 0; i < total; ++i) { + if (temp_array[i] != NULL) { + switch (AddMaterialToStorage(pStorage_space, temp_array[i])) { + case eStorage_allocated: + BrMaterialAdd(temp_array[i]); + new_ones += 1; + break; + case eStorage_duplicate: + if (gDisallow_duplicates) { + FatalError(kFatalError_DuplicateMaterial_S, temp_array[i]->identifier); + } else { + BrMaterialFree(temp_array[i]); + } + break; + case eStorage_not_enough_room: + FatalError(kFatalError_InsufficientMaterialSlots); + break; + } + } + } + return new_ones; +} + +// FUNCTION: CARMA2_HW 0x00502210 +void C2_HOOK_FASTCALL DodgyModelUpdate(br_model* pM) { + + BrResFree(pM->faces); + BrResFree(pM->vertices); + pM->nfaces = 0; + pM->nvertices = 0; + pM->faces = NULL; + pM->vertices = NULL; +} + +// FUNCTION: CARMA2_HW 0x005024b0 +void C2_HOOK_FASTCALL LoadIfItsAPixelmap(const char* pPath) { + char s[256]; + + Uppercaseificate(s, pPath); + if (strstr(s, ".PIX") != NULL) { + AddPixelmaps(gStorage_for_callbacks, pPath); + } +} + +// FUNCTION: CARMA2_HW 0x00502490 +void C2_HOOK_FASTCALL LoadAllPixelmapsInDirectory(tBrender_storage* pStorage, const char* pPath) { + + gStorage_for_callbacks = pStorage; + PFForEveryFile(pPath, LoadIfItsAPixelmap); +} + +// FUNCTION: CARMA2_HW 0x005026b0 +int C2_HOOK_FASTCALL GetFileName(const char *path, tName_list *pList) { + tPath_name pathCopy; + tPath_name pathUpper; + tPath_name dir_path; + tPath_name stem_path; + + strcpy(pathCopy, path); + Uppercaseificate(pathUpper, pathCopy); + if (strstr(pathUpper, ".PIX") == NULL + && strstr(pathUpper, ".TIF") == NULL) { + return 0; + } + SepDirAndFilename(pathUpper, dir_path, stem_path); + strcpy(pList->items[pList->size], stem_path); + if (pList->size < (int)REC2_ASIZE(pList->items)) { + pList->size += 1; + } + return 0; +} + +// FUNCTION: CARMA2_HW 0x00502780 +int C2_HOOK_FASTCALL GetAdditionalFileName(const char* path, tName_list* pList) { + tPath_name pathCopy; + tPath_name upperPath; + tPath_name dir_path; + tPath_name stem_path; + int alreadyInList; + int i; + + strcpy(pathCopy, path); + Uppercaseificate(upperPath, pathCopy); + + if (strstr(upperPath, ".PIX") == NULL + && strstr(upperPath, ".P16") == NULL + && strstr(upperPath, ".P08") == NULL + && strstr(upperPath, ".TIF") == NULL) { + return 0; + } + SepDirAndFilename(upperPath, dir_path, stem_path); -// DodgyModelUpdate + for (i = 0, alreadyInList = 0; i < pList->size; i++) { + if (strcmp(pList->items[i], stem_path) == 0) { + alreadyInList = 1; + break; + } + } + if (!alreadyInList) { + strcpy(pList->items[pList->size], stem_path); + if (pList->size < (int)REC2_ASIZE(pList->items)) { + pList->size += 1; + } + } + return 0; +} -// LoadIfItsAPixelmap +// FUNCTION: CARMA2_HW 0x005028f0 +void C2_HOOK_FASTCALL LoadAllImagesInDirectory(tBrender_storage* pStorage_space, const char* path) { + tPath_name pathCopy; + tPath_name pixPath; + tPath_name tifPath; + tName_list list; + int i; -// LoadAllPixelmapsInDirectory + C2_HOOK_BUG_ON(sizeof(tBrender_storage) != 68); -// GetFileName + gStorage_for_callbacks = pStorage_space; + // TwatPIX16(path); + list.size = 0; + strcpy(pathCopy, path); + if (gDisableTiffConversion) { + PFForEveryFile2(pathCopy, (tEnumPathCallback)GetAdditionalFileName, &list); + } + if (!gDisableTiffConversion) { + PathCat(tifPath, pathCopy, "TIFFX"); + PFForEveryFile2(tifPath, (tEnumPathCallback)GetFileName, &list); + } + PathCat(pixPath, pathCopy, "PIX8"); + PFForEveryFile2(pixPath, (tEnumPathCallback)GetAdditionalFileName, &list); + if (!gDisableTiffConversion) { + PathCat(tifPath, pathCopy, "TIFFRGB"); + PFForEveryFile2(tifPath, (tEnumPathCallback)GetAdditionalFileName, &list); + } + PathCat(pixPath, pathCopy, "PIX16"); + PFForEveryFile2(pixPath, (tEnumPathCallback)GetAdditionalFileName, &list); + for (i = 0; i < list.size; i++) { + PathCat(pathCopy, path, list.items[i]); + AddPixelmaps(gStorage_for_callbacks, pathCopy); + } +} -// GetAdditionalFileName +// FUNCTION: CARMA2_HW 0x00502a70 +void C2_HOOK_FASTCALL LoadIfItsAMaterial(const char* pPath) { + char path[256]; + tRendererShadingType shading; -// LoadAllImagesInDirectory + if (gMaterial_shading_for_callback == kRendererShadingType_Undefined) { + shading = kRendererShadingType_Default; + } else { + shading = gMaterial_shading_for_callback; + } + Uppercaseificate(path, pPath); + if (strstr(path, ".MAT") != NULL) { + AddMaterials(gStorage_for_callbacks, pPath, shading); + } +} + +// FUNCTION: CARMA2_HW 0x00502ad0 +void C2_HOOK_FASTCALL LoadAllMaterialsInDirectory(tBrender_storage* pStorage, const char* pPath, tRendererShadingType pShading) { -// LoadIfItsAMaterial + gMaterial_shading_for_callback = pShading; + gStorage_for_callbacks = pStorage; + PFForEveryFile(pPath, LoadIfItsAMaterial); + gMaterial_shading_for_callback = kRendererShadingType_Undefined; +} -// LoadAllMaterialsInDirectory +// FUNCTION: CARMA2_HW 0x00502b20 +void C2_HOOK_FASTCALL LoadIfItsAModel(const char* pPath) { + char s[256]; -// LoadIfItsAModel + Uppercaseificate(s, pPath); + if (strstr(s, ".DAT") != NULL) { + AddModels(gStorage_for_callbacks, pPath); + } +} -// LoadAllModelsInDirectory +// FUNCTION: CARMA2_HW 0x00502b00 +void C2_HOOK_FASTCALL LoadAllModelsInDirectory(tBrender_storage *pStorage, const char* pPath) { -// LoadIfItsAShadeTable + gStorage_for_callbacks = pStorage; + PFForEveryFile(pPath, LoadIfItsAModel); +} -// LoadAllShadeTablesInDirectory +// FUNCTION: CARMA2_HW 0x00502b80 +void C2_HOOK_FASTCALL LoadIfItsAShadeTable(const char* pPath) { + char path[256]; + + Uppercaseificate(path, pPath); + if (strstr(path, ".TAB") != NULL) { + AddShadeTables(gStorage_for_callbacks, pPath); + } +} + +// FUNCTION: CARMA2_HW 0x00502b60 +void C2_HOOK_FASTCALL LoadAllShadeTablesInDirectory(tBrender_storage* pStorage, const char* pPath) { + + gStorage_for_callbacks = pStorage; + PFForEveryFile(pPath, LoadIfItsAShadeTable); +} // LoadAllStuffInDirectory -// DisallowDuplicates +// FUNCTION: CARMA2_HW 0x00502d60 +void C2_HOOK_FASTCALL DisallowDuplicates(void) { -// AllowDuplicates +} + +// FUNCTION: CARMA2_HW 0x00502d70 +void C2_HOOK_FASTCALL AllowDuplicates(void) { + gDisallow_duplicates = 0; +} diff --git a/src/carma2/newcommon/28-world3.h b/src/carma2/newcommon/28-world3.h index cb780b1263..3eaeb0e60b 100644 --- a/src/carma2/newcommon/28-world3.h +++ b/src/carma2/newcommon/28-world3.h @@ -60,17 +60,17 @@ extern void C2_HOOK_FASTCALL InitialiseStorageSpace(int pUnknown, tBrender_stora // ClearOutStorageSpace -// AddPixelmapToStorage +extern tAdd_to_storage_result C2_HOOK_FASTCALL AddPixelmapToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_pm); -// AddShadeTableToStorage +extern tAdd_to_storage_result C2_HOOK_FASTCALL AddShadeTableToStorage(tBrender_storage* pStorage_space, br_pixelmap* pThe_st); -// AddMaterialToStorage +extern tAdd_to_storage_result C2_HOOK_FASTCALL AddMaterialToStorage(tBrender_storage* pStorage_space, br_material* pThe_mat); -// AddModelToStorage +extern tAdd_to_storage_result C2_HOOK_FASTCALL AddModelToStorage(tBrender_storage* pStorage_space, br_model* pThe_mod); -tAdd_to_storage_result C2_HOOK_FASTCALL AddSoundToStorage(tBrender_storage* pStorage_space, int pSound_id); +extern tAdd_to_storage_result C2_HOOK_FASTCALL AddSoundToStorage(tBrender_storage* pStorage_space, int pSound_id); -// AddPixelmaps +extern int C2_HOOK_FASTCALL AddPixelmaps(tBrender_storage* pStorage_space, const char* path); // LoadSinglePixelmap @@ -80,40 +80,40 @@ tAdd_to_storage_result C2_HOOK_FASTCALL AddSoundToStorage(tBrender_storage* pSto extern tAdd_to_storage_result C2_HOOK_FASTCALL LoadSingleSound(tBrender_storage* pStorage_space, int pSound_id); -// AddShadeTables +extern int C2_HOOK_FASTCALL AddShadeTables(tBrender_storage* pStorage_space, const char* pPath); -// AddModels +extern int C2_HOOK_FASTCALL AddModels(tBrender_storage* pStorage_space, const char* pPath); -// AddMaterials +extern int C2_HOOK_FASTCALL AddMaterials(tBrender_storage* pStorage_space, const char* pPath, tRendererShadingType pShading); -// DodgyModelUpdate +extern void C2_HOOK_FASTCALL DodgyModelUpdate(br_model* pM); -// LoadIfItsAPixelmap +extern void C2_HOOK_FASTCALL LoadIfItsAPixelmap(const char* pPath); -// LoadAllPixelmapsInDirectory +extern void C2_HOOK_FASTCALL LoadAllPixelmapsInDirectory(tBrender_storage* pStorage, const char* pPath); -// GetFileName +extern int C2_HOOK_FASTCALL GetFileName(const char *path, tName_list *pList); -// GetAdditionalFileName +extern int C2_HOOK_FASTCALL GetAdditionalFileName(const char* path, tName_list* pList); -// LoadAllImagesInDirectory +extern void C2_HOOK_FASTCALL LoadAllImagesInDirectory(tBrender_storage* pStorage_space, const char* path); -// LoadIfItsAMaterial +extern void C2_HOOK_FASTCALL LoadIfItsAMaterial(const char* pPath); -// LoadAllMaterialsInDirectory +extern void C2_HOOK_FASTCALL LoadAllMaterialsInDirectory(tBrender_storage* pStorage, const char* pPath, tRendererShadingType pShading); -// LoadIfItsAModel +extern void C2_HOOK_FASTCALL LoadIfItsAModel(const char* pPath); -// LoadAllModelsInDirectory +extern void C2_HOOK_FASTCALL LoadAllModelsInDirectory(tBrender_storage *pStorage, const char* pPath); // LoadIfItsAShadeTable -// LoadAllShadeTablesInDirectory +extern void C2_HOOK_FASTCALL LoadAllShadeTablesInDirectory(tBrender_storage* pStorage, const char* pPath); -// LoadAllStuffInDirectory +extern void C2_HOOK_FASTCALL LoadIfItsAShadeTable(const char* pPath); -// DisallowDuplicates +extern void C2_HOOK_FASTCALL DisallowDuplicates(void); -// AllowDuplicates +extern void C2_HOOK_FASTCALL AllowDuplicates(void); #endif // GUARD_28_WORLD3_H diff --git a/src/carma2/newcommon/41-utility.c b/src/carma2/newcommon/41-utility.c index 7073c74a58..b152f38b58 100644 --- a/src/carma2/newcommon/41-utility.c +++ b/src/carma2/newcommon/41-utility.c @@ -2,7 +2,10 @@ #include "01-network.h" #include "02-init.h" +#include "18-graphics2.h" +#include "63-loading3.h" #include "69-sound.h" +#include "70-packfile.h" #include "globvars.h" #include "platform.h" @@ -37,29 +40,77 @@ br_error C2_HOOK_FASTCALL DRBrEnd(void) { return 0; } +// FUNCTION: CARMA2_HW 0x00513460 +void C2_HOOK_FASTCALL Uppercaseificate(char* dest, const char* src) { + int len; + int i; -// Uppercaseificate + len = (int)strlen(src); + for (i = 0; i < (int)len; i++) { + dest[i] = toupper(src[i]); + } + dest[len] = '\0'; +} // CheckQuit // sqr -// STUB: CARMA2_HW 0x00513520 +// FUNCTION: CARMA2_HW 0x00513520 int C2_HOOK_FASTCALL IRandomBetween(int pA, int pB) { - NOT_IMPLEMENTED(); + int num; + +#if RAND_MAX == 0x7fff + num = (pB + 1 - pA) * rand() / (RAND_MAX + 1) + pA; + return num; +#else + num = (pB + 1 - pA) * (rand() % 0x8000) / (0x7fff + 1) + pA; + return num; +#endif +} + +// FUNCTION: CARMA2_HW 0x00513550 +int C2_HOOK_FASTCALL PercentageChance(int pC) { + + if (pC == 0) { + return 0; + } + return IRandomBetween(0, 99) < pC; +} + +// FUNCTION: CARMA2_HW 0x00513580 +int C2_HOOK_FASTCALL IRandomPosNeg(int pN) { + + return IRandomBetween(-pN, pN); } -// PercentageChance +// FUNCTION: CARMA2_HW 0x005135b0 +float C2_HOOK_STDCALL FRandomBetween(float pA, float pB) { -// IRandomPosNeg +#if RAND_MAX == 0x7fff + return (float)rand() * (pB - pA) / (float)RAND_MAX + pA; +#else + return (float)(rand() % 0x10000) * (pB - pA) / (float)(0x7fff + 1) + pA; +#endif +} -// FRandomBetween +// FUNCTION: CARMA2_HW 0x005135e0 +float C2_HOOK_STDCALL FRandomPosNeg(float pN) { -// FRandomPosNeg + return FRandomBetween(-pN, pN); +} + +// FUNCTION: CARMA2_HW 0x00513620 +br_scalar C2_HOOK_STDCALL SRandomBetween(br_scalar pA, br_scalar pB) { -// SRandomBetween + return FRandomBetween(pA, pB); +} -// SRandomPosNeg +// FUNCTION: CARMA2_HW 0x00513650 +br_scalar C2_HOOK_STDCALL SRandomPosNeg(br_scalar pN) { + + return SRandomBetween(-pN, pN); +} // FUNCTION: CARMA2_HW 0x00513690 void C2_HOOK_FASTCALL PathCat(char* pDestn_str, const char* pStr_1, const char* pStr_2) { @@ -80,7 +131,15 @@ void C2_HOOK_FASTCALL PathCat(char* pDestn_str, const char* pStr_1, const char* // tandeg -// GetFileLength +// FUNCTION: CARMA2_HW 0x00513790 +tU32 C2_HOOK_FASTCALL GetFileLength(FILE* pF) { + tU32 the_size; + + PFfseek(pF, 0, SEEK_END); + the_size = PFftell(pF); + PFrewind(pF); + return the_size; +} // FUNCTION: CARMA2_HW 0x005137d0 br_pixelmap* C2_HOOK_FASTCALL DRPixelmapAllocate(br_uint_8 pType, br_uint_16 pW, br_uint_16 pH, void* pPixels, int pFlags) { @@ -110,11 +169,52 @@ br_pixelmap* C2_HOOK_FASTCALL DRPixelmapAllocateSub(br_pixelmap* pPm, br_uint_16 // DRPixelmapLoad -// SepDirAndFilename +// FUNCTION: CARMA2_HW 0x005139a0 +void C2_HOOK_FASTCALL SepDirAndFilename(const char* path, char* dirPath, char* stemPath) { + size_t pathLen; + size_t dirLen; + size_t i; + + pathLen = strlen(path); + dirLen = 0; + for (i = pathLen - 1; ; i--) { + if (i == 0) { + break; + } + if (path[i] == gDir_separator[0]) { + dirLen = i; + break; + } + } + memcpy(dirPath, path, dirLen); + dirPath[dirLen] = '\0'; + if (*dirPath != '\0') { + dirLen += 1; + } + for (i = 0; path[dirLen + i] != '.' && dirLen + i != pathLen; i++) { + stemPath[i] = path[dirLen + i]; + } + stemPath[i] = '\0'; +} // DRLoadMultiplePix -// DRPixelmapLoadMany +// FUNCTION: CARMA2_HW 0x00514570 +int C2_HOOK_FASTCALL DRPixelmapLoadMany(const char* texturePathNoExt, br_pixelmap** pixelmaps, size_t capacity) { + tPath_name texturePath; + tPath_name texturePathDir; + tPath_name texturePathStem; + int errorCode; + + strcpy(texturePath, texturePathNoExt); + strcat(texturePath, ".TIF"); + SepDirAndFilename(texturePath, texturePathDir, texturePathStem); + pixelmaps[0] = DRLdImg(texturePathDir, texturePathStem, gRender_palette, gPixelFlags, &errorCode); + if (pixelmaps[0] == NULL || errorCode != 0) { + return 0; + } + return 1; +} // WaitFor @@ -315,7 +415,38 @@ static tMaterial_exception* C2_HOOK_FASTCALL FindExceptionInList(const char* pId return pList; } -// NobbleNonzeroBlacks +// FUNCTION: CARMA2_HW 0x00517fa0 +void C2_HOOK_FASTCALL NobbleNonzeroBlacks(br_pixelmap* pPalette) { + int modified; + int i; + br_colour *pixels; + br_colour c; + int r; + int g; + int b; + + pixels= pPalette->pixels; + modified = 0; + if (*pixels != BR_COLOUR_RGBA(0, 0, 0, 0)) { + *pixels = BR_COLOUR_RGBA(0, 0, 0, 0); + modified = 1; + } + pixels++; + for (i = 0; i < 255; i++ ) { + c = *pixels; + r = BR_COLOUR_RED(c); + g = BR_COLOUR_GRN(c); + b = BR_COLOUR_BLU(c); + if (r == 0 && g == 0 && b == 0) { + *pixels = BR_COLOUR_RGB(1, 1, 1); + modified = 1; + } + pixels++; + } + if (modified) { + BrMapUpdate(pPalette, BR_MAPU_ALL); + } +} // FUNCTION: CARMA2_HW 0x005182f0 void C2_HOOK_FASTCALL GlorifyMaterial(br_material** pMaterials, int pCount, tRendererShadingType pShading) { @@ -384,7 +515,29 @@ void C2_HOOK_FASTCALL GlorifyMaterial(br_material** pMaterials, int pCount, tRen // FindBestColourMatch -// WhitenVertexRGB +// FUNCTION: CARMA2_HW 0x00518690 +void C2_HOOK_FASTCALL WhitenVertexRGB(br_model** pModels, int pCount) { + int i; + br_vertex* vertex; + + if (gScreen == NULL) { + return; + } + if (gScreen->type == BR_PMT_INDEX_8) { + return; + } + for (i = 0; i < pCount; i++) { + int j; + + for (j = 0; j < pModels[i]->nvertices; j++) { + vertex = &pModels[i]->vertices[j]; + + vertex->red = 0xff; + vertex->grn = 0xff; + vertex->blu = 0xff; + } + } +} // ArenaOpenFile diff --git a/src/carma2/newcommon/41-utility.h b/src/carma2/newcommon/41-utility.h index 411d7586f5..632a3b32fc 100644 --- a/src/carma2/newcommon/41-utility.h +++ b/src/carma2/newcommon/41-utility.h @@ -9,7 +9,7 @@ extern char* gMisc_strings[300]; extern br_error C2_HOOK_FASTCALL DRBrEnd(void); -// Uppercaseificate +extern void C2_HOOK_FASTCALL Uppercaseificate(char* dest, const char* src); // CheckQuit @@ -17,23 +17,23 @@ extern br_error C2_HOOK_FASTCALL DRBrEnd(void); extern int C2_HOOK_FASTCALL IRandomBetween(int pA, int pB); -// PercentageChance +extern int C2_HOOK_FASTCALL PercentageChance(int pC); -// IRandomPosNeg +extern int C2_HOOK_FASTCALL IRandomPosNeg(int pN); -// FRandomBetween +extern float C2_HOOK_STDCALL FRandomBetween(float pA, float pB); -// FRandomPosNeg +extern float C2_HOOK_STDCALL FRandomPosNeg(float pN); -// SRandomBetween +extern br_scalar C2_HOOK_STDCALL SRandomBetween(br_scalar pA, br_scalar pB); -// SRandomPosNeg +extern br_scalar C2_HOOK_STDCALL SRandomPosNeg(br_scalar pN); extern void C2_HOOK_FASTCALL PathCat(char* pDestn_str, const char* pStr_1, const char* pStr_2); // tandeg -// GetFileLength +extern tU32 C2_HOOK_FASTCALL GetFileLength(FILE* pF); extern br_pixelmap* C2_HOOK_FASTCALL DRPixelmapAllocate(br_uint_8 pType, br_uint_16 pW, br_uint_16 pH, void* pPixels, int pFlags); @@ -43,11 +43,11 @@ extern br_pixelmap* C2_HOOK_FASTCALL DRPixelmapAllocateSub(br_pixelmap* pPm, br_ // DRPixelmapLoad -// SepDirAndFilename +extern void C2_HOOK_FASTCALL SepDirAndFilename(const char* path, char* dirPath, char* stemPath); // DRLoadMultiplePix -// DRPixelmapLoadMany +extern int C2_HOOK_FASTCALL DRPixelmapLoadMany(const char* texturePathNoExt, br_pixelmap** pixelmaps, size_t capacity); // WaitFor @@ -179,13 +179,13 @@ extern int C2_HOOK_FASTCALL PossibleUnlock(int pValue); // tMaterial_exception* C2_HOOK_FASTCALL FindExceptionInList(const char* pIdentifier, tMaterial_exception* pList) -// NobbleNonzeroBlacks +extern void C2_HOOK_FASTCALL NobbleNonzeroBlacks(br_pixelmap* pPalette); extern void C2_HOOK_FASTCALL GlorifyMaterial(br_material** pMaterials, int pCount, tRendererShadingType pShading); // FindBestColourMatch -// WhitenVertexRGB +extern void C2_HOOK_FASTCALL WhitenVertexRGB(br_model** pModels, int pCount); // ArenaOpenFile diff --git a/src/carma2/newcommon/63-loading3.c b/src/carma2/newcommon/63-loading3.c index f046d7b23d..53879d119c 100644 --- a/src/carma2/newcommon/63-loading3.c +++ b/src/carma2/newcommon/63-loading3.c @@ -119,19 +119,106 @@ br_pixelmap* C2_HOOK_FASTCALL LoadPixelmap(const char* pPath_name) { // LoadActor -// DRLoadPalette +// FUNCTION: CARMA2_HW 0x0048f090 +void C2_HOOK_FASTCALL DRLoadPalette(const char* pPath_name) { + br_pixelmap* palette_array[100]; + int number_of_palettes; + int i; + + number_of_palettes = BrPixelmapLoadMany(pPath_name, palette_array, REC2_ASIZE(palette_array)); + for (i = 0; i < number_of_palettes; i++) { + palette_array[i]->row_bytes = (palette_array[i]->row_bytes + 3) & ~0x3; + palette_array[i]->base_x = 0; + palette_array[i]->base_y = 0; + } + BrTableAddMany(palette_array, number_of_palettes); +} -// DRLoadShadeTable +// FUNCTION: CARMA2_HW 0x0048f100 +void C2_HOOK_FASTCALL DRLoadShadeTable(const char* pPath_name) { + br_pixelmap* table_array[100]; + int number_of_tables; + int i; + + number_of_tables = BrPixelmapLoadMany(pPath_name, table_array, REC2_ASIZE(table_array)); + for (i = 0; i < number_of_tables; i++) { + table_array[i]->row_bytes = (table_array[i]->row_bytes + 3) & ~0x3; + table_array[i]->base_x = 0; + table_array[i]->base_y = 0; + } + BrTableAddMany(table_array, number_of_tables); +} -// DRLoadMaterials +// FUNCTION: CARMA2_HW 0x0048f1d0 +void C2_HOOK_FASTCALL DRLoadMaterials(const char* pPath_name) { + br_material* material_array[100]; + int i; + int number_of_materials; -// DRLoadModels + PossibleService(); + number_of_materials = BrMaterialLoadMany(pPath_name, material_array, REC2_ASIZE(material_array)); + for (i = 0; i < number_of_materials; i++) { + material_array[i]->flags &= ~BR_MATF_LIGHT; + } + BrMaterialAddMany(material_array, number_of_materials); +} -// DRLoadActors +// FUNCTION: CARMA2_HW 0x0048f230 +void C2_HOOK_FASTCALL DRLoadModels(const char* pPath_name) { + int i; + br_model* model_array[100]; + int number_of_models; -// DRLoadLights + PossibleService(); + number_of_models = BrModelLoadMany(pPath_name, model_array, REC2_ASIZE(model_array)); + WhitenVertexRGB(model_array, number_of_models); + for (i = 0; i < number_of_models; i++) { + model_array[i]->flags = BR_MODF_UPDATEABLE; + } + BrModelAddMany(model_array, number_of_models); +} -// LoadInFiles +// FUNCTION: CARMA2_HW 0x0048f290 +void C2_HOOK_FASTCALL DRLoadActors(const char* pPath_name) { + int i; + br_actor* actor_array[100]; + int number_of_actors; + + PossibleService(); + number_of_actors = BrActorLoadMany(pPath_name, actor_array, REC2_ASIZE(actor_array)); + for (i = 0; i < number_of_actors; i++) { + gActor_array[gNumber_of_actors] = actor_array[i]; + gNumber_of_actors++; + } +} + +// FUNCTION: CARMA2_HW 0x0048f2e0 +void C2_HOOK_FASTCALL DRLoadLights(const char* pPath_name) { + br_actor* actor; + br_light* light; + + actor = BrActorAllocate(BR_ACTOR_LIGHT, NULL); + light = actor->type_data; + light->type = BR_LIGHT_DIRECT; + light->colour = BR_COLOUR_RGB(gLighting_data.directional.red, gLighting_data.directional.green, gLighting_data.directional.blue); + light->attenuation_c = 1.0f; + BrMatrix34RotateX(&actor->t.t.mat, BR_ANGLE_DEG(-60)); + BrMatrix34PostRotateY(&actor->t.t.mat, BR_ANGLE_DEG(30)); + gLight_array[gNumber_of_lights] = actor; + gNumber_of_lights++; + EnableLights(); +} + +// FUNCTION: CARMA2_HW 0x0048f360 +void C2_HOOK_FASTCALL LoadInFiles(const char* pThe_path, const char* pArchive_name, tPDForEveryFileRecurse_cbfn pAction_routine) { + tPath_name the_path; + tTWTVFS twt; + + PathCat(the_path, pThe_path, pArchive_name); + twt = OpenPackFileAndSetTiffLoading(the_path); + PFForEveryFile(the_path, pAction_routine); + ClosePackFileAndSetTiffLoading(twt); +} // STUB: CARMA2_HW 0x0048f3b0 int C2_HOOK_FASTCALL TestForOriginalCarmaCDinDrive(void) { diff --git a/src/carma2/newcommon/63-loading3.h b/src/carma2/newcommon/63-loading3.h index 38438d3991..f498ef6935 100644 --- a/src/carma2/newcommon/63-loading3.h +++ b/src/carma2/newcommon/63-loading3.h @@ -3,6 +3,7 @@ #include "c2_hooks.h" #include "brender/brender.h" +#include "rec2_types.h" // NearestPowerOfTwo @@ -22,19 +23,19 @@ extern br_pixelmap* C2_HOOK_FASTCALL LoadPixelmap(const char* pPath_name); // LoadActor -// DRLoadPalette +extern void C2_HOOK_FASTCALL DRLoadPalette(const char* pPath_name); -// DRLoadShadeTable +extern void C2_HOOK_FASTCALL DRLoadShadeTable(const char* pPath_name); -// DRLoadMaterials +extern void C2_HOOK_FASTCALL DRLoadMaterials(const char* pPath_name); -// DRLoadModels +extern void C2_HOOK_FASTCALL DRLoadModels(const char* pPath_name); -// DRLoadActors +extern void C2_HOOK_FASTCALL DRLoadActors(const char* pPath_name); -// DRLoadLights +extern void C2_HOOK_FASTCALL DRLoadLights(const char* pPath_name); -// LoadInFiles +extern void C2_HOOK_FASTCALL LoadInFiles(const char* pThe_path, const char* pArchive_name, tPDForEveryFileRecurse_cbfn pAction_routine); extern int C2_HOOK_FASTCALL TestForOriginalCarmaCDinDrive(void); diff --git a/src/carma2/newcommon/70-packfile.c b/src/carma2/newcommon/70-packfile.c index 8b208b09e7..3d49a7a87c 100644 --- a/src/carma2/newcommon/70-packfile.c +++ b/src/carma2/newcommon/70-packfile.c @@ -3,6 +3,7 @@ #include "08-loading1.h" #include "41-utility.h" #include "69-sound.h" +#include "platform.h" #include "rec2_macros.h" #include @@ -227,7 +228,17 @@ br_size_t C2_HOOK_FASTCALL PFfwrite(const void* buf, br_size_t size, unsigned in NOT_IMPLEMENTED(); } -// PFftell +// FUNCTION: CARMA2_HW 0x004b4b00 +int C2_HOOK_FASTCALL PFftell(FILE* pF) { + int pos; + + if ((uintptr_t)pF >= REC2_ASIZE(gTwatVfsFiles)) { + return ftell(pF); + } + pos = gTwatVfsFiles[(uintptr_t)pF].pos - gTwatVfsFiles[(uintptr_t)pF].start; + gTwatVfsFiles[(uintptr_t)pF].error = 0; + return pos; +} // FUNCTION: CARMA2_HW 0x004b4b70 int C2_HOOK_FASTCALL PFfseek(FILE* pF, int offset, int whence) { @@ -276,9 +287,45 @@ int C2_HOOK_FASTCALL PFfeof(FILE* pFile) { NOT_IMPLEMENTED(); } -// PFForEveryFile +// FUNCTION: CARMA2_HW 0x004b4c80 +void C2_HOOK_FASTCALL PFForEveryFile(const char* pThe_path, tPDForEveryFileRecurse_cbfn pAction_routine) { + int twt; + int i; + char buffer[256]; -// PFForEveryFile2 + for (twt = 0; twt < (int)REC2_ASIZE(gTwatVfsMountPoints); twt++) { + if (gTwatVfsMountPoints[twt].header == NULL) { + continue; + } + if (DRStricmp(pThe_path, gTwatVfsMountPoints[twt].path) != 0) { + continue; + } + for (i = 0; i < gTwatVfsMountPoints[twt].header->nbFiles; i++) { + PathCat(buffer, pThe_path, gTwatVfsMountPoints[twt].header->fileHeaders[i].filename); + pAction_routine(buffer); + } + return; + } + PDForEveryFile(pThe_path, pAction_routine); +} + +// FUNCTION: CARMA2_HW 0x004b4d30 +void C2_HOOK_FASTCALL PFForEveryFile2(const char* path, tEnumPathCallback pCallback, void* data) { + int twt; + int i; + tPath_name twt_filePath; + + for (twt = 0; twt < (int)REC2_ASIZE(gTwatVfsMountPoints); twt++) { + if (gTwatVfsMountPoints[twt].header != NULL && DRStricmp(gTwatVfsMountPoints[twt].path, path) == 0) { + for (i = 0; i < gTwatVfsMountPoints[twt].header->nbFiles; i++) { + PathCat(twt_filePath, path, gTwatVfsMountPoints[twt].header->fileHeaders[i].filename); + pCallback(twt_filePath, data); + } + return; + } + } + PDEnumPath(path, pCallback, data); +} // FUNCTION: CARMA2_HW 0x004b4df0 tTWTVFS C2_HOOK_FASTCALL OpenPackFileAndSetTiffLoading(const char* path) { @@ -298,7 +345,21 @@ void C2_HOOK_FASTCALL ClosePackFileAndSetTiffLoading(tTWTVFS twt) { NOT_IMPLEMENTED(); } -// PackFileRevertTiffLoading +// FUNCTION: CARMA2_HW 0x004b4e60 +void C2_HOOK_FASTCALL PackFileRevertTiffLoading(void) { + int count; + + count = gDisableTiffConversionStackPos; + if (count != 0) { // or > 0 if it is unsigned + gDisableTiffConversionStack[count] = gDisableTiffConversion; + gDisableTiffConversion = gDisableTiffConversionStack[count - 1]; + } +} -// PackFileRerevertTiffLoading +// FUNCTION: CARMA2_HW 0x004b4e90 +void C2_HOOK_FASTCALL PackFileRerevertTiffLoading(void) { + if (gDisableTiffConversionStackPos != 0) { + gDisableTiffConversion = gDisableTiffConversionStack[gDisableTiffConversionStackPos]; + } +} diff --git a/src/carma2/newcommon/70-packfile.h b/src/carma2/newcommon/70-packfile.h index 14120e6cb1..e996bcae1e 100644 --- a/src/carma2/newcommon/70-packfile.h +++ b/src/carma2/newcommon/70-packfile.h @@ -30,7 +30,7 @@ extern br_size_t C2_HOOK_FASTCALL PFfread(void* buf, br_size_t size, unsigned in extern br_size_t C2_HOOK_FASTCALL PFfwrite(const void* buf, br_size_t size, unsigned int n, void* f); -// PFftell +extern int C2_HOOK_FASTCALL PFftell(FILE* pF); extern int C2_HOOK_FASTCALL PFfseek(FILE* pF, int offset, int whence); @@ -38,16 +38,16 @@ extern void C2_HOOK_FASTCALL PFrewind(FILE* pF); extern int C2_HOOK_FASTCALL PFfeof(FILE* pFile); -// PFForEveryFile +extern void C2_HOOK_FASTCALL PFForEveryFile(const char* pThe_path, tPDForEveryFileRecurse_cbfn pAction_routine); -// PFForEveryFile2 +extern void C2_HOOK_FASTCALL PFForEveryFile2(const char* path, tEnumPathCallback pCallback, void* data); extern tTWTVFS C2_HOOK_FASTCALL OpenPackFileAndSetTiffLoading(const char* path); extern void C2_HOOK_FASTCALL ClosePackFileAndSetTiffLoading(tTWTVFS twt); -// PackFileRevertTiffLoading +extern void C2_HOOK_FASTCALL PackFileRevertTiffLoading(void); -// PackFileRerevertTiffLoading +extern void C2_HOOK_FASTCALL PackFileRerevertTiffLoading(void); #endif // GUARD_70_PACKFILE_H diff --git a/src/carma2/platform/win32/win32.c b/src/carma2/platform/win32/win32.c index c34d13a984..ff2853ce7a 100644 --- a/src/carma2/platform/win32/win32.c +++ b/src/carma2/platform/win32/win32.c @@ -34,7 +34,7 @@ #ifndef GET_SC_WPARAM #endif -#if defined(_MSC_VER) && _MSC_VER < 1200 +#if defined(_MSC_VER) && _MSC_VER < 1300 #define GET_SC_WPARAM(wParam) ((int)wParam &0xfff0) #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) typedef LONG LSTATUS;