theballaam96

DK64 - Limit to 1 file, expand save file

Sep 2nd, 2022 (edited)
2,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.65 KB | None | 0 0
  1. // NOTE: Save file expansion unintentionally disables global data writing (for now)
  2. /*
  3.     Only useful if you need to have more singles/bunches/coins in the world or you need more flags
  4.     The following code needs to be run during ROM init
  5. */
  6.  
  7. void expandSaveFile(int static_expansion, int actor_count) {
  8.     /*
  9.         Example Usage:
  10.             expandSaveFile(0x100,300);
  11.         0x100 - How many flags extra you'll need outside of coins/cbs/dirt patches
  12.         300 - Max Amount of balloons and dirt patches you're expecting (Vanilla: 121)
  13.     */
  14.     int expansion = static_expansion + actor_count;
  15.     int model2_start = 800 + expansion;
  16.     int flag_block_size = 0x6B7 + expansion;
  17.     // Flag Block Size
  18.     *(short*)(0x8060E36A) = flag_block_size;
  19.     *(short*)(0x8060E31E) = flag_block_size;
  20.     *(short*)(0x8060E2C6) = flag_block_size;
  21.     *(short*)(0x8060D54A) = flag_block_size;
  22.     *(short*)(0x8060D4A2) = flag_block_size;
  23.     *(short*)(0x8060D45E) = flag_block_size;
  24.     *(short*)(0x8060D3C6) = flag_block_size;
  25.     *(short*)(0x8060D32E) = flag_block_size;
  26.     *(short*)(0x8060D23E) = flag_block_size;
  27.     *(short*)(0x8060CF62) = flag_block_size;
  28.     *(short*)(0x8060CC52) = flag_block_size;
  29.     *(short*)(0x8060C78A) = flag_block_size;
  30.     *(short*)(0x8060C352) = flag_block_size;
  31.     *(short*)(0x8060BEC6) = flag_block_size - 0x72; // (0x645, might need adjusting)
  32.     *(short*)(0x8060BF96) = flag_block_size;
  33.     *(short*)(0x8060BA7A) = flag_block_size;
  34.     // Model 2 Start
  35.     *(short*)(0x8060C2F2) = model2_start;
  36.     *(short*)(0x8060BCDE) = model2_start;
  37.     // Reallocate Balloons + Patches
  38.     *(short*)(0x80688BCE) = 800 + static_expansion; // Reallocated to just before model 2 block
  39. }
  40.  
  41. // 1-File Fixes
  42. /*
  43.     Does the following things:
  44.     - Disables EEPROM Shuffling
  45.     - Files 2 & 3 read file 1
  46.     - Saving cannot occur with files 2->4. For all intents & purposes, these files no longer exist
  47. */
  48. *(int*)(0x8060CF34) = 0x240E0001; // Slot 1
  49. *(int*)(0x8060CF38) = 0x240F0002; // Slot 2
  50. *(int*)(0x8060CF3C) = 0x24180003; // Slot 3
  51. *(int*)(0x8060CF40) = 0x240D0000; // Slot 0
  52. *(int*)(0x8060D3AC) = 0; // Prevent EEPROM Shuffle
  53. *(int*)(0x8060DCE8) = 0; // Prevent EEPROM Shuffle
  54. *(int*)(0x8060C760) = 0x24900000; // Always load file 0
  55. *(short*)(0x8060CC22) = 1; // File Loop Cancel 1
  56. *(short*)(0x8060CD1A) = 1; // File Loop Cancel 2
  57. *(short*)(0x8060CE7E) = 1; // File Loop Cancel 3
  58. *(short*)(0x8060CE5A) = 1; // File Loop Cancel 4
  59. *(short*)(0x8060CF0E) = 1; // File Loop Cancel 5
  60. *(short*)(0x8060CF26) = 1; // File Loop Cancel 6
  61. *(short*)(0x8060D0DE) = 1; // File Loop Cancel 7
  62. *(short*)(0x8060D106) = 1; // File Loop Cancel 8
  63. *(short*)(0x8060D43E) = 1; // File Loop Cancel 8
  64. *(int*)(0x8060CD08) = 0x26670000; // Save to File - File Index
  65. *(int*)(0x8060CE48) = 0x26670000; // Save to File - File Index
  66. *(int*)(0x8060CF04) = 0x26270000; // Save to File - File Index
  67. *(int*)(0x8060BFA4) = 0x252A0000; // Global Block after 1 file entry
  68. *(int*)(0x8060E378) = 0x258D0000; // Global Block after 1 file entry
  69. *(int*)(0x8060D33C) = 0x254B0000; // Global Block after 1 file entry
  70. *(int*)(0x8060D470) = 0x256C0000; // Global Block after 1 file entry
  71. *(int*)(0x8060D4B0) = 0x252A0000; // Global Block after 1 file entry
  72. *(int*)(0x8060D558) = 0x258D0000; // Global Block after 1 file entry
  73. *(int*)(0x8060CF74) = 0x25090000; // Global Block after 1 file entry
  74. *(int*)(0x8060CFCC) = 0x25AE0000; // Global Block after 1 file entry
  75. *(int*)(0x8060D24C) = 0x25AE0000; // Global Block after 1 file entry
  76. *(int*)(0x8060C84C) = 0xA02067C8; // Force file 0
  77. *(int*)(0x8060C654) = 0x24040000; // Force file 0 - Save
  78. *(int*)(0x8060C664) = 0xAFA00034; // Force file 0 - Save
  79. *(int*)(0x8060C6C4) = 0x24040000; // Force file 0 - Read
  80. *(int*)(0x8060C6D4) = 0xAFA00034; // Force file 0 - Read
Advertisement
Add Comment
Please, Sign In to add comment