Bart wrote:Hey Ian, I saved you some work and figured out the polygon header bits from the API header filesWe were right all along about many of them, including specular. A few are clearly not used in Model 3, such as the extra texture Y address bits (Pro-1000 supported more texture RAM). And translucency is a bit different. Looks like you nailed fixed shading and smooth shading,though!
Give this bad boy a spin:
- Code: Select all
/*
* Real3D Pro-1000 polygon header definition
*/
#include <cstdio>
#include <cstring>
#include <cstdint>
class PRO_MCW1
{
public:
// header[5]:7-0
unsigned long _y_memory_map_start : 7 ; // 6-0
unsigned long _x_memory_map_start_bit_0 : 1 ; // 7
// header[4]:7-0
unsigned long _x_memory_map_start_bits_6_1 : 6 ; // 5-0
unsigned long _even_bank_select : 1 ; // 6
unsigned long _translator_map_select : 1 ; // 7
// header[3]:7-0
unsigned long _map_size_y : 3 ; // 2-0
unsigned long _map_size_x : 3 ; // 5-3
unsigned long _y_wrap_smoothing : 1 ; // 6
unsigned long _x_wrap_smoothing : 1 ; // 7
// header[2]:7-0
unsigned long _y_mirror : 1 ; // 0
unsigned long _x_mirror : 1 ; // 1
unsigned long _microtexture_min_lod : 2 ; // 3-2
unsigned long _microtexture_enable : 1 ; // 4
unsigned long _microtexture_map_select : 3 ; // 7-5
} ;
class PRO_MCW2
{
public :
// header[6]
unsigned long _translucency_mode : 3 ; // 2-0
unsigned long _layered_polygon : 1 ; // 3
unsigned long _high_priority : 1 ; // 4
unsigned long _shininess : 2 ; // 6-5
unsigned long _texture_mode : 3 ; // 9-7
unsigned long _enable_texture_modulation : 1 ; // 10
unsigned long _light_modifier : 5 ; // 15-11
unsigned long _luminous_feature : 1 ; // 16
unsigned long _translucency_pattern_select : 1 ; // 17
unsigned long _polygon_translucency : 6 ; // 23-18
unsigned long _translator_map_offset : 7 ; // 30-24
unsigned long _contour_texture_enable : 1 ; // 31
} ;
class PRO_HW_Polygon
{
public:
// header[0]
unsigned long _use_prev_vert0 : 1 ; // 0
unsigned long _use_prev_vert1 : 1 ; // 1
unsigned long _use_prev_vert2 : 1 ; // 2
unsigned long _use_prev_vert3 : 1 ; // 3
unsigned long _smoothing : 1 ; // 4
unsigned long _polygon_is_points : 1 ; // 5
unsigned long _vertex_count : 1 ; // 6
unsigned long _enable_specular : 1 ; // 7
unsigned long _discard_2 : 1 ; // 8
unsigned long _discard_1 : 1 ; // 9
unsigned long _node_id : 15 ; // 24-10
unsigned long _clockwise_data : 1 ; // 25
unsigned long _specular : 6 ; // 31-26
// header[1]
unsigned long _no_los_return : 1 ; // 0
unsigned long _actual_color : 1 ; // 1
unsigned long _last_polygon : 1 ; // 2
unsigned long _smooth_shading : 1 ; // 3
unsigned long _double_sided : 1 ; // 4
unsigned long _fixed_shading : 1 ; // 5
unsigned long _texture_address_scale : 1 ; // 6
unsigned long _edge_on_translucency : 1 ; // 7
unsigned long _normal_x : 24 ; // 31-8
// header[2]
unsigned long _mcw1_bits_24_31 : 8 ; // 7-0
unsigned long _normal_y : 24 ; // 31-8
// header[3]
unsigned long _mcw1_bits_16_23 : 8 ; // 7-0
unsigned long _normal_z : 24 ; // 31-8
// header[4]
unsigned long _mcw1_bits_8_15 : 8 ; // 7-0
unsigned long _color : 24 ; // 31-8
// header[5]
unsigned long _mcw1_bits_0_7 : 8 ; // 7-0
unsigned long _texture_np : 24 ; // 31-8
// header[6]
PRO_MCW2 _mcw2 ;
};
static_assert(sizeof(PRO_HW_Polygon) == 7*4, "Polygon header is not 7 words long");
int main()
{
PRO_HW_Polygon p;
memset(&p, 0, sizeof(p));
// Test out some bits!
p._enable_specular = 1;
p._fixed_shading = 1;
p._contour_texture_enable = 1;
// Print them out as they would appear on Model 3
uint32_t *data = reinterpret_cast<uint32_t *>(&p);
for (int i = 0; i < 7; i++)
printf("%d: %08x\n", i, data[i]);
return 0;
}
If this is correct, our transparency bit is wrong ?
