øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1856.msg19770e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexd3f8.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1856.15e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexd3f8.html.zxï9g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ…¬6OKtext/htmlISO-8859-1gzip@øÕ6ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 07:12:06 GMT0ó°° ®0®P®€§²ð®î9g^ÿÿÿÿÿÿÿÿå36 Where are the graphics for... well... everything?

Author Topic: Where are the graphics for... well... everything?  (Read 8088 times)

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #15 on: December 16, 2013, 11:53:43 AM »
Even within a given tileset though, the individual tiles use different palettes. Take the castle for example. You have blue water, grey bricks, etc. What I'm looking for in #2 is the palettes for the individual tiles.
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #16 on: December 16, 2013, 07:33:05 PM »
Ah - hmmm... no clue. Don't think I ever knew there was more than one per map.
Are they definitely two different palettes?

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #17 on: December 16, 2013, 09:03:41 PM »
This may help. You might be able to trace back to what writing the map data to the RAM (7F5000 according to this list):

Map Data

7E06A2 - Makes screen flash when walking, like damage
7E06C2 - Makes screen pixelate when walking, like poison
7E06C4 - Makes location's colors inverted (not sprites)
7E06C9 - Layer 2's scrolling method
7E06E3 - change this for screen shake
7E0EDB - Tile properties for town (solid, non-solid, exit, harmful,etc...)
7E1A02 - Can you save and use a tent here? (00 - no, 01 - yes)
7E1E00 - Music data (instruments and the likes)
7E09CF - Event for location?
7E09D1 - Storyline point for location?
7E1703 - Current location map
7E0649 - Location name displayed (00-not currently displaying, 01-currently displaying)
7E08F0 - Location NPC sprite data, palette, location, movement, etc..
7F5000 - Location MAP data in RAM
7E172C - Location Exit destination
7E0FDE - Location NPC Layout
7E0FDD - Location tileset
7E0FD6 - Location Name displayed upon entering
7E0FD4 - Layer 1 visibility, On/Off
7E0FD3 - Layer 1 tileset (Whole maps, used for water and the likes)
7E0FE0 - Layer 1 palette for locations
7F4480 - Town Baron Level Data

http://datacrystal.romhacking.net/wiki/Final_Fantasy_IV:RAM_map
"Now I know; and knowing makes it even more confusing..."

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #18 on: December 17, 2013, 05:04:32 AM »
Perhaps an illustration would help explain what I'm talking about.

In the attached image, all the tiles are using the greyscale palette used by the castle wall tiles. This illustrates what I mean by different tiles having different palette indexes. The castle wall sections look correct but the water looks like stone, and so does everything else. Probably what's happening is the map has associated with it a "large" palette of X 8-color segments, and each tile has associated with it a segment index. Like so:

Code: [Select]
[########][########][########][########]... etc
00        01        02        03

So in the Sylph cave, the palette would consist of various shades of brown and green, whereas in the Feymarch it would consist of various shades of brown and red, but the damage floor tiles would always use, say, palette segment 6, which would be green for Sylph and red for Feymarch. Probably. In reality I have no idea how to figure this stuff out, I'm just speculating.

As well, you can see from the graphic tiles themselves what I'm talking about in terms of having to assemble the actual 16x16 tiles. The game tries to reuse tiles wherever it can, so no doubt there's a castle wall tile constructed by using tiles like so:

Code: [Select]
03 04
03 04

In "FF4.txt" there's a section of rom from A2000-A5FFF labelled "Town Map Tile Formation Data (*4)" which I initially assumed would list graphic tile indexes in the order they're used to construct map tiles (so for the above example, something like 03040304). However, upon inspection of the data in that section, that's definitely not how it's stored; or if it is, it's not as straightforward as that and there's something more complicated going on in there. For example, the first segment of four bytes from that section is:

Code: [Select]
5A 00
B1 04

Which if you assemble those tiles in that order (or any order really) don't make a recognizable map tile. In fact there isn't even a tile B1. I'm so confused...

 :blits:
Let's dance!

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #19 on: December 17, 2013, 02:58:30 PM »
"Duffman has located the source of the problem - OH YEAH!"  :yabin:

Well - I think I have it anyway - here's what I think is going on but it's up to tell me if this is enough to build an algorithm on. I looked at the data for Mysidia (@ B8977 - Unheadered) with FF4Tools. I agree that didn't make any sense on the face of it so I started watching the RAM to see what happens walking into town and I was a little surprised at my findings: Looking @ 7F5000 had the same hex code that I saw in Tools - which to me says that the game doesn't assembly the map when running, there's a coded version of it somewhere in the ROM because that's all Tools is working from.

So I opened up the ROM in HxD and I looked back at Mysidia. Then I started changing things trying to figure it out. What I found eventually as a pattern was a set of two rules. Reading the hex code in pairs you can work out the following:

XX YY        <----- If XX > 80 Then use tile: (XX – 80) a total of: YY times
(80 is 00 when you loop back around on the tile map)

Or

if XX < 80 Then use Tile XX a single time


I had a picture of Mysidia's map up and comparing it against the code as I was trying to interpret gave me a good match:


Here's a bit of the code for Mysidia starting at the begining which corresponds to top left (0,0)

80 04 93 01 55 D6 10 57 93 03 80 02 93 03 95 01 6B E8 04 46 C1 04 47 E8 04 6B 95 03 13 00 13 95

or interpreting it as operations

80 04    = 5 x Tile 00
93 01    = 2 x Tile 13
55        = 1 x Tile 55
D6 10    = 20 x Tile 56
57        = 1 x Tile 57
93 03    = 4 x Tile 13
80 02    = 3 x Tile 00

   That puts you in the 2nd row – which it should: Each row is 32 Tiles in Length

    5 + 2 + 1 + 20 + 1 + 4 + 3 = 33 = 32 +1

It was 55 D6 10 57 93 that threw me off but looking at the actual map vs the code I came up with the alternative rule. The code in this section of the ROM should have much of what is needed - but I haven't gone through it yet.

This should help with FF4kster - it has given so much to me so it's nice to at least try and give back.  :terrydia:

"Now I know; and knowing makes it even more confusing..."

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #20 on: December 17, 2013, 04:17:04 PM »
Excellent work! ... However... I actually knew that part already ^_^;

What I'm looking for is something a little different. This is partially my fault for not defining my terms clearly.

Map Tile: A 16x16 pixel object used to create maps. These have several properties including solidity, event trigger capability, warp trigger, probably a palette index, and probably other properties as well. It is composed of four graphic tiles in some order.

Graphic Tile: An 8x8 pixel object used to create map tiles (among other things). It has no properties on its own (probably) other than its visual appearance.

All graphics on the SNES are composed of graphic tiles. They are usually arranged in some combination to form sprites. For example, if you look at the graphic data for one of the characters, you will notice that there are "pieces missing". This is because the game re-uses these 8x8 tiles wherever possible. So if, say, the back top part of Cecil's head is the same in one pose as it is in another, you will only see that tile once in the ROM rather than twice. Somewhere else, the game is figuring out how to arrage the various 8x8 tiles to create the Cecil sprite it needs.

So what I need to figure out here is not so much "how are map tiles arranged to create a map" (good work on finding that though by the way, that's awesome), but rather "how are graphic tiles arranged to form a map tile".

For example, in the image attached to my previous post, tile 03 (row 0, column 3) looks kind of like it might be the left side of a piece of wall. Tile 04 looks like it might be the right side of a piece of wall. So I would expect that somewhere there's some kind of instruction or table or something that tells the game to construct a 16x16 tile out of two 03s on the right and two 04s on the left, in a square formation. This would create the graphic for one of the castle wall tiles (probably).

So the first question is "where is this information stored?" According to FF4.txt, A2000-A5FFF contains "Town Map Tile Formation Data (*4)". "Tile formation" sounds to me like it is probably describing this process of constructing map tiles from graphic tiles, and 4 bytes is exactly the number that I would expect to describe a single entry (e.g. the arrangement in the previous example might described as "03040304"). However, when I examine this data in a hex editor, it doesn't make any sense in that context.

That, then, leads to the next question: "how is the information encoded?" While it's possible that the data I'm looking for is somewhere else entirely, it's also possible that it is indeed in that section of ROM cited above, but the process for constructing a tile isn't simply done by listing tile indexes next to each other the way I would expect. In such a situation I would need to know how the game interprets the data.
Let's dance!

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #21 on: December 17, 2013, 04:59:14 PM »
"Duffman Zigged but shoulda Zagged - Oh NO!!"


- It's ok, Pinkpuff; it was still cute to go through and solve the mystery.  :tongue:


I think I get what you are saying though, that last post seems pretty clear. Many tiles make a map, but each tile is 4 pixels (8x8) - right?
"Now I know; and knowing makes it even more confusing..."

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #22 on: December 17, 2013, 05:10:52 PM »
Exactly. Like, if you have a tree tile, it's not just one tree tile, it's a "top left corner of a tree" tile, a "top right corner of a tree" tile, a "bottom left corner of a tree" tile, and a "bottom right corner of a tree" tile. For a tree, those are probably all different tiles but for other objects they might reuse some of them. In fact if the tree is symmetrical and has no shadow, the "right" tiles might just be the "left" tiles mirrored, so only two different graphic tiles arranged to make the four-tile image.
Let's dance!

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #23 on: December 17, 2013, 05:16:47 PM »
This is what pops into my mind reading that last post - the question on the table is: how does the analysis below work in regards to how tiles are constructed?



How to change Imp into Shadow

A few points worth mentioning here.
Notice that these arrangements all seem to work in reverse order. This is related to the fact that a summon's image is inverted over the y-axis (because it's on your side, not the enemy's). When visualizing your summon image, it may help to imagine what it would look like if you were attacked from behind - or if you were fighting against it.

In the game's original programming, all Summon image tiles are numbered with ones and tens places as multiples of 2. The enumeration of the tile tells the game where to display the sprites in a sprite arrangement. Sprite 00 will always appear in the top right corner (unless back-attacked) of tile 00. If there is no tile 00, sprite 00 will not appear. Tile XY will always contain sprites XY, XY+1, X+1Y, and X+1Y+1.

There is no restriction, by the way, that says "the top row of tiles must only be numbered 0x, the second row must be numbered 2x, etc."
Hypothetically, Imp's tiles could be arranged like this:



- I think we're on the same page. Now that my brain comprehends the problem...how to solve it... :hmm:
"Now I know; and knowing makes it even more confusing..."

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #24 on: December 17, 2013, 06:38:14 PM »
I don't have it - but I really feel like it's staring me in the face.  :eek:

I've uploaded a bunch of screenshots of my changing the bytes between A2000 & A5FFF - I used the "fill selection" in HxD. I tried various patterns but but I can't seem to bring it together in my head - probably too little food and sleep  :isuck:

Anyway, have a look - the patterns are noted in the file names - I'll have a look again later with fresh eyes

"Now I know; and knowing makes it even more confusing..."

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #25 on: December 17, 2013, 09:10:19 PM »
Pinkpuff - those asterisks in yousei's document indicate footnotes, I think.
Is there a "*4" at the bottom of the doc that might help?

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #26 on: December 17, 2013, 09:18:34 PM »
Nice catch Chillyfeez - I missed that one too - oops  :sad:


*4 -- Town Map Tile Formation Data, 2 bytes

0x0000         8x8 tile (0x00-0xFF)
0x0001:0...1   ?
0x0001:2-4      Palette Index
0x0001:5      Tile Priority (0 = behind character, 1 = in front of character)
0x0001:6      Flip tile horizontally
0x0001:7      Flip tile vertically

*5 -- Town Map Tile Properties, 2 bytes

0x0000:0      Can walk on/off tile
0x0000:1...2   ?


I should also have mentioned in my last post that the attached pictures were taken while I was standing on the Lunar Whale in front of the controls.  :tongue:
"Now I know; and knowing makes it even more confusing..."

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #27 on: December 18, 2013, 02:37:43 AM »
I missed that as well.

Sadly it means that is not the information I'm looking for (though it will be important later). The hunt continues...

 :edit:
*WEAPONS-GRADE FACEPALM*

This is indeed the information I've been looking for... it's just stored in a messed up way.

For one thing, I was looking at the wrong section of the data segment. The first set of graphic tiles is the castle apparently, but the first set of arrangements (formations, whatever) are for the Airship (tileset index 0 in FF4Tools; derp). They then follow that order, so the castle tileset is tileset 03, and since each tileset has 0x80 map tiles with 8 bytes per tile that's 0x400 bytes. So 0x400 * 3 = 0xC00 so the castle arrangements begin at A2C00.

Not only that, they're not stored with all four tile corners next to each other, oh no. That would make too much sense for these guys. Instead, the first 0x100 bytes are describing the top left corners of all the tiles; the next 0x100 bytes are the top right corners of all the tiles, followed by all the bottom left corners, then all the bottom right corners. So to read a tile arrangement you have to read pairs of bytes starting at A2C00 (for the castle) and then jumping ahead by 0x100 bytes for each corner. Wow.
 :lame:

Oh yeah and also apparently a 1 in the horizontal flip bit means "don't flip it" but a 1 in the vertical flip bit means "do flip it"... either that or I have something messed up in my horizontal flipping code but I don't think I do.

Anyway, I'm back on track now, thanks everyone for all your help  :childish:
« Last Edit: December 18, 2013, 06:58:53 AM by Pinkpuff »
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #28 on: December 18, 2013, 07:42:31 AM »
Good ol FFIV... just when you think you've seen the height of needlessly complicated, you get a gem like this. Nice work deciphering that!

LordGarmonde

  • Baigan
  • *
  • Posts: 271
  • Gender: Male
  • "Power only breeds war..."
    • View Profile
Re: Where are the graphics for... well... everything?
« Reply #29 on: December 18, 2013, 01:42:36 PM »
That reminds me of another post I had run into while trying to get up to speed:

Ok, I've just stumbled onto something that makes even Baby Jesus cry...

...Now I know why JCE thinks this game is a coding disaster. It is a coding disaster. :bah:

Let the fun continue...

I think there may be something to that  :wink:


"Now I know; and knowing makes it even more confusing..."