Author Topic: FF II: A Threat from Within - Expanded ROM = New Features!  (Read 35783 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - OPINION(s) NEEDED FOR SOMETHING
« Reply #240 on: August 14, 2016, 09:01:38 PM »
No, I think you're misunderstanding me. ROM expansion is expressly not an option, because doing so would break FF4kster compatibility.

FF4kster makes so many aspects of editing FF4 so convenient that it's worth going out of my way to figure out ways around ROM expansion.

I was thinking, though, there's no reason to make it necessary to rename things. Patching programs (LIPS, in particular, but I think it's universally true) maintain the original filename, so the player would simply have to apply the next patch when it came time to do so. That sort of answers my flash cart question, too.

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - OPINION(s) NEEDED FOR SOMETHING
« Reply #241 on: August 15, 2016, 02:46:55 AM »
Correct me if I I got it wrong, but your idea is to do edit with FF4kster keeping the ROM size (and layout compatible with FF4kster). Lets call it MasterROM. Then save different parts of the ROM in external files (.ips or something). When the time for 'Disk 2' come, the user should stop, apply patches for 'disk 2' and run the ROM.

My idea is:
Do the same till you make the external files. Do the same for 'disk 3',...
When you have all externals, simply put them in a new ExtendedROM that contain MasterROM + expansion containing all the external files. Its Win-Win situation: user plays on Extended (no stop), you edit content on Master (FF4kster OK).

There is one problem:
when the time for disk change comes, you will have to write a routine, that transfer bytes from Extended -> Normal. I dont think with your knowledge this will be a hard task. If bytes are sequential this is really just few byte asm code. The catch is you must copy ROM -> ROM. I hope emulators dont check for 'read only' memory protection ...

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - OPINION(s) NEEDED FOR SOMETHING
« Reply #242 on: August 15, 2016, 10:39:39 AM »
OK, I thought maybe that's what you were getting at. Yeah, that would work, I guess.

I wouldn't have to recopy the entire ROM, just the data that changes depending on the "disc," which would all be catalogued in the IPS file anyway.
Yeah, I guess that's probably the better way to go.

Too bad, I was starting to hatch ambitious plans to re-draw the graphics in the castle shot from the prologue ("the crystal was shedding its light silently") to be a different picture to show at each disc change. That would have been fun, but you're right - playability probably takes priority here.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: FF II: A Threat from Within - OPINION(s) NEEDED FOR SOMETHING
« Reply #243 on: August 16, 2016, 06:22:29 PM »
If you tell me the size of the expanded rom I can give you a hacked FF4kster that detects your rom specifically ^_^
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - OPINION(s) NEEDED FOR SOMETHING
« Reply #244 on: August 16, 2016, 07:07:15 PM »
Oh. Um. Well, that would make things pretty convenient. I wouldn't have asked you for something like that, but if you're offering...
I'll have to fix my Overworld triggers, too, because some of them are technically invalid and my unwillingness to spend time fixing them has forced me to continue using an older version of FF4kster up to this point, but really that's just a "me" thing.
Yeah, lemme take a couple of days to figure all this out and I will get back to you with a file size.
 :childish:

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #245 on: September 17, 2016, 12:05:34 PM »
So now that PinkPuff has given me an avenue for ROM expansion, I'm tapping into some of the stuff I wouldn't have been able to do before.

As previously stated, there will be some built-in "Disc Changes" throughout the game. Thanks to the ROM expansion (and Squall's suggestion as to how to handle it), the following banks of data will be reset three or four times throughout the game, at specific points (the first one is coming soon, after the Titan battle, I think):
-Enemy Experience Given (small but noticeable adjustments up - monsters get harder as the player levels up, so it's only right they should offer more EXP)
-Dialogue Bank 1
-Dialogue Bank 3 (These will enable me to not worry about dialogue space at all)
-Dialogue Bank 2 (This will enable me to have townspeople change their text without making major adjustments to their speech algorithms)
-Event Calls (there are only 86 of these, and I've used around 50 so far. Don't have to worry about running out of these now!)
-Location Triggers (This will allow different event calls to result from the same trigger points, and will also enable me to have progress-dependent treasure chests, a la FFVI!)

In addition to all of that, I now have more freedom to tweak various pieces of game mechanics that I would have gone without doing before for fear of space limitations.
Example: Avon, the hired Bard, is now better at using items than the rest of the characters.
I had already improved the Salve command so that, instead of just using one Cure1 item to cast the Cure1 spell on all party members, now he is able to split any single-target item among all targets (works for healing and attack items).
Now, I've also made adjustments to the damage calculation formula, so when Avon uses the Item command, the Damage/Healing output is equal to (Normal Damage/Healing output * Avon's Level) / 10; and when he uses the Salve command, the Damage/Healing output is equal to (Normal Damage/Healing output * Avon's Level) / 4, then the result is divided among the entire target party. This allows Avon to keep Cure1 potions somewhat relevant for most of the early portion of the game, keep Cure2 potions relevant for at least the first half of the game, and keep Cure3 potions a viable option for pretty much the whole game (they heal one character for 9999 beginning at level 58 or so).

For those interested in seeing how it all works, when the regular damage formula would load the damage into the X register, TfW will instead run the following subroutine:
Code: [Select]
$20/8000 AD 81 26    LDA $2681  [$00:2681]   Load user's ID
$20/8003 29 0F       AND #$0F               
$20/8005 C9 04       CMP #$04                Is it Avon?
$20/8007 F0 05       BEQ $05    [$800E]      If it IS Avon, skip to 800E
---------------------------------------------
$20/8009 7B          TDC                     
$20/800A AE 41 39    LDX $3941  [$00:3941]   
$20/800D 6B          RTL                     Otherwise use normal damage/healing output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$20/800E AD 42 39    LDA $3942  [$00:3942]   Load upper byte of Damage/Healing output
$20/8011 30 07       BMI $07    [$801A]      If bit 7 is set, skip to 801A*
$20/8013 09 80       ORA #$80               
$20/8015 8D 42 39    STA $3942  [$00:3942]   Otherwise set bit 7*
$20/8018 80 EF       BRA $EF    [$8009]      And jump back to 8009
---------------------------------------------
$20/801A AD 42 39    LDA $3942  [$00:3942]   Load upper byte of Damage/Healing output
$20/801D 29 7F       AND #$7F               
$20/801F 8D 42 39    STA $3942  [$00:3942]   Clear bit 7*
$20/8022 AD D1 26    LDA $26D1  [$00:26D1]   Load Avon's Command used
$20/8025 C9 0A       CMP #$0A                Is it Salve?
$20/8027 F0 09       BEQ $09    [$8032]      If so skip to 8032
$20/8029 C9 01       CMP #$01                Is it Item?
$20/802B D0 DC       BNE $DC    [$8009]      If not jump back to 8009
---------------------------------------------
$20/802D A2 0A 00    LDX #$000A              Load 000A into X
$20/8030 80 03       BRA $03    [$8035]      Skip to 8035
---------------------------------------------
$20/8032 A2 04 00    LDX #$0004              Load 0004 into X
---------------------------------------------
$20/8035 AD 82 26    LDA $2682  [$00:2682]   Load Avon's Level
$20/8038 85 E8       STA $E8    [$00:06E8]   Store in E8
$20/803A C2 20       REP #$20               
$20/803C AD 41 39    LDA $3941  [$00:3941]   Load Damage/Healing output
$20/803F 20 5D 80    JSR $805D  [$00:805D]   E8 (2-byte) = Avon's Level * Damage/Healing output
$20/8042 A5 E8       LDA $E8    [$00:06E8]   Load result
$20/8044 20 7C 80    JSR $807C  [$00:807C]   Divide by X
$20/8047 AA          TAX                     Transfer result to X
$20/8048 7B          TDC                     Clear A
$20/8049 E2 20       SEP #$20                Set A to 8-bits
$20/804B 6B          RTL                     End

*NOTE: For some reason, this subroutine always runs twice - playing with the uppermost bit here (which isn't set for healing until after the routine runs) keeps the calculations from running twice.

Swordmaster

  • Octomammoth
  • *
  • Posts: 23
  • Gender: Male
  • Wit and courage have served thee well.
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #246 on: September 17, 2016, 04:38:48 PM »
Genius idea, chillyfeez-san!  That would also make a perfect chemist class.  I wonder if it's possible to have items usable to this character exclusively.  Like how it works in FF3j.  (If I am remembering that right... might also be FF5?)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #247 on: September 17, 2016, 07:36:48 PM »
That's kind of a fun idea, actually, Swordmaster.
There certainly are a lot of usable items in the game that I was planning on just leaving out, but maybe I can use them that way.
I think when I was writing the Salve command I came across the part of the code that determines usability of items in the inventory. I could probably put in a check for user:Avon for a specified range and make that a possibility.
I don't think I'll do that now, but it will likely be something I'll look into down the road.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #248 on: September 17, 2016, 10:14:54 PM »
I know I've been gone for a very long time, but I stop in from time to time to see progress. That you managed to expand the rom while not breaking all of the tools in the progress is very impressive and I am really glad to see that you plan on using this new space in your next updates. I likely won't be able to help at all in the foreseeable future (job+college...), but I do enjoy seeing the progress made.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #249 on: September 18, 2016, 11:47:31 AM »
Nice to hear from you anyway, Grimoire.
A lot of the credit goes to Pinkpuff for making me a hacked version of FF4kster that skips the ROM size check at startup.
Progress is slow but steady on the overall project. You know me, I see somebody looking for ASM hacking help in their own FFIV project and I'm like, "Ooooh, me! Me! I can do that!" and before you know it I've spent the week not working on my own stuff. I maintain that it's for the greater good, though, as it a) allows other people to make quality FFIV hacks thus keeping the game itself relevant in the hacking community and b) keeps my own idea engine fresh so that whenever I finally finish this thing I'll be proud of what I've created.

And then there's the stuff I have to do simply to keep everything organized, like this:

This spreadsheet keeps track of all of the AI indices, conditions and scripts I've used already and allows me to type in a number at the top of the appropriate column and returns a number in a bright red box representing how many times that number appears in that column, because too many times now I've put monster AI all together only to find out later that I accidentally wrote over that of a different monster. This will help me keep all of that straight, but also that was my whole day yesterday.
 :bored:
« Last Edit: September 18, 2016, 12:15:33 PM by chillyfeez »

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #250 on: September 19, 2016, 07:18:59 AM »
I'm glad that PinkPuff agreed to make a custom build, because this will give you so much freedom and skip dealing with trivial things like "how much space I have" or "where to allocate something".

chillyfeez I will be glad to help you, but let me be clear what can be in your disposal:
- I know nothing about FF4 (hopefully some of the things are similar to FF5)
- I'm not art person - graphics, music, level design, story,..
- I can read code, but writing is meh (I was fluent in the past on 6502, but haven't done this in years)
- I can make utilities (applications) for Windows, that can help do things - like automating tasks, prototyping (a model of what can become real feature in the project), ... Things here are limited only by imagination :D

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #251 on: September 19, 2016, 10:07:30 AM »
Wow, squall, I think that could be awesome.

Most of those things you said you can't/don't do I have no need for anyway.

Regarding utilities: one thing comes to mind that I always wished I had...
A few years ago I spent some time studying the music engine and I learned, mostly, how to write custom songs. Now, I'm no Uematsu, not by a long shot but if you've played any of the TfW demos, or have paid close attention to the stuff I've posted here before, then you know I have written two songs that are in the game.
I'd like to put more new music into the game - a combination of original pieces and at least one ported in from FFVI, but the process takes FOREVER.
What I'm getting at is, if you could make a utility that either
A) works like a midi sequencer, but generates output in FFIV's SPC format,
or
B) converts existing midi files into FFIV's SPC format
that would be absolutely amazing.
I can provide documentation of my research of the game's music engine. I'm typing this on my tablet, but after I post I'll move to the computer and attach the file.
 :edit: file attached

Each SPC sequence has the following components:
-song header (mostly info about where each track starts)
-track headers (info at the beginning of each track that determines instrument, starting octave, tempo, various other stuff)
-the actual notes themselves
I'd primarily be looking for something that can convert the notes to the right format - that's what takes the longest - but if you think you could make something that automates the whole process, even better. And I think I'd actually prefer something that generates its own file that I could copy and paste into the ROM via hex editor. That way I wouldn't have to worry about the length of the song until it was fully written.

If I'm completely off base about what you were offering, by the way, that's fine. This was going to be a quick reply that obviously turned into something really long.
 :blush:
« Last Edit: September 19, 2016, 10:19:59 AM by chillyfeez »

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #252 on: September 19, 2016, 04:43:12 PM »
Hey chillyfeez, that is exactly what I was offering, that I could be most useful :D

Just to be sure that we are on the same page, you need a tool that:
 - easily enter the music data (notes and all commands)
 - uses couple of tracks for above
 - export data in a raw SPC700 format
 - (optional) if possible, play the music, to test before using it in a ROM
 - (optional) writing the output directly to FF4 ROM (no need for copy/paste, hex editors,..)
 - (optional) import of data from FF4 ROM

In order to accomplish the goals, I need:
- what format commands will use? Obviously notes will use the simple forms like, C, C#,... What about the rest? (table with all 256 commands)
- how do you imagine the tracks go? - horizontally or vertically? Most editors that I have seen use vertical flow, but horizontal seems more natural
- exact specification of what to be exported and what format
- playing music would require external program. That would mean export in SPC file format. Can you find the spec of that format?

Since you are very creative person, if you have in mind a design of how the application would look, please draw a simple outline

P.S. Since we probably will have many things to settle in the beginning, maybe it will be easier to use a chat-like means. If so details on PM please :)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,281
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #253 on: September 20, 2016, 01:36:22 AM »
Hey chillyfeez, that is exactly what I was offering, that I could be most useful :D
Yay! :happy:

Quote
Just to be sure that we are on the same page, you need a tool that:
 - easily enter the music data (notes and all commands)
Yup
Quote
- uses couple of tracks for above
Not quite sure what you mean by that?
Quote
- export data in a raw SPC700 format
 - (optional) if possible, play the music, to test before using it in a ROM
 - (optional) writing the output directly to FF4 ROM (no need for copy/paste, hex editors,..)
 - (optional) import of data from FF4 ROM
Yup, as long as those things seem possible

Quote
In order to accomplish the goals, I need:
- what format commands will use? Obviously notes will use the simple forms like, C, C#,... What about the rest? (table with all 256 commands)
- how do you imagine the tracks go? - horizontally or vertically? Most editors that I have seen use vertical flow, but horizontal seems more natural
- exact specification of what to be exported and what format
Let me get some stuff together to answer these questions. I think I can cut some of the fluff out of that document and turn it into a list of what would actually need to be used and put together a bit of a concept of how.
That all might take me some time, so if I don't do it quickly, it's not because I've forgotten. ;)

Quote
- playing music would require external program. That would mean export in SPC file format. Can you find the spec of that format?
Honestly, I wouldn't know where to start looking. The only experience I have with video game music is hacking songs in FFIV. I know Geiger's has an SPC dump option, but I've never even tried using it. But previewing music would just be an extra bonus feature anyway, so maybe we can come back to this at a later date...

Quote
Since you are very creative person, if you have in mind a design of how the application would look, please draw a simple outline
I'll think about that a bit...

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #254 on: September 20, 2016, 03:50:29 AM »
Quote
Let me get some stuff together to answer these questions. I think I can cut some of the fluff out of that document and turn it into a list of what would actually need to be used and put together a bit of a concept of how.
I'm not sure what is your experience with that sort of things, but let me share mine and hopefully it will be useful for you:

In the past programs similar to what you want to create were called Trackers - Mod Tracker, Impulse Tracker, Scream Tracker:

They all share the base idea - you have instruments & a script of the song. Instruments have their info (name, who made the sample,..) and the samples. The script (I dont know a better word) of the song consist of notes & commands arranged in tracks. Then they were grouped in chunks called patterns. And there was info what pattern on what channel to play.

From what I see our task would be a simplified version:
- we need to have list of instruments names, but the rest is 'embedded' in FF4
- the main focus will be on the 'script' part - we will have up to 8 tracks, no patterns. For each track we will enter notes or commands. Thats why we need a table of how commands will be entered. Also as you can see on the picture, the flow is vertical
- initially we will have no Play, no nice graphics effects. But if we want to do it later on we will have to extract samples from FF4.