Files
TeslaRel410/sda4/DPL3/VRENDER/PXPL5SUP/PXPL5TST.C
T
CydandClaude Fable 5 db7745fcd0 sda4: commit the Glaze developer hard-drive dump
Un-ignored: the dev drive is the ground truth the restoration and
emulator work constantly reference (DPL3/LIBDPL + VRENDER i860 renderer
source, BT/RP live+dev game trees, VGL_LABS pod boot, scene/audio
content). Kept in-repo for the pod-owner community.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 19:41:15 -05:00

205 lines
5.7 KiB
C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "..\..\unc\igc\igc_opcd.h"
#include "divpxmap.h"
/*{{{ includes*/
#include "DMAengn.h"
#include "pxpl5sup.h"
#include "pxpl5tri.h"
/*}}} */
/*{{{ extern fns*/
extern float second_(void);
extern void binitize_8(void);
extern void preplane_4( float *, void *, float *, float *, float *, float *);
extern void tex_fixz ( float *z1, float *z2, float *z3 );
extern float tex_scalefac ( float z1, float z2, float z3 );
extern int getFsr (void);
extern void setFsr(int fsr );
/*}}} */
/*{{{ typedefs for new PMESH types*/
typedef struct s_vert {
float position [4];
float xformpos [4];
float texcoords[2];
float normal [3];
float colour [3];
} MESH_VERTEX;
/*}}} */
/*{{{ static void set_vertex ( int index,*/
static void set_vertex ( int index,
MESH_VERTEX *vertices,
float x, float y, float z,
float diff, float spec, float u, float v )
{
vertices[index].position[0]=x;
vertices[index].position[1]=y;
vertices[index].position[2]=z;
vertices[index].xformpos[0]=x;
vertices[index].xformpos[1]=y;
vertices[index].xformpos[2]=z;
vertices[index].xformpos[3]=1.0;
vertices[index].texcoords[0]=u;
vertices[index].texcoords[1]=v;
vertices[index].colour[0]=diff;
vertices[index].colour[1]=spec;
}
/*}}} */
int main(int argc, char **argv )
{
/*{{{ declare locals*/
int i, j, benny=0, truncy[4];
float then, now, a, b, c;
preplane prep;
MESH_VERTEX *vertices, *vert0, *vert1, *vert2, *vert3, *vert4, *vert5;
float *eqn;
int *ieqn;
float materials[4];
/*}}} */
/*{{{ disable floating-point traps*/
setFsr ( 1 | getFsr ());
/*}}} */
/*{{{ allocate and initialize memory*/
eqn=(float *) malloc(1024*sizeof(float));
ieqn=(int *) eqn;
vertices=(MESH_VERTEX *) malloc ( 128 * sizeof(MESH_VERTEX));
printf ("pxpl5tst is go\n" );
set_vertex ( 45, vertices, 32.0f, 32.0f, 122.0f,
1.4f, 1.31f, 0.0f, 1.0f );
set_vertex ( 63, vertices, 42.0f, 22.0f, 38.0f,
2.1f, -2.04f, 1.0f, 1.0f );
set_vertex ( 123, vertices, 12.0f, 62.0f, 822.0f,
3.43f, 1.53f, 0.0f, 0.0f );
set_vertex ( 15, vertices, 132.0f, 132.0f, 622.0f,
1.4f, 3.31f, 0.0f, 0.0f );
set_vertex ( 23, vertices, 142.0f, 150.0f, 138.0f,
2.1f, 1.04f, 0.0f, 1.0f );
set_vertex ( 81, vertices, 152.0f, 162.0f, 222.0f,
3.43f, -1.53f, 1.0f, 1.0f );
vert0=&vertices[ 45];
vert1=&vertices[ 63];
vert2=&vertices[123];
vert3=&vertices[ 15];
vert4=&vertices[ 23];
vert5=&vertices[ 81];
printf ("vertices 0x%x vert0 0x%x vert1 0x%x vert2 0x%x\n",
(int) vertices, (int) vert0, (int) vert1, (int) vert2 );
grab_binchunks ( 400 );
create_screenbins ( 1024, 512 );
for (i=0; i<256; i++) eqn[i]=0.0f;
materials[0]=1.0;
materials[1]=1.0;
materials[2]=1.0;
materials[3]=1.0;
/*}}} */
/*{{{ printf some pxpl5 instructions in hex*/
{
int a, b, c, d, e, f, g, h, i, j, k;
a = Ix_SETENABS();
b = Ix_CLRENABS();
c = Ix_TREEltZERO_L3();
d = Ix_TREEgeZERO_L3();
e = Ix_MEMltTREE_L3(dvpx_zbuf,dvpx_zbufbits);
f = Ix_TREEintoMEM_L0(dvpx_zbuf,dvpx_zbufbits);
g = Ix_TREEintoMEM_L3(dvpx_diffuse, dvpx_diffusebits );
h = Ix_TREEintoMEM_L3(dvpx_specular, dvpx_specularbits );
i = Ix_TREEintoMEM_L3(dvpx_texu, dvpx_texubits );
j = Ix_TREEintoMEM_L3(dvpx_texv, dvpx_texvbits );
k = Ix_TREEintoMEM_L3(dvpx_texz, dvpx_texzbits );
printf ( "SETENABS 0x%8x CLRENABS 0x%8x\n", a, b );
printf ( "TREEltZERO_L3 0x%8x TREEgeZERO_L3 0x%8x\n", c, d );
printf ( "MEMltTREE_l3 0x%8x TREEintoMEM_L0(zbuf) 0x%8x\n", e, f );
printf ( "TREEintoMEM_L3(diff) 0x%8x TREEintoMEM_L3(spec) 0x%8x\n", g, h );
printf ( "TREEintoMEM_L3(texu) 0x%8x TREEintoMEM_L3(texv) 0x%8x\n", i, j );
printf ( "TREEintoMEM_L3(texz) 0x%8x\n", k );
}
/*}}} */
/*{{{ time triangle performance*/
then=second_();
for (j=2000; j; j-- ) {
float *coeffs=&eqn[0];
coeffs=tri_zb_d_s_tex ( coeffs, materials[0], 0x87654321, (float *)vert3,(float *)vert4,(float *)vert5,
0 );
coeffs=tri_zb_d_s_tex ( coeffs, materials[1], 0x89ab1234, (float *)vert0,(float *)vert1,(float *)vert2,
0 );
coeffs=tri_zb_d_s_tex ( coeffs, materials[2], 0x87654321, (float *)vert3,(float *)vert4,(float *)vert5,
0 );
coeffs=tri_zb_d_s_tex ( coeffs, materials[3], 0x89ab1234, (float *)vert0,(float *)vert1,(float *)vert2,
0 );
benny+=4;
}
now =second_();
printf ("Gosh golly gee - %d triangles pxpl5ized in %f ticks (%f per sec)\n",
benny, now - then, (float) benny / (now - then));
/*}}} */
/*{{{ debug results*/
printf ( "Dump of equation memory 0x%x\n", (int) &eqn[0] );
for (i=0; i<70; i++ ) {
printf ( "(0x%8x) memory[%d] - 0x%8x (%f)\n", (int) (&ieqn[i]), i, ieqn[i], eqn[i] );
}
/*}}} */
/*{{{ test texture scaling thing*/
{
int ii;
float mult, z1, z2, z3;
z1=0.0234;
z2=0.00134;
z3=0.03516;
for (ii=0; ii<4; ii++ ) {
mult = tex_scalefac ( z1, z2, z3 );
tex_fixz ( &z1, &z2, &z3 );
printf ( "tex_scalefac returned %f (0x%x)\n", mult, *(int *) &mult );
z1*=0.6412;
z2*=0.8412;
z3*=0.4412;
}
}
/*}}} */
/* dump_bins ( screenbins, 10, 4 ); */
}