Supermodel/Src/Debugger/CPU/Musashi68KDebug.h

118 lines
2.6 KiB
C
Raw Permalink Normal View History

/**
** 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
*/
#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
{
/*
* CCPUDebug implementation for the Musashi Motorola 68000 emulator.
*/
class CMusashi68KDebug : public C68KDebug, public ::IBus
{
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;
::IBus *m_bus;
2018-01-22 18:27:51 +00:00
// Inlined methods
2018-01-22 21:10:20 +00:00
void SetM68KContext()
2018-01-22 18:27:51 +00:00
{
M68KGetContext(&m_savedCtx);
if (m_savedCtx.Debug != this)
M68KSetContext(m_ctx);
}
2018-01-22 21:10:20 +00:00
void UpdateM68KContext(M68KCtx *ctx)
2018-01-22 18:27:51 +00:00
{
m_ctx = ctx;
}
2018-01-22 21:10:20 +00:00
void RestoreM68KContext()
2018-01-22 18:27:51 +00:00
{
if (m_savedCtx.Debug != this)
M68KSetContext(&m_savedCtx);
}
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);
// IBus methods
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
}
#endif // INCLUDED_MUSASHI68KDEBUG_H
#endif // SUPERMODEL_DEBUGGER