Geometry Layout Commands « 1 2
Users browsing this thread: 1 Guest(s)

Has anyone managed to get the 0x1D scaling command working on a level's geometry? This could potentially be used to extend the level boundaries much further than previously possible. I had a brief attempt at it myself, but it crashed.

(15-07-2015, 01:57 PM)Skeletons Wrote: Has anyone managed to get the 0x1D scaling command working on a level's geometry? This could potentially be used to extend the level boundaries much further than previously possible. I had a brief attempt at it myself, but it crashed.


The 0x1D command effects everything in the following node (Between the 0x04 & 0x05 commands). The long 0x17 command doesn't seem to like the scaling command, so you need to nest the 0x15 display list by itself like this:

Spoiler: images
[Image: V4Jxzam.png]

[Image: Nl8AG6I.png]

How do display lists effect the level boundaries anyway? I would've thought that the game would only look at the collision map for that sorta thing, or is this something related to your importer?
(This post was last modified: 15-07-2015, 08:43 PM by David. Edit Reason: better wording )

It might be possible to extend the boundaries much further in the next importer version. Here I've scaled up a maximum-size level to 2x and it didn't cause any problems.
   

I think that I've got three more commands: 0x0A, 0x17, and 0x08 which are used in level geo layouts.

Code:
​Geo Layout CMD 0x0A -- Set camera frustum properties
0A [AA] [BB BB] [CC CC] [DD DD] {EE EE EE EE}

[ 0A 00 00 2D 00 64 61 A8 ]​ // 0x0A cmd in File select menu
[ 0A 01 00 2D 00 64 4E 20 80 29 AA 3C ]​ // 0x0A cmd in Castle Grounds geo layout

AA = Use ASM code? (Either 0 or 1)
BB = Camera FOV (0x2D = 45, Only useful in menus?)
CC = Camera Near
DD = Camera Far
EE = Pointer to an ASM function

​Example of lowering the far value:
[Image: XnHz9OW.png]


Code:
​Geo Layout CMD 0x17 -- Sets up rendering for 3D Objects?

17 00 00 00


​This is what happens when you remove the 0x17 cmd from the geo layout:
[Image: Qi9ZUw0.png]


Code:
​Geo Layout CMD 0x08 -- Start Geo Layout and set screen render area.
[08]​ [00 00] [??] [XX XX] [YY YY] [WW WW] [HH HH]

[ 08 00 00 0A 00 A0 00 78 00 A0 00 78 ]​ // Start of Castle Grounds Geo Layout.

?? = Either 00 or 0A
XX = X position
YY = Y position
WW = Width of screen
HH = Height of screen

[Image: XUsUB00.png]

​Edit:
There also seems to be 3 NOP (unused) commands. 0x1A & 0x1E skip 8 bytes, while 0x1F skips 16 bytes.

Code:
​GeoLayout1A: # begin 8037DEF8 (0FAC78)
 lw    $t6, 0x8038bd80 # lui $t6, 0x8039/lw $t6, -0x4280($t6)
 lui   $at, 0x8039
 addiu $t7, $t6, 8
 sw    $t7, %lo(0x8038BD80)($at) # $t7, -0x4280($at)
 jr    $ra
 nop  

Code:
​GeoLayout1E: # begin 8037DB50 (0FA8D0)
 lw    $t6, 0x8038bd80 # lui $t6, 0x8039/lw $t6, -0x4280($t6)
 lui   $at, 0x8039
 addiu $t7, $t6, 8
 sw    $t7, %lo(0x8038BD80)($at) # $t7, -0x4280($at)
 jr    $ra
 nop  

Code:
​GeoLayout1F: # begin 8037D4DC (0FA25C)
 lw    $t6, 0x8038bd80 # lui $t6, 0x8039/lw $t6, -0x4280($t6)
 lui   $at, 0x8039
 addiu $t7, $t6, 0x10
 sw    $t7, %lo(0x8038BD80)($at) # $t7, -0x4280($at)
 jr    $ra
 nop  
(This post was last modified: 09-04-2016, 04:52 AM by David.)

I've got some updates to 4 more commands: 0x02, 0x00, 0x10, and 0x19.

Geo Layout CMD 0x02: Branch/Jump to segmented address

02 [AA] 00 00 [SS SS SS SS]

[AA]​ decides if the command is a branch or a jump.
[SS SS SS SS]​ = Segmented address to go to

If AA is 1, then the return address will be stored for the 0x03 command to use.
If AA is not 1, then the return address will not be stored.

Basically:
02 01 00 00 [SS SS SS SS] = Branch to segmented address
02 00 00 00 [SS SS SS SS] = Jump to segmented address

Geo Layout CMD 0x00 (unused?): Branches to segmented address and stores 2 return address. You should probably just use the 0x02 command for regular branching.

00 00 00 00 [SS SS SS SS]

/* Geo Layout 0x00 Rough translation. */
// 0x8038bd80 = Pointer to current Geo layout command
// 0x8038BCB8 = Pointer to array/table to where branch return pointers are stored.
// 0x8038bd7a = Branch depth value.
{
0x8038BCB8 + (0x8038bd7a * 4) = 0x8038bd80 + 8; // Stores the pointer to the next geo cmd after this one.
0x8038bd7a++; // Increment branch value

0x8038BCB8 + (0x8038bd7a * 4) = (0x8038bd78 << 16) + 0x8038bd7e; // Store another address
0x8038bd7a++; // Increment branch value
0x8038BD7E = 0x8038bd7a;

0x8038BD80 = SegmentedToVirtual(0x8038bd80 + 4); // Go to the segmented address.
return;
}

Geo Layout CMD 0x10: Applies translation & rotation to the following node.

10 [AA] [BB BB] [XX XX] [YY YY] [ZZ ZZ] [XR XR] [YR YR] [ZR ZR]

[ 10 00 00 00 00 8E FF CD FF 82 00 16 FF D8 FF 79 ]​ # a 0x10 cmd used in Mario's Geo Layout

The ASM code of this command branches based on the first digit of the AA byte, but the game crashes if I try to use something other than 0x00. BB seems to be used in the code when AA != 0x00.

XX = (s16) X translation offset
YY = (s16) Y translation offset
ZZ = (s16) Z translation offset
XR = (s16) X rotation offset
YR = (s16) Y rotation offset
ZR = (s16) Z rotation offset

Geo Layout CMD 0x19: Set background image or color.

19 00 [TT TT] [AA AA AA AA]

TT = RGBA5551 background color if AA == 0x00.
otherwise, TT = background ID number? (0 to 9)

AA = ASM function to set the background image, always 0x802763D4

[ 19 00 00 00 80 27 63 D4 ]​ # Bob-Omb's Battlefield
[ 19 00 00 01 80 27 63 D4 ]​ # Lethal Lava Land
[ 19 00 00 02 80 27 63 D4 ]​ # Wet Dry World
[ 19 00 00 03 80 27 63 D4 ]​ # Rainbow Ride
[ 19 00 00 04 80 27 63 D4 ]​ # Cool Cool Mountain
[ 19 00 00 05 80 27 63 D4 ]​ # Shifting Sand Land
[ 19 00 00 06 80 27 63 D4 ]​ # Big Boo's Haunt
[ 19 00 00 07 80 27 63 D4 ]​ # Bowser 1 Course
[ 19 00 00 08 80 27 63 D4 ]​ # Jolly Roger Bay
[ 19 00 00 09 80 27 63 D4 ]​ # Bowser 3 Course
[ 19 00 00 01 00 00 00 00 ]​ # Secret Slide, pure black background.
(This post was last modified: 10-04-2016, 08:37 PM by David.)

(10-04-2016, 08:28 PM)David Wrote: I've got some updates to 4 more commands: 0x02, 0x00, 0x10, and 0x19.


Thanks David. I have updated the Geo Layout wiki page with your new findings. I have a couple comments about some of them below.

(10-04-2016, 08:28 PM)David Wrote:
Geo Layout CMD 0x02: Branch/Jump to segmented address

02 [AA] 00 00 [SS SS SS SS]

[AA]​ decides if the command is a branch or a jump.


For 0x02, I would recommend different terminology than 'branch' and 'jump' because they effectively mean the same thing (although branch generally being relative and jump absolute). I'd recommend 'jump' and 'jump and link' since they are absolute addresses and one variant saves the return address.

(10-04-2016, 08:28 PM)David Wrote:
Geo Layout CMD 0x10: Applies translation & rotation to the following node.

10 [AA] [BB BB] [XX XX] [YY YY] [ZZ ZZ] [XR XR] [YR YR] [ZR ZR]

[ 10 00 00 00 00 8E FF CD FF 82 00 16 FF D8 FF 79 ]​ # a 0x10 cmd used in Mario's Geo Layout

The ASM code of this command branches based on the first digit of the AA byte, but the game crashes if I try to use something other than 0x00. BB seems to be used in the code when AA != 0x00.


I am still trying to figure out what is going with AA in command 10. It looks like the code first masks bits 5-7 (0x70) and compares those bits with 4 different AA cases (0, 1, 2, 3) to determine how the following data is handled.
AA = 0 reads X,Y,Z as s16 and RX,RY,RZ by: (val << 15) / 180
AA = 1 reads X,Y,Z as s16 and RX,RY,RZ as s16 (although using different function)
AA = 2 reads X,Y,Z by: (val << 15) / 180 and RX,RY,RZ as s16
AA = 3 does something different, reading X,Y,Z as s16, then (val << 15) / 180 for one of the values?

I'm still unclear on what the remaining bits in AA do. I see some geo layout 0x10 commands for some enemies have the upper and lower bits (0x81) of AA set.

(10-04-2016, 08:28 PM)David Wrote:
Geo Layout CMD 0x19: Set background image or color.

19 00 [TT TT] [AA AA AA AA]

TT = RGBA5551 background color if AA == 0x00.
otherwise, TT = background ID number? (0 to 9)


This is great info! I have some ideas that I want to try with this, but for now just testing out a nice '19 00 F529 00000000' on castle grounds:
[Image: TIe0pYI.png]
(This post was last modified: 23-06-2017, 08:06 PM by queueRAM. Edit Reason: wiki links )

(11-04-2016, 09:09 PM)queueRAM Wrote:
(10-04-2016, 08:28 PM)David Wrote:
Geo Layout CMD 0x19: Set background image or color.

19 00 [TT TT] [AA AA AA AA]

TT = RGBA5551 background color if AA == 0x00.
otherwise, TT = background ID number? (0 to 9)


This is great info! I have some ideas that I want to try with this, but for now just testing out a nice '19 00 F529 00000000' on castle grounds:
[Image: TIe0pYI.png]


What's interesting to me is that you can change the RGBA5551 color dynamically in-game.

[AA AA AA AA]​ is stored at: (value at 0x8038BCA4) + 0xD4
[TT TT]​ value is stored at: (value at 0x8038BCA4) + 0xDE
A copy of [TT TT] is stored at: (value at 0x8038BCA4) + 0xDC

Someone can write some custom ASM code to make the background fade into different colors, so there is potential to make a real-time day/night cycle that doesn't make a huge impact on performance. Of course you would need to put something in the background to make it look more a little bit more interesting.

0x8033B910 contains a pointer to a struct(or is it an array of stucts?) with some settings created from the geo layout commands. Like the values from the 0x08 cmd (set screen render area) are also stored there and can also be changed on the fly.

(value at 0x8033B910) + 0x16 = screen X position
(value at 0x8033B910) + 0x18 = screen Y position
(value at 0x8033B910) + 0x1A = screen width
(value at 0x8033B910) + 0x1C = screen height

Some of the functions defined by n64split seem to refer it as a "SceneGraphNode". Do you have any more information on that?

Edit:

Turns out that 0x8033B910 is a more consistent pointer than 0x8038BCA4, so we should probably use that instead. 

Also wrote some custom ASM code that will change the background color in the current level. Each color value has 5 bits, so it can only go up to 0x1F (31). If anyone wants to play around with it to see how it works heres a link to the sourse: http://pastebin.com/raw/xBbgLpv0

[Image: HgImddu.png]
(This post was last modified: 16-04-2016, 03:48 PM by David.)

I've been doing some investigating in the past couple days, and got some new information on the geometry layout commands 0x0C & 0x0D. The wiki has been updated with this info.

Geo Layout CMD 0x0C: Enable/Disable Z-Buffer

0C [AA] 00 00

AA = 0x00 to disable Z-buffer, 0x01 to enable Z-buffer

This command is used in level geometry layouts. Z-Buffering is disabled when rendering the skybox, and re-enabled when rendering level geometry.

​[ 0C 01 00 00 ] will wrap the following Fast3D data around the node:

E7 00 00 00 00 00 00 00
B7 00 00 00 00 00 00 01
// Node's Fast3D commands
E7 00 00 00 00 00 00 00
B6 00 00 00 00 00 00 01

Geo Layout CMD 0x0D: Set Render Range

Used in WF, CCM, TTM, SSL levels and some geo layouts. This command will make the following node only render in a certain distance range away from the camera.

0D 00 00 00 [AA AA] [BB BB]

AAAA = (s16) Minimum distance value
BBBB = (s16) Maximum distance value

Example from “Grassy Level Part” in Whomp's fortress:

0049E3A8 / 0E000958 [ 20 00 07 D0 ]
0049E3AC / 0E00095C [ 04 00 00 00 ]
0049E3B0 / 0E000960    [ 0D 00 00 00 F8 30 1F 40 ]
0049E3B8 / 0E000968    [ 04 00 00 00 ]
0049E3BC / 0E00096C       [ 15 01 00 00 07 00 AB A0 ] // Real geometry (Camera is nearby)
0049E3C4 / 0E000974       [ 15 06 00 00 07 00 AF B8 ]
0049E3CC / 0E00097C    [ 05 00 00 00 ]
0049E3D0 / 0E000980    [ 0D 00 00 00 1F 40 4E 20 ]
0049E3D8 / 0E000988    [ 04 00 00 00 ]
0049E3DC / 0E00098C       [ 15 01 00 00 07 00 AE C8 ] // Fake geometry (Camera is far away)
0049E3E4 / 0E000994    [ 05 00 00 00 ]
0049E3E8 / 0E000998 [ 05 00 00 00 ]
0049E3EC / 0E00099C [ 01 00 00 00 ]

[Image: LYqgK7f.png][Image: MsnjZFB.png]
(This post was last modified: 18-12-2016, 06:58 AM by David.)

Good work David! A better understanding of script commands will make me able to render better levels and objects within my tool.
Thanks for your scientific research Smile

Geometry Layout Commands « 1 2
Users browsing this thread: 1 Guest(s)