openMSX
Classes | Public Types | Public Member Functions | Friends | List of all members
openmsx::MSXCPU Class Referencefinal

#include <MSXCPU.hh>

Inheritance diagram for openmsx::MSXCPU:
Inheritance graph
[legend]
Collaboration diagram for openmsx::MSXCPU:
Collaboration graph
[legend]

Public Types

enum  CPUType { CPU_Z80, CPU_R800 }
 

Public Member Functions

 MSXCPU (MSXMotherBoard &motherboard)
 
 ~MSXCPU ()
 
void doReset (EmuTime::param time)
 Reset CPU. More...
 
void setActiveCPU (CPUType cpu)
 Switch between Z80/R800. More...
 
void setDRAMmode (bool dram)
 Sets DRAM or ROM mode (influences memory access speed for R800). More...
 
void updateVisiblePage (byte page, byte primarySlot, byte secondarySlot)
 Inform CPU of bank switch. More...
 
void invalidateMemCache (word start, unsigned size)
 Invalidate the CPU its cache for the interval [start, start + size) For example MSXMemoryMapper and MSXGameCartrigde need to call this method when a 'memory switch' occurs. More...
 
void raiseIRQ ()
 This method raises a maskable interrupt. More...
 
void lowerIRQ ()
 This methods lowers the maskable interrupt again. More...
 
void raiseNMI ()
 This method raises a non-maskable interrupt. More...
 
void lowerNMI ()
 This methods lowers the non-maskable interrupt again. More...
 
bool isM1Cycle (unsigned address) const
 Should only be used from within a MSXDevice::readMem() method. More...
 
void exitCPULoopSync ()
 See CPUCore::exitCPULoopsync() More...
 
void exitCPULoopAsync ()
 See CPUCore::exitCPULoopAsync() More...
 
bool isR800Active () const
 Is the R800 currently active? More...
 
void setZ80Freq (unsigned freq)
 Switch the Z80 clock freq. More...
 
void setInterface (MSXCPUInterface *interf)
 
void disasmCommand (Interpreter &interp, array_ref< TclObject > tokens, TclObject &result) const
 
void setPaused (bool paused)
 (un)pause CPU. More...
 
void setNextSyncPoint (EmuTime::param time)
 
void wait (EmuTime::param time)
 
EmuTime waitCycles (EmuTime::param time, unsigned cycles)
 
EmuTime waitCyclesR800 (EmuTime::param time, unsigned cycles)
 
CPURegsgetRegisters ()
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Friends

class MSXMotherBoard
 

Detailed Description

Definition at line 27 of file MSXCPU.hh.

Member Enumeration Documentation

◆ CPUType

Enumerator
CPU_Z80 
CPU_R800 

Definition at line 30 of file MSXCPU.hh.

Constructor & Destructor Documentation

◆ MSXCPU()

openmsx::MSXCPU::MSXCPU ( MSXMotherBoard motherboard)
explicit

◆ ~MSXCPU()

openmsx::MSXCPU::~MSXCPU ( )

Member Function Documentation

◆ disasmCommand()

void openmsx::MSXCPU::disasmCommand ( Interpreter interp,
array_ref< TclObject tokens,
TclObject result 
) const

Definition at line 221 of file MSXCPU.cc.

Referenced by isR800Active().

◆ doReset()

void openmsx::MSXCPU::doReset ( EmuTime::param  time)

Reset CPU.

Requires CPU is not in the middle of an instruction, so exitCPULoop was called and execute() method returned.

Definition at line 80 of file MSXCPU.cc.

Referenced by openmsx::MSXMotherBoard::doReset(), and openmsx::MSXMotherBoard::powerUp().

◆ exitCPULoopAsync()

void openmsx::MSXCPU::exitCPULoopAsync ( )

◆ exitCPULoopSync()

void openmsx::MSXCPU::exitCPULoopSync ( )

See CPUCore::exitCPULoopsync()

Definition at line 118 of file MSXCPU.cc.

Referenced by openmsx::MSXCPUInterface::doBreak(), openmsx::MSXMotherBoard::exitCPULoopSync(), getRegisters(), and setActiveCPU().

◆ getRegisters()

CPURegs & openmsx::MSXCPU::getRegisters ( )

Definition at line 203 of file MSXCPU.cc.

References exitCPULoopSync().

Referenced by isR800Active().

◆ invalidateMemCache()

void openmsx::MSXCPU::invalidateMemCache ( word  start,
unsigned  size 
)

◆ isM1Cycle()

bool openmsx::MSXCPU::isM1Cycle ( unsigned  address) const

Should only be used from within a MSXDevice::readMem() method.

Returns true if that read was the first byte of an instruction (the Z80 M1 pin is active). This implementation is not 100% accurate, but good enough for now.

Definition at line 174 of file MSXCPU.cc.

Referenced by openmsx::RomRamFile::readMem().

◆ isR800Active()

bool openmsx::MSXCPU::isR800Active ( ) const
inline

◆ lowerIRQ()

void openmsx::MSXCPU::lowerIRQ ( )

This methods lowers the maskable interrupt again.

A device may never call this method more often than it called the method raiseIRQ(). Before using this method take a look at IRQHelper.

Definition at line 158 of file MSXCPU.cc.

Referenced by openmsx::IRQSource::lower(), and openmsx::OptionalIRQ::lower().

◆ lowerNMI()

void openmsx::MSXCPU::lowerNMI ( )

This methods lowers the non-maskable interrupt again.

A device may never call this method more often than it called the method raiseNMI(). Before using this method take a look at IRQHelper.

Definition at line 168 of file MSXCPU.cc.

◆ raiseIRQ()

void openmsx::MSXCPU::raiseIRQ ( )

This method raises a maskable interrupt.

A device may call this method more than once. If the device wants to lower the interrupt again it must call the lowerIRQ() method exactly as many times. Before using this method take a look at IRQHelper.

Definition at line 153 of file MSXCPU.cc.

Referenced by openmsx::IRQSource::raise(), and openmsx::OptionalIRQ::raise().

◆ raiseNMI()

void openmsx::MSXCPU::raiseNMI ( )

This method raises a non-maskable interrupt.

A device may call this method more than once. If the device wants to lower the interrupt again it must call the lowerNMI() method exactly as many times. Before using this method take a look at IRQHelper.

Definition at line 163 of file MSXCPU.cc.

◆ serialize()

template<typename Archive >
void openmsx::MSXCPU::serialize ( Archive &  ar,
unsigned  version 
)

Definition at line 396 of file MSXCPU.cc.

Referenced by isR800Active().

◆ setActiveCPU()

void openmsx::MSXCPU::setActiveCPU ( CPUType  cpu)

Switch between Z80/R800.

Definition at line 88 of file MSXCPU.cc.

References CPU_R800, CPU_Z80, and exitCPULoopSync().

Referenced by openmsx::MSXS1990::writeIO().

◆ setDRAMmode()

void openmsx::MSXCPU::setDRAMmode ( bool  dram)

Sets DRAM or ROM mode (influences memory access speed for R800).

Definition at line 99 of file MSXCPU.cc.

References invalidateMemCache().

Referenced by openmsx::MSXS1990::writeIO().

◆ setInterface()

void openmsx::MSXCPU::setInterface ( MSXCPUInterface interf)

◆ setNextSyncPoint()

void openmsx::MSXCPU::setNextSyncPoint ( EmuTime::param  time)

◆ setPaused()

void openmsx::MSXCPU::setPaused ( bool  paused)

(un)pause CPU.

During pause the CPU executes NOP instructions continuously (just like during HALT). Used by turbor hw pause.

Definition at line 229 of file MSXCPU.cc.

References openmsx::CPURegs::getA(), openmsx::CPURegs::getA2(), openmsx::CPURegs::getB(), openmsx::CPURegs::getB2(), openmsx::CPURegs::getC(), openmsx::CPURegs::getC2(), openmsx::CPURegs::getD(), openmsx::CPURegs::getD2(), openmsx::CPURegs::getE(), openmsx::CPURegs::getE2(), openmsx::CPURegs::getF(), openmsx::CPURegs::getF2(), openmsx::CPURegs::getH(), openmsx::CPURegs::getH2(), openmsx::CPURegs::getI(), openmsx::CPURegs::getIFF1(), openmsx::CPURegs::getIFF2(), openmsx::CPURegs::getIM(), openmsx::CPURegs::getIXh(), openmsx::CPURegs::getIXl(), openmsx::CPURegs::getIYh(), openmsx::CPURegs::getIYl(), openmsx::CPURegs::getL(), openmsx::CPURegs::getL2(), openmsx::CPURegs::getPCh(), openmsx::CPURegs::getPCl(), openmsx::CPURegs::getR(), openmsx::CPURegs::getSPh(), openmsx::CPURegs::getSPl(), OUTER, openmsx::CPURegs::prevWasEI(), openmsx::CPURegs::setA(), openmsx::CPURegs::setA2(), openmsx::CPURegs::setB(), openmsx::CPURegs::setB2(), openmsx::CPURegs::setC(), openmsx::CPURegs::setC2(), openmsx::CPURegs::setD(), openmsx::CPURegs::setD2(), openmsx::TclObject::setDouble(), openmsx::CPURegs::setE(), openmsx::CPURegs::setE2(), openmsx::CPURegs::setF(), openmsx::CPURegs::setF2(), openmsx::CPURegs::setH(), openmsx::CPURegs::setH2(), openmsx::CPURegs::setI(), openmsx::CPURegs::setIFF1(), openmsx::CPURegs::setIFF2(), openmsx::CPURegs::setIM(), openmsx::TclObject::setInt(), openmsx::CPURegs::setIXh(), openmsx::CPURegs::setIXl(), openmsx::CPURegs::setIYh(), openmsx::CPURegs::setIYl(), openmsx::CPURegs::setL(), openmsx::CPURegs::setL2(), openmsx::CPURegs::setPCh(), openmsx::CPURegs::setPCl(), openmsx::CPURegs::setR(), openmsx::CPURegs::setSPh(), openmsx::CPURegs::setSPl(), openmsx::EmuDuration::toDouble(), and UNREACHABLE.

Referenced by isR800Active(), openmsx::MSXMotherBoard::pause(), and openmsx::MSXMotherBoard::unpause().

◆ setZ80Freq()

void openmsx::MSXCPU::setZ80Freq ( unsigned  freq)

Switch the Z80 clock freq.

Definition at line 180 of file MSXCPU.cc.

Referenced by isR800Active(), openmsx::MSXCielTurbo::writeIO(), and openmsx::MSXMatsushita::writeSwitchedIO().

◆ updateVisiblePage()

void openmsx::MSXCPU::updateVisiblePage ( byte  page,
byte  primarySlot,
byte  secondarySlot 
)

Inform CPU of bank switch.

This will invalidate memory cache and update memory timings on R800.

Definition at line 141 of file MSXCPU.cc.

References invalidateMemCache().

Referenced by openmsx::MSXCPUInterface::unregisterGlobalWrite().

◆ wait()

void openmsx::MSXCPU::wait ( EmuTime::param  time)

◆ waitCycles()

EmuTime openmsx::MSXCPU::waitCycles ( EmuTime::param  time,
unsigned  cycles 
)

Definition at line 191 of file MSXCPU.cc.

Referenced by isR800Active(), and openmsx::VDP::writeIO().

◆ waitCyclesR800()

EmuTime openmsx::MSXCPU::waitCyclesR800 ( EmuTime::param  time,
unsigned  cycles 
)

Friends And Related Function Documentation

◆ MSXMotherBoard

friend class MSXMotherBoard
friend

Definition at line 124 of file MSXCPU.hh.


The documentation for this class was generated from the following files: