Advertisement
cloudmax

Zora Tunic and stuff for MM

Nov 23rd, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.69 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;GameShark Menu Fix (Makes sure that you aren't in a pause menu)
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. D03FDA3D 0000
  5.  
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7. ;Custom Action Engine (NOT GameShark Safe)
  8. ;Could be made safe by adding a check to make sure that game isn't in a menu.
  9. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  10. .org 0x8074F210
  11. J start
  12. NOP
  13. mask:
  14. .org 0x803B00A0
  15. start:
  16. BEQ AT, R0, setup ;Branch if action is NOT less than 0x4D
  17. NOP
  18. J mask ;Jump to the Mask function
  19. LBU V0, 0x0153(S0) ;Restore V0, it was overwritten
  20. end:
  21. JAL 0x8074B680 ;Play sound
  22. NOP
  23. J 0x8074F3B4 ;
  24. LW RA, 0x002C(SP) ;
  25. unusable:
  26. J end ;Jump to End
  27. ADDIU A1, R0, 0x0834 ;Set sound to play to Unusable Item
  28. setup:
  29. ;V1 = 0x8011A5D0 (SRAM Address)
  30. ;S1 = Action ID
  31. ;RA = Default Return Address, do not change unless you know what you're doing
  32. LI RA, end ;Set RA to end so that it can be used at the end of a function.
  33. LI V1, 0x801EF670 ;V1 = SRAM Address
  34. ADDU T1, R0, R0 ;Clear T1 for function setups
  35. ADDU T2, R0, R0 ;Clear T2 for function setups
  36. ADDU T3, R0, R0 ;Clear T3 for function setups
  37. ADDU T4, R0, R0 ;Clear T4 for function setups
  38. ADDU T5, R0, R0 ;Clear T5 for function setups
  39. ADDU T6, R0, R0 ;Clear T6 for function setups
  40. ADDU T7, R0, R0 ;Clear T7 for function setups
  41. LI V0, verify ;Prepare V0 for function setup verification
  42. B functions ;Jump to functions
  43. NOP
  44. verify:
  45. ;AT = Return Address Address to return to after verifying the item.
  46. ;T1 = Magic Required You need atleast this much magic to use it.
  47. ;T2 = Magic Cost This is the amount of magic it'll cost when using it. This'll be the required amount if it is higher than T1.
  48. ;T3 = Ammo Cost The amount of Ammo you need to use the item, you'll also loose the same amount. (ONLY WORKS FOR ITEMS WITH AMMO)
  49. ;T4 = Health Required The amount of health you need to use the item.
  50. ;T5 = Rupee Cost The amount of rupees it'll cost to use the item.
  51. ;T6 = Restriction Decides when an item CAN'T be used. 0x1 = Standing, 0x2 = Midair
  52. ; These bitflags will disable the item even if the button isn't. The default restrictions are still applied. items can't be used from ledges, climbable collision, rolling, etc.
  53. ;T7 Unused
  54. ;T8 Unused
  55. ;T9 Unused
  56. ;V0 Used for verification
  57. ;V1 = 0x8011A5D0 SRAM Address
  58.  
  59. ;Check health
  60. LH V0, 0x0036(V1) ;V0 = Current Health
  61. SLT V0, V0, T4 ;If (Current Health < Health Required) {V0 = 0x1} Else {V0 = 0x0}
  62. BNE V0, R0, unusable ;Branch to unusable if you do not have enough health
  63. NOP
  64. ;T4, V0 is now available
  65.  
  66. ;Check Magic
  67. LB V0, 0x0039(V1) ;V0 = Current Magic
  68. SLT T4, V0, T1 ;If (Current Magic < Magic Required) {T4 = 0x1} Else {T4 = 0x0}
  69. BNE T4, R0, unusable ;Branch to unusable if you do not have enough magic
  70. NOP
  71. SUB T1, V0, T2 ;T1 = V0 - T2 (New Magic)
  72. BLTZ T1, unusable ;Branch to unusable if you do not have enough magic
  73. NOP
  74. ;T2, T4, V0 is now unused
  75.  
  76. ;Check Rupees
  77. LH V0, 0x003A(V1) ;V0 = Current Rupees
  78. SUB V0, V0, T5 ;V0 = V0 - T5 (New Rupees)
  79. BLTZ V0, unusable ;Branch to unusable if you do not have rupees
  80. NOP
  81. SUB T5, R0, T5 ;T5 = -T5 (Rupees to decrease by)
  82. ;T2, T4, V0 is now unused
  83.  
  84. ;Check Ammunition
  85. ;First of all, we need to know what item slot the item being used is linked to.
  86. ;To do this, we'll have to read read the Last Pressed Item Button Index from 0x801DAB70
  87. ;Then we use that ID to get the item slot linked to the specified button.
  88. ;We make sure that the item ID has a value below 14
  89. ;(so that it won't attempt to read incorrect data, only slot 0-13 has ammo)
  90. ;If the action requires Ammo, but the item slot doesn't have ammo, the item won't be usable in order to prevent data manipulation.
  91. ;If it passes the check we look up how much Ammo the item has and continue like normally.
  92. BEQ T3, R0, ammobranch ;There's no ammo cost, skip past.
  93. LUI V0, 8040 ;V0 = Last Pressed Item Button Index Address (Upper Bytes)
  94. LB V0, 0xFEF5(V0) ;V0 = Last Pressed Item Button Index
  95. ADDU V0, V1, V0 ;V0 = SRAM + Last Pressed Item Button Index
  96. LB V0, 0x005C(V0) ;V0 = Item Slot ID
  97. SLTI T2, V0, 0x0014 ;If (Item Slot ID < 0x0014) {T2 = 0x1} Else {T2 = 0x0}
  98. BEQ T2, R0, unusable ;Branch to unusable if the Item Slot ID isn't below 14
  99. NOP
  100. ADDU T2, V1, V0 ;T2 = SRAM + Item Slot ID
  101. LB T2, 0x00A0(T2) ;T2 = Ammo
  102. SUB T3, T2, T3 ;T3 = Ammo - Ammo Cost
  103. BLTZ T3, unusable ;Branch to unusable if you do not have enough ammo
  104. NOP
  105. ;T2, T4 is now unused
  106. ;V0 won't be changed for the rest of the verification so that the item slot can be easily accessed later on
  107. ammobranch:
  108.  
  109. ;Check Restriction
  110. ;0x801DAAB8 = Standing, In Water, Jumping up against ledge, etc. State
  111. ;0x1 = Standing
  112. ;0x60 = In Water?
  113.  
  114. ;BEQ T6, R0, verresqu ;There is no restriction, skip past the check
  115. ;NOP
  116. ;LUI T4, 0x801E ;T4 = standing & in water state (Upper bytes)
  117. ;LH T4, 0xAAB8(T4) ;T4 = Current standing & in water state
  118. ;verresstand:
  119. ;ANDI T2, T6, 0x0001 ;T2 = 0x1 if Standing is restricted
  120. ;BEQ T2, R0, verresair ;Branch to midair check if standing isn't restricted
  121. ;NOP
  122. ;ANDI T2, T4, 0x0001 ;T2 = 0x1 if you're standing
  123. ;BNE T2, R0, unusable ;Branch to unusable if you're standing
  124. ;NOP
  125. ;verresair:
  126. ;ANDI T2, T6, 0x0002 ;T2 = 0x2 if being in midair is restricted
  127. ;BEQ T2, R0, verresqu ;Branch to restriction check end if being in midair isn't restricted
  128. ;NOP
  129. ;ANDI T2, T4, 0x0001 ;T2 = 0x1 if you're standing
  130. ;BEQ T2, R0, end ;Branch to end if you're not standing
  131. ;ADDU A0, R0, R0 ;Set sound to play to nothing
  132. ;verresqu:
  133.  
  134. ;T2, T4, T6 is now unused
  135.  
  136. ;Update
  137. ;T1 = New Magic Amount
  138. ;T2 = Unused
  139. ;T3 = New Ammo Amount
  140. ;T4 = Unused
  141. ;T5 = Amount of rupees to decrease by
  142. ;T6 = Unused
  143. ;T7 = Unused
  144. ;T8 = Unused
  145. ;T9 = Unused
  146. ;V0 = Item Slot ID
  147. ;V1 = SRAM Address
  148.  
  149. SB T1, 0x0039(V1) ;Current Magic = New Magic Amount
  150.  
  151. LUI T2, 801F ;Rupee increase/decrease address upper half
  152. LH T4, 0x0688(T2) ;Load current rupee increase/decrease amount
  153. ADDU T4, T4, T5 ;Set new rupee increase/decrease amount
  154. SH T4, 0x0688(T2) ;Store new rupeee increase/decrease amount
  155.  
  156. ADDU T2, V1, V0 ;T2 = SRAM + Item Slot ID
  157. SB T3, 0x00A0(T2) ;Current Ammo = New Ammo Amount
  158.  
  159. LI RA, end ;Set RA to end so that it can be used at the end of a function.
  160. JR AT ;Jump Back
  161. NOP
  162. functions:
  163. SLTI T0, S1, 0x55 ;Set T0 if A2 is less than 0x55 (0x53 & 0x54)
  164. BNE T0, R0, tunics ;Branch to tunics if action is less than 0x55
  165. NOP
  166. B end ;Branch to end if action doesn't exist
  167. NOP
  168. tunics:
  169. ADDIU T0, S1, 0xFFAF ;T0 = S1 - 0x51 = New Tunic
  170. LB T1, 0x006C(V1) ;T1 = Current Boots & Tunic
  171. ANDI T2, T1, 0x000F ;T2 = Current Tunic
  172. ANDI T3, T1, 0x00F0 ;T3 = Current Boots
  173. BEQL T0, T2, updatetunic ;Execute Delay Slot and Branch if you already have the tunic equipped
  174. ADDU T3, T3, R0 ;T3 = Current Boots & No Tunic
  175. ADDU T3, T3, T0 ;T3 = Current Boots & New Tunic
  176. updatetunic:
  177. SB T3, 0x006C(V1) ;T1 = Current Tunics & Boots
  178. ADDIU T3, R0, 0x0001 ;T3 = 0x1
  179. SB T3, 0x0145(S0) ;Unequip Iron Boots
  180. J end ;Function is over, jump to end
  181. ADDIU A1, R0, 0x0834 ;Set sound to play to Pull out Item
  182.  
  183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  184. ;Set Up Tunic Actions (GameShark Safe)
  185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  186. 80779E37 0053
  187. 80779E3D 0054
  188.  
  189. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  190. ;Add OoT Dialog Icon Entries (GameShark Safe)
  191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  192. 811CFFBE 0005
  193. 811CFFC0 000B
  194. 811CFFC2 0011
  195.  
  196.  
  197. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  198. ;TEXT SETUP (ROM Patch Only)
  199. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  200. Icons
  201. 0x15 Fairy Ocarina (OoT)
  202. 0x16 Fairy Slingshot (OoT)
  203. 0x17 Hookshot (OoT)
  204.  
  205. icon 22 (0x16)
  206. Goron Tunic
  207. Allows the bearer to withstand
  208. heated areas.
  209.  
  210. icon 23 (0x17)
  211. Zora Tunic
  212. Allows the bearer to breathe
  213. while underwater.
  214.  
  215. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  216. ;Allow any action to be performed under water (NOT GameShark Safe)
  217. ;Could be made safe by adding a check to make sure that game isn't in a menu.
  218. ;WARNING: Game may crash when changing Form. Need to look into this.
  219. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  220. .org 0x8074EEC4
  221. BEQL R0, R0, 0x8074EEEC
  222.  
  223. D03FDA3D 0000
  224. 8174EEC4 5000
  225.  
  226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  227. ;Allow Tunics, Bottles, Hookshot & Great Fairy Sword in water (GameShark Safe)
  228. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  229. .org 0x8012432C
  230. NOP
  231. .org 0x80124344
  232. NOP
  233.  
  234. .org 0x80110898
  235. J 0x803B0300
  236. NOP
  237.  
  238. .org 0x803B0300
  239. BEQ T7, AT, usable ;It is zora Mask, can use
  240. LB A0, 0x0020(T0) ;A0 = Form
  241. ADDIU AT, R0, 0x04 ;AT = 0x4 (Link)
  242. BNE A0, AT, disable ;You're not link form, can't use tunics
  243. ADDIU AT, R0, 0x0B ;0x0B = Goron Tunic
  244. BEQ T7, AT, usable ;It is goron Tunic, can use
  245. ADDIU AT, R0, 0x11 ;0x11 = Zora Tunic
  246. BEQ T7, AT, usable ;It is zora Tunic, can use
  247. NOP
  248. disable:
  249. J 0x801108A0
  250. NOP
  251. usable:
  252. J 0x801109B8
  253. LBU T7, 0x3F18(A1)
  254.  
  255. underwatercheck:
  256. BEQL T2, AT, donecheck ;You are Link
  257. ADDIU T7, R0, 0x000F ;T7 = 0x0F (Link Start Range)
  258. donecheck:
  259. J 0x8011091C
  260. SLT AT, A2, T7 ;Set AT = 0x1 if item is below start range
  261.  
  262. .org 0x801108DC
  263. BNEL A3, R0, 0x80110910
  264. ADDIU T7, R0, 0x00012 ;T7 = 0x12 (Zora Link Start Range)
  265.  
  266. .org 0x80110914
  267. J underwatercheck
  268. LB AT, 0x0020(T0) ;AT = Form
  269.  
  270. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  271. ;Allow Zora Swimming with Zora Tunic (NOT GameShark Safe)
  272. ;Could be made safe by adding a check to make sure that game isn't in a menu.
  273. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  274.  
  275. ;Add iron boots to B when Link have Zora Tunic Equipped
  276. .org 0x8075757C
  277. JAL 0x803B0340
  278. OR V0, R0, T7 ;V0 = Current Form
  279. BEQ AT, R0, 0x80757594 ;You aren't Zora Link, and you don't have Zora Tunic Equipped, branch
  280. NOP
  281. JAL 0x807574DC
  282. .org 0x807575A0
  283. OR V0, R0, R0 ;Clear out V0
  284.  
  285. ;Add zora swimming to A when Link have Zora Tunic Equipped
  286. .org 0x8076DBDC
  287. JAL 0x803B0340
  288. OR V0, R0, T6 ;V0 = Current Form
  289. BEQ AT, R0, 0x8076DCD0 ;You aren't Zora Link, and you don't have Zora Tunic Equipped, branch
  290. OR V0, R0, R0 ;Clear out V0
  291.  
  292. ;Allow Link to Surface with A
  293. .org 0x807575F4
  294. NOP
  295.  
  296. ;Remove Dive ability from A when Link have Zora Tunic Equipped
  297. ;0x80758888 is the branch used to prevent zora link from having Dive on A
  298. .org 0x8075887C
  299. LBU V0, 0x014B(S0) ;Change the register used from T0 to V0
  300. JAL 0x803B0340
  301. .org 0x80758888
  302. BNEL AT, R0, 0x80758998 ;You are Zora Link, or you have the Zora Tunic Equipped, branch
  303.  
  304. ;Set A Button Text to Swim instead of Dive when Link have Zora Tunic Equipped
  305. .org 0x80760228
  306. BNEL T7, R0, 0x80760294
  307.  
  308. .org 0x80760294
  309. JAL 0x803B0340
  310. LBU V0, 0x014B(A3)
  311. BEQL AT, R0, 0x807602B0 ;You aren't Zora Link, and you don't have Zora Tunic Equipped, branch
  312.  
  313.  
  314. ;Zora Link or Zora Tunic Check
  315. ;V0 is Current Form (this register will not be changed)
  316. ;AT will return as 0x0 if false, 0x1 if true.
  317. ;It is set up this way to allow the function to run from all the Zora Checks.
  318. .org 0x803B0340
  319. ADDIU AT, R0, 0x0002 ;0x2 = Zora
  320. BEQ V0, AT, usable ;You're zora link, branch
  321. ADDIU AT, R0, 0x0004 ;0x4 = Link
  322. BNE V0, AT, end ;You're not Link, branch
  323. LUI AT, 0x801F ;AT = 0x801F0000
  324. LB AT, 0xF6DC(AT) ;AT = Boots & Tunic Byte
  325. ANDI AT, AT, 0x000F ;AT = Tunic
  326. XORI AT, AT, 0x0003 ;AT will be set to 0 only if Zora Tunic is equipped.
  327. BNE AT, R0, end ;You don't have zora tunic equipped, branch
  328. NOP
  329. usable:
  330. JR RA
  331. ADDIU AT, R0, 0x0001 ;AT = 0x1
  332. end:
  333. JR RA
  334. ADDIU AT, R0, 0x0000 ;AT = 0x0
  335.  
  336. ;To do:
  337. ;Make it so that the B Button says "Dive" when you have zora tunic equipped
  338. ;This can't be solved with a simple Branch since Zora Link always has Text on the B button, while Link doesn't.
  339. 80122130
  340. 80114E60
  341.  
  342. A2 80545ED0
  343.  
  344. 80178E24
  345.  
  346. 80236C40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement