Author Topic: Coords for tiles in window.bin  (Read 6544 times)

Akari

  • Moderator
  • Freak
  • *
  • Posts: 761
  • Karma: 26
    • View Profile
Coords for tiles in window.bin
« on: 2006-06-03 03:47:21 »
How square set up coords for the tiles in window.bin interface elements? It's hardcoded in the exe or they have some sort of description for it?

dziugo

  • No life
  • *
  • Posts: 1474
  • Karma: 3
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Coords for tiles in window.bin
« Reply #1 on: 2006-06-03 07:42:38 »
It's hardcoded. At least for items I looked at.

Akari

  • Moderator
  • Freak
  • *
  • Posts: 761
  • Karma: 26
    • View Profile
Re: Coords for tiles in window.bin
« Reply #2 on: 2006-06-03 14:11:25 »
It's hardcoded. At least for items I looked at.

Hmm... then why last part of window.bin looks so like the tile size? Can someone with knowledge of disasm check out for what this file used and what are exact coords for first archive in window.bin

For the time being I hardcoded coords. Soon I update SVN with support for fonts and windows.

Halkun, by the way, how internally position for the text set? For now I set window space as 320x240 and it could be set as is     KERNEL->DrawString("AKARI\nIS\tBAKA!", 200, 200);

And I need char table for real char assosiation, not the ASCII.

dziugo

  • No life
  • *
  • Posts: 1474
  • Karma: 3
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Coords for tiles in window.bin
« Reply #3 on: 2006-06-03 17:05:39 »
Last part is font's size (for each char).

dziugo

halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Coords for tiles in window.bin
« Reply #4 on: 2006-06-03 21:46:39 »
This was going to be somethig I was going to do for you guys. (Map the coords of window.bin) I may put my fieldscript opcodes to the side and knock that out real quick.

I have about 26 Opcodes decrypted so far.


Akari

  • Moderator
  • Freak
  • *
  • Posts: 761
  • Karma: 26
    • View Profile
Re: Coords for tiles in window.bin
« Reply #5 on: 2006-06-04 02:54:57 »
Last part is font's size (for each char).

Can you describe the format?

Quote
I may put my fieldscript opcodes to the side and knock that out real quick.

It will be very helpfull. And I need to know which palette use for each part of window.bin. Because I need to create usual textures, but dont want create 17 copies of the same texture with different palettes.

dziugo

  • No life
  • *
  • Posts: 1474
  • Karma: 3
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Coords for tiles in window.bin
« Reply #6 on: 2006-06-04 08:14:32 »
FF7 uses an array to see how much pixels each letter has. The address in memory (after loading ff7.exe EN v1.0):
 - 0x0098F458

In that array, each byte corresponds to a single character. To decode the data stored, all you have to do is get the byte for a character, and look for the corresponding data in the array. After that:
 - to get a character's width, AND a just-found-byte with 0x1F  (00011111b)
 - to get a character's padding (well I don't know if that's what it's called, but it's just a number of pixels before the character), SHR just-found-byte by 5

Example:
To get a quotation mark "values", we:
 - get the byte for that character - it's stored in address 0x0098F458 (base address) + 0x1F (the hex value for quotation mark). It should be 0x27 (or 00100111b or 39);
 - AND it with 1F, or modulo it by 0x20 (32) - we get 7
 - SHR it (the byte read 0x27) by 5 (or divide by 32) - we get 1
And... that's it. Remeber that these values are in 320x240 resolution mode (not really sure about that), to get the size in the 640x480 mode multiply the results by 1.666667, and truncate the non-integer part (even if it's 4.9998, we get 4).

Full version :P

dziugo

Micky

  • Insane poster
  • *
  • Posts: 300
  • Karma: 4
    • View Profile
Re: Coords for tiles in window.bin
« Reply #7 on: 2006-06-04 12:03:23 »
... or grab my code, which works on the PSX version.

halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Coords for tiles in window.bin
« Reply #8 on: 2006-06-04 18:58:51 »
I HAVE IT!!!!!!!!!!

I stayed up to an obscene hour working on this, but for you guys I mapped out all of window.bin's coords. I have a handy package of graphic helpers to assist you in getting what you need.

You can download it here

This is from the README.txt file (Included with the package)


Quote
Hi there,
The following files here are to help you plot the window.bin graphics. I have
mapped the borders of all the graphics and placed them in the following
non-lossy .png files
                                                                               
The files are as follows.
                                                                               
winwithtex.png - this shows the texture boundries superimposed over the
textures themselves.
                                                                               
windowbin8x8.png - This is just the boundries overlaied on a 8x8 grid so you
can easily figure out the coordinates.
                                                                               
windowbin_transwhite.png - This is a transparent png that has just the borders
in white so you can overlay them yourself.
                                                                               
windowbin_transblack.png - This is a transparent png that has just the borders
in black this time  so you can overlay them yourself.
                                                                               
                                                                               
################################
# Notes on window.bin textures #
################################
                                                                               
There are a few things to note. First all texture borders stop on a mutiple of
8 pixels, execpt for the words and numbers that "bounce" during a battle
attack. These are 10 pixels high. This has to do with the fact that these
textures are copied elsewhere during the "bounce" and not taken directly from
window.bin. The "bounce numbers" are actually 16 pixels high, but the bottom 6
pixels are transparent and don't matter.(The origin of the textures are the
upper left hand corner)
                                                                               
The three blank "x" textures are for the chataracter avatars. These are at a
different colordepth so the space for them is wider. (The PSX could hold
mutiple color depths on the same video surface)
                                                                               
#####################################
# Notes on the Color Look Up Tables #
#####################################
                                                                               
window.bin has 16 CLUTs, the first color of all CLUTs are always transparent.
The different colors are allocated for the following textures
                                                                               
                                                                               
Clut 1
Window borders in lower left hand corner.
                                                                               
Clut 2
Battle menu words (HP, NAME, BARRIER, etc) , selector finger, scollbar widgets,
materia slots and links, sleaping Zzz and Silence bobbles, equip weapon icons,
shop weapon and item icons, "here" pointing finger (comes on when you press
"select"  Pretty much all greyscale items. Blue text.
                                                                               
Clut 3
Purple ATB bar, red text
                                                                               
Clut 4
Blue ATB bar, pink text
                                                                               
Clut 5
Green text, green materia, green filled and unfilled master ranking stars
                                                                               
Clut 6
Cyan text, blue materia, blue filled and unfilled master ranking stars
                                                                               
Clut 7
Yellow text
                                                                               
Clut 8
White text, Battle target arrow, selecter finger with red "X" over the top, PSX
R1,R2,L1,L2, start, and select buttons
                                                                               
Clut 9
Coin attack "throw" colors for texture, yellow materia, yellow filled and
unfilled master ranking stars.
                                                                               
                                                                               
Clut 10
Arrows that show exits (when select is pushed), purple materia, filled and
unfilled purple master ranking stars.
                                                                               
Clut 11
Red materia, red filled and unfilled master ranking stars PSX "shape" buttons
                                                                               
Clut 12
Tifa limit slots

Clut 13
Countdown clock
                                                                               
Clut 14
Colors for Cloud? (not avatar)
                                                                               
Clut 15
Unknown, possably a limit
                                                                               
Clut 16
Unknown, possably a limit
                                                                               
                                                                               
####################################################
# Notes on dialog font (second file in window.bin) #
####################################################
                                                                               
These are 12x12 caracters arranged in FFText order.

Have fun ^_^


###########
EDIT
###########

Let me know if this was helpful... I'm back to opcode decrypting again
« Last Edit: 2006-06-04 21:56:13 by halkun »

Akari

  • Moderator
  • Freak
  • *
  • Posts: 761
  • Karma: 26
    • View Profile
Re: Coords for tiles in window.bin
« Reply #9 on: 2006-06-05 19:27:03 »
Quote
Clut 3
Purple ATB bar, red text
                                                                               
Clut 4
Blue ATB bar, pink text
                                                                               
Clut 5
Green text

Clut 7
Yellow text
                                                                               
Clut 8
White text

Hmm... the color of those are transparent. So we cant see the font... although it works on window borders. Any comments?

Maybe I made some mistake?
Code: [Select]
u16 col = GetU16LE(sizeof(timHeader) + clut_number * tim_header->number_of_colors * 2 + i * 2);
clut[i].b = ((col      ) & 31) * 8;
clut[i].g = ((col >>  5) & 31) * 8;
clut[i].r = ((col >> 10) & 31) * 8;
clut[i].a = ((col & 0x8000) || (col == 0x0000)) ? 0 : 255;
Although this works in all times  :-(

By the way.. some progress

halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Coords for tiles in window.bin
« Reply #10 on: 2006-06-05 21:59:58 »
Cool!

However, you are using the wrong font. You have to use the second texture found in window.bin. (That's the 12x12 font). Right now you are using the 8x8 that's used for the battle system.

Don't forget, the 8x10 is for the "bounce" text during an attack.

(Also, the text is too dark ^_^_
« Last Edit: 2006-06-05 22:56:40 by halkun »

halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Coords for tiles in window.bin
« Reply #11 on: 2006-06-05 22:59:25 »
Quote
Clut 3
Purple ATB bar, red text
                                                                               
Clut 4
Blue ATB bar, pink text
                                                                               
Clut 5
Green text

Clut 7
Yellow text
                                                                               
Clut 8
White text

Hmm... the color of those are transparent. So we cant see the font... although it works on window borders. Any comments?

I was under the impression that index #0 in the CLUT was transparent, no matter what CLUT was loaded. I'll peek at it when I get home.

sfx1999

  • No life
  • *
  • Posts: 1143
  • Karma: 0
    • View Profile
Re: Coords for tiles in window.bin
« Reply #12 on: 2006-06-06 02:24:11 »
Akari, it is more like 8.225 than just 8.

Reason being:

255 = 31x

This is because the maximum number for the system is 255 for 8 bits, and 31 for 5 bits. 31 times 8 is only 248.

This would cause greyness. To fix it, you will need to either multiply it by 8.225, or make a table. If you are using the table:

I posted code earlier but it didn't work. I'll post it again if I get it.

[edit]Here is a table for you:

Code: [Select]
unsigned char conv5to8[32] = {0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148,
156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255};
« Last Edit: 2006-06-06 02:54:18 by sfx1999 »

Akari

  • Moderator
  • Freak
  • *
  • Posts: 761
  • Karma: 26
    • View Profile
Re: Coords for tiles in window.bin
« Reply #13 on: 2006-06-07 16:33:33 »
No comments


halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Coords for tiles in window.bin
« Reply #14 on: 2006-06-08 17:46:17 »
I have a comment.

That's Hawt!

However we are now running up against a resolution issue. I'm going to start a new thread about that.

sfx1999

  • No life
  • *
  • Posts: 1143
  • Karma: 0
    • View Profile
Re: Coords for tiles in window.bin
« Reply #15 on: 2006-06-08 21:34:08 »
Did you use the table I gave you?