Users browsing this thread: 1 Guest(s)
MMMMMMMagic update

#1
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
So, when I first joined the site... my first major patch was to make it so any character could use magic if you wanted them to. It was a little sloppy, only reused magic lists in a very specific character ID order, and would cost Gogo's cumulative magic setup... It's time to revisit this. There is a better way!

I've got some ideas, but I'd like some feedback, or maybe a coder or two willing to help out with the patch. I will likely release 2 versions of the hack.

Version A:
  • compatible with any current game progress,
  • keeps magic system in tact
  • 12 reusable lists applicable to any character via table
  • Gogo's magic still works like normal and is selectable in the table for any character
Version B:
  • requires restarting your game (not an issue for people making original hacks)
  • loses the ability to learn magic from equipment
  • 16 reusable lists applicable to any character via table
  • free's up 88 ($58) bytes of SRAM
  • includes room for up to 10 new learnable spells.
  • Gogo's magic still works like normal and is selectable in the table for any character
Version A is assuming most people will want to keep the magic system as-is. Some hacks rely heavily on magic-teaching equipment... it is essentially just an updated version of my original "MMMMMMMagic" patch that no longer has the downside of forfeiting Gogo's magic system.


Version 2 is what I really want to talk about. This would be a relatively major overhaul of the way the game reads/writes magic... but its actually pretty simple. And it only costs the ability to learn magic via equipment... also, checking your % learned from your magic menu would be troublesome, instead that will be moved to the Espers menu.

Esentially, this is the logic. Learned magic will be binary, on or off. This allows us to fit every learned spell into 7 bytes (with 2 extra bits)... I want to increase that to and "even" 8 bytes, which allows up to 10 more learnable spells. This should be pretty easy to fix in natural magic as its binary as well (you hit the right level, you learn it, flip the bit on). Progression-based learning is a lot harder... so how are we going to handle this? ESPERS! instead of having a byte per spell... we will use a byte per-Esper per-list. By using multipliers, each esper can easily display how far along you are in each spell (even if you have to add percentages from other espers that learn the same spells). Once you hit 100% on a spell, it turns on the appropriate bit in the list and BAM, magic learned. There are 27 Espers so 27 bytes + the 8 bytes of binary = 35 ($23) per magic list. This is in contrast to the 54 ($36) of per-spell learning in vanilla. Which means we can make up to 16 magic lists and have 88 ($58) left over bytes that can be used for other things in the SRAM. I don't see any practical reason to go above 16 lists, but hypothetically giving up the extra SRAM you can make up to 18 lists this way.

The reason this removes learning spells by weapons is the fact that it's progression-based learning by individual spells. I can't add bytes for each weapon for each character, and I could add a system where you could learn from 1 piece of equipment at a time, and if you unequip you lose all your progress... but that's just getting REALLY muddy and complicates things a lot... So I think in this instance, you'd be better off just dropping equipment-based learning entirely. To replace it, it would be pretty easy to learn spells via event or item, as both of those methods would be binary.

So this is where you guys come in... I'm trying to keep track of all the places the game interacts with the magic lists. I need a complete list to make sure I'm doing this right. Also, if any coders would be willing to work on building this patch, in part or in whole, so I don't have to, I'd be totally fine with that and obviously you would get credit for your work. If anyone can help me hunt down the exact locations in each bank, that would be really helpful.
  • Menu Magic list (C3 bank)
  • Menu Esper list (C3 bank)
  • Magic list loaded for battle (C2 bank)
  • Battle Magic menu (C1 bank)
  • Battle Magic menu (C2 bank)
  • Colluseum/Confused (C2 bank)? (Is this independent or based on what was loaded pre-battle?)
  • Learning magic from Espers post-battle (C2 bank)
  • Learning magic via level-up post-battle (C2 bank)
  • Learning magiv via event (C0 bank) (unused code in vanilla but useful for hackers)
I can't help but feel like I'm forgetting things... Also, I might be remembering some of this wrong. Does the spell list get loaded to an active party location for battle, or is it called directly from the spell list during battle?

Anyway, the magic lists take up soooooooo much SRAM, and a more efficient system would be a Godsend for hackers, especially those wanting to add a 15th and 16th permanent party character. So help me out! Let's do this.

Happy Hacking!




Final Beta Round!

MMMMMagic 1.9.5 Beta!

Includes:
  • headered FF3us 1.0 patched with the plug-and-play MMMMMagic update patch (no guest adder)
  • a save file with all magic unlearned
  • the full disassembly for the update
I will be making the expert hackers version this week that has no preset new magic, and desperations still enabled. It will have a .ips, a .asm, and this Thursday's stream will be dedicated to how to use/modify the patch: setting magic lists, what data to edit, and how to create and set up new spells in the lists.



  Find
Quote  
[-] The following 1 user says Thank You to B-Run for this post:
  • SSJ Rick (07-01-2016)

#2
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
This is a great idea, I'd love to see this working and am willing to help.

In a way we could describe this as storing raw AP gained.

For peer review, one issue I could think of:
Two Espers can teach the same spell, this means computing all espers to realize a single spell learning status%
Another solution to this problem is to ignore it, so if you already learnt 10% of a cure from an Old Esper you will start at 0% for cure on the Newly equipped Esper.
This will be an issue to consider for the Menu Magic list aswell unless you would skip showing learning progress in that list.

Another similar cool system could store AP and allowing the characters to spend it to learn stuff. That kind of system could easily be derived if the one above is implemented.
  Find
Quote  

#3
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
(06-30-2016, 11:39 AM)m06 Wrote: This is a great idea, I'd love to see this working and am willing to help.

In a way we could describe this as storing raw AP gained.

For peer review, one issue I could think of:
Two Espers can teach the same spell, this means computing all espers to realize a single spell learning status%
Another solution to this problem is to ignore it, so if you already learnt 10% of a cure from an Old Esper you will start at 0% for cure on the Newly equipped Esper.
This will be an issue to consider for the Menu Magic list aswell unless you would skip showing learning progress in that list.

Another similar cool system could store AP and allowing the characters to spend it to learn stuff. That kind of system could easily be derived if the one above is implemented.

Yeah, I have been throwing those ideas around... My plan is to just remove partially learned magic from the magic menu, i don't need it trying to calculate EVERYTHING over and over... but it SHOULD be doable on the espers menu, since theres just a couple spells per esper, and you don't need to scroll around, it can be thrown up and be done... much more manageable. We could simplify things further by making it only for that specific esper, but I'd like to try having it check other espers first.

And for choosing to learn with AP... I like the idea, but its too far removed from the learning system for my taste... and would also require some custom menu building for selection and such. But it would be great for a job-class system, which this patch would also help a lot with.

The first thing i need is all of the locations in the ROM that magic is observed/used/learned. Pick a bank, and find some addresses so we can plan our code!

Thanks!
  Find
Quote  

#4
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
"Pick a bank, and find some addresses so we can plan our code!"
- Ok

C0 Bank

Event command to teach a spell, there is an event for learning a spell (CA/000C), that is never used. There is code for an event command but no pointer it seems.
C0/AE0D: Learn a spell, though this looks like unused code

C0/A17F: Teach Natural Abilities learned via Automatic Level-Up
C0/A196: Fork: Terra's Spell list
C0/A1B8: Fork: Celes's Spell list


C2 Bank
Colosseum:
C2/0420: (Pick action to take if character Berserked, Zombied, Muddled, Charmed, or in the Colosseum)
C2/051A: (Magic and X-Magic)

Battle Menu:
C2/5429: (Magic and X-Magic menu entry) - (Blank out Magic/X-Magic menu if no spells are known and no Esper is equipped), maybe you don't need this it uses RAM $F6

C2/5551: (Generate Lore menus based on known Lores, and generate Magic menus based on spells
known by ANY character. C2/568D will eliminate unknown spells and modify costs as
needed, on a per character basis.)

C2/568D: (Generate a character's Esper menu, blank out unknown spells from their Magic menu,
and adjust spell and Lore MP costs based on equipped Relics.)

Spell Points and Level Ups:
C2/5FEF: (Progress towards uncursing Cursed Shield, and learning spells taught by equipment)
C2/602A: (Progress towards learning spells taught by Esper)
C2/604B: Progress towards learning spell

C2/6133: (Mark just-learned spells for a character as known, and display messages for them)

C2/61FC: (Terra and Celes natural magic learning at level up)

C3 Bank
C3/0D2B: Determine if a character actually knows magic

C3/4FC4: Draw a column of spells
C3/50A2: Get spell's learned amount, or, if it's Gogo, branch below to check everybody else in the party.

C3/599F: Esper detailed screen
C3/5A84: Draw dd% in the esper screen

C3/87C7: Draw spell learning in equipment info screen


That's what I got for now, I also wanted to suggest you make hex for testing your data structure. We could directly modify the SRM with a script (https://www.ff6hacking.com/forums/showth...p?tid=2067) or debugger.

Edit:
Made some hypothetical data list.
Code:
Learned Magic Byte #1
$01    Black Magic    Fire
$02    Black Magic    Ice
$04    Black Magic    Bolt
$08    Black Magic    Poison
$10    Black Magic    Drain
$20    Black Magic    Fire2
$40    Black Magic    Ice2
$80    Black Magic    Bolt2

Learned Magic Byte #2
$01    Black Magic    Bio
$02    Black Magic    Fire3
$04    Black Magic    Ice3
$08    Black Magic    Bolt3
$10    Black Magic    Break
$20    Black Magic    Doom
$40    Black Magic    Pearl
$80    Black Magic    Flare

Learned Magic Byte #3
$01    Black Magic    Demi
$02    Black Magic    Quartr
$04    Black Magic    X-Zone
$08    Black Magic    Meteor
$10    Black Magic    Ultima
$20    Black Magic    Quake
$40    Black Magic    WWind
$80    Black Magic    Merton

Learned Magic Byte #4
$01    Gray Magic    Scan
$02    Gray Magic    Slow
$04    Gray Magic    Rasp
$08    Gray Magic    Mute
$10    Gray Magic    Safe
$20    Gray Magic    Sleep
$40    Gray Magic    Muddle
$80    Gray Magic    Haste

Learned Magic Byte #5
$01    Gray Magic    Stop
$02    Gray Magic    Bserk
$04    Gray Magic    Float
$08    Gray Magic    Imp
$10    Gray Magic    Rflect
$20    Gray Magic    Shell
$40    Gray Magic    Vanish
$80    Gray Magic    Haste2

Learned Magic Byte #6
$01    Gray Magic    Slow2
$02    Gray Magic    Osmose
$03    Gray Magic    Warp
$04    Gray Magic    Quick
$10    Gray Magic    Dispel
$20    White Magic    Cure
$40    White Magic    Cure2
$80    White Magic    Cure3

Learned Magic Byte #7
$01    White Magic    Life
$02    White Magic    Life2
$04    White Magic    Antdot
$08    White Magic    Remedy
$10    White Magic    Regen
$20    White Magic    Life3
$40    Esper        Ramuh
$80    Esper        Ifrit

Learned Magic Byte #8
$01    Esper        Shiva
$02    Esper        Siren
$04    Esper        Terrato
$08    Esper        Shoat
$10    Esper        Maduin
$20    Esper        Bismark
$40    Esper        Stray
$80    Esper        Palador

Edit 2: added some C2 stuff, a lot in the C2 seems to work on the initalized battle menus
  Find
Quote  
[-] The following 1 user says Thank You to m06 for this post:
  • madsiur (07-02-2016)

#5
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
FANTASTIC!

Hopefully I'll get some time to dig into this over the weekend. Gotta do stream prep for tonight, and we'll see what kind of things I have immediately on the docket after that... but hopefully we can start getting this coded soon.
  Find
Quote  

#6
Posts: 149
Threads: 21
Thanks Received: 40
Thanks Given: 3
Joined: Dec 2013
Reputation: 9
Status
Auto-life
It will be a relatively complex project because you must hunt down any piece of code related with the learning rate of the magic system to change it from one-byte to one-bit. They are scattered in the rom and if you fail to detect all of them bugs surely will happen. I recommend to be pragmatic and to check all information available to discovery what can be implemented. Based on it, a plan can be designed.

The relevant main routines that i know are described below:

C0/A17F to learn magic or update other skills at level up

It is necessary to update Terra/Celes natural learning of spells. I suspect this routine only works at character creation to enable spells based on the level of the character created.

C2/4F08 to discover mp cost for spell

When i changed the C2/568D routine in the imbued magic hack, i discovered that the mp costs, in the battle menu, are wrong. In the end, this routine has a bad design and may not work correctly based in your changes in the C2/568D routine. If you have trouble with the mp costs for the magic spells in the battle menu, i tell you in advance that this routine deserve you attention.

C2/568D to setup magic spells in the magic menu in battle

It is a complex code because it aggregates the summon, magic and lore spells in the same routine. They are too much optimized that you will be forced to deal with all of them in the code. It is not possible to change only the magic spells. Many other factors are in the way, like the alteration of the summon/spells/lore MP costs. Anyway, in battle, if you want the magic spells in the magic menu to work in one-bit instead of one-byte, you must update this routine.

C2/5FEF cursed shield and learning spells by equipment

The cursed shield and the learning by equipment are mixed in code. Probably you must separate the aggregated routines.

C2/602A to update learn rate or enable spell after battle based on esper

To turn the one-byte storage of learned spells to one-bit. You need also to check where the new learn rate of spells will be stored.

C2/61FC to learn magic or update other skills at level up

It is similar in functionality to C0/A17F. However, it update the natural magic for Terra or Celes after every battle if the conditions are correct.

C2/6283 to discovery address of stored spell learn rate

This function probably must be converted from one-byte to one-bit. It probably setup $F4 as a pointer to check, in another functions, the learn rate of the character spells.

C3/0D2B discovery if character knows magic

To discover if the character knows magic and enable/disable the mp display. If the display of the mp points in the menus are disabled, you should check this routine.

C3/50A2 discover learned spells from character for no-battle menus

It must be reimplemented to read from one-byte to one-bit.
  Find
Quote  
[-] The following 1 user says Thank You to HatZen08 for this post:
  • madsiur (07-02-2016)

#7
Posts: 81
Threads: 4
Thanks Received: 6
Thanks Given: 6
Joined: Nov 2009
Reputation: 14
Status
Weakness
I had thought to do this one time before, but I never really tackled it, as it is quite involved. However, I am 100% in favor of doing it this way, at least as a major tweak patch. If I have any information that can be helpful for you, I'll be glad to dig it up, but it looks like you have a good start on it already judging from Hatzen's post above.


I appreciate the prayers and good wishes. Those who don't know, I was diagnosed with stage 4 melanoma in 2019, and I have done well with the treatment, but eventually treatments stop working and you change.  I recently had a seizure at work, now I am healing but not able to work or really do much at all. The focus is just to get better. Again, thanks for the support and if I can help you I will.  I've forgotten more about this game than most people should ever learn, lol.
  Find
Quote  

#8
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Honestly... as much as I would love to be the one to code it... I've had my hands super full recently... it may be another week or so before I can really get to it. If someone wants to take a crack at it, we've laid out the logic, and found most of the relevant code. Just remember to put a table in with $00-$0F to find out which of the 16 magic lists to use for each character (based on character properties ID, not actor), and basically any other number be Gogo's magic... I would recommend leaving at least 32 slots for the table.

Anyone want to give it a shot?

Edit: Oh! and for natural magic, it should check the character ID for whether or not to learn natural magic, but then have it save to the magic list in that characters slot in the table. make sense?
  Find
Quote  

#9
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
So this is what we came up with on-stream last night. I will try to get this coded over the weekend, after that, the rest should be a LOT more simple... until I find another roadblock, of course.

[Image: Spell_Check_Diagram_zpstqh3wjob.jpg]
  Find
Quote  
[-] The following 1 user says Thank You to B-Run for this post:
  • SSJ Rick (07-23-2016)

#10
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Ok, good good good stuff happening.

[Image: MMMMMagic000_zpshqj7dfm8.png]

But I'm at an impasse on what to include in the patch release, and what to leave up to the modder...

First: For useage of the 10 additional spells, reordering the spells is a pretty simple ASM task, just updating the table with the correct order, editing espers to reflect the change, and changing the offset values for each list order in C2/574B... it sounds complicated, but its actually relatively simple. However it is something that would need to get done if someone was going to customize the new spells. This can't be pre-worked unless we set specific spells in specific slots.

Second: Startup animations for the new spells won't be automatically set. Again, if people are making their own lists they may decide to use Summons (which already have their own animation), or a physical set (with no animation), or brand new Black/White/Gray magic... So that means adding code if you need to use the magic startup animations, since they are hardcoded for the current spells only. Again, this can't be pre-worked unless we set specific spells in specific slots. Tho what I could do is set up the code, and set it up so all the hacker would need to do is set up the values of the additional spells for each startup animation type they want.

Now, with both of these things in mind, I could, for the official patch, do this work for them. My plan would be to use a specific set of new spells, built over the Desperation attacks, and remove the desperation mechanic from the game, then do all the work of reordering and setting up startup animations. I recognize most people wont go through the effort to do the ASM to make it totally custom, so there should be an option for non-ASMers. What that would do, however, is exclude the possibility of people using non-standard magic types, like Summons or even Blitz' in their additional magic. So it loses flexibility for something more plug-and-play.

I guess I could release multiple versions of the patch, one for people who want to customize it, and one for people who want plug-and-play.

Anyone who is interested in this patch have any comments or suggestions? How would YOU like to see it when you patch your ROM?
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite