2016-03-14 04:28:53 +00:00
|
|
|
#ifndef VMACHINE_H
|
|
|
|
#define VMACHINE_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <queue>
|
|
|
|
#include "system.h"
|
|
|
|
#include "MKCpu.h"
|
|
|
|
#include "Memory.h"
|
|
|
|
#include "Display.h"
|
|
|
|
|
|
|
|
//#define WINDOWS 1
|
|
|
|
#if defined (WINDOWS)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define IOREFRESH 32
|
|
|
|
#define OPINTERRUPT 25 // operator interrupt code (CTRL-Y)
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace MKBasic {
|
|
|
|
|
|
|
|
class VMachine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VMachine();
|
|
|
|
VMachine(string romfname, string ramfname);
|
|
|
|
~VMachine();
|
|
|
|
|
|
|
|
void InitVM();
|
|
|
|
Regs *Run();
|
|
|
|
Regs *Run(unsigned short addr);
|
|
|
|
Regs *Exec();
|
|
|
|
Regs *Exec(unsigned short addr);
|
|
|
|
Regs *Step();
|
|
|
|
Regs *Step(unsigned short addr);
|
|
|
|
void LoadROM(string romfname);
|
|
|
|
void LoadRAM(string ramfname);
|
|
|
|
void LoadRAMBin(string ramfname);
|
|
|
|
unsigned short MemPeek8bit(unsigned short addr);
|
|
|
|
void MemPoke8bit(unsigned short addr, unsigned char v);
|
|
|
|
Regs *GetRegs();
|
|
|
|
void SetCharIO(unsigned short addr, bool echo);
|
|
|
|
void DisableCharIO();
|
|
|
|
unsigned short GetCharIOAddr();
|
|
|
|
bool GetCharIOActive();
|
|
|
|
void ShowIO();
|
|
|
|
void ClearScreen();
|
|
|
|
void ScrHome();
|
|
|
|
bool IsAutoExec();
|
|
|
|
void EnableROM();
|
|
|
|
void DisableROM();
|
|
|
|
void SetROM(unsigned short start, unsigned short end);
|
|
|
|
void EnableROM(unsigned short start, unsigned short end);
|
|
|
|
unsigned short GetROMBegin();
|
|
|
|
unsigned short GetROMEnd();
|
|
|
|
bool IsROMEnabled();
|
|
|
|
unsigned short GetRunAddr();
|
|
|
|
void SetOpInterrupt(bool opint);
|
|
|
|
bool IsOpInterrupt();
|
|
|
|
queue<string> GetExecHistory();
|
|
|
|
unsigned short Disassemble(unsigned short addr, char *buf);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MKCpu *mpCPU;
|
|
|
|
Memory *mpROM;
|
|
|
|
Memory *mpRAM;
|
|
|
|
Display *mpDisp;
|
|
|
|
unsigned short mRunAddr;
|
|
|
|
unsigned short mCharIOAddr;
|
|
|
|
bool mCharIOActive;
|
|
|
|
bool mCharIO;
|
|
|
|
bool mOpInterrupt; // operator interrupt from console
|
|
|
|
bool mAutoExec;
|
|
|
|
|
|
|
|
void LoadMEM(string memfname, Memory *pmem);
|
|
|
|
void ShowDisp();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace MKBasic
|
|
|
|
|
|
|
|
#endif
|