Seen 2 Weeks Ago
Posted September 1st, 2019
1 posts
1.4 Years
Hello, I've been a member here for a while but this is my first post.

I was taking a look at the BDHC format and found that some people have figured out most of the file and that the only part left was the inclines. I figured out what they are.

Here's the main resource I looked at: https : // hirotdk . neocities . org/HGSS_File_Specs.html#Terrain
(I can't post links so I had to space it out)

So what are the inclines? Well they are not inclines. They are just simply normal vectors saved as ints. These normals represent the up direction of the plate.

Reading:
So here are the known values:
- Flat Plate:   00 00 00 00 00 10 00 00 00 00 00 00
- North Stairs: 00 00 00 00 50 0B 00 00 50 0B 00 00
- East Stairs:  B0 F4 FF FF 50 0B 00 00 00 00 00 00
- West Stairs:  50 0B 00 00 50 0B 00 00 00 00 00 00
And here they are when read as int vectors
- Flat Plate:   { 0,    4096, 0}
- North Stairs: { 0,    2896, 2896}
- East Stairs:  {-2896, 2896, 0}
- West Stairs:  { 2896, 2896, 0}
Then you convert them to float vectors and normalize them:
- Flat Plate:   { 0,     1,     0}
- North Stairs: { 0,     0.707, 0.707}
- East Stairs:  {-0.707, 0.707, 0}
- West Stairs:  { 0.707, 0.707, 0}
Writing:
And to convert the float vectors back to int vectors:
Just take the normalized float vector and multiply all the values by 4096 and then round to the closest whole number. (Then you can write them back to the file.)

Example of random arbitrary untested normal:
Float Vector: {0.13, 0.912, 0.39}
Int Vector: {532, 3736, 1597}
Hex: 14 02 00 00 98 0E 00 00 3D 06 00 00
The reason for the number 4096 is to keep some precision. Of course some precision will be lost but 4096 is what nintendo used, so we should probably use that.

Keep in mind I have not tested any rom editing for this, but this is just how to read it and write it. It should function in game.

Thank you for reading. I hope this is helpful.

~ Matt