øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=1856.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index58cc-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1856.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index58cc-2.html.zx­9g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ…¬ºõOKtext/htmlISO-8859-1gzip@øÕºõÿÿÿÿÿÿÿÿTue, 10 Mar 2020 07:11:01 GMT0ó°° ®0®P®€§²ð®­9g^ÿÿÿÿÿÿÿÿCºõ Print Page - Where are the graphics for... well... everything?

Board of Slick

Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Pinkpuff on August 16, 2013, 12:00:05 PM

Title: Where are the graphics for... well... everything?
Post by: Pinkpuff on August 16, 2013, 12:00:05 PM
USE TILE LAYER! or something yeah I know, but that will only get me so far. Particularly I need to know where the palettes are for these things (and if the offsets for the graphics themselves happen to be known off hand it would also save me some work digging around with a graphic tool trying to find them myself; I'd rather spend my time programming than hunting, though I will if I have to). In addition, some things are animations as opposed to simply static sprites, so I would love to have some details on how those work. Wouldn't it be great to see in FF4kster for example a preview of the currently highlighted spell animation with the currently selected palette, instead of just a bunch of numbers?

So really I need the details for as many different things as humanly possible, but here is a list of the more high-priority things:

Also I know some of the things on this list are well known and easy to find but I'm going to keep them here for the sake of organization.
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on August 16, 2013, 12:48:53 PM
Unheadered binary offsets:

Code: [Select]
0x48000 - 0x4FFDF:  Monster Graphics 1 (3BPP)
0x50000 - 0x56EFF:  Monster Graphics 2 (3BPP)

0x57000 - 0x57FFF: Font (2BPP)

0x58000 - 0x5FD57: Monster Graphics 3 (3BPP)
0x60000 - 0x616F7: Monster Graphics 4 (3BPP)
0x616F8 - 0x632F7: Zeromus Transformed Graphics (4BPP)

0x636C0 - 0x67277: Spell Effect Graphics (3BPP)

0x679C0 - 0x67FEF: Battle Status and Numeral Graphics (3BPP)

0x68818 - 0x6E397: Summoned Monster Graphics (3BPP)

0xACC00 - 0xAD83F: Ending Solar System Graphics (4BPP)

0xADC00 - 0xAFFFF: Airship Tileset (4BPP)

0xD0000 - 0xD7DFF: Battle Character Sprites [800 per char, Golbez/Anna shared] (4BPP)
0xD8000 - 0xDB2FF: Playable Character Field/Overworld Sprites [200 per char] (3BPP)
0xDB300 - 0xDFFDF: NPC Field Sprites (3BPP)
0xE0000 - 0xE27EF: Overworld Sprites (3BPP)

0xE5900 - 0xE637F: Battle Weapon Sprites (3BPP)
0xE6380 - 0xE6DFF: Battle Weapon Slash Sprites (3BPP)

0xED3C0 - 0xEED3F: Character Menu Portraits (3BPP)

0xEED40 - 0xEFFFF: Castle Exterior Tileset (3BPP)
0xF0020 - 0xF1567: Cave Magnes/Sealed Cave Tileset (3BPP)
0xF1568 - 0xFE7F8: Remaining Tilesets [can break these down later] (3BPP)

I lost the document I originally had these in, so dug them up again. Overlooked battle BGs somehow. Had palettes at one point too; hopefully someone still has those.
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on August 16, 2013, 05:36:04 PM
"Ending Solar System Graphics..." is that where the moon breaks away from the solar system?
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on August 16, 2013, 05:48:09 PM
I'm not sure if the moon is in there, but yeah, should be those graphics.
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on August 16, 2013, 09:37:19 PM
I'm gonna look around and see if I can find the palettes documented. If I (or someone else) don't find them within a few days, I'll use the TLP/SNESPal method to figure them out.
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on August 16, 2013, 09:43:23 PM
Zyrthofar's editor can do the spell/weapon palettes (they're shared, so ff4hackster doesn't currently have all the possible weapon palettes, just the intended ones), so those are easily tracked down via edits in that at least. And I know most of the others are documented somewhere, but finding them again is pretty painless.
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on August 22, 2013, 08:53:53 PM
Here are some palette offsets courtesy of Phoenix and Yousei:

Code: [Select]
D0200-D7E3F Battle Character Graphic Data (4 bitplanes, composite)
D0200-D09FF Dark Knight Cecil
D0A00-D11FF Kain
D1200-D19FF Young Rydia
D1A00-D21FF Tellah
D2200-D29FF Edward
D2A00-D31FF Rosa
D3200-D39FF Yang
D3A00-D41FF Palom
D4200-D49FF Porom
D4A00-D51FF Paladin Cecil
D5200-D59FF Cid
D5A00-D61FF Older Rydia
D6200-D69FF Edge
D6A00-D71FF FuSoYa
D7200-D77FF Pig
D7800-D7B5F Golbez
D7B60-D7D1F Anna
D7D20-D7E3F (blank)
E7F00-E80FF Character Battle Palette Data

Code: [Select]
68200-6823F Overworld Character Palette Data
AB4FA-AB50B Overworld Character Palette Pointers (1 byte per character, values 00-03)
D8200-DB4FF Overworld Character Graphic Data (3 bitplanes, composite)
D8200-D84FF Dark Knight Cecil
D8500-D87FF Kain
D8800-D8AFF Young Rydia
D8B00-D8DFF Tellah
D8E00-D90FF Edward
D9100-D93FF Rosa
D9400-D96FF Yang
D9700-D99FF Palom
D9A00-D9CFF Porom
D9D00-D9FFF Paladin Cecil
DA000-DA2FF Cid
DA300-DA5FF Older Rydia
DA600-DA8FF Edge
DA900-DABFF FuSoYa
DAC00-DAEFF Mini
DAF00-DB1FF Toad
DB200-DB4FF Pig

Code: [Select]
688D0-689CF Character Portrait Palette Data
ED5C0-EEF3F Character Portrait Graphic Data (3 bitplanes, composite, 384 bytes per class id)

Code: [Select]
44200- (08C000-      ) Title Screen Graphic Data

46A00-46AFF (08E800-08E8FF) Title Screen Palette Data

68200-6823F (0D8000-0D803F) Overworld Character Palette Data
68240-6827F (0D8040-0D807F) Overworld Vehicle Palette Data

7D400- (0FD200-      ) Battle Background Palette Data

A0800-A0AFF (148600-1488FF) World Map Tile Palette Pointers
A0B00-A0C7F (148900-148A7F) World Map Palette Data

A6000-A6FFF (14DE00-14EDFF) Town Map Palette Data

E7000-E7E9F (1CEE00-1CFC9F) Enemy Palette Data

If you don't have a copy of Yousei's old FF4.txt, I've attached it.
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on September 19, 2013, 11:51:09 PM
The standard monster sizes, 00 - 10 (hex) are defined in a table beginning at 7015E.

Each is two bytes, representing the width and height respectively.
I found them while hunting for the "special" sizes. I imagine those are nearby, but I'll have to play around with some special sized monsters to try to figure it out. I imagine the encoding will be pretty complicated. As I recall, the "size" byte points to a set palette as well (changing the byte in the monster's image data that normally would change the palette has no effect, and most "special" size monsters have a 00 in their palette byte).

Obviously, this would be the exciting part, allowing you to fight against Shiva/Indra/Jinn without messing up other monsters.
I'll figure it out eventually. In the mean time, enjoy making 1x1 and 7x7 enemies (or 1x7, or 5x14, or whatever rectangle you can dream up).
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on September 23, 2013, 10:12:24 AM
New discovery!

I found out where the game stores the palette pointers for the "Special" sizes.
Once the game determines that the monster is a special size, it looks up a set of five corresponding bytes in a table at 7D000 (FCE00 in LoROM).
Byte 02 determines the palette.

So, for D. Mist (Size 80), the five bytes are at 7D000 and are:
35 91 A1 02 00
D. Mist uses Palette A1 (Multiply by 10 hex and add to E7000 = E7A10 for the beginning of the palette data).
If I want D. Mist to use Imp's palette instead, I change the data at 7D000 to read:
35 91 00 02 00

Of course, D. Mist changes into mist and at that time changes to special size 81, so you'd need to change the A1 at 7D007 to the same thing, unless you want the mist to be a different color than the dragon.

So there you have it. Unfortunately (I guess), the palette must stay linked to the size, but by default, each special size is linked to only one monster (and to change that fact would probably be more work than it was worth anyway).  I'm sure the other four bytes per size in this table do fun things as well, but I haven't experimented yet. I'll keep you posted.
 :edit: It seems the other four bytes work together to point to the sprite arrangement.  I don't know why the programmers chose to sprite it the way they did, because these numbers all roll around a bunch then finally end up indicating a two-byte pointer in the table beginning at 75100 (ECF00 in LoROM).
 :edit: 2 The fifth byte in the five byte sequence above indicates which pointer within this table will be used. So, D. Mist's fifth byte is 00 - it will use the first pointer.
Add this pointer to E0000 in LoROM, or 68200 in ROM, to get to... Dat-da-da-daaah the sprite arrangement data!
It doesn't work exactly like it does for summons. Basically, when a monster's image is loaded into the game, the game starts at the pointer and loads a ton of sprites into memory - more than it needs for one image, more on that later.
The game has also, at this point, picked out a size from the table at 7015E, which is larger than we originally thought. More on that some other time - I have to finish up for the day.
 :edit: The size is determined by the second byte of the info at 7D000, but only by bits 0-5 of that byte. bits 6-7 have an entirely separate purpose (don't know).
So, using the example of D. Mist again, byte 01 of its entry in the table is 91 (10010001). Ignoring bits 6-7 (for the moment), we get 11 (--010001). This tells us that D. Mist uses the 11th (hex) size in the table (0Ax08). If we wanted D. Mist to be 2x2 instead, we can change this to 00 (the first entry in the size table). Just be sure to leave bytes 6-7 the same. So to make D. Mist 2x2, change the 91 at 7D001 to 80.

So, we've got a defined x and y size from the size table, all the game needs is to know how to fill that space. In the case of D. Mist, the data (at 75172) reads:
Code: [Select]
-- -- FE 06 00 01 02 FE 06 03 04 05 06 FE 03 07
08 09 0A 0B 0C 0D FE 03 0E 0F 10 11 12 FF 14 FE
03 15 16 17 18 19 FE 05 13 1A 1B 1C 1D 1E 1F FE
02 20 21 22 23 24 25 26 FF 27 2F 2A 2B 29 2A 2B 2C 2D 2E
FE represents a number of blank spaces, defined by the following byte, so D. Mist's image starts out with six blank spaces, then the arrangement data tells the game which of the stored sprites to display - so sprites 00, 01 and 02. Then there are 6 more empty spaces. Now, on the first line, as defined by D. Mist's size, there is only room for one more space (D. Mist's size is 0Ax08), then we go to the next line for the other five empty spaces. Then sprites 03, 04, 05 and 06, then three more empty spaces... and so on in that fashion. FF represents a single empty space (a space saver for when you only need one).

Like I said, I have to go for today, but I wanted to get this all down while it's still fresh. I'll elaborate/clarify later or tomorrow when I have more time.
Title: Re: Where are the graphics for... well... everything?
Post by: Grimoire LD on September 23, 2013, 11:00:22 AM
I was wondering why those palettes were listed as 00. Another great find Chillyfeez!
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on September 23, 2013, 11:24:41 AM
see the large edit above
Title: Re: Where are the graphics for... well... everything?
Post by: Grimoire LD on September 23, 2013, 11:38:40 AM
What a strange way to handle it... does this have something to do with transforming sprites by any chance? Like when the Mist Dragon turns into Mist or MomBomb puffs up?
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on September 23, 2013, 04:36:50 PM
Precisely. It allows different forms of the same monster to repeat the same sprites (you don't need eight copies of Octomamm's head).

With this info, we can make shiva, jinn and indra enemy monsters now. I'll put some samples together pretty soon - that'll help illustrate the process. I want to look into the Asura and Bahamut subroutines first, though. I think then I'll be able to comfortably close the book on my monster research (and maybe actually get back to working on my hack).

 :edit: Samples here:
http://slickproductions.org/forum/index.php?topic=1890.0
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on December 16, 2013, 05:45:07 AM
I'm currently trying to get the "inner map" tiles read and displayed correctly. So far, I seem to be getting the palettes without any trouble, as well as the 8x8 graphic tiles.

My questions are these:

1. How does the game determine how to assemble the 8x8 graphic tiles into a 16x16 sprite? Where is this information in the ROM and how is it read?
2. How does it determine which 16x16 map tile uses which 8-color palette?
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on December 16, 2013, 11:46:36 AM
Regarding question 2, that's determined by map info. The sealed cave and cave eblana use the same tileset even though one is yellowish orange amd one is grayish blue.

No idea about question 1. Sorry.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff 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.
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez 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?
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff 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:
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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:

Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff 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.
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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?
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff 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.
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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:
(http://memberfiles.freewebs.com/22/01/115500122/photos/undefined/CrazyImp.jpg)


- I think we're on the same page. Now that my brain comprehends the problem...how to solve it... :hmm:
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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

Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez 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?
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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:
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff 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:
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez 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!
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde 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:


Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on December 18, 2013, 05:26:35 PM
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!
When I was learning to code NES homebrews, I remember reading that pointers should be handled in this same manner, rather than the way we typically find them in ROMs. It's supposed to be more efficient code-wise, although I can't remember why anymore. Maybe here the speed increase was actually worth the extra effort to store them like that.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on December 19, 2013, 05:06:21 AM
Quote
0xF1568 - 0xFE7F8: Remaining Tilesets [can break these down later] (3BPP)

Were these ever broken down after?
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on December 19, 2013, 07:09:12 PM
Sorry, never got around to it.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on December 20, 2013, 03:50:52 AM
I see. I tried finding the boundaries myself but it's not straightforward. Between that and the issues I'm having getting the palettes working correctly I think I might just use hard-coded tiles for now and come back to this later. Seeing what would be involved in changing a map tile's graphic makes me skeptical that people would be inclined to do it without a devoted editor (which when the time comes I might just build into FF4kster after all!).
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on December 22, 2013, 10:08:13 PM
Yeah, that's probably not a bad idea (using hard coded for now). I've always wanted to give the castle and town interior tilesets an overhaul, to use wall borders like the tower and cave tilesets do, but I'm not even sure if there are enough tiles to do it without sacrificing details. I just dislike the way those two sets still use the FF2, FF3-like exterior walls style instead of the better looking style used by the other sets.

Speaking of those borders, when you do add map editing support, tile scaling and a gamma correction features would really be appreciated. It was always a pain editing caves using FF Tools since I couldn't really make out the corner tiles at all. I ended up modifying the map editor to use a black background, which really helped.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on December 23, 2013, 05:02:48 AM
Scaling will be easy when I get the tile graphics read from the rom directly, but it's unlikely to happen while I'm using the hard-coded tiles. Gamma correction, I have no idea how to do that. The background will ideally be whatever image that map has set as its background by default and maybe an option to turn it off and on or something.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on January 11, 2014, 04:03:10 AM
Ok so I managed to find almost all the tilesets:

Castle Exterior: EEF40
Sealed Cave: F0220
Town: F1768
House: F2EC0
Castle Interior: F3AC0
Crystal Room: F51E8
Lunar Subterrane: F61A8
Lunar Core: F61A8
Feymarch: F8200
Tower: F9700
Lunar Whale: F9700
Mountain: FD408
Cave: FEA88

The ones missing are the Giant, the Ship, and the Airship.

The Giant I found partial success at the same address as the Tower and Lunar Whale, but while some of the tiles would appear correct, others would not; so if that is the correct address, then there's something else going on for the Giant tileset specifically.

The Airship address I noticed was posted in the first page of this thread, and it is oddly at 4 BPP rather than 3 like the rest of them, but it too does not seem to appear correctly. The ship I have no idea whatsoever. Could be that it shares graphic tiles with the Airship tileset much like the Tower and Lunar Whale; but until I can get the Airship tileset working I don't have any way to verify that.

I can't convert the system to dynamic tile reading until I can get all the tilesets working. Does anyone have any ideas as to where I should go from here?
Title: Re: Where are the graphics for... well... everything?
Post by: chillyfeez on January 11, 2014, 11:16:48 AM
I don't know if this helps you or not... and I can't say I've ever really looked at thow the graphics are actually encoded for the tilesets, but FFTools seems to indicate that:
-Airship and Ship are different tilesets
-Lunar Whale, Tower and Giant are all different tilesets
I imagine it's probable that these tilesets share graphics tiles, but it seems the tilesets themselves are different (according to phoenix, anyway).
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on January 11, 2014, 05:07:50 PM
There's no question that they're different tilesets. However it's apparently possible that two different tilesets share the same pointer for the graphic tiles. The ship and airship do seem to have the same pointer as each other, and the Tower, Giant, and Whale all seem to share a pointer as well. The only thing is that the Giant tiles, well, some look fine, but many don't. And I can't get the airship or sea ship tilesets to look correct, even at what should be the correct pointer.
Title: Re: Where are the graphics for... well... everything?
Post by: Dragonsbrethren on January 13, 2014, 03:05:44 PM
Are you loading the airship/ship tiles as 4BPP? It's the only map tileset I know actually uses 16 colors per metatile. Parts of the giant might too, not sure.
Title: Re: Where are the graphics for... well... everything?
Post by: Gedankenschild on March 17, 2014, 09:18:30 PM
What exactly is the problem with the ship/airship tileset? Glancing over it, it looks pretty complete (and a single one, too)...
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on March 18, 2014, 04:54:15 AM
Whoa, I was never able to get mine to look like that! Maybe I'm just not interpreting 4BPP correctly in the code or something... I'll look into it and tinker a little, and if I still can't get it I'll post the relevant code and maybe someone else will be able to see what's going wrong.
Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on April 01, 2014, 04:24:05 AM
Attached screenshot is what I'm getting.

Here's my code for the graphic reading funciton:

Code: [Select]

SetTiles(&hADE00, 256, 4)

sub SetTiles(start as UInteger, total_tiles as Integer, bpp as UByte = 3)

 dim b as UByte
 
 for i as Integer = 0 to total_tiles - 1
  for j as Integer = 0 to 7
   for k as Integer = 0 to 7
    sprite(i, k, j) = 0
   next
  next
 next
 
 for i as Integer = 0 to total_tiles - 1
 
  if bpp < 4 then
 
   for j as Integer = 0 to 7
    b = ByteAt(start + i * 24 + j * 2)
    for k as Integer = 0 to 7
     sprite(i, k, j) = (b \ 2^k) and 1
    next
    b = ByteAt(start + i * 24 + j * 2 + 1)
    for k as Integer = 0 to 7
     sprite(i, k, j) += ((b \ 2^k) and 1) * 2
    next
   next
   
   if bpp = 3 then
    for j as Integer = 0 to 7
     b = ByteAt(start + i * 24 + 16 + j)
     for k as Integer = 0 to 7
      sprite(i, k, j) += ((b \ 2^k) and 1) * 4
     next
    next
   end if
 
  elseif bpp = 4 then
 
   for j as Integer = 0 to 7
    b = ByteAt(start + i * 24 + j * 2)
    for k as Integer = 0 to 7
     sprite(i, k, j) = (b \ 2^k) and 1
    next
    b = ByteAt(start + i * 24 + j * 2 + 1)
    for k as Integer = 0 to 7
     sprite(i, k, j) += ((b \ 2^k) and 1) * 2
    next
   next

   for j as Integer = 0 to 7
    b = ByteAt(start + i * 24 + 16 + j * 2)
    for k as Integer = 0 to 7
     sprite(i, k, j) += ((b \ 2^k) and 1) * 4
    next
    b = ByteAt(start + i * 24 + 16 + j * 2 + 1)
    for k as Integer = 0 to 7
     sprite(i, k, j) += ((b \ 2^k) and 1) * 8
    next
   next

  end if
 
 next

end sub

Title: Re: Where are the graphics for... well... everything?
Post by: Gedankenschild on July 27, 2014, 07:34:45 PM
I realize I'm pointing out the obvious, but: Looking at both our screens again I notice that your tileset seems pretty exactly double the size of mine with noticable redundancy. So you seem to be extracting too much. Not exactly coding help, but well... Don't forget: It may be twice the colors, but it's only one more bit (OK, probably not helpful, but that was actually a somewhat important realization in my understanding the ASM code.) Good luck!
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde on July 28, 2014, 05:10:05 AM
I wish I could be of more help but when it comes to the graphics:  :blits:

 :offtopic:  (Sort of at least  :tongue:)

One thing I did put together yesterday (for fun!) was this comparison shot between the SNES, Wonderswan, & GBA releases. It was kinda neat to look at.

Also, is it me, or does the deck actually look best in the WSC version? But that's just a choice in style.

Title: Re: Where are the graphics for... well... everything?
Post by: Pinkpuff on July 29, 2014, 06:25:10 AM
I realize I'm pointing out the obvious, but: Looking at both our screens again I notice that your tileset seems pretty exactly double the size of mine with noticable redundancy. So you seem to be extracting too much. Not exactly coding help, but well... Don't forget: It may be twice the colors, but it's only one more bit (OK, probably not helpful, but that was actually a somewhat important realization in my understanding the ASM code.) Good luck!

Mine is twice the size because I think yours was just the graphic tiles whereas mine is the tileset, as in, the map tiles, so, the graphics all assembled, flipped as needed, possible duplicates graphically to account for tiles that are different but look the same, etc.

However, your observation did point me in the right direction! My eye was drawn to that "i * 24" part, and I was going, "wait, if it's 4bpp shouldn't there be 32 bytes per graphic, not 24 like in 3bpp?" so I changed that and voila, SUCCESS!!

 :happy: You guys have no idea how happy I am right now!  :childish:

Alright, so, next step will be dynamic overlays (the red square, arrows, etc, to indicate the various tile properties) and then I can eliminate that whole folder of graphics ripped from FF4Tools from the package altogether! After that, I can start on the tile editor so the user can dynamically manipulate the tiles themselves (what ones have chests, their walkable properties, whatever else was discovered). In any case, discussion on those topics can go in the main thread. Eventually I'll still probably need this thread though for working out the monster graphics, weapons/spell graphics, and such once I get there.
Title: Re: Where are the graphics for... well... everything?
Post by: Gedankenschild on July 29, 2014, 07:08:34 AM
Ah, I see. So yours is essentially what ends up in VRAM...
Well, congratulations then!  :cookie:
Title: Re: Where are the graphics for... well... everything?
Post by: LordGarmonde on July 29, 2014, 11:18:40 PM
:happy: You guys have no idea how happy I am right now!  :childish:
Congrats Pinkpuff! I remember months back when I was Photoshopping the red out of those tilesets. Good for you for not having given up on your pursuit - you made a good compromise with the external references and keep the editor going - but you never gave up. I think I do understand how good such a victory feels - and since I've no hat to tip to you please accept:  :cookie:

lol  :laugh: - Moving forward though I definitely agree that this thread will continue to be of use - so very complicated