Files
TeslaRel410/CODE/RP/MUNGA_L4/L4MOUSE.CPP
T
CydandClaude Fable 5 fdd9ac9d97 Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)
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>
2026-07-02 13:21:58 -05:00

189 lines
4.5 KiB
C++

//===========================================================================//
// File: PCmouse.cc //
// Project: MUNGA Brick: Platform-specific IO //
// Contents: PC mouse interface //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- -----------------------------------------------------------//
// 01/24/95 CPB Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved //
// PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <mungal4.hpp>
#pragma hdrstop
#if !defined(L4MOUSE_HPP)
# include <l4mouse.hpp>
#endif
#define MOUSEINT 0x33
//
//############################################################################
// Creator - reset the driver and check for existence
//
//############################################################################
//
Mouse::Mouse()
{
Check_Pointer(this);
//
//-----------------------------------------------
// Reset driver and read status
//-----------------------------------------------
//
_AX = 0;
geninterrupt(MOUSEINT);
//
//-----------------------------------------------
// AX will be zero if error, 0xFFFF if ok.
// BX is the number of buttons.
//-----------------------------------------------
//
if (_AX == 0xFFFF)
{
ButtonCount = _BX;
Errors = 0;
}
else
{
Errors = 1;
ButtonCount = 0;
}
Check_Fpu();
}
Logical
Mouse::TestInstance() const
{
return True;
}
//
//############################################################################
// ReadCounters - return how many 'mickeys' the mouse has moved
// since the last call
//############################################################################
//
void
Mouse::ReadCounters(int *xp, int *yp)
{
Check(this);
Check_Pointer(xp);
Check_Pointer(yp);
if (Errors)
{
*xp = 0;
*yp = 0;
}
else
{
//
//-----------------------------------------------
// Read motion counters
//-----------------------------------------------
//
_AX = 0x000B;
geninterrupt(MOUSEINT);
//
//-----------------------------------------------
// CX = UNSIGNED x counter,
// DX = UNSIGNED y counter.
// These must be converted to signed values.
//-----------------------------------------------
//
int a = _CX;
int b = _DX;
if (a & 0x8000)
{
a |= (int)(~65535L);
}
if (b & 0x8000)
{
b |= (int)(~65535L);
}
*xp = a;
*yp = b;
}
Check_Fpu();
}
//
//############################################################################
// ButtonPressed - return the number of times a given button was pressed
// since the last call
//############################################################################
//
int
Mouse::ButtonPressed(int buttonNum)
{
Check(this);
if (Errors)
{
return 0;
}
else
{
//
//-----------------------------------------------
// Read button press data
//-----------------------------------------------
//
_AX = 0x0005;
_BX = (unsigned short) buttonNum;
geninterrupt(MOUSEINT);
//
//-----------------------------------------------
// AX = current button states
// BX = number of times pressed since last call
//-----------------------------------------------
//
return (int) _BX;
}
}
//
//############################################################################
// ButtonReleased - return the number of times a given button was released
// since the last call
//############################################################################
//
int
Mouse::ButtonReleased(int buttonNum)
{
Check(this);
if (Errors)
{
return 0;
}
else
{
//
//-----------------------------------------------
// Read button press data
//-----------------------------------------------
//
_AX = 0x0006;
_BX = (unsigned short) buttonNum;
geninterrupt(MOUSEINT);
//
//-----------------------------------------------
// AX = current button states
// BX = number of times pressed since last call
//-----------------------------------------------
//
return _BX;
}
}