øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;u=278;area=showposts;start=855e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index6f4b.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;area=showposts;u=278e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index6f4b.html.zxÒåg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ0P.€MOKtext/htmlISO-8859-1gzip0|Ö€MÿÿÿÿÿÿÿÿTue, 10 Mar 2020 19:25:29 GMT0ó°° ®0®P®€§²ð®Ñåg^ÿÿÿÿÿÿÿÿ6€M Show Posts - chillyfeez

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - chillyfeez

856
No worries. Even I, who am not involved in any kind of schooling and have a job that is extremely undemanding this time of year, have not been working as furiously on my hacking lately (I figured out that flag business, which is cool, but that didn't actually take very long).
I've been replaying the psx FFs quite a bit lately - one of my go-to activities when I'm bored - I have been getting some good ideas by doing so...

857
It's your own project. There are no deadlines. :)

858
Final Fantasy IV Research & Development / Re: Event Flag log
« on: May 01, 2014, 10:01:19 AM »
Well, after all that, I discovered a more mathematical (and thus, to me at least, easier) way to figure all this out.

So...
0,0 on the Overworld Map is loaded into 7F:5C71 (the first byte of Map RAM), and the first row (0,0 through 255,0) is loaded when 7E:0693 is 00.
0,1 on the Overworld Map is loaded into 7F:5D71 (100 hex bytes, or one row's worth, later), and the second row (0,1 through 255,1) is loaded when 7E:0693 is 01.
0,3 on the Overworld Map is loaded into 7F:5E71, and the third row (0,2 through 255,2) is loaded when 7E:0693 is 02.
... And so on in this fashion for the first 64 rows (0,0 through 255,63), or 1/4 of the map.

Now then...
0,64 on the Overworld Map is loaded into 7F:5C71 (the first byte of Map RAM), and the 65th row (0,64 through 255,64) is loaded when 7E:0693 is 40 (hex, which equals 64 in base-10).
0,65 on the Overworld Map is loaded into (you guessed it) 7F:5D71, and the 66th row (0,65 through 255,65) is loaded when 7E:0693 is (you guessed it again) 41 (or 65 in base-10).
... And so on in this fashion for the rest of the second 64 rows.

From here, the pattern is pretty predictable.

So...
To figure out the coding to change a specific point on the map:
First, figure out the hex representation of your map position.
The change will be made when 7E:0693 equals the y value of the point you want to change.
Then, simply add your x value to 7F:5C71 to determine the indexed location in RAM that will be affected.

For example:
If you want a flag to change position 123,204 on the Overworld Map...
first, convert your base-10 position to hex. That's 7B,CC.
You'll be making the change when 7E:0693 equals your y value: CC.
Then add your x value (7B) to 7F:5C71. That's 7F:5CEC.

So the code would look like this (after the flag check comes back true):
Code: [Select]
A5 93 LDA $93
C9 CC CMP #$CC
D0 06 BNE $06
A9 13 LDA #$13
9F EC 5C 7F STA $7F5CEC,X
6B RTL

There it is!
A much quicker process than what I previously posted!
 :childish:

859
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 26, 2014, 11:35:01 AM »
I think those divisions in yousei's editor are monster encounter borders.

Like I said, new RAM is overwritten with every movement north or south. Wherever you may be located, there will be 20 (hex) rows above you and below you loaded. And the entire row, from x=0 through x=255.

860
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 25, 2014, 03:09:13 PM »
OK, I cracked it!

For proof of concept, I wrote some code that makes a (broken) castle appear just south of Fabul when flag 48 is clear:




So... how does it work?

Let's preface this by saying that there's no easy equation to make this work, and the size of what you can make appear/disappear is still limited by the fairly small amount of space available for code - and this block has no large amount of empty space to speak of, so to jump to a different spot for more code would require a JML or JSL.

So...
7F:5C71-7F:9C70 is the place in RAM where the game stores the current Overworld map data. Probably Underworld and Moon, too if that's where you are, and possibly even location map data, but these are all irrelevant to what we're doing now.
Each byte in this block of RAM represents one map tile. They will all have a value of 00-7F, so if the map data in ROM says 99 05 (5 bytes of ocean), the RAM will read 19 19 19 19 19 (5 single bytes of ocean).
You may notice that this is only 4000 (hex) bytes, which at 100 (hex) bytes per row means the game is only loading 40 (hex) rows of map into the game at any given time. You'd be right. with every movement up or down, the game is constantly changing 0x0100 byte blocks of RAM. Presumably, 0x40 rows is about as far as the game can display if the map is zoomed out as much as possible, so beyond that much is deemed not worth loading.
NOW, a given spot on the map will always occupy the same exact spot in RAM, as long as it is loaded at the time, so it is possible to specify exactly which tiles you want to change, but finding exactly where in RAM your tile is can be a bit of a complicated process. So I'll do my best to explain...

So, first thing to do is fly to the correct y-position of the tile(s) you want to change:


Next, change the first byte of map RAM from 19 (it will always be 19 - there is no part of the map at x-position 0 that is not ocean) to something visually distinct, like 43 (desert):


Now, being careful to stay in the same y-position, fly out to x-position 0 to see where that bit of desert appeared:

Note that we got lucky here - you might not see the bit of desert on the first try. If you don't, skip forward exactly 0x1000 bytes of RAM (0x10 rows) and try again at 7F:6C71. You'll have to fly left or right to get this spot out of view, then fly back after you change your byte of RAM.

Once you've seen where your bit of desert appears, you can begin to triangulate the right spot. If you need to change a more north portion of the map (lower y-position), then use a lower portion or RAM, higher to move more south. In this particular situation, we need a more north position, but we're already at the very beginning of the map block or RAM, so we'll cycle to the end (7F:9c70) and move backwards from there:



Almost there... two more spaces up should do.


Found it!
This block of 0x0100 bytes is the row containing the tiles we want to change.

Next, fly back to the tiles we want to change to observe the current landscape there.
We want to change two tiles that happen to be in the middle of a row of 6 "top edge of light green grass" tiles, which, referencing this chart, will have a value of 4C.
So we're looking for "4C 4C 4C 4C 4C 4C" in this block or RAM:

Found 'em!
Just to be sure, we'll turn these bytes into desert to be sure they're the right ones (remember to fly left and right so the game can change what the tiles look like):

OK, we're good. The Bytes of RAM we want to change are 7F:9A47-9A48.

Now, just to be sure we've triangulated the RAM bytes we want to change, let's manually make the changes. We'll turn these two bytes into 2D, 2E (top left and top right of broken castle), then we'll change the two bytes 0x0100 bytes later (7F:9B47-9B48, which will be the next row down) to 3D, 3E (bottom left and bottom right of broken castle):

Yep, that's what we want!

The next step is to find the outer limit of where this RAM will be loaded thusly... that is, how far north can I fly before these bytes are loaded with different values? I recommend slowing down emulation (press "-" on your keyboard) so as not to fly more than one tile at a time. We want to know exactly when the RAM changes:

There we are.

Now, fly back down one space at a time until it changes back:


Once you've arrived at the right place, observe the current value of 7E:0693:

That'd be it - 3D (and 3E for the next row down).

OK, the last thing to do is figure out what your register X value will be when 7E:0693 turns to 3D. For that, use this chart:
Code: [Select]
7E:0693 X
------- -----------------------
C0 OR HIGHER (7E:0693 - C0) * 0x0100
80 THROUGH BF (7E:0693 - 80) * 0x0100
40 THROUGH 7F (7E:0693 - 40) * 0x0100
UNDER 40 7E:0693 * 0x0100

So, using what we just figured out, we can write the code:
Code: [Select]
$15/C78B AD 86 12    LDA $1286  [$00:1286]   A:0000 X:3D00
$15/C78E 29 01       AND #$01                A:0000 X:3D00 ;Check if flag 48 is set
$15/C790 D0 58       BNE $58    [$C7EA]      A:0000 X:3D00 ;If so, skip the rest
$15/C792 A5 93       LDA $93    [$00:0693]   A:0000 X:3D00
$15/C794 C9 3D       CMP #$3D                A:003D X:3D00 ;If clear, then check if 7E:0693 is 3D
$15/C796 D0 0C       BNE $0C    [$C7A4]      A:003D X:3D00 ;If not, skip to next check
$15/C798 A9 2D       LDA #$2D                A:003D X:3D00
$15/C79A 9F 47 5D 7F STA $7F5D47,x[$7F:9A47] A:002D X:3D00 ;If so, load 2D (top left of broken castle) into 7F:9A47
$15/C79E 1A          INC A                   A:002D X:3D00
$15/C79F 9F 48 5D 7F STA $7F5D48,x[$7F:9A48] A:002E X:3D00 ;And 2E (top right of broken castle) into 7F:9A48
$15/C7A3 6B          RTL                     A:002E X:3D00 ;End
$15/C7A4 C9 3E       CMP #$3E                A:003E X:3E00 ;Check if 7E:0693 is 3E
$15/C7A6 D0 0B       BNE $0B    [$C7B3]      A:003E X:3E00 ;If not, end
$15/C7A8 A9 3D       LDA #$3D                A:003E X:3E00
$15/C7AA 9F 47 5D 7F STA $7F5D47,x[$7F:9B47] A:003D X:3E00 ;If so, load 3D (bottom left of broken castle) into 7F:9B47
$15/C7AE 1A          INC A                   A:003D X:3E00
$15/C7AF 9F 48 5D 7F STA $7F5D48,x[$7F:9B48] A:003E X:3E00 ;And 3E (bottom right of broken castle) into 7F:9B48
$15/C7B3 6B          RTL       ;End

And there you have it!

This method can be used to make any type of tile appear anywhere on the Overworld map, using any given flag as the trigger.
It's not the quickest process in the world. It'll never make it into any editor. But at least now the knowledge is out there. One more mystery solved.


861
Not a lot of activity here lately. Well, in case anybody's still reading...

My original plan was to take what I learned and get back to my hack, but as is my usual MO, my curiosity got the better of me.

I decided to investigate the flag-triggered landscape changes. From what I can tell, there are three:
-closing of the passage past Mist (flag 14)
-Damcyan turning from normal castle into broken castle (flag 20)
-opening the hole to the Underworld (flag 48)

Here's a disassembly of the Underworld hole routine (which is actually the routine to close the hole when the flag is set - it's open by default):
Code: [Select]
$15/C78B AD 86 12    LDA $1286  [$00:1286]   
$15/C78E 29 01       AND #$01                ;Check if flag 48 is set
$15/C790 D0 58       BNE $58    [$C7EA]      ;If it is, end routine
$15/C792 A5 93       LDA $93    [$00:0693]    ;If it is clear, load 0693 in RAM
$15/C794 C9 D2       CMP #$D2                ;Check if it is D2 (Will be discussed but not necessarily explained later)
$15/C796 D0 07       BNE $07    [$C79F]      ;If not, skip to next check
$15/C798 A9 13       LDA #$13                ;If it is, load 13 (center mountain tile) into A
$15/C79A 9F DB 5C 7F STA $7F5CDB,x ;Store A in 7F:5CDB,x (under these circumstances, this will be the place in RAM where the top tile of the hole to the Underworld is stored)
$15/C79E 6B          RTL                      ;End
$15/C79F C9 D3       CMP #$D3                ;Check if 0693 is D3
$15/C7A1 D0 0F       BNE $0F    [$C7B2]      ;If not, skip to next check
$15/C7A3 A9 13       LDA #$13                ;If it is, load 13 (center mountain tile) into A
$15/C7A5 9F DA 5C 7F STA $7F5CDA,x
$15/C7A9 9F DB 5C 7F STA $7F5CDB,x
$15/C7AD 9F DC 5C 7F STA $7F5CDC,x ;Store A in 7F:5CDA,x through 7F:5CDC,x (second row of the hole to the Underworld)
$15/C7B1 6B          RTL                      ;End
$15/C7B2 C9 D4       CMP #$D4                ;Check if 0693 is D4
$15/C7B4 D0 17       BNE $17    [$C7CD]      ;If not, skip to next check
$15/C7B6 A9 13       LDA #$13                ;If it is, load 13 (center mountain tile) into A
$15/C7B8 9F D9 5C 7F STA $7F5CD9,x
$15/C7BC 9F DA 5C 7F STA $7F5CDA,x
$15/C7C0 9F DB 5C 7F STA $7F5CDB,x
$15/C7C4 9F DC 5C 7F STA $7F5CDC,x
$15/C7C8 9F DD 5C 7F STA $7F5CDD,x ;Store A in 7F:5CD9,x through 7F:5CDD,x (center row of hole)
$15/C7CC 6B          RTL                      ;End
$15/C7CD C9 D5       CMP #$D5                ;Check if 0693 is D5
$15/C7CF D0 0F       BNE $0F    [$C7E0]      ;If not, skip to next check
$15/C7D1 A9 13       LDA #$13                ;If it is, load 13 (center mountain tile) into A
$15/C7D3 9F DA 5C 7F STA $7F5CDA,x
$15/C7D7 9F DB 5C 7F STA $7F5CDB,x
$15/C7DB 9F DC 5C 7F STA $7F5CDC,x ;Store A in 7F:5CDA,x through 7F:5CDC (penultimate row of hole)
$15/C7DF 6B          RTL                      ;End
$15/C7E0 C9 D6       CMP #$D6                ;Check if 0693 is D6
$15/C7E2 D0 06       BNE $06    [$C7EA]      ;If not, end routine
$15/C7E4 A9 13       LDA #$13                ;If it is, load 13 (center mountain tile) into A
$15/C7E6 9F DB 5C 7F STA $7F5CDB,x ;Store A in 7F:5CDB (bottom tile of the hole)
$15/C7EA 6B          RTL            ;End       

Now then, this is all pretty straightforward, except that there is some info that I don't fully understand.
The first is 0693 in RAM.
Here's what I know about it:
-It changes with every step (or one tile of movement) up or down, but stays the same when moving left or right
-it is the same if you are facing down as it is if you are facing right, and the same facing up as facing left, but different (seemingly by 0x40) between up/left and down/right. To hopefully better explain - if you are facing down and 0693 is D2, turning to facing up (without moving) would change 0693 to 92.

The implications of this knowledge - it is entirely possible to relocate where each row of mountains appears by any number of spaces up or down by increasing or decreasing the comparisons on 0693:


Seen here, intentionally spread out between Agart and Baron by changing the original D2, D3, D4, D5 and D6 values to B2, B4, B6, B8 and BA.

Now, it is possible to move the mountains left or right by changing the indexed RAM locations in this code (7F:5CD9, etc), but there are limits. you can't just increase one of these values by 0x80 and have the mountains move halfway across the world sideways. I don't know exactly what the limits are, but I know the mountains can't go as far as the Tower of Bab-il. I suppose this could be illuminated by learning exactly how much map data is loaded into RAM at a time, and how the game knows when to load a new set of data.
I don't know if I'll be examining this anytime soon. it seems like a lot of work for something I don't really need at the moment... which probably means I won't be able to resist looking into it anyway.
 :blush:

It's also possible, by the way, to change what kind of landscape tile the changed tiles become, by the way, by changing those LDA #$13 commands to a different value. You can use this graphic to help with that. Bear in mind, though, that given how this is coded, it'll be tough to make any different types of tile within the same row.

862
When he gets hit. Every character has such a pose, which is only ever displayed for less than one second at a time.

863
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 13, 2014, 01:00:01 PM »
Yeah, I was trying to figure out how to make it so the ship stays parked outside of the appropriate dock in my hack. I think I've got enough info for that now. I think I can place the ship at different ports using event flags, since I'm not planning for landscape changes (as yet...), but VE13 will have its use too (I won't say more... Spoilers).

I probably will, somewhere down the road, explore in-depth the landscape changes, but I got what I need here for now, so it'll be a while.

864
Discovered a new little tidbit, just thought I'd link to it from here for the sake of organization.
http://slickproductions.org/forum/index.php?topic=1930.msg20765#msg20765

865
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 12, 2014, 10:23:49 PM »
Well, that was interesting.

What makes the ship appear near Fabul is Visual Effect 13 (0D), previously thought to do nothing.
Playing Visual Effect 13 runs the following code:
Code: [Select]
$00/D0BA A9 01       LDA #$01               
$00/D0BC 8D 28 17    STA $1728  [$00:1728] 
$00/D0BF A2 DE 38    LDX #$38DE             
$00/D0C2 8E 29 17    STX $1729  [$00:1729]

So, 1714-172B in RAM is where the game stores the information about where all of the vehicles are parked.
There's an entry for Black Chocobo, Hovercraft, Enterprise, Falcon, Lunar Whale and Ship, and each entry is four bytes long.
Byte 00:
 01: visible
 00: not visible
Byte 01:x-position
Byte 02:y-position
Byte 03:Which world it's on (00-Overworld, 01-Underworld, 02-Moon)

So Visual Effect 13 parks the Ship just off the Fabul dock.
You could change which vehicle is parked by the visual effect by decreasing the values at D0BE-F and D0C3-4 by increments of four.
So:
Code: [Select]
$00/D0BA A9 01       LDA #$01               
$00/D0BC 8D 20 17    STA $1720  [$00:1720] 
$00/D0BF A2 DE 38    LDX #$38DE             
$00/D0C2 8E 21 17    STX $1721  [$00:1721]
would put the Falcon at the Fabul dock.

You can also change where the vehicle is placed by changing D0C0-1
Changing
$00/D0BF A2 DE 38    LDX #$38DE 
to
$00/D0BF A2 66 9E    LDX #$9E66
Would place the ship outside of Baron.

Note that:
a) You can't board the ship, even if you place it somewhere where you can walk on top of it
b) The ship disappears by way of Visual Effect 17 (when it's sucked into Leviatan's whirlpool), so unless you plan on running this effect eventually, or finding some other way, the ship will never disappear. 

866
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 11, 2014, 11:09:43 AM »
So I've found the code that creates the mountains that block off Mist after the Mist events, which are related to the flag set during that event. As of now, all I know how to do with that info is change what type of land appears there (say, keep the grassland, or turn it into desert instead, or whatever), or to alter which flag makes these changes. I think that with a bit of playing around, I can use this knowledge to make mountains appear elsewhere (instead of near Mist), but that's not really a concern for me at the moment.

I'm much more interested in how the ship appears outside of Fabul after the Fabul battle. It is not the flag set during that event (44, I think). Nor is it the flag set during "Discussion about rescuing Rosa" (27). The ship does appear during one of the two events, though.
Time to put on my sleuthing cap.
 :hmm:

Anybody got any ideas about this one?

867
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 07, 2014, 09:24:16 PM »
Thanks.
Well, regular party data runs through 113F, then shadow party data, then flags.
But you'd probably have to be looking for the flags in order to find them, they'd seem pretty cryptic otherwise.

Yeah, there's only one used between 86 and 255, so that's 168 unused flags.

868
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 07, 2014, 10:14:28 AM »
OK, that was remarkably easy.

Event flags are stored in RAM at 1280-129F.

It works exactly the way I imagined it would.

Each bit represents a flag: 32(d) bytes * 8 = 256
Flag 0 is bit 0 of byte 0 in this range. Flag FF (255) is bit 7 of byte 1F.
So, if you have flag 0 (and only flag 0) set, your RAM at 1280 will look like this:
Code: [Select]
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

If you have flag 255 (and only flag 255) set, your RAM at 1280 will look like this:
Code: [Select]
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80

Setting flags 8,17,26,35,44,53,62,71,80,89,98,107,116,125,134,143,152,161,170,179,188,197,206,215,224,233,242 and 251 (and only those flags) yields:
Code: [Select]
00 01 02 04 08 10 20 40 80 00 01 02 04 08 10 20
40 80 00 01 02 04 08 10 20 40 80 00 01 02 04 08
Sorry, I ended up with more time than I expected...
 :blush:

And there you have it!

ON the surface, knowing this doesn't change much (I suppose someone with a lot of time on their hands could play the whole game through to look for changes in this range not made by events, but I have no plans of doing that), but this will be the first step toward learning how flags affect the landscape and vehicle travel.
 :happy:

 :edit: Interestingly enough, flag 225 - the one cleared during the Dark Elf 'Me Attack You' event, and the only one above 86 that seems to be used at all - is the only one set at the start of the game... I don't know off the top of my head, but I'd put money on this being the flag that controls the magnetic property in Magnes Cave. Another instance of the Square team wasting some time. They could have easily had the magnetic property turned ON when this flag is clear and OFF when it's set, have it set during 'Me Attack You!' and not bother setting it at the start of the game. Well... whatever.

 :edit: 2 - Also worth noting: Setting/clearing flag 255 terminates the event. The flag is totally usable, but somehow the game interprets the FF as both which flag to set, and the "End Event" command.

869
All of those $03xxxx offsets are LoROM, not ROM.
In the case of any LoROM offset in the 30000s, subtract 20000 to find its unheadered ROM equivalent (then add 200 for the headered offset).
Since all of the battle mechanics in FF4 are located in the $03/8000 - $03/FFFF range in LoROM, they will be in $01/8200 - $02/01FF in a headered ROM.

870
Final Fantasy IV Research & Development / Re: Event Flag log
« on: April 06, 2014, 09:01:22 PM »
I have a plan for how I'm gonna find them, but it'll take a solid, uninterrupted hour or so of experimentation. I'm getting over a pretty bad cold so I haven't had that in a few days. Tomorrow, I think, if I can get a slew of neglected errands done in good time.