Author Topic: FF II: A Threat from Within - Expanded ROM = New Features!  (Read 35787 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 - Expanded ROM = New Features!
« Reply #285 on: November 15, 2017, 05:07:19 AM »
My personal advice - pick one that is easy to make (luckily 2 seems simple enough). When all things are done and you still think: "this is a wrong" - implement another option, just don't stop and waste time for it (now) :D
You're right - I'm over-thinking the matter. Just pick a way and if it doesn't seem right down the road, fix it then.
Thanks!

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #286 on: November 18, 2017, 09:28:42 PM »
Hey chillyfeez, since you can expand the ROM now, and the first post seems outdated, maybe some kind of update info will give more light on whats going on :D
- What is your goal (of the project)
- What is current state
- What are you working atm...

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 #287 on: November 18, 2017, 11:42:43 PM »
Sure, okay...

So the story concept hasn't ever changed. There were details - how to get from Major Plot Point A to B - that I didn't plan ahead of time. I actually think the dialogue ends up better and more natural because of this. When I'm writing a scene, I know the gyst of what's going to happen, but all of the actual lines are written on the fly. The downside to that, though, was that I was maxing out quickly on dialogue space. That's the big problem that was resolved by expanding the ROM, but I didn't need an entire extra MB of ROM for dialogue, so I sat down and figured out which other sections of data could benefit from periodic refreshment. The following sets of data will change over a few times in the game depending on story progress (a flag in RAM will be set that tells the ROM to now reference an entirely separate location in ROM for the data in question):
-Dialogue bank 1 (including pointers)
-Dialogue bank 2 (including pointers)
-Dialogue bank 3 (including pointers)
-Event data
-Trigger data (meaning some chests will contain different treasures depending on when they're opened, like in FFVI)

But I'm also toying with some other ideas...
-now that I've done away with the relative monster scaling, another possibility could be different sets of monster data. So (for example), Imps don't ever get to be super-powerful, but maybe they get a few hundred more HP and an attack that can deal a couple hundred HP damage. I could also have the Exp tables change at the same time.

-I might create a second set of location map data, so that towns might be slightly different when you revisit them. I'm not exactly sure how I would use this, but it creates a lot of possibilities.

-This is a new but very intriguing idea - I have the ability to create separate sets of character starting data and even image data. Originally, Rydia was going to be the only temporary playable character, but by doing this I could include, say, Luca and Cuore as temporary characters as well (both were planned into the story, but only as NPCs)

I haven't actually gotten back to working on story progression yet. Before I get to that I have to rebalance all of the existing monsters in the game thus far, since their stats will be static now. As far as the story's progress, I'm actually pretty close to a place that could be a stopping point for the end of a chapter, so depending on how long it takes me to get through the rebalancing it's possible I'll be able to roll out another release pretty soon.

I don't get to work on the project as frequently as I was a couple of years ago. I got a promotion at work this year, which means my work schedule is more similar to that of normal people's jobs (it's still big box retail, though, so still not anything close to 9-5 M-F). What that means for my life, though, is that I get to hang out with my wife more, but I am alone in the house less, and alone in the house is when I do most of my serious ROM hacking. Rest assured, though, I am still committed to this project.

Since my brain always seems to need a hacking side-gig, though, I've also been researching the workings of the Namingway screen. I think there really is a possibility that I could hack it into a PHS system. I really have no idea what I would do with that, but I feel like it might be a fun patch to release to the world for other people to use in their own hacks, maybe. I donno, maybe I could find a use for it in TfW, too. I do plan on having a fair amount of final party fluidity for the player. We'll see, I guess...

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #288 on: November 19, 2017, 04:05:56 AM »
Quote
I might create a second set of location map data, so that towns might be slightly different when you revisit them. I'm not exactly sure how I would use this, but it creates a lot of possibilities
Yes, while reading what you try to accomplish, I think that way will be easiest, yet giving you much more freedom. The reason for that is:
 - you don't need code to change things on the fly.
 - also changing with code could be quite limiting too (from authors perspective), because you must code to see the results. Its like creating a picture on the fly - its always easier, convenient and better to paint it with a good edit tool :)
 - if you need more the 2 periods, you can use more then 1 copy
FF5 uses this trick for places that permanently change - like meteor hitting an island and it vanish - 2 different maps with before and after meteor's hit.

P.S. What is 'Namingway screen'?

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 #289 on: November 19, 2017, 07:01:55 AM »
The 'namingway screen' is the ffiv character name change system. In order to change Cecil's name to (the much-more appropriate) "Fart," you talk to Namingway, and a new screen opens up in which you select which character to rename, then input the new name.
Since name changing in FF games is a fun but ultimately useless luxury (either partially or completely removed from all games past IX), I've had a dream about replacing it with a system that allows easy party changes. I'm not sure if you were around in this community yet a few years ago when I was working on a "shadow party hack" that would allow the game to save the data of all characters that leave the game (instead of only having five slots for character saving), but it was something I worked on for a long while. I had gotten it to work, but I was never really fully happy with it, which is why it's not implemented in TfW (same reason the dash toggle from User Options isn't used). Part of the reason I wasn't happy with it is that the system it uses to control level growth when characters are not in the party is enormously complicated and doesn't work properly 100% of the time (if a character is supposed to gain 90 levels while not in the party, sometimes they'll only come back having gained 80 levels,but then they level up ten times after their first battle, which feels hacky). But the other "problem" was that even with free access to all of the characters, there was no system for easy swapping in and out. I think Grimoire LD had tried a system in which all of the characters hang out in the Big Whale after the Giant of Bab-il and you added and removed each one by talking to them. But again, after much more streamlined systems in all titles beyond V, this lacks the user-friendliness you want in a good mod.
So... That's what I've been playing around with.

Bahamut ZERO

  • Cagnazzo
  • *
  • Posts: 347
  • Gender: Male
  • If ye're takin a beatin, hop in de back row!
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #290 on: November 19, 2017, 05:31:36 PM »
Woah, glad to see you back, Chillyfeez! Nice to hear you're still making progress on TFW.

Quote
Since my brain always seems to need a hacking side-gig, though, I've also been researching the workings of the Namingway screen. I think there really is a possibility that I could hack it into a PHS system.

Aaaand my mind's been blown within 5 minutes of checking in on this forum for the first time in what feels like ages.


Quote
But the other "problem" was that even with free access to all of the characters, there was no system for easy swapping in and out. I think Grimoire LD had tried a system in which all of the characters hang out in the Big Whale after the Giant of Bab-il and you added and removed each one by talking to them. But again, after much more streamlined systems in all titles beyond V, this lacks the user-friendliness you want in a good mod.

Yeah, recycling the Namingway screen sounds a LOT more streamlined. I went the Grimoire route, then tweaked the save point event to the allow the player to transfer to a map where all the npc's chill, sort of like the End of Time in Chrono Trigger. Currently it uses:

*12 events, for 11 characters plus an event for dumping your party for changing characters and solo Cecil runs
*11 NPCs
*11+ flags, to control which characters are available for swapping
*5 MORE flags, to attempt tracking how many characters are currently in your party
*Extreme abuse of the conditional branch mod  :yabin:

So many dancers were harmed in the making of that setup..  :sleep:


Speaking of the Shadow party mod, the other day I realized that editing a character's starting stats and/or stat gains in FF4kster resets their shadow slot to it's original, vanilla counterpart. Do you happen to have any notes on where the shadow slots are set so I can manually fix the pointers via hex editor?
I update my graphics thread on almost a daily basis, so keep an eye out for new stuff!

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 #291 on: November 19, 2017, 06:43:11 PM »
Hey, BZ!
From the online Final Fantasy 4 Reference Book:

Shadow Party Data

I still have a lot of research to do before I can start actually hacking the Namingway screen - I figured out how to remove the alphabet from the entry box, but that's the easy part. Now I have to research the regular menu screen to figure out how character portraits are drawn. Since I don't really know much about graphics processing, this will be a much longer process and will involve a lot of trial-and-error assembly copying. Once I get that down, though, I'm pretty confident I can get the actual character switching process coded pretty easily, though I'm not sure how much ROM space will be needed for all of it. Anyway, once I have something worth actually showing off, I'll start a dedicated thread for that.

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 #292 on: November 20, 2017, 11:23:32 AM »
Sheesh... Spent all morning sifting through graphics code trying to find useful nuggets. I forgot how complicated this crap is...
Maybe I should table the PHS idea for a bit...
 :lame:

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #293 on: November 20, 2017, 04:46:49 PM »
Indeed, sometimes too complicated :D

I wonder, since you are going to work intensively with graphic, do you know the Prerequisites ?
I know it may sound awkward, but if you know the basics, then you can more easily understand the code. If not don't hesitate to ask questions.

It took me couple of days reading SNES PPU's document, reading examples, before I can say I know all the Prerequisites.  The truth is, if it wasn't for a simple explanation of samurai_goroh on how palettes were stored internally it could take me loooong time ... Its really crucial to understand how things work internally, then you will understand why the ASM code looks so complicated :)

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 #294 on: November 20, 2017, 10:51:49 PM »
Oh, so you understand this to some extent, Squall?
I definitely don't have a working knowledge of most of the things listed there.
The only document I've ever found about SNES graphics is this one, and I'm pretty sure the author of that assumes some base knowledge that I do not have.

I'm not against reading up in order to learn what I need to know, but if you could direct me to the proper resources, that would be awesome.

 :edit:
Looking again at that document I linked... I think it probably has a lot of useful information, but what it lacks (that I need in order to understand) is concrete examples. I'm sure I could learn how this stuff works if someone demonstrated for me.
 :blits:
« Last Edit: November 21, 2017, 12:33:38 AM by chillyfeez »

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #295 on: November 21, 2017, 08:08:13 AM »
Quote
I'm not against reading up in order to learn what I need to know, but if you could direct me to the proper resources, that would be awesome.
This document is good. The problem is (as with most of the documents I've read) it is good to use as reference (Help) rather step by step tutorial.

OK lets forget all technical details and start from a scratch:

I. Mode
Modern or old all graphic system use a mode in which to display whatever we see on the screen. Some cards have only 1 mode, but most, more then 1. Think of SNES PPU as a graphic card that you plug in your computer.

1. So what is a video mode? Its a sum of number of characteristics:
- Resolution: usually defined in pixels - how long and wide is our screen (in pixels)
- Max number of colors that could be simultaneously seen on the screen
- BPP: Bits per pixels - how many bits we need to define the color of the screen
- Video Memory: the mode dictate how to interpret the memory in order to compose the screen
- many other things like layers, buffers, graphical objects (like Sprites), ...

2. Types of Modes:
2.1. Depend on how video memory is interpreted.
- Bit-planes - the video memory contain the color for each pixel. Modern cards use primary 1 plane of bits, which is very easy to ASM. Unfortunately almost all of the old cards use more then 1 plane to organize bits for a pixels. I'm sure there was a hardware need for that, but its quite complicated to manage this in ASM. For now I'm not going to delve in this, but will mention that SNES uses 4 planes.
- Tile based - the main video memory contain index of a tile rather raw pixels. That s pretty much as text mode in DOS/Linux - the video memory contain ASCII (or other pages) index of letters and there is a separate place that hold the definition of each letter. In SNES is the same but is called Tile.

2.2. Depending on how color is stored:
 - True Color - each color contain the necessary bits for R/G/B components. In SNES its 5-5-5 - meaning 5 bits for each component
 - Palette based - each color is an index into predefined palette of colors (defined in their absolute RGB value)

 :edit:
3 OK that was theory, what about some examples?
Mode is more abstract, so not many operation could be done:
- We can set desired mode (0..7). Usually this is one of the first things in the initialization code.
- Normal resolution is 256x240 (PAL) or 256x224 (NTSC) with 50/60Hz. We can't set the frequency, but we can read it. We can set V resolution.
Code: [Select]
$2105 (W): bit 2-0  BG Screen Mode
$2133 (W): bit 2 - BG V-Direction Display (0=224 Lines, 1=239 Lines) (for NTSC/PAL)
$213F (R): bit 4 - Frame Rate  (0=NTSC/60Hz, 1=PAL/50Hz)

* In SNES Mode 0-6 are all Tile based, Mode 7 is bit-planes. All modes use palettes to designate the color.
** For specifics like resolution and BPP better check documents.


So what do you think that for a start? Is it easy to chew or is too technical? Do we need to delve in more or thats enough? Next will be layer, palette, tile, ,...
« Last Edit: November 21, 2017, 12:53:38 PM by Squall »

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 #296 on: November 21, 2017, 08:43:32 AM »
I think I understand that - on a conceptual basis, anyway. I'm not really sure how I apply that knowledge when writing ASM to actually display an image, but maybe you just haven't gotten to that part yet?

One question: when I'm working with a screen that already exists (in this case, the Namingway screen), which already contains visual elements that I ultimately want to keep (windows, some text, the 4BPP character battle sprites lined up along the top of the screen, the finger), is the current mode then already defined? Or do I need to define a different video mode for every different type (or layer?) Of image on screen? Or maybe I might have to set a different mode in order to display image data that didn't already exist in some form?

Wait - is it plausible that I could hack the code that normally is used to display the 32x32 Namingway image in order to display the character portraits that I want?

Maybe I should stop trying to find a quick fix and just sit back and digest your tutorial?

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #297 on: November 21, 2017, 10:14:43 AM »
Quote
is the current mode then already defined?
Yes, its defined. Pretty much if you see something on the screen - a mode is set. So if you want to use it and edit - you must find what mode that is. I had a tool - you make a save-state and then load it in that tool - it can tell you plenty of things about PPU.
But its not written in stone ... you can use another mode if you prefer, but most likely it will be a LOT of work.

Quote
Wait - is it plausible that I could hack the code that normally is used to display the 32x32 Namingway image in order to display the character portraits that I want?
Sure you can easily change the 32x32 image to whatever you want - you need to change the building tiles (that include palette, maybe some attributes)

Quote
I'm not really sure how I apply that knowledge when writing ASM to actually display an image, but maybe you just haven't gotten to that part yet?
Hehe displaying an image is the cherry of the cake, it require many things to know (take into account). We will come there ... soon :D

P.S. If I use terms that you not know, or you have some intuitive understanding - we can go in details.
As hacker you usually try to hack - edit things. But if you have the full picture in mind you can discard what have been done and make it from the scratch. This will give you all the freedom to do what you want the way you want it :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 #298 on: November 21, 2017, 03:20:03 PM »
I researched the routine that "draws" Namingway a bit. Using the disassembly in conjunction with that document I was able to see how the routine enters the sprite (or "tile?") Data into VRAM, but I haven't found yet how it then takes that data and arranges it and places it on screen. This is important information for my purposes because:
A) even though Namingway and the portraits are both 32x32 pixels, Namingway seems to be an arrangement of four 16x16 tiles in a 2x2 formation
Code: [Select]
AABB
AABB
CCDD
CCDD
and the portraits are a straight 32x32
Code: [Select]
AAAA
BBBB
CCCC
DDDD
I'm probably using the wrong words, but hopefully those diagrams better explain what I mean.
B) that's not where I want my 32x32 images to appear, so I'll need to find and change the assembly that designates the x,y location of the image(s) in question.

Anyway, having you explain how it all works definitely will be helpful!

Squall

  • Hell's Rider
  • *
  • Posts: 425
    • View Profile
Re: FF II: A Threat from Within - Expanded ROM = New Features!
« Reply #299 on: November 21, 2017, 05:05:55 PM »
Patience, patience my young padwan :D

OK since you are so eager ... its hard to tell is it a sprite or layer. If you see:
STA $2101 ; bits 5-7 contain the dimension of a sprite  1-mean 32x32 sprite build by 8x8 tiles
Then for sure it uses sprites. Keep in mind that regardless, you image 32x32 is build by 4x4 tiles, each 8x8 pixels, not 16x16 pixels

Quote
B) that's not where I want my 32x32 images to appear, so I'll need to find and change the assembly that designates the x,y location of the image(s) in question.
if you see instructions like STA $2118 - that is writing to video memory. If you see reading like LDA $2139 - that is reading from video. $2116 is the address in the video that you read/write. All addresses are 16 bit and are used to set/get values for small things. For large usually DMA/HDMA is used.

To change where X,Y you must convert X,Y in video memory address and then write it in $2116. If you want to change x+1, the address must be increased by 2. Also x+1 mean 8 pixels to the right :D