2011-09-21 22:53:41 +00:00
|
|
|
/**
|
|
|
|
** Supermodel
|
|
|
|
** A Sega Model 3 Arcade Emulator.
|
|
|
|
** Copyright 2011 Bart Trzynadlowski, Nik Henson
|
|
|
|
**
|
|
|
|
** This file is part of Supermodel.
|
|
|
|
**
|
|
|
|
** Supermodel is free software: you can redistribute it and/or modify it under
|
|
|
|
** the terms of the GNU General Public License as published by the Free
|
|
|
|
** 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/>.
|
|
|
|
**/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Musashi68KDebug.h
|
|
|
|
*/
|
|
|
|
|
2011-09-18 21:59:23 +00:00
|
|
|
#ifdef SUPERMODEL_DEBUGGER
|
|
|
|
#ifndef INCLUDED_MUSASHI68KDEBUG_H
|
|
|
|
#define INCLUDED_MUSASHI68KDEBUG_H
|
|
|
|
|
|
|
|
#include "68KDebug.h"
|
|
|
|
#include "CPU/Bus.h"
|
|
|
|
#include "CPU/68K/68K.h"
|
|
|
|
#include "Types.h"
|
|
|
|
|
|
|
|
// TODO - can't get this namespace to work with 68K.h for some reason - strange Visual Studio errors
|
2018-01-22 18:27:51 +00:00
|
|
|
namespace Debugger
|
|
|
|
{
|
2011-09-18 21:59:23 +00:00
|
|
|
/*
|
|
|
|
* CCPUDebug implementation for the Musashi Motorola 68000 emulator.
|
|
|
|
*/
|
2016-04-11 03:39:19 +00:00
|
|
|
class CMusashi68KDebug : public C68KDebug, public ::IBus
|
2011-09-18 21:59:23 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
static UINT32 GetReg(CCPUDebug *cpu, unsigned id);
|
|
|
|
|
|
|
|
static bool SetReg(CCPUDebug *cpu, unsigned id, UINT32 data);
|
|
|
|
|
|
|
|
M68KCtx *m_ctx;
|
|
|
|
UINT32 m_resetAddr;
|
|
|
|
|
|
|
|
M68KCtx m_savedCtx;
|
|
|
|
|
2016-04-11 03:39:19 +00:00
|
|
|
::IBus *m_bus;
|
2011-09-18 21:59:23 +00:00
|
|
|
|
2018-01-22 18:27:51 +00:00
|
|
|
// Inlined methods
|
2011-09-18 21:59:23 +00:00
|
|
|
|
2018-01-22 18:27:51 +00:00
|
|
|
void CMusashi68KDebug::SetM68KContext()
|
|
|
|
{
|
|
|
|
M68KGetContext(&m_savedCtx);
|
|
|
|
if (m_savedCtx.Debug != this)
|
|
|
|
M68KSetContext(m_ctx);
|
|
|
|
}
|
2011-09-18 21:59:23 +00:00
|
|
|
|
2018-01-22 18:27:51 +00:00
|
|
|
void CMusashi68KDebug::UpdateM68KContext(M68KCtx *ctx)
|
|
|
|
{
|
|
|
|
m_ctx = ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMusashi68KDebug::RestoreM68KContext()
|
|
|
|
{
|
|
|
|
if (m_savedCtx.Debug != this)
|
|
|
|
M68KSetContext(&m_savedCtx);
|
|
|
|
}
|
2011-09-18 21:59:23 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
UINT32 GetSP();
|
|
|
|
|
|
|
|
public:
|
|
|
|
CMusashi68KDebug(const char *name, M68KCtx *m68K);
|
|
|
|
|
|
|
|
virtual ~CMusashi68KDebug();
|
|
|
|
|
|
|
|
// CCPUDebug methods
|
|
|
|
|
|
|
|
void AttachToCPU();
|
|
|
|
|
|
|
|
void DetachFromCPU();
|
|
|
|
|
|
|
|
UINT32 GetResetAddr();
|
|
|
|
|
|
|
|
bool UpdatePC(UINT32 pc);
|
|
|
|
|
|
|
|
bool ForceException(CException *ex);
|
|
|
|
|
|
|
|
bool ForceInterrupt(CInterrupt *in);
|
|
|
|
|
|
|
|
UINT64 ReadMem(UINT32 addr, unsigned dataSize);
|
|
|
|
|
|
|
|
bool WriteMem(UINT32 addr, unsigned dataSize, UINT64 data);
|
|
|
|
|
2016-04-11 03:39:19 +00:00
|
|
|
// IBus methods
|
2011-09-18 21:59:23 +00:00
|
|
|
|
|
|
|
UINT8 Read8(UINT32 addr);
|
|
|
|
|
|
|
|
void Write8(UINT32 addr, UINT8 data);
|
|
|
|
|
|
|
|
UINT16 Read16(UINT32 addr);
|
|
|
|
|
|
|
|
void Write16(UINT32 addr, UINT16 data);
|
|
|
|
|
|
|
|
UINT32 Read32(UINT32 addr);
|
|
|
|
|
|
|
|
void Write32(UINT32 addr, UINT32 data);
|
|
|
|
};
|
2018-01-22 18:27:51 +00:00
|
|
|
}
|
2011-09-18 21:59:23 +00:00
|
|
|
|
|
|
|
#endif // INCLUDED_MUSASHI68KDEBUG_H
|
|
|
|
#endif // SUPERMODEL_DEBUGGER
|