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>
104 lines
2.8 KiB
C++
104 lines
2.8 KiB
C++
/*
|
|
This code relies on the hand-assembly coded edgize, preplanarize,
|
|
planarize and binitize functions.
|
|
|
|
Preplanarize is called first - this caches the edgizing and planarizing
|
|
repeated expressions into registers, and computes screen-space minimax
|
|
x and y coordinates -
|
|
|
|
rminx
|
|
rminy
|
|
rmaxx
|
|
rmaxy
|
|
rx23 \
|
|
rx31 > the recurring differences
|
|
rx12 /
|
|
rC the divisor for preplanarizing
|
|
rv1y
|
|
rv2y
|
|
rv3y
|
|
rv4y for quads
|
|
rv1x
|
|
rv2x
|
|
rv3x
|
|
and rv4x for quads
|
|
|
|
Total 16 fp regs
|
|
|
|
To ease planarizing and z-buffering, we will keep vertex pointers in
|
|
registers throughout -
|
|
|
|
rv1
|
|
rv2
|
|
rv3
|
|
rv4
|
|
|
|
Total 4 int regs
|
|
|
|
A subsequent call to edgeize_triangle edgizes the three edges
|
|
correctly, in order, and will guarantee no DDA cracks. A similar edgize_quad
|
|
needs implementing (so I need to reserve rvx4 and rvy4)
|
|
After edgizing we proceed to planarize - this is done by chained calls to
|
|
planarize_fn, passing in 3 fp registers which hold the v1 v2 v3 values to
|
|
be planarized, and a pointer register to where A B C should be stored.
|
|
|
|
Then binitize_fn is called, which uses the pre-computed minimax values to
|
|
drop the macro value, coefficient start address and coefficient count into
|
|
screen-bins.
|
|
|
|
So, in general, a triangle drawing function will call
|
|
|
|
preplanarize_fn ( float *coeffs, VERTEX *a, VERTEX *b, VERTEX *c, VERTEX *d )
|
|
edgize_tri_fn ( void )
|
|
zbuffer_fn ( void )
|
|
planarize_fn ( int opcode, ) many times
|
|
binitize_fn () to close
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "pxpl5asm.h"
|
|
|
|
float *tri_zb_d_s ( float *coeffs, float *v1, float *v2, float *v3 )
|
|
{
|
|
/* z-buffered, diffuse-lit, specular lit triangle */
|
|
float *t=coeffs;
|
|
|
|
preplanarize_fn ( coeffs, 0, v1, v2, v3, NULL );
|
|
|
|
edgize_tri_fn ();
|
|
zbuffer_fn ();
|
|
|
|
planarize_fn ( 0x666, 3 );
|
|
planarize_fn ( 0x666, 4 );
|
|
|
|
return safe_binitize_fn ( 0x666, 4, 10 );
|
|
}
|
|
|
|
float *tri_zb_d_s_tex ( float *coeffs, float *v1, float *v2, float *v3 )
|
|
{
|
|
/* z-buffered, diffuse-lit, specular lit, textured triangle */
|
|
float *t=coeffs;
|
|
|
|
preplanarize_fn ( coeffs, 0, v1, v2, v3, NULL );
|
|
|
|
edgize_tri_fn ();
|
|
zbuffer_fn ();
|
|
|
|
planarize_fn ( 0x666, 3 ); /* diff */
|
|
planarize_fn ( 0x666, 4 ); /* spec */
|
|
planarize_fn ( 0x666, 5 ); /* u */
|
|
planarize_fn ( 0x666, 6 ); /* v */
|
|
planarize_fn ( 0x666, 7 ); /* homo */
|
|
|
|
return safe_binitize_fn ( 0x666, 4, 10 );
|
|
}
|
|
|
|
float *tri_zb_d_s_texm ( float *coeffs, float *v1, float *v2, float *v3 )
|
|
{
|
|
/* z-buffered, diffuse-lit, specular lit, textured, mipped triangle */
|
|
return NULL;
|
|
}
|
|
|