Difference between revisions of "Sort List Crash 2/3"
m (6 revisions imported: Initial import from Wikia) |
m (→Polygon ID) |
||
(One intermediate revision by the same user not shown) | |||
Line 27: | Line 27: | ||
Each Polygon ID has the following format: | Each Polygon ID has the following format: | ||
− | <code> | + | <code>WWWSSPPP PPPPPPPP</code> |
* W = index of world model | * W = index of world model | ||
* S = state of the polygon | * S = state of the polygon | ||
Line 34: | Line 34: | ||
The polygon state also specifies whether to fully draw the quad or only half of it. A quad can be conceived as a combination of two triangles (ABC and CDA respectively) into a single polygon (ABCD). When only triangle ABC needs to be drawn, SS=1. Should only triangle CDA be drawn, SS=2. Finally, if the entire quad needs to be drawn, SS=3. | The polygon state also specifies whether to fully draw the quad or only half of it. A quad can be conceived as a combination of two triangles (ABC and CDA respectively) into a single polygon (ABCD). When only triangle ABC needs to be drawn, SS=1. Should only triangle CDA be drawn, SS=2. Finally, if the entire quad needs to be drawn, SS=3. | ||
+ | |||
=== Item 2 to N-1: Difference List === | === Item 2 to N-1: Difference List === | ||
{| class="article-table" | {| class="article-table" |
Latest revision as of 20:17, 1 November 2019
Contents
Introduction
The sort lists in Crash 2/3 are for the most part similar to the ones found in Crash 1. Therefore it is recommended to read the extensive article about Sort Lists in Crash 1 first before reading this article.
Format
Item 1/Item N: Main Source/Target List
Offset | Field | Size | Value |
---|---|---|---|
0x0 | List Size (polygon ID count) | 2 bytes | c |
0x2 | List Type | 2 bytes | 0 |
0x4 | Polygon IDs | c x 2 bytes | * |
Polygon ID
Each Polygon ID has the following format:
WWWSSPPP PPPPPPPP
- W = index of world model
- S = state of the polygon
- P = index of polygon in world model
Since scenery entries in Crash 2/3 have lists for both triangles and quads, the polygon state is used to differentiate between an index for a triangle (SS = 0) and a quad (SS = 1-3).
The polygon state also specifies whether to fully draw the quad or only half of it. A quad can be conceived as a combination of two triangles (ABC and CDA respectively) into a single polygon (ABCD). When only triangle ABC needs to be drawn, SS=1. Should only triangle CDA be drawn, SS=2. Finally, if the entire quad needs to be drawn, SS=3.
Item 2 to N-1: Difference List
Offset | Field | Size | Value |
---|---|---|---|
0x0 | List Size minus 2 (in hwords) | 2 bytes | c + 2 |
0x2 | List Type | 2 bytes | 1 |
0x4 | Rel. Index of end of removing nodes minus 2Rel. Index of start of adding nodes minus 2 | 2 bytes | a + 2 |
0x6 | Rel. Index of end of adding nodes minus 2Rel. Index of start of swapping nodes minus 2 | 2 bytes | r + 2 |
Nodes/List | |||
0x8 | Removing Nodes | (a - 2) x 2 bytes | * |
0x8 + ((a - 2) x 2) | Adding Nodes | (r-a-2) x 2 bytes | * |
0x8 + ((r - 2) x 2) | Swapping Nodes | (c-r-a-2) x 2 bytes | * |
Adding/Removing Nodes
Adding and Removing nodes have the same format:
CCCCNNNN NNNNNNNN (WWWSSPPP PPPPPPPP x (C+1))
C
= add/skip count (this node contains C+1 polygon IDs, number of polygon IDs to add/skip)N
= add/skip index (the polygon IDs from this node will be added to the new list in a progression, or skipped and not added in a retrogression)- WSP = polygon ID(s) to add when inserting; other than in Crash 1 these polygon IDs in are the same as in the Source/Target lists since the copyflag functionality is abandoned in Crash 2/3.
Swapping Nodes
Format A: 1BBBBAAA AAAAAAAA [01CCCCCC CCCDDDDD]
Format B: 0000AAAA AAAAAAAA 0000BBBB BBBBBBBB [01CCCCCC CCCDDDDD]
A
= index of Polygon ID AB
= index of Polygon ID B relative to A + 1C
= index of Polygon ID C relative to AD
= index of Polygon ID D relative to C + 17
Besides these swapping node formats familiair from Crash 1, there is another type of 'swapping node' in Crash 2/3 that accounts for the swapping of polygon states. They always come after the formats A - D, at the end of the difference list. The swapping is really a XOR-operation on the SS-value of the polygon ID that it refers to.
Format E: 001XXPPP PPPPPPPP
- X = XOR mask; the new polygon ID
WWW**PPP PPPPPPPP
=WWW00PPP PPPPPPPP + ((SS^XX) << 11)
- P = Targeted polygon index