Files
TeslaRel410/sda4/DPL3/DPL_HOST.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

1562 lines
33 KiB
C++

#include <stdio.h>
#include <stdlib.h>
#include <dpltypes.h>
#include <dpl.h>
#include <dpl_host.h>
#include <vr_comms.h>
/*{{{ banner*/
/* **************************************************
Copyright DIVISION Limited (c) 1994
All rights reserved
File : dpl_host.c
Project : dpl interface
host / dependent section
Author : PJA
Date : 22/06/94
Function: The host-specific functions for pxpl5 DPL
History : Rev 1.0, 23 / 06 / 1994
**************************** */
/*}}} */
static char last_op[256];
char *__lastop=&last_op[0];
/*{{{ velocirender_create ( dpl_node *n )*/
static void
velocirender_create ( dpl_node *n )
{
int nb;
static int32 name=0;
vr_action action;
if (dpl_WarningLevel > 5)
printf ("remote VelociRender create node 0x%x type 0x%x (%s)\n",
n,
n->type_check,
dpl_TypeToString(n->type_check));
sprintf ( __lastop, "create %s", dpl_TypeToString(n->type_check));
velocirender_transmit ( vr_create_action, &n->type_check, 4, 1 );
velocirender_receive ( &action, &n->remote, &nb );
if (action != vr_create_action) {
printf ("ERROR : unexpected action %d returned in velocirender_create\n",
action );
exit(666);
}
}
/*}}} */
/*{{{ velocirender_delete ( dpl_node *n )*/
static void
velocirender_delete ( dpl_node *n )
{
vr_action action;
int32 nb;
int32 xmit[2];
if (dpl_WarningLevel > 5)
printf ("remote VelociRender delete node 0x%x remote 0x%x\n",
n, n->remote );
sprintf ( __lastop, "delete %s", dpl_TypeToString(n->type_check));
xmit[0]=(int32) n->remote;
xmit[1]=(int32) n->type_check;
velocirender_transmit ( vr_delete_action, xmit, 8, 1 );
velocirender_receive ( &action, &n->remote, &nb );
if (action != vr_delete_action) {
printf ("ERROR : unexpected action %d returned in velocirender_delete\n",
action );
exit(666);
}
}
/*}}} */
/*{{{ velocirender_flush ( dpl_node *n, int size_in_bytes )*/
#define delta (sizeof(dpl_node) - sizeof(dpl_remote_node))
static void
velocirender_flush ( dpl_node *n, int size_in_bytes )
{
char *start=sizeof(dpl_node) + (char *) n;
if (dpl_WarningLevel > 5)
printf ("VelociRender flush on node 0x%x remote %d type %s size %d\n",
n, n->remote,
dpl_TypeToString(n->type_check),
size_in_bytes-delta);
sprintf ( __lastop, "flush %s", dpl_TypeToString(n->type_check));
velocirender_transmit ( vr_flush_action, &n->remote,
size_in_bytes-delta, 1 );
}
/*}}} */
/*{{{ null_create ( dpl_node *n )*/
static void
null_create ( dpl_node *n )
{
static int32 name=0;
n->remote=(void *) (++name);
if (dpl_WarningLevel)
printf ("warning : issuing create on local-only type 0x%x\n", n->type_check );
}
/*}}} */
/*{{{ null_delete ( dpl_node *n )*/
static void
null_delete ( dpl_node *n )
{
if (dpl_WarningLevel)
printf ("warning : issuing delete on local-only type 0x%x\n", n->type_check );
}
/*}}} */
#define typeize(type,node) type *t=(type *) node
#define remotize(local,node) if (((local)=(node))!=NULL) node=((dpl_node *)(node))->remote
#define uncover(n) if (n->hidden) (n->unhide)(n)
/*{{{ zone*/
static void
__dpl_flush_zone ( dpl_node * node)
{
dpl_DCS *root;
dpl_LMODEL *lmodel;
typeize ( dpl_ZONE, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_zone\n");
remotize(root, t->root);
remotize(lmodel,t->lmodel);
velocirender_flush ( node, sizeof(dpl_ZONE ));
t->root=root;
t->lmodel=lmodel;
return;
}
static void
__dpl_hide_zone ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_zone\n");
return;
}
static void
__dpl_unhide_zone ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_zone\n");
return;
}
/*}}} */
/*{{{ dcs*/
static void
__dpl_flush_dcs ( dpl_node * node)
{
dpl_node *n;
typeize ( dpl_DCS, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_dcs\n");
remotize(n, t->node);
velocirender_flush ( node, sizeof(dpl_DCS ));
t->node = n;
return;
}
static void
__dpl_hide_dcs ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_dcs\n");
return;
}
static void
__dpl_unhide_dcs ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_dcs\n");
return;
}
/*}}} */
/*{{{ geometry*/
static void
__dpl_flush_geometry ( dpl_node * node)
{
dpl_GEOGROUP *n;
typeize ( dpl_GEOMETRY, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_geometry\n");
remotize(n, t->parent);
velocirender_flush ( node, sizeof(dpl_GEOMETRY ));
t->parent=n;
sprintf ( __lastop, "flush geometry" );
return;
}
static void
__dpl_hide_geometry ( dpl_node * node)
{
dpl_GEOMETRY *geo=(dpl_GEOMETRY *) node;
if (dpl_WarningLevel > 5)
printf ("hide_geometry\n");
if (node->hidden)
return;
node->hidden=1;
return;
}
static void
__dpl_unhide_geometry ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_geometry\n");
return;
}
/*}}} */
/*{{{ geogroup*/
static void
__dpl_flush_geogroup ( dpl_node * node)
{
dpl_MATERIAL *fm, *bm;
dpl_LOD *n;
typeize ( dpl_GEOGROUP, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_geogroup\n");
remotize(fm, t->f_material);
remotize(bm, t->b_material);
remotize(n, t->parent );
velocirender_flush ( node, sizeof(dpl_GEOGROUP ));
t->f_material=fm;
t->b_material=bm;
t->parent=n;
return;
}
static void
__dpl_hide_geogroup ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_geogroup\n");
return;
}
static void
__dpl_unhide_geogroup ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_geogroup\n");
return;
}
/*}}} */
/*{{{ lod*/
static void
__dpl_flush_lod ( dpl_node * node)
{
dpl_OBJECT *n;
typeize ( dpl_LOD, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_lod\n");
remotize(n, t->parent );
velocirender_flush ( node, sizeof(dpl_LOD ));
t->parent=n;
return;
}
static void
__dpl_hide_lod ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_lod\n");
return;
}
static void
__dpl_unhide_lod ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_lod\n");
return;
}
/*}}} */
/*{{{ object*/
static void
__dpl_flush_object ( dpl_node * node)
{
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_object\n");
velocirender_flush ( node, sizeof(dpl_OBJECT ));
return;
}
static void
__dpl_hide_object ( dpl_node * node)
{
dpl_OBJECT *o=(dpl_OBJECT *) node;
dpl_LOD *lod;
dpl_GEOGROUP *grp;
dpl_GEOMETRY *geo;
dpl_VERTEX_LIST *vl, *prevl;
dpl_CONNECTION_LIST *cl, *precl;
dpl_list *lod_list, *grp_list, *geo_list;
/*
printf ("hide 0x%x\n", o );
fflush(stdout);
*/
if (dpl_WarningLevel > 5)
printf ("hide_object\n");
for ( lod_list=o->lod_list.head; lod_list; lod_list=lod_list->next ) {
lod=(dpl_LOD *) lod_list->item;
/*
printf ("free lod 0x%x\n", lod );
fflush(stdout);
*/
if (lod) for ( grp_list=lod->geogroup_list.head; grp_list; grp_list=grp_list->next ) {
grp=(dpl_GEOGROUP *) grp_list->item;
/*
printf ("free grp 0x%x\n", grp );
fflush(stdout);
*/
if (geo) for ( geo_list=grp->geometry_list.head; geo_list; geo_list=geo_list->next ) {
geo=(dpl_GEOMETRY *) geo_list->item;
/*
printf ("free geo 0x%x\n", geo );
fflush(stdout);
*/
cl=geo->connections;
vl=geo->vertices;
while (vl) {
prevl=vl;
vl=vl->next;
/* printf ("free vlist 0x%x\n", prevl ); */
free(prevl);
}
while (cl) {
precl=cl;
cl=cl->next;
/* printf ("free clist 0x%x\n", precl ); */
free(precl);
}
free(geo);
}
free(grp);
}
free(lod);
}
o->dplnode.hidden=1;
/*
printf ("returning from hide\n");
fflush(stdout);
*/
return;
}
static void
__dpl_unhide_object ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_object\n");
return;
}
/*}}} */
/*{{{ instance*/
static void
__dpl_flush_instance ( dpl_node * node)
{
typeize ( dpl_INSTANCE, node );
dpl_OBJECT *object;
dpl_LOD *forcelod;
dpl_MATERIAL *f_material;
dpl_MATERIAL *b_material;
dpl_TEXTURE *f_texture;
dpl_TEXTURE *b_texture;
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_instance\n");
remotize ( object, t->object );
remotize ( forcelod, t->forcelod );
remotize ( f_material, t->f_material );
remotize ( b_material, t->b_material );
remotize ( f_texture, t->f_texture );
remotize ( b_texture, t->b_texture );
velocirender_flush ( node, sizeof(dpl_INSTANCE ));
t->object = object;
t->forcelod = forcelod;
t->f_material = f_material;
t->b_material = b_material;
t->f_texture = f_texture;
t->b_texture = b_texture;
return;
}
static void
__dpl_hide_instance ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_instance\n");
return;
}
static void
__dpl_unhide_instance ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_instance\n");
return;
}
/*}}} */
/*{{{ texture*/
static void
__dpl_flush_texture ( dpl_node * node)
{
typeize ( dpl_TEXTURE, node );
dpl_TEXMAP *texmap;
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_texture\n");
remotize ( texmap, t->texmap );
velocirender_flush ( node, sizeof(dpl_TEXTURE ));
t->texmap=texmap;
return;
}
static void
__dpl_hide_texture ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_texture\n");
return;
}
static void
__dpl_unhide_texture ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_texture\n");
return;
}
/*}}} */
/*{{{ texmap*/
static void
__dpl_flush_texmap ( dpl_node * node)
{
typeize ( dpl_TEXMAP, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_texmap\n");
velocirender_flush ( node, sizeof(dpl_TEXMAP ));
sprintf ( __lastop, "flush texels" );
return;
}
static void
__dpl_hide_texmap ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_texmap\n");
return;
}
static void
__dpl_unhide_texmap ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_texmap\n");
return;
}
/*}}} */
/*{{{ material*/
static void
__dpl_flush_material ( dpl_node * node)
{
typeize ( dpl_MATERIAL, node );
dpl_TEXTURE *texture;
dpl_RAMP *ramp;
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_material\n");
remotize ( ramp, t->ramp );
remotize ( texture, t->texture );
velocirender_flush ( node, sizeof(dpl_MATERIAL ));
t->ramp=ramp;
t->texture=texture;
return;
}
static void
__dpl_hide_material ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_material\n");
return;
}
static void
__dpl_unhide_material ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_material\n");
return;
}
/*}}} */
/*{{{ lmodel*/
static void
__dpl_flush_lmodel ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("flush_lmodel\n");
uncover(node);
velocirender_flush ( node, sizeof(dpl_LMODEL ));
return;
}
static void
__dpl_hide_lmodel ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_lmodel\n");
return;
}
static void
__dpl_unhide_lmodel ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_lmodel\n");
return;
}
/*}}} */
/*{{{ light*/
static void
__dpl_flush_light ( dpl_node * node)
{
typeize ( dpl_LIGHT, node );
dpl_DCS *dcs;
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_light\n");
remotize ( dcs, t->dcs );
velocirender_flush ( node, sizeof(dpl_LIGHT ));
t->dcs=dcs;
return;
}
static void
__dpl_hide_light ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_light\n");
return;
}
static void
__dpl_unhide_light ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_light\n");
return;
}
/*}}} */
/*{{{ ramp*/
static void
__dpl_flush_ramp ( dpl_node * node)
{
typeize ( dpl_RAMP, node );
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_rampl\n");
velocirender_flush ( node, sizeof(dpl_RAMP ));
return;
}
static void
__dpl_hide_ramp ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_ramp\n");
return;
}
static void
__dpl_unhide_ramp ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_ramp\n");
return;
}
/*}}} */
/*{{{ view*/
static void
__dpl_flush_view ( dpl_node * node)
{
uncover(node);
if (dpl_WarningLevel > 5)
printf ("flush_view\n");
velocirender_flush ( node, sizeof(dpl_VIEW ));
return;
}
static void
__dpl_hide_view ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("hide_view\n");
return;
}
static void
__dpl_unhide_view ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("unhide_view\n");
return;
}
/*}}} */
/*{{{ null*/
static void
__dpl_flush_null ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("warning : issuing flush on local-only type 0x%x\n", node->type_check );
return;
}
static void
__dpl_hide_null ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("warning : issuing hide on local-only type 0x%x\n", node->type_check );
return;
}
static void
__dpl_unhide_null ( dpl_node * node)
{
if (dpl_WarningLevel > 5)
printf ("warning : issuing unhide on local-only type 0x%x\n", node->type_check );
return;
}
/*}}} */
/*{{{ static void dpl_bind ( node, fn, fn, fn, fn, fn, fn )*/
static void
dpl_bind ( dpl_node *node,
int (*create)( struct s_dplnode *),
int (*delete)( struct s_dplnode *),
int (*flush)( struct s_dplnode *),
int (*hide)( struct s_dplnode *),
int (*unhide)( struct s_dplnode *) ) {
if (dpl_WarningLevel > 5)
printf ( "dpl_bind to node 0x%x\n", node );
node->ghost_create = create;
node->ghost_delete = delete;
node->flush = flush;
node->hide = hide;
node->unhide = unhide;
}
/*}}} */
/*{{{ dpl porting layer*/
/* ********************************
dpl porting layer
the following functions must be visible to the generic
layer to support communication between host and ghost
ghost_dpl_init perform ghost-specific initializations
ghost_dpl_bind_functions binds the 'methods' into each class
ghost_dpl_add_list_item implement remote list management
ghost_dpl_remove_list_item
ghost_dpl_nest_dcs implement remote tree management
ghost_dpl_link_dcs
ghost_dpl_prune_dcs
ghost_dpl_morph_object implement morphing in ghost copy
ghost_dpl_draw_scene fire off a render
ghost_dpl_draw_scene_complete poll render status
ghost_dpl_wait_draw_scene_complete sleep until render status==ok
ghost_dpl_version fill in ghost bits of version structure
ghost_dpl_statistics fill in ghost bits of statto structure
*/
/*}}} */
/* ********************************
functions to modify ghost database plumbing
*/
/*{{{ ghost_dpl_add_list_item ( dpl_superlist *head, dpl_node *node )*/
void
ghost_dpl_add_list_item ( dpl_superlist *head, dpl_node *node )
{
void *list_op[2]={NULL, NULL};
if (dpl_WarningLevel > 5)
printf ("__dpl_add_list_item\n" );
if (head->dplnode) {
list_op[0]=head->dplnode->remote;
list_op[1]=node->remote;
sprintf ( __lastop, "add %s (0x%x) to %s (0x%x)",
dpl_TypeToString(node->type_check),
node->type_check,
dpl_TypeToString(head->dplnode->type_check),
head->dplnode->type_check);
velocirender_transmit ( vr_list_add_action, list_op, 8, 1 );
}
else {
if (dpl_WarningLevel > 1)
printf ("attempt to add item to list with no node\n" );
}
return;
}
/*}}} */
/*{{{ ghost_dpl_remove_list_item ( dpl_superlist *head, dpl_node *node )*/
void
ghost_dpl_remove_list_item ( dpl_superlist *head, dpl_node *node )
{
void *list_op[2]={NULL, NULL};
if (dpl_WarningLevel > 5)
printf ("__dpl_remove_list_item\n" );
if (head->dplnode) {
list_op[0]=head->dplnode->remote;
list_op[1]=node->remote;
sprintf ( __lastop, "remove %s from %s",
dpl_TypeToString(node->type_check),
dpl_TypeToString(head->dplnode->type_check));
velocirender_transmit ( vr_list_remove_action, list_op, 8, 1 );
}
else {
if (dpl_WarningLevel > 1)
printf ("attempt to add item to list with no node\n" );
}
return;
}
/*}}} */
/*{{{ ghost_dpl_nest_dcs ( dpl_DCS *parent, dpl_DCS *node )*/
void
ghost_dpl_nest_dcs ( dpl_DCS *parent, dpl_DCS *node )
{
void *list_op[2]={NULL, NULL};
if (dpl_WarningLevel > 5)
printf ("__dpl_nest_dcs\n" );
if (parent) list_op[0]=parent->dplnode.remote;
if (node) list_op[1]=node->dplnode.remote;
sprintf ( __lastop, "nest DCS" );
velocirender_transmit ( vr_dcs_nest_action, list_op, 8, 1 );
return;
}
/*}}} */
/*{{{ ghost_dpl_link_dcs ( dpl_DCS *bro, dpl_DCS *sis )*/
void
ghost_dpl_link_dcs ( dpl_DCS *bro, dpl_DCS *sis )
{
void *list_op[2]={NULL, NULL};
if (dpl_WarningLevel > 5)
printf ("__dpl_link_dcs\n" );
sprintf ( __lastop, "link DCS" );
if (bro) list_op[0]=bro->dplnode.remote;
if (sis) list_op[1]=sis->dplnode.remote;
velocirender_transmit ( vr_dcs_link_action, list_op, 8, 1 );
return;
}
/*}}} */
/*{{{ ghost_dpl_prune_dcs ( dpl_DCS *parent, dpl_DCS *child )*/
void
ghost_dpl_prune_dcs ( dpl_DCS *parent, dpl_DCS *child )
{
void *list_op[2]={NULL, NULL};
if (dpl_WarningLevel > 5)
printf ("__dpl_prune_dcs\n" );
if (parent) list_op[0]=parent->dplnode.remote;
if (child) list_op[1]=child->dplnode.remote;
sprintf ( __lastop, "prune DCS" );
velocirender_transmit ( vr_dcs_prune_action, list_op, 8, 1 );
return;
}
/*}}} */
/*{{{ ghost_dpl_morph_object ( dpl_OBJECT *morphed,*/
void
ghost_dpl_morph_object ( dpl_OBJECT *morphed,
dpl_OBJECT *a,
dpl_OBJECT *b,
float32 alpha )
{
int32 morph_op[4]={0, 0, 0, 0};
if (dpl_WarningLevel > 5)
printf ("__dpl_morph_object\n" );
sprintf ( __lastop, "morph OBJECT" );
morph_op[0]=(int32) (morphed->dplnode.remote);
morph_op[1]=(int32) (a->dplnode.remote);
morph_op[2]=(int32) (b->dplnode.remote);
morph_op[3]=*(int32 *) &alpha;
velocirender_transmit ( vr_morph_action, morph_op, 16, 1 );
return;
}
/*}}} */
/*{{{ ghost_dpl_set_texmap_texels ( dpl_TEXMAP *tm,*/
extern int32
ghost_dpl_set_texmap_texels ( dpl_TEXMAP *tm,
int32 *texels,
int32 u_size,
int32 v_size,
int32 mode )
{
/* does this piece-wise */
/* work out haw many blocks of each type we will send */
vr_action action;
int32 nb, n_texels=u_size*v_size, set_geom_rec[8];
/*
printf ("ghost set texmap texels, %d texels\n", n_texels );
*/
set_geom_rec[0]=(int32 ) (tm->dplnode.remote);
set_geom_rec[1]=n_texels;
set_geom_rec[2]=u_size;
set_geom_rec[3]=v_size;
set_geom_rec[4]=mode;
velocirender_transmit ( vr_set_texmap_texels_action, set_geom_rec,
8*sizeof(int32), 1 );
while (n_texels) {
velocirender_transmit ( vr_set_texmap_texels_action,
texels, 64*4, 0 );
n_texels-=64;
texels +=64;
}
velocirender_receive ( &action, set_geom_rec, &nb );
return (action==vr_set_texmap_texels_action);
}
/*}}} */
/*{{{ ghost_dpl_set_geometry_vertices ( dpl_GEOMETRY *gg,*/
extern int32
ghost_dpl_set_geometry_vertices ( dpl_GEOMETRY *gg,
dpl_VERTEX_LIST *vl,
dpl_CONNECTION_LIST *cl,
int32 vertices,
int32 connections )
{
/* does this piece-wise */
/* work out haw many blocks of each type we will send */
vr_action action;
int32 vert_blox=0, conn_blox=0;
int32 nb, set_geom_rec[8];
dpl_VERTEX_LIST *v=vl;
dpl_CONNECTION_LIST *c=cl;
/*
printf ("ghost set geom verts, %d verts, %d conns\n",
vertices, connections );
*/
for ( v=vl; v; v=v->next )
vert_blox++;
for ( c=cl; c; c=c->next )
conn_blox++;
/*
printf ("have decided to send %d, %d blocks\n",
vert_blox, conn_blox );
*/
set_geom_rec[0]=(int32 ) (gg->dplnode.remote);
set_geom_rec[1]=vert_blox;
set_geom_rec[2]=conn_blox;
set_geom_rec[3]=vertices;
set_geom_rec[4]=connections;
velocirender_transmit ( vr_set_geom_verts_action, set_geom_rec,
5*sizeof(int32), 1 );
/*
printf ("will be sending %d blocks of verts, %d blocks of connections\n",
vert_blox, conn_blox );
*/
while (vert_blox) {
/*
printf ("sending %d bytes\n", sizeof(dpl_VERTEX_LIST));
*/
velocirender_transmit ( vr_set_geom_verts_action,
vl, sizeof(dpl_VERTEX_LIST), 1 );
vert_blox--;
vl=vl->next;
}
while (conn_blox) {
velocirender_transmit ( vr_set_geom_verts_action,
cl, sizeof(dpl_CONNECTION_LIST), 1 );
conn_blox--;
cl=cl->next;
}
velocirender_receive ( &action, set_geom_rec, &nb );
return (action==vr_set_geom_verts_action);
}
/*}}} */
/* ********************************
general ghost control functions
*/
/*{{{ ghost_dpl_init ( argc, argv )*/
static char tranny_boot[128];
static char i860_boot[128];
/*{{{ char *find_arg ( int argc, char **argv, char *str, int* ignore, int ignore_val )*/
static char
*find_arg ( int argc, char **argv, char *str, int* ignore, int ignore_val )
{
int i;
char *arg;
if (dpl_WarningLevel > 3)
printf ("find_arg %s ", str );
for (i=0; i<argc; i++ ) {
if (arg=argv[i]) {
if (arg[0] == '/') {
if (strcmp ( arg+1, str ) == 0) {
if (i != (argc-1)) {
if (dpl_WarningLevel > 3)
printf ( "is %s at argv[%d]\n", argv[i+1], i+1 );
ignore[i] =ignore_val;
ignore[i+1]=ignore_val;
return argv[i+1];
}
}
}
}
}
if (dpl_WarningLevel > 3)
printf ( "is NULL\n" );
return NULL;
}
/*}}} */
/*{{{ static int frag ( char **argc, char *string )*/
static int frag ( char **argv, char *string )
{
int argc=1, i=0;
argv[0]=string;
while (*string) {
if ((*string) == '~') {
*string=0x0;
string++;
if (*string) {
argv[argc]=string;
argc++;
}
}
string++;
}
/*
printf ("frag found %d strings\n", argc );
for (i=0; i<argc; i++) {
printf ("%d : %s\n", i, argv[i] );
}
*/
return argc;
}
/*}}} */
void
ghost_dpl_init ( char *dpl_arg )
{
char *tranny_code,
*i860_code,
*hsp_code,
*video_mode,
*device,
*link_A,
*link_B,
*n_860s;
int argc=0;
char *argv[32];
vr_action action;
char *i860_init=malloc(256);
int32 *ignore=(int32 *) malloc(64*sizeof(int32));
int32 nb, i, v_link_A, v_link_B, v_device, v_n_860s;
if (dpl_WarningLevel > 5)
printf ("ghost_dpl_init\n" );
for (i=0; i<64; i++)
ignore[i]=0;
sprintf ( __lastop, "init" );
dpl_little_endian=0x0;
*((char *) &dpl_little_endian)=0x1;
dpl_little_endian&=0x1;
/* printf ("dpl_little_endian=%d\n", dpl_little_endian ); */
strcpy ( i860_init, dpl_arg );
argc=frag ( argv, i860_init );
device = find_arg ( argc, argv, "device", ignore, 0 );
tranny_code = find_arg ( argc, argv, "tranny", ignore, 1 );
i860_code = find_arg ( argc, argv, "i860" , ignore, 1 );
hsp_code = find_arg ( argc, argv, "hsp" , ignore, 1 );
video_mode = find_arg ( argc, argv, "video" , ignore, 0 );
n_860s = find_arg ( argc, argv, "n_860s", ignore, 0 );
link_A = find_arg ( argc, argv, "link_A", ignore, 0 );
link_B = find_arg ( argc, argv, "link_B", ignore, 0 );
if (tranny_code)
strcpy ( tranny_boot, tranny_code );
else
strcpy ( tranny_boot, "NULL" );
if (i860_code)
strcpy ( i860_boot, i860_code );
else
strcpy ( i860_boot, "NULL" );
sscanf ( device, "%x", &v_device );
sscanf ( link_A, "%d", &v_link_A );
sscanf ( link_B, "%d", &v_link_B );
sscanf ( n_860s, "%d", &v_n_860s );
start_velocirender ( tranny_code,
hsp_code,
i860_code,
v_device,
v_link_A,
v_link_B,
v_n_860s );
i860_init[0]=0x0;
for (i=1; i<argc; i++) {
if (ignore[i] == 0) {
strcat ( i860_init, argv[i] );
strcat ( i860_init, "|" );
}
}
strcat ( i860_init, "\n" );
velocirender_transmit ( vr_init_action, i860_init, 1+strlen(i860_init), 1 );
velocirender_receive ( &action, ignore, &nb );
free(ignore);
free(i860_init);
return;
}
/*}}} */
/*{{{ ghost_dpl_draw_scene ( int32 double_buffered )*/
void
ghost_dpl_draw_scene ( int32 double_buffered )
{
int32 n;
if (dpl_WarningLevel > 5)
printf ("ghost_dpl_draw_scene\n" );
sprintf ( __lastop, "draw scene" );
n=double_buffered;
velocirender_transmit ( vr_draw_scene_action, &n, 4, 1 );
return;
}
/*}}} */
/*{{{ ghost_dpl_draw_scene_complete ( void );*/
int32
ghost_dpl_draw_scene_complete ( void )
{
vr_action action;
int32 n_bytes;
int32 hit;
if (dpl_WarningLevel > 5)
printf ("ghost_dpl_draw_scene_complete\n" );
sprintf ( __lastop, "draw scene complete" );
return velocirender_inputstatus ();
return 1;
}
/*}}} */
/*{{{ ghost_dpl_wait_draw_scene_complete ( void );*/
void
ghost_dpl_wait_draw_scene_complete ( void )
{
if (dpl_WarningLevel > 5)
printf ("ghost_dpl_wait_draw_scene_complete\n" );
sprintf ( __lastop, "wait scene complete" );
velocirender_frameack ();
return;
}
/*}}} */
/*{{{ ghost_dpl_version ( dpl_VERSION *version )*/
void
ghost_dpl_version ( dpl_VERSION *version )
{
version->firmware_major_version=3;
version->firmware_minor_version=0;
sprintf ( __lastop, "version" );
strcat ( version->detailed, ":transp=%s :i860=%s",
tranny_boot, i860_boot );
}
/*}}} */
/*{{{ ghost_dpl_statistics ( dpl_STATISTICS *statto )*/
void
ghost_dpl_statistics ( dpl_STATISTICS *statto )
{
sprintf ( __lastop, "statistics" );
statto->polys_in_last_frame = 10.0f;
statto->last_edit_time = 10.0f;
statto->last_cull_time = 100.0f;
statto->last_frame_time_sb = 1000.0f;
statto->last_frame_time = 2000.0f;
statto->polys_per_second = 10.0f;
statto->polys_per_second_sb = 20.0f;
}
/*}}} */
/*{{{ ghost_dpl_readpixels ( int32 *pixels, int32 x, int32 y, int32 n_pixels );*/
void
ghost_dpl_readpixels ( int32 *pixels, int32 x, int32 y, int32 n_pixels )
{
sprintf ( __lastop, "read pixels" );
return;
}
/*}}} */
/*{{{ ghost_dpl_sectvector ( dpl_POINT sect,*/
dpl_INSTANCE *
ghost_dpl_sectvector ( dpl_POINT sect,
float32 x0, float32 y0, float32 z0,
float32 x1, float32 y1, float32 z1 )
{
sprintf ( __lastop, "sect vector" );
return NULL;
}
/*}}} */
/*{{{ ghost_dpl_sectpixel ( dpl_POINT sect, float32 x, float32 y );*/
dpl_INSTANCE *
ghost_dpl_sectpixel ( dpl_POINT sect, float32 x, float32 y )
{
sprintf ( __lastop, "sect pixel" );
return NULL;
}
/*}}} */
/*{{{ ghost_dpl_bind_functions ( dpl_node *node )*/
void
ghost_dpl_bind_functions ( dpl_node *node )
{
if (node == NULL) {
printf ("attempt to bind functions to NULL node\n" );
exit ( 666 );
}
if (dpl_WarningLevel > 5)
printf ( "dpl_bind_functions node 0x%x type 0x%x\n", node, node->type_check );
switch (node->type_check) {
case dpl_type_zone :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_zone,
__dpl_hide_zone,
__dpl_unhide_zone );
break;
/*}}} */
case dpl_type_view :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_view,
__dpl_hide_view,
__dpl_unhide_view );
break;
/*}}} */
case dpl_type_instance :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_instance,
__dpl_hide_instance,
__dpl_unhide_instance );
break;
/*}}} */
case dpl_type_lmodel :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_lmodel,
__dpl_hide_lmodel,
__dpl_unhide_lmodel );
break;
/*}}} */
case dpl_type_light :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_light,
__dpl_hide_light,
__dpl_unhide_light );
break;
/*}}} */
case dpl_type_dcs :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_dcs,
__dpl_hide_dcs,
__dpl_unhide_dcs );
break;
/*}}} */
case dpl_type_object :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_object,
__dpl_hide_object,
__dpl_unhide_object );
break;
/*}}} */
case dpl_type_lod :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_lod,
__dpl_hide_lod,
__dpl_unhide_lod );
break;
/*}}} */
case dpl_type_ramp :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_ramp,
__dpl_hide_ramp,
__dpl_unhide_ramp );
break;
/*}}} */
case dpl_type_geogroup :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_geogroup,
__dpl_hide_geogroup,
__dpl_unhide_geogroup );
break;
/*}}} */
case dpl_type_geometry :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_geometry,
__dpl_hide_geometry,
__dpl_unhide_geometry );
break;
/*}}} */
case dpl_type_material :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_material,
__dpl_hide_material,
__dpl_unhide_material );
break;
/*}}} */
case dpl_type_texmap :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_texmap,
__dpl_hide_texmap,
__dpl_unhide_texmap );
break;
/*}}} */
case dpl_type_texture :
/*{{{ */
dpl_bind ( node,
velocirender_create,
velocirender_delete,
__dpl_flush_texture,
__dpl_hide_texture,
__dpl_unhide_texture );
break;
/*}}} */
default :
/*{{{ */
dpl_bind ( node,
null_create,
null_delete,
__dpl_flush_null,
__dpl_hide_null,
__dpl_unhide_null );
break;
/*}}} */
}
}
/*}}} */