Author Topic: Chrono Cross Backgrounds (Research)  (Read 4314 times)

Vehek

  • Errare Explorer (+1500)
  • *
  • Posts: 1761
    • View Profile
Chrono Cross Backgrounds (Research)
« on: January 16, 2009, 06:59:21 pm »
It looks like background assembly is OUT 7 outputted by the room dumper.

Header:
N# N# N# N# ?? ?? ?? ?? N1 N1 N1 N1

N# - Number of something.
?? - Always 00 00 000 in the few files I've looked at.
N1 - Something. Doesn't seem to be an offset. The number of these is the N#.


The tile data is dec12 bytes each.

XX XX YY YY TT TT TT TT ?? ?? ?? ??.

XX - X coordinate on screen
YY - Y coordinate on screen
TT - Three different things are done with this (getting a copy of the value each time).
First, it's shift right 0x0B bits and then ANDed with 0x1F. I don't know what this does yet.
The value is shifted right 0x1B bits and then has 0xE0 added to it. This seems to determine the palette used.
Finally, it's ANDed with 0x7FF, and is apparently the tile used.

I haven't tried much with the last part of it yet, except it might be related to layering.
---
For me, the asm for this is at 0xac5c0 in memory.
Code: [Select]
000ac5c0: 24a50004 addiu r5,r5,0x0004
000ac5c4: 8ca30004 lw r3,0x0004(r5)
000ac5c8: 8cb00000 lw r16,0x0000(r5)
000ac5d0: 00034c02 srl r9,r3,0x10
000ac5d4: 3055ffff andi r21,r2,0xffff
000ac5d8: 0002b402 srl r22,r2,0x10
000ac5dc: 001012c2 srl r2,r16,0x0b
000ac5e0: 3042001f andi r2,r2,0x001f
000ac5e4: afa20018 sw r2,0x0018(r29)
000ac5e8: 001016c2 srl r2,r16,0x1b
000ac5ec: 244200e0 addiu r2,r2,0x00e0
000ac5f0: 321407ff andi r20,r16,0x07ff

Test by tampering with the code:


[attachment deleted by admin]
« Last Edit: January 29, 2009, 04:44:02 pm by Vehek »

justin3009

  • Fan Project Leader
  • God of War (+3000)
  • *
  • Posts: 3296
    • View Profile
Re: Chrono Cross Backgrounds
« Reply #1 on: January 16, 2009, 07:57:02 pm »
Very nice Vehek!

FaustWolf

  • Guru of Time Emeritus
  • Arbiter (+8000)
  • *
  • Posts: 8972
  • Fan Power Advocate
    • View Profile
Re: Chrono Cross Backgrounds
« Reply #2 on: January 16, 2009, 08:30:45 pm »
Damn nice work there Vehek. I wonder if there's something in there specifying palette application? The structure of the room files is as follows:
http://www.chronocompendium.com/Term/Room_Files.html

OUT #1 is the palette data; I assume there's a bunch of palettes sitting in there.

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Chrono Cross Backgrounds (Research)
« Reply #3 on: February 02, 2009, 06:31:37 am »
It looks like background assembly is OUT 7 outputted by the room dumper.

Header:
N# N# N# N# ?? ?? ?? ?? N1 N1 N1 N1

N# - Number of something.
?? - Always 00 00 000 in the few files I've looked at.
N1 - Something. Doesn't seem to be an offset. The number of these is the N#.


Perhaps those are layer depth values?

The tile data is dec12 bytes each.

XX XX YY YY TT TT TT TT ?? ?? ?? ??.

XX - X coordinate on screen
YY - Y coordinate on screen
TT - Three different things are done with this (getting a copy of the value each time).
First, it's shift right 0x0B bits and then ANDed with 0x1F. I don't know what this does yet.
The value is shifted right 0x1B bits and then has 0xE0 added to it. This seems to determine the palette used.
Finally, it's ANDed with 0x7FF, and is apparently the tile used.


XX XX YY YY UU UU VV CC ?? ?? ?? LL

UU UU = U/2 + TPX (texture page x coordinate)
VV VV = V  (It seems this value is always V, since texture page y coordinate is always 256 from those examples)


UU UU = U/2 ADD TPX (texture page x coordinate)
VV CC = V ADD (CLUT offset - 0x70000)
LL - It seems to be the layer index, a smaller value will make it displayed in front of those have larger values.
« Last Edit: February 02, 2009, 12:52:21 pm by utunnels »

yaz0r

  • Architect of Kajar
  • Porrean (+50)
  • *
  • Posts: 65
    • View Profile
Re: Chrono Cross Backgrounds (Research)
« Reply #4 on: February 04, 2009, 05:50:31 am »
I took a quick look at the header part of the file, and it seems to me that it actulay goes like this:

UInt32 uNumLayers
UInt32 aRange[uNumLayers + 1];

The aRange is a serie of index into the array of elements that direcly follow the header (stride is obviously 0xC). To get the actual offset for an element, the formula is simply (id * 0xC + uNumLayers * 4 + 4).
When the game want to draw layer 3, it will draw the elements from aRange[3] to aRange[4] from the array.
The first aRange is always 0x0, as the first layer always start at the id 0, and the aRange size if [uNumLayers + 1] and not [uNumLayers] as it would require the range of the last layer in the data.
I'll see what I can do with the actual array data later on.
« Last Edit: February 04, 2009, 06:09:03 am by yaz0r »

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Chrono Cross Backgrounds (Research)
« Reply #5 on: February 04, 2009, 07:51:59 am »
I wonder how tile animation works.
Maybe when these are solved, we can assemble all maps without my tool.

yaz0r

  • Architect of Kajar
  • Porrean (+50)
  • *
  • Posts: 65
    • View Profile
Re: Chrono Cross Backgrounds (Research)
« Reply #6 on: February 04, 2009, 10:18:20 am »
From what I have seen in some room scripts, animation are performed by activating/deactivating overlapping background layers in cycle. I don't have an exemple here, but it look like this:

Label:
ACTIVATE_BACKGROUND_LAYER(2)
WAIT(10)
DEACTIVATE_BACKGROUND_LAYER(2)
ACTIVATE_BACKGROUND_LAYER(3)
WAIT(10)
DEACTIVATE_BACKGROUND_LAYER(3)
JUMP Label
« Last Edit: February 04, 2009, 10:20:03 am by yaz0r »

Akari

  • Iokan (+1)
  • *
  • Posts: 11
    • View Profile
Re: Chrono Cross Backgrounds (Research)
« Reply #7 on: February 04, 2009, 01:54:05 pm »
From what I have seen in some room scripts, animation are performed by activating/deactivating overlapping background layers in cycle. I don't have an exemple here, but it look like this:

Label:
ACTIVATE_BACKGROUND_LAYER(2)
WAIT(10)
DEACTIVATE_BACKGROUND_LAYER(2)
ACTIVATE_BACKGROUND_LAYER(3)
WAIT(10)
DEACTIVATE_BACKGROUND_LAYER(3)
JUMP Label

Just like in FFVII and Xenogears.
From what I know in FFVII - there are 3 types of layers. Bottom, depth sorted and dynamic. Dynamic layer's depth and position set from script. FFVII has 4 layers, two of them are dynamic.