News: 11 March 2016 - Forum Rules, Mobile Version
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia

Author Topic: FF1 NES - seeking advice on expanding magic system  (Read 539 times)

essellejaye

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
FF1 NES - seeking advice on expanding magic system
« on: April 14, 2017, 01:59:05 am »
I've been wondering about expanding the FF1 magic list to 128 spells, 16 per level (8 white and 8 black).
Has anyone attempted to do this, and if so, what blockers did you encounter?

Examining the assembly, I'm not sure how feasible this is, I spotted some difficulties, including but not limited to:
-The out-of-battle spell handling routine is a mess;
-Out-of-battle stores spells by in-level slot (1-8) instead of absolute ID, and there's a bug to fix (ORA vs. ADC) before attempting to expand it;
-The battle attack IDs for magic start at $B0 (MG_START), leaving a range that only has room for 8 spells per level;
-How to rearrange the spell list (and related info) to reflect the move from 8 spells/level to 16.

I experimentally added support for an alternate set of 64 spells to the game (I made space to add the new spell data, names, and prices).
In addition to the 64 standard spells (4 STD white and 4 STD black per level),
I've added 64 alternate spells (4 ALT white, and 4 ALT black per level).
Classes are assigned to use either the standard set of spells or the alternate set, but not both.
So that allows, for example, the Red mage to have his own set (or 2) of spells, or a new class like a Sage to have a separate line of spells.
Rewriting the hard-coded out-of-battle handler to use a jump table also allows both differing sets of STD and ALT spells to be cast.

Here's a sample video showing the Red mage buying and using ALT magic, while the White and Black mages uses STD:
https://youtu.be/LhyD-kk09ns

I went with this implementation as a "half-step" to my initial goal.

Also, I'm experimenting with a related set of changes to make an expanded magic system a little easier to use:
-Use one inn, and the price is based on character levels (currently the highest level, not an average or anything);
-Use one clinic, and the price is based on the level of the revived character;
-Hijack the first 8 inns, and use them as ALT white magic shops;
-Hijack the first 8 clinics, and use them as ALT black magic shops;
-Introduce new menu strings to give the ALT WMAGIC and BMAGIC shopstheir own names.

Disch

  • Hero Member
  • *****
  • Posts: 2499
  • NES Junkie
    • View Profile
Re: FF1 NES - seeking advice on expanding magic system
« Reply #1 on: April 14, 2017, 10:43:16 am »
Quote
what blockers did you encounter?

I think I answered a similar question about adding more weapons/armor in another thread (was that you or someone else?  I can't remember).

Spells are considered "items" in some regard.  There's a max of 256 "items" in the base game, since they are referenced via a single-byte ID value.  Getting around that cap is extremely difficult, as you'd pretty much have to rip up all the code that interacts with items and rewrite it to use different indexes.

The easier way would be to take "item" slots away from something else (like treasure chest gold amounts) and give them to magic.  But this is not easy.... for one, you're probably not going to be able to find 64 items you're willing to scrap.  And two, changing which range is designated to which type (ie: shrinking the TC gold range and increasing the magic range) would require mulitiple [small] code changes.  Pretty much all the code that does range checks on the item ID to see what kind of item it is would have to be updated.  While it definitely COULD be done, it'd be very error-prone.

Vanya

  • Hero Member
  • *****
  • Posts: 1127
    • View Profile
Re: FF1 NES - seeking advice on expanding magic system
« Reply #2 on: April 14, 2017, 11:42:29 am »
The ALT magic system you came up with seems to be about as close as you're going to get without having to do what Disch said.
Given that, an entire alternate set of spells seems like a pretty awesome trade off.
It's an achievement in and of itself that should accommodate the needs of most potential users.
I've always wanted some custom commands for the more bland jobs and this ALT Magic system could be an elegant solution.
Does your system allow mixing the two lists?
If not could the unused byte be used to accomplish a mixed list?

I'm very interested in the version of FFHackster in your video, BTW.
I assume it's a branch of FFHackster CV?

On a side note, my personal "holy grail" for FF1 is overhauling the Magic Point system into a traditional MP system.
Given that the current system uses 8 bytes to track Magic Points and the spells themselves already have an unused byte, it shouldn't be very difficult to implement.

essellejaye

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
Re: FF1 NES - seeking advice on expanding magic system
« Reply #3 on: April 14, 2017, 09:02:49 pm »
In my initial implementation, I didn't allow using ALT and STD at the same time.
In light of what @Disch expounded, 16-per-level isn't feasible, but I've got another idea on how I might pull off mixing ALT and STD.
The way the game stores in-battle and out-of-battle spell IDs (which differs) is the current hurdle.
I'll tackle that after polishing the initial implementation.
I left byte 7 in the magic definition open for hack-defined purposes, so I'd like to avoid using it if possible.

As for FFHackster2017, yeah, CV had a major bug in the text editor, and I've added support for editing assembly projects as well as ROMs.
I was initially going to do a C# port, and I did implement a few editors, but with the relatively limited time I have to work on things, I figured I could update the C++ version sooner.
When I'm done, I'll release it.
Not sure if I'll get back to the C# port or not, though. I rushed through the C# project in a few days to see how feasible it was, and while the simple editors weren't tough, the more complex ones are going to take quite some time. Some screen shots:
https://drive.google.com/drive/folders/0B2yvIhyoAprkTk13QU55am5sRG8?usp=sharing


essellejaye

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
Re: FF1 NES - seeking advice on expanding magic system
« Reply #4 on: May 12, 2017, 04:18:44 am »
I'm very interested in the version of FFHackster in your video, BTW.
I assume it's a branch of FFHackster CV?

Hi @Vanya,

I've got an alpha build, which fixes the text editing issue of FFHCV, and adds some other enhancements.
If you're still interested, here a video about it:
https://youtu.be/xk02JFaE6wc

Here's the application (and source):
https://drive.google.com/drive/folders/0B2yvIhyoAprkajFqS2YwMklaNmc?usp=sharing

And here are a slightly annotated copy of Disch's assembly (used as a clean copy for reverting the project)
and a Hackster DAT file:
https://drive.google.com/drive/folders/0B2yvIhyoAprka2JieTR3em5CZnc?usp=sharing

It is usable (I'm using it to develop my own hack and features), remember that it is an alpha.

Vanya

  • Hero Member
  • *****
  • Posts: 1127
    • View Profile
Re: FF1 NES - seeking advice on expanding magic system
« Reply #5 on: May 12, 2017, 10:27:05 am »
Awesome! I'll check this out as soon as I have a chance.
I'll be sure to report any bugs I find.
Thanks for making this available. :)