CryZe

Wind Waker - Save and Death Warp Location Function

Oct 30th, 2014
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.87 KB | None | 0 0
  1. struct checkData
  2. {
  3.     bool isActive; //0
  4.     short eventFlagMask; //2
  5.     char stage[8]; //4
  6.     char room; //12
  7.     char startCode; //13
  8. };
  9.  
  10. struct stag_info
  11. {
  12.     /*0x00*/ float depthMin;
  13.     /*0x04*/ float depthMax;
  14.     /*0x09*/ char stageGroupID; //Determines if the stage is a dungeon, and if so, which one. 0x7 is Dragon Roost Cavern, 0x9 is the Forbidden Woods, 0xB is the Tower of the Gods, 0xD is the Earth Temple, and 0xF is the Wind Temple. The only differences that could be seen between them is that these IDs display the key counter in the UI and write the correct names into the space on the dungeon map screen.
  15.     /*0x0A*/ short loadedParticleBank; //particle bank to load for the stage. Method of IDing a certain particle bank is currently unknown.
  16.     /*0x0C*/ int someFlags;
  17.     /*0x10*/ byte unknown2; //RGB data? I don't know for what though, nothing changed when I changed this. These three unknowns are usually set to 00 00 FF. That can be the default value to use for file creation, since it works
  18.     /*0x11*/ byte unknown3;
  19.     /*0x12*/ short drawRange;
  20. };
  21.  
  22. struct scls_info
  23. {
  24.     /*0x0*/ char stage[8]; //Name of destination worldspace
  25.     /*0x8*/ byte startCode; //Spawn index to use to enter the destination map
  26.     /*0x9*/ byte room; //Number of destination room
  27.     /*0xA*/ byte wipe; //The old doc says this is "exitType," but I messed with it and found no changes?
  28.     /*0xB*/ byte padding;
  29. };
  30.  
  31. struct map_info
  32. {
  33.     /*0x00*/ float fullMapImageScaleX;
  34.     /*0x04*/ float fullMapImageScaleY;
  35.     /*0x08*/ float fullMapSpaceScaleX;
  36.     /*0x0C*/ float fullMapSpaceScaleY;
  37.     /*0x10*/ float fullMapXCoord;
  38.     /*0x14*/ float fullMapYCoord;
  39.     /*0x18*/ float zoomedMapXScrolling1; //Something with scrolling, but that's also defined below?
  40.     /*0x1C*/ float zoomedMapYScrolling1; //Does something like scrolling on y-axis
  41.     /*0x20*/ float zoomedMapXScrolling2;
  42.     /*0x24*/ float zoomedMapYScrolling2;
  43.     /*0x28*/ float zoomedMapXCoord;
  44.     /*0x2C*/ float zoomedMapYCoord;
  45.     /*0x30*/ float zoomedMapScale; //That's what it appeared to affect, anyway
  46.     /*0x34*/ byte unknown1; //Always 0x80?
  47.     /*0x35*/ byte mapIndex; //number of the map image to use. For instance, using the first image would be 80, the second 81, and so on.
  48.     /*0x36*/ byte quadrantCoordinates; //2 signed nybbles, ZX
  49.     /*0x37*/ byte padding;
  50. };
  51.  
  52. checkData l_checkData[6] =
  53. {
  54.     checkData(true, 0x2A08, "", 0, 0), //Late Game
  55.     checkData(true, 0x0F80, "sea", 0xB, 0x80), //Windfall
  56.     checkData(true, 0x0801, "MajyuE", 0, 0), //Forsaken Fortress 1
  57.     checkData(true, 0x0808, "MajyuE", 0, 0x12), //Forsaken Fortress 1 on Pirate Ship?
  58.     checkData(true, 0x2401, "A_umikz", 0, 0xCC), //On the Ocean with the Pirates
  59.     checkData(false, 0x0000, "sea", 0x2C, 0x80) //Outset
  60. }
  61.  
  62. void dComIfGs_setGameStartStage_Fv()
  63. {
  64.     int room;
  65.     char startCode;
  66.     char stage[8];
  67.     float coordinates[3];
  68.     map_info* mapInfo;
  69.     stag_info* stagInfo;
  70.     scls_info* sclsInfo;
  71.     char stageGroupID;
  72.     char stageType;
  73.    
  74.     checkData* l_checkDataIterator = &l_checkData;
  75.     for (int i = 0; i < 5; ++i)
  76.     {
  77.         if (l_checkDataIterator->isActive == 1 && isEventBit(&g_dComIfG_gameInfo->eventFlags, l_checkDataIterator->eventFlagMask))
  78.             break;
  79.        
  80.         l_checkDataIterator++;
  81.     }
  82.  
  83.     if (strcmp(&l_checkDataIterator->stage, "") != 0)
  84.     {
  85.         strcpy(stage, &l_checkDataIterator->stage);
  86.         room = l_checkDataIterator->room;
  87.         startCode = l_checkDataIterator->startCode;
  88.     }
  89.     else
  90.     {
  91.         getStagInfo = g_dComIfG_gameInfo->stageData->getStagInfo;
  92.         stagInfo = getStagInfo(&g_dComIfG_gameInfo->stageData);
  93.         stageType = (stagInfo->someFlags >> 16) & 0x7;
  94.         stageGroupID = (stagInfo->stageGroupID >> 1) & 0x7F;
  95.  
  96.         if (strcmp(&g_dComIfG_gameInfo->currentStage, "PShip") == 0)
  97.         {
  98.             strcpy(stage, "sea");
  99.             room = (int)getEventReg_11dSv_event(&g_dComIfG_gameInfo->eventFlags, 0xC3FF);
  100.             startCode = getEventReg_11dSv_event(&g_dComIfG_gameInfo->eventFlags, 0x85FF);
  101.             dKy_set_nexttime(*(r2 - 0x79D0));
  102.         }
  103.         else if (stageType == 0x7)
  104.         {
  105.             r29 = g_dComIfG_gameInfo->address0x5B40;
  106.             startCode = r29->address0x3594 & 0xFF;
  107.             room = r29->address0x20A;
  108.             if (room >= 0 && startCode != 0xFF && dComIfGs_checkSeaLandingEvent(room))
  109.             {
  110.                 //On the ocean, no calculation needed?
  111.                 strcpy(stage, &g_dComIfG_gameInfo->currentStage);
  112.             }
  113.             else
  114.             {
  115.                 //On the ocean, calculate spawn by geometry?
  116.                 r3 = g_dComIfG_gameInfo->address0x5B48; //803BDC50
  117.                 if (r3 != 0)
  118.                 {
  119.                     sclsInfo = dComIfGs_getMeshSceneList(r3 + 504);
  120.                 }
  121.                 else
  122.                 {
  123.                     sclsInfo = dComIfGs_getMeshSceneList(r29 + 504);
  124.                 }
  125.                 strcpy(stage, &sclsInfo->stage);
  126.                 room = (int)sclsInfo->room;
  127.                 startCode = sclsInfo->startCode;
  128.             }
  129.         }
  130.         else if (stageType == 1 /*Normal Dungeon Room*/ || stageType == 6 /*Miniboss*/ || stageType == 3 /*Boss*/ || stageType == 8 || stageGroupID == 9)
  131.         {
  132.             //Dungeons
  133.             sclsInfo = getSceneList(0);
  134.             strcpy(stage, &sclsInfo->stage);
  135.             room = (int)sclsInfo->room;
  136.             startCode = sclsInfo->startCode;
  137.         }
  138.         else if (stageGroupID == 10)
  139.         {
  140.             //Beedle and Submarine
  141.             float* oceanCoordinates = &g_dComIfG_gameInfo->oceanCoordinates;
  142.             coordinates[0] = oceanCoordinates[0];
  143.             coordinates[1] = oceanCoordinates[1];
  144.             coordinates[2] = oceanCoordinates[2];
  145.             sclsInfo = dComIfGd_getMeshSceneList(coordinates);
  146.             strcpy(stage, &sclsInfo->stage);
  147.             room = (int)sclsInfo->room;
  148.             startCode = sclsInfo->startCode;
  149.         }
  150.         else if (stageGroupID >= 11 || stageGroupID == 13)
  151.         {
  152.             //Everything with a map
  153.             strcpy(stage, "sea");
  154.             getMapInfo = g_dComIfG_gameInfo->stageData->getMapInfo;
  155.             mapInfo = getMapInfo(&g_dComIfG_gameInfo->stageData);
  156.             assert(mapInfo != 0);
  157.             room = (int)(7 * (dStage_mapInfo_GetOceanZ(mapInfo) + 3) + dStage_mapInfo_GetOceanX(mapInfo) + 4);
  158.             startCode = 0;
  159.         }
  160.         else
  161.         {
  162.             //Default to Windfall
  163.             strcpy(stage, "sea");
  164.             room = 11;
  165.             startCode = 0;
  166.         }
  167.     }
  168.  
  169.     set_25dSv_player_return_place(&g_dComIfG_gameInfo->saveStage, stage, room, startCode);
  170. }
Advertisement
Add Comment
Please, Sign In to add comment