Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
240 lines
7.3 KiB
C++
240 lines
7.3 KiB
C++
//===========================================================================//
|
|
// File: analysis.cpp //
|
|
// Project: MUNGA Brick: none //
|
|
// Contents: Utilities for using logic analyzer with parallel port dongle //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 04/19/94 WGR Initial coding. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. All Rights reserved //
|
|
// PROPRIETARY AND CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(PROFILE_HPP)
|
|
# include "analysis.hpp"
|
|
#endif
|
|
|
|
#if defined(USE_PROFILE_ANALYSIS)
|
|
# if defined(USE_TIME_ANALYSIS)
|
|
# error NETNUB may not use time analysis!
|
|
# endif
|
|
|
|
# include <dos.h>
|
|
# include <stdio.h>
|
|
|
|
//
|
|
// these macros must be undefined for Borland to access the inp & outportb functions
|
|
//
|
|
# undef inportb
|
|
# undef outportb
|
|
|
|
# define TRACE_COUNT 12
|
|
|
|
# if defined(USE_PROFILE_ANALYSIS)
|
|
|
|
//
|
|
// table of data representing bits on the parallel port at 0x378 (usually LPT1)
|
|
// DO NOT ALTER THIS DATA - IT REQUIRES LOTS OF SCHEMATIC TRACING TO DUPLICATE
|
|
//
|
|
const struct parallelbit
|
|
{
|
|
unsigned int port;
|
|
unsigned char mask;
|
|
int sense;
|
|
}
|
|
bitTable[12] =
|
|
{
|
|
{0x378, 0x80, 0x00},
|
|
{0x378, 0x40, 0x00},
|
|
{0x378, 0x20, 0x00},
|
|
{0x378, 0x10, 0x00},
|
|
{0x37a, 0x08, 0x01},
|
|
{0x37a, 0x04, 0x00},
|
|
{0x37a, 0x02, 0x01},
|
|
{0x37a, 0x01, 0x01},
|
|
{0x378, 0x08, 0x00},
|
|
{0x378, 0x04, 0x00},
|
|
{0x378, 0x02, 0x00},
|
|
{0x378, 0x01, 0x00}
|
|
};
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Analysis_Status()
|
|
{
|
|
int i;
|
|
printf("Active traces:");
|
|
for (i=0; i<12; ++i)
|
|
{
|
|
if (Read_Analysis(i))
|
|
{
|
|
printf(" %i", i);
|
|
}
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Set one of the 12 outputable bits of the parallel port at 0x378 (usually
|
|
// LPT1), taking into account the hardware sense of the bit
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Set_Analysis(int bit)
|
|
{
|
|
//
|
|
//------------------------------------------------------------------
|
|
// read the current value of the appropriate port
|
|
//------------------------------------------------------------------
|
|
//
|
|
int port_value;
|
|
port_value = inportb(bitTable[bit].port);
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// set the appropriate bit, taking into account the hardware sense
|
|
//------------------------------------------------------------------
|
|
//
|
|
if (bitTable[bit].sense == 0)
|
|
{
|
|
port_value |= bitTable[bit].mask;
|
|
}
|
|
else
|
|
{
|
|
port_value &= ~(bitTable[bit].mask);
|
|
}
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// put the modified value into the appropriate port
|
|
//------------------------------------------------------------------
|
|
//
|
|
outportb(bitTable[bit].port,(unsigned char)port_value);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Clear one of the 12 outputable bits of the parallel port at 0x378 (usually
|
|
// LPT1, taking into account the hardware sense of the bit.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Clear_Analysis(int bit)
|
|
{
|
|
//
|
|
//------------------------------------------------------------------
|
|
// read the current value of the appropriate port
|
|
//------------------------------------------------------------------
|
|
//
|
|
int port_value;
|
|
port_value = inportb(bitTable[bit].port);
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// clear the appropriate bit, taking into account the hardware sense
|
|
//------------------------------------------------------------------
|
|
//
|
|
if (bitTable[bit].sense == 0)
|
|
{
|
|
port_value &= ~(bitTable[bit].mask);
|
|
}
|
|
else
|
|
{
|
|
port_value |= bitTable[bit].mask;
|
|
}
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// put the modified value into the appropriate port
|
|
//------------------------------------------------------------------
|
|
//
|
|
outportb(bitTable[bit].port,(unsigned char)port_value);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Toggle one of the 12 outputable bits of the parallel port at 0x378 (usually
|
|
// LPT1, taking into account the hardware sense of the bit.
|
|
//#############################################################################
|
|
//
|
|
int
|
|
Read_Analysis(int bit)
|
|
{
|
|
//
|
|
//------------------------------------------------------------------
|
|
// read the current value of the appropriate port
|
|
//------------------------------------------------------------------
|
|
//
|
|
int port_value;
|
|
port_value = inportb(bitTable[bit].port);
|
|
|
|
//
|
|
//---------------------------
|
|
// Read the bit appropriately
|
|
//---------------------------
|
|
//
|
|
port_value &= bitTable[bit].mask;
|
|
if (bitTable[bit].sense)
|
|
{
|
|
port_value ^= bitTable[bit].mask;
|
|
}
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// return the bit's state
|
|
//------------------------------------------------------------------
|
|
//
|
|
return port_value != 0;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Clear all of the 12 outputable bits of the parallel port at 0x378.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Reset_Analysis(void)
|
|
{
|
|
//
|
|
//------------------------------------------------------------------
|
|
// clear all 12 outputable bits of the parallel port
|
|
// at 0x378 (usually LPT1)
|
|
//------------------------------------------------------------------
|
|
//
|
|
int i;
|
|
for (i = 0; i < 12; i++)
|
|
{
|
|
Clear_Analysis(i);
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Test all of the 12 outputable bits of the parallel port at 0x378.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Test_Analysis(void)
|
|
{
|
|
//
|
|
//------------------------------------------------------------------
|
|
// toggle (twice) all 12 outputable bits of the parallel port
|
|
// at 0x378 (usually LPT1)
|
|
//------------------------------------------------------------------
|
|
//
|
|
int i;
|
|
for (i = 0; i < 12; i++) Clear_Analysis(i);
|
|
for (i = 0; i < 12; i++) Set_Analysis(i);
|
|
for (i = 0; i < 12; i++) Clear_Analysis(i);
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|