Files
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

275 lines
5.6 KiB
C++

/*
FILE : testpp5.c
PROJECT : pxpl5 renderer test
Author : Phil Atkin
(C) Division Ltd 1993.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <math.h>
#include "dpl5.h"
#include "boot.h"
#include "startup.h"
char *progname;
int860 link_A, link_B;
extern int860 __acks_per_frame;
extern int magicLeftVal,
magicRightVal;
/*{{{ void eyeStuff ( VIEW *view )*/
void eyeStuff ( VIEW *view, int left )
{
float scale=1.0;
PAZidMatrix(view->f);
PAZidMatrix(view->b);
if (left) scale *= -1.0f;
PAZtranslatePair (view->f, view->b, scale*1.275, 0, 0 );
PAZrotatePair (view->f, view->b, 180, PAZ_Y );
PAZtranslatePair (view->f, view->b, 0, 0, -48 );
if (left == (-1)) view->shift_x=0.0;
else if (left) view->shift_x=0.2147;
else view->shift_x=-0.2147;
/* view->shift_y = 0.0f; */
PAZwriteView ( view );
}
/*}}} */
/*{{{ void spinning_jenny ( INSTANCE *inst, VIEW *view, char *scale_str )*/
void spinning_jenny ( INSTANCE *inst, VIEW *eye, VIEW *rye, char *scale_str, int base, int times )
{
float theta, scale_fac=0.1;
int i;
float then, now;
if (rye == NULL)
eyeStuff ( eye, -1 );
else {
eyeStuff ( eye, 0 );
eyeStuff ( rye, 1 );
}
sscanf(scale_str, "%f", &scale_fac );
printf ("spinning jenny, scale factor %f\n", scale_fac );
for (i=base; i<times; i++) {
int nulls=0;
theta = (i+40)*0.43;
PAZidMatrix(inst->f);
PAZscale (inst->f, scale_fac, scale_fac, scale_fac, 1 );
PAZrotate (inst->f, theta*2.4, PAZ_X, 1 );
PAZrotate (inst->f, theta*1.3, PAZ_Z, 1 );
PAZrotate (inst->f, theta/2.5, PAZ_Y, 1 );
PAZwriteMatrix ( inst );
PAZrenderScene ();
}
}
/*}}} */
/*{{{ char *makeVizName ( char *name )*/
char vizStr [256];
char *makeVizName ( char *name )
{
char *root;
if ((root=getenv("VIZPATH")) == NULL)
return(name);
else {
strcpy ( vizStr, root );
strcat ( vizStr, name );
return ( vizStr );
}
}
/*}}} */
/*{{{ char *makeTexName ( char *name )*/
char texStr [256];
char *makeTexName ( char *name )
{
char *root;
if ((root=getenv("TEXTURE")) == NULL)
return(name);
else {
strcpy ( vizStr, root );
strcat ( vizStr, name );
return ( vizStr );
}
}
/*}}} */
/*{{{ char *makedplName ( char *name )*/
char *makedplName ( char *dplstr, char *name )
{
char *root;
if ((root=getenv("DVIEWBIN")) == NULL)
return(name);
else {
strcpy ( dplstr, root );
strcat ( dplstr, name );
return ( dplstr );
}
}
/*}}} */
/*{{{ int env2hex ()*/
int env2hex ( char *env_str, int default_v )
{
char *s;
int v;
if (s = getenv(env_str)) {
if (sscanf(s, "%x", &v) == 1) {
return v;
}
}
printf ("Defaulting on %s to 0x%x\n", env_str, default_v );
return default_v;
}
/*}}} */
/*{{{ int nain ( int argc, char *argv[])*/
int nain ( int argc, char *argv[])
{
LIGHTSOURCE *bulb1, *bulb2, *bulb3, *bulb4, *bulb5, *bulb6;
INSTANCE *inst, *kiddy, *kiddy2;
OBJECT *obj;
SCENE *s;
VIEW *eye, *rye;
float t;
char *objname;
int i, made, ramp;
MATERIAL *mtl;
TEXTURE *tex;
s = initialize_all ( 0, -1, &eye, &rye );
printf ( "PAZcreateInstance\n" );
inst = PAZcreateInstance ();
printf ("returned 0x%x\n", inst );
obj=PAZcreateObject ( makeVizName(argv[2]), makeTexName );
inst->obj=obj;
PAZidMatrixPair ( inst->f, inst->b );
inst->enable=1;
PAZwriteInstance ( inst );
printf ( "PAZcreateMaterial\n" );
mtl=PAZcreateMaterial();
{
mtl->kd[0]=0.99;
mtl->kd[1]=0.99;
mtl->kd[2]=0.99;
mtl->ks =0.7;
mtl->power=7.3;
mtl->opacity=1.0f;
mtl->tex=tex;
mtl->ramp_entry=0;
strcpy ( mtl->texture_name, "default" );
strcpy ( mtl->material_name, "viz_0001" );
}
PAZwriteMaterial(mtl);
printf ("returned 0x%x\n", mtl );
/* create 3 light bulbs */
/*
*/
bulb1=PAZcreateLight ();
PAZinitLight ( bulb1, 0, 0.9, 0.2, 0.9, 1, 0, 0 );
PAZwriteLight ( bulb1 );
bulb3=PAZcreateLight ();
PAZinitLight ( bulb3, 0, 0.2, 0.9, 0.9, -1, 0, 0 );
PAZwriteLight ( bulb3 );
bulb2=PAZcreateLight ();
PAZinitLight ( bulb2, 2, 0.4, 0.4, 0.4, -0.577, 0.577, -0.577 );
PAZwriteLight ( bulb2 );
PAZsetBackGND ( 0.5, 0.3, 0.2 );
PAZfog ( 1, 200.0, 4000.0, 0.4f, 0.3f, 0.1f );
while (1) {
inst->f_material=mtl->name;
PAZwriteInstance ( inst );
spinning_jenny ( inst, eye, rye, argv[1], 0, 1000 );
inst->f_material=NULL;
PAZwriteInstance ( inst );
spinning_jenny ( inst, eye, rye, argv[1], 0, 1000 );
}
}
/*}}} */
/*{{{ int main ( int argc, char *argv[] )*/
int main ( int argc, char *argv[] )
{
link_A= 1;
link_B=-1;
progname=argv[0];
if (argc < 3) {
printf ("usage %s: <scale> <v2zfile>\n", argv[0] );
exit(666);
}
else {
char dplStr1 [256];
char dplStr2 [256];
magicLeftVal =env2hex("LEFTMAGIC", 0x3281);
magicRightVal=env2hex("RIGHTMAGIC", 0x3281);
if (magicLeftVal & 0x8) {
x_size=1024;
y_size=768;
}
else if (magicLeftVal & 0x10) {
x_size=640;
y_size=480;
}
else if (magicLeftVal & 0x20) {
x_size=832;
y_size=512;
}
start_dView ( makedplName ( dplStr1, "dv_skip.btl"),
NULL,
makedplName ( dplStr2, "pazpl5.mng"),
env2hex("TRANSPUTER", 0x200), 1, -1 );
nain ( argc, argv );
}
}
/*}}} */