Line 1... |
Line 1... |
#include "stdafx.h"
|
#include "stdafx.h"
|
|
|
extern clsPIC pic1;
|
extern unsigned int breakpoints[30];
|
|
extern unsigned __int64 ibreakpoints[10];
|
|
extern bool ib_active[10];
|
|
extern bool isRunning;
|
|
extern bool stepout, stepover;
|
|
extern unsigned int step_depth, stepover_depth;
|
|
extern unsigned int stepoverBkpt;
|
|
extern unsigned int stepover_pc;
|
|
extern bool animate;
|
|
extern bool fullspeed;
|
|
extern bool runstop;
|
|
|
clsSystem::clsSystem() {
|
clsSystem::clsSystem() {
|
int nn;
|
int nn;
|
WriteROM = false;
|
WriteROM = false;
|
for (nn = 0; nn < sizeof(memory); nn+=8) {
|
for (nn = 0; nn < sizeof(memory); nn+=8) {
|
memory[nn>>3] = 0;
|
memory[nn>>3] = 0;
|
}
|
}
|
|
quit = false;
|
Reset();
|
Reset();
|
};
|
};
|
void clsSystem::Reset()
|
void clsSystem::Reset()
|
{
|
{
|
int nn;
|
int nn;
|
Line 21... |
Line 32... |
VideoMemDirty[nn] = true;
|
VideoMemDirty[nn] = true;
|
}
|
}
|
leds = 0;
|
leds = 0;
|
write_error = false;
|
write_error = false;
|
runstop = false;
|
runstop = false;
|
cpu1.system1 = this;
|
cpu2.system1 = this;
|
refscreen = true;
|
refscreen = true;
|
|
cpu2.Reset();
|
|
pic1.Reset();
|
|
uart1.Reset();
|
};
|
};
|
unsigned __int64 clsSystem::Read(unsigned int ad, int sr) {
|
unsigned __int64 clsSystem::Read(unsigned int ad, int sr) {
|
__int64 rr;
|
__int64 rr;
|
unsigned __int8 sc;
|
unsigned __int8 sc;
|
unsigned __int8 st;
|
unsigned __int8 st;
|
Line 72... |
Line 86... |
else if (pic1.IsSelected(ad)) {
|
else if (pic1.IsSelected(ad)) {
|
rr = pic1.Read(ad);
|
rr = pic1.Read(ad);
|
rr = (rr << 48) | (rr << 32) | (rr << 16) | rr;
|
rr = (rr << 48) | (rr << 32) | (rr << 16) | rr;
|
return rr;
|
return rr;
|
}
|
}
|
|
else if (uart1.IsSelected(ad)) {
|
|
rr = uart1.Read(ad) & 0xFF;
|
|
rr = (rr << 56) | (rr << 48) || (rr << 40) | (rr << 32)
|
|
| (rr << 24) | (rr << 16) | (rr << 8) | rr;
|
|
return rr;
|
|
}
|
return 0;
|
return 0;
|
};
|
};
|
int clsSystem::Write(unsigned int ad, unsigned __int64 dat, unsigned int mask, int cr) {
|
int clsSystem::Write(unsigned int ad, unsigned __int64 dat, unsigned int mask, int cr) {
|
int nn;
|
int nn;
|
int ret;
|
int ret;
|
Line 89... |
Line 109... |
radr1 = 0x00000000;
|
radr1 = 0x00000000;
|
if (ad==radr2)
|
if (ad==radr2)
|
radr2 = 0x00000000;
|
radr2 = 0x00000000;
|
}
|
}
|
if (ad < 134217728) {
|
if (ad < 134217728) {
|
if (ad >= 0x10000 && ad < 0x20000) {
|
if (ad >= 0xFFFC0000LL) {
|
write_error = true;
|
write_error = true;
|
ret = true;
|
ret = true;
|
goto j1;
|
goto j1;
|
}
|
}
|
if ((ad & 0xfffffff0)==0x00c431a0) {
|
if ((ad & 0xfffffff0)==0x00c431a0) {
|
Line 195... |
Line 215... |
else if ((ad & 0xFFFF0000)==0xFFD00000) {
|
else if ((ad & 0xFFFF0000)==0xFFD00000) {
|
VideoMem[(ad>>2)& 0xFFF] = dat;
|
VideoMem[(ad>>2)& 0xFFF] = dat;
|
VideoMemDirty[(ad>>2)&0xfff] = true;
|
VideoMemDirty[(ad>>2)&0xfff] = true;
|
refscreen = true;
|
refscreen = true;
|
}
|
}
|
|
else if ((ad & 0xFFFF0000)==0xFFD10000) {
|
|
DBGVideoMem[(ad>>2)& 0xFFF] = dat;
|
|
DBGVideoMemDirty[(ad>>2)&0xfff] = true;
|
|
refscreen = true;
|
|
}
|
else if ((ad & 0xFFFC0000)==0xFFFC0000 && WriteROM) {
|
else if ((ad & 0xFFFC0000)==0xFFFC0000 && WriteROM) {
|
rom[(ad&0x3FFFF)>>3] = dat;
|
rom[(ad&0x3FFFF)>>3] = dat;
|
}
|
}
|
else if (keybd.IsSelected(ad)) {
|
else if (keybd.IsSelected(ad)) {
|
switch(ad & 1) {
|
switch(ad & 1) {
|
Line 206... |
Line 231... |
}
|
}
|
}
|
}
|
else if (pic1.IsSelected(ad)) {
|
else if (pic1.IsSelected(ad)) {
|
pic1.Write(ad,dat,0x3);
|
pic1.Write(ad,dat,0x3);
|
}
|
}
|
|
else if (uart1.IsSelected(ad)) {
|
|
uart1.Write(ad,dat,0x1);
|
|
}
|
ret = true;
|
ret = true;
|
j1:
|
j1:
|
for (nn = 0; nn < numDataBreakpoints; nn++) {
|
for (nn = 0; nn < numDataBreakpoints; nn++) {
|
if (ad==dataBreakpoints[nn]) {
|
if (ad==dataBreakpoints[nn]) {
|
runstop = true;
|
runstop = true;
|
Line 225... |
Line 253... |
|
|
unsigned __int64 clsSystem::ReadByte(unsigned int ad) {
|
unsigned __int64 clsSystem::ReadByte(unsigned int ad) {
|
unsigned __int64 dat = Read(ad);
|
unsigned __int64 dat = Read(ad);
|
return (dat >> ((ad & 7) * 8)) & 0xFFLL;
|
return (dat >> ((ad & 7) * 8)) & 0xFFLL;
|
}
|
}
|
|
unsigned __int64 clsSystem::ReadChar(unsigned int ad) {
|
|
unsigned __int64 dat = Read(ad);
|
|
return (dat >> ((ad & 7) * 8)) & 0xFFFFLL;
|
|
}
|
|
unsigned __int64 clsSystem::ReadHalf(unsigned int ad) {
|
|
unsigned __int64 dat = Read(ad);
|
|
return (dat >> ((ad & 7) * 8)) & 0xFFFFFFFFLL;
|
|
}
|
|
|
|
|
|
void clsSystem::Step() {
|
|
uart1.Step();
|
|
keybd.Step();
|
|
pic1.Step();
|
|
cpu2.Step();
|
|
}
|
|
|
|
void clsSystem::Run() {
|
|
int nn,kk;
|
|
int xx;
|
|
|
|
do {
|
|
if (isRunning) {
|
|
// if (cpu2.pc > 134217727) {
|
|
if (cpu2.pc < 0xFFFC0000LL && cpu2.pc & 0x1000 != 0x1000) {
|
|
isRunning = false;
|
|
continue;
|
|
}
|
|
if (cpu2.pc == stepoverBkpt) {
|
|
stepoverBkpt = 0;
|
|
isRunning = false;
|
|
continue;
|
|
}
|
|
for (kk = 0; kk < 5; kk++) {
|
|
if (cpu2.pc == ibreakpoints[kk] && ib_active[kk]) {
|
|
isRunning = false;
|
|
continue;
|
|
}
|
|
}
|
|
if (system1.write_error==true) {
|
|
isRunning = false;
|
|
continue;
|
|
// this->lblWriteErr->Visible = true;
|
|
}
|
|
// Runstop becomes active when a data breakpoint is hit.
|
|
if (runstop) {
|
|
isRunning = false;
|
|
runstop = false;
|
|
continue;
|
|
}
|
|
cpu2.Step();
|
|
pic1.Step();
|
|
if (stepout) {
|
|
if (cpu2.sub_depth<step_depth) {
|
|
isRunning = false;
|
|
stepout = false;
|
|
continue;
|
|
}
|
|
}
|
|
if (stepover) {
|
|
if (cpu2.pc > stepover_pc && cpu2.sub_depth==stepover_depth) {
|
|
isRunning = false;
|
|
stepover = false;
|
|
continue;
|
|
}
|
|
}
|
|
/*
|
|
if (cpu2.pc == stepoverBkpt) {
|
|
stepoverBkpt = 0;
|
|
cpu2.isRunning = false;
|
|
UpdateListBox(cpu2.pc-32);
|
|
return;
|
|
}
|
|
for (kk = 0; kk < numBreakpoints; kk++) {
|
|
if (cpu2.pc == breakpoints[kk]) {
|
|
cpu2.isRunning = false;
|
|
UpdateListBox(cpu2.pc-32);
|
|
return;
|
|
}
|
|
}
|
|
cpu2.Step();
|
|
pic1.Step();
|
|
UpdateListBox(cpu2.pc-32);
|
|
*/
|
|
// UpdateListBox(cpu2.pc-32);
|
|
}
|
|
} while (false); // !quit
|
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|