2011-09-14 19:08:43 +00:00
|
|
|
/**
|
|
|
|
** Supermodel
|
|
|
|
** A Sega Model 3 Arcade Emulator.
|
2021-02-18 10:29:15 +00:00
|
|
|
** Copyright 2011-2021 Bart Trzynadlowski, Nik Henson, Ian Curtis,
|
|
|
|
** Harry Tuttle, and Spindizzi
|
2011-09-14 19:08:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of Supermodel.
|
|
|
|
**
|
|
|
|
** Supermodel is free software: you can redistribute it and/or modify it under
|
2021-02-18 10:29:15 +00:00
|
|
|
** the terms of the GNU General Public License as published by the Free
|
2011-09-14 19:08:43 +00:00
|
|
|
** Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
** any later version.
|
|
|
|
**
|
|
|
|
** Supermodel is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
** more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License along
|
|
|
|
** with Supermodel. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**/
|
2021-02-18 10:29:15 +00:00
|
|
|
|
2011-09-14 19:08:43 +00:00
|
|
|
/*
|
2021-02-18 10:29:15 +00:00
|
|
|
* WheelBoard.h
|
2011-09-14 19:08:43 +00:00
|
|
|
*
|
2021-02-18 10:29:15 +00:00
|
|
|
* Header for the CWheelBoard (force feedback emulation for wheel) class.
|
2011-09-14 19:08:43 +00:00
|
|
|
*/
|
|
|
|
|
2021-02-18 10:29:15 +00:00
|
|
|
#ifndef INCLUDED_WHEELBOARD_H
|
|
|
|
#define INCLUDED_WHEELBOARD_H
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2021-11-22 17:15:06 +00:00
|
|
|
#include "DriveBoard.h"
|
2017-03-27 03:19:15 +00:00
|
|
|
#include "Util/NewConfig.h"
|
2021-02-18 10:29:15 +00:00
|
|
|
#include "Game.h"
|
2011-09-07 07:06:40 +00:00
|
|
|
|
|
|
|
/*
|
2021-02-18 10:29:15 +00:00
|
|
|
* CWheelBoard
|
2011-09-07 07:06:40 +00:00
|
|
|
*/
|
2021-02-18 10:29:15 +00:00
|
|
|
class CWheelBoard : public CDriveBoard
|
2011-09-07 07:06:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-27 03:19:15 +00:00
|
|
|
/*
|
2021-02-18 10:29:15 +00:00
|
|
|
* GetType(void):
|
2017-03-27 03:19:15 +00:00
|
|
|
*
|
|
|
|
* Returns:
|
2021-02-18 10:29:15 +00:00
|
|
|
* Drive board type.
|
2017-03-27 03:19:15 +00:00
|
|
|
*/
|
2021-02-18 10:29:15 +00:00
|
|
|
Game::DriveBoardType GetType(void);
|
2017-03-27 03:19:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get7SegDisplays(seg1Digit1, seg1Digit2, seg2Digit1, seg2Digit2):
|
|
|
|
*
|
|
|
|
* Reads the 7-segment displays.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* seg1Digit1 Reference of variable to store digit 1 of the first 7-
|
|
|
|
* segment display to.
|
|
|
|
* seg1Digit2 First display, second digit.
|
|
|
|
* seg2Digit1 Second display, first digit.
|
|
|
|
* seg2Digit2 Second display, second digit.
|
|
|
|
*/
|
|
|
|
void Get7SegDisplays(UINT8 &seg1Digit, UINT8 &seg1Digit2, UINT8 &seg2Digit1, UINT8 &seg2Digit2);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SaveState(SaveState):
|
|
|
|
*
|
|
|
|
* Saves the drive board state.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* SaveState Block file to save state information to.
|
|
|
|
*/
|
|
|
|
void SaveState(CBlockFile *SaveState);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LoadState(SaveState):
|
|
|
|
*
|
|
|
|
* Restores the drive board state.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* SaveState Block file to load save state information from.
|
|
|
|
*/
|
|
|
|
void LoadState(CBlockFile *SaveState);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset(void):
|
|
|
|
*
|
|
|
|
* Resets the drive board.
|
|
|
|
*/
|
|
|
|
void Reset(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read():
|
|
|
|
*
|
|
|
|
* Reads data from the drive board.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Data read.
|
|
|
|
*/
|
|
|
|
UINT8 Read(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write(data):
|
|
|
|
*
|
|
|
|
* Writes data to the drive board.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* data Data to send.
|
|
|
|
*/
|
|
|
|
void Write(UINT8 data);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RunFrame(void):
|
|
|
|
*
|
|
|
|
* Emulates a single frame's worth of time on the drive board.
|
|
|
|
*/
|
|
|
|
void RunFrame(void);
|
|
|
|
|
|
|
|
/*
|
2021-02-18 10:29:15 +00:00
|
|
|
* CWheelBoard(config):
|
|
|
|
* ~CWheelBoard():
|
2017-03-27 03:19:15 +00:00
|
|
|
*
|
|
|
|
* Constructor and destructor. Memory is freed by destructor.
|
|
|
|
*
|
|
|
|
* Paramters:
|
|
|
|
* config Run-time configuration. The reference should be held because
|
|
|
|
* this changes at run-time.
|
|
|
|
*/
|
2021-02-18 10:29:15 +00:00
|
|
|
CWheelBoard(const Util::Config::Node &config);
|
|
|
|
~CWheelBoard(void);
|
2017-03-27 03:19:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read8(addr):
|
|
|
|
* IORead8(portNum):
|
|
|
|
*
|
|
|
|
* Methods for reading from Z80's memory and IO space. Required by CBus.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* addr Address in memory (0-0xFFFF).
|
|
|
|
* portNum Port address (0-255).
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A byte of data from the address or port.
|
|
|
|
*/
|
|
|
|
UINT8 IORead8(UINT32 portNum);
|
2021-02-18 10:29:15 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
/*
|
|
|
|
* Write8(addr, data):
|
|
|
|
* IORead8(portNum, data):
|
|
|
|
*
|
|
|
|
* Methods for writing to Z80's memory and IO space. Required by CBus.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* addr Address in memory (0-0xFFFF).
|
|
|
|
* portNum Port address (0-255).
|
|
|
|
* data Byte to write.
|
|
|
|
*/
|
|
|
|
void IOWrite8(UINT32 portNum, UINT8 data);
|
2020-10-24 09:12:54 +00:00
|
|
|
|
2021-02-18 10:29:15 +00:00
|
|
|
protected:
|
|
|
|
void Disable(void);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2021-02-18 10:29:15 +00:00
|
|
|
private:
|
|
|
|
void LoadLegacyState(CBlockFile *SaveState);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT8 m_seg1Digit1; // Current value of left digit on 7-segment display 1
|
|
|
|
UINT8 m_seg1Digit2; // Current value of right digit on 7-segment display 1
|
|
|
|
UINT8 m_seg2Digit1; // Current value of left digit on 7-segment display 2
|
|
|
|
UINT8 m_seg2Digit2; // Current value of right digit on 7-segment display 2
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT16 m_adcPortRead; // ADC port currently reading from
|
|
|
|
UINT8 m_adcPortBit; // Bit number currently reading on ADC port
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT8 m_port42Out; // Last value sent to Z80 I/O port 42 (encoder motor data)
|
|
|
|
UINT8 m_port46Out; // Last value sent to Z80 I/O port 46 (encoder motor control)
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT8 m_prev42Out; // Previous value sent to Z80 I/O port 42
|
|
|
|
UINT8 m_prev46Out; // Previous value sent to Z80 I/O port 46
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT8 m_uncenterVal1; // First part of pending uncenter command
|
|
|
|
UINT8 m_uncenterVal2; // Second part of pending uncenter command
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
// Feedback state
|
|
|
|
INT8 m_lastConstForce; // Last constant force command sent
|
|
|
|
UINT8 m_lastSelfCenter; // Last self center command sent
|
|
|
|
UINT8 m_lastFriction; // Last friction command sent
|
|
|
|
UINT8 m_lastVibrate; // Last vibrate command sent
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
UINT8 SimulateRead(void);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SimulateWrite(UINT8 data);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SimulateFrame(void);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void ProcessEncoderCmd(void);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SendStopAll(void);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SendConstantForce(INT8 val);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SendSelfCenter(UINT8 val);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SendFriction(UINT8 val);
|
2011-09-07 07:06:40 +00:00
|
|
|
|
2017-03-27 03:19:15 +00:00
|
|
|
void SendVibrate(UINT8 val);
|
2020-10-24 09:12:54 +00:00
|
|
|
|
|
|
|
uint8_t ReadADCChannel1();
|
|
|
|
|
|
|
|
uint8_t ReadADCChannel2();
|
|
|
|
|
|
|
|
uint8_t ReadADCChannel3();
|
|
|
|
|
|
|
|
uint8_t ReadADCChannel4();
|
2011-09-07 07:06:40 +00:00
|
|
|
};
|
|
|
|
|
2021-02-18 10:29:15 +00:00
|
|
|
#endif // INCLUDED_WHEELBOARD_H
|