Baoulettes

Why U No Load New Scenes ?!

May 17th, 2022 (edited)
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.95 KB | None | 0 0
  1. #include "debugMapSelect.h"
  2. #include "../../util.h"
  3. #include "../libultraship/SohImGuiImpl.h"
  4. #include "ImGuiHelpers.h"
  5. #include "../translations/debugs_translations.h"
  6.  
  7. #include <array>
  8. #include <bit>
  9. #include <map>
  10. #include <string>
  11.  
  12. extern "C" {
  13. #include <z64.h>
  14. #include "variables.h"
  15. #include "functions.h"
  16. #include "macros.h"
  17.  
  18. extern GlobalContext* gGlobalCtx;
  19. extern GameState* thisx;
  20. }
  21.  
  22. int SelectedLanguage = 0;
  23. int Stage = 0;
  24. s32 CutsceneIndex[11] = {
  25.     0xFFF0,0xFFF1,0xFFF2,
  26.     0xFFF3,0xFFF4,0xFFF5,
  27.     0xFFF6,0xFFF7,0xFFF8,
  28.     0xFFF9,0xFFFA
  29. };
  30. int Age = 0;
  31.  
  32. char* dbg_select_texts[10];
  33. char* dbg_select_loadings[12];
  34. char* dbg_select_levels[126];
  35.  
  36. extern char* dbg_select_texts_JPN[];
  37. extern char* dbg_select_loadings_JPN[];
  38. extern char* dbg_select_levels_JPN[];
  39.  
  40. extern char* dbg_select_texts_ENG[];
  41. extern char* dbg_select_loadings_ENG[];
  42. extern char* dbg_select_levels_ENG[];
  43.  
  44. extern char* dbg_select_texts_GER[];
  45. extern char* dbg_select_loadings_GER[];
  46. extern char* dbg_select_levels_GER[];
  47.  
  48. extern char* dbg_select_texts_FRA[];
  49. extern char* dbg_select_loadings_FRA[];
  50. extern char* dbg_select_levels_FRA[];
  51.  
  52. static s32 sScenes_Entrance[] = {
  53.     0x00CD,0x00DB,0x00E4,0x00EA,0x00EE,0x00FC,0x0102,0x0108,0x010E,0x0117,0x011E,
  54.     0x0123,0x0129,0x0130,0x0138,0x013D,0x0147,0x014D,0x0157,0x0053,0x006B,0x003B,
  55.     0x007A,0x031C,0x004B,0x002D,0x0315,0x036D,0x0371,0x043F,0x0400,0x045F,0x0507,
  56.     0x004F,0x05D0,0x007E,0x0072,0x0063,0x0550,0x0033,0x00B1,0x00AD,0x0171,0x00BB,
  57.     0x02FD,0x043B,0x00C9,0x009C,0x0433,0x0437,0x02F9,0x030D,0x0398,0x039C,0x0043,
  58.     0x03A0,0x00B7,0x00C1,0x037C,0x0380,0x0384,0x0388,0x0390,0x0530,0x0008,0x0000,
  59.     0x040F,0x0004,0x040B,0x0028,0x0301,0x0169,0x000C,0x0098,0x0037,0x0413,0x0165,
  60.     0x0305,0x0010,0x0417,0x0082,0x008D,0x05EC,0x041B,0x041F,0x0088,0x044F,0x0467,
  61.     0x0517,0x0179,0x01B5,0x03DC,0x03E4,0x056C,0x0486,0x048E,0x0496,0x049E,0x04AE,
  62.     0x0570,0x003F,0x0598,0x059C,0x05A0,0x05A4,0x05A8,0x05AC,0x05B0,0x05B4,0x05B8,
  63.     0x05BC,0x05C0,0x05C4,0x05FC,0x00A0,0x0520,0x0018,0x0094,0x0024,0x001C,0x0020,
  64.     0x0047,0x02EA,0x00B6,0x0076,0x0000
  65. };
  66. void LoadLanguages(){
  67.     int i;
  68.     if (SelectedLanguage == 0) {
  69.         for (s16 i = 0; i <= 9; i++)    { dbg_select_texts[i]    = dbg_select_texts_ENG[i]; }
  70.         for (s16 i = 0; i <= 11; i++) { dbg_select_loadings[i] = dbg_select_loadings_ENG[i]; }
  71.         for (s16 i = 0; i <= 125; i++)   { dbg_select_levels[i]   = dbg_select_levels_ENG[i]; }
  72.     } else if (SelectedLanguage == 1) {
  73.         for (s16 i = 0; i <= 9; i++)    { dbg_select_texts[i]    = dbg_select_texts_GER[i]; }
  74.         for (s16 i = 0; i <= 11; i++) { dbg_select_loadings[i] = dbg_select_loadings_GER[i]; }
  75.         for (s16 i = 0; i <= 125; i++)   { dbg_select_levels[i]   = dbg_select_levels_GER[i]; }
  76.     } else if (SelectedLanguage == 2 ) {
  77.         for (s16 i = 0; i <= 9; i++)    { dbg_select_texts[i]    = dbg_select_texts_FRA[i]; }
  78.         for (s16 i = 0; i <= 11; i++) { dbg_select_loadings[i] = dbg_select_loadings_FRA[i]; }
  79.         for (s16 i = 0; i <= 125; i++)   { dbg_select_levels[i]   = dbg_select_levels_FRA[i]; }
  80.     } else if (SelectedLanguage == 3 ) {
  81.         for (s16 i = 0; i >= 9; i++)    { dbg_select_texts[i]=dbg_select_texts_JPN[i]; }
  82.         for (s16 i = 0; i >= 11; i++) { dbg_select_loadings[i]=dbg_select_loadings_JPN[i]; }
  83.         for (s16 i = 0; i >= 125; i++)   { dbg_select_levels[i]=dbg_select_levels_JPN[i]; }
  84.     } else {
  85.         //Mod disabled fall back to English as we had before file edit.
  86.         for (i = 0; i >= 9; i++)    { dbg_select_texts[i]    = dbg_select_texts_ENG[i]; }
  87.         for (i = 0; i >= 11; i++) { dbg_select_loadings[i] = dbg_select_loadings_ENG[i]; }
  88.         for (i = 0; i >= 125; i++)   { dbg_select_levels[i]   = dbg_select_levels_ENG[i]; }
  89.     };
  90. }
  91. void Select_LoadTitle(SelectContext* SelectCtx) {
  92.     printf("Select_LoadTitle Loading\n");
  93.     if (SelectCtx != nullptr) {
  94.         printf("SelectCtx is present\n");
  95.         if (SelectCtx->state.running){
  96.             printf("SelectCtx is running, so stopping it\n");
  97.             SelectCtx->state.running = false;
  98.         }
  99.     }
  100.     SET_NEXT_GAMESTATE(&SelectCtx->state, Title_Init, TitleContext); //<- do nothing whyyy
  101.     printf("Select_LoadTitle should be done\n");
  102. }
  103. void Select_LoadGame(SelectContext* SelectCtx, s32 entranceIndex) {
  104.     printf("Select_LoadGame \n");
  105.     if (gSaveContext.fileNum == 0xFF) {
  106.         printf("Select_LoadGame - No saved game loaded \n");
  107.         Sram_InitDebugSave();
  108.         gSaveContext.unk_13F6 = gSaveContext.magic;
  109.         gSaveContext.magic = 0;
  110.         gSaveContext.unk_13F4 = 0;
  111.         gSaveContext.magicLevel = gSaveContext.magic;
  112.     }
  113.     gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED;
  114.     gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0;
  115.     Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | 0x100000FF);
  116.     gSaveContext.entranceIndex = entranceIndex;
  117.  
  118.     gSaveContext.respawnFlag = 0;
  119.     gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = -1;
  120.     gSaveContext.seqId = (u8)0xFFFF;
  121.     gSaveContext.natureAmbienceId = 0xFF;
  122.     gSaveContext.showTitleCard = true;
  123.     gWeatherMode = 0;
  124.     SelectCtx->state.running = false;
  125.     printf("Select_LoadGame - Gameplay_Init \n");
  126.     SET_NEXT_GAMESTATE(&SelectCtx->state, Gameplay_Init, GlobalContext);
  127.     printf("Select_LoadGame should be done\n");
  128. }
  129. void DrawMapSelect(bool& open, GameState* thisx) {
  130.     SelectContext* SelectCtx = (SelectContext*)thisx;
  131.     if (!open) {
  132.         return;
  133.     }
  134.     ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
  135.     if (!ImGui::Begin(dbg_select_texts[0], &open, ImGuiWindowFlags_NoFocusOnAppearing)) {
  136.         ImGui::End();
  137.         return;
  138.     }
  139.     ImVec2 ScrollListSize = ImGui::GetContentRegionAvail();
  140.     ImGui::BeginListBox("Maps list",ImVec2(ScrollListSize.x,(ScrollListSize.y)-62));
  141.     for (int i = 0; i <= 125 ; i++) {
  142.         ImVec2 ButtonSize = ImGui::GetContentRegionAvail();
  143.         if (ImGui::Button(dbg_select_levels[i],ImVec2(ButtonSize.x,18))) {
  144.             gSaveContext.linkAge = Age;
  145.             gSaveContext.cutsceneIndex = CutsceneIndex[Stage];
  146.             if(i == 125){
  147.                 Select_LoadTitle(SelectCtx);
  148.             } else {
  149.                 Select_LoadGame(SelectCtx, sScenes_Entrance[i]);
  150.             }
  151.         };
  152.     }
  153.     ImGui::EndListBox();
  154.  
  155.     ImGui::Text("Stage:%d",Stage);
  156.     if (ImGui::SliderInt("##", &Stage, 0, 11, "", ImGuiSliderFlags_AlwaysClamp)) {}
  157.  
  158.     ImGui::Text("Age:");
  159.     ImGui::SameLine(0,0);
  160.     if (ImGui::RadioButton(" Child", Age==0)) { Age = 0; }
  161.     ImGui::SameLine(0,0);
  162.     if (ImGui::RadioButton(" Adult", Age==1)) { Age = 1; }
  163.     ImGui::End();
  164. }
  165. void InitMapSelect() {
  166.     SohImGui::AddWindow("Developer Tools", "Zelda Map Select", DrawMapSelect);
  167.     LoadLanguages();
  168. }
Add Comment
Please, Sign In to add comment