A slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=1930.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index91ce.html slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1930.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index91ce.html.z x ;g^ ,/ OK text/html ISO-8859-1 gzip 0| Tue, 10 Mar 2020 07:18:48 GMT 0 0 P ;g^ 7
Print Page - Event Flag log
Board of Slick
Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: chillyfeez on April 04, 2014, 01:29:00 PM
Title: Event Flag log
Post by: chillyfeez on April 04, 2014, 01:29:00 PM
this is a log I made for my own purposes. Mostly I wanted to avoid setting flags in my hack that would have unexpected effects, like changing the landscape or adding the drill to the Falcon.
FLAG (Dec)SET FIRST (w/hex event #)CLEARSET SECOND ----------------------------------------------------- 0010 Opening events 0112 Speaking to Kain in Baron 0251 Rosa getting captured 0311 Cid greeting cecil 0415 Cecil sleeping, prologue 0521 Cecil/Yang fight 061B Cagnazzo battle, losing twins 078C Meeting Giott, Calbrena Battle, Rydia Rejoins 0819 Odin battle 091A Baigan Battle 1096 Jump from Bab-il, airship escape95 Yang Destroys Super Cannon 1162 Becoming Paladin, Tellah remembers 1282 Kain regaining his senses 132F Mist Dragon Battle 1430 Mist Events 1539 Kaipo events, Y Rydia Joining 1643 Tellah fights Edward, leaves, Edward Joins 173A Curing Rosa 1845 Antlion battle 193D Octomamm battle 2042 Redwings bomb Damcyan 2146 Rydia melts Hobbs ice, learns Fire 2247 Yang joins, Mombomb battle 2331 Watery Cave camping 2483 Depart Fabul, Leviatan attack 2595 Yang destroys Super CannonF7 Speaking to sylph before Yang Awakes 26(nothing) 2748 Fabul battle 285E Talking with Elder, Twins join 295F Palom puts out Ordeals fire 3060 Meeting Tellah on Mt. Ordeals 3161 Milon battle 3263 Milon Z. battle 3364 Talking to Elder after becoming paladin 3414 Rosa greeting Cecil 3574 Obtaining Earth Crystal 3671 Meeting Edward in Toroia, receiving TwinHarp 3772 Speaking with Edward in Toroia after Dark Elf 3866 Entering Tower of Zot first time 3943 Tellah fights Edward, leaves, Edward Joins 4018 Finding Odin before Feymarch 41(nothing) 4279 Magus Sisters battle 437C Valvalis battle 4452 Discussion about rescuing Rosa 457F Entering Cave Magnes 4673 Dark Elf 'me attack you' battle 477A Top of Zot eventsC6 Drilling to the surface 4884 Usinhg Magma Key 494A Toroia clerics after Earth Crystal 508B First visit to Underworld, Enterprise crash 5194 Lugae battles 529A Edge joins, Rubicant battle 53(nothing) 540E Rubicant main battle1D Attaching Enterprise hook 55A5 Finding the Falcon 56A7 Heat shielding the Falcon 57A6 Obtaining Luca Key 58B6 Kain stealing dark crystal and leaving 59A8 Opening the Sealed Cave 60C5 Attaching airship drill 61(nothing) 62A9 Feymarch entrance 63AF Obtaining Dark Crystal 64AA Demon Wall battle 65B6 Kain stealing Dark Crystal and leaving 669E Lunar Whale surfacing 67C9 Asura battle 68CA Leviatan battle 69CF Bahamut battle 70D0 meeting FuSoYa and having him join 71E6 Giant of Bab-il CPU battle 72ED Four Fiends battle 73E2 trading rat tail for adamant 74EE Giving Adamant and Legend to Kokkol 75E1 Obtaining Excalibur 76(nothing) 7709 Receiving the PanE5 Using the Pan and learning Sylph 78F9 Trading Pan for Spoon 79F3 Behemoth battle 50 80 (nothing) 8104 Behemoth battle 51 82A1 Fighting Edge's parents05 Behemoth battle 52 83(nothing) 8408 Rydia learning SylphFC Obtaining Ribbon 85(nothing) 86F2 Exiting Watery Pass - North (then nothing, until...) 22573 Dark Elf 'Me attack you' battle There are some curiosities here, some that seem to indicate that I've missed something. Certain flags get set twice without ever being cleared. Or cleared without ever being set. I'll make edits if I find anything I've missed. Do you suppose it's possible some flags get set or cleared by other means besides events?
I may, at some point, look into figuring out how the landscape and vehicles are changed by flags. Those findings would be posted here as well.
Anybody happen to know where in RAM the flags are actually stored? It must be a 0x20 byte block, likely somewhere in the 1000-17FF range (because that's apparently what is saved in save data). I can go searching for it, but I don't want to bother if it's already known.
Title: Re: Event Flag log
Post by: Grimoire LD on April 06, 2014, 05:37:26 PM
Wow! So there's over 120 unused Event Flags, eh? Great work there Chillyfeez! This is a nice piece of work you made here. But there are a few curiosities... Unfortunately I have no idea where the Event Flags are located either. It is reasonable they are in the section you mentioned, but I have never come across them.
Title: Re: Event Flag log
Post by: Pinkpuff on April 06, 2014, 06:41:18 PM
I just put a "plot flag" config file into FF4kster. Next time I upload it'll be there.
Title: Re: Event Flag log
Post by: chillyfeez 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.
Title: Re: Event Flag log
Post by: chillyfeez 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:
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:
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 08Sorry, 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.
Title: Re: Event Flag log
Post by: Grimoire LD on April 07, 2014, 07:43:02 PM
That is some fantastic work there Chillyfeez! I can't believe I missed that considering it is Right After the Character Stats!
So the rest of the flags are usable, hmm? I am sure that can be put to some good use.
Title: Re: Event Flag log
Post by: chillyfeez 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.
Title: Re: Event Flag log
Post by: chillyfeez 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?
Title: Re: Event Flag log
Post by: chillyfeez 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:
$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:
$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.
Title: Re: Event Flag log
Post by: Grimoire LD on April 13, 2014, 11:23:07 AM
Wha? Great sleuthing there Chillyfeez! I wasn't sure how that worked either, I thought it might have been an NPC activation. Well now I know that is clearly not the case.
Title: Re: Event Flag log
Post by: chillyfeez 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.
Title: Re: Event Flag log - "Together, We Can Move Mountains!"
Post by: chillyfeez on April 21, 2014, 04:19:41 PM
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):
$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:
(http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/Moving%20Mountains.jpg) 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 (http://slickproductions.org/forum/index.php?topic=1866.msg19013#msg19013) 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.
Title: Re: Event Flag log
Post by: Grimoire LD on April 21, 2014, 06:57:39 PM
That's some neat information you gathered Chillyfeez! I think for the majority of us we're at the end-semester crunch. We're getting all of our assignments and all of that done so we don't have as much time as we'd like for FFIV. I am looking forward to see what else you find in regards to these changed tiles on the world maps though.
Title: Re: Event Flag log
Post by: chillyfeez 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: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/flag%2048%20set.jpg)
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: (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%201%20-%20find%20y-pos.jpg)
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): (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%202%20-%20make%20first%20tile%20desert.jpg)
Now, being careful to stay in the same y-position, fly out to x-position 0 to see where that bit of desert appeared: (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%203%20-%20see%20where%20tile%201%20is.jpg) 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: (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%204a%20-%20trial%20and%20error%201.jpg)
(http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%204b%20-%20tiral%20and%20error%202.jpg) Almost there... two more spaces up should do.
(http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%204c%20-%20found%20it.jpg) 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 (http://slickproductions.org/forum/index.php?topic=1866.msg19013#msg19013), will have a value of 4C. So we're looking for "4C 4C 4C 4C 4C 4C" in this block or RAM: (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%205%20-%20find%20exact%20spot%20in%20RAM.jpg) 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): (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%205a%20-%20just%20to%20be%20sure.jpg) 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): (http://memberfiles.freewebs.com/22/01/115500122/photos/flag-landscape-tutorial/step%206%20-%20what%20we%20want.jpg) 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: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/step%207a%20-%20find%20outer%20limits%201.jpg) There we are.
Now, fly back down one space at a time until it changes back: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/step%207b%20-%20find%20outer%20limits%202.jpg)
Once you've arrived at the right place, observe the current value of 7E:0693: (http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/step%208%20-%20note%200693%20value.jpg) 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:
7E:0693X ------------------------------ C0 OR HIGHER(7E:0693 - C0) * 0x0100 80 THROUGH BF(7E:0693 - 80) * 0x0100 40 THROUGH 7F(7E:0693 - 40) * 0x0100 UNDER 407E:0693 * 0x0100 So, using what we just figured out, we can write the code:
$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.
Title: Re: Event Flag log
Post by: Grimoire LD on April 26, 2014, 10:31:25 AM
Haha! That is amazing work and very comprehensive as well. Though just a bit of curiosity... is this why Yousei's old World Map Editor shows the world carved into many, many blocks of (what I assume) 32x32? Could that also be used as a reference for the RAM Changing?
Title: Re: Event Flag log
Post by: chillyfeez 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.
Title: Re: Event Flag log
Post by: chillyfeez 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):
A5 93LDA $93 C9 CCCMP #$CC D0 06BNE $06 A9 13LDA #$13 9F EC 5C 7FSTA $7F5CEC,X 6BRTL There it is! A much quicker process than what I previously posted! :childish:
Title: Re: Event Flag log
Post by: chillyfeez on May 10, 2014, 01:10:24 PM
So here's a thing I'm working on: Overworld encounters that are determined by game progress instead of physical location. This was inspired by ffviii and ix, in which this does happen at certain points, but it has special significance for my hack, where much time will be spent traversing the same terrain - it'll be nice to not have to fight imps at level 25. I wrote some prototype code this morning and it works like a charm, but I think I still need to work in the bit that tells the game only to do this on the world map and not in locations. I'll post a universal patch when this is complete.
:edit: typos - I said "is" instead of "ix"and "t8me" instead of "time"
Title: Re: Event Flag log
Post by: chillyfeez on May 11, 2014, 12:42:43 PM
So, as if the programmers actually wanted me to do this, it turns out that the code that picks encounter sets in the Overworld is entirely separate from that which picks encounter sets everywhere else (presumably the same goes for the Underworld and the Moon, but my goal was to only make this happen in the Overworld anyway). So I didn't need to make any edits to the original prototype code! (... ok, I did clean it up a bit after testing it out)
So, the original code that picks enemy encounter sets in the Overworld looks like this:
$00/8994 5A PHY $00/8995 FA PLX $00/8996 BF 42 C5 0E LDA $0EC542,x ;Load encounter set based on current section of Overworld Map Simple enough - observe current location, then reference the appropriate encounter set.
My custom code uses a convenient big block of empty coding space at (LoROM) 00/FD31-FFBB Basically, it looks at flags 240-245 (normally unused) and based on which, if any, is set it will reference a different encounter set. By using this code, the hacker can then (using FF4kster) simply set one of these flags at the point in the game when they want Overworld encounters to get more difficult!
$00/8994 4C 31 FD JMP $FD31 [$00:FD31] ;Jump to custom code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $00/FD31 5A PHY $00/FD32 FA PLX ;Make sure registers X and Y are not affected by the custom code, in case they're important (They're not used here) $00/FD33 AD 9E 12 LDA $129E [$00:129E] $00/FD36 29 3F AND #$3F ;Observe (only) flags 240 through 245 $00/FD38 C9 20 CMP #$20 ;Is flag 245 set? $00/FD3A 90 04 BCC $04 [$FD40] ;If not, skip to next check $00/FD3C A9 06 LDA #$06 ;If so, load encounter set 6 into A $00/FD3E 80 1E BRA $1E [$FD5E] ;Jump to end $00/FD40 C9 10 CMP #$10 ;Is flag 244 set? $00/FD42 90 04 BCC $04 [$FD48] ;If not, skip to next check $00/FD44 A9 05 LDA #$05 ;If so, load encounter set 5 into A $00/FD46 80 16 BRA $16 [$FD5E] ;Jump to end $00/FD48 C9 08 CMP #$08 ;Is flag 243 set? $00/FD4A 90 04 BCC $04 [$FD50] ;If not, skip to next check $00/FD4C A9 04 LDA #$04 ;If so, load encounter set 4 into A $00/FD4E 80 0E BRA $0E [$FD5E] ;Jump to end $00/FD50 C9 04 CMP #$04 ;Is flag 242 set? $00/FD52 90 04 BCC $04 [$FD58] ;If not, skip to next check $00/FD54 A9 03 LDA #$03 ;If so, load encounter set 3 into A $00/FD56 80 06 BRA $06 [$FD5E] ;Jump to end $00/FD58 C9 02 CMP #$02 ;Is flag 241 Set? $00/FD5A 90 02 BCC $02 [$FD5E] ;If not, then the appropriate encounter set (0 or 1) is already loaded into A, so jump to end $00/FD5C A9 02 LDA #$02 ;If so, load encounter set 2 into A $00/FD5E 4C 9A 89 JMP $899A [$00:899A] ;Jump back to the rest of the normal routine By the way, this only uses three of the almost 40 lines of code in FD31-FFBB, so the same could be done for the other world maps if you wanted.
Since the code is all here, I'm going to skip the patch (I have some housework to do today). But I can put up a patch later if anyone wants it - let me know.
Title: Re: Event Flag log
Post by: Grimoire LD on May 11, 2014, 03:43:36 PM
Oh my goodness! This is absolutely awesome! What a fantastic idea for a patch, Chillyfeez and what a way to show an ever changing world instead of... as you mentioned.. Imps in at least 60% of the world map. Keep up the excellent work!