Pages: 1
Posted on 07-05-13, 12:07 am (rev. 6 by  Arisotura on 07-05-13, 08:20 pm)
☭ coffee and cream


Karma: 10542
Posts: 1023/2780
Since: 06-26-11
This is mostly a findings dump.

0x020C7CEC: table that manages 3D tile rendering for Jyotyu (other similar tables must exist for other tilesets). The table holds one byte per tile, for tiles 112-255.

Each byte is the index of the tile to render. Indexes are universal, for example, you can have the game render a fence instead of a pipe. You just need to find the right values.

2D water tiles can be used in that table too (values are 0x78 for water body and 0x79 for water top). However, the 2D water doesn't use the tables. Instead, the code has another special case for it (tiles 41, 147, 148).

It is worth noting that tile 41 uses 3D tile 0x78, and the 2D tile shows a coin. The object that uses that tile (object 87) is a coin in 2D water. This means that the 3D tile system overlays 3D tiles on top of 2D tiles, which would allow for some fancy stuff.


0x020F438C: the function responsible for drawing 3D tiles. Yet to be done: reverse it, and find out how adding 3D tiles would work.


0x020AF2DC: function responsible for loading the textures used by the 3D tiles.


0x02121EC0: table listing all the textures to load for 3D tiles. Each entry is 12 bytes: bytes 0-3 -> ext file ID of the file to load from, bytes 4-7 -> ID of the texture to choose inside the file, bytes 8-9 -> palette offset in 16-byte steps

They use the palette offset trick there to do the multiple pipe colors (0x00 = green, 0x20 = red, 0x40 = yellow). It should be possible to reuse that trick to make proper blue pipes, and even more!

The table contains 142 entries. Only the first 68 are loaded in MvsL mode.


0x0212A86C: table holding the parameters for the textures once they're loaded. 8 bytes per entry: bytes 0-3 -> texture parameters, bytes 4-7 -> palette base. Both values can be directly passed to GX registers TEXIMAGE_PARAM and PLTT_BASE (0x040004A8 and 0x040004AC) (or FIFO commands 0x2A and 0x2B).


Process to load a texture:

• Call loadFileByExtId_3dModel() with appropriate parameters (R0 = file ext ID, R1 = 1 if file is LZ compressed).
• Call NNS_G3dGetTex() with R0 = the value returned by loadFile_blahblah().
• Call function at 0x02019AFC with R0 = the value returned by NNS_G3dGetTex(), R1 = the ID of the texture to retrieve, and R2 = a pointer to a dword where the texparams for the texture will be stored.
• Call function at 0x02019A88 with R0 = the value returned by NNS_G3dGetTex(), R1 = 0, and R2 = a pointer to a dword where the palettebase for the texture will be stored.

Once you got your texparams and palettebase, you can draw quads and other shit using that texture easily. If you want to pull the same trick that is used for colored pipes, you'll need to remember to add the right value to the palettebase, though.


For hacking the 3D tile system: looking for refs to 0x020C7CEC and looking around those places should give you an idea of all the special cases that exist for 3D tiles.
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Posted on 07-05-13, 08:55 am


Karma: 3767
Posts: 1889/2112
Since: 06-28-11
Thanks so fucking much for finding this. I hope we will be able to overlay more tiles with 3D tiles.
So if we find those similar tables for different tilesets, we would be able to add more 3D tiles to it?
Posted on 07-05-13, 12:32 pm
Roy Koopa


Karma: 4011
Posts: 2481/2722
Since: 06-26-11
Can someone explain it easier?
_________________________
See a lots of creative DS Hacking here
If you want to support me, you might check out my Patreon Page : )
Posted on 07-05-13, 06:09 pm
☭ coffee and cream


Karma: 10542
Posts: 1024/2780
Since: 06-26-11
Posted by Freeze
Thanks so fucking much for finding this. I hope we will be able to overlay more tiles with 3D tiles.
So if we find those similar tables for different tilesets, we would be able to add more 3D tiles to it?

All we need is to find out how to load 3D tiles from nsbtx files.

The rest will just be hacking the existing tables. Or adding more to them. It'll require ASM hacking though.

Or alternately we could rebuild this whole system in a more flexible way.
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Posted on 11-23-20, 06:34 pm
Giant Red Paratroopa
Not Edible

Karma: 3386
Posts: 1164/1447
Since: 02-12-16
Sorry for the bump, but what do these offsets correspond to? I'm trying to find these tables in the ROM, but clearly those aren't ROM offsets since every offset here ends up outside of the ROM's 32MB. I'd really like to be able to access the 0x020C7CEC and 0x02121EC0 tables, so any help is appreciated.
_________________________
Nothing to say, so jadnjkfmnjamnfjkldnajfnjkanfjdksan jsdnvj m.

Posted on 11-23-20, 07:04 pm (rev. 1 by RicBent on 11-23-20, 07:05 pm)
Mariomaster

Karma: 8573
Posts: 1596/1681
Since: 06-09-12
Those offsets are in address space, not absolute offsets from the ROM start.

0x020C7CEC is at 0x2F60C in overlay 0.
0x02121EC0 is at 0x55BE0 in overlay 10.

If you want to have a look at it you should probably just go to those addresses in IDA.
_________________________
GitHub - Kuribo64 - YouTube
Posted on 11-23-20, 07:05 pm (rev. 4 by  poudink on 11-28-20, 07:30 pm)
Giant Red Paratroopa
Not Edible

Karma: 3386
Posts: 1165/1447
Since: 02-12-16
Thanks for the help.
_________________________
Nothing to say, so jadnjkfmnjamnfjkldnajfnjkanfjdksan jsdnvj m.

Pages: 1