Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.61 KB | None | 0 0
  1. hirom
  2. ; header
  3.  
  4. ; Regular Magic Gogo v1.0
  5. ;
  6. ; This patch adjusts some SRAM locations such that Gogo
  7. ; has a regular magic list and is able to learn spells
  8. ; from espers. It will be incompatible as-is with patches
  9. ; that affect:
  10. ;
  11. ; *Morph (now at $1E3A)
  12. ; *SwdTech (now at $1E3B)
  13. ; *Blitz (now at $1E3C)
  14. ; *Lores (now at $1E3D-$1E3F)
  15. ;
  16. ; as it adjusts the location-in-SRAM where information
  17. ; about them is stored. [DEPRECATED: It also uses 6 bytes at the end
  18. ; of the treasure chest bytes; only the first 33 are known
  19. ; to be used, so this shouldn't affect the vanilla game,
  20. ; but it limits any hacks to 42, rather than 48, treasure
  21. ; chest bytes.]
  22. ;
  23. ; If you need information on compatibility, feel free to
  24. ; drop me a line via email (in.the.afterlight@gmail.com)
  25. ; or via PM at ff6hacking.com (where I am known as
  26. ; GrayShadows). Patches with available .asm files should
  27. ; be relatively easy to render compatible; patches without
  28. ; sufficient documentation are more problematic, but not
  29. ; impossible, to make cooperative.
  30. ;
  31. ; NB: This is a specialised version of the mod that uses
  32. ; theoretically unused SRAM space immediately preceding the
  33. ; treasure chest bytes, coded specifically for Gi Nattak at
  34. ; ff6hacking.com. It should be fine to use with other mods,
  35. ; and in fact moves around fewer things, but there may be
  36. ; some issues with compatibility if it turns out the RAM space
  37. ; isn't as unused as is theorised. The goal of this version
  38. ; is to preserve all existing treasure chest bytes, so that
  39. ; they are usable in hacks with additional chests.
  40.  
  41.  
  42.  
  43.  
  44. ; Section 1: Moving RAM locations
  45.  
  46. ; 1.1 Initialising RAM at New Game
  47.  
  48.  
  49. org $C0BB1A
  50. STZ $1E3A,X ; Part of the function that zeroes Treasure Chest
  51. INX ; bytes at game start. Expands to include six
  52. CPX #$0036 ; additional bytes, which cover new Morph/SwdTech/
  53. ; Blitz/Lore locations.
  54.  
  55.  
  56. org $C0BDD2
  57. CPX #$02DF ; Part of a function that governs zeroing
  58. ; starting magic lists. This bundles the
  59. ; new magic list, as well as a few additional
  60. ; bytes (including learned Rages and Dances)
  61. ; in to the same function, saving a few bytes
  62. ; that could potentially used in other patches.
  63.  
  64.  
  65. org $C0BDD7
  66. JSR $BB18 ; Closes treasure chests and zeroes moved SRAM
  67. ; bytes. Needs to be moved or it will overwrite
  68. ; the new Lore bytes.
  69. rep 23 : NOP ; Space cleared by consolidating functions.
  70.  
  71.  
  72. org $C0BE17
  73. LDA $E6F564 ; Initialises Strago's known lores at recruit.
  74. STA $1E3A ; Strago's known lores, byte 1
  75. LDA $E6F565
  76. STA $1E3B ; Strago's known lores, byte 2
  77. LDA $E6F566
  78. STA $1E3C ; Strago's known lores, byte 3
  79.  
  80.  
  81. org $C0BE8D
  82. rep 3 : NOP ; Originally a call to C0/BB18; we've moved that
  83. ; earlier in the code, so we can skip over it here.
  84.  
  85.  
  86. ; 1.2 SwdTech
  87. org $C0A1F6 ; Teaches SwdTech at recruit.
  88. LDA $1E3B
  89.  
  90. org $C0A1FD ; Teaches SwdTech at recruit.
  91. STA $1E3B
  92.  
  93. org $C0AFFA ; Teaches all SwdTech (gen. act. 8F)
  94. STA $1E3B
  95.  
  96. org $C2580D
  97. LDA $1E3B
  98.  
  99. org $C261D0
  100. TSB $1E3B
  101.  
  102. org $C3537A
  103. LDA $1E3B
  104.  
  105.  
  106.  
  107. ; 1.3 Blitzes
  108. org $C0A21D ; Teaches Blitz at recruit.
  109. LDA $1E3C
  110.  
  111. org $C0A224 ; Teaches Blitz at recruit.
  112. STA $1E3C
  113.  
  114. org $C0B002 ; Teaches Bum Rush (gen. act. 90)
  115. LDA $1E3C
  116.  
  117. org $C0B007 ; Teaches Bum Rush (gen. act. 90)
  118. STA $1E3C
  119.  
  120. org $C20576
  121. LDA $1E3C
  122.  
  123. org $C24E07
  124. BIT $1E3C
  125.  
  126. org $C25818
  127. LDA $1E3C
  128.  
  129. org $C261EC
  130. TSB $1E3C
  131.  
  132. org $C3561B
  133. LDA $1E3C
  134.  
  135.  
  136.  
  137. ; 1.4 Morph
  138. org $C20559
  139. CMP $1E3A
  140.  
  141. org $C20B1B
  142. LDX $1E3A
  143.  
  144. org $C20B3B
  145. LDA $1E3A
  146.  
  147. org $C20B46
  148. LDA $1E3A
  149.  
  150. org $C25328
  151. CMP $1E3A ; Allows/disallows Morph menu slot
  152.  
  153. org $C25424
  154. STA $1E3A ; Part of function that sets Morph timer to full.
  155.  
  156. ; Commented out for compatibility with Hatzen's Resilient Morph
  157. ; org $C25E3F
  158. ; ADC $1E3A
  159.  
  160. ; org $C25E46
  161. ; STA $1E3A
  162.  
  163.  
  164.  
  165. ; 1.5 Lores
  166. org $C236FD
  167. BIT $1E3D,X
  168.  
  169. org $C2556F
  170. BIT $1E3D,X
  171.  
  172. org $C25ED0
  173. ORA $1E3D,X
  174. STA $1E3D,X
  175.  
  176. org $C3521C
  177. LDA $1E3D,X
  178.  
  179.  
  180.  
  181.  
  182.  
  183. ; Section 2: Teaching Gogo Magic
  184. org $C2558C
  185. CMP #$0E ; Branches for Umaro and above rather than Gogo and up.
  186.  
  187. org $C25E5C
  188. CMP #$0E ; Branches if Umaro, rather than Umaro and/or Gogo
  189.  
  190. org $C256CC
  191. CMP #$0E ; Umaro branches to Gogo's former branch (Y = 0),
  192. ; and then temporary characters will branch (Y = 2).
  193.  
  194. org $C25EB2
  195. CMP #$0E ; Branches if Umaro so that spells aren't learned.
  196.  
  197.  
  198.  
  199.  
  200. ; Section 3: Gogo in the Menu
  201. org $C34D6F
  202. CMP #$0E ; This was originally a check for Gogo to disable
  203. ; the Espers option in the Skills menu. This increments
  204. ; by 1 to disable for Umaro instead.
  205.  
  206. org $C30D3F
  207. CMP #$0E ; BEQ Umaro, BCS temp character.
  208.  
  209. org $C350AA
  210. CMP #$0E ; BEQ Umaro, to build magic list from spells known
  211. ; by other characters.
  212.  
  213.  
  214.  
  215. ; Bypasses Gogo's custom status menu code by altering the targets of a BRA
  216. ; and three JSR
  217. ;org $c32249 ; [BRA]
  218. ;db $09
  219. ;
  220. ;org $c31C50 ; [JSR]
  221. ;db $78
  222. ;
  223. ;org $c32219 ; [JSR]
  224. ;db $78
  225. ;
  226. ;org $c3223F ; [JSR]
  227. ;db $78
  228.  
  229.  
  230.  
  231.  
  232. ; Section 4: Compatibility
  233.  
  234. ; 4.1: Hatzen's Resilient Morph
  235.  
  236. org $C25E3C
  237. LDA #$FF
  238. STA $1E3A
  239. BRA MorphExitOne
  240. LSR $F1
  241. ROR $F0
  242. RTS
  243. NOP
  244. MorphExitOne:
  245.  
  246. org $C20D00
  247. BCC MorphBra1
  248. LDA $3AA1,Y
  249. BIT #$02
  250. BEQ MorphBra2
  251. JSR $5E43
  252. MorphBra2:
  253. BIT #$20
  254. BEQ MorphBra1
  255. JSR $5E43
  256. MorphBra1:
  257. LDA $3EF9,Y
  258. BIT #$08
  259. BEQ MorphExit2
  260. LDA $F1
  261. BMI MorphExit2
  262. ASL $F0
  263. ROL $F1
  264. MorphExit2:
  265.  
  266.  
  267.  
  268.  
  269. ; 4.2 Natural Ability Learning Expansion
  270. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  271. ; SKILLS LEARNED AT LEVEL UP
  272. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  273.  
  274. ; This points to the function governing learning abilities at
  275. ; level up, originally at C2/61B6 and now at C2/A736.
  276. org $C260BC
  277. JSR $A736
  278.  
  279. ; Determine if the character learns natural magic at level up.
  280. org $C2A736
  281. LDX #$0000 ; Relm's spell list is the first two bytes
  282. ; of the natural magic table now located at
  283. ; EC/E3A0. In vanilla, this starts at EC/E3C0
  284. ; with Terra's table; Relm's occupies two bytes
  285. ; of free space preceding.
  286. CMP #$04 ;
  287. BEQ LvlUpMagic ; Branches to teach natural magic.
  288. LDX #$0020 ; Terra's spell list is second in the table.
  289. CMP #$00 ;
  290. BEQ LvlUpMagic ;
  291. LDX #$0040 ; Celes' spell list is third.
  292. CMP #$06 ;
  293. BEQ LvlUpMagic ;
  294. LDX #$0000 ; Cyan's SwdTech list is the first eight bytes
  295. ; of the SwdTech/Blitz table at E6/F490
  296. CMP #$02 ;
  297. BNE LvlUpSabin ; If not Cyan, branch to check for Sabin.
  298. ; Else, it is Cyan and the code can continue
  299. ; to check his level.
  300.  
  301. ;;;;;;;;;;;;;;;;;;
  302. ; Cyan @ level up
  303. ;;;;;;;;;;;;;;;;;;
  304. JSR LvlAbility ; Check for SwdTechs at this level.
  305. BEQ ExitLearning ; If none, exit.
  306. TSB $1E3B ; Enable the new SwdTech.
  307. BNE ExitLearning ; If already enabled, exit.
  308. ; This should only occur after Cyan's dream,
  309. ; which teaches him SwdTechs through an event.
  310. LDA #$40
  311. TSB $F0
  312. BNE ExitLearning
  313. LDA #$42
  314. JMP $5FD4
  315.  
  316. ;;;;;;;;;;;;;;;;;;
  317. ; Sabin @ level up
  318. ;;;;;;;;;;;;;;;;;;
  319. LvlUpSabin:
  320. LDX #$0008 ; Blitzes are in the second byte of the table.
  321. CMP #$05 ; Check for Sabin.
  322. BNE ExitLearning ; Exit if not Sabin.
  323. JSR LvlAbility ; Check for Blitzes at this level.
  324. BEQ ExitLearning ; If none, exist.
  325. TSB $1E3C ; Enable the new Blitz.
  326. BNE ExitLearning ; If already enabled, exit.
  327. ; This should only occur with Bum Rush, after
  328. ; meeting Duncan in the WoR.
  329. LDA #$80
  330. TSB $F0
  331. BNE ExitLearning
  332. LDA #$33
  333. JMP $5FD4
  334.  
  335. ;;;;;;;;;;;;;;;;;;
  336. ; Magic @ level up
  337. ;;;;;;;;;;;;;;;;;;
  338. LvlUpMagic:
  339. PHY
  340. XBA
  341. LDY #$0010 ; The spell list is composed of 16 2-byte
  342. ; blocks for a total of 32 bytes.
  343. LvlCheckMag:
  344. CMP $ECE3A1,X ; Check against level at which spell is learned
  345. BNE IncSpell ; If no spell at this level, branch and
  346. ; increment to next spell in table.
  347. PHA
  348. PHY
  349. TDC ; [Clear 16-bit A]
  350. LDA $ECE3A0,X ; Get the spell ID from the table.
  351. TAY
  352. LDA ($F4),Y ; [(?? check entry in spell list ??)]
  353. CMP #$FF
  354. BEQ PullYA
  355. LDA #$80
  356. STA ($F4),Y
  357. PullYA:
  358. PLY
  359. PLA
  360. IncSpell: ; Increment to next 2-byte block.
  361. INX
  362. INX
  363. DEY ; Decrement Y
  364. BNE LvlCheckMag ; If we haven't checked all 32 bytes,
  365. ; branch back and continue.
  366. PLY
  367. RTS
  368.  
  369. ;;;;;;;;;;;;;;;;;;
  370. ; Abilities/lvl up
  371. ;;;;;;;;;;;;;;;;;;
  372. LvlAbility:
  373. LDA #$01
  374. STA $EE ; Start by marking Tech/Blitz as #0
  375. XBA ; [Get current level from top of A?]
  376. LvlCheckAbi: ;
  377. CMP $E6F490,X ; Check level against Blitz/Tech table.
  378. BEQ AbiBitfield ; If equal, branch.
  379. INX ; Else, increment to check next index.
  380. ASL $EE ; Check next Tech against level.
  381. BCC LvlCheckAbi ; If carry is set, we've checked all 8 bits and
  382. ; no ability is learned. $EE will be #0.
  383. AbiBitfield:
  384. LDA $EE ; Get the SwdTech/Blitz bitfield. The bit that
  385. ; is set = the ability to learn at this level.
  386.  
  387. ExitLearning:
  388. RTS
  389.  
  390.  
  391.  
  392.  
  393. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  394. ; DEFAULT SKILLS AT RECRUITMENT
  395. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  396.  
  397.  
  398. ; This section governs natural abilities learned at
  399. ; recruitment
  400.  
  401. ;;;;;;;;;;;;;;;;;;
  402. ; DEFAULT DANCES
  403. ;;;;;;;;;;;;;;;;;;
  404. ; This sets default dances learned at the same time as default
  405. ; lores and rages. Rather than pulling the information from
  406. ; elsewhere in the rom, the bit is hardcoded in with an LDA
  407. ; to keep the code in-line.
  408. ;
  409. ; Originally I was teaching dances at recruitment the same way
  410. ; that Cyan and Sabin learn their initial SwdTechs and Blitzes.
  411. ; However, because they learn their skills through level up,
  412. ; they require more complex code to verify which skills they
  413. ; should already have when you meet them. This new code teaches
  414. ; Wind Song by default in the same way that Strago and Gau learn
  415. ; their default Lores and Rages, respectively.
  416.  
  417. org $C0BE2F ; Originally this is used to set font to white.
  418. ; As this is also in C3, it's unnecessary here, and
  419. ; so we can use these addresses for teaching Dances.
  420. ; It follows immediately after the code teaching
  421. ; the default Lores.
  422. STA $1D4C ; Stores bits in location of learned Dances in RAM
  423. NOP ; The original code here is six bytes long.
  424. ; As the new code is only five, this blocks out the
  425. ; remaining byte preventing any further snarls.
  426.  
  427. ;;;;;;;;;;;;;;;;;;
  428. ; NATURAL SKILLS
  429. ; AT RECRUITMENT
  430. ;;;;;;;;;;;;;;;;;;
  431. ; These originally called C0/A17F and are being redirected
  432. ; to the new location of the subroutine at C0/D68D.
  433. org $C09F6D
  434. JSR $D68D
  435.  
  436. org $C0A177
  437. JSR $D68D
  438.  
  439. org $C0C547
  440. JSR $D68D
  441.  
  442. ; When recruiting a character, check if they learn abilities
  443. ; based on their level. If so, teach them all abilities up to
  444. ; their current level.
  445. org $C0D68D
  446. ;;;;;;;;;;;;;;;;;;
  447. LDA $1600,Y ; Grab the ID of the character being recruited.
  448. CMP #$04 ;
  449. BEQ RelmRecruit ; If Relm, branch.
  450. CMP #$00 ;
  451. BEQ TerraRecruit ; If Terra, branch.
  452. CMP #$06 ;
  453. BEQ CelesRecruit ; If Celes, branch.
  454. CMP #$02 ;
  455. BEQ CyanRecruit ; If Cyan, branch.
  456. CMP #$05 ;
  457. BNE ExitRecruit ; If not Sabin, exit.
  458. JMP SabinRecruit ; Else it is Sabin, so jump.
  459. ; Sabin's recruitment subroutine is to far away
  460. ; to branch, so we need to jump to it instead.
  461. ExitRecruit:
  462. RTS
  463.  
  464. RelmRecruit:
  465. LDX $00
  466. TeachRelm:
  467. LDA $ECE3A1,X ; Get level from natural magic table.
  468. CMP $1608,Y ; Check against current level.
  469. BEQ RelmRecCont ; If equal, proceed to learn spell.
  470. BCS ExitRecruit ; If lower, exit.
  471. RelmRecCont:
  472. PHY
  473. LDA $ECE3A0,X ; Grab the spell learned at this level.
  474. TAY
  475. LDA #$FF
  476. STA $1C1E,Y ; Teach it.
  477. PLY
  478. INX
  479. INX
  480. CPX #$0020 ; Have we checked all 16 spells?
  481. BEQ ExitRecruit ; If yes, exit.
  482. BRA TeachRelm ; Else, continue checking.
  483.  
  484. TerraRecruit:
  485. LDX $00
  486. TeachTerra:
  487. LDA $ECE3C1,X ; Get level from natural magic table.
  488. CMP $1608,Y ; Check against current level.
  489. BEQ TerraRecCont ; If equal, proceed to learn spell.
  490. BCS ExitRecruit ; If lower, exit
  491. TerraRecCont:
  492. PHY
  493. LDA $ECE3C0,X ; Grab the spell learned at this level
  494. TAY
  495. LDA #$FF
  496. STA $1A6E,Y ; Teach it
  497. PLY
  498. INX
  499. INX
  500. CPX #$0020 ; Have we checked all 16 spells?
  501. BEQ ExitRecruit ; If so, exit.
  502. BRA TeachTerra ; Else, continue checking.
  503.  
  504. CelesRecruit:
  505. LDX $00
  506. TeachCeles:
  507. LDA $ECE3E1,X ; Get level from natural magic table.
  508. CMP $1608,Y ; Check against current level.
  509. BEQ CelesRecCont ; If equal, proceed to learn spell.
  510. BCS ExitRecruit ; If lower, exit
  511. CelesRecCont:
  512. PHY
  513. LDA $ECE3E0,X ; Grab the spell learned at this level
  514. TAY
  515. LDA #$FF
  516. STA $1BB2,Y ; Teach it
  517. PLY
  518. INX
  519. INX
  520. CPX #$0020 ; Have we checked all 16 spells?
  521. BEQ ExitRecruit ; If so, exit
  522. BRA TeachCeles ; Else, continue checking
  523.  
  524. CyanRecruit:
  525. STZ $1B
  526. LDX $00
  527. TeachCyan:
  528. LDA $E6F490,X ; Get level at which Tech is learned
  529. CMP $1608,Y ; Is Cyan at that level?
  530. BEQ CyanRecCont ; If so, proceed with learning
  531. BCS SetCyan ; If he is lower, exit and teach Techs.
  532. CyanRecCont:
  533. INC $1B
  534. INX
  535. CPX #$0008 ; Have we checked all eight Techs?
  536. BEQ SetCyan ; If so, exit
  537. BRA TeachCyan ; Else, continue checking
  538. SetCyan:
  539. LDA $1B
  540. TAX
  541. LDA $1E3B ; Get currently known Techs
  542. ORA $C0A22C,X ; Add to bitfield of Techs learned at level
  543. STA $1E3B ; Set new Blitzes learned
  544. RTS
  545.  
  546. SabinRecruit:
  547. STZ $1B
  548. LDX $00
  549. TeachSabin:
  550. LDA $E6F498,X ; Get level at which Blitz is learned
  551. CMP $1608,Y ; Is Sabin at that level?
  552. BEQ SabinRecCont ; If so, proceed with learning
  553. BCS SetSabin ; If he is lower, exit and teach Blitzes.
  554. SabinRecCont:
  555. INC $1B
  556. INX
  557. CPX #$0008 ; Have we checked all eight blitzes?
  558. BEQ SetSabin ; If so, exit
  559. BRA TeachSabin ; Else, continue checking
  560. SetSabin:
  561. LDA $1B
  562. TAX
  563. LDA $1E3C ; Get currently known Blitzes
  564. ORA $C0A22C,X ; Add to bitfield of Blitzes learned at level
  565. STA $1E3C ; Set new Blitzes learned
  566. RTS
  567.  
  568.  
  569.  
  570. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  571. ; NATURAL MAGIC
  572. ; TABLES
  573. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  574.  
  575. ; Relm's natural magic learning list.
  576. ; This precedes Celes and Terra's lists in the table,
  577. ; occupying free space right before it.
  578. org $ECE3A0
  579. DB $2D, $01 ; Cure @ 1
  580. DB $34, $03 ; Regen @ 3
  581. DB $00, $07 ; Fire @ 7
  582. DB $19, $0B ; Slow @ 11
  583. DB $30, $0F ; Life @ 15
  584. DB $04, $14 ; Fire 2 @ 20
  585. DB $29, $19 ; Osmose @ 25
  586. DB $0E, $1E ; Gust @ 30
  587. DB $2E, $23 ; Cure 2 @ 35
  588. DB $08, $28 ; Fire 3 @ 40
  589. DB $16, $2D ; Cyclon @ 45
  590. DB $28, $33 ; Slow 2 @ 51
  591. DB $0F, $39 ; Flare @ 57
  592. DB $31, $3E ; Life 2 @ 63
  593. DB $10, $45 ; Scorch @ 69
  594. DB $35, $4B ; Life 3 @ 75
  595.  
  596. ; Adjusts Celes's list slightly.
  597. ; This fixes a glitch if she averages to a level above 32 that
  598. ; would prevent her learning Muddle and orders the spells more
  599. ; logically.
  600. org $ECE3F0
  601. DW $1E21 ; Muddle @ 33
  602. DW $2128 ; Berserk @ 40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement