More 8080 opcodes
This commit is contained in:
parent
5558a581d7
commit
eba9428fbf
4 changed files with 1220 additions and 282 deletions
|
|
@ -699,6 +699,901 @@ CPUDef.opCMC = function()
|
|||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x40 (MOV B,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBB = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x41 (MOV B,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBC = function()
|
||||
{
|
||||
this.regB = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x42 (MOV B,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBD = function()
|
||||
{
|
||||
this.regB = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x43 (MOV B,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBE = function()
|
||||
{
|
||||
this.regB = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x44 (MOV B,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBH = function()
|
||||
{
|
||||
this.regB = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x45 (MOV B,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBL = function()
|
||||
{
|
||||
this.regB = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x46 (MOV B,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBM = function()
|
||||
{
|
||||
this.regB = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x47 (MOV B,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVBA = function()
|
||||
{
|
||||
this.regB = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x48 (MOV C,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCB = function()
|
||||
{
|
||||
this.regC = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x49 (MOV C,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCC = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4A (MOV C,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCD = function()
|
||||
{
|
||||
this.regC = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4B (MOV C,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCE = function()
|
||||
{
|
||||
this.regC = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4C (MOV C,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCH = function()
|
||||
{
|
||||
this.regC = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4D (MOV C,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCL = function()
|
||||
{
|
||||
this.regC = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4E (MOV C,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCM = function()
|
||||
{
|
||||
this.regC = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x4F (MOV C,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVCA = function()
|
||||
{
|
||||
this.regC = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x50 (MOV D,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDB = function()
|
||||
{
|
||||
this.regD = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x51 (MOV D,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDC = function()
|
||||
{
|
||||
this.regD = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x52 (MOV D,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDD = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x53 (MOV D,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDE = function()
|
||||
{
|
||||
this.regD = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x54 (MOV D,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDH = function()
|
||||
{
|
||||
this.regD = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x55 (MOV D,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDL = function()
|
||||
{
|
||||
this.regD = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x56 (MOV D,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDM = function()
|
||||
{
|
||||
this.regD = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x57 (MOV D,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVDA = function()
|
||||
{
|
||||
this.regD = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x58 (MOV E,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEB = function()
|
||||
{
|
||||
this.regE = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x59 (MOV E,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEC = function()
|
||||
{
|
||||
this.regE = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5A (MOV E,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVED = function()
|
||||
{
|
||||
this.regE = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5B (MOV E,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEE = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5C (MOV E,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEH = function()
|
||||
{
|
||||
this.regE = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5D (MOV E,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEL = function()
|
||||
{
|
||||
this.regE = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5E (MOV E,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEM = function()
|
||||
{
|
||||
this.regE = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x5F (MOV E,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVEA = function()
|
||||
{
|
||||
this.regE = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x60 (MOV H,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHB = function()
|
||||
{
|
||||
this.regH = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x61 (MOV H,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHC = function()
|
||||
{
|
||||
this.regH = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x62 (MOV H,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHD = function()
|
||||
{
|
||||
this.regH = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x63 (MOV H,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHE = function()
|
||||
{
|
||||
this.regH = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x64 (MOV H,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHH = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x65 (MOV H,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHL = function()
|
||||
{
|
||||
this.regH = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x66 (MOV H,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHM = function()
|
||||
{
|
||||
this.regH = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x67 (MOV H,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVHA = function()
|
||||
{
|
||||
this.regH = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x68 (MOV L,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLB = function()
|
||||
{
|
||||
this.regL = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x69 (MOV L,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLC = function()
|
||||
{
|
||||
this.regL = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6A (MOV L,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLD = function()
|
||||
{
|
||||
this.regL = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6B (MOV L,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLE = function()
|
||||
{
|
||||
this.regL = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6C (MOV L,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLH = function()
|
||||
{
|
||||
this.regL = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6D (MOV L,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLL = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6E (MOV L,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLM = function()
|
||||
{
|
||||
this.regL = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x6F (MOV L,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVLA = function()
|
||||
{
|
||||
this.regL = this.regA;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x70 (MOV M,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVMB = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regB);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x71 (MOV M,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVMC = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regC);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x72 (MOV M,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVMD = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regD);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x73 (MOV M,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVME = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regE);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x74 (MOV M,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVMH = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regH);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x75 (MOV M,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVML = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regL);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x76 (HLT)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opHLT = function()
|
||||
{
|
||||
/*
|
||||
* The CPU is never REALLY halted by a HLT instruction; instead, by setting X86.INTFLAG.HALT,
|
||||
* we are signalling to stepCPU() that it's free to end the current burst AND that it should not
|
||||
* execute any more instructions until checkINTR() indicates a hardware interrupt is requested.
|
||||
*/
|
||||
this.intFlags |= CPUDef.INTFLAG.HALT;
|
||||
this.nStepCycles -= 7;
|
||||
/*
|
||||
* If a Debugger is present and the HALT message category is enabled, then we REALLY halt the CPU,
|
||||
* on the theory that whoever's using the Debugger would like to see HLTs.
|
||||
*/
|
||||
if (DEBUGGER && this.dbg && this.messageEnabled(Messages.HALT)) {
|
||||
this.setPC(this.getPC() - 1); // this is purely for the Debugger's benefit, to show the HLT
|
||||
this.dbg.stopCPU();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* We also REALLY halt the machine if interrupts have been disabled, since that means it's dead
|
||||
* in the water (we have no NMI generation mechanism at the moment).
|
||||
*/
|
||||
if (!this.getIF()) {
|
||||
if (DEBUGGER && this.dbg) this.setPC(this.getPC() - 1);
|
||||
this.stopCPU();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x77 (MOV M,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVMA = function()
|
||||
{
|
||||
this.setByte(this.getHL(), this.regA);
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x78 (MOV A,B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAB = function()
|
||||
{
|
||||
this.regA = this.regB;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x79 (MOV A,C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAC = function()
|
||||
{
|
||||
this.regA = this.regC;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7A (MOV A,D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAD = function()
|
||||
{
|
||||
this.regA = this.regD;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7B (MOV A,E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAE = function()
|
||||
{
|
||||
this.regA = this.regE;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7C (MOV A,H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAH = function()
|
||||
{
|
||||
this.regA = this.regH;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7D (MOV A,L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAL = function()
|
||||
{
|
||||
this.regA = this.regL;
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7E (MOV A,M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAM = function()
|
||||
{
|
||||
this.regA = this.getByte(this.getHL());
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x7F (MOV A,A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opMOVAA = function()
|
||||
{
|
||||
this.nStepCycles -= 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x80 (ADD B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDB = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regB);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x81 (ADD C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDC = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regC);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x82 (ADD D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDD = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regD);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x83 (ADD E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDE = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regE);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x84 (ADD H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDH = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regH);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x85 (ADD L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDL = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regL);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x86 (ADD M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDM = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.getByte(this.getHL()));
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x87 (ADD A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADDA = function()
|
||||
{
|
||||
this.regA = this.addByte(this.regA, this.regA);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x88 (ADC B)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCB = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regB);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x89 (ADC C)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCC = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regC);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8A (ADC D)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCD = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regD);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8B (ADC E)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCE = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regE);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8C (ADC H)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCH = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regH);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8D (ADC L)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCL = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regL);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8E (ADC M)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCM = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.getByte(this.getHL()));
|
||||
this.nStepCycles -= 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* op=0x8F (ADC A)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
*/
|
||||
CPUDef.opADCA = function()
|
||||
{
|
||||
this.regA = this.addByteCarry(this.regA, this.regA);
|
||||
this.nStepCycles -= 4;
|
||||
};
|
||||
|
||||
/**
|
||||
* opTBD()
|
||||
*
|
||||
|
|
@ -735,26 +1630,26 @@ CPUDef.aOps = [
|
|||
/* 0x34-0x37 */ CPUDef.opINRM, CPUDef.opDCRM, CPUDef.opMVIM, CPUDef.opSTC,
|
||||
/* 0x38-0x3B */ CPUDef.opNOP, CPUDef.opDADSP, CPUDef.opLDA, CPUDef.opDCXSP,
|
||||
/* 0x3C-0x3F */ CPUDef.opINRA, CPUDef.opDCRA, CPUDef.opMVIA, CPUDef.opCMC,
|
||||
/* 0x40-0x43 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x44-0x47 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x48-0x4B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x4C-0x4F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x50-0x53 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x54-0x57 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x58-0x5B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x5C-0x5F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x60-0x63 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x64-0x67 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x68-0x6B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x6C-0x6F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x70-0x73 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x74-0x77 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x78-0x7B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x7C-0x7F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x80-0x83 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x84-0x87 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x88-0x8B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x8C-0x8F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x40-0x43 */ CPUDef.opMOVBB, CPUDef.opMOVBC, CPUDef.opMOVBD, CPUDef.opMOVBE,
|
||||
/* 0x44-0x47 */ CPUDef.opMOVBH, CPUDef.opMOVBL, CPUDef.opMOVBM, CPUDef.opMOVBA,
|
||||
/* 0x48-0x4B */ CPUDef.opMOVCB, CPUDef.opMOVCC, CPUDef.opMOVCD, CPUDef.opMOVCE,
|
||||
/* 0x4C-0x4F */ CPUDef.opMOVCH, CPUDef.opMOVCL, CPUDef.opMOVCM, CPUDef.opMOVCA,
|
||||
/* 0x50-0x53 */ CPUDef.opMOVDB, CPUDef.opMOVDC, CPUDef.opMOVDD, CPUDef.opMOVDE,
|
||||
/* 0x54-0x57 */ CPUDef.opMOVDH, CPUDef.opMOVDL, CPUDef.opMOVDM, CPUDef.opMOVDA,
|
||||
/* 0x58-0x5B */ CPUDef.opMOVEB, CPUDef.opMOVEC, CPUDef.opMOVED, CPUDef.opMOVEE,
|
||||
/* 0x5C-0x5F */ CPUDef.opMOVEH, CPUDef.opMOVEL, CPUDef.opMOVEM, CPUDef.opMOVEA,
|
||||
/* 0x60-0x63 */ CPUDef.opMOVHB, CPUDef.opMOVHC, CPUDef.opMOVHD, CPUDef.opMOVHE,
|
||||
/* 0x64-0x67 */ CPUDef.opMOVHH, CPUDef.opMOVHL, CPUDef.opMOVHM, CPUDef.opMOVHA,
|
||||
/* 0x68-0x6B */ CPUDef.opMOVLB, CPUDef.opMOVLC, CPUDef.opMOVLD, CPUDef.opMOVLE,
|
||||
/* 0x6C-0x6F */ CPUDef.opMOVLH, CPUDef.opMOVLL, CPUDef.opMOVLM, CPUDef.opMOVLA,
|
||||
/* 0x70-0x73 */ CPUDef.opMOVMB, CPUDef.opMOVMC, CPUDef.opMOVMD, CPUDef.opMOVME,
|
||||
/* 0x74-0x77 */ CPUDef.opMOVMH, CPUDef.opMOVML, CPUDef.opHLT, CPUDef.opMOVMA,
|
||||
/* 0x78-0x7B */ CPUDef.opMOVAB, CPUDef.opMOVAC, CPUDef.opMOVAD, CPUDef.opMOVAE,
|
||||
/* 0x7C-0x7F */ CPUDef.opMOVAH, CPUDef.opMOVAL, CPUDef.opMOVAM, CPUDef.opMOVAA,
|
||||
/* 0x80-0x83 */ CPUDef.opADDB, CPUDef.opADDC, CPUDef.opADDD, CPUDef.opADDE,
|
||||
/* 0x84-0x87 */ CPUDef.opADDH, CPUDef.opADDL, CPUDef.opADDM, CPUDef.opADDA,
|
||||
/* 0x88-0x8B */ CPUDef.opADCB, CPUDef.opADCC, CPUDef.opADCD, CPUDef.opADCE,
|
||||
/* 0x8C-0x8F */ CPUDef.opADCH, CPUDef.opADCL, CPUDef.opADCM, CPUDef.opADCA,
|
||||
/* 0x90-0x93 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x94-0x97 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
/* 0x98-0x9B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD,
|
||||
|
|
|
|||
|
|
@ -749,6 +749,34 @@ CPUSim.prototype.decByte = function(b)
|
|||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* addByte(dst, src)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
* @param {number} dst
|
||||
* @param {number} src
|
||||
* @return {number} dst + src
|
||||
*/
|
||||
CPUSim.prototype.addByte = function(dst, src)
|
||||
{
|
||||
this.resultAuxOverflow = dst ^ src;
|
||||
return (this.resultZeroCarry = this.resultParitySign = dst + src) & 0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
* addByteCarry(dst, src)
|
||||
*
|
||||
* @this {CPUSim}
|
||||
* @param {number} dst
|
||||
* @param {number} src
|
||||
* @return {number} dst + src + carry
|
||||
*/
|
||||
CPUSim.prototype.addByteCarry = function(dst, src)
|
||||
{
|
||||
this.resultAuxOverflow = dst ^ src;
|
||||
return (this.resultZeroCarry = this.resultParitySign = dst + src + ((this.resultZeroCarry & 0x100)? 1 : 0)) & 0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
* getByte(addr)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,171 +1,179 @@
|
|||
(function(){var k;function fa(a,b){var c;if(a){b||(b=16);if("$"==a.charAt(0))b=16,a=a.substr(1);else if("0x"==a.substr(0,2))b=16,a=a.substr(2);else{var d=a.charAt(a.length-1).toLowerCase();"h"==d?(b=16,d=null):"."==d&&(b=10,d=null);null==d&&(a=a.substr(0,a.length-1))}var e,d=a,f=b;(f&&10!=f?16==f?null!==d.match(/^[0-9a-f]+$/i):2==f&&null!==d.match(/^[01]+$/i):null!==d.match(/^[0-9]+$/))&&!isNaN(e=parseInt(a,b))&&(c=e|0)}return c}
|
||||
function n(a,b){var c="";void 0===b?b=8:8<b&&(b=8);if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;){var d=a&15,d=d+(0<=d&&9>=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function q(a){return"0x"+n(a,4)}function ga(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0<d&&(c=c.substr(0,d));b&&(d=c.lastIndexOf("."),0<d&&(c=c.substring(0,d)));return c}function ha(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}
|
||||
function ia(a,b){return-1!==a.indexOf(b,a.length-b.length)}var ja={"&":"&","<":"<",">":">",'"':""","'":"'"};function ka(a){return a.replace(/[&<>"']/g,function(a){return ja[a]})}function la(a,b){return(a+" ").slice(0,b)}function qa(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
|
||||
function ra(a,b,c){var d=0,e=a.length,f=0;for(void 0===c&&(c=function(a,b){return a>b?1:a<b?-1:0});d<e;){var h=d+e>>1,g;g=c(b,a[h]);0<g?d=h+1:(e=h,f=!g)}return f?d:~d}var sa=Date.now||function(){return+new Date};function ta(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function ya(a,b){var c;if(Array.prototype.indexOf)return a.indexOf(b,c);c=c||0;0>c&&(c+=a.length);0>c&&(c=0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return c;return-1}
|
||||
function u(a,b,c,d){var e=0,f=null,h=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),d&&d(a,f,e))});if(b&&"object"==
|
||||
typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");g.open("POST",a,!!c);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(l)}else g.open("GET",a,!!c),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();c||(f=g.responseText,200!=g.status&&(e=g.status||-1),d&&d(a,f,e),h=[f,e]);return h}function za(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function Aa(){return window?window.navigator.userAgent:""}function v(a){window&&window.alert(a)}function Ba(a){var b=!1;window&&(b=window.confirm(a));return b}var Ca=null;function Da(){if(null==Ca){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Ca=a}return Ca}
|
||||
function Ea(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function Fa(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Ga(a){if(window){var b=Aa();return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}function Ha(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}
|
||||
function Ia(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,f=!1;a.onmousedown=function(){f||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}var Ja={init:[],show:[],exit:[]},Na=!1,Qa=!0;function Ra(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Sa(a){Ja.init.push(a)}
|
||||
function Ta(a){if(Qa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){v("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.")}}function Ua(a){!Qa&&a?(Qa=!0,Na&&Va("init")):Qa=a}function Va(a){Ja[a]&&Ta(Ja[a])}Ra("onload",function(){Na=!0;Ta(Ja.init)});Ra("onpageshow",function(){Ta(Ja.show)});Ra(Ga("Opera")||Ga("iOS")?"onunload":"onbeforeunload",function(){Ta(Ja.exit)});
|
||||
function x(a,b,c,d){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.wb=b.comment;this.Lb=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Ab=this.id.substr(0,b),this.Xa=this.id.substr(b+1)):this.Xa=this.id;this[a]=c;this.j={Ka:!1,Ha:!1,ob:!1,W:!1,Ja:!1};this.lb=null;this.j.Ja=!1;this.H={};this.C=null;this.Y=d||0;y.push(this)}var Wa=void 0,Xa={};
|
||||
if(window){Wa||(Wa=window.location.search.substr(1));for(var Ya,Za=/\+/g,$a=/([^&=]+)=?([^&]*)/g;Ya=$a.exec(Wa);)Xa[decodeURIComponent(Ya[1].replace(Za," "))]=decodeURIComponent(Ya[2].replace(Za," "))}function ab(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
|
||||
function z(a,b){b||(b=x);a.prototype=ab(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var y=[],bb={};function cb(a,b,c){bb[a]&&b&&(bb[a][b]=c)}function C(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<y.length;b++){var d=y[b];a&&d.id.indexOf(a)||c.push(d)}return c}
|
||||
function db(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<y.length;d++)if(c)c==y[d]&&(c=null);else if(!(a!=y[d].type||b&&y[d].id.indexOf(b)))return y[d]}return null}function E(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){v(c.message+" ("+a+")")}return b}
|
||||
function eb(a,b){for(var c=F(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var l=g.split(" "),m=0;m<l.length;m++)switch(g=l[m],g){case "pc8080-binding":(g=E(h))&&g.binding&&a.la(g.type,g.binding,h,g.value),m=l.length}}}}
|
||||
function F(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
|
||||
x.prototype={constructor:x,parent:null,toString:function(){return this.name?this.name:this.id||this.type},la:function(a,b,c){switch(b){case "clear":return this.H[b]||(this.H[b]=c,c.onclick=function(a){return function(){a.H.print&&(a.H.print.value="")}}(this)),!0;case "print":return this.H[b]||(this.za=this.H[b]=c,c.value="",this.g=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
|
||||
this.fa=function(a,b,c){this.g(a,"notice",c)}),!0;default:return!1}},log:function(){},g:function(){},status:function(a){this.g(this.Xa+": "+a)},fa:function(a,b){b||v(a)},ta:function(){return this.j.W=!0},sa:function(a,b){b&&(this.j.W=!1);return!0}};function fb(a,b,c){a.C&&(!0===c||gb(a,c|0))&&a.C.message(b,void 0)}function gb(a,b){if(a.C){a===a.C?b|=0:b=b||a.Y;var c=a.C.Y&b;return!!b&&c===b||!!(c&a.C.Sb)}return!1}
|
||||
function hb(a,b){if(a.j.ob)return a.j.Ha&&(a.j.Ha=!1),a.j.ob=!1;if(a.j.Ja)return a.g(a.toString()+" error"),!1;a.j.Ha=b;return a.j.Ha}function ib(a,b){a.j.Ha&&(b?a.j.ob=!0:void 0===b&&a.g(a.toString()+" busy"));return a.j.Ha}function G(a){if(!a.j.Ja&&(a.j.Ka=!0,a.j.Ka)){var b=a.lb;a.lb=null;b&&b()}}function tb(a,b){b&&(a.j.Ka?b():a.lb=b);return a.j.Ka}function ub(a,b){a.j.Ja=!0;a.fa(b)}
|
||||
var vb="undefined"!==typeof ArrayBuffer,wb=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
|
||||
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function xb(a){x.call(this,"Panel",a,xb)}z(xb);k=xb.prototype;k.la=function(a,b,c,d){return this.s&&this.s.la(a,b,c,d)||this.b&&this.b.la(a,b,c,d)||this.w&&this.w.la(a,b,c,d)||this.C&&this.C.la(a,b,c,d)?!0:this.parent.la.call(this,a,b,c,d)};k.La=function(a,b,c,d){this.s=a;this.A=b;this.b=c;this.C=d;this.w=yb(a,"Keyboard")};k.ta=function(a,b){b||zb();return!0};k.sa=function(){return!0};k.ma=function(){};
|
||||
function zb(){for(var a=!1,b=F(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=E(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<y.length;h++)if(y[h].id===f){f=y[h];break a}f=null}f||(a=!0,f=new xb(e));eb(f,d);a&&G(f)}}Sa(zb);
|
||||
function Ab(a,b,c){x.call(this,"Bus",a,Ab);this.b=b;this.C=c;this.L=a.buswidth||16;this.O=Math.pow(2,this.L);this.w=this.O-1|0;this.R=20>=this.L?12:24>=this.L?14:15;this.Z=1<<this.R;this.S=this.Z>>2;this.s=this.Z-1;this.J=this.O/this.Z|0;this.N=this.J-1;this.B=[];this.F=[];this.G=this.I=!1;this.T=[];this.V=[];a=new H;Bb(a,this.C);this.A=Array(this.J);for(b=0;b<this.J;b++)this.A[b]=a;a=this.b;b=this.A;c=this.R;var d=this.w;a.ea=b;a.R=c;a.Z=1<<a.R;a.G=a.Z-1;a.T=b.length;a.S=a.T-1;a.L=d;G(this)}z(Ab);
|
||||
Ab.prototype.reset=function(){};Ab.prototype.ta=function(a,b){b||this.reset();return!0};function Cb(a,b,c,d){for(var e=b>>>a.R;0<c&&e<a.A.length;){var f=a.A[e],h=e*a.Z,g=c>a.Z?a.Z:c;if(f&&f.size){if(f.type==d){if(b+c<=f.u)return f.hb+=f.u-b,f.u=b,!0;if(b>=f.u+f.hb){g=f.size-(b-h);g>c&&(g=c);f.hb=b-f.u+g;c-=g;b=h+a.Z;continue}}return Db(1,b,c)}f=a.A[e];b=new H(b,g,a.Z,d);Bb(b,a.C,f);a.A[e++]=b;b=h+a.Z;c-=g}return 0>=c?!0:Db(2,b,c)}function Eb(a,b){return a.A[(b&a.w)>>>a.R].fb(b&a.s,b)}
|
||||
function Fb(a,b){if(void 0===b)return a.G=!a.G,a.G;void 0===a.B[b]&&(a.B[b]=[null,!1]);a.B[b][1]=!a.B[b][1];return a.B[b][1]}function Gb(a,b){if(void 0===b)return a.I=!a.I,a.I;void 0===a.F[b]&&(a.F[b]=[null,!1]);a.F[b][1]=!a.F[b][1];return a.F[b][1]}function Db(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Hb;if(vb){var Ib=new ArrayBuffer(2);(new DataView(Ib)).setUint16(0,256,!0);Hb=256===(new Uint16Array(Ib))[0]}else Hb=!1;var Jb=Hb;
|
||||
function H(a,b,c,d){this.id=Kb+=2;this.b=null;this.u=a;this.hb=b;this.size=c||0;this.type=d||Lb;this.A=d==Mb;Bb(this);this.va=this.Vb=!1;if(c)if(vb)this.F=new ArrayBuffer(c),this.G=new DataView(this.F,0,c),this.H=new Uint8Array(this.F,0,c),this.J=new Uint16Array(this.F,0,c>>1),this.b=new Int32Array(this.F,0,c>>2),Nb(this,Jb?Ob:ac);else{this.b=Array(c>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Nb(this,bc)}else Nb(this)}var Lb=0,Mb=2,cc=["NONE","RAM","ROM","VIDEO","H/W"],Kb=0;
|
||||
H.prototype={constructor:H,parent:null,save:function(){var a,b;if(vb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.G.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(vb)for(b=0;b<a.length;b++)this.G.setInt32(b<<2,a[b],!0);else this.b=a;return this.va=!0}return!1},ya:function(a,b){b?0===this.w++&&dc(this,ec,!1):0===this.s++&&fc(this,ec,!1)},L:function(){this.C&&gb(this.C,129)&&this.C.message("attempt to read invalid block %"+n(this.u),!0);
|
||||
return 255},B:function(a,b){this.C&&gb(this.C,129)&&this.C.message("attempt to write "+q(b)+" to invalid block %"+n(this.u),!0)},N:function(a,b){return this.Sa(a++,b++)|this.Sa(a,b)<<8},I:function(a,b,c){this.Ua(a++,b&255,c++);this.Ua(a,b>>8,c)},V:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},oa:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},Ga:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<<d)|b<<d;this.va=!0},jb:function(a,
|
||||
b){var c=a>>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<<d)|b<<d:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.va=!0},S:function(a,b){if(this.C&&null!=this.u){var c=this.C;gc(c,this.u+a,1,c.S)&&c.U(!0)}return this.fb(a,b)},ka:function(a,b){if(this.C&&null!=this.u){var c=this.C;gc(c,this.u+a,2,c.S)&&c.U(!0)}return this.tb(a,b)},wa:function(a,b,c){if(this.C&&null!=this.u){var d=this.C;gc(d,this.u+a,1,d.G)&&d.U(!0)}this.A?this.B(a,b,c):this.Va(a,b,c)},Xa:function(a,b,
|
||||
c){if(this.C&&null!=this.u){var d=this.C;gc(d,this.u+a,2,d.G)&&d.U(!0)}this.A?this.B(a,b,c):this.ub(a,b,c)},O:function(a){return this.H[a]},T:function(a){return this.H[a]},da:function(a){return this.G.getUint16(a,!0)},na:function(a){return a&1?this.H[a]|this.H[a+1]<<8:this.J[a>>1]},qa:function(a,b){this.H[a]=b;this.va=!0},xa:function(a,b){this.H[a]=b;this.va=!0},Wa:function(a,b){this.G.setUint16(a,b,!0);this.va=!0},Ya:function(a,b){a&1?(this.H[a]=b,this.H[a+1]=b>>8):this.J[a>>1]=b;this.va=!0}};
|
||||
function Bb(a,b,c){a.C=b;a.s=a.w=0;c&&((a.s=c.s)&&fc(a,ec,!1),(a.w=c.w)&&dc(a,ec,!1))}function hc(a,b){b?0===--a.w&&(a.Ua=a.A?a.B:a.Va,a.Pb=a.A?a.I:a.ub):0===--a.s&&(a.Sa=a.fb,a.Mb=a.tb)}function dc(a,b,c){c&&a.w||(a.Ua=!a.A&&b[2]||a.B,a.Pb=!a.A&&b[3]||a.I);if(c||void 0===c)a.Va=b[2]||a.B,a.ub=b[3]||a.I}function fc(a,b,c){c&&a.s||(a.Sa=b[0]||a.L,a.Mb=b[1]||a.N);if(c||void 0===c)a.fb=b[0]||a.L,a.tb=b[1]||a.N}function Nb(a,b){b||(b=ic);fc(a,b,void 0);dc(a,b,void 0)}
|
||||
var ic=[],bc=[H.prototype.V,H.prototype.oa,H.prototype.Ga,H.prototype.jb],ec=[H.prototype.S,H.prototype.ka,H.prototype.wa,H.prototype.Xa];if(vb)var ac=[H.prototype.O,H.prototype.da,H.prototype.qa,H.prototype.Wa],Ob=[H.prototype.T,H.prototype.na,H.prototype.xa,H.prototype.Ya];
|
||||
function jc(a,b){x.call(this,"CPU",a,jc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Ra=c;this.i.Da=d;this.i.qb=Math.round(this.i.Ra/1E4)/100;this.i.Ba=this.i.qb*this.i.Da;this.j.X=!1;this.j.pb=!1;this.j.Eb=a.autoStart;this.j.Fb=!1;this.j.Ia=!1;this.i.Za=this.i.Oa=0;this.i.$a=a.csStart;this.i.Na=a.csInterval;this.i.Pa=a.csStop;this.ka=this.Fa.bind(this);G(this)}z(jc);var kc=["power","reset"];k=jc.prototype;
|
||||
k.La=function(a,b,c,d){this.s=a;this.A=b;this.C=d;for(b=0;b<kc.length;b++)(c=this.H[kc[b]])&&this.s.la(null,kc[b],c);yb(a,"FPU");this.w=yb(a,"ChipSet");a=lc(a,"autoStart");null!=a&&(this.j.Eb="true"==a?!0:"false"==a?!1:!!a);G(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};
|
||||
k.ta=function(a,b){if(!b){if(a&&this.restore){mc(this);if(!this.restore(a))return!1;nc(this)}else this.reset();if(this.C){var c=this.C;c.g("Type ? for help with PC8080 Debugger commands");c.ma();if(c.Ya){var d=c.Ya;c.Ya=null;oc(c,d)}}else this.g("No debugger detected")}I(this);return!0};k.sa=function(a){return a?this.save():!0};function pc(a){(a.j.Eb||!a.C&&void 0===a.H.run)&&a.Fa(!0)}k.Gb=function(){return 0};
|
||||
function nc(a){void 0===a.i.$a&&(a.i.$a=0);void 0===a.i.Na&&(a.i.Na=-1);void 0===a.i.Pa&&(a.i.Pa=-1);a.j.Ia=0<=a.i.$a&&0<a.i.Na;a.j.Ia&&(a.i.Za=0,a.i.Oa=a.i.$a-a.J)}function qc(a,b){if(a.j.Ia){var c=!1;a.i.Za=a.i.Za+a.Gb()|0;a.i.Oa-=b;0>=a.i.Oa&&(a.i.Oa+=a.i.Na,c=!0);0<=a.i.Pa&&a.i.Pa<=rc(a)&&(a.i.Na=a.i.Pa=-1,nc(a),a.U(),c=!0);c&&a.g(rc(a)+" cycles: checksum="+n(a.i.Za))}}
|
||||
k.la=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.H[b]=c;a=!0;break;case "run":this.H[b]=c;c.onclick=function(){var a;if(a=d.s)if(a=d.s,a.j.W)a=!0;else{var b=null,c,g=C(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.j.Ka);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.j.W);c++);c==g.length&&(b=a);v("The "+b.type+" component ("+b.id+") is not "+(b.j.Ka?"powered yet":"ready yet"+(b.lb?" (waiting for notification)":""))+".");a=!1}a&&(d.j.X?d.U(!0):d.Fa(!0))};a=!0;break;
|
||||
case "speed":this.H[b]=c;a=!0;break;case "setSpeed":this.H[b]=c,c.onclick=function(){sc(d,d.i.Da<<1,!0)},c.textContent=this.i.Ba.toFixed(2)+"Mhz",a=!0}return a};function tc(a,b,c){a.J+=b;c&&(a.F=a.b=0)}
|
||||
function uc(a,b){var c=30;60>c&&(c=60);2>c&&(c=2);var d=1;b&&1<a.i.Da&&a.i.Aa&&(d=a.i.Aa/a.i.qb);a.i.Ib=Math.round(1E3/30);a.i.Zb=Math.floor(a.i.Ra/c*d);a.i.rb=Math.floor(a.i.Ra/30*d);a.i.Kb=Math.floor(a.i.Ra/60*d);a.i.Jb=Math.floor(a.i.Ra/2*d);b||(a.i.Qa=a.i.rb,a.i.bb=a.i.Kb,a.i.ab=a.i.Jb);a.i.sb=0}function rc(a){return a.J+a.I+a.F-a.b}function mc(a){a.i.Aa=0;a.J=a.I=a.F=a.b=0;nc(a);sc(a,1)}
|
||||
function sc(a,b,c){var d=!1;if(void 0!==b){.8>a.i.Aa/a.i.Ba?b=1:d=!0;a.i.Da=b;b=a.i.qb*a.i.Da;if(a.i.Ba!=b){a.i.Ba=b;b=a.i.Ba.toFixed(2)+"Mhz";var e=a.H.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.s&&a.s.gb()}tc(a,a.I);a.I=0;a.i.Ma=sa();a.i.Ca=0;uc(a);return d}
|
||||
k.Fa=function(a){if(hb(this,!0)){if(!this.j.X){sc(this);this.s&&this.s.start(this.i.Ma,rc(this));this.j.X=!0;this.j.pb=!0;this.w&&this.w.$b();var b=this.H.run;b&&(b.textContent="Halt");this.s&&(this.s.ma(!0),a&&this.s.gb(!0))}this.i.sb>=this.i.Ra&&uc(this,!0);this.i.cb=0;this.i.mb=sa();this.i.Ca&&(a=this.i.mb-this.i.Ca,a>this.i.Ib&&(this.i.Ma+=a,this.i.Ma>this.i.mb&&(this.i.Ma=this.i.mb)));try{do{var c=this.j.Ia?1:this.i.Zb;this.w&&(this.w.Ob(),c=this.w.bc(0,c),c=this.w.ac(c));try{this.Ta(c)}catch(e){if("number"!=
|
||||
typeof e)throw e;}var d=this.F-this.b;this.I+=d;this.i.cb+=d;tc(this,0,!0);qc(this,d);this.i.bb-=d;0>=this.i.bb&&(this.i.bb+=this.i.Kb);this.i.ab-=d;0>=this.i.ab&&(this.i.ab+=this.i.Jb,this.s&&this.s.ma());this.i.Qa-=d;if(0>=this.i.Qa){this.i.Qa+=this.i.rb;break}}while(this.j.X)}catch(e){this.U();I(this);this.s&&this.s.stop(sa(),rc(this));hb(this,!1);ub(this,e.stack||e.message);return}c=setTimeout;d=this.ka;this.i.Ca=sa();a=this.i.Ib;this.i.cb&&(a=Math.round(a*this.i.cb/this.i.rb));a-=this.i.Ca-this.i.mb;
|
||||
if(b=this.i.Ca-this.i.Ma)this.i.Aa=Math.round(this.I/(10*b))/100,864E5<=b&&(this.J=0,this.w&&this.w.Ob(!0),sc(this));if(0>a||this.i.Aa<this.i.Ba)a=0;this.i.sb+=this.i.cb;this.i.Ca+=a;c(d,a)}else I(this),this.s&&this.s.stop(sa(),rc(this))};k.Ta=function(){return 0};k.U=function(a){ib(this,!0);this.F-=this.b;this.b=0;tc(this,this.I);this.I=0;if(this.j.X){this.j.X=!1;this.w&&this.w.$b();var b=this.H.run;b&&(b.textContent="Run")}this.j.kb=a};function I(a,b){a.s&&a.s.ma(b)}
|
||||
function vc(a){this.Hb=a.model||8080;jc.call(this,a,1E6);this.da=wc;mc(this);this.j.kb=this.j.Ub=!1;this.V=0;this.ea=[];this.R=this.Z=this.G=this.T=this.S=this.L=0;xc(this)}z(vc,jc);k=vc.prototype;k.reset=function(){this.j.X&&this.U();xc(this);mc(this);this.j.Ja=!1};function xc(a){a.K=0;a.aa=0;a.ga=0;a.ba=0;a.ha=0;a.ca=0;a.ia=0;a.ja=0;a.P=0;yc(a,0);a.O=0}k.Gb=function(){var a=this.K+this.aa+this.ga+this.ba+this.ha+this.ca+this.ia|0;return a=a+this.ja+this.P+zc(this)|0};
|
||||
k.save=function(){var a=new J(this);M(a,0,[this.K,this.aa,this.ga,this.ba,this.ha,this.ca,this.ia,this.ja,this.P,zc(this)]);M(a,1,[this.N,this.O,this.J,this.i.Da]);for(var b=this.A,c=0,d=[],e=0;e<b.J;e++){var f=b.A[e];if(f.va||f.Vb){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,l=0,m=[];g<f.length;){for(var p=f[g],r=g+1;r<f.length&&f[r]===p;)r++;m[l++]=r-g;m[l++]=p;g=r}if(m.length<f.length){f=m;break a}}d[h]=f}}M(a,2,d);return a.data()};
|
||||
k.restore=function(a){var b=a[0];this.K=b[0];this.aa=b[1];this.ga=b[2];this.ba=b[3];this.ha=b[4];this.ca=b[5];this.ia=b[6];this.ja=b[7]&65535;this.P=b[8]&65535;yc(this,b[9]);b=a[1];this.N=b[0];this.O=b[1];this.J=b[2];sc(this,b[3]);a:{b=this.A;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.S){for(var f=0,h=Array(b.S),g=0;g<e.length-1;)for(var l=e[g++],m=e[g++];l--;)h[f++]=m;e=h}f=b.A[d];if(!f||!f.restore(e)){v("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
k.la=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "D":case "E":case "H":case "L":case "SP":case "PC":case "F":case "SF":case "ZF":case "AF":case "PF":case "CF":this.H[b]=c;this.V++;d=!0;break;default:d=this.parent.la.call(this,a,b,c)}return d};function Ac(a){return a.aa<<8|a.ga}function Bc(a,b){a.aa=b>>8&255;a.ga=b&255}function Cc(a){return a.ba<<8|a.ha}function Dc(a,b){a.ba=b>>8&255;a.ha=b&255}function N(a){return a.ca<<8|a.ia}function Ec(a,b){a.ca=b>>8&255;a.ia=b&255}
|
||||
function dd(a){return(a.M^a.B)&16?16:0}function zc(a){return a.Ea&-214|(a.M&128?128:0)|(a.D&255?0:64)|dd(a)|(wb[a.M&255]?4:0)|(a.D&256?1:0)}function yc(a,b){a.D=a.M=a.B=0;b&1&&(a.D|=256);b&4||(a.M|=1);b&16&&(a.B|=16);b&64||(a.D|=255);b&128&&(a.M^=192);a.Ea=a.Ea&-513|b&512|2}function ed(a,b){a.B=b;b=(a.M=b+1)&255;a.D=a.D&-256|b;return b}function fd(a,b){a.B=b;b=(a.M=b-1)&255;a.D=a.D&-256|b;return b}function gd(a,b){return a.ea[(b&a.L)>>>a.R].Sa(b&a.G,b)}
|
||||
function hd(a,b){var c=b&a.G,d=(b&a.L)>>>a.R;if(c<a.G)return a.ea[d].Mb(c,b);c=a.ea[d].Sa(c,b);return c|=a.ea[d+1&a.S].Sa(0,b+1)<<8}function id(a,b,c){a.ea[(b&a.L)>>>a.R].Ua(b&a.G,c&255,b)}function O(a){var b=gd(a,a.P);a.P=a.P+1&65535;return b}function jd(a){var b=hd(a,a.P);a.P=a.P+2&65535;return b}function P(a,b,c,d){d=d||2;a.H[b]&&(void 0===c&&(ub(a,"Value for "+b+" is invalid"),a.U()),c=!a.j.X||a.j.Fb?n(c,d):"--------".substr(0,d),a.H[b].textContent!=c&&(a.H[b].textContent=c))}
|
||||
k.ma=function(a){this.V&&(a||!this.j.X||this.j.Fb)&&(P(this,"A",this.K),P(this,"B",this.aa),P(this,"C",this.ga),P(this,"D",this.ba),P(this,"E",this.ha),P(this,"H",this.ca),P(this,"L",this.ia),P(this,"SP",this.ja,4),P(this,"PC",this.P,4),a=zc(this),P(this,"F",a,2),P(this,"SF",a&128,1),P(this,"ZF",a&64,1),P(this,"AF",a&16,1),P(this,"PF",a&4,1),P(this,"CF",a&1,1));if(a=this.H.speed)a.textContent=this.j.X&&this.i.Aa?this.i.Aa.toFixed(2)+"Mhz":"Stopped"};
|
||||
k.Ta=function(a){this.j.kb=!0;var b=this.j.Ub=this.C&&kd(this.C),c=a?this.j.pb?0:1:-1;this.j.pb=!1;this.F=this.b=a;this.w&&!a&&this.w.Ob();a||(this.N|=4);do{if(this.O&&this.O&4){this.N=this.b=0;break}if(b){if(ld(this.C,this.P,c)){this.U();break}c=1}this.N=0;this.da[O(this)].call(this)}while(0<this.b);return this.j.kb?this.F-this.b:void 0===this.j.kb?0:-1};Sa(function(){for(var a=F(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new vc(d);eb(d,c)}});function md(){this.b-=4}
|
||||
function Q(){this.P=this.P-1&65535;fb(this,"unimplemented opcode",!0);this.U()}
|
||||
var wc=[md,function(){Bc(this,jd(this));this.b-=10},function(){id(this,Ac(this),this.K);this.b-=7},function(){Bc(this,Ac(this)+1);this.b-=5},function(){this.aa=ed(this,this.aa);this.b-=5},function(){this.aa=fd(this,this.aa);this.b-=5},function(){this.aa=O(this);this.b-=7},function(){var a=this.K<<1;this.K=a&255|a>>8;this.D=this.D&255|a&256;this.b-=4},md,function(){var a;Ec(this,a=N(this)+Ac(this));this.D=this.D&255|a>>8&256;this.b-=10},function(){this.K=gd(this,Ac(this));this.b-=7},function(){Bc(this,
|
||||
Ac(this)-1);this.b-=5},function(){this.ga=ed(this,this.ga);this.b-=5},function(){this.ga=fd(this,this.ga);this.b-=5},function(){this.ga=O(this);this.b-=7},function(){var a=this.K<<8&256;this.K=(a|this.K)>>1;this.D=this.D&255|a;this.b-=4},md,function(){Dc(this,jd(this));this.b-=10},function(){id(this,Cc(this),this.K);this.b-=7},function(){Dc(this,Cc(this)+1);this.b-=5},function(){this.ba=ed(this,this.ba);this.b-=5},function(){this.ba=fd(this,this.ba);this.b-=5},function(){this.ba=O(this);this.b-=7},
|
||||
function(){var a=this.K<<1;this.K=a&255|this.D>>8;this.D=this.D&255|a&256;this.b-=4},md,function(){var a;Ec(this,a=N(this)+Cc(this));this.D=this.D&255|a>>8&256;this.b-=10},function(){this.K=gd(this,Cc(this));this.b-=7},function(){Dc(this,Cc(this)-1);this.b-=5},function(){this.ha=ed(this,this.ha);this.b-=5},function(){this.ha=fd(this,this.ha);this.b-=5},function(){this.ha=O(this);this.b-=7},function(){var a=this.K<<8&256;this.K=(this.D&256|this.K)>>1;this.D=this.D&255|a;this.b-=4},md,function(){Ec(this,
|
||||
jd(this));this.b-=10},function(){var a=jd(this),b=N(this),c=a&this.G,d=(a&this.L)>>>this.R;c<this.G?this.ea[d].Pb(c,b&65535,a):(this.ea[d++].Ua(c,b&255,a),this.ea[d&this.S].Ua(0,b>>8&255,a+1));this.b-=16},function(){Ec(this,N(this)+1);this.b-=5},function(){this.ca=ed(this,this.ca);this.b-=5},function(){this.ca=fd(this,this.ca);this.b-=5},function(){this.ca=O(this);this.b-=7},function(){var a=this.K,b=!!(this.D&256),c=!!dd(this);9<(a&15)||c?(a+=6,c=!0):c=!1;160<=a||b?(a+=96,b=!0):b=!1;this.D=this.M=
|
||||
this.K=a&255;this.D=b?this.D|256:this.D&-257;this.B=c?~this.M&16|this.B&-17:this.M&16|this.B&-17;this.b-=4},md,function(){var a;Ec(this,a=N(this)+N(this));this.D=this.D&255|a>>8&256;this.b-=10},function(){Ec(this,hd(this,jd(this)));this.b-=16},function(){Ec(this,N(this)-1);this.b-=5},function(){this.ia=ed(this,this.ia);this.b-=5},function(){this.ia=fd(this,this.ia);this.b-=5},function(){this.ia=O(this);this.b-=7},function(){this.K=~this.K&255;this.b-=4},md,function(){this.ja=jd(this)&65535;this.b-=
|
||||
10},function(){id(this,jd(this),this.K);this.b-=13},function(){this.ja=this.ja+1&65535;this.b-=5},function(){var a=N(this);id(this,a,ed(this,gd(this,a)));this.b-=10},function(){var a=N(this);id(this,a,fd(this,gd(this,a)));this.b-=10},function(){id(this,N(this),O(this));this.b-=10},function(){this.D|=256;this.b-=4},md,function(){var a;this.ja=(a=N(this)+this.ja)&65535;this.D=this.D&255|a>>8&256;this.b-=10},function(){this.K=gd(this,jd(this));this.b-=13},function(){this.ja=this.ja-1&65535;this.b-=5},
|
||||
function(){this.K=ed(this,this.K);this.b-=5},function(){this.K=fd(this,this.K);this.b-=5},function(){this.K=O(this);this.b-=7},function(){this.D=this.D&256?this.D&-257:this.D|256;this.b-=4},Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,
|
||||
Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q];function nd(a){x.call(this,"ROM",a,nd);this.s=null;this.G=a.addr;this.w=a.size;this.B=a.alias;this.F=a.file;this.I=ga(this.F);if(this.F){a=this.F;var b=ha(this.I);"json"!=b&&"hex"!=b&&(a=za()+"/api/v1/dump?file="+this.F+"&format=bytes&decimal=true");var c=this;u(a,null,!0,function(a,b,f){od(c,a,b,f)})}}z(nd);nd.prototype.La=function(a,b,c,d){this.A=b;this.b=c;this.C=d;pd(this)};
|
||||
nd.prototype.ta=function(){if(this.ra){if(this.C){var a=this.C,b=this.id,c=this.G,d=this.w,e=this.ra,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var l=g.o,m=g.a;if(void 0!==l){var p=f,l=[l>>>0,h],r=ra(p,l,a.xb);0>r&&p.splice(-(r+1),0,l)}m&&(g.a=m.replace(/''/g,'"'))}a.I.push({cc:b,u:c,Yb:d,ra:e,yb:f})}delete this.ra}return!0};nd.prototype.sa=function(){return!0};
|
||||
function od(a,b,c,d){if(d)a.fa("Unable to load system ROM (error "+d+": "+b+")");else{cb(a.Ab,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.s=f;else if(h)for(a.s=Array(4*h.length),d=c=0;c<h.length;c++)a.s[d++]=h[c]&255,a.s[d++]=h[c]>>8&255,a.s[d++]=h[c]>>16&255,a.s[d++]=h[c]>>24&255;else a.s=e;a.ra=e.symbols;if(!a.s.length){v("Empty ROM: "+b);return}if(1==a.s.length){v(a.s[0]);return}}catch(g){a.fa("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.s=Array(b.length),e=0;e<b.length;e++)a.s[e]=fa(b[e],16);pd(a)}}
|
||||
function pd(a){if(!tb(a))if(!a.F)G(a);else if(a.s&&a.A){if(a.s.length!=a.w)ub(a,"ROM size (0x"+n(a.s.length)+") does not match specified size ("+("0x"+n(a.w))+")");else{var b;b=a.G;if(Cb(a.A,b,a.w,Mb)){for(var c=0;c<a.s.length;c++){var d=a.A,e=b+c;d.A[(e&d.w)>>>d.R].Va(e&d.s,a.s[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.B?b.push(a.B):null!=a.B&&a.B.length&&(b=a.B);for(c=0;c<b.length;c++){for(var f=a,d=b[c],e=f.A,h=f.w,g=[],l=f.G>>>e.R;0<h&&l<e.A.length;)g.push(e.A[l++]),h-=e.Z;e=f.A;
|
||||
f=f.w;h=0;for(d>>>=e.R;0<f&&d<e.A.length;){l=g[h++];if(!l)break;e.A[d++]=l;f-=e.Z}}delete a.s}}G(a)}}Sa(function(){for(var a=F(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new nd(d);eb(d,c)}});function qd(a){x.call(this,"RAM",a,qd);this.B=a.addr;this.w=a.size;this.s=!1}z(qd);k=qd.prototype;k.La=function(a,b,c,d){this.A=b;this.b=c;this.C=d;G(this)};k.ta=function(a,b){b||this.reset();return!0};k.sa=function(a){return a?this.save():!0};
|
||||
k.reset=function(){!this.s&&this.w&&Cb(this.A,this.B,this.w,1)&&(this.s=!0,this.status(Math.floor(this.w/1024)+"Kb allocated"));this.s||v("No RAM allocated")};k.save=function(){return null};k.restore=function(){return!0};Sa(function(){for(var a=F(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new qd(d);eb(d,c)}});function rd(a){x.call(this,"Keyboard",a,rd,65536);G(this)}z(rd);
|
||||
Sa(function(){for(var a=F(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new rd(d);eb(d,c)}});function sd(a){x.call(this,"Video",a,sd,262144);G(this)}z(sd);
|
||||
Sa(function(){for(var a=F(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=E(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=Aa().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
|
||||
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Xa.aspect);f&&.3<=f&&3.33>=f&&(Ra("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");Ga("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e.getContext("2d");d=new sd(d);eb(d,c)}});
|
||||
function td(a){x.call(this,"Debugger",a,td);this.V=this.Ga=this.L=0;this.O=R();this.zb=R();this.F=-1;this.B=[];this.na=!1;this.da=R();this.I=[];this.ka={};this.w=this.S=this.G=[];ud(this);this.wa=0;vd(this);this.Wa=[];wd(this,a.messages);this.Ya=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return oc(b,a)}):void 0===global.$&&(global.$=function(a){return oc(b,a)})}z(td);
|
||||
var xd={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine","t [#]":"trace","u [#]":"unassemble",x:"execution options",v:"print version","var":"assign variable"},yd="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "),
|
||||
zd="B C D E H L M A F BC DE HL PSW SP PC".split(" "),Ad=[[45],[42,2323,32],[71,2387],[29,2323],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,6419],[40,2387],[23,2323],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2579,32],[71,2643],[29,2579],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,6675],[40,2643],[23,2579],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2835,32],[68,99],[29,2835],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,6931],[41,99],[23,2835],[28,1297],[22,1297],[44,
|
||||
(function(){var k;function aa(a,b){var c;if(a){b||(b=16);if("$"==a.charAt(0))b=16,a=a.substr(1);else if("0x"==a.substr(0,2))b=16,a=a.substr(2);else{var d=a.charAt(a.length-1).toLowerCase();"h"==d?(b=16,d=null):"."==d&&(b=10,d=null);null==d&&(a=a.substr(0,a.length-1))}var e,d=a,f=b;(f&&10!=f?16==f?null!==d.match(/^[0-9a-f]+$/i):2==f&&null!==d.match(/^[01]+$/i):null!==d.match(/^[0-9]+$/))&&!isNaN(e=parseInt(a,b))&&(c=e|0)}return c}
|
||||
function n(a,b){var c="";void 0===b?b=8:8<b&&(b=8);if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;){var d=a&15,d=d+(0<=d&&9>=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function q(a){return"0x"+n(a,4)}function ha(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0<d&&(c=c.substr(0,d));b&&(d=c.lastIndexOf("."),0<d&&(c=c.substring(0,d)));return c}function ia(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}
|
||||
function ja(a,b){return-1!==a.indexOf(b,a.length-b.length)}var ka={"&":"&","<":"<",">":">",'"':""","'":"'"};function la(a){return a.replace(/[&<>"']/g,function(a){return ka[a]})}function ma(a,b){return(a+" ").slice(0,b)}function na(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
|
||||
function oa(a,b,c){var d=0,e=a.length,f=0;for(void 0===c&&(c=function(a,b){return a>b?1:a<b?-1:0});d<e;){var h=d+e>>1,g;g=c(b,a[h]);0<g?d=h+1:(e=h,f=!g)}return f?d:~d}var pa=Date.now||function(){return+new Date};function ua(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function va(a,b){var c;if(Array.prototype.indexOf)return a.indexOf(b,c);c=c||0;0>c&&(c+=a.length);0>c&&(c=0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return c;return-1}
|
||||
function t(a,b,c,d){var e=0,f=null,h=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),d&&d(a,f,e))});if(b&&"object"==
|
||||
typeof b){var m="",l;for(l in b)b.hasOwnProperty(l)&&(m&&(m+="&"),m+=l+"="+encodeURIComponent(b[l]));m=m.replace(/%20/g,"+");g.open("POST",a,!!c);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(m)}else g.open("GET",a,!!c),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();c||(f=g.responseText,200!=g.status&&(e=g.status||-1),d&&d(a,f,e),h=[f,e]);return h}function wa(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function xa(){return window?window.navigator.userAgent:""}function v(a){window&&window.alert(a)}function Ca(a){var b=!1;window&&(b=window.confirm(a));return b}var Da=null;function Ea(){if(null==Da){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Da=a}return Da}
|
||||
function Fa(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function Ga(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Ha(a){if(window){var b=xa();return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}function Ia(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}
|
||||
function Ja(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,f=!1;a.onmousedown=function(){f||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}var Ka={init:[],show:[],exit:[]},La=!1,Pa=!0;function Sa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Ta(a){Ka.init.push(a)}
|
||||
function Ua(a){if(Pa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){v("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.")}}function Va(a){!Pa&&a?(Pa=!0,La&&Wa("init")):Pa=a}function Wa(a){Ka[a]&&Ua(Ka[a])}Sa("onload",function(){La=!0;Ua(Ka.init)});Sa("onpageshow",function(){Ua(Ka.show)});Sa(Ha("Opera")||Ha("iOS")?"onunload":"onbeforeunload",function(){Ua(Ka.exit)});
|
||||
function w(a,b,c,d){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.xb=b.comment;this.Mb=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Bb=this.id.substr(0,b),this.Ya=this.id.substr(b+1)):this.Ya=this.id;this[a]=c;this.s={La:!1,Ia:!1,pb:!1,ba:!1,Ka:!1};this.mb=null;this.s.Ka=!1;this.I={};this.B=null;this.ea=d||0;y.push(this)}var Xa=void 0,Ya={};
|
||||
if(window){Xa||(Xa=window.location.search.substr(1));for(var Za,$a=/\+/g,ab=/([^&=]+)=?([^&]*)/g;Za=ab.exec(Xa);)Ya[decodeURIComponent(Za[1].replace($a," "))]=decodeURIComponent(Za[2].replace($a," "))}function bb(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
|
||||
function z(a,b){b||(b=w);a.prototype=bb(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var y=[],cb={};function db(a,b,c){cb[a]&&b&&(cb[a][b]=c)}function A(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<y.length;b++){var d=y[b];a&&d.id.indexOf(a)||c.push(d)}return c}
|
||||
function eb(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<y.length;d++)if(c)c==y[d]&&(c=null);else if(!(a!=y[d].type||b&&y[d].id.indexOf(b)))return y[d]}return null}function B(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){v(c.message+" ("+a+")")}return b}
|
||||
function fb(a,b){for(var c=E(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var m=g.split(" "),l=0;l<m.length;l++)switch(g=m[l],g){case "pc8080-binding":(g=B(h))&&g.binding&&a.la(g.type,g.binding,h,g.value),l=m.length}}}}
|
||||
function E(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
|
||||
w.prototype={constructor:w,parent:null,toString:function(){return this.name?this.name:this.id||this.type},la:function(a,b,c){switch(b){case "clear":return this.I[b]||(this.I[b]=c,c.onclick=function(a){return function(){a.I.print&&(a.I.print.value="")}}(this)),!0;case "print":return this.I[b]||(this.Aa=this.I[b]=c,c.value="",this.g=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
|
||||
this.ia=function(a,b,c){this.g(a,"notice",c)}),!0;default:return!1}},log:function(){},g:function(){},status:function(a){this.g(this.Ya+": "+a)},ia:function(a,b){b||v(a)},ua:function(){return this.s.ba=!0},ta:function(a,b){b&&(this.s.ba=!1);return!0}};function gb(a,b,c){a.B&&(!0===c||hb(a,c|0))&&a.B.message(b,void 0)}function hb(a,b){if(a.B){a===a.B?b|=0:b=b||a.ea;var c=a.B.ea&b;return!!b&&c===b||!!(c&a.B.Tb)}return!1}
|
||||
function ib(a,b){if(a.s.pb)return a.s.Ia&&(a.s.Ia=!1),a.s.pb=!1;if(a.s.Ka)return a.g(a.toString()+" error"),!1;a.s.Ia=b;return a.s.Ia}function jb(a,b){a.s.Ia&&(b?a.s.pb=!0:void 0===b&&a.g(a.toString()+" busy"));return a.s.Ia}function F(a){if(!a.s.Ka&&(a.s.La=!0,a.s.La)){var b=a.mb;a.mb=null;b&&b()}}function kb(a,b){b&&(a.s.La?b():a.mb=b);return a.s.La}function lb(a,b){a.s.Ka=!0;a.ia(b)}
|
||||
var wb="undefined"!==typeof ArrayBuffer,xb=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
|
||||
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function yb(a){w.call(this,"Panel",a,yb)}z(yb);k=yb.prototype;k.la=function(a,b,c,d){return this.u&&this.u.la(a,b,c,d)||this.b&&this.b.la(a,b,c,d)||this.A&&this.A.la(a,b,c,d)||this.B&&this.B.la(a,b,c,d)?!0:this.parent.la.call(this,a,b,c,d)};k.Ma=function(a,b,c,d){this.u=a;this.C=b;this.b=c;this.B=d;this.A=zb(a,"Keyboard")};k.ua=function(a,b){b||Ab();return!0};k.ta=function(){return!0};k.ma=function(){};
|
||||
function Ab(){for(var a=!1,b=E(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=B(d),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<y.length;h++)if(y[h].id===f){f=y[h];break a}f=null}f||(a=!0,f=new yb(e));fb(f,d);a&&F(f)}}Ta(Ab);
|
||||
function Bb(a,b,c){w.call(this,"Bus",a,Bb);this.b=b;this.B=c;this.T=a.buswidth||16;this.W=Math.pow(2,this.T);this.A=this.W-1|0;this.X=20>=this.T?12:24>=this.T?14:15;this.fa=1<<this.X;this.Y=this.fa>>2;this.u=this.fa-1;this.K=this.W/this.fa|0;this.V=this.K-1;this.D=[];this.G=[];this.H=this.J=!1;this.aa=[];this.ca=[];a=new H;Cb(a,this.B);this.C=Array(this.K);for(b=0;b<this.K;b++)this.C[b]=a;a=this.b;b=this.C;c=this.X;var d=this.A;a.ha=b;a.X=c;a.fa=1<<a.X;a.G=a.fa-1;a.Y=b.length;a.W=a.Y-1;a.T=d;F(this)}
|
||||
z(Bb);Bb.prototype.reset=function(){};Bb.prototype.ua=function(a,b){b||this.reset();return!0};function Db(a,b,c,d){for(var e=b>>>a.X;0<c&&e<a.C.length;){var f=a.C[e],h=e*a.fa,g=c>a.fa?a.fa:c;if(f&&f.size){if(f.type==d){if(b+c<=f.w)return f.ib+=f.w-b,f.w=b,!0;if(b>=f.w+f.ib){g=f.size-(b-h);g>c&&(g=c);f.ib=b-f.w+g;c-=g;b=h+a.fa;continue}}return Eb(1,b,c)}f=a.C[e];b=new H(b,g,a.fa,d);Cb(b,a.B,f);a.C[e++]=b;b=h+a.fa;c-=g}return 0>=c?!0:Eb(2,b,c)}
|
||||
function Fb(a,b){return a.C[(b&a.A)>>>a.X].gb(b&a.u,b)}function Gb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.D[b]&&(a.D[b]=[null,!1]);a.D[b][1]=!a.D[b][1];return a.D[b][1]}function Hb(a,b){if(void 0===b)return a.J=!a.J,a.J;void 0===a.G[b]&&(a.G[b]=[null,!1]);a.G[b][1]=!a.G[b][1];return a.G[b][1]}function Eb(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Ib;
|
||||
if(wb){var Jb=new ArrayBuffer(2);(new DataView(Jb)).setUint16(0,256,!0);Ib=256===(new Uint16Array(Jb))[0]}else Ib=!1;var Kb=Ib;
|
||||
function H(a,b,c,d){this.id=Lb+=2;this.b=null;this.w=a;this.ib=b;this.size=c||0;this.type=d||Mb;this.C=d==Nb;Cb(this);this.wa=this.Wb=!1;if(c)if(wb)this.G=new ArrayBuffer(c),this.H=new DataView(this.G,0,c),this.I=new Uint8Array(this.G,0,c),this.K=new Uint16Array(this.G,0,c>>1),this.b=new Int32Array(this.G,0,c>>2),Ob(this,Kb?Pb:Qb);else{this.b=Array(c>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Ob(this,cc)}else Ob(this)}var Mb=0,Nb=2,dc=["NONE","RAM","ROM","VIDEO","H/W"],Lb=0;
|
||||
H.prototype={constructor:H,parent:null,save:function(){var a,b;if(wb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.H.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(wb)for(b=0;b<a.length;b++)this.H.setInt32(b<<2,a[b],!0);else this.b=a;return this.wa=!0}return!1},za:function(a,b){b?0===this.A++&&ec(this,fc,!1):0===this.u++&&gc(this,fc,!1)},T:function(){this.B&&hb(this.B,129)&&this.B.message("attempt to read invalid block %"+n(this.w),!0);
|
||||
return 255},D:function(a,b){this.B&&hb(this.B,129)&&this.B.message("attempt to write "+q(b)+" to invalid block %"+n(this.w),!0)},V:function(a,b){return this.Ta(a++,b++)|this.Ta(a,b)<<8},J:function(a,b,c){this.Va(a++,b&255,c++);this.Va(a,b>>8,c)},ca:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},pa:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},Ha:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<<d)|b<<d;this.wa=!0},kb:function(a,
|
||||
b){var c=a>>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<<d)|b<<d:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.wa=!0},Y:function(a,b){if(this.B&&null!=this.w){var c=this.B;hc(c,this.w+a,1,c.Y)&&c.Z(!0)}return this.gb(a,b)},na:function(a,b){if(this.B&&null!=this.w){var c=this.B;hc(c,this.w+a,2,c.Y)&&c.Z(!0)}return this.ub(a,b)},xa:function(a,b,c){if(this.B&&null!=this.w){var d=this.B;hc(d,this.w+a,1,d.H)&&d.Z(!0)}this.C?this.D(a,b,c):this.Wa(a,b,c)},Ya:function(a,b,
|
||||
c){if(this.B&&null!=this.w){var d=this.B;hc(d,this.w+a,2,d.H)&&d.Z(!0)}this.C?this.D(a,b,c):this.vb(a,b,c)},W:function(a){return this.I[a]},aa:function(a){return this.I[a]},ga:function(a){return this.H.getUint16(a,!0)},oa:function(a){return a&1?this.I[a]|this.I[a+1]<<8:this.K[a>>1]},ra:function(a,b){this.I[a]=b;this.wa=!0},ya:function(a,b){this.I[a]=b;this.wa=!0},Xa:function(a,b){this.H.setUint16(a,b,!0);this.wa=!0},Za:function(a,b){a&1?(this.I[a]=b,this.I[a+1]=b>>8):this.K[a>>1]=b;this.wa=!0}};
|
||||
function Cb(a,b,c){a.B=b;a.u=a.A=0;c&&((a.u=c.u)&&gc(a,fc,!1),(a.A=c.A)&&ec(a,fc,!1))}function ic(a,b){b?0===--a.A&&(a.Va=a.C?a.D:a.Wa,a.Qb=a.C?a.J:a.vb):0===--a.u&&(a.Ta=a.gb,a.Nb=a.ub)}function ec(a,b,c){c&&a.A||(a.Va=!a.C&&b[2]||a.D,a.Qb=!a.C&&b[3]||a.J);if(c||void 0===c)a.Wa=b[2]||a.D,a.vb=b[3]||a.J}function gc(a,b,c){c&&a.u||(a.Ta=b[0]||a.T,a.Nb=b[1]||a.V);if(c||void 0===c)a.gb=b[0]||a.T,a.ub=b[1]||a.V}function Ob(a,b){b||(b=jc);gc(a,b,void 0);ec(a,b,void 0)}
|
||||
var jc=[],cc=[H.prototype.ca,H.prototype.pa,H.prototype.Ha,H.prototype.kb],fc=[H.prototype.Y,H.prototype.na,H.prototype.xa,H.prototype.Ya];if(wb)var Qb=[H.prototype.W,H.prototype.ga,H.prototype.ra,H.prototype.Xa],Pb=[H.prototype.aa,H.prototype.oa,H.prototype.ya,H.prototype.Za];
|
||||
function kc(a,b){w.call(this,"CPU",a,kc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Sa=c;this.i.Ea=d;this.i.rb=Math.round(this.i.Sa/1E4)/100;this.i.Ca=this.i.rb*this.i.Ea;this.s.da=!1;this.s.qb=!1;this.s.Fb=a.autoStart;this.s.Gb=!1;this.s.Ja=!1;this.i.$a=this.i.Pa=0;this.i.ab=a.csStart;this.i.Oa=a.csInterval;this.i.Qa=a.csStop;this.ga=this.Ga.bind(this);F(this)}z(kc);var lc=["power","reset"];k=kc.prototype;
|
||||
k.Ma=function(a,b,c,d){this.u=a;this.C=b;this.B=d;for(b=0;b<lc.length;b++)(c=this.I[lc[b]])&&this.u.la(null,lc[b],c);zb(a,"FPU");this.A=zb(a,"ChipSet");a=mc(a,"autoStart");null!=a&&(this.s.Fb="true"==a?!0:"false"==a?!1:!!a);F(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};
|
||||
k.ua=function(a,b){if(!b){if(a&&this.restore){nc(this);if(!this.restore(a))return!1;oc(this)}else this.reset();if(this.B){var c=this.B;c.g("Type ? for help with PC8080 Debugger commands");c.ma();if(c.Za){var d=c.Za;c.Za=null;pc(c,d)}}else this.g("No debugger detected")}I(this);return!0};k.ta=function(a){return a?this.save():!0};function qc(a){(a.s.Fb||!a.B&&void 0===a.I.run)&&a.Ga(!0)}k.Hb=function(){return 0};
|
||||
function oc(a){void 0===a.i.ab&&(a.i.ab=0);void 0===a.i.Oa&&(a.i.Oa=-1);void 0===a.i.Qa&&(a.i.Qa=-1);a.s.Ja=0<=a.i.ab&&0<a.i.Oa;a.s.Ja&&(a.i.$a=0,a.i.Pa=a.i.ab-a.J)}function rc(a,b){if(a.s.Ja){var c=!1;a.i.$a=a.i.$a+a.Hb()|0;a.i.Pa-=b;0>=a.i.Pa&&(a.i.Pa+=a.i.Oa,c=!0);0<=a.i.Qa&&a.i.Qa<=sc(a)&&(a.i.Oa=a.i.Qa=-1,oc(a),a.Z(),c=!0);c&&a.g(sc(a)+" cycles: checksum="+n(a.i.$a))}}
|
||||
k.la=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.I[b]=c;a=!0;break;case "run":this.I[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.s.ba)a=!0;else{var b=null,c,g=A(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.s.La);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.s.ba);c++);c==g.length&&(b=a);v("The "+b.type+" component ("+b.id+") is not "+(b.s.La?"powered yet":"ready yet"+(b.mb?" (waiting for notification)":""))+".");a=!1}a&&(d.s.da?d.Z(!0):d.Ga(!0))};a=!0;
|
||||
break;case "speed":this.I[b]=c;a=!0;break;case "setSpeed":this.I[b]=c,c.onclick=function(){tc(d,d.i.Ea<<1,!0)},c.textContent=this.i.Ca.toFixed(2)+"Mhz",a=!0}return a};function uc(a,b,c){a.J+=b;c&&(a.D=a.b=0)}
|
||||
function vc(a,b){var c=30;60>c&&(c=60);2>c&&(c=2);var d=1;b&&1<a.i.Ea&&a.i.Ba&&(d=a.i.Ba/a.i.rb);a.i.Jb=Math.round(1E3/30);a.i.$b=Math.floor(a.i.Sa/c*d);a.i.sb=Math.floor(a.i.Sa/30*d);a.i.Lb=Math.floor(a.i.Sa/60*d);a.i.Kb=Math.floor(a.i.Sa/2*d);b||(a.i.Ra=a.i.sb,a.i.cb=a.i.Lb,a.i.bb=a.i.Kb);a.i.tb=0}function sc(a){return a.J+a.H+a.D-a.b}function nc(a){a.i.Ba=0;a.J=a.H=a.D=a.b=0;oc(a);tc(a,1)}
|
||||
function tc(a,b,c){var d=!1;if(void 0!==b){.8>a.i.Ba/a.i.Ca?b=1:d=!0;a.i.Ea=b;b=a.i.rb*a.i.Ea;if(a.i.Ca!=b){a.i.Ca=b;b=a.i.Ca.toFixed(2)+"Mhz";var e=a.I.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.u&&a.u.hb()}uc(a,a.H);a.H=0;a.i.Na=pa();a.i.Da=0;vc(a);return d}
|
||||
k.Ga=function(a){if(ib(this,!0)){if(!this.s.da){tc(this);this.u&&this.u.start(this.i.Na,sc(this));this.s.da=!0;this.s.qb=!0;this.A&&this.A.ac();var b=this.I.run;b&&(b.textContent="Halt");this.u&&(this.u.ma(!0),a&&this.u.hb(!0))}this.i.tb>=this.i.Sa&&vc(this,!0);this.i.eb=0;this.i.nb=pa();this.i.Da&&(a=this.i.nb-this.i.Da,a>this.i.Jb&&(this.i.Na+=a,this.i.Na>this.i.nb&&(this.i.Na=this.i.nb)));try{do{var c=this.s.Ja?1:this.i.$b;this.A&&(this.A.Pb(),c=this.A.cc(0,c),c=this.A.bc(c));try{this.Ua(c)}catch(e){if("number"!=
|
||||
typeof e)throw e;}var d=this.D-this.b;this.H+=d;this.i.eb+=d;uc(this,0,!0);rc(this,d);this.i.cb-=d;0>=this.i.cb&&(this.i.cb+=this.i.Lb);this.i.bb-=d;0>=this.i.bb&&(this.i.bb+=this.i.Kb,this.u&&this.u.ma());this.i.Ra-=d;if(0>=this.i.Ra){this.i.Ra+=this.i.sb;break}}while(this.s.da)}catch(e){this.Z();I(this);this.u&&this.u.stop(pa(),sc(this));ib(this,!1);lb(this,e.stack||e.message);return}c=setTimeout;d=this.ga;this.i.Da=pa();a=this.i.Jb;this.i.eb&&(a=Math.round(a*this.i.eb/this.i.sb));a-=this.i.Da-
|
||||
this.i.nb;if(b=this.i.Da-this.i.Na)this.i.Ba=Math.round(this.H/(10*b))/100,864E5<=b&&(this.J=0,this.A&&this.A.Pb(!0),tc(this));if(0>a||this.i.Ba<this.i.Ca)a=0;this.i.tb+=this.i.eb;this.i.Da+=a;c(d,a)}else I(this),this.u&&this.u.stop(pa(),sc(this))};k.Ua=function(){return 0};k.Z=function(a){jb(this,!0);this.D-=this.b;this.b=0;uc(this,this.H);this.H=0;if(this.s.da){this.s.da=!1;this.A&&this.A.ac();var b=this.I.run;b&&(b.textContent="Run")}this.s.lb=a};function I(a,b){a.u&&a.u.ma(b)}
|
||||
function wc(a){this.Ib=a.model||8080;kc.call(this,a,1E6);this.ca=xc;nc(this);this.s.lb=this.s.Vb=!1;this.aa=0;this.ha=[];this.X=this.fa=this.G=this.Y=this.W=this.T=0;yc(this)}z(wc,kc);k=wc.prototype;k.reset=function(){this.s.da&&this.Z();yc(this);nc(this);this.s.Ka=!1};function yc(a){a.j=0;a.L=0;a.O=0;a.M=0;a.P=0;a.N=0;a.R=0;a.ja=0;a.U=0;zc(a,0);a.K=0}k.Hb=function(){var a=this.j+this.L+this.O+this.M+this.P+this.N+this.R|0;return a=a+this.ja+this.U+Ac(this)|0};
|
||||
k.save=function(){var a=new J(this);K(a,0,[this.j,this.L,this.O,this.M,this.P,this.N,this.R,this.ja,this.U,Ac(this)]);K(a,1,[this.V,this.K,this.J,this.i.Ea]);for(var b=this.C,c=0,d=[],e=0;e<b.K;e++){var f=b.C[e];if(f.wa||f.Wb){d[c++]=e;var h=c++;a:if(f=f.save()){for(var g=0,m=0,l=[];g<f.length;){for(var p=f[g],r=g+1;r<f.length&&f[r]===p;)r++;l[m++]=r-g;l[m++]=p;g=r}if(l.length<f.length){f=l;break a}}d[h]=f}}K(a,2,d);return a.data()};
|
||||
k.restore=function(a){var b=a[0];this.j=b[0];this.L=b[1];this.O=b[2];this.M=b[3];this.P=b[4];this.N=b[5];this.R=b[6];this.ja=b[7]&65535;this.U=b[8]&65535;zc(this,b[9]);b=a[1];this.V=b[0];this.K=b[1];this.J=b[2];tc(this,b[3]);a:{b=this.C;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.Y){for(var f=0,h=Array(b.Y),g=0;g<e.length-1;)for(var m=e[g++],l=e[g++];m--;)h[f++]=l;e=h}f=b.C[d];if(!f||!f.restore(e)){v("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
k.la=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "D":case "E":case "H":case "L":case "SP":case "PC":case "F":case "SF":case "ZF":case "AF":case "PF":case "CF":this.I[b]=c;this.aa++;d=!0;break;default:d=this.parent.la.call(this,a,b,c)}return d};function Bc(a){return a.L<<8|a.O}function Cc(a,b){a.L=b>>8&255;a.O=b&255}function Dc(a){return a.M<<8|a.P}function Ec(a,b){a.M=b>>8&255;a.P=b&255}function L(a){return a.N<<8|a.R}function Fc(a,b){a.N=b>>8&255;a.R=b&255}
|
||||
function Gc(a){return(a.S^a.ka)&16?16:0}function Ac(a){return a.Fa&-214|(a.S&128?128:0)|(a.F&255?0:64)|Gc(a)|(xb[a.S&255]?4:0)|(a.F&256?1:0)}function zc(a,b){a.F=a.S=a.ka=0;b&1&&(a.F|=256);b&4||(a.S|=1);b&16&&(a.ka|=16);b&64||(a.F|=255);b&128&&(a.S^=192);a.Fa=a.Fa&-513|b&512|2}function fd(a,b){a.ka=b;b=(a.S=b+1)&255;a.F=a.F&-256|b;return b}function gd(a,b){a.ka=b;b=(a.S=b-1)&255;a.F=a.F&-256|b;return b}function hd(a,b,c){a.ka=b^c;return(a.F=a.S=b+c)&255}
|
||||
function id(a,b,c){a.ka=b^c;return(a.F=a.S=b+c+(a.F&256?1:0))&255}function M(a,b){return a.ha[(b&a.T)>>>a.X].Ta(b&a.G,b)}function jd(a,b){var c=b&a.G,d=(b&a.T)>>>a.X;if(c<a.G)return a.ha[d].Nb(c,b);c=a.ha[d].Ta(c,b);return c|=a.ha[d+1&a.W].Ta(0,b+1)<<8}function P(a,b,c){a.ha[(b&a.T)>>>a.X].Va(b&a.G,c&255,b)}function Q(a){var b=M(a,a.U);a.U=a.U+1&65535;return b}function kd(a){var b=jd(a,a.U);a.U=a.U+2&65535;return b}
|
||||
function R(a,b,c,d){d=d||2;a.I[b]&&(void 0===c&&(lb(a,"Value for "+b+" is invalid"),a.Z()),c=!a.s.da||a.s.Gb?n(c,d):"--------".substr(0,d),a.I[b].textContent!=c&&(a.I[b].textContent=c))}
|
||||
k.ma=function(a){this.aa&&(a||!this.s.da||this.s.Gb)&&(R(this,"A",this.j),R(this,"B",this.L),R(this,"C",this.O),R(this,"D",this.M),R(this,"E",this.P),R(this,"H",this.N),R(this,"L",this.R),R(this,"SP",this.ja,4),R(this,"PC",this.U,4),a=Ac(this),R(this,"F",a,2),R(this,"SF",a&128,1),R(this,"ZF",a&64,1),R(this,"AF",a&16,1),R(this,"PF",a&4,1),R(this,"CF",a&1,1));if(a=this.I.speed)a.textContent=this.s.da&&this.i.Ba?this.i.Ba.toFixed(2)+"Mhz":"Stopped"};
|
||||
k.Ua=function(a){this.s.lb=!0;var b=this.s.Vb=this.B&&ld(this.B),c=a?this.s.qb?0:1:-1;this.s.qb=!1;this.D=this.b=a;this.A&&!a&&this.A.Pb();a||(this.V|=4);do{if(this.K&&this.K&4){this.V=this.b=0;break}if(b){if(md(this.B,this.U,c)){this.Z();break}c=1}this.V=0;this.ca[Q(this)].call(this)}while(0<this.b);return this.s.lb?this.D-this.b:void 0===this.s.lb?0:-1};Ta(function(){for(var a=E(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new wc(d);fb(d,c)}});function nd(){this.b-=4}
|
||||
function S(){this.U=this.U-1&65535;gb(this,"unimplemented opcode",!0);this.Z()}
|
||||
var xc=[nd,function(){Cc(this,kd(this));this.b-=10},function(){P(this,Bc(this),this.j);this.b-=7},function(){Cc(this,Bc(this)+1);this.b-=5},function(){this.L=fd(this,this.L);this.b-=5},function(){this.L=gd(this,this.L);this.b-=5},function(){this.L=Q(this);this.b-=7},function(){var a=this.j<<1;this.j=a&255|a>>8;this.F=this.F&255|a&256;this.b-=4},nd,function(){var a;Fc(this,a=L(this)+Bc(this));this.F=this.F&255|a>>8&256;this.b-=10},function(){this.j=M(this,Bc(this));this.b-=7},function(){Cc(this,Bc(this)-
|
||||
1);this.b-=5},function(){this.O=fd(this,this.O);this.b-=5},function(){this.O=gd(this,this.O);this.b-=5},function(){this.O=Q(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(a|this.j)>>1;this.F=this.F&255|a;this.b-=4},nd,function(){Ec(this,kd(this));this.b-=10},function(){P(this,Dc(this),this.j);this.b-=7},function(){Ec(this,Dc(this)+1);this.b-=5},function(){this.M=fd(this,this.M);this.b-=5},function(){this.M=gd(this,this.M);this.b-=5},function(){this.M=Q(this);this.b-=7},function(){var a=this.j<<
|
||||
1;this.j=a&255|this.F>>8;this.F=this.F&255|a&256;this.b-=4},nd,function(){var a;Fc(this,a=L(this)+Dc(this));this.F=this.F&255|a>>8&256;this.b-=10},function(){this.j=M(this,Dc(this));this.b-=7},function(){Ec(this,Dc(this)-1);this.b-=5},function(){this.P=fd(this,this.P);this.b-=5},function(){this.P=gd(this,this.P);this.b-=5},function(){this.P=Q(this);this.b-=7},function(){var a=this.j<<8&256;this.j=(this.F&256|this.j)>>1;this.F=this.F&255|a;this.b-=4},nd,function(){Fc(this,kd(this));this.b-=10},function(){var a=
|
||||
kd(this),b=L(this),c=a&this.G,d=(a&this.T)>>>this.X;c<this.G?this.ha[d].Qb(c,b&65535,a):(this.ha[d++].Va(c,b&255,a),this.ha[d&this.W].Va(0,b>>8&255,a+1));this.b-=16},function(){Fc(this,L(this)+1);this.b-=5},function(){this.N=fd(this,this.N);this.b-=5},function(){this.N=gd(this,this.N);this.b-=5},function(){this.N=Q(this);this.b-=7},function(){var a=this.j,b=!!(this.F&256),c=!!Gc(this);9<(a&15)||c?(a+=6,c=!0):c=!1;160<=a||b?(a+=96,b=!0):b=!1;this.F=this.S=this.j=a&255;this.F=b?this.F|256:this.F&-257;
|
||||
this.ka=c?~this.S&16|this.ka&-17:this.S&16|this.ka&-17;this.b-=4},nd,function(){var a;Fc(this,a=L(this)+L(this));this.F=this.F&255|a>>8&256;this.b-=10},function(){Fc(this,jd(this,kd(this)));this.b-=16},function(){Fc(this,L(this)-1);this.b-=5},function(){this.R=fd(this,this.R);this.b-=5},function(){this.R=gd(this,this.R);this.b-=5},function(){this.R=Q(this);this.b-=7},function(){this.j=~this.j&255;this.b-=4},nd,function(){this.ja=kd(this)&65535;this.b-=10},function(){P(this,kd(this),this.j);this.b-=
|
||||
13},function(){this.ja=this.ja+1&65535;this.b-=5},function(){var a=L(this);P(this,a,fd(this,M(this,a)));this.b-=10},function(){var a=L(this);P(this,a,gd(this,M(this,a)));this.b-=10},function(){P(this,L(this),Q(this));this.b-=10},function(){this.F|=256;this.b-=4},nd,function(){var a;this.ja=(a=L(this)+this.ja)&65535;this.F=this.F&255|a>>8&256;this.b-=10},function(){this.j=M(this,kd(this));this.b-=13},function(){this.ja=this.ja-1&65535;this.b-=5},function(){this.j=fd(this,this.j);this.b-=5},function(){this.j=
|
||||
gd(this,this.j);this.b-=5},function(){this.j=Q(this);this.b-=7},function(){this.F=this.F&256?this.F&-257:this.F|256;this.b-=4},function(){this.b-=5},function(){this.L=this.O;this.b-=5},function(){this.L=this.M;this.b-=5},function(){this.L=this.P;this.b-=5},function(){this.L=this.N;this.b-=5},function(){this.L=this.R;this.b-=5},function(){this.L=M(this,L(this));this.b-=7},function(){this.L=this.j;this.b-=5},function(){this.O=this.L;this.b-=5},function(){this.b-=5},function(){this.O=this.M;this.b-=
|
||||
5},function(){this.O=this.P;this.b-=5},function(){this.O=this.N;this.b-=5},function(){this.O=this.R;this.b-=5},function(){this.O=M(this,L(this));this.b-=7},function(){this.O=this.j;this.b-=5},function(){this.M=this.L;this.b-=5},function(){this.M=this.O;this.b-=5},function(){this.b-=5},function(){this.M=this.P;this.b-=5},function(){this.M=this.N;this.b-=5},function(){this.M=this.R;this.b-=5},function(){this.M=M(this,L(this));this.b-=7},function(){this.M=this.j;this.b-=5},function(){this.P=this.L;this.b-=
|
||||
5},function(){this.P=this.O;this.b-=5},function(){this.P=this.M;this.b-=5},function(){this.b-=5},function(){this.P=this.N;this.b-=5},function(){this.P=this.R;this.b-=5},function(){this.P=M(this,L(this));this.b-=7},function(){this.P=this.j;this.b-=5},function(){this.N=this.L;this.b-=5},function(){this.N=this.O;this.b-=5},function(){this.N=this.M;this.b-=5},function(){this.N=this.P;this.b-=5},function(){this.b-=5},function(){this.N=this.R;this.b-=5},function(){this.N=M(this,L(this));this.b-=7},function(){this.N=
|
||||
this.j;this.b-=5},function(){this.R=this.L;this.b-=5},function(){this.R=this.O;this.b-=5},function(){this.R=this.M;this.b-=5},function(){this.R=this.P;this.b-=5},function(){this.R=this.N;this.b-=5},function(){this.b-=5},function(){this.R=M(this,L(this));this.b-=7},function(){this.R=this.j;this.b-=5},function(){P(this,L(this),this.L);this.b-=7},function(){P(this,L(this),this.O);this.b-=7},function(){P(this,L(this),this.M);this.b-=7},function(){P(this,L(this),this.P);this.b-=7},function(){P(this,L(this),
|
||||
this.N);this.b-=7},function(){P(this,L(this),this.R);this.b-=7},function(){this.K|=4;this.b-=7;this.B&&hb(this,-2147483648)?(this.U=this.U-1&65535,this.B.Z()):this.Fa&512||(this.B&&(this.U=this.U-1&65535),this.Z())},function(){P(this,L(this),this.j);this.b-=7},function(){this.j=this.L;this.b-=5},function(){this.j=this.O;this.b-=5},function(){this.j=this.M;this.b-=5},function(){this.j=this.P;this.b-=5},function(){this.j=this.N;this.b-=5},function(){this.j=this.R;this.b-=5},function(){this.j=M(this,
|
||||
L(this));this.b-=7},function(){this.b-=5},function(){this.j=hd(this,this.j,this.L);this.b-=4},function(){this.j=hd(this,this.j,this.O);this.b-=4},function(){this.j=hd(this,this.j,this.M);this.b-=4},function(){this.j=hd(this,this.j,this.P);this.b-=4},function(){this.j=hd(this,this.j,this.N);this.b-=4},function(){this.j=hd(this,this.j,this.R);this.b-=4},function(){this.j=hd(this,this.j,M(this,L(this)));this.b-=7},function(){this.j=hd(this,this.j,this.j);this.b-=4},function(){this.j=id(this,this.j,this.L);
|
||||
this.b-=4},function(){this.j=id(this,this.j,this.O);this.b-=4},function(){this.j=id(this,this.j,this.M);this.b-=4},function(){this.j=id(this,this.j,this.P);this.b-=4},function(){this.j=id(this,this.j,this.N);this.b-=4},function(){this.j=id(this,this.j,this.R);this.b-=4},function(){this.j=id(this,this.j,M(this,L(this)));this.b-=7},function(){this.j=id(this,this.j,this.j);this.b-=4},S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,
|
||||
S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S];function od(a){w.call(this,"ROM",a,od);this.u=null;this.H=a.addr;this.A=a.size;this.D=a.alias;this.G=a.file;this.J=ha(this.G);if(this.G){a=this.G;var b=ia(this.J);"json"!=b&&"hex"!=b&&(a=wa()+"/api/v1/dump?file="+this.G+"&format=bytes&decimal=true");var c=this;t(a,null,!0,function(a,b,f){pd(c,a,b,f)})}}z(od);od.prototype.Ma=function(a,b,c,d){this.C=b;this.b=c;this.B=d;qd(this)};
|
||||
od.prototype.ua=function(){if(this.sa){if(this.B){var a=this.B,b=this.id,c=this.H,d=this.A,e=this.sa,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var m=g.o,l=g.a;if(void 0!==m){var p=f,m=[m>>>0,h],r=oa(p,m,a.yb);0>r&&p.splice(-(r+1),0,m)}l&&(g.a=l.replace(/''/g,'"'))}a.J.push({dc:b,w:c,Zb:d,sa:e,zb:f})}delete this.sa}return!0};od.prototype.ta=function(){return!0};
|
||||
function pd(a,b,c,d){if(d)a.ia("Unable to load system ROM (error "+d+": "+b+")");else{db(a.Bb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,h=e.data;if(f)a.u=f;else if(h)for(a.u=Array(4*h.length),d=c=0;c<h.length;c++)a.u[d++]=h[c]&255,a.u[d++]=h[c]>>8&255,a.u[d++]=h[c]>>16&255,a.u[d++]=h[c]>>24&255;else a.u=e;a.sa=e.symbols;if(!a.u.length){v("Empty ROM: "+b);return}if(1==a.u.length){v(a.u[0]);return}}catch(g){a.ia("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.u=Array(b.length),e=0;e<b.length;e++)a.u[e]=aa(b[e],16);qd(a)}}
|
||||
function qd(a){if(!kb(a))if(!a.G)F(a);else if(a.u&&a.C){if(a.u.length!=a.A)lb(a,"ROM size (0x"+n(a.u.length)+") does not match specified size ("+("0x"+n(a.A))+")");else{var b;b=a.H;if(Db(a.C,b,a.A,Nb)){for(var c=0;c<a.u.length;c++){var d=a.C,e=b+c;d.C[(e&d.A)>>>d.X].Wa(e&d.u,a.u[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.D?b.push(a.D):null!=a.D&&a.D.length&&(b=a.D);for(c=0;c<b.length;c++){for(var f=a,d=b[c],e=f.C,h=f.A,g=[],m=f.H>>>e.X;0<h&&m<e.C.length;)g.push(e.C[m++]),h-=e.fa;e=f.C;
|
||||
f=f.A;h=0;for(d>>>=e.X;0<f&&d<e.C.length;){m=g[h++];if(!m)break;e.C[d++]=m;f-=e.fa}}delete a.u}}F(a)}}Ta(function(){for(var a=E(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new od(d);fb(d,c)}});function rd(a){w.call(this,"RAM",a,rd);this.D=a.addr;this.A=a.size;this.u=!1}z(rd);k=rd.prototype;k.Ma=function(a,b,c,d){this.C=b;this.b=c;this.B=d;F(this)};k.ua=function(a,b){b||this.reset();return!0};k.ta=function(a){return a?this.save():!0};
|
||||
k.reset=function(){!this.u&&this.A&&Db(this.C,this.D,this.A,1)&&(this.u=!0,this.status(Math.floor(this.A/1024)+"Kb allocated"));this.u||v("No RAM allocated")};k.save=function(){return null};k.restore=function(){return!0};Ta(function(){for(var a=E(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new rd(d);fb(d,c)}});function sd(a){w.call(this,"Keyboard",a,sd,65536);F(this)}z(sd);
|
||||
Ta(function(){for(var a=E(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new sd(d);fb(d,c)}});function td(a){w.call(this,"Video",a,td,262144);F(this)}z(td);
|
||||
Ta(function(){for(var a=E(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=B(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=xa().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
|
||||
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Ya.aspect);f&&.3<=f&&3.33>=f&&(Sa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");Ha("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e.getContext("2d");d=new td(d);fb(d,c)}});
|
||||
function ud(a){w.call(this,"Debugger",a,ud);this.ca=this.Ha=this.T=0;this.W=T();this.Ab=T();this.G=-1;this.D=[];this.oa=!1;this.ga=T();this.J=[];this.na={};this.A=this.Y=this.H=[];vd(this);this.xa=0;wd(this);this.Xa=[];xd(this,a.messages);this.Za=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return pc(b,a)}):void 0===global.$&&(global.$=function(a){return pc(b,a)})}z(ud);
|
||||
var yd={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine","t [#]":"trace","u [#]":"unassemble",x:"execution options",v:"print version","var":"assign variable"},zd="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "),
|
||||
Ad="B C D E H L M A F BC DE HL PSW SP PC".split(" "),Bd=[[45],[42,2323,32],[71,2387],[29,2323],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,6419],[40,2387],[23,2323],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2579,32],[71,2643],[29,2579],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,6675],[40,2643],[23,2579],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2835,32],[68,99],[29,2835],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,6931],[41,99],[23,2835],[28,1297],[22,1297],[44,
|
||||
1297,32],[16],[45,32768],[42,3347,32],[70,97],[29,3347],[28,1553],[22,1553],[44,1553,32],[72],[45,32768],[21,7443],[39,97],[23,3347],[28,1809],[22,1809],[44,1809,32],[17],[43,17,17],[43,17,273],[43,17,529],[43,17,785],[43,17,1041],[43,17,1297],[43,17,1553],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1553],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,785],[43,529,1041],[43,529,1297],[43,529,1553],[43,529,1809],[43,785,17],[43,785,
|
||||
273],[43,785,529],[43,785,785],[43,785,1041],[43,785,1297],[43,785,1553],[43,785,1809],[43,1041,17],[43,1041,273],[43,1041,529],[43,1041,785],[43,1041,1041],[43,1041,1297],[43,1041,1553],[43,1041,1809],[43,1297,17],[43,1297,273],[43,1297,529],[43,1297,785],[43,1297,1041],[43,1297,1297],[43,1297,1553],[43,1297,1809],[43,1553,17],[43,1553,273],[43,1553,529],[43,1553,785],[43,1553,1041],[43,1553,1297],[43,1553,1553],[43,1553,1809],[43,1809,17],[43,1809,273],[43,1809,529],[43,1809,785],[43,1809,1041],
|
||||
[43,1809,1297],[43,1809,1553],[43,1809,1809],[3,17],[3,273],[3,529],[3,785],[3,1041],[3,1297],[3,1553],[3,1809],[2,17],[2,273],[2,529],[2,785],[2,1041],[2,1297],[2,1553],[2,1809],[73,17],[73,273],[73,529],[73,785],[73,1041],[73,1297],[73,1553],[73,1809],[66,17],[66,273],[66,529],[66,785],[66,1041],[66,1297],[66,1553],[66,1809],[5,17],[5,273],[5,529],[5,785],[5,1041],[5,1297],[5,1553],[5,1809],[76,17],[76,273],[76,529],[76,785],[76,1041],[76,1297],[76,1553],[76,1809],[46,17],[46,273],[46,529],[46,
|
||||
785],[46,1041],[46,1297],[46,1553],[46,1809],[18,17],[18,273],[18,529],[18,785],[18,1041],[18,1297],[18,1553],[18,1809],[58],[50,2323],[34,35],[30,35],[11,35],[51,2323],[4,33],[65],[62],[54],[38,35],[30,32803],[15,35],[7,35],[1,33],[65],[57],[50,2579],[33,35],[48,33],[10,35],[51,2579],[74,33],[65],[55],[54,32768],[31,35],[27,33],[8,35],[7,32803],[67,33],[65],[61],[50,2835],[37,35],[78],[14,35],[51,2835],[6,33],[65],[60],[49],[36,35],[75],[13,35],[7,32803],[77,33],[65],[59],[50,3091],[35,35],[24],
|
||||
[12,35],[51,3091],[47,33],[65],[56],[69],[32,35],[25],[9,35],[7,32803],[19,33],[65]],U={cpu:1,bus:64,mem:128,port:256,timer:2048,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:536870912,warn:1073741824,halt:-2147483648};k=td.prototype;
|
||||
k.La=function(a,b,c,d){this.A=b;this.b=c;this.s=a;(a=lc(a,"messages"))&&wd(this,a);this.jb=Ad;Bd(this,function(a){a:{var b=d.b.ea,c=a[0],g=a=0,l=b.length;if(c){a=V(W(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.b.R;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var p=b[g];p.type==c?m++||d.g("..."):(c=p.type,m=cc[c],p&&d.g(n(p.id)+" %"+n(g<<d.b.R)+" %%"+n(p.u)+" "+q(p.hb)+" "+q(p.size)+
|
||||
" "+m),c!=Lb&&(c=-1),m=0);a+=d.b.Z;g++}}});G(this)};
|
||||
k.la=function(a,b,c){var d=this;switch(b){case "debugInput":return this.qa=this.H[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",oc(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?d.F<d.B.length-1&&(b=d.B[++d.F]):40==a.keyCode&&(0<d.F?b=d.B[--d.F]:(b="",d.F=-1)),null!=b){var h=b.length;c.value=b;c.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.H[b]=c,Ia(c,function(){if(d.qa){var a=d.qa.value;d.qa.value=
|
||||
"";oc(d,a,!0);return!0}return!1}),!0;case "step":return this.H[b]=c,Ia(c,function(a){var b=!1;ib(d,!0)||(hb(d,!0),b=d.Ta(a?1:0),hb(d,!1));return b}),!0}return!1};k.gb=function(){this.qa&&this.qa.focus()};function V(a){a=a&&a.u;null==a&&(a=-1);return a}k.ua=function(a,b){var c=255,d=V(a);-1!==d&&(c=Eb(this.A,d),b&&Cd(a,b));return c};k.ib=function(a,b){var c=65535,d=V(a);if(-1!==d){var c=this.A,e=d&c.s,f=(d&c.w)>>>c.R,c=e!=c.s?c.A[f].tb(e,d):c.A[f++].fb(e,d)|c.A[f&c.N].fb(0,d+1)<<8;b&&Cd(a,b)}return c};
|
||||
k.vb=function(a,b,c){var d=V(a);if(-1!==d){var e=this.A;e.A[(d&e.w)>>>e.R].Va(d&e.s,b&255,d);c&&Cd(a,c);I(this.b,!0)}};k.Qb=function(a,b,c){var d=V(a);if(-1!==d){var e=this.A,f=d&e.s,h=(d&e.w)>>>e.R;f!=e.s?e.A[h].ub(f,b&65535,d):(e.A[h++].Va(f,b&255,d),e.A[h&e.N].Va(0,b>>8&255,d+1));c&&Cd(a,c);I(this.b,!0)}};function R(a){return{u:a||0,pa:!1}}function Dd(a){return[a.u,a.pa]}function Ed(a){return{u:a[0],pa:a[1]}}
|
||||
function W(a,b,c){var d;c=(c?a.O:a.zb).u;if(void 0!==b){d=b=Fd(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;c<a.I.length;c++){var f=a.I[c].ra[d];if(void 0!==f){d=f.o;void 0!==d&&(e=R(d));break}}if(d=e)return d;c=Gd(a,b,void 0)}null!=c&&(d=R(c));return d}function Hd(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Rb=Id(a,b.Nb=c[2]))}function Cd(a,b){null!=a.u&&(a.u+=b||1)}
|
||||
function Jd(a,b,c){var d="";for(c=c||256;d.length<c;){var e=a.ua(b,1);if(!e||36==e||127<=e)break;d+=32<=e?String.fromCharCode(e):"."}return d}function wd(a,b){a.C=a;a.Y=a.Sb=1073741824;a.xa=null;var c=Id(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(c.length)for(var d in U)0<=ya(c,d)&&(a.Y|=U[d],a.g(d+" messages enabled"))}function Bd(a,b){for(var c in U)if(64==U[c]){a.Wa[c]=b;break}}
|
||||
function Kd(a,b){var c;a=a.toUpperCase();null==b?c=ya(zd,a):(c=ya(zd,a.substr(b,3)),0>c&&(c=ya(zd,a.substr(b,2))));return c}function Ld(a,b){var c=0,d=Md(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 8:c=2;break;case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"}
|
||||
function Md(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.K;break;case 8:c=zc(d)&255;break;case 0:c=d.aa;break;case 1:c=d.ga;break;case 9:c=d.aa<<8|d.ga;break;case 2:c=d.ba;break;case 3:c=d.ha;break;case 10:c=d.ba<<8|d.ha;break;case 4:c=d.ca;break;case 5:c=d.ia;break;case 11:c=d.ca<<8|d.ia;break;case 12:c=d.K<<8|zc(d)&255;break;case 13:c=d.ja;break;case 14:c=d.P}}return c}
|
||||
function Nd(a,b){b=Fd(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Kd(b,c+1),0<=e&&(b=b.substr(0,c)+Ld(a,e)+b.substr(c+1+zd[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=fa(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=W(a,e))?(d=e+' "'+Jd(a,d)+'"',b=b.replace("$"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("^",c));)e=b.substr(c+1,9),(d=W(a,e))?(Cd(d),d=e+' "'+
|
||||
Jd(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}k.message=function(a,b){b&&(a+=" at "+n(R(this.b.P).u,4));if(!this.xa||a!=this.xa)if(this.xa=a,this.Y&-2147483648&&(this.U(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Qa=0;c.F-=c.b;c.b=0;I(c)}};function Od(a,b,c,d){a.message(b.Xa+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")}
|
||||
function vd(a){var b;if(kd(a)){if(!a.N||!a.N.length){a.N=Array(1E3);for(b=0;b<a.N.length;b++)a.N[b]=R();a.oa=0;a.g("instruction history buffer allocated")}if(!a.J||!a.J.length)for(a.J=Array(256),b=0;b<a.J.length;b++)a.J[b]=[b,0]}else a.N&&a.N.length&&a.g("instruction history buffer freed"),a.oa=0,a.N=[],a.J=[]}k.Fa=function(a){if(!Pd(this))return!1;this.b.Fa(a);return!0};
|
||||
k.Ta=function(a,b,c){if(!Pd(this))return!1;this.L=0;a||kd(this)&&ld(this,this.b.P,0);try{var d=this.b.Ta(a);0<d&&(this.L+=d,tc(this.b,d,!0),qc(this.b,d),this.V++)}catch(e){"number"!=typeof e&&(this.L=0,ub(this.b,e.stack||e.message))}!1!==c&&I(this.b);this.ma(b||!1);return 0<this.L};k.U=function(a){this.b&&this.b.U(a)};k.ma=function(a){void 0===a&&(a=!0);this.O=R(this.b.P);a&&1!=this.T?Qd(this):Rd(this)};
|
||||
function Pd(a){var b;if(b=a.b&&tb(a.b))b=a.b,b.j.W?b=!0:(b.g(b.toString()+" not powered"),b=!1);b&&!ib(a.b)?(a=a.b,a.j.Ja?(a.g(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}k.ta=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};k.sa=function(a,b){b&&this.g(a?"suspending":"shutting down");return a?this.save():!0};k.reset=function(a){vd(this);this.V=this.Ga=0;this.xa=null;this.L=0;this.O=R(this.b.P);this.j.X=!1;Sd(this);a||this.ma()};
|
||||
k.save=function(){var a=new J(this);M(a,0,Dd(this.O));M(a,1,Dd(this.da));M(a,2,[this.B,this.na,this.Y]);M(a,3,this.I);return a.data()};k.restore=function(a){var b=0;void 0!==a[2]&&(this.O=Ed(a[b++]),this.da=Ed(a[b++]),this.B=a[b][0],"string"==typeof this.B&&(this.B=[this.B]),this.na=a[b][1],this.Y|=a[b][2]);a[3]&&(this.I=a[3]);return!0};k.start=function(a,b){this.T||this.g("running");this.j.X=!0;this.Tb=a;this.Wb=b};
|
||||
k.stop=function(a,b){if(this.j.X){this.j.X=!1;this.L=b-this.Wb;if(!this.T){var c="stopped";if(this.L){var d=a-this.Tb,e=0<d?Math.round(1E3*this.L/d):0,c=c+" (";kd(this)&&(c+=this.V+" opcodes, ",this.Ga-=this.V,this.V=0);c+=this.L+" cycles, "+d+" ms, "+e+" hz)"}else gb(this,-2147483648)&&(c+=" (use the 't' command to execute blocked faults)");this.g(c)}this.ma(!0);this.gb();Sd(this,this.b.P)}};function kd(a){return 1<a.w.length||!!a.wa}
|
||||
function ld(a,b,c){var d=a.b;if(0<c&&(a.wa&&!--a.wa||gc(a,b,1,a.w)))return!0;0<=c&&a.J.length&&(a.V++,b=Eb(a.A,b),null!=b&&(a.J[b][1]++,b=a.N[a.oa],b.u=d.P,b.pa=!1,++a.oa==a.N.length&&(a.oa=0)));return!1}function Td(a,b,c){a.g("break on input from port "+q(b)+": "+n(c));a.U(!0)}function Ud(a,b,c){a.g("break on output to port "+q(b)+": "+n(c));a.U(!0)}
|
||||
function ud(a){var b,c;a.w=["bp"];if(void 0!==a.S)for(b=1;b<a.S.length;b++){c=a.S[b];var d=a.b;hc(d.ea[V(c)>>>d.R],!1)}a.S=["br"];if(void 0!==a.G)for(b=1;b<a.G.length;b++)c=a.G[b],d=a.b,hc(d.ea[V(c)>>>d.R],!0);a.G=["bw"];a.Bb=0}k.ya=function(a,b,c){var d=!0;c||Vd(this,a,b,!1,!0);if(a!=this.w){var e=V(b);if(-1===e)this.g("invalid address: "+n(b.u,4)),d=!1;else{var f=this.b;f.ea[e>>>f.R].ya(e&f.G,a==this.G)}}d&&(a.push(b),c?b.pa=!0:(Wd(this,a,a.length-1,"set"),vd(this)));return d};
|
||||
function Vd(a,b,c,d,e){var f=!1;c=V(c);for(var h=1;h<b.length;h++){var g=b[h];if(c==V(g)&&(!d||g.pa)){f=!0;g.pa||e||Wd(a,b,h,"cleared");b.splice(h,1);b!=a.w&&(d=a.b,hc(d.ea[c>>>d.R],b==a.G));g.pa||vd(a);break}}return f}function Xd(a,b){for(var c=1;c<b.length;c++)Wd(a,b,c);return b.length-1}function Wd(a,b,c,d){c=b[c];a.g(b[0]+" "+n(c.u,4)+(d?" "+d:c.Nb?' "'+c.Nb+'"':""))}
|
||||
function Sd(a,b){if(void 0!==b)gc(a,b,1,a.w,!0),a.T=0;else for(var c=1;c<a.w.length;c++){var d=a.w[c];if(d.pa){if(!Vd(a,a.w,d,!0))break;c=0}}}
|
||||
function gc(a,b,c,d,e){var f=!1;if(!a.Bb++)for(var h=1;!f&&h<d.length;h++){var g=d[h];if(!e||g.pa)for(var l=V(g),m=0;m<c;m++)if(b+m==l){var p,f=!0;g.pa&&(Vd(a,d,g,!0),e=!0);if(p=g.Rb){for(var f=!1,r=0;r<p.length;r++)if(!Yd(a,p[r],!0)){if(p[r].indexOf("if")){f=!0;break}for(var t=r+1;t<p.length&&p[t].indexOf("else");t++)r++;if(t==p.length){f=!0;break}}a.b.j.X||(f=!0)}if(f){e||Wd(a,d,h,"hit");break}}}a.Bb--;return f}
|
||||
function Zd(a,b,c,d){for(var e=R(b.u),f=a.ua(b,1),h=a.jb[f],f="",g=null,l=yd[h[0]],m=h.length-1,p=1;p<=m;p++){var r="",t=h[p];if(void 0!==t){var K=t&15;if(0==K){if(null==g)continue;K=g}g=K;K=t&240;if(32==K){var r=a,K=b,B=" ";switch(t&15){case 1:t&12288&&(B=n(r.ua(K,1),2));break;case 2:B=n(r.ua(K,1)<<24>>24,4);break;case 3:B=n(r.ib(K,2),4);break;default:B="imm("+q(t)+")"}r=B}else 16==K&&(r=zd[(t&3840)>>8]);if(!r||!r.length){f="INVALID";break}0<f.length&&(f+=",");f+=r||"???"}}h="";g=n(e.u,4)+" ";if(-1!==
|
||||
e.u&&-1!==b.u){do if(h+=n(a.ua(e,1),2),null==e.u)break;while(e.u!=b.u)}g+=la(h,11);g+=la(l,7);f&&(g+=" "+f);c&&(g=la(g,40)+";"+c,g=a.b.j.Ia?g+("cycles="+rc(a.b).toString()+" cs="+n(a.b.i.Za)):g+(null!=d?"="+d.toString():""));return g}function $d(a,b){var c;switch(b){case "I":c=a.b.Ea&512;break;case "S":c=a.b.M&128?128:0;break;case "Z":c=a.b.D&255?0:64;break;case "A":c=dd(a.b);break;case "P":c=wb[a.b.M&255]?4:0;break;case "C":c=a.b.D&256?1:0;break;default:c=0}return b+(c?"1":"0")+" "}
|
||||
function X(a,b){return zd[b]+"="+Ld(a,b)+" "}var ae={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
|
||||
function be(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<<e;break;case ">>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f<e?1:0;break;case "<=":d=f<=e?1:0;break;case ">":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break;
|
||||
[12,35],[51,3091],[47,33],[65],[56],[69],[32,35],[25],[9,35],[7,32803],[19,33],[65]],W={cpu:1,bus:64,mem:128,port:256,timer:2048,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:536870912,warn:1073741824,halt:-2147483648};k=ud.prototype;
|
||||
k.Ma=function(a,b,c,d){this.C=b;this.b=c;this.u=a;(a=mc(a,"messages"))&&xd(this,a);this.kb=Bd;Cd(this,function(a){a:{var b=d.b.ha,c=a[0],g=a=0,m=b.length;if(c){a=X(Y(d,c));if(-1===a){d.g("invalid address: "+c);break a}g=a>>>d.b.X;m=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,l=0;m--;){var p=b[g];p.type==c?l++||d.g("..."):(c=p.type,l=dc[c],p&&d.g(n(p.id)+" %"+n(g<<d.b.X)+" %%"+n(p.w)+" "+q(p.ib)+" "+q(p.size)+
|
||||
" "+l),c!=Mb&&(c=-1),l=0);a+=d.b.fa;g++}}});F(this)};
|
||||
k.la=function(a,b,c){var d=this;switch(b){case "debugInput":return this.ra=this.I[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",pc(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?d.G<d.D.length-1&&(b=d.D[++d.G]):40==a.keyCode&&(0<d.G?b=d.D[--d.G]:(b="",d.G=-1)),null!=b){var h=b.length;c.value=b;c.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.I[b]=c,Ja(c,function(){if(d.ra){var a=d.ra.value;d.ra.value=
|
||||
"";pc(d,a,!0);return!0}return!1}),!0;case "step":return this.I[b]=c,Ja(c,function(a){var b=!1;jb(d,!0)||(ib(d,!0),b=d.Ua(a?1:0),ib(d,!1));return b}),!0}return!1};k.hb=function(){this.ra&&this.ra.focus()};function X(a){a=a&&a.w;null==a&&(a=-1);return a}k.va=function(a,b){var c=255,d=X(a);-1!==d&&(c=Fb(this.C,d),b&&Dd(a,b));return c};k.jb=function(a,b){var c=65535,d=X(a);if(-1!==d){var c=this.C,e=d&c.u,f=(d&c.A)>>>c.X,c=e!=c.u?c.C[f].ub(e,d):c.C[f++].gb(e,d)|c.C[f&c.V].gb(0,d+1)<<8;b&&Dd(a,b)}return c};
|
||||
k.wb=function(a,b,c){var d=X(a);if(-1!==d){var e=this.C;e.C[(d&e.A)>>>e.X].Wa(d&e.u,b&255,d);c&&Dd(a,c);I(this.b,!0)}};k.Rb=function(a,b,c){var d=X(a);if(-1!==d){var e=this.C,f=d&e.u,h=(d&e.A)>>>e.X;f!=e.u?e.C[h].vb(f,b&65535,d):(e.C[h++].Wa(f,b&255,d),e.C[h&e.V].Wa(0,b>>8&255,d+1));c&&Dd(a,c);I(this.b,!0)}};function T(a){return{w:a||0,qa:!1}}function Ed(a){return[a.w,a.qa]}function Fd(a){return{w:a[0],qa:a[1]}}
|
||||
function Y(a,b,c){var d;c=(c?a.W:a.Ab).w;if(void 0!==b){d=b=Gd(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;c<a.J.length;c++){var f=a.J[c].sa[d];if(void 0!==f){d=f.o;void 0!==d&&(e=T(d));break}}if(d=e)return d;c=Hd(a,b,void 0)}null!=c&&(d=T(c));return d}function Id(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Sb=Jd(a,b.Ob=c[2]))}function Dd(a,b){null!=a.w&&(a.w+=b||1)}
|
||||
function Kd(a,b,c){var d="";for(c=c||256;d.length<c;){var e=a.va(b,1);if(!e||36==e||127<=e)break;d+=32<=e?String.fromCharCode(e):"."}return d}function xd(a,b){a.B=a;a.ea=a.Tb=1073741824;a.ya=null;var c=Jd(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(c.length)for(var d in W)0<=va(c,d)&&(a.ea|=W[d],a.g(d+" messages enabled"))}function Cd(a,b){for(var c in W)if(64==W[c]){a.Xa[c]=b;break}}
|
||||
function Ld(a,b){var c;a=a.toUpperCase();null==b?c=va(Ad,a):(c=va(Ad,a.substr(b,3)),0>c&&(c=va(Ad,a.substr(b,2))));return c}function Md(a,b){var c=0,d=Nd(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 8:c=2;break;case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"}
|
||||
function Nd(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.j;break;case 8:c=Ac(d)&255;break;case 0:c=d.L;break;case 1:c=d.O;break;case 9:c=d.L<<8|d.O;break;case 2:c=d.M;break;case 3:c=d.P;break;case 10:c=d.M<<8|d.P;break;case 4:c=d.N;break;case 5:c=d.R;break;case 11:c=d.N<<8|d.R;break;case 12:c=d.j<<8|Ac(d)&255;break;case 13:c=d.ja;break;case 14:c=d.U}}return c}
|
||||
function Od(a,b){b=Gd(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Ld(b,c+1),0<=e&&(b=b.substr(0,c)+Md(a,e)+b.substr(c+1+Ad[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=aa(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=Y(a,e))?(d=e+' "'+Kd(a,d)+'"',b=b.replace("$"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("^",c));)e=b.substr(c+1,9),(d=Y(a,e))?(Dd(d),d=e+' "'+
|
||||
Kd(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}k.message=function(a,b){b&&(a+=" at "+n(T(this.b.U).w,4));if(!this.ya||a!=this.ya)if(this.ya=a,this.ea&-2147483648&&(this.Z(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Ra=0;c.D-=c.b;c.b=0;I(c)}};function Pd(a,b,c,d){a.message(b.Ya+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")}
|
||||
function wd(a){var b;if(ld(a)){if(!a.V||!a.V.length){a.V=Array(1E3);for(b=0;b<a.V.length;b++)a.V[b]=T();a.pa=0;a.g("instruction history buffer allocated")}if(!a.K||!a.K.length)for(a.K=Array(256),b=0;b<a.K.length;b++)a.K[b]=[b,0]}else a.V&&a.V.length&&a.g("instruction history buffer freed"),a.pa=0,a.V=[],a.K=[]}k.Ga=function(a){if(!Qd(this))return!1;this.b.Ga(a);return!0};
|
||||
k.Ua=function(a,b,c){if(!Qd(this))return!1;this.T=0;a||ld(this)&&md(this,this.b.U,0);try{var d=this.b.Ua(a);0<d&&(this.T+=d,uc(this.b,d,!0),rc(this.b,d),this.ca++)}catch(e){"number"!=typeof e&&(this.T=0,lb(this.b,e.stack||e.message))}!1!==c&&I(this.b);this.ma(b||!1);return 0<this.T};k.Z=function(a){this.b&&this.b.Z(a)};k.ma=function(a){void 0===a&&(a=!0);this.W=T(this.b.U);a&&1!=this.aa?Rd(this):Sd(this)};
|
||||
function Qd(a){var b;if(b=a.b&&kb(a.b))b=a.b,b.s.ba?b=!0:(b.g(b.toString()+" not powered"),b=!1);b&&!jb(a.b)?(a=a.b,a.s.Ka?(a.g(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}k.ua=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};k.ta=function(a,b){b&&this.g(a?"suspending":"shutting down");return a?this.save():!0};k.reset=function(a){wd(this);this.ca=this.Ha=0;this.ya=null;this.T=0;this.W=T(this.b.U);this.s.da=!1;Td(this);a||this.ma()};
|
||||
k.save=function(){var a=new J(this);K(a,0,Ed(this.W));K(a,1,Ed(this.ga));K(a,2,[this.D,this.oa,this.ea]);K(a,3,this.J);return a.data()};k.restore=function(a){var b=0;void 0!==a[2]&&(this.W=Fd(a[b++]),this.ga=Fd(a[b++]),this.D=a[b][0],"string"==typeof this.D&&(this.D=[this.D]),this.oa=a[b][1],this.ea|=a[b][2]);a[3]&&(this.J=a[3]);return!0};k.start=function(a,b){this.aa||this.g("running");this.s.da=!0;this.Ub=a;this.Xb=b};
|
||||
k.stop=function(a,b){if(this.s.da){this.s.da=!1;this.T=b-this.Xb;if(!this.aa){var c="stopped";if(this.T){var d=a-this.Ub,e=0<d?Math.round(1E3*this.T/d):0,c=c+" (";ld(this)&&(c+=this.ca+" opcodes, ",this.Ha-=this.ca,this.ca=0);c+=this.T+" cycles, "+d+" ms, "+e+" hz)"}else hb(this,-2147483648)&&(c+=" (use the 't' command to execute blocked faults)");this.g(c)}this.ma(!0);this.hb();Td(this,this.b.U)}};function ld(a){return 1<a.A.length||!!a.xa}
|
||||
function md(a,b,c){var d=a.b;if(0<c&&(a.xa&&!--a.xa||hc(a,b,1,a.A)))return!0;0<=c&&a.K.length&&(a.ca++,b=Fb(a.C,b),null!=b&&(a.K[b][1]++,b=a.V[a.pa],b.w=d.U,b.qa=!1,++a.pa==a.V.length&&(a.pa=0)));return!1}function Ud(a,b,c){a.g("break on input from port "+q(b)+": "+n(c));a.Z(!0)}function Vd(a,b,c){a.g("break on output to port "+q(b)+": "+n(c));a.Z(!0)}
|
||||
function vd(a){var b,c;a.A=["bp"];if(void 0!==a.Y)for(b=1;b<a.Y.length;b++){c=a.Y[b];var d=a.b;ic(d.ha[X(c)>>>d.X],!1)}a.Y=["br"];if(void 0!==a.H)for(b=1;b<a.H.length;b++)c=a.H[b],d=a.b,ic(d.ha[X(c)>>>d.X],!0);a.H=["bw"];a.Cb=0}k.za=function(a,b,c){var d=!0;c||Wd(this,a,b,!1,!0);if(a!=this.A){var e=X(b);if(-1===e)this.g("invalid address: "+n(b.w,4)),d=!1;else{var f=this.b;f.ha[e>>>f.X].za(e&f.G,a==this.H)}}d&&(a.push(b),c?b.qa=!0:(Xd(this,a,a.length-1,"set"),wd(this)));return d};
|
||||
function Wd(a,b,c,d,e){var f=!1;c=X(c);for(var h=1;h<b.length;h++){var g=b[h];if(c==X(g)&&(!d||g.qa)){f=!0;g.qa||e||Xd(a,b,h,"cleared");b.splice(h,1);b!=a.A&&(d=a.b,ic(d.ha[c>>>d.X],b==a.H));g.qa||wd(a);break}}return f}function Yd(a,b){for(var c=1;c<b.length;c++)Xd(a,b,c);return b.length-1}function Xd(a,b,c,d){c=b[c];a.g(b[0]+" "+n(c.w,4)+(d?" "+d:c.Ob?' "'+c.Ob+'"':""))}
|
||||
function Td(a,b){if(void 0!==b)hc(a,b,1,a.A,!0),a.aa=0;else for(var c=1;c<a.A.length;c++){var d=a.A[c];if(d.qa){if(!Wd(a,a.A,d,!0))break;c=0}}}
|
||||
function hc(a,b,c,d,e){var f=!1;if(!a.Cb++)for(var h=1;!f&&h<d.length;h++){var g=d[h];if(!e||g.qa)for(var m=X(g),l=0;l<c;l++)if(b+l==m){var p,f=!0;g.qa&&(Wd(a,d,g,!0),e=!0);if(p=g.Sb){for(var f=!1,r=0;r<p.length;r++)if(!Zd(a,p[r],!0)){if(p[r].indexOf("if")){f=!0;break}for(var u=r+1;u<p.length&&p[u].indexOf("else");u++)r++;if(u==p.length){f=!0;break}}a.b.s.da||(f=!0)}if(f){e||Xd(a,d,h,"hit");break}}}a.Cb--;return f}
|
||||
function $d(a,b,c,d){for(var e=T(b.w),f=a.va(b,1),h=a.kb[f],f="",g=null,m=zd[h[0]],l=h.length-1,p=1;p<=l;p++){var r="",u=h[p];if(void 0!==u){var N=u&15;if(0==N){if(null==g)continue;N=g}g=N;N=u&240;if(32==N){var r=a,N=b,D=" ";switch(u&15){case 1:u&12288&&(D=n(r.va(N,1),2));break;case 2:D=n(r.va(N,1)<<24>>24,4);break;case 3:D=n(r.jb(N,2),4);break;default:D="imm("+q(u)+")"}r=D}else 16==N&&(r=Ad[(u&3840)>>8]);if(!r||!r.length){f="INVALID";break}0<f.length&&(f+=",");f+=r||"???"}}h="";g=n(e.w,4)+" ";if(-1!==
|
||||
e.w&&-1!==b.w){do if(h+=n(a.va(e,1),2),null==e.w)break;while(e.w!=b.w)}g+=ma(h,11);g+=ma(m,7);f&&(g+=" "+f);c&&(g=ma(g,40)+";"+c,g=a.b.s.Ja?g+("cycles="+sc(a.b).toString()+" cs="+n(a.b.i.$a)):g+(null!=d?"="+d.toString():""));return g}function ae(a,b){var c;switch(b){case "I":c=a.b.Fa&512;break;case "S":c=a.b.S&128?128:0;break;case "Z":c=a.b.F&255?0:64;break;case "A":c=Gc(a.b);break;case "P":c=xb[a.b.S&255]?4:0;break;case "C":c=a.b.F&256?1:0;break;default:c=0}return b+(c?"1":"0")+" "}
|
||||
function be(a,b){return Ad[b]+"="+Md(a,b)+" "}var ce={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
|
||||
function de(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<<e;break;case ">>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f<e?1:0;break;case "<=":d=f<=e?1:0;break;case ">":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break;
|
||||
case "^":d=f^e;break;case "|":d=f|e;break;case "&&":d=f&&e?1:0;break;case "||":d=f||e?1:0;break;default:return!1}a.push(d|0)}return!0}
|
||||
function Gd(a,b,c){var d;if(b){b=Fd(a,b);for(var e=0,f=!1,h=b,g=[],l=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<m.length;){var p=m[e++],r=p.length,p=qa(p);if(!p){f=!0;break}p=ce(a,p,null,!1===c);if(void 0===p){f=!0;c=!1;break}g.push(p);if(e==m.length)break;var p=m[e++],t=p.length;l.length&&ae[p]<ae[l[l.length-1]]&&be(g,l,1);l.push(p);b=b.substr(r+t)}be(g,l)&&1==g.length||(f=!0);f?c&&a.g("error parsing '"+h+"' at character "+(h.length-b.length)):(d=g.pop(),c&&De(a,null,
|
||||
d))}return d}function Fd(a,b){for(var c;(c=b.match(/\{(.*?)}/))&&!(0<=c[1].indexOf("{"));){var d=Gd(a,c[1]);b=b.replace("{"+c[1]+"}",null!=d?n(d):"undefined")}for(;(c=b.match(/\[(.*?)]/))&&!(0<=c[1].indexOf("["));)d=W(a,c[1]),b=b.replace("["+c[1]+"]",d?n(a.ib(d,0),4):"undefined");for(c=b;d=c.match(/\$([a-z]+)/i);){var e=null;switch(d[1].toLowerCase()){case "ops":e=a.V-a.Ga}if(null==e)break;c=c.replace(d[0],e.toString())}return c}
|
||||
function ce(a,b,c,d){var e;void 0!==b?(e=Kd(b),0<=e?e=Md(a,e):(e=a.ka[b],void 0===e&&(e=fa(b))),void 0!==e||d||a.g("invalid "+(c?c:"value")+": "+b)):d||a.g("missing "+(c||"value"));return e}
|
||||
function De(a,b,c){var d,e=!1;if(void 0!==c){e=!0;d=c;var f,h="";if(!f||4<f)f=4;for(var g=0;g<f;g++){h&&(h=","+h);var l=d&255,m=8,p="";void 0===m?m=32:32<m&&(m=32);if(null==l||isNaN(l))for(;0<m--;)p="?"+p;else for(;0<m--;)p=(l&1?"1":"0")+p,l>>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Ee(a,b){if(b)return De(a,b,a.ka[b]);var c=0;for(b in a.ka)De(a,b,a.ka[b]),c++;return 0<c}td.prototype.xb=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
|
||||
function Fe(a,b,c){var d=[],e=V(b)>>>0;for(b=0;b<a.I.length;b++){var f=a.I[b],h=f.u>>>0,g=f.Yb;if(e>=h&&e<h+g){e=ra(f.yb,[e-h],a.xb);0<=e?Ge(a,b,e,d):c&&(e=~e,Ge(a,b,e-1,d),Ge(a,b,e,d));break}}return d}function Ge(a,b,c,d){var e={},f=a.I[b].yb,h=0,g=null;0<=c&&c<f.length&&(h=f[c][0],g=f[c][1]);g&&(e=a.I[b].ra[g],g="."==g.charAt(0)?null:e.l||g);d.push(g);d.push(h);d.push(e.a);d.push(e.c)}
|
||||
function He(a,b){if("?"==b)a.g("frequency commands:"),a.g("\tclear\tclear all frequency counts");else{var c,d=0;if(a.J)if("clear"==b){for(c=0;c<a.J.length;c++)a.J[c]=[c,0];a.g("frequency data cleared");d++}else if(void 0!==b)a.g("unknown frequency command: "+b),d++;else{var e=a.J.slice();e.sort(function(a,b){return b[1]-a[1]});for(c=0;c<e.length;c++){var f=e[c][0],h=e[c][1];h&&(a.g((yd[a.jb[f][0]]+" ").substr(0,5)+" ("+("0x"+n(f,2))+"): "+h+" times"),d++)}}d||a.g("no frequency data available")}}
|
||||
function Ie(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return Ee(a)||a.g("no variables"),!0;if(!c[2])return Ee(a,c[1]);if(!c[3])return delete a.ka[c[1]],!0;var d=Gd(a,c[3]);return void 0!==d?(a.ka[c[1]]=d,!0):!1}a.g("invalid assignment:"+b);return!1}
|
||||
function Je(a,b,c){var d=null;if(b=W(a,b,!0)){var e=Fe(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.u-e[1])&&(h=" + "+q(f)),f=e[0]+" ("+n(e[1],4)+")"+h,c&&a.g(f),d=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.u)&&(h=" - "+q(f)),f=e[4]+" ("+n(e[5],4)+")"+h,c&&a.g(f),d||(d=f))}else c&&a.g("no symbols")}return d}
|
||||
function Qd(a,b){var c;if(b&&"?"==b[1])a.g("register commands:"),a.g("\tr\tdump registers"),a.g("\trx [#]\tset flag or register x to [#]");else{null==c&&(c=!0);if(null!=b&&1<b.length){var d=b[1],e=null,f=d.indexOf("=");if(0<f)e=d.substr(f+1),d=d.substr(0,f);else if(2<b.length)e=b[2];else{a.g("missing value for "+b[1]);return}var f=!1,h=Gd(a,e);if(void 0!==h){var f=!0,g=d.toUpperCase();"E"==g.charAt(0)&&(g=null);switch(g){case "A":a.b.K=h&255;break;case "B":a.b.aa=h&255;break;case "BC":a.b.aa=h<<8&
|
||||
255;case "C":a.b.ga=h&255;break;case "D":a.b.ba=h&255;break;case "DE":a.b.ba=h<<8&255;case "E":a.b.ha=h&255;break;case "H":a.b.ca=h&255;break;case "HL":a.b.ca=h<<8&255;case "L":a.b.ia=h&255;break;case "SP":a.b.ja=h&65535;break;case "PC":a.b.P=h&65535;a.O=R(a.b.P);break;case "PS":yc(a.b,h);break;case "C":h?(d=a.b,d.D|=256):(d=a.b,d.D&=255);break;case "P":h?(d=a.b,wb[d.M&255]||(d.M^=1)):(d=a.b,wb[d.M&255]&&(d.M^=1));break;case "A":h?(d=a.b,d.B=~d.M&16|d.B&-17):(d=a.b,d.B=d.M&16|d.B&-17);break;case "Z":h?
|
||||
(d=a.b,d.D&=-256):(d=a.b,d.D|=255);break;case "S":h?(d=a.b,d.M&128||(d.M^=192)):(d=a.b,d.M&128&&(d.M^=192));break;case "I":h?(d=a.b,d.Ea|=512):(d=a.b,d.Ea&=-513);break;default:a.g("unknown register: "+d);return}}if(!f){a.g("invalid value: "+e);return}I(a.b);a.g("updated registers:")}a.g(X(a,7)+X(a,8)+X(a,0)+X(a,1)+X(a,2)+X(a,3)+X(a,4)+X(a,5)+X(a,13)+$d(a,"I")+$d(a,"S")+$d(a,"Z")+$d(a,"A")+$d(a,"P")+$d(a,"C"));c&&(a.O=R(a.b.P),Rd(a,n(a.O.u,4)))}}
|
||||
function Ke(a,b){b=qa(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Nd(a,c[2])):Gd(a,b,!0)}function Le(a,b,c){var d="t"!=b;c=ce(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Ha(c,function(){return hb(a,!0)&&a.Ta(e,d,!1)},function(){I(a.b);hb(a,!1)})}
|
||||
function Rd(a,b,c,d){if(b=W(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=W(a,c,!0);if(!d||d.u<b.u)return;e=d.u-b.u;if(256<e){a.g("range too large");return}d=-1}c=0;for(var f;0<e&&d--;){f=ib(a,!1)||a.T?a.L:null;var h=null!=f?"cycles":null,g=Fe(a,b),l=b.u;if(g[0]&&d&&(!c&&d||0>g[0].indexOf("+"))){var m=g[0]+":";g[2]&&(m+=" "+g[2]);a.g(m)}g[3]&&(h=g[3],f=null);f=Zd(a,b,h,f);a.g(f);a.O=b;e-=b.u-l;c++}}}
|
||||
function Id(a,b,c,d){if(c)if(b){0>a.F&&a.B.length&&(a.F=0);if(0>a.F||b!=a.B[a.F])a.B.splice(0,0,b),a.F=0;a.F--}else b=a.B[a.F+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==d&&!e||!h)a.push(qa(b.substring(c,f))),c=f+1}}return a}
|
||||
function Yd(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.na&&(a.g("ended assemble at "+n(a.da.u,4)),a.O=a.da,a.na=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.xa=null;if(tb(a)&&0<b.length){a.na&&(b="a "+n(a.da.u,4)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),l=1;l<h.length;l++){var m=h.charAt(l);if("?"==g||"r"==g||"a">m||"z"<m){f[0]=h.substr(l);f.unshift(h.substr(0,l));break}}switch(f[0].charAt(0)){case "a":var p=W(a,f[1],!0);if(p)if(a.da=
|
||||
p,void 0===f[2])a.g("begin assemble at "+n(p.u,4)),a.na=!0,I(a.b);else{var r;a.g("not supported yet");r=[];if(r.length){for(var t=0;t<r.length;t++)a.vb(p,r[t],1);a.g(Zd(a,a.da))}}break;case "b":a:{var K=f[0],B=f[1],ff=b;if("?"==B)a.g("breakpoint commands:"),a.g("\tbi [p]\ttoggle break on input port [p]"),a.g("\tbo [p]\ttoggle break on output port [p]"),a.g("\tbp [a]\tset exec breakpoint at addr [a]"),a.g("\tbr [a]\tset read breakpoint at addr [a]"),a.g("\tbw [a]\tset write breakpoint at addr [a]"),
|
||||
a.g("\tbc [a]\tclear breakpoint at addr [a]"),a.g("\tbl\tlist all breakpoints"),a.g("\tbn [n]\tbreak after [n] instruction(s)");else{var Z=K.charAt(1);if("l"==Z){var Ka=0,Ka=Ka+Xd(a,a.w),Ka=Ka+Xd(a,a.S);(Ka+=Xd(a,a.G))||a.g("no breakpoints")}else if("n"==Z)a.wa=ce(a,B),a.g("break after "+a.wa+" instruction(s)");else if(void 0===B)a.g("missing breakpoint address");else{var A=R();if("*"!=B&&(A=W(a,B,!0),!A))break a;B=q(A.u);"c"==Z?null==A.u?(ud(a),a.g("all breakpoints cleared")):Vd(a,a.w,A)||Vd(a,a.S,
|
||||
A)||Vd(a,a.G,A)||a.g("breakpoint missing: "+n(A.u,4)):"i"==Z?a.g("breakpoint "+(Fb(a.A,A.u)?"enabled":"cleared")+": port "+B+" (input)"):"o"==Z?a.g("breakpoint "+(Gb(a.A,A.u)?"enabled":"cleared")+": port "+B+" (output)"):null!=A.u&&(Hd(a,A,ff),"p"==Z?a.ya(a.w,A):"r"==Z?a.ya(a.S,A):"w"==Z?a.ya(a.G,A):a.g("unknown breakpoint command: "+Z))}}}break;case "c":a.za&&(a.za.value="");break;case "d":a:{var La,Ma=f[0],aa=f[1],ua=f[2],gf=f[3];if("?"==aa){var ba="";for(La in U)a.Wa[La]&&(ba&&(ba+=","),ba+=La);
|
||||
ba+=",state,symbols";a.g("dump memory commands:");a.g("\tdb [a] [#] dump # bytes at address a");a.g("\tdw [a] [#] dump # words at address a");a.g("\tdd [a] [#] dump # dwords at address a");a.g("\tdh [#] [#] dump # instructions from history");ba.length&&a.g("dump extension commands:\n\t"+ba)}else if("state"==aa){var de=Me(a.s,!0);"console"==ua?console.log(de):(a.za&&(a.za.value=""),a.g(de))}else if("symbols"==aa)for(var Fc=0;Fc<a.I.length;Fc++){var Gc=a.I[Fc],Oa;for(Oa in Gc.ra)if("."!=
|
||||
Oa.charAt(0)){var ee=Gc.ra[Oa].o;if(void 0!==ee){var fe=Gc.ra[Oa].l;fe&&(Oa=fe);a.g(n(ee,4)+" "+Oa)}}}else{if("d"==Ma){for(La in U)if(f[1]==La){var ge=a.Wa[La];ge?(f.shift(),f.shift(),ge(f)):a.g("no dump registered for "+aa);break a}aa||(Ma=a.Xb||"db")}else a.Xb=Ma;if("dh"==Ma){var he=aa,ie=ua,je="",ke=0,D=a.oa,ca=a.N;if(ca.length){var L=+he||a.Cb,Pa=+ie||10;isNaN(L)?L=Pa:je="more ";L>ca.length&&(a.g("note: only "+ca.length+" available"),L=ca.length);D-=L;0>D&&(null==ca[ca.length-1].u?(L=D+L,D=0):
|
||||
D+=ca.length);var Hc=[];"call"==ie&&(Pa=1E5,Hc=["CALL"]);for(void 0!==he&&a.g(L+" instructions earlier:");0<Pa&&D!=a.oa;){var le=ca[D++];if(null==le.u)break;var jb=R(le.u),hf=L--,me=Zd(a,jb,"history",hf);(!Hc.length||0<=me.indexOf(Hc[0]))&&a.g(me);jb.nb&&(D+=jb.nb,Pa-=jb.nb,L-=jb.nb);D>=ca.length&&(D=0);a.Cb=L;ke++;Pa--}}ke||(a.g("no "+je+"history available"),a.Cb=void 0)}else{var Pb=W(a,aa);if(Pb){var Qb=0;ua&&("l"==ua.charAt(0)&&(ua=ua.substr(1)||gf),Qb=ce(a,ua)>>>0,65536<Qb&&(Qb=65536));for(var va=
|
||||
"",jf=(Qb||128)+15>>4||1,Ic="dd"==Ma?4:"dw"==Ma?2:1,ne=0;ne<jf;ne++){for(var Rb=0,Jc=0,kb="",Kc="",aa=n(Pb.u,4),Lc=0;16>Lc;Lc++){var Sb=a.ua(Pb,1),Rb=Rb|Sb<<(Jc++<<3);Jc==Ic&&(kb+=n(Rb,2*Ic),kb+=1==Ic?7==Lc?"-":" ":" ",Rb=Jc=0);Kc+=32<=Sb&&128>Sb?String.fromCharCode(Sb):"."}va&&(va+="\n");va+=aa+" "+kb+" "+Kc}va&&a.g(va);a.zb=Pb}}}}break;case "e":if("else"==f[0])break;var Tb=1,oe=255,pe=a.ua,qe=a.vb;"ew"==f[0]&&(Tb=2,oe=65535,pe=a.ib,qe=a.Qb);var re=Tb<<1,se=f[1];if(null==se)a.g("edit memory commands:"),
|
||||
a.g("\teb [a] [...] edit bytes at address a"),a.g("\tew [a] [...] edit words at address a");else{var Ub=W(a,se);if(Ub)for(var Vb=2;Vb<f.length;Vb++){var lb=Gd(a,f[Vb]);if(void 0===lb){a.g("unrecognized value: "+f[Vb]);break}lb&~oe&&a.g("warning: "+n(lb)+" exceeds "+Tb+"-byte value");var kf=pe.call(a,Ub);a.g("changing "+n(Ub.u,4)+" from 0x"+n(kf,re)+" to 0x"+n(lb,re));qe.call(a,Ub,lb,Tb)}}break;case "f":He(a,f[1]);break;case "g":a:{var te=f[1],lf=b;if(void 0!==te){var Mc=W(a,te,!0);if(!Mc)break a;
|
||||
Hd(a,Mc,lf);a.ya(a.w,Mc,!0)}a.Fa(!0)||c||a.g("cpu busy or unavailable, run command ignored")}break;case "h":var Nc;a.j.X?(Nc="halting",a.U()):Nc="already halted";c||a.g(Nc);break;case "i":if("if"==f[0]){var Oc;var mb=b.substr(2),mb=qa(mb);Gd(a,mb)?(c||a.g("true: "+mb),Oc=!0):(c||a.g("false: "+mb),Oc=!1);Oc||(d=!1);break}var Pc=f[1];if(Pc&&"?"!=Pc){var Qc=ce(a,Pc);if(void 0!==Qc){for(var S=a.A,ma=Qc,Rc=1,Sc=0,Tc=0;0<Rc;){var Wb=S.B[ma],nb=S.T[ma]||1,Uc=1==nb?255:2==nb?65535:-1,na=Uc;void 0!==Wb?(Wb[0]&&
|
||||
(na=Wb[0](ma,void 0),void 0===na?na=Uc:na&=Uc),S.C&&S.G!=Wb[1]&&Td(S.C,ma,na)):S.C&&(Od(S.C,S,ma,null),S.G&&Td(S.C,ma,na));Sc|=na<<Tc;Tc+=nb<<3;ma+=nb;Rc-=nb}a.g(q(Qc)+": "+("0x"+n(Sc,2)))}}else a.g("input commands:"),a.g("\ti [p]\tread port [p]"),a.g("warning: port accesses can affect hardware state");break;case "k":var mf=f[0];if("?"==f[1])a.g("stack trace commands:"),a.g("\tk\tshow frame addresses"),a.g("\tks\tshow symbol information");else{var Vc=0,ue=R(),ob=R(a.b.ja);for(a.g("stack trace for "+
|
||||
n(ob.u,4));10>Vc;){for(var wa=null,nf=256;65536>ob.u>>>0;){ue.u=a.ib(ob,2);if(null==ob.u||!nf--)break;for(var of=a,Xb=ue,ve=null,pb=Xb.u,we=pb,Wc=1;6>=Wc&&pb;Wc++){if(2<Wc){Xb.u=pb;var Yb=Zd(of,Xb);if(0<Yb.indexOf("CALL")){var xe=Yb.indexOf(" ");if(pb+(Yb.indexOf(" ",xe+1)-xe-1)/2==we){ve=Yb;break}}}pb--}Xb.u=we;if(wa=ve)break}if(!wa||null==wa)break;var ye=null;if("ks"==mf){var ze=wa.match(/[0-9A-F]+$/);ze&&(ye=Je(a,ze[0]))}wa=la(wa,50)+" ;"+(ye||"stack="+n(ob.u,4));a.g(wa);Vc++}Vc||a.g("no return addresses found")}break;
|
||||
case "l":if("ln"==f[0]){Je(a,f[1],!0);break}break;case "m":a:{var da,ea=null,w=f[1];"?"==w&&(w=void 0);if(void 0!==w){var xa=0;if("all"==w)xa=1610481663,w=null;else if("on"==w)ea=!0,w=null;else if("off"==w)ea=!1,w=null;else{"keys"==w&&(w="key");"kbd"==w&&(w="keyboard");for(da in U)if(w==da){xa=U[da];ea=!!(a.Y&xa);break}if(!xa){a.g("unknown message category: "+w);break a}}xa&&("on"==f[2]?(a.Y|=xa,ea=!0):"off"==f[2]&&(a.Y&=~xa,ea=!1))}var pf=0,oa="";for(da in U)if(!w||w==da){var qf=!!(a.Y&U[da]);if(null===
|
||||
ea||ea==qf)oa&&(oa+=","),++pf%10||(oa+="\n\t"),"key"==da&&(da="keys"),oa+=da}void 0===w&&a.g("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.g((null!==ea?ea?"messages on: ":"messages off: ":"message categories:\n\t")+(oa||"none"));vd(a)}break;case "o":var Xc=f[1],rf=f[2];if(Xc&&"?"!=Xc){var Yc=ce(a,Xc,"port #"),Zc=ce(a,rf);if(void 0!==Yc&&void 0!==Zc){for(var T=a.A,pa=Yc,Ae=Zc,$c=1,ad=0;0<$c;){var Zb=T.F[pa],qb=T.V[pa]||1,sf=1==qb?255:2==qb?65535:-1,$b=(Ae>>>=ad)&sf;if(void 0!==
|
||||
Zb){if(Zb[0])Zb[0](pa,$b,void 0);T.C&&T.I!=Zb[1]&&Ud(T.C,pa,$b)}else T.C&&(Od(T.C,T,pa,$b),T.I&&Ud(T.C,pa,$b));ad+=qb<<3;pa+=qb;$c-=qb}a.g(q(Yc)+": "+("0x"+n(Zc,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){Ke(a,b.substr(5));break}var Be="pr"==f[0]?1:0,tf=1+Be;if(a.T)a.g("step in progress");else{var bd=R(a.b.P);switch(a.ua(bd)){case 205:a.T=tf,Cd(bd,3)}a.T?(a.ya(a.w,bd,!0),
|
||||
a.Fa()||(a.s&&a.s.gb(),a.T=0)):Le(a,Be?"tr":"t")}break;case "r":if("reset"==b){a.s&&a.s.reset();break}Qd(a,f);break;case "t":Le(a,f[0],f[1]);break;case "u":Rd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){Ie(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Hb+",RELEASE"+(vb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(Aa());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var rb;void 0!==f[3]&&(rb=+f[3]);switch(f[2]){case "int":a.b.i.Na=rb;break;case "start":a.b.i.$a=rb;break;case "stop":a.b.i.Pa=
|
||||
rb;break;default:a.g("unknown cs option");break a}void 0!==rb&&nc(a.b);a.g("checksums "+(a.b.j.Ia?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(sc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.Ba.toFixed(2)+"Mhz")+" ("+a.b.i.Da+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),a.g("\tcs stop #\tset checksum cycle stop count to #"),
|
||||
a.g("\tsp #\t\tset speed multiplier to #");break;case "?":if(f[1]){Ke(a,b.substr(1));break}var sb="commands:",cd;for(cd in xd)sb+="\n"+la(cd,7)+xd[cd];kd(a)||(sb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(sb);break;default:a.g("unknown command: "+b),d=!1}}}catch(Ce){a.g("debugger error: "+(Ce.stack||Ce.message)),d=!1}return d}function oc(a,b,c){b=Id(a,b,c);for(var d in b)if(!Yd(a,b[d]))return!1;return!0}
|
||||
Sa(function(){for(var a=F(document,"pc8080","debugger"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new td(d);eb(d,c)}});function J(a,b,c){this.id=a.id;this.key=Ne(a,b,c);this.C=a.C;Oe(this,a.Lb)}function Ne(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
|
||||
J.prototype={constructor:J,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Oe(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
|
||||
function Oe(a,b){a[a.id]={};b&&M(a,"parms",b);a.b=!1}function Pe(a){var b=!0;if(Da()){var c=JSON.stringify(a[a.id]);Fa(a.key,c)||(v("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Qe(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){v(c.message||c),b=!1}return b}function Re(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:Da()&&(b=Ea(a.key))?(a[a.id]=b,a.b=!0):!1}function Se(a,b){return a[a.id][b]||null}function M(a,b,c){try{a[a.id][b]=c}catch(d){}}
|
||||
function Te(a,b,c){x.call(this,"Computer",a,Te,67108864);this.j.W=!1;Ue(this,b);this.S=lc(this,"autoPower",a);this.B=0;this.na=a.busWidth||a.buswidth;this.s=Ve;this.N=null;this.I=this.ka=!1;this.oa=lc(this,"url")||"";(Math.random()+.1).toString(36);this.w=We(this);if(this.b=db("CPU",this.id)){this.C=db("Debugger",this.id);this.qa=[];for(b=null;b=yb(this,"Video",b);)this.qa.push(b);this.A=new Ab({id:this.Ab+".bus",buswidth:this.na},this.b,this.C);var d,e=C(this.id);if((this.F=db("Panel",this.id))&&
|
||||
this.F.za)for(b=0;b<e.length;b++)d=e[b],d.fa=this.F.fa,d.g=this.F.g,d.za=this.F.za;for(b=0;b<e.length;b++)d=e[b],d.La&&d.La(this,this.A,this.b,this.C);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.L=d:this.s=parseInt(d,10));var f;if(a=lc(this,"state")||(f=!0,a.state))b=this.T=a,f||(this.I=!0,this.s=Ve),this.s&&(this.O=new J(this,Y),Re(this.O)?b=null:delete this.O);!b&&this.s&&(b=Xe(this))&&(this.I=!0);if(b){var h=this;u(b,null,!0,function(a,b,c){c?(h.L=null,h.I=!1,h.fa("Unable to load machine state from server (error "+
|
||||
c+(b?": "+qa(b):"")+")")):(h.N=b,h.ka=!0);G(h)})}else G(this);this.H.power||(this.S=!0);!c&&this.S&&Ye(this,this.eb)}else v("Unable to find CPU component")}z(Te);var Y="1.21.7",Ve=0;function Ue(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){v(d.message+" ("+c+")")}}a.J=b}
|
||||
function lc(a,b,c){var d=b.toLowerCase(),d=Xa[b]||Xa[d];void 0===d&&a.J&&(d=a.J[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Ye(a,b,c){for(var d=C(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!tb(f)){tb(f,function(){Ye(a,b,c)});return}}b.call(a,c)}
|
||||
function Ze(a,b){var c=new J(a,Y,"validate");if(Re(c)&&Qe(c)){var d=Se(c,"timestamp"),e=b?Se(b,"timestamp"):"unknown";d!=e&&(a.fa("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=Te.prototype;
|
||||
k.eb=function(a){void 0===a&&(a=this.s||(this.N?1:Ve));if(!this.B){this.B++;var b=!1,c=!1;this.da=!1;var d=this.O||new J(this,Y);if(-1==a)b=!0;else if(a>Ve){if(Re(d,this.N)){this.G=new J(this,Y,"failsafe");Re(this.G)&&($e(this,d),a=2,Oe(this.G));M(this.G,"timestamp",ta());Pe(this.G);var e=this.s&&!this.I;if(1==a||Ba("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Qe(d)){var f=Se(d,"code"),h=Se(d,"data");f&&("ok"==f?Re(d,h):("error"==f&&"no machine state"!=
|
||||
h?(this.fa("Error: "+h),"unable to verify user"==h&&(Fa("user",""),this.w=null)):this.g(f+": "+h),Oe(d),Re(d)?(c=Qe(d),e=!0):c=!1))}e&&Ze(this,c?d:null)}else 2==a&&d.clear()}else Ze(this);delete this.N;delete this.O}e=C(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.b&&(c=af(this,h,d,b,c));b=[d,a,c];-1!=a?Ye(this,this.Db,b):this.Db(b)}};
|
||||
function af(a,b,c,d,e){if(!b.j.W){b.j.W=!0;if(b.ta){var f=null;e&&((f=Se(c,b.id))||(f=Se(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.ta(f,d)&&f&&(v("Unable to restore state for "+b.type),a.T&&!a.ka?(c.clear(),a.s=Ve,window&&window.location.reload()):a.da=!0,b.ta(null),e=!1)}if(!d&&b.wb)for(a=b.wb.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
|
||||
k.Db=function(a){var b=a[0],c=0>a[1];a=a[2];this.j.W=!0;var d=this.H.power;d&&(d.textContent="Shutdown");this.V||(this.g("PC8080 v"+Y+"\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>"),this.V=!0);this.b&&(af(this,this.b,b,c,a),pc(this.b));this.da&&($e(this,b),b.clear());!c&&this.G&&(this.G.clear(),delete this.G);this.B=0};
|
||||
function $e(a,b){if(Ba("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.oa,d=a.w||"",e=b.toString(),f={app:"PC8080"};f.ver=Y;f.url=c;f.user=d;f.type="bug";f.data=e;u("http://www.pcjs.org/api/v1/report",f,!0)}}
|
||||
function Me(a,b,c){var d,e="none";if(a.B)return null;a.B--;var f=new J(a,Y),h=new J(a,Y,"validate"),g=ta();M(h,"timestamp",g);M(f,"timestamp",g);M(f,"version","1.21.7");M(f,"url",window?window.location.href:null);M(f,"browser",Aa());a.b&&a.b.sa&&(c&&a.b.U(),d=a.b.sa(b,c),"object"===typeof d&&M(f,a.b.id,d),c&&(a.b.j.W=!1,!1===d&&(e=null)));for(var g=C(a.id),l=0;l<g.length;l++){var m=g[l];m.j.W&&(m.sa&&(d=m.sa(b,c),"object"===typeof d&&M(f,m.id,d)),c&&(m.j.W=!1,!1===d&&(e=null)))}e&&(c?(g=d=!1,b?(a.w&&
|
||||
bf(a,a.w,f.toString()),Pe(h)&&Pe(f)||(e=null,d=g=!0)):a.s&&(d=!0,g=3==a.s),d&&f.clear(g)):e=f.toString());c&&(a.j.W=!1,b=a.H.power)&&(b.textContent="Power");a.B=0;return e}k.reset=function(){this.A&&this.A.reset&&(fb(this,"Resetting "+this.A.type),this.A.reset());for(var a=C(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.A&&c.reset&&(fb(this,"Resetting "+c.type),c.reset())}};
|
||||
k.start=function(a,b){for(var c=C(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};k.stop=function(a,b){for(var c=C(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
|
||||
k.la=function(a,b,c){var d=this;switch(b){case "power":return this.H[b]=c,c.onclick=function(){d.B||(d.j.W?Me(d,!1,!0):Ye(d,d.eb))},!0;case "reset":return this.H[b]=c,c.onclick=function(){if(d.j.W&&!d.B)if(d.s&&!d.L){var a=Ba("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Me(d,a,!0);!a&&d.T?window&&window.location.reload():d.eb(Ve)}else d.reset(),d.b&&pc(d.b)},!0;case "save":if(ia(za(),"pcjs.org")){c.parentNode.removeChild(c);break}this.H[b]=
|
||||
c;c.onclick=function(){var a=We(d,!0);if(a){var b=!!(d.s&&!d.L||d.T),c=Me(d,b);b?bf(d,a,c):d.fa("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function We(a,b){var c=a.w;c||(c=Ea("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=cf(a,c))||a.fa("The user ID is invalid."))):b&&a.fa("Browser local storage is not available"));return c}
|
||||
function cf(a,b){a.w=null;var c=u(za()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(Fa("user",c.data),a.w=c.data)}catch(e){v(e.message+" ("+d+")")}return a.w}function Xe(a){var b=null;a.w&&(b=za()+"/api/v1/user?req=load&user="+a.w+"&state="+Ne(a,Y));return b}
|
||||
function bf(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Ne(a,Y);d.data=c;b=u(za()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.fa("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.fa(c),Fa("user",""),a.w=null)}}
|
||||
function yb(a,b,c){a=C(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}k.gb=function(){};k.ma=function(a){this.b&&this.b.ma(a);this.F&&this.F.ma(a)};Sa(function(){for(var a=F(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=E(c),c=F(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=E(f),h=new Te(h,d,!0);eb(h,f);h.S&&Ye(h,h.eb)}});
|
||||
Ja.show.push(function(){for(var a=F(document,"pc8080","computer"),b=0;b<a.length;b++){var c=E(a[b]);(c=db("Computer",c.id))&&c.V&&!c.j.W&&c.eb(-1)}});Ja.exit.push(function(){for(var a=F(document,"pc8080","computer"),b=0;b<a.length;b++){var c=E(a[b]);(c=db("Computer",c.id))&&c.j.W&&Me(c,!(!c.s||c.L),!0)}});var df=0;function ef(a,b,c,d,e,f){e("Loading "+a+"...");u(a,null,!0,function(h,g,l){l?(g||(g="unable to load "+a+" ("+l+")"),f(g,null)):uf(g,a,b,c,d,e,f)})}
|
||||
function uf(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){cb(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
|
||||
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){g=null,a=r.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?vf(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
|
||||
function vf(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");u(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=g[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);g[0]!=l&&(h=h.replace(g[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(d[0],h);vf(a,b,c)}})}else c(a,null)}
|
||||
function wf(a,b,c,d){function e(a){if(void 0===g){var b=h&&F(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ka(a))}function f(a){e("Error: "+a);l&&(--df||Ua(!0));l=!1}var h,g,l=!0;df++;bb[a]={};try{if(h=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=m:r.appendChild(document.createTextNode(m));p.appendChild(r)}c||
|
||||
(c="/versions/pc8080/1.21.7/components.xsl");m=function(d,g){g?ef(c,null,null,!1,e,function(d,m){if(m)if(cb(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(m);l?(h.outerHTML=l,--df||Ua(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--df||Ua(!0)):f("invalid machine element: "+
|
||||
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?ef(b,a,d,!0,e,m):uf(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(t){f(t.message)}return l}window.embedPC8080=function(a,b,c,d){Ua(!1);return wf(a,b,c,d)};window.enableEvents=Ua;window.sendEvent=Va;
|
||||
function xf(a,b,c,d){if(!c&&b){d.push(b);a=bb[d[0]];b=null;for(var e in a)if(ia(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?u(b,null,!0,function(a,b){yf(b,d)}):yf(null,d)}else v("Error ("+c+") requesting "+a)}
|
||||
function yf(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=bb[f],l={},m;for(m in g){var p=g[m],r=ha(m);if("xml"==r){for(r=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(g[m]);){var t=d[2];t&&(g[t]||(p=p.replace(d[0],"")))}d=m=ga(m)}else"xsl"==r&&(e=m=ga(m));l[m]=p}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&e?(m=JSON.stringify(l),h+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
|
||||
"©"),m=h,g=null,l="data:application/javascript,",l=Ga("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),m&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=l,g.download=m,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+m+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(m?" ("+m+")":"")+"."),c+=', copy it to your web server as "'+h+'", and then add the following to your web page:\n\n',
|
||||
function Hd(a,b,c){var d;if(b){b=Gd(a,b);for(var e=0,f=!1,h=b,g=[],m=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<l.length;){var p=l[e++],r=p.length,p=na(p);if(!p){f=!0;break}p=ee(a,p,null,!1===c);if(void 0===p){f=!0;c=!1;break}g.push(p);if(e==l.length)break;var p=l[e++],u=p.length;m.length&&ce[p]<ce[m[m.length-1]]&&de(g,m,1);m.push(p);b=b.substr(r+u)}de(g,m)&&1==g.length||(f=!0);f?c&&a.g("error parsing '"+h+"' at character "+(h.length-b.length)):(d=g.pop(),c&&Fe(a,null,
|
||||
d))}return d}function Gd(a,b){for(var c;(c=b.match(/\{(.*?)}/))&&!(0<=c[1].indexOf("{"));){var d=Hd(a,c[1]);b=b.replace("{"+c[1]+"}",null!=d?n(d):"undefined")}for(;(c=b.match(/\[(.*?)]/))&&!(0<=c[1].indexOf("["));)d=Y(a,c[1]),b=b.replace("["+c[1]+"]",d?n(a.jb(d,0),4):"undefined");for(c=b;d=c.match(/\$([a-z]+)/i);){var e=null;switch(d[1].toLowerCase()){case "ops":e=a.ca-a.Ha}if(null==e)break;c=c.replace(d[0],e.toString())}return c}
|
||||
function ee(a,b,c,d){var e;void 0!==b?(e=Ld(b),0<=e?e=Nd(a,e):(e=a.na[b],void 0===e&&(e=aa(b))),void 0!==e||d||a.g("invalid "+(c?c:"value")+": "+b)):d||a.g("missing "+(c||"value"));return e}
|
||||
function Fe(a,b,c){var d,e=!1;if(void 0!==c){e=!0;d=c;var f,h="";if(!f||4<f)f=4;for(var g=0;g<f;g++){h&&(h=","+h);var m=d&255,l=8,p="";void 0===l?l=32:32<l&&(l=32);if(null==m||isNaN(m))for(;0<l--;)p="?"+p;else for(;0<l--;)p=(m&1?"1":"0")+p,m>>=1;h=p+"b"+h;d>>=8}d="0x"+n(c)+" "+c+". ("+h+")"}a.g((null!=b?b+": ":"")+d);return e}function Ge(a,b){if(b)return Fe(a,b,a.na[b]);var c=0;for(b in a.na)Fe(a,b,a.na[b]),c++;return 0<c}ud.prototype.yb=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
|
||||
function He(a,b,c){var d=[],e=X(b)>>>0;for(b=0;b<a.J.length;b++){var f=a.J[b],h=f.w>>>0,g=f.Zb;if(e>=h&&e<h+g){e=oa(f.zb,[e-h],a.yb);0<=e?Ie(a,b,e,d):c&&(e=~e,Ie(a,b,e-1,d),Ie(a,b,e,d));break}}return d}function Ie(a,b,c,d){var e={},f=a.J[b].zb,h=0,g=null;0<=c&&c<f.length&&(h=f[c][0],g=f[c][1]);g&&(e=a.J[b].sa[g],g="."==g.charAt(0)?null:e.l||g);d.push(g);d.push(h);d.push(e.a);d.push(e.c)}
|
||||
function Je(a,b){if("?"==b)a.g("frequency commands:"),a.g("\tclear\tclear all frequency counts");else{var c,d=0;if(a.K)if("clear"==b){for(c=0;c<a.K.length;c++)a.K[c]=[c,0];a.g("frequency data cleared");d++}else if(void 0!==b)a.g("unknown frequency command: "+b),d++;else{var e=a.K.slice();e.sort(function(a,b){return b[1]-a[1]});for(c=0;c<e.length;c++){var f=e[c][0],h=e[c][1];h&&(a.g((zd[a.kb[f][0]]+" ").substr(0,5)+" ("+("0x"+n(f,2))+"): "+h+" times"),d++)}}d||a.g("no frequency data available")}}
|
||||
function Ke(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return Ge(a)||a.g("no variables"),!0;if(!c[2])return Ge(a,c[1]);if(!c[3])return delete a.na[c[1]],!0;var d=Hd(a,c[3]);return void 0!==d?(a.na[c[1]]=d,!0):!1}a.g("invalid assignment:"+b);return!1}
|
||||
function Le(a,b,c){var d=null;if(b=Y(a,b,!0)){var e=He(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.w-e[1])&&(h=" + "+q(f)),f=e[0]+" ("+n(e[1],4)+")"+h,c&&a.g(f),d=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.w)&&(h=" - "+q(f)),f=e[4]+" ("+n(e[5],4)+")"+h,c&&a.g(f),d||(d=f))}else c&&a.g("no symbols")}return d}
|
||||
function Rd(a,b){var c;if(b&&"?"==b[1])a.g("register commands:"),a.g("\tr\tdump registers"),a.g("\trx [#]\tset flag or register x to [#]");else{var d=a.b;null==c&&(c=!0);if(null!=b&&1<b.length){var e=b[1],f=null,h=e.indexOf("=");if(0<h)f=e.substr(h+1),e=e.substr(0,h);else if(2<b.length)f=b[2];else{a.g("missing value for "+b[1]);return}var h=!1,g=Hd(a,f);if(void 0!==g){var h=!0,m=e.toUpperCase();"E"==m.charAt(0)&&(m=null);switch(m){case "A":d.j=g&255;break;case "B":d.L=g&255;break;case "BC":d.L=g>>
|
||||
8&255;case "C":d.O=g&255;break;case "D":d.M=g&255;break;case "DE":d.M=g>>8&255;case "E":d.P=g&255;break;case "H":d.N=g&255;break;case "HL":d.N=g>>8&255;case "L":d.R=g&255;break;case "SP":d.ja=g&65535;break;case "PC":d.U=g&65535;a.W=T(d.U);break;case "PS":zc(d,g);break;case "C":d.F=g?d.F|256:d.F&255;break;case "P":g?xb[d.S&255]||(d.S^=1):xb[d.S&255]&&(d.S^=1);break;case "A":d.ka=g?~d.S&16|d.ka&-17:d.S&16|d.ka&-17;break;case "Z":d.F=g?d.F&-256:d.F|255;break;case "S":g?d.S&128||(d.S^=192):d.S&128&&(d.S^=
|
||||
192);break;case "I":d.Fa=g?d.Fa|512:d.Fa&-513;break;default:a.g("unknown register: "+e);return}}if(!h){a.g("invalid value: "+f);return}I(d);a.g("updated registers:")}a.g(be(a,7)+be(a,8)+be(a,0)+be(a,1)+be(a,2)+be(a,3)+be(a,4)+be(a,5)+be(a,13)+ae(a,"I")+ae(a,"S")+ae(a,"Z")+ae(a,"A")+ae(a,"P")+ae(a,"C"));c&&(a.W=T(d.U),Sd(a,n(a.W.w,4)))}}function Me(a,b){b=na(b);var c=b.match(/^(['"])(.*?)\1$/);c?a.g(Od(a,c[2])):Hd(a,b,!0)}
|
||||
function Ne(a,b,c){var d="t"!=b;c=ee(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Ia(c,function(){return ib(a,!0)&&a.Ua(e,d,!1)},function(){I(a.b);ib(a,!1)})}
|
||||
function Sd(a,b,c,d){if(b=Y(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c){d=Y(a,c,!0);if(!d||d.w<b.w)return;e=d.w-b.w;if(256<e){a.g("range too large");return}d=-1}c=0;for(var f;0<e&&d--;){f=jb(a,!1)||a.aa?a.T:null;var h=null!=f?"cycles":null,g=He(a,b),m=b.w;if(g[0]&&d&&(!c&&d||0>g[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=$d(a,b,h,f);a.g(f);a.W=b;e-=b.w-m;c++}}}
|
||||
function Jd(a,b,c,d){if(c)if(b){0>a.G&&a.D.length&&(a.G=0);if(0>a.G||b!=a.D[a.G])a.D.splice(0,0,b),a.G=0;a.G--}else b=a.D[a.G+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==d&&!e||!h)a.push(na(b.substring(c,f))),c=f+1}}return a}
|
||||
function Zd(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.oa&&(a.g("ended assemble at "+n(a.ga.w,4)),a.W=a.ga,a.oa=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ya=null;if(kb(a)&&0<b.length){a.oa&&(b="a "+n(a.ga.w,4)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),m=1;m<h.length;m++){var l=h.charAt(m);if("?"==g||"r"==g||"a">l||"z"<l){f[0]=h.substr(m);f.unshift(h.substr(0,m));break}}switch(f[0].charAt(0)){case "a":var p=Y(a,f[1],!0);if(p)if(a.ga=
|
||||
p,void 0===f[2])a.g("begin assemble at "+n(p.w,4)),a.oa=!0,I(a.b);else{var r;a.g("not supported yet");r=[];if(r.length){for(var u=0;u<r.length;u++)a.wb(p,r[u],1);a.g($d(a,a.ga))}}break;case "b":a:{var N=f[0],D=f[1],hf=b;if("?"==D)a.g("breakpoint commands:"),a.g("\tbi [p]\ttoggle break on input port [p]"),a.g("\tbo [p]\ttoggle break on output port [p]"),a.g("\tbp [a]\tset exec breakpoint at addr [a]"),a.g("\tbr [a]\tset read breakpoint at addr [a]"),a.g("\tbw [a]\tset write breakpoint at addr [a]"),
|
||||
a.g("\tbc [a]\tclear breakpoint at addr [a]"),a.g("\tbl\tlist all breakpoints"),a.g("\tbn [n]\tbreak after [n] instruction(s)");else{var ba=N.charAt(1);if("l"==ba){var Ma=0,Ma=Ma+Yd(a,a.A),Ma=Ma+Yd(a,a.Y);(Ma+=Yd(a,a.H))||a.g("no breakpoints")}else if("n"==ba)a.xa=ee(a,D),a.g("break after "+a.xa+" instruction(s)");else if(void 0===D)a.g("missing breakpoint address");else{var C=T();if("*"!=D&&(C=Y(a,D,!0),!C))break a;D=q(C.w);"c"==ba?null==C.w?(vd(a),a.g("all breakpoints cleared")):Wd(a,a.A,C)||Wd(a,
|
||||
a.Y,C)||Wd(a,a.H,C)||a.g("breakpoint missing: "+n(C.w,4)):"i"==ba?a.g("breakpoint "+(Gb(a.C,C.w)?"enabled":"cleared")+": port "+D+" (input)"):"o"==ba?a.g("breakpoint "+(Hb(a.C,C.w)?"enabled":"cleared")+": port "+D+" (output)"):null!=C.w&&(Id(a,C,hf),"p"==ba?a.za(a.A,C):"r"==ba?a.za(a.Y,C):"w"==ba?a.za(a.H,C):a.g("unknown breakpoint command: "+ba))}}}break;case "c":a.Aa&&(a.Aa.value="");break;case "d":a:{var Na,Oa=f[0],ca=f[1],ya=f[2],jf=f[3];if("?"==ca){var da="";for(Na in W)a.Xa[Na]&&(da&&(da+=","),
|
||||
da+=Na);da+=",state,symbols";a.g("dump memory commands:");a.g("\tdb [a] [#] dump # bytes at address a");a.g("\tdw [a] [#] dump # words at address a");a.g("\tdd [a] [#] dump # dwords at address a");a.g("\tdh [#] [#] dump # instructions from history");da.length&&a.g("dump extension commands:\n\t"+da)}else if("state"==ca){var fe=Oe(a.u,!0);"console"==ya?console.log(fe):(a.Aa&&(a.Aa.value=""),a.g(fe))}else if("symbols"==ca)for(var Hc=0;Hc<a.J.length;Hc++){var Ic=a.J[Hc],Qa;for(Qa in Ic.sa)if("."!=
|
||||
Qa.charAt(0)){var ge=Ic.sa[Qa].o;if(void 0!==ge){var he=Ic.sa[Qa].l;he&&(Qa=he);a.g(n(ge,4)+" "+Qa)}}}else{if("d"==Oa){for(Na in W)if(f[1]==Na){var ie=a.Xa[Na];ie?(f.shift(),f.shift(),ie(f)):a.g("no dump registered for "+ca);break a}ca||(Oa=a.Yb||"db")}else a.Yb=Oa;if("dh"==Oa){var je=ca,ke=ya,le="",me=0,G=a.pa,ea=a.V;if(ea.length){var O=+je||a.Db,Ra=+ke||10;isNaN(O)?O=Ra:le="more ";O>ea.length&&(a.g("note: only "+ea.length+" available"),O=ea.length);G-=O;0>G&&(null==ea[ea.length-1].w?(O=G+O,G=0):
|
||||
G+=ea.length);var Jc=[];"call"==ke&&(Ra=1E5,Jc=["CALL"]);for(void 0!==je&&a.g(O+" instructions earlier:");0<Ra&&G!=a.pa;){var ne=ea[G++];if(null==ne.w)break;var mb=T(ne.w),kf=O--,oe=$d(a,mb,"history",kf);(!Jc.length||0<=oe.indexOf(Jc[0]))&&a.g(oe);mb.ob&&(G+=mb.ob,Ra-=mb.ob,O-=mb.ob);G>=ea.length&&(G=0);a.Db=O;me++;Ra--}}me||(a.g("no "+le+"history available"),a.Db=void 0)}else{var Rb=Y(a,ca);if(Rb){var Sb=0;ya&&("l"==ya.charAt(0)&&(ya=ya.substr(1)||jf),Sb=ee(a,ya)>>>0,65536<Sb&&(Sb=65536));for(var za=
|
||||
"",lf=(Sb||128)+15>>4||1,Kc="dd"==Oa?4:"dw"==Oa?2:1,pe=0;pe<lf;pe++){for(var Tb=0,Lc=0,nb="",Mc="",ca=n(Rb.w,4),Nc=0;16>Nc;Nc++){var Ub=a.va(Rb,1),Tb=Tb|Ub<<(Lc++<<3);Lc==Kc&&(nb+=n(Tb,2*Kc),nb+=1==Kc?7==Nc?"-":" ":" ",Tb=Lc=0);Mc+=32<=Ub&&128>Ub?String.fromCharCode(Ub):"."}za&&(za+="\n");za+=ca+" "+nb+" "+Mc}za&&a.g(za);a.Ab=Rb}}}}break;case "e":if("else"==f[0])break;var Vb=1,qe=255,re=a.va,se=a.wb;"ew"==f[0]&&(Vb=2,qe=65535,re=a.jb,se=a.Rb);var te=Vb<<1,ue=f[1];if(null==ue)a.g("edit memory commands:"),
|
||||
a.g("\teb [a] [...] edit bytes at address a"),a.g("\tew [a] [...] edit words at address a");else{var Wb=Y(a,ue);if(Wb)for(var Xb=2;Xb<f.length;Xb++){var ob=Hd(a,f[Xb]);if(void 0===ob){a.g("unrecognized value: "+f[Xb]);break}ob&~qe&&a.g("warning: "+n(ob)+" exceeds "+Vb+"-byte value");var mf=re.call(a,Wb);a.g("changing "+n(Wb.w,4)+" from 0x"+n(mf,te)+" to 0x"+n(ob,te));se.call(a,Wb,ob,Vb)}}break;case "f":Je(a,f[1]);break;case "g":a:{var ve=f[1],nf=b;if(void 0!==ve){var Oc=Y(a,ve,!0);if(!Oc)break a;
|
||||
Id(a,Oc,nf);a.za(a.A,Oc,!0)}a.Ga(!0)||c||a.g("cpu busy or unavailable, run command ignored")}break;case "h":var Pc;a.s.da?(Pc="halting",a.Z()):Pc="already halted";c||a.g(Pc);break;case "i":if("if"==f[0]){var Qc;var pb=b.substr(2),pb=na(pb);Hd(a,pb)?(c||a.g("true: "+pb),Qc=!0):(c||a.g("false: "+pb),Qc=!1);Qc||(d=!1);break}var Rc=f[1];if(Rc&&"?"!=Rc){var Sc=ee(a,Rc);if(void 0!==Sc){for(var U=a.C,qa=Sc,Tc=1,Uc=0,Vc=0;0<Tc;){var Yb=U.D[qa],qb=U.aa[qa]||1,Wc=1==qb?255:2==qb?65535:-1,ra=Wc;void 0!==Yb?
|
||||
(Yb[0]&&(ra=Yb[0](qa,void 0),void 0===ra?ra=Wc:ra&=Wc),U.B&&U.H!=Yb[1]&&Ud(U.B,qa,ra)):U.B&&(Pd(U.B,U,qa,null),U.H&&Ud(U.B,qa,ra));Uc|=ra<<Vc;Vc+=qb<<3;qa+=qb;Tc-=qb}a.g(q(Sc)+": "+("0x"+n(Uc,2)))}}else a.g("input commands:"),a.g("\ti [p]\tread port [p]"),a.g("warning: port accesses can affect hardware state");break;case "k":var of=f[0];if("?"==f[1])a.g("stack trace commands:"),a.g("\tk\tshow frame addresses"),a.g("\tks\tshow symbol information");else{var Xc=0,we=T(),rb=T(a.b.ja);for(a.g("stack trace for "+
|
||||
n(rb.w,4));10>Xc;){for(var Aa=null,pf=256;65536>rb.w>>>0;){we.w=a.jb(rb,2);if(null==rb.w||!pf--)break;for(var qf=a,Zb=we,xe=null,sb=Zb.w,ye=sb,Yc=1;6>=Yc&&sb;Yc++){if(2<Yc){Zb.w=sb;var $b=$d(qf,Zb);if(0<$b.indexOf("CALL")){var ze=$b.indexOf(" ");if(sb+($b.indexOf(" ",ze+1)-ze-1)/2==ye){xe=$b;break}}}sb--}Zb.w=ye;if(Aa=xe)break}if(!Aa||null==Aa)break;var Ae=null;if("ks"==of){var Be=Aa.match(/[0-9A-F]+$/);Be&&(Ae=Le(a,Be[0]))}Aa=ma(Aa,50)+" ;"+(Ae||"stack="+n(rb.w,4));a.g(Aa);Xc++}Xc||a.g("no return addresses found")}break;
|
||||
case "l":if("ln"==f[0]){Le(a,f[1],!0);break}break;case "m":a:{var fa,ga=null,x=f[1];"?"==x&&(x=void 0);if(void 0!==x){var Ba=0;if("all"==x)Ba=1610481663,x=null;else if("on"==x)ga=!0,x=null;else if("off"==x)ga=!1,x=null;else{"keys"==x&&(x="key");"kbd"==x&&(x="keyboard");for(fa in W)if(x==fa){Ba=W[fa];ga=!!(a.ea&Ba);break}if(!Ba){a.g("unknown message category: "+x);break a}}Ba&&("on"==f[2]?(a.ea|=Ba,ga=!0):"off"==f[2]&&(a.ea&=~Ba,ga=!1))}var rf=0,sa="";for(fa in W)if(!x||x==fa){var sf=!!(a.ea&W[fa]);
|
||||
if(null===ga||ga==sf)sa&&(sa+=","),++rf%10||(sa+="\n\t"),"key"==fa&&(fa="keys"),sa+=fa}void 0===x&&a.g("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.g((null!==ga?ga?"messages on: ":"messages off: ":"message categories:\n\t")+(sa||"none"));wd(a)}break;case "o":var Zc=f[1],tf=f[2];if(Zc&&"?"!=Zc){var $c=ee(a,Zc,"port #"),ad=ee(a,tf);if(void 0!==$c&&void 0!==ad){for(var V=a.C,ta=$c,Ce=ad,bd=1,cd=0;0<bd;){var ac=V.G[ta],tb=V.ca[ta]||1,uf=1==tb?255:2==tb?65535:-1,bc=(Ce>>>=cd)&
|
||||
uf;if(void 0!==ac){if(ac[0])ac[0](ta,bc,void 0);V.B&&V.J!=ac[1]&&Vd(V.B,ta,bc)}else V.B&&(Pd(V.B,V,ta,bc),V.J&&Vd(V.B,ta,bc));cd+=tb<<3;ta+=tb;bd-=tb}a.g(q($c)+": "+("0x"+n(ad,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){Me(a,b.substr(5));break}var De="pr"==f[0]?1:0,vf=1+De;if(a.aa)a.g("step in progress");else{var dd=T(a.b.U);switch(a.va(dd)){case 205:a.aa=vf,Dd(dd,3)}a.aa?
|
||||
(a.za(a.A,dd,!0),a.Ga()||(a.u&&a.u.hb(),a.aa=0)):Ne(a,De?"tr":"t")}break;case "r":if("reset"==b){a.u&&a.u.reset();break}Rd(a,f);break;case "t":Ne(a,f[0],f[1]);break;case "u":Sd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){Ke(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Ib+",RELEASE"+(wb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(xa());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var ub;void 0!==f[3]&&(ub=+f[3]);switch(f[2]){case "int":a.b.i.Oa=ub;break;case "start":a.b.i.ab=
|
||||
ub;break;case "stop":a.b.i.Qa=ub;break;default:a.g("unknown cs option");break a}void 0!==ub&&oc(a.b);a.g("checksums "+(a.b.s.Ja?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(tc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.Ca.toFixed(2)+"Mhz")+" ("+a.b.i.Ea+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),
|
||||
a.g("\tcs stop #\tset checksum cycle stop count to #"),a.g("\tsp #\t\tset speed multiplier to #");break;case "?":if(f[1]){Me(a,b.substr(1));break}var vb="commands:",ed;for(ed in yd)vb+="\n"+ma(ed,7)+yd[ed];ld(a)||(vb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(vb);break;default:a.g("unknown command: "+b),d=!1}}}catch(Ee){a.g("debugger error: "+(Ee.stack||Ee.message)),d=!1}return d}function pc(a,b,c){b=Jd(a,b,c);for(var d in b)if(!Zd(a,b[d]))return!1;return!0}
|
||||
Ta(function(){for(var a=E(document,"pc8080","debugger"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new ud(d);fb(d,c)}});function J(a,b,c){this.id=a.id;this.key=Pe(a,b,c);this.B=a.B;Qe(this,a.Mb)}function Pe(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
|
||||
J.prototype={constructor:J,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Qe(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
|
||||
function Qe(a,b){a[a.id]={};b&&K(a,"parms",b);a.b=!1}function Re(a){var b=!0;if(Ea()){var c=JSON.stringify(a[a.id]);Ga(a.key,c)||(v("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Se(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){v(c.message||c),b=!1}return b}function Te(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:Ea()&&(b=Fa(a.key))?(a[a.id]=b,a.b=!0):!1}function Ue(a,b){return a[a.id][b]||null}function K(a,b,c){try{a[a.id][b]=c}catch(d){}}
|
||||
function Ve(a,b,c){w.call(this,"Computer",a,Ve,67108864);this.s.ba=!1;We(this,b);this.Y=mc(this,"autoPower",a);this.D=0;this.oa=a.busWidth||a.buswidth;this.u=Xe;this.V=null;this.J=this.na=!1;this.pa=mc(this,"url")||"";(Math.random()+.1).toString(36);this.A=Ye(this);if(this.b=eb("CPU",this.id)){this.B=eb("Debugger",this.id);this.ra=[];for(b=null;b=zb(this,"Video",b);)this.ra.push(b);this.C=new Bb({id:this.Bb+".bus",buswidth:this.oa},this.b,this.B);var d,e=A(this.id);if((this.G=eb("Panel",this.id))&&
|
||||
this.G.Aa)for(b=0;b<e.length;b++)d=e[b],d.ia=this.G.ia,d.g=this.G.g,d.Aa=this.G.Aa;for(b=0;b<e.length;b++)d=e[b],d.Ma&&d.Ma(this,this.C,this.b,this.B);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.T=d:this.u=parseInt(d,10));var f;if(a=mc(this,"state")||(f=!0,a.state))b=this.aa=a,f||(this.J=!0,this.u=Xe),this.u&&(this.W=new J(this,Z),Te(this.W)?b=null:delete this.W);!b&&this.u&&(b=Ze(this))&&(this.J=!0);if(b){var h=this;t(b,null,!0,function(a,b,c){c?(h.T=null,h.J=!1,h.ia("Unable to load machine state from server (error "+
|
||||
c+(b?": "+na(b):"")+")")):(h.V=b,h.na=!0);F(h)})}else F(this);this.I.power||(this.Y=!0);!c&&this.Y&&$e(this,this.fb)}else v("Unable to find CPU component")}z(Ve);var Z="1.21.7",Xe=0;function We(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){v(d.message+" ("+c+")")}}a.K=b}
|
||||
function mc(a,b,c){var d=b.toLowerCase(),d=Ya[b]||Ya[d];void 0===d&&a.K&&(d=a.K[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function $e(a,b,c){for(var d=A(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!kb(f)){kb(f,function(){$e(a,b,c)});return}}b.call(a,c)}
|
||||
function af(a,b){var c=new J(a,Z,"validate");if(Te(c)&&Se(c)){var d=Ue(c,"timestamp"),e=b?Ue(b,"timestamp"):"unknown";d!=e&&(a.ia("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=Ve.prototype;
|
||||
k.fb=function(a){void 0===a&&(a=this.u||(this.V?1:Xe));if(!this.D){this.D++;var b=!1,c=!1;this.ga=!1;var d=this.W||new J(this,Z);if(-1==a)b=!0;else if(a>Xe){if(Te(d,this.V)){this.H=new J(this,Z,"failsafe");Te(this.H)&&(bf(this,d),a=2,Qe(this.H));K(this.H,"timestamp",ua());Re(this.H);var e=this.u&&!this.J;if(1==a||Ca("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Se(d)){var f=Ue(d,"code"),h=Ue(d,"data");f&&("ok"==f?Te(d,h):("error"==f&&"no machine state"!=
|
||||
h?(this.ia("Error: "+h),"unable to verify user"==h&&(Ga("user",""),this.A=null)):this.g(f+": "+h),Qe(d),Te(d)?(c=Se(d),e=!0):c=!1))}e&&af(this,c?d:null)}else 2==a&&d.clear()}else af(this);delete this.V;delete this.W}e=A(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.b&&(c=cf(this,h,d,b,c));b=[d,a,c];-1!=a?$e(this,this.Eb,b):this.Eb(b)}};
|
||||
function cf(a,b,c,d,e){if(!b.s.ba){b.s.ba=!0;if(b.ua){var f=null;e&&((f=Ue(c,b.id))||(f=Ue(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.ua(f,d)&&f&&(v("Unable to restore state for "+b.type),a.aa&&!a.na?(c.clear(),a.u=Xe,window&&window.location.reload()):a.ga=!0,b.ua(null),e=!1)}if(!d&&b.xb)for(a=b.xb.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
|
||||
k.Eb=function(a){var b=a[0],c=0>a[1];a=a[2];this.s.ba=!0;var d=this.I.power;d&&(d.textContent="Shutdown");this.ca||(this.g("PC8080 v"+Z+"\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>"),this.ca=!0);this.b&&(cf(this,this.b,b,c,a),qc(this.b));this.ga&&(bf(this,b),b.clear());!c&&this.H&&(this.H.clear(),delete this.H);this.D=0};
|
||||
function bf(a,b){if(Ca("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.pa,d=a.A||"",e=b.toString(),f={app:"PC8080"};f.ver=Z;f.url=c;f.user=d;f.type="bug";f.data=e;t("http://www.pcjs.org/api/v1/report",f,!0)}}
|
||||
function Oe(a,b,c){var d,e="none";if(a.D)return null;a.D--;var f=new J(a,Z),h=new J(a,Z,"validate"),g=ua();K(h,"timestamp",g);K(f,"timestamp",g);K(f,"version","1.21.7");K(f,"url",window?window.location.href:null);K(f,"browser",xa());a.b&&a.b.ta&&(c&&a.b.Z(),d=a.b.ta(b,c),"object"===typeof d&&K(f,a.b.id,d),c&&(a.b.s.ba=!1,!1===d&&(e=null)));for(var g=A(a.id),m=0;m<g.length;m++){var l=g[m];l.s.ba&&(l.ta&&(d=l.ta(b,c),"object"===typeof d&&K(f,l.id,d)),c&&(l.s.ba=!1,!1===d&&(e=null)))}e&&(c?(g=d=!1,b?
|
||||
(a.A&&df(a,a.A,f.toString()),Re(h)&&Re(f)||(e=null,d=g=!0)):a.u&&(d=!0,g=3==a.u),d&&f.clear(g)):e=f.toString());c&&(a.s.ba=!1,b=a.I.power)&&(b.textContent="Power");a.D=0;return e}k.reset=function(){this.C&&this.C.reset&&(gb(this,"Resetting "+this.C.type),this.C.reset());for(var a=A(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.C&&c.reset&&(gb(this,"Resetting "+c.type),c.reset())}};
|
||||
k.start=function(a,b){for(var c=A(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};k.stop=function(a,b){for(var c=A(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
|
||||
k.la=function(a,b,c){var d=this;switch(b){case "power":return this.I[b]=c,c.onclick=function(){d.D||(d.s.ba?Oe(d,!1,!0):$e(d,d.fb))},!0;case "reset":return this.I[b]=c,c.onclick=function(){if(d.s.ba&&!d.D)if(d.u&&!d.T){var a=Ca("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Oe(d,a,!0);!a&&d.aa?window&&window.location.reload():d.fb(Xe)}else d.reset(),d.b&&qc(d.b)},!0;case "save":if(ja(wa(),"pcjs.org")){c.parentNode.removeChild(c);
|
||||
break}this.I[b]=c;c.onclick=function(){var a=Ye(d,!0);if(a){var b=!!(d.u&&!d.T||d.aa),c=Oe(d,b);b?df(d,a,c):d.ia("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function Ye(a,b){var c=a.A;c||(c=Fa("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=ef(a,c))||a.ia("The user ID is invalid."))):b&&a.ia("Browser local storage is not available"));return c}
|
||||
function ef(a,b){a.A=null;var c=t(wa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(Ga("user",c.data),a.A=c.data)}catch(e){v(e.message+" ("+d+")")}return a.A}function Ze(a){var b=null;a.A&&(b=wa()+"/api/v1/user?req=load&user="+a.A+"&state="+Pe(a,Z));return b}
|
||||
function df(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Pe(a,Z);d.data=c;b=t(wa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.ia("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.ia(c),Ga("user",""),a.A=null)}}
|
||||
function zb(a,b,c){a=A(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}k.hb=function(){};k.ma=function(a){this.b&&this.b.ma(a);this.G&&this.G.ma(a)};Ta(function(){for(var a=E(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=B(c),c=E(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=B(f),h=new Ve(h,d,!0);fb(h,f);h.Y&&$e(h,h.fb)}});
|
||||
Ka.show.push(function(){for(var a=E(document,"pc8080","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=eb("Computer",c.id))&&c.ca&&!c.s.ba&&c.fb(-1)}});Ka.exit.push(function(){for(var a=E(document,"pc8080","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=eb("Computer",c.id))&&c.s.ba&&Oe(c,!(!c.u||c.T),!0)}});var ff=0;function gf(a,b,c,d,e,f){e("Loading "+a+"...");t(a,null,!0,function(h,g,m){m?(g||(g="unable to load "+a+" ("+m+")"),f(g,null)):wf(g,a,b,c,d,e,f)})}
|
||||
function wf(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){db(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
|
||||
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){g=null,a=r.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?xf(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
|
||||
function xf(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");t(e,null,!0,function(f,h,g){if(g||!h)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=h.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var m=g[0],l,p=/( [a-z]+=)(['"])(.*?)\2/g;l=p.exec(f);)m=0>m.indexOf(l[1])?m.replace(">",l[0]+">"):m.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=m&&(h=h.replace(g[0],m))}else{c(a,"missing <"+d[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(d[0],h);xf(a,b,c)}})}else c(a,null)}
|
||||
function yf(a,b,c,d){function e(a){if(void 0===g){var b=h&&E(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=la(a))}function f(a){e("Error: "+a);m&&(--ff||Va(!0));m=!1}var h,g,m=!0;ff++;cb[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=l:r.appendChild(document.createTextNode(l));p.appendChild(r)}c||
|
||||
(c="/versions/pc8080/1.21.7/components.xsl");l=function(d,g){g?gf(c,null,null,!1,e,function(d,m){if(m)if(db(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(m);l?(h.outerHTML=l,--ff||Va(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--ff||Va(!0)):f("invalid machine element: "+
|
||||
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?gf(b,a,d,!0,e,l):wf(b,null,a,d,!1,e,l)}else f("missing machine element: "+a)}catch(u){f(u.message)}return m}window.embedPC8080=function(a,b,c,d){Va(!1);return yf(a,b,c,d)};window.enableEvents=Va;window.sendEvent=Wa;
|
||||
function zf(a,b,c,d){if(!c&&b){d.push(b);a=cb[d[0]];b=null;for(var e in a)if(ja(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?t(b,null,!0,function(a,b){Af(b,d)}):Af(null,d)}else v("Error ("+c+") requesting "+a)}
|
||||
function Af(a,b){var c,d,e,f=b[0],h=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=cb[f],m={},l;for(l in g){var p=g[l],r=ia(l);if("xml"==r){for(r=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(g[l]);){var u=d[2];u&&(g[u]||(p=p.replace(d[0],"")))}d=l=ha(l)}else"xsl"==r&&(e=l=ha(l));m[l]=p}a&&(m[l="css"]=a);b[2]&&(m[l="parms"]=b[2]);b[3]&&(m[l="state"]=b[3]);d&&e?(l=JSON.stringify(m),h+=".js",c=c[1]+"var resources="+l+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
|
||||
"©"),l=h,g=null,m="data:application/javascript,",m=Ha("Firefox")?m+encodeURIComponent(c):m+encodeURI(c),l&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=m,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+l+"."):(window.open(m),c="Check your browser for a new window/tab containing the requested data"+(l?" ("+l+")":"")+"."),c+=', copy it to your web server as "'+h+'", and then add the following to your web page:\n\n',
|
||||
c+='<div id="'+f+'"></div>\n',c+="...\n",c+='<script type="text/javascript" src="'+h+'">\x3c/script>\n',c+='<script type="text/javascript">embedPC("'+f+'","'+d+'","'+e+'");\x3c/script>\n\n',c+="The machine should appear where the <div> is located.",v(c)):v("Missing XML/XSL resources")}
|
||||
window.savePC=function(a,b,c){var d=db("Computer",a),e=db("Debugger",a);if(d){var f=Me(d,!0),h=d.J?JSON.stringify(d.J):null;b||(b="/versions/pcjs/1.21.7/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,Lb:h}))return!0;u(b,null,!0,function(c,d,e){xf(c,d,e,[a,ga(b,!0),h,f])});return!0}v("Unable to identify machine '"+a+"'");return!1};})();
|
||||
window.savePC=function(a,b,c){var d=eb("Computer",a),e=eb("Debugger",a);if(d){var f=Oe(d,!0),h=d.K?JSON.stringify(d.K):null;b||(b="/versions/pcjs/1.21.7/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,Mb:h}))return!0;t(b,null,!0,function(c,d,e){zf(c,d,e,[a,ha(b,!0),h,f])});return!0}v("Unable to identify machine '"+a+"'");return!1};})();
|
||||
|
|
|
|||
|
|
@ -1,98 +1,105 @@
|
|||
(function(){var e;function aa(a){var b=16,c;if(a){b||(b=16);if("$"==a.charAt(0))b=16,a=a.substr(1);else if("0x"==a.substr(0,2))b=16,a=a.substr(2);else{var d=a.charAt(a.length-1).toLowerCase();"h"==d?(b=16,d=null):"."==d&&(b=10,d=null);null==d&&(a=a.substr(0,a.length-1))}var f,d=a,g=b;(g&&10!=g?16==g?null!==d.match(/^[0-9a-f]+$/i):2==g&&null!==d.match(/^[01]+$/i):null!==d.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(c=f|0)}return c}
|
||||
(function(){var h;function aa(a){var b=16,c;if(a){b||(b=16);if("$"==a.charAt(0))b=16,a=a.substr(1);else if("0x"==a.substr(0,2))b=16,a=a.substr(2);else{var d=a.charAt(a.length-1).toLowerCase();"h"==d?(b=16,d=null):"."==d&&(b=10,d=null);null==d&&(a=a.substr(0,a.length-1))}var e,d=a,f=b;(f&&10!=f?16==f?null!==d.match(/^[0-9a-f]+$/i):2==f&&null!==d.match(/^[01]+$/i):null!==d.match(/^[0-9]+$/))&&!isNaN(e=parseInt(a,b))&&(c=e|0)}return c}
|
||||
function n(a,b){var c="";void 0===b?b=8:8<b&&(b=8);if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;){var d=a&15,d=d+(0<=d&&9>=d?48:55),c=String.fromCharCode(d)+c;a>>=4}return c}function ba(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0<d&&(c=c.substr(0,d));b&&(d=c.lastIndexOf("."),0<d&&(c=c.substring(0,d)));return c}function ca(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}
|
||||
function da(a,b){return-1!==a.indexOf(b,a.length-b.length)}var ea={"&":"&","<":"<",">":">",'"':""","'":"'"};function fa(a){return a.replace(/[&<>"']/g,function(a){return ea[a]})}var p=Date.now||function(){return+new Date};function ga(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function q(a,b,c,d){var f=0,g=null,k=null;if("object"==typeof resources&&(g=resources[a]))return d&&d(a,g,f),[g,f];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),k;var h=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(h.onreadystatechange=function(){4===h.readyState&&(g=h.responseText,200==h.status||!h.status&&g.length&&"file:"==(window?window.location.protocol:"file:")||(f=h.status||-1),d&&d(a,g,f))});if(b&&"object"==
|
||||
typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");h.open("POST",a,!!c);h.setRequestHeader("Content-type","application/x-www-form-urlencoded");h.send(l)}else h.open("GET",a,!!c),"bytes"==b&&h.overrideMimeType("text/plain; charset=x-user-defined"),h.send();c||(g=h.responseText,200!=h.status&&(f=h.status||-1),d&&d(a,g,f),k=[g,f]);return k}function ha(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function t(a){window&&window.alert(a)}function ia(a){var b=!1;window&&(b=window.confirm(a));return b}var ja=null;function ka(){if(null==ja){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}ja=a}return ja}function la(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
|
||||
function ma(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function na(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}var u={init:[],show:[],exit:[]},oa=!1,pa=!0;function qa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function v(a){u.init.push(a)}
|
||||
function ra(a){if(pa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){t("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.")}}function sa(a){!pa&&a?(pa=!0,oa&&ta("init")):pa=a}function ta(a){u[a]&&ra(u[a])}qa("onload",function(){oa=!0;ra(u.init)});qa("onpageshow",function(){ra(u.show)});qa(na("Opera")||na("iOS")?"onunload":"onbeforeunload",function(){ra(u.exit)});
|
||||
function w(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.Ka=b.comment;this.Wa=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Ma=this.id.substr(0,b),this.La=this.id.substr(b+1)):this.La=this.id;this[a]=c;this.f={ca:!1,ka:!1,Fa:!1,F:!1,Y:!1};this.za=null;this.f.Y=!1;this.i={};this.I=null;x.push(this)}var ua=void 0,va={};
|
||||
if(window){ua||(ua=window.location.search.substr(1));for(var wa,xa=/\+/g,ya=/([^&=]+)=?([^&]*)/g;wa=ya.exec(ua);)va[decodeURIComponent(wa[1].replace(xa," "))]=decodeURIComponent(wa[2].replace(xa," "))}function za(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
|
||||
function y(a,b){b||(b=w);a.prototype=za(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var x=[],Ba={};function Ca(a,b,c){Ba[a]&&b&&(Ba[a][b]=c)}function z(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<x.length;b++){var d=x[b];a&&d.id.indexOf(a)||c.push(d)}return c}
|
||||
function A(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<x.length;d++)if(c)c==x[d]&&(c=null);else if(!(a!=x[d].type||b&&x[d].id.indexOf(b)))return x[d]}return null}function C(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){t(c.message+" ("+a+")")}return b}
|
||||
function D(a,b){for(var c=E(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var f=c[d].childNodes,g=0;g<f.length;g++){var k=f[g];if(1===k.nodeType){var h=k.getAttribute("class");if(h)for(var l=h.split(" "),m=0;m<l.length;m++)switch(h=l[m],h){case "pc8080-binding":(h=C(k))&&h.binding&&a.M(h.type,h.binding,k,h.value),m=l.length}}}}
|
||||
function E(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var f=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)f.test(a[b].className)&&c.push(a[b]);return c}
|
||||
w.prototype={constructor:w,parent:null,toString:function(){return this.name?this.name:this.id||this.type},M:function(a,b,c){switch(b){case "clear":return this.i[b]||(this.i[b]=c,c.onclick=function(a){return function(){a.i.print&&(a.i.print.value="")}}(this)),!0;case "print":return this.i[b]||(this.Ea=this.i[b]=c,c.value="",this.L=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
|
||||
this.G=function(a,b,c){this.L(a,"notice",c)}),!0;default:return!1}},log:function(){},L:function(){},status:function(a){this.L(this.La+": "+a)},G:function(a,b){b||t(a)},V:function(){return this.f.F=!0},U:function(a,b){b&&(this.f.F=!1);return!0}};function Da(a,b){if(a.f.Fa)return a.f.ka&&(a.f.ka=!1),a.f.Fa=!1;if(a.f.Y)return a.L(a.toString()+" error"),!1;a.f.ka=b;return a.f.ka}function F(a){if(!a.f.Y&&(a.f.ca=!0,a.f.ca)){var b=a.za;a.za=null;b&&b()}}
|
||||
function Ea(a,b){b&&(a.f.ca?b():a.za=b);return a.f.ca}
|
||||
var Fa="undefined"!==typeof ArrayBuffer,Ga=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
|
||||
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function Ha(a){w.call(this,"Panel",a,Ha)}y(Ha);e=Ha.prototype;e.M=function(a,b,c,d){return this.h&&this.h.M(a,b,c,d)||this.b&&this.b.M(a,b,c,d)||this.a&&this.a.M(a,b,c,d)?!0:this.parent.M.call(this,a,b,c,d)};e.la=function(a,b,c,d){this.h=a;this.o=b;this.b=c;this.I=d;this.a=Ia(a,"Keyboard")};e.V=function(a,b){b||Ja();return!0};e.U=function(){return!0};e.aa=function(){};
|
||||
function Ja(){for(var a=!1,b=E(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],f=C(d),g;a:{g=f.id;if(void 0!==g)for(var k=void 0,k=0;k<x.length;k++)if(x[k].id===g){g=x[k];break a}g=null}g||(a=!0,g=new Ha(f));D(g,d);a&&F(g)}}v(Ja);
|
||||
function Ka(a,b,c){w.call(this,"Bus",a,Ka);this.b=b;this.I=c;this.g=a.buswidth||16;this.o=Math.pow(2,this.g);this.h=this.o-1|0;this.m=20>=this.g?12:24>=this.g?14:15;this.j=1<<this.m;this.l=this.j>>2;this.s=this.j-1;this.c=this.o/this.j|0;a=new G;La(a,this.I);this.a=Array(this.c);for(b=0;b<this.c;b++)this.a[b]=a;a=this.b;b=this.a;c=this.m;var d=this.h;a.J=b;a.m=c;a.j=1<<a.m;a.P=a.j-1;a.va=b.length;a.ia=a.va-1;a.W=d;F(this)}y(Ka);Ka.prototype.reset=function(){};
|
||||
Ka.prototype.V=function(a,b){b||this.reset();return!0};function Ma(a,b,c,d){for(var f=b>>>a.m;0<c&&f<a.a.length;){var g=a.a[f],k=f*a.j,h=c>a.j?a.j:c;if(g&&g.size){if(g.type==d){if(b+c<=g.ja)return g.Da+=g.ja-b,g.ja=b,!0;if(b>=g.ja+g.Da){h=g.size-(b-k);h>c&&(h=c);g.Da=b-g.ja+h;c-=h;b=k+a.j;continue}}return Na(1,b,c)}g=a.a[f];b=new G(b,h,a.j,d);La(b,a.I,g);a.a[f++]=b;b=k+a.j;c-=h}return 0>=c?!0:Na(2,b,c)}function Na(a,b,c){t("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Oa;
|
||||
if(Fa){var Pa=new ArrayBuffer(2);(new DataView(Pa)).setUint16(0,256,!0);Oa=256===(new Uint16Array(Pa))[0]}else Oa=!1;var Qa=Oa;
|
||||
function G(a,b,c,d){this.id=Ra+=2;this.b=null;this.ja=a;this.Da=b;this.size=c||0;this.type=d||Sa;this.i=d==Ta;La(this);this.T=this.eb=!1;if(c)if(Fa)this.c=new ArrayBuffer(c),this.g=new DataView(this.c,0,c),this.a=new Uint8Array(this.c,0,c),this.j=new Uint16Array(this.c,0,c>>1),this.b=new Int32Array(this.c,0,c>>2),Ua(this,Qa?Va:Wa);else{this.b=Array(c>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Ua(this,Xa)}else Ua(this)}var Sa=0,Ta=2,Ra=0;
|
||||
G.prototype={constructor:G,parent:null,save:function(){var a,b;if(Fa)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.g.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(Fa)for(b=0;b<a.length;b++)this.g.setInt32(b<<2,a[b],!0);else this.b=a;return this.T=!0}return!1},m:function(){return 255},s:function(){},l:function(a,b){return this.ta(a++,b++)|this.ta(a,b)<<8},u:function(a,b,c){this.ua(a++,b&255,c++);this.ua(a,b>>8,c)},C:function(a){return this.b[a>>
|
||||
2]>>>((a&3)<<3)&255},N:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},W:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<<d)|b<<d;this.T=!0},wa:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<<d)|b<<d:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.T=!0},A:function(a,b){return this.w(a,b)},H:function(a,b){return this.J(a,b)},R:function(a,b,c){this.i||this.Za(a,b,c)},ba:function(a,b,
|
||||
c){this.i||this.ia(a,b,c)},v:function(a){return this.a[a]},B:function(a){return this.a[a]},D:function(a){return this.g.getUint16(a,!0)},K:function(a){return a&1?this.a[a]|this.a[a+1]<<8:this.j[a>>1]},P:function(a,b){this.a[a]=b;this.T=!0},S:function(a,b){this.a[a]=b;this.T=!0},X:function(a,b){this.g.setUint16(a,b,!0);this.T=!0},va:function(a,b){a&1?(this.a[a]=b,this.a[a+1]=b>>8):this.j[a>>1]=b;this.T=!0}};function La(a,b,c){a.I=b;a.h=a.o=0;c&&((a.h=c.h)&&Ya(a,Za,!1),(a.o=c.o)&&$a(a,Za,!1))}
|
||||
function $a(a,b,c){c&&a.o||(a.ua=!a.i&&b[2]||a.s,a.ib=!a.i&&b[3]||a.u);if(c||void 0===c)a.Za=b[2]||a.s,a.ia=b[3]||a.u}function Ya(a,b,c){c&&a.h||(a.ta=b[0]||a.m,a.gb=b[1]||a.l);if(c||void 0===c)a.w=b[0]||a.m,a.J=b[1]||a.l}function Ua(a,b){b||(b=ab);Ya(a,b,void 0);$a(a,b,void 0)}var ab=[],Xa=[G.prototype.C,G.prototype.N,G.prototype.W,G.prototype.wa],Za=[G.prototype.A,G.prototype.H,G.prototype.R,G.prototype.ba];
|
||||
if(Fa)var Wa=[G.prototype.v,G.prototype.D,G.prototype.P,G.prototype.X],Va=[G.prototype.B,G.prototype.K,G.prototype.S,G.prototype.va];
|
||||
function bb(a,b){w.call(this,"CPU",a,bb);var c=a.cycles||b,d=a.multiplier||1;this.b={};this.b.ha=c;this.b.ga=d;this.b.Ga=Math.round(this.b.ha/1E4)/100;this.b.da=this.b.Ga*this.b.ga;this.f.O=!1;this.f.Ra=!1;this.f.Pa=a.autoStart;this.f.Qa=!1;this.f.xa=!1;this.b.Ba=this.b.fa=0;this.b.Ca=a.csStart;this.b.ma=a.csInterval;this.b.na=a.csStop;this.bb=this.Ja.bind(this);F(this)}y(bb);var cb=["power","reset"];e=bb.prototype;
|
||||
e.la=function(a,b,c,d){this.h=a;this.o=b;this.I=d;for(b=0;b<cb.length;b++)(c=this.i[cb[b]])&&this.h.M(null,cb[b],c);Ia(a,"FPU");this.s=Ia(a,"ChipSet");a=db(a,"autoStart");null!=a&&(this.f.Pa="true"==a?!0:"false"==a?!1:!!a);F(this)};e.reset=function(){};e.save=function(){return null};e.restore=function(){return!1};e.V=function(a,b){if(!b){if(a&&this.restore){eb(this);if(!this.restore(a))return!1;fb(this)}else this.reset();this.L("No debugger detected")}gb(this);return!0};
|
||||
e.U=function(a){return a?this.save():!0};function hb(a){(a.f.Pa||void 0===a.i.run)&&a.Ja()}e.Sa=function(){return 0};function fb(a){void 0===a.b.Ca&&(a.b.Ca=0);void 0===a.b.ma&&(a.b.ma=-1);void 0===a.b.na&&(a.b.na=-1);a.f.xa=0<=a.b.Ca&&0<a.b.ma;a.f.xa&&(a.b.Ba=0,a.b.fa=a.b.Ca-a.S)}
|
||||
e.M=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.i[b]=c;a=!0;break;case "run":this.i[b]=c;c.onclick=function(){var a;if(a=d.h)if(a=d.h,a.f.F)a=!0;else{var b=null,c,h=z(a.id);for(c=0;c<h.length&&(b=h[c],b===a||b.f.ca);c++);if(c==h.length)for(c=0;c<h.length&&(b=h[c],b===a||b.f.F);c++);c==h.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.f.ca?"powered yet":"ready yet"+(b.za?" (waiting for notification)":""))+".");a=!1}a&&(d.f.O?H(d,!0):d.Ja())};a=!0;break;
|
||||
case "speed":this.i[b]=c;a=!0;break;case "setSpeed":this.i[b]=c,c.onclick=function(){ib(d,d.b.ga<<1)},c.textContent=this.b.da.toFixed(2)+"Mhz",a=!0}return a};function jb(a,b,c){a.S+=b;c&&(a.R=a.a=0)}function kb(a,b){var c=30;60>c&&(c=60);2>c&&(c=2);var d=1;b&&1<a.b.ga&&a.b.Z&&(d=a.b.Z/a.b.Ga);a.b.Ta=Math.round(1E3/30);a.b.fb=Math.floor(a.b.ha/c*d);a.b.Ha=Math.floor(a.b.ha/30*d);a.b.Va=Math.floor(a.b.ha/60*d);a.b.Ua=Math.floor(a.b.ha/2*d);b||(a.b.qa=a.b.Ha,a.b.pa=a.b.Va,a.b.oa=a.b.Ua);a.b.Ia=0}
|
||||
function lb(a){return a.S+a.N+a.R-a.a}function eb(a){a.b.Z=0;a.S=a.N=a.R=a.a=0;fb(a);ib(a,1)}function ib(a,b){if(void 0!==b){.8>a.b.Z/a.b.da&&(b=1);a.b.ga=b;var c=a.b.Ga*a.b.ga;if(a.b.da!=c){a.b.da=c;var c=a.b.da.toFixed(2)+"Mhz",d=a.i.setSpeed;d&&(d.textContent=c);a.L("target speed: "+c)}}jb(a,a.N);a.N=0;a.b.ea=p();a.b.$=0;kb(a)}
|
||||
e.Ja=function(){if(Da(this,!0)){if(!this.f.O){ib(this);this.h&&this.h.start(this.b.ea,lb(this));this.f.O=!0;this.f.Ra=!0;this.s&&this.s.hb();var a=this.i.run;a&&(a.textContent="Halt");this.h&&this.h.aa(!0)}this.b.Ia>=this.b.ha&&kb(this,!0);this.b.ra=0;this.b.Aa=p();this.b.$&&(a=this.b.Aa-this.b.$,a>this.b.Ta&&(this.b.ea+=a,this.b.ea>this.b.Aa&&(this.b.ea=this.b.Aa)));try{do{var b=this.f.xa?1:this.b.fb;this.s&&(this.s.Ya(),b=this.s.kb(0,b),b=this.s.jb(b));try{this.Xa(b)}catch(f){if("number"!=typeof f)throw f;
|
||||
}var c=this.R-this.a;this.N+=c;this.b.ra+=c;jb(this,0,!0);a=c;if(this.f.xa){var d=!1;this.b.Ba=this.b.Ba+this.Sa()|0;this.b.fa-=a;0>=this.b.fa&&(this.b.fa+=this.b.ma,d=!0);0<=this.b.na&&this.b.na<=lb(this)&&(this.b.ma=this.b.na=-1,fb(this),H(this),d=!0);d&&this.L(lb(this)+" cycles: checksum="+n(this.b.Ba))}this.b.pa-=c;0>=this.b.pa&&(this.b.pa+=this.b.Va);this.b.oa-=c;0>=this.b.oa&&(this.b.oa+=this.b.Ua,this.h&&this.h.aa());this.b.qa-=c;if(0>=this.b.qa){this.b.qa+=this.b.Ha;break}}while(this.f.O)}catch(f){H(this);
|
||||
gb(this);this.h&&this.h.stop(p(),lb(this));Da(this,!1);b=f.stack||f.message;this.f.Y=!0;this.G(b);return}b=setTimeout;c=this.bb;this.b.$=p();a=this.b.Ta;this.b.ra&&(a=Math.round(a*this.b.ra/this.b.Ha));a-=this.b.$-this.b.Aa;if(d=this.b.$-this.b.ea)this.b.Z=Math.round(this.N/(10*d))/100,864E5<=d&&(this.S=0,this.s&&this.s.Ya(!0),ib(this));if(0>a||this.b.Z<this.b.da)a=0;this.b.Ia+=this.b.ra;this.b.$+=a;b(c,a)}else gb(this),this.h&&this.h.stop(p(),lb(this))};e.Xa=function(){return 0};
|
||||
function H(a,b){a.f.ka&&(a.f.Fa=!0);a.R-=a.a;a.a=0;jb(a,a.N);a.N=0;if(a.f.O){a.f.O=!1;a.s&&a.s.hb();var c=a.i.run;c&&(c.textContent="Run")}a.f.ya=b}function gb(a){a.h&&a.h.aa(void 0)}function mb(a){this.ab=a.model||8080;bb.call(this,a,1E6);this.$a=nb;eb(this);this.f.ya=this.f.cb=!1;this.wa=0;this.J=[];this.m=this.j=this.P=this.va=this.ia=this.W=0;ob(this)}y(mb,bb);e=mb.prototype;e.reset=function(){this.f.O&&H(this);ob(this);eb(this);this.f.Y=!1};
|
||||
function ob(a){a.g=0;a.v=0;a.A=0;a.w=0;a.B=0;a.C=0;a.D=0;a.H=0;a.u=0;pb(a,0);a.ba=0}e.Sa=function(){var a=this.g+this.v+this.A+this.w+this.B+this.C+this.D|0;return a=a+this.H+this.u+qb(this)|0};
|
||||
e.save=function(){var a=new I(this);J(a,0,[this.g,this.v,this.A,this.w,this.B,this.C,this.D,this.H,this.u,qb(this)]);J(a,1,[this.X,this.ba,this.S,this.b.ga]);for(var b=this.o,c=0,d=[],f=0;f<b.c;f++){var g=b.a[f];if(g.T||g.eb){d[c++]=f;var k=c++;a:if(g=g.save()){for(var h=0,l=0,m=[];h<g.length;){for(var B=g[h],r=h+1;r<g.length&&g[r]===B;)r++;m[l++]=r-h;m[l++]=B;h=r}if(m.length<g.length){g=m;break a}}d[k]=g}}J(a,2,d);return a.data()};
|
||||
e.restore=function(a){var b=a[0];this.g=b[0];this.v=b[1];this.A=b[2];this.w=b[3];this.B=b[4];this.C=b[5];this.D=b[6];this.H=b[7]&65535;this.u=b[8]&65535;pb(this,b[9]);b=a[1];this.X=b[0];this.ba=b[1];this.S=b[2];ib(this,b[3]);a:{b=this.o;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],f=a[c+1];if(f&&f.length<b.l){for(var g=0,k=Array(b.l),h=0;h<f.length-1;)for(var l=f[h++],m=f[h++];l--;)k[g++]=m;f=k}g=b.a[d];if(!g||!g.restore(f)){t("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
e.M=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "D":case "E":case "H":case "L":case "SP":case "PC":case "F":case "SF":case "ZF":case "AF":case "PF":case "CF":this.i[b]=c;this.wa++;d=!0;break;default:d=this.parent.M.call(this,a,b,c)}return d};function rb(a){return a.v<<8|a.A}function sb(a,b){a.v=b>>8&255;a.A=b&255}function tb(a){return a.w<<8|a.B}function ub(a,b){a.w=b>>8&255;a.B=b&255}function K(a){return a.C<<8|a.D}function L(a,b){a.C=b>>8&255;a.D=b&255}
|
||||
function qb(a){return a.Na&-214|(a.l&128?128:0)|(a.c&255?0:64)|((a.l^a.K)&16?16:0)|(Ga[a.l&255]?4:0)|(a.c&256?1:0)}function pb(a,b){a.c=a.l=a.K=0;b&1&&(a.c|=256);b&4||(a.l|=1);b&16&&(a.K|=16);b&64||(a.c|=255);b&128&&(a.l^=192);a.Na=a.Na&-513|b&512|2}function M(a,b){a.K=b;b=(a.l=b+1)&255;a.c=a.c&-256|b;return b}function N(a,b){a.K=b;b=(a.l=b-1)&255;a.c=a.c&-256|b;return b}function O(a,b){return a.J[(b&a.W)>>>a.m].ta(b&a.P,b)}
|
||||
function vb(a,b){var c=b&a.P,d=(b&a.W)>>>a.m;if(c<a.P)return a.J[d].gb(c,b);c=a.J[d].ta(c,b);return c|=a.J[d+1&a.ia].ta(0,b+1)<<8}function P(a,b,c){a.J[(b&a.W)>>>a.m].ua(b&a.P,c&255,b)}function Q(a){var b=O(a,a.u);a.u=a.u+1&65535;return b}function R(a){var b=vb(a,a.u);a.u=a.u+2&65535;return b}function S(a,b,c,d){d=d||2;a.i[b]&&(void 0===c&&(a.f.Y=!0,a.G("Value for "+b+" is invalid"),H(a)),c=!a.f.O||a.f.Qa?n(c,d):"--------".substr(0,d),a.i[b].textContent!=c&&(a.i[b].textContent=c))}
|
||||
e.aa=function(a){this.wa&&(a||!this.f.O||this.f.Qa)&&(S(this,"A",this.g),S(this,"B",this.v),S(this,"C",this.A),S(this,"D",this.w),S(this,"E",this.B),S(this,"H",this.C),S(this,"L",this.D),S(this,"SP",this.H,4),S(this,"PC",this.u,4),a=qb(this),S(this,"F",a,2),S(this,"SF",a&128,1),S(this,"ZF",a&64,1),S(this,"AF",a&16,1),S(this,"PF",a&4,1),S(this,"CF",a&1,1));if(a=this.i.speed)a.textContent=this.f.O&&this.b.Z?this.b.Z.toFixed(2)+"Mhz":"Stopped"};
|
||||
e.Xa=function(a){this.f.ya=!0;this.f.cb=!1;this.f.Ra=!1;this.R=this.a=a;this.s&&!a&&this.s.Ya();a||(this.X|=4);do{if(this.ba&&this.ba&4){this.X=this.a=0;break}this.X=0;this.$a[Q(this)].call(this)}while(0<this.a);return this.f.ya?this.R-this.a:void 0===this.f.ya?0:-1};v(function(){for(var a=E(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new mb(d);D(d,c)}});function T(){this.a-=4}function U(){this.u=this.u-1&65535;H(this)}
|
||||
var nb=[T,function(){sb(this,R(this));this.a-=10},function(){P(this,rb(this),this.g);this.a-=7},function(){sb(this,rb(this)+1);this.a-=5},function(){this.v=M(this,this.v);this.a-=5},function(){this.v=N(this,this.v);this.a-=5},function(){this.v=Q(this);this.a-=7},function(){var a=this.g<<1;this.g=a&255|a>>8;this.c=this.c&255|a&256;this.a-=4},T,function(){var a;L(this,a=K(this)+rb(this));this.c=this.c&255|a>>8&256;this.a-=10},function(){this.g=O(this,rb(this));this.a-=7},function(){sb(this,rb(this)-
|
||||
1);this.a-=5},function(){this.A=M(this,this.A);this.a-=5},function(){this.A=N(this,this.A);this.a-=5},function(){this.A=Q(this);this.a-=7},function(){var a=this.g<<8&256;this.g=(a|this.g)>>1;this.c=this.c&255|a;this.a-=4},T,function(){ub(this,R(this));this.a-=10},function(){P(this,tb(this),this.g);this.a-=7},function(){ub(this,tb(this)+1);this.a-=5},function(){this.w=M(this,this.w);this.a-=5},function(){this.w=N(this,this.w);this.a-=5},function(){this.w=Q(this);this.a-=7},function(){var a=this.g<<
|
||||
1;this.g=a&255|this.c>>8;this.c=this.c&255|a&256;this.a-=4},T,function(){var a;L(this,a=K(this)+tb(this));this.c=this.c&255|a>>8&256;this.a-=10},function(){this.g=O(this,tb(this));this.a-=7},function(){ub(this,tb(this)-1);this.a-=5},function(){this.B=M(this,this.B);this.a-=5},function(){this.B=N(this,this.B);this.a-=5},function(){this.B=Q(this);this.a-=7},function(){var a=this.g<<8&256;this.g=(this.c&256|this.g)>>1;this.c=this.c&255|a;this.a-=4},T,function(){L(this,R(this));this.a-=10},function(){var a=
|
||||
R(this),b=K(this),c=a&this.P,d=(a&this.W)>>>this.m;c<this.P?this.J[d].ib(c,b&65535,a):(this.J[d++].ua(c,b&255,a),this.J[d&this.ia].ua(0,b>>8&255,a+1));this.a-=16},function(){L(this,K(this)+1);this.a-=5},function(){this.C=M(this,this.C);this.a-=5},function(){this.C=N(this,this.C);this.a-=5},function(){this.C=Q(this);this.a-=7},function(){var a=this.g,b=!!(this.c&256),c=!!((this.l^this.K)&16);9<(a&15)||c?(a+=6,c=!0):c=!1;160<=a||b?(a+=96,b=!0):b=!1;this.c=this.l=this.g=a&255;this.c=b?this.c|256:this.c&
|
||||
-257;this.K=c?~this.l&16|this.K&-17:this.l&16|this.K&-17;this.a-=4},T,function(){var a;L(this,a=K(this)+K(this));this.c=this.c&255|a>>8&256;this.a-=10},function(){L(this,vb(this,R(this)));this.a-=16},function(){L(this,K(this)-1);this.a-=5},function(){this.D=M(this,this.D);this.a-=5},function(){this.D=N(this,this.D);this.a-=5},function(){this.D=Q(this);this.a-=7},function(){this.g=~this.g&255;this.a-=4},T,function(){this.H=R(this)&65535;this.a-=10},function(){P(this,R(this),this.g);this.a-=13},function(){this.H=
|
||||
this.H+1&65535;this.a-=5},function(){var a=K(this);P(this,a,M(this,O(this,a)));this.a-=10},function(){var a=K(this);P(this,a,N(this,O(this,a)));this.a-=10},function(){P(this,K(this),Q(this));this.a-=10},function(){this.c|=256;this.a-=4},T,function(){var a;this.H=(a=K(this)+this.H)&65535;this.c=this.c&255|a>>8&256;this.a-=10},function(){this.g=O(this,R(this));this.a-=13},function(){this.H=this.H-1&65535;this.a-=5},function(){this.g=M(this,this.g);this.a-=5},function(){this.g=N(this,this.g);this.a-=
|
||||
5},function(){this.g=Q(this);this.a-=7},function(){this.c=this.c&256?this.c&-257:this.c|256;this.a-=4},U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U];
|
||||
function V(a){w.call(this,"ROM",a,V);this.a=null;this.m=a.addr;this.c=a.size;this.g=a.alias;this.h=a.file;this.l=ba(this.h);if(this.h){a=this.h;var b=ca(this.l);"json"!=b&&"hex"!=b&&(a=ha()+"/api/v1/dump?file="+this.h+"&format=bytes&decimal=true");var c=this;q(a,null,!0,function(a,b,g){wb(c,a,b,g)})}}y(V);V.prototype.la=function(a,b,c,d){this.o=b;this.b=c;this.I=d;xb(this)};V.prototype.V=function(){this.j&&(this.I&&this.I.b(this.id,this.m,this.c,this.j),delete this.j);return!0};V.prototype.U=function(){return!0};
|
||||
function wb(a,b,c,d){if(d)a.G("Unable to load system ROM (error "+d+": "+b+")");else{Ca(a.Ma,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var f=eval("("+c+")"),g=f.bytes,k=f.data;if(g)a.a=g;else if(k)for(a.a=Array(4*k.length),d=c=0;c<k.length;c++)a.a[d++]=k[c]&255,a.a[d++]=k[c]>>8&255,a.a[d++]=k[c]>>16&255,a.a[d++]=k[c]>>24&255;else a.a=f;a.j=f.symbols;if(!a.a.length){t("Empty ROM: "+b);return}if(1==a.a.length){t(a.a[0]);return}}catch(h){a.G("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.a=Array(b.length),f=0;f<b.length;f++)a.a[f]=aa(b[f]);xb(a)}}
|
||||
function xb(a){if(!Ea(a))if(!a.h)F(a);else if(a.a&&a.o){if(a.a.length!=a.c){var b="ROM size (0x"+n(a.a.length)+") does not match specified size ("+("0x"+n(a.c))+")";a.f.Y=!0;a.G(b)}else{b=a.m;if(Ma(a.o,b,a.c,Ta)){for(var c=0;c<a.a.length;c++){var d=a.o,f=b+c;d.a[(f&d.h)>>>d.m].Za(f&d.s,a.a[c]&255,f)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.g?b.push(a.g):null!=a.g&&a.g.length&&(b=a.g);for(c=0;c<b.length;c++){for(var g=a,d=b[c],f=g.o,k=g.c,h=[],l=g.m>>>f.m;0<k&&l<f.a.length;)h.push(f.a[l++]),k-=
|
||||
f.j;f=g.o;g=g.c;k=0;for(d>>>=f.m;0<g&&d<f.a.length;){l=h[k++];if(!l)break;f.a[d++]=l;g-=f.j}}delete a.a}}F(a)}}v(function(){for(var a=E(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new V(d);D(d,c)}});function yb(a){w.call(this,"RAM",a,yb);this.g=a.addr;this.c=a.size;this.a=!1}y(yb);e=yb.prototype;e.la=function(a,b,c,d){this.o=b;this.b=c;this.I=d;F(this)};e.V=function(a,b){b||this.reset();return!0};e.U=function(a){return a?this.save():!0};
|
||||
e.reset=function(){!this.a&&this.c&&Ma(this.o,this.g,this.c,1)&&(this.a=!0,this.status(Math.floor(this.c/1024)+"Kb allocated"));this.a||t("No RAM allocated")};e.save=function(){return null};e.restore=function(){return!0};v(function(){for(var a=E(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new yb(d);D(d,c)}});function zb(a){w.call(this,"Keyboard",a,zb);F(this)}y(zb);v(function(){for(var a=E(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new zb(d);D(d,c)}});
|
||||
function Ab(a){w.call(this,"Video",a,Ab);F(this)}y(Ab);
|
||||
v(function(){for(var a=E(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=C(c),f=document.createElement("canvas");if(void 0===f||!f.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}f.setAttribute("class","pcjs-canvas");f.setAttribute("width",d.screenWidth);f.setAttribute("height",d.screenHeight);f.style.backgroundColor=d.screenColor;f.style.height="auto";0<=(window?window.navigator.userAgent:"").indexOf("MSIE")&&(c.onresize=function(a,
|
||||
b,c,d){return function(){b.style.height=(a.clientWidth*d/c|0)+"px"}}(c,f,d.screenWidth,d.screenHeight),c.onresize());var g=+(d.aspect||va.aspect);g&&.3<=g&&3.33>=g&&(qa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,f,g)),window.onresize());c.appendChild(f);g=document.createElement("textarea");na("iOS")&&(g.setAttribute("autocapitalize","off"),g.setAttribute("autocorrect","off"));c.appendChild(g);f.getContext("2d");d=new Ab(d);D(d,c)}});
|
||||
function I(a,b,c){this.id=a.id;this.key=Bb(a,b,c);this.I=a.I;Cb(this,a.Wa)}function Bb(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
|
||||
I.prototype={constructor:I,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Cb(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(f){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(f){}b.splice(c,1);c=0}}};
|
||||
function Cb(a,b){a[a.id]={};b&&J(a,"parms",b);a.b=!1}function Db(a){var b=!0;if(ka()){var c=JSON.stringify(a[a.id]);ma(a.key,c)||(t("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Eb(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){t(c.message||c),b=!1}return b}function W(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:ka()&&(b=la(a.key))?(a[a.id]=b,a.b=!0):!1}function X(a,b){return a[a.id][b]||null}function J(a,b,c){try{a[a.id][b]=c}catch(d){}}
|
||||
function Fb(a,b,c){w.call(this,"Computer",a,Fb);this.f.F=!1;Gb(this,b);this.A=db(this,"autoPower",a);this.g=0;this.H=a.busWidth||a.buswidth;this.a=Y;this.u=null;this.m=this.D=!1;this.J=db(this,"url")||"";(Math.random()+.1).toString(36);this.c=Hb(this);if(this.b=A("CPU",this.id)){this.I=A("Debugger",this.id);this.K=[];for(b=null;b=Ia(this,"Video",b);)this.K.push(b);this.o=new Ka({id:this.Ma+".bus",buswidth:this.H},this.b,this.I);var d,f=z(this.id);if((this.h=A("Panel",this.id))&&this.h.Ea)for(b=0;b<
|
||||
f.length;b++)d=f[b],d.G=this.h.G,d.L=this.h.L,d.Ea=this.h.Ea;for(b=0;b<f.length;b++)d=f[b],d.la&&d.la(this,this.o,this.b,this.I);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.s=d:this.a=parseInt(d,10));var g;if(a=db(this,"state")||(g=!0,a.state))b=this.w=a,g||(this.m=!0,this.a=Y),this.a&&(this.v=new I(this,Z),W(this.v)?b=null:delete this.v);!b&&this.a&&(b=Ib(this))&&(this.m=!0);if(b){var k=this;q(b,null,!0,function(a,b,c){c?(k.s=null,k.m=!1,k.G("Unable to load machine state from server (error "+
|
||||
c+(b?": "+(String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/g,"")):"")+")")):(k.u=b,k.D=!0);F(k)})}else F(this);this.i.power||(this.A=!0);!c&&this.A&&Jb(this,this.sa)}else t("Unable to find CPU component")}y(Fb);var Z="1.21.7",Y=0;function Gb(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){t(d.message+" ("+c+")")}}a.l=b}
|
||||
function db(a,b,c){var d=b.toLowerCase(),d=va[b]||va[d];void 0===d&&a.l&&(d=a.l[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Jb(a,b,c){for(var d=z(a.id),f=0;f<=d.length;f++){var g=f<d.length?d[f]:a;if(!Ea(g)){Ea(g,function(){Jb(a,b,c)});return}}b.call(a,c)}
|
||||
function Kb(a,b){var c=new I(a,Z,"validate");if(W(c)&&Eb(c)){var d=X(c,"timestamp"),f=b?X(b,"timestamp"):"unknown";d!=f&&(a.G("Machine state may be out-of-date\n("+d+" vs. "+f+")\nCheck your browser's local storage limits"),b||c.clear())}}e=Fb.prototype;
|
||||
e.sa=function(a){void 0===a&&(a=this.a||(this.u?1:Y));if(!this.g){this.g++;var b=!1,c=!1;this.C=!1;var d=this.v||new I(this,Z);if(-1==a)b=!0;else if(a>Y){if(W(d,this.u)){this.j=new I(this,Z,"failsafe");W(this.j)&&(Lb(this,d),a=2,Cb(this.j));J(this.j,"timestamp",ga());Db(this.j);var f=this.a&&!this.m;if(1==a||ia("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Eb(d)){var g=X(d,"code"),k=X(d,"data");g&&("ok"==g?W(d,k):("error"==g&&"no machine state"!=k?
|
||||
(this.G("Error: "+k),"unable to verify user"==k&&(ma("user",""),this.c=null)):this.L(g+": "+k),Cb(d),W(d)?(c=Eb(d),f=!0):c=!1))}f&&Kb(this,c?d:null)}else 2==a&&d.clear()}else Kb(this);delete this.u;delete this.v}f=z(this.id);for(g=0;g<f.length;g++)k=f[g],k!==this&&k!=this.b&&(c=Mb(this,k,d,b,c));b=[d,a,c];-1!=a?Jb(this,this.Oa,b):this.Oa(b)}};
|
||||
function Mb(a,b,c,d,f){if(!b.f.F){b.f.F=!0;if(b.V){var g=null;f&&((g=X(c,b.id))||(g=X(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof g&&(g=null);!b.V(g,d)&&g&&(t("Unable to restore state for "+b.type),a.w&&!a.D?(c.clear(),a.a=Y,window&&window.location.reload()):a.C=!0,b.V(null),f=!1)}if(!d&&b.Ka)for(a=b.Ka.split("|"),c=0;c<a.length;c++)b.status(a[c])}return f}
|
||||
e.Oa=function(a){var b=a[0],c=0>a[1];a=a[2];this.f.F=!0;var d=this.i.power;d&&(d.textContent="Shutdown");this.B||(this.L("PC8080 v"+Z+"\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>"),this.B=!0);this.b&&(Mb(this,this.b,b,c,a),hb(this.b));this.C&&(Lb(this,b),b.clear());!c&&this.j&&(this.j.clear(),delete this.j);this.g=0};
|
||||
function Lb(a,b){if(ia("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.J,d=a.c||"",f=b.toString(),g={app:"PC8080"};g.ver=Z;g.url=c;g.user=d;g.type="bug";g.data=f;q("http://www.pcjs.org/api/v1/report",g,!0)}}
|
||||
function Nb(a,b,c){var d,f="none";if(a.g)return null;a.g--;var g=new I(a,Z),k=new I(a,Z,"validate"),h=ga();J(k,"timestamp",h);J(g,"timestamp",h);J(g,"version","1.21.7");J(g,"url",window?window.location.href:null);J(g,"browser",window?window.navigator.userAgent:"");a.b&&a.b.U&&(c&&H(a.b),d=a.b.U(b,c),"object"===typeof d&&J(g,a.b.id,d),c&&(a.b.f.F=!1,!1===d&&(f=null)));for(var h=z(a.id),l=0;l<h.length;l++){var m=h[l];m.f.F&&(m.U&&(d=m.U(b,c),"object"===typeof d&&J(g,m.id,d)),c&&(m.f.F=!1,!1===d&&(f=
|
||||
null)))}f&&(c?(h=d=!1,b?(a.c&&Ob(a,a.c,g.toString()),Db(k)&&Db(g)||(f=null,d=h=!0)):a.a&&(d=!0,h=3==a.a),d&&g.clear(h)):f=g.toString());c&&(a.f.F=!1,b=a.i.power)&&(b.textContent="Power");a.g=0;return f}e.reset=function(){this.o&&this.o.reset&&this.o.reset();for(var a=z(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.o&&c.reset&&c.reset()}};e.start=function(a,b){for(var c=z(this.id),d=0;d<c.length;d++){var f=c[d];"CPU"!=f.type&&f!==this&&f.start&&f.start(a,b)}};
|
||||
e.stop=function(a,b){for(var c=z(this.id),d=0;d<c.length;d++){var f=c[d];"CPU"!=f.type&&f!==this&&f.stop&&f.stop(a,b)}};
|
||||
e.M=function(a,b,c){var d=this;switch(b){case "power":return this.i[b]=c,c.onclick=function(){d.g||(d.f.F?Nb(d,!1,!0):Jb(d,d.sa))},!0;case "reset":return this.i[b]=c,c.onclick=function(){if(d.f.F&&!d.g)if(d.a&&!d.s){var a=ia("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Nb(d,a,!0);!a&&d.w?window&&window.location.reload():d.sa(Y)}else d.reset(),d.b&&hb(d.b)},!0;case "save":if(da(ha(),"pcjs.org")){c.parentNode.removeChild(c);break}this.i[b]=
|
||||
c;c.onclick=function(){var a=Hb(d,!0);if(a){var b=!!(d.a&&!d.s||d.w),c=Nb(d,b);b?Ob(d,a,c):d.G("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function Hb(a,b){var c=a.c;c||(c=la("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=Pb(a,c))||a.G("The user ID is invalid."))):b&&a.G("Browser local storage is not available"));return c}
|
||||
function Pb(a,b){a.c=null;var c=q(ha()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(ma("user",c.data),a.c=c.data)}catch(f){t(f.message+" ("+d+")")}return a.c}function Ib(a){var b=null;a.c&&(b=ha()+"/api/v1/user?req=load&user="+a.c+"&state="+Bb(a,Z));return b}
|
||||
function Ob(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Bb(a,Z);d.data=c;b=q(ha()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var f=d.indexOf("\n");0<f&&(d=d.substr(0,f));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.G("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.G(c),ma("user",""),a.c=null)}}
|
||||
function Ia(a,b,c){a=z(a.id);for(var d=0;d<a.length;d++){var f=a[d];if(c)c==f&&(c=null);else if(f.type==b)return f}return null}e.aa=function(a){this.b&&this.b.aa(a);this.h&&this.h.aa(a)};v(function(){for(var a=E(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=C(c),c=E(c,"pc8080","computer"),f=0;f<c.length;f++){var g=c[f],k=C(g),k=new Fb(k,d,!0);D(k,g);k.A&&Jb(k,k.sa)}});
|
||||
u.show.push(function(){for(var a=E(document,"pc8080","computer"),b=0;b<a.length;b++){var c=C(a[b]);(c=A("Computer",c.id))&&c.B&&!c.f.F&&c.sa(-1)}});u.exit.push(function(){for(var a=E(document,"pc8080","computer"),b=0;b<a.length;b++){var c=C(a[b]);(c=A("Computer",c.id))&&c.f.F&&Nb(c,!(!c.a||c.s),!0)}});var Qb=0;function Rb(a,b,c,d,f,g){f("Loading "+a+"...");q(a,null,!0,function(k,h,l){l?(h||(h="unable to load "+a+" ("+l+")"),g(h,null)):Sb(h,a,b,c,d,f,g)})}
|
||||
function Sb(a,b,c,d,f,g,k){function h(a,g){if(g)k(g,null);else{if(c){Ca(c,b,a);var h=b;h&&0>h.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(h=window.location.pathname+h);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+h+'"}';"object"==typeof resources&&(h=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(h?' url="'+h+'"':""))}f||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
|
||||
h=null;if("<"==a.charAt(0))try{f||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(h=new window.ActiveXObject("Microsoft.XMLDOM"),h.async=!1,h.loadXML(a)):h=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){h=null,a=r.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);k(a,h)}}a?f?Tb(a,g,h):h(a,null):k("no data"+(b?" for file: "+b:""),null)}
|
||||
function Tb(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var f=d[2];b("Loading "+f+"...");q(f,null,!0,function(g,k,h){if(h||!k)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(g=d[3])if(h=k.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[0],m,B=/( [a-z]+=)(['"])(.*?)\2/g;m=B.exec(g);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);h[0]!=l&&(k=k.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+f);return}k=k.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(d[0],k);Tb(a,b,c)}})}else c(a,null)}
|
||||
function Ub(a,b,c,d){function f(a){if(void 0===h){var b=k&&E(k,"machine-warning");h=b&&b[0]||k}h&&(h.innerHTML=fa(a))}function g(a){f("Error: "+a);l&&(--Qb||sa(!0));l=!1}var k,h,l=!0;Qb++;Ba[a]={};try{if(k=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var B=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=m:r.appendChild(document.createTextNode(m));B.appendChild(r)}c||
|
||||
(c="/versions/pc8080/1.21.7/components.xsl");m=function(d,h){h?Rb(c,null,null,!1,f,function(d,m){if(m)if(Ca(a,c,d),f("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=h.transformNode(m);l?(k.outerHTML=l,--Qb||sa(!0)):g("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(h,document))?k.parentNode?(k.parentNode.replaceChild(l,k),--Qb||sa(!0)):g("invalid machine element: "+
|
||||
a):g("transformToFragment failed")):g("unable to transform XML: unsupported browser");else g(d)}):g(d)};"<"!=b.charAt(0)?Rb(b,a,d,!0,f,m):Sb(b,null,a,d,!1,f,m)}else g("missing machine element: "+a)}catch(Aa){g(Aa.message)}return l}window.embedPC8080=function(a,b,c,d){sa(!1);return Ub(a,b,c,d)};window.enableEvents=sa;window.sendEvent=ta;
|
||||
function Vb(a,b,c,d){if(!c&&b){d.push(b);a=Ba[d[0]];b=null;for(var f in a)if(da(f,"components.xsl")){b=f.replace(".xsl",".css");break}b?q(b,null,!0,function(a,b){Wb(b,d)}):Wb(null,d)}else t("Error ("+c+") requesting "+a)}
|
||||
function Wb(a,b){var c,d,f,g=b[0],k=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var h=Ba[g],l={},m;for(m in h){var B=h[m],r=ca(m);if("xml"==r){for(r=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(h[m]);){var Aa=d[2];Aa&&(h[Aa]||(B=B.replace(d[0],"")))}d=m=ba(m)}else"xsl"==r&&(f=m=ba(m));l[m]=B}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&f?(m=JSON.stringify(l),k+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
|
||||
"©"),m=k,h=null,l="data:application/javascript,",l=na("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),m&&(h=document.createElement("a"),"string"!=typeof h.download&&(h=null)),h?(h.href=l,h.download=m,document.body.appendChild(h),h.click(),document.body.removeChild(h),c="Check your Downloads folder for "+m+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(m?" ("+m+")":"")+"."),c+=', copy it to your web server as "'+k+'", and then add the following to your web page:\n\n',
|
||||
c+='<div id="'+g+'"></div>\n',c+="...\n",c+='<script type="text/javascript" src="'+k+'">\x3c/script>\n',c+='<script type="text/javascript">embedPC("'+g+'","'+d+'","'+f+'");\x3c/script>\n\n',c+="The machine should appear where the <div> is located.",t(c)):t("Missing XML/XSL resources")}
|
||||
window.savePC=function(a,b,c){var d=A("Computer",a),f=A("Debugger",a);if(d){var g=Nb(d,!0),k=d.l?JSON.stringify(d.l):null;b||(b="/versions/pcjs/1.21.7/pc"+(f?"-dbg":"")+".js");if(c&&c({state:g,Wa:k}))return!0;q(b,null,!0,function(c,d,f){Vb(c,d,f,[a,ba(b,!0),k,g])});return!0}t("Unable to identify machine '"+a+"'");return!1};})();
|
||||
function da(a,b){return-1!==a.indexOf(b,a.length-b.length)}var ea={"&":"&","<":"<",">":">",'"':""","'":"'"};function fa(a){return a.replace(/[&<>"']/g,function(a){return ea[a]})}var ga=Date.now||function(){return+new Date};function ha(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function p(a,b,c,d){var e=0,f=null,k=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),k;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),d&&d(a,f,e))});if(b&&"object"==
|
||||
typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");g.open("POST",a,!!c);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(l)}else g.open("GET",a,!!c),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();c||(f=g.responseText,200!=g.status&&(e=g.status||-1),d&&d(a,f,e),k=[f,e]);return k}function ia(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function q(a){window&&window.alert(a)}function ja(a){var b=!1;window&&(b=window.confirm(a));return b}var ka=null;function la(){if(null==ka){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}ka=a}return ka}function ma(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
|
||||
function na(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function oa(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}var r={init:[],show:[],exit:[]},pa=!1,qa=!0;function ra(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function u(a){r.init.push(a)}
|
||||
function sa(a){if(qa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){q("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.")}}function ta(a){!qa&&a?(qa=!0,pa&&ua("init")):qa=a}function ua(a){r[a]&&sa(r[a])}ra("onload",function(){pa=!0;sa(r.init)});ra("onpageshow",function(){sa(r.show)});ra(oa("Opera")||oa("iOS")?"onunload":"onbeforeunload",function(){sa(r.exit)});
|
||||
function v(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id;this.name=b.name;this.La=b.comment;this.Wa=b;void 0===this.id&&(this.id="");b=this.id.indexOf(".");0<b?(this.Na=this.id.substr(0,b),this.Ma=this.id.substr(b+1)):this.Ma=this.id;this[a]=c;this.f={ca:!1,la:!1,Fa:!1,F:!1,Z:!1};this.za=null;this.f.Z=!1;this.s={};this.J=null;w.push(this)}var va=void 0,wa={};
|
||||
if(window){va||(va=window.location.search.substr(1));for(var xa,ya=/\+/g,za=/([^&=]+)=?([^&]*)/g;xa=za.exec(va);)wa[decodeURIComponent(xa[1].replace(ya," "))]=decodeURIComponent(xa[2].replace(ya," "))}function Aa(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
|
||||
function x(a,b){b||(b=v);a.prototype=Aa(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}var w=[],Ba={};function Da(a,b,c){Ba[a]&&b&&(Ba[a][b]=c)}function y(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<w.length;b++){var d=w[b];a&&d.id.indexOf(a)||c.push(d)}return c}
|
||||
function z(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<w.length;d++)if(c)c==w[d]&&(c=null);else if(!(a!=w[d].type||b&&w[d].id.indexOf(b)))return w[d]}return null}function A(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){q(c.message+" ("+a+")")}return b}
|
||||
function B(a,b){for(var c=C(b.parentNode,"pc8080-control"),d=0;d<c.length;d++)for(var e=c[d].childNodes,f=0;f<e.length;f++){var k=e[f];if(1===k.nodeType){var g=k.getAttribute("class");if(g)for(var l=g.split(" "),m=0;m<l.length;m++)switch(g=l[m],g){case "pc8080-binding":(g=A(k))&&g.binding&&a.M(g.type,g.binding,k,g.value),m=l.length}}}}
|
||||
function C(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
|
||||
v.prototype={constructor:v,parent:null,toString:function(){return this.name?this.name:this.id||this.type},M:function(a,b,c){switch(b){case "clear":return this.s[b]||(this.s[b]=c,c.onclick=function(a){return function(){a.s.print&&(a.s.print.value="")}}(this)),!0;case "print":return this.s[b]||(this.Ea=this.s[b]=c,c.value="",this.L=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
|
||||
this.G=function(a,b,c){this.L(a,"notice",c)}),!0;default:return!1}},log:function(){},L:function(){},status:function(a){this.L(this.Ma+": "+a)},G:function(a,b){b||q(a)},W:function(){return this.f.F=!0},V:function(a,b){b&&(this.f.F=!1);return!0}};function Ea(a,b){if(a.f.Fa)return a.f.la&&(a.f.la=!1),a.f.Fa=!1;if(a.f.Z)return a.L(a.toString()+" error"),!1;a.f.la=b;return a.f.la}function E(a){if(!a.f.Z&&(a.f.ca=!0,a.f.ca)){var b=a.za;a.za=null;b&&b()}}
|
||||
function Fa(a,b){b&&(a.f.ca?b():a.za=b);return a.f.ca}
|
||||
var Ga="undefined"!==typeof ArrayBuffer,Ha=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
|
||||
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function Ia(a){v.call(this,"Panel",a,Ia)}x(Ia);h=Ia.prototype;h.M=function(a,b,c,d){return this.u&&this.u.M(a,b,c,d)||this.a&&this.a.M(a,b,c,d)||this.b&&this.b.M(a,b,c,d)?!0:this.parent.M.call(this,a,b,c,d)};h.ma=function(a,b,c,d){this.u=a;this.A=b;this.a=c;this.J=d;this.b=Ja(a,"Keyboard")};h.W=function(a,b){b||Ka();return!0};h.V=function(){return!0};h.ba=function(){};
|
||||
function Ka(){for(var a=!1,b=C(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=A(d),f;a:{f=e.id;if(void 0!==f)for(var k=void 0,k=0;k<w.length;k++)if(w[k].id===f){f=w[k];break a}f=null}f||(a=!0,f=new Ia(e));B(f,d);a&&E(f)}}u(Ka);
|
||||
function La(a,b,c){v.call(this,"Bus",a,La);this.a=b;this.J=c;this.g=a.buswidth||16;this.i=Math.pow(2,this.g);this.h=this.i-1|0;this.B=20>=this.g?12:24>=this.g?14:15;this.w=1<<this.B;this.j=this.w>>2;this.l=this.w-1;this.c=this.i/this.w|0;a=new F;Ma(a,this.J);this.b=Array(this.c);for(b=0;b<this.c;b++)this.b[b]=a;a=this.a;b=this.b;c=this.B;var d=this.h;a.K=b;a.B=c;a.w=1<<a.B;a.P=a.w-1;a.wa=b.length;a.ia=a.wa-1;a.X=d;E(this)}x(La);La.prototype.reset=function(){};
|
||||
La.prototype.W=function(a,b){b||this.reset();return!0};function Na(a,b,c,d){for(var e=b>>>a.B;0<c&&e<a.b.length;){var f=a.b[e],k=e*a.w,g=c>a.w?a.w:c;if(f&&f.size){if(f.type==d){if(b+c<=f.ka)return f.Da+=f.ka-b,f.ka=b,!0;if(b>=f.ka+f.Da){g=f.size-(b-k);g>c&&(g=c);f.Da=b-f.ka+g;c-=g;b=k+a.w;continue}}return Oa(1,b,c)}f=a.b[e];b=new F(b,g,a.w,d);Ma(b,a.J,f);a.b[e++]=b;b=k+a.w;c-=g}return 0>=c?!0:Oa(2,b,c)}function Oa(a,b,c){q("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Pa;
|
||||
if(Ga){var Qa=new ArrayBuffer(2);(new DataView(Qa)).setUint16(0,256,!0);Pa=256===(new Uint16Array(Qa))[0]}else Pa=!1;var Ra=Pa;
|
||||
function F(a,b,c,d){this.id=Sa+=2;this.a=null;this.ka=a;this.Da=b;this.size=c||0;this.type=d||Ta;this.h=d==Ua;Ma(this);this.U=this.eb=!1;if(c)if(Ga)this.c=new ArrayBuffer(c),this.g=new DataView(this.c,0,c),this.b=new Uint8Array(this.c,0,c),this.l=new Uint16Array(this.c,0,c>>1),this.a=new Int32Array(this.c,0,c>>2),Va(this,Ra?Wa:Xa);else{this.a=Array(c>>2);for(a=0;a<this.a.length;a++)this.a[a]=0;Va(this,Ya)}else Va(this)}var Ta=0,Ua=2,Sa=0;
|
||||
F.prototype={constructor:F,parent:null,save:function(){var a,b;if(Ga)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.g.getInt32(b<<2,!0);else a=this.a;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(Ga)for(b=0;b<a.length;b++)this.g.setInt32(b<<2,a[b],!0);else this.a=a;return this.U=!0}return!1},m:function(){return 255},s:function(){},o:function(a,b){return this.ua(a++,b++)|this.ua(a,b)<<8},u:function(a,b,c){this.va(a++,b&255,c++);this.va(a,b>>8,c)},C:function(a){return this.a[a>>
|
||||
2]>>>((a&3)<<3)&255},N:function(a){var b=a>>2;a=(a&3)<<3;var c=this.a[b]>>a;return 24>a?c&65535:c&255|(this.a[b+1]&255)<<8},T:function(a,b){var c=a>>2,d=(a&3)<<3;this.a[c]=this.a[c]&~(255<<d)|b<<d;this.U=!0},wa:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.a[c]=this.a[c]&~(65535<<d)|b<<d:(this.a[c]=this.a[c]&16777215|b<<24,c++,this.a[c]=this.a[c]&-256|b>>8);this.U=!0},v:function(a,b){return this.w(a,b)},H:function(a,b){return this.I(a,b)},R:function(a,b,c){this.h||this.Za(a,b,c)},Y:function(a,b,c){this.h||
|
||||
this.ia(a,b,c)},A:function(a){return this.b[a]},B:function(a){return this.b[a]},D:function(a){return this.g.getUint16(a,!0)},K:function(a){return a&1?this.b[a]|this.b[a+1]<<8:this.l[a>>1]},P:function(a,b){this.b[a]=b;this.U=!0},S:function(a,b){this.b[a]=b;this.U=!0},X:function(a,b){this.g.setUint16(a,b,!0);this.U=!0},ja:function(a,b){a&1?(this.b[a]=b,this.b[a+1]=b>>8):this.l[a>>1]=b;this.U=!0}};function Ma(a,b,c){a.J=b;a.i=a.j=0;c&&((a.i=c.i)&&Za(a,$a,!1),(a.j=c.j)&&ab(a,$a,!1))}
|
||||
function ab(a,b,c){c&&a.j||(a.va=!a.h&&b[2]||a.s,a.ib=!a.h&&b[3]||a.u);if(c||void 0===c)a.Za=b[2]||a.s,a.ia=b[3]||a.u}function Za(a,b,c){c&&a.i||(a.ua=b[0]||a.m,a.gb=b[1]||a.o);if(c||void 0===c)a.w=b[0]||a.m,a.I=b[1]||a.o}function Va(a,b){b||(b=bb);Za(a,b,void 0);ab(a,b,void 0)}var bb=[],Ya=[F.prototype.C,F.prototype.N,F.prototype.T,F.prototype.wa],$a=[F.prototype.v,F.prototype.H,F.prototype.R,F.prototype.Y];
|
||||
if(Ga)var Xa=[F.prototype.A,F.prototype.D,F.prototype.P,F.prototype.X],Wa=[F.prototype.B,F.prototype.K,F.prototype.S,F.prototype.ja];
|
||||
function cb(a,b){v.call(this,"CPU",a,cb);var c=a.cycles||b,d=a.multiplier||1;this.b={};this.b.ha=c;this.b.ga=d;this.b.Ga=Math.round(this.b.ha/1E4)/100;this.b.da=this.b.Ga*this.b.ga;this.f.O=!1;this.f.Ra=!1;this.f.Pa=a.autoStart;this.f.Qa=!1;this.f.xa=!1;this.b.Ba=this.b.fa=0;this.b.Ca=a.csStart;this.b.na=a.csInterval;this.b.oa=a.csStop;this.bb=this.Ja.bind(this);E(this)}x(cb);var db=["power","reset"];h=cb.prototype;
|
||||
h.ma=function(a,b,c,d){this.u=a;this.A=b;this.J=d;for(b=0;b<db.length;b++)(c=this.s[db[b]])&&this.u.M(null,db[b],c);Ja(a,"FPU");this.C=Ja(a,"ChipSet");a=eb(a,"autoStart");null!=a&&(this.f.Pa="true"==a?!0:"false"==a?!1:!!a);E(this)};h.reset=function(){};h.save=function(){return null};h.restore=function(){return!1};h.W=function(a,b){if(!b){if(a&&this.restore){fb(this);if(!this.restore(a))return!1;gb(this)}else this.reset();this.L("No debugger detected")}hb(this);return!0};
|
||||
h.V=function(a){return a?this.save():!0};function ib(a){(a.f.Pa||void 0===a.s.run)&&a.Ja()}h.Sa=function(){return 0};function gb(a){void 0===a.b.Ca&&(a.b.Ca=0);void 0===a.b.na&&(a.b.na=-1);void 0===a.b.oa&&(a.b.oa=-1);a.f.xa=0<=a.b.Ca&&0<a.b.na;a.f.xa&&(a.b.Ba=0,a.b.fa=a.b.Ca-a.S)}
|
||||
h.M=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.s[b]=c;a=!0;break;case "run":this.s[b]=c;c.onclick=function(){var a;if(a=d.u)if(a=d.u,a.f.F)a=!0;else{var b=null,c,g=y(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.f.ca);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.f.F);c++);c==g.length&&(b=a);q("The "+b.type+" component ("+b.id+") is not "+(b.f.ca?"powered yet":"ready yet"+(b.za?" (waiting for notification)":""))+".");a=!1}a&&(d.f.O?G(d,!0):d.Ja())};a=!0;break;
|
||||
case "speed":this.s[b]=c;a=!0;break;case "setSpeed":this.s[b]=c,c.onclick=function(){jb(d,d.b.ga<<1)},c.textContent=this.b.da.toFixed(2)+"Mhz",a=!0}return a};function kb(a,b,c){a.S+=b;c&&(a.R=a.a=0)}function lb(a,b){var c=30;60>c&&(c=60);2>c&&(c=2);var d=1;b&&1<a.b.ga&&a.b.$&&(d=a.b.$/a.b.Ga);a.b.Ta=Math.round(1E3/30);a.b.fb=Math.floor(a.b.ha/c*d);a.b.Ha=Math.floor(a.b.ha/30*d);a.b.Va=Math.floor(a.b.ha/60*d);a.b.Ua=Math.floor(a.b.ha/2*d);b||(a.b.ra=a.b.Ha,a.b.qa=a.b.Va,a.b.pa=a.b.Ua);a.b.Ia=0}
|
||||
function mb(a){return a.S+a.N+a.R-a.a}function fb(a){a.b.$=0;a.S=a.N=a.R=a.a=0;gb(a);jb(a,1)}function jb(a,b){if(void 0!==b){.8>a.b.$/a.b.da&&(b=1);a.b.ga=b;var c=a.b.Ga*a.b.ga;if(a.b.da!=c){a.b.da=c;var c=a.b.da.toFixed(2)+"Mhz",d=a.s.setSpeed;d&&(d.textContent=c);a.L("target speed: "+c)}}kb(a,a.N);a.N=0;a.b.ea=ga();a.b.aa=0;lb(a)}
|
||||
h.Ja=function(){if(Ea(this,!0)){if(!this.f.O){jb(this);this.u&&this.u.start(this.b.ea,mb(this));this.f.O=!0;this.f.Ra=!0;this.C&&this.C.hb();var a=this.s.run;a&&(a.textContent="Halt");this.u&&this.u.ba(!0)}this.b.Ia>=this.b.ha&&lb(this,!0);this.b.sa=0;this.b.Aa=ga();this.b.aa&&(a=this.b.Aa-this.b.aa,a>this.b.Ta&&(this.b.ea+=a,this.b.ea>this.b.Aa&&(this.b.ea=this.b.Aa)));try{do{var b=this.f.xa?1:this.b.fb;this.C&&(this.C.Ya(),b=this.C.kb(0,b),b=this.C.jb(b));try{this.Xa(b)}catch(e){if("number"!=typeof e)throw e;
|
||||
}var c=this.R-this.a;this.N+=c;this.b.sa+=c;kb(this,0,!0);a=c;if(this.f.xa){var d=!1;this.b.Ba=this.b.Ba+this.Sa()|0;this.b.fa-=a;0>=this.b.fa&&(this.b.fa+=this.b.na,d=!0);0<=this.b.oa&&this.b.oa<=mb(this)&&(this.b.na=this.b.oa=-1,gb(this),G(this),d=!0);d&&this.L(mb(this)+" cycles: checksum="+n(this.b.Ba))}this.b.qa-=c;0>=this.b.qa&&(this.b.qa+=this.b.Va);this.b.pa-=c;0>=this.b.pa&&(this.b.pa+=this.b.Ua,this.u&&this.u.ba());this.b.ra-=c;if(0>=this.b.ra){this.b.ra+=this.b.Ha;break}}while(this.f.O)}catch(e){G(this);
|
||||
hb(this);this.u&&this.u.stop(ga(),mb(this));Ea(this,!1);b=e.stack||e.message;this.f.Z=!0;this.G(b);return}b=setTimeout;c=this.bb;this.b.aa=ga();a=this.b.Ta;this.b.sa&&(a=Math.round(a*this.b.sa/this.b.Ha));a-=this.b.aa-this.b.Aa;if(d=this.b.aa-this.b.ea)this.b.$=Math.round(this.N/(10*d))/100,864E5<=d&&(this.S=0,this.C&&this.C.Ya(!0),jb(this));if(0>a||this.b.$<this.b.da)a=0;this.b.Ia+=this.b.sa;this.b.aa+=a;b(c,a)}else hb(this),this.u&&this.u.stop(ga(),mb(this))};h.Xa=function(){return 0};
|
||||
function G(a,b){a.f.la&&(a.f.Fa=!0);a.R-=a.a;a.a=0;kb(a,a.N);a.N=0;if(a.f.O){a.f.O=!1;a.C&&a.C.hb();var c=a.s.run;c&&(c.textContent="Run")}a.f.ya=b}function hb(a){a.u&&a.u.ba(void 0)}function nb(a){this.ab=a.model||8080;cb.call(this,a,1E6);this.$a=ob;fb(this);this.f.ya=this.f.cb=!1;this.Ka=0;this.K=[];this.B=this.w=this.P=this.wa=this.ia=this.X=0;pb(this)}x(nb,cb);h=nb.prototype;h.reset=function(){this.f.O&&G(this);pb(this);fb(this);this.f.Z=!1};
|
||||
function pb(a){a.c=0;a.h=0;a.i=0;a.j=0;a.l=0;a.m=0;a.o=0;a.H=0;a.D=0;qb(a,0);a.T=0}h.Sa=function(){var a=this.c+this.h+this.i+this.j+this.l+this.m+this.o|0;return a=a+this.H+this.D+rb(this)|0};
|
||||
h.save=function(){var a=new H(this);I(a,0,[this.c,this.h,this.i,this.j,this.l,this.m,this.o,this.H,this.D,rb(this)]);I(a,1,[this.Y,this.T,this.S,this.b.ga]);for(var b=this.A,c=0,d=[],e=0;e<b.c;e++){var f=b.b[e];if(f.U||f.eb){d[c++]=e;var k=c++;a:if(f=f.save()){for(var g=0,l=0,m=[];g<f.length;){for(var D=f[g],t=g+1;t<f.length&&f[t]===D;)t++;m[l++]=t-g;m[l++]=D;g=t}if(m.length<f.length){f=m;break a}}d[k]=f}}I(a,2,d);return a.data()};
|
||||
h.restore=function(a){var b=a[0];this.c=b[0];this.h=b[1];this.i=b[2];this.j=b[3];this.l=b[4];this.m=b[5];this.o=b[6];this.H=b[7]&65535;this.D=b[8]&65535;qb(this,b[9]);b=a[1];this.Y=b[0];this.T=b[1];this.S=b[2];jb(this,b[3]);a:{b=this.A;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.j){for(var f=0,k=Array(b.j),g=0;g<e.length-1;)for(var l=e[g++],m=e[g++];l--;)k[f++]=m;e=k}f=b.b[d];if(!f||!f.restore(e)){q("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
h.M=function(a,b,c){var d=!1;switch(b){case "A":case "B":case "C":case "D":case "E":case "H":case "L":case "SP":case "PC":case "F":case "SF":case "ZF":case "AF":case "PF":case "CF":this.s[b]=c;this.Ka++;d=!0;break;default:d=this.parent.M.call(this,a,b,c)}return d};function sb(a){return a.h<<8|a.i}function tb(a,b){a.h=b>>8&255;a.i=b&255}function ub(a){return a.j<<8|a.l}function vb(a,b){a.j=b>>8&255;a.l=b&255}function J(a){return a.m<<8|a.o}function K(a,b){a.m=b>>8&255;a.o=b&255}
|
||||
function rb(a){return a.ja&-214|(a.v&128?128:0)|(a.g&255?0:64)|((a.v^a.I)&16?16:0)|(Ha[a.v&255]?4:0)|(a.g&256?1:0)}function qb(a,b){a.g=a.v=a.I=0;b&1&&(a.g|=256);b&4||(a.v|=1);b&16&&(a.I|=16);b&64||(a.g|=255);b&128&&(a.v^=192);a.ja=a.ja&-513|b&512|2}function L(a,b){a.I=b;b=(a.v=b+1)&255;a.g=a.g&-256|b;return b}function M(a,b){a.I=b;b=(a.v=b-1)&255;a.g=a.g&-256|b;return b}function N(a,b,c){a.I=b^c;return(a.g=a.v=b+c)&255}function O(a,b,c){a.I=b^c;return(a.g=a.v=b+c+(a.g&256?1:0))&255}
|
||||
function P(a,b){return a.K[(b&a.X)>>>a.B].ua(b&a.P,b)}function wb(a,b){var c=b&a.P,d=(b&a.X)>>>a.B;if(c<a.P)return a.K[d].gb(c,b);c=a.K[d].ua(c,b);return c|=a.K[d+1&a.ia].ua(0,b+1)<<8}function Q(a,b,c){a.K[(b&a.X)>>>a.B].va(b&a.P,c&255,b)}function R(a){var b=P(a,a.D);a.D=a.D+1&65535;return b}function S(a){var b=wb(a,a.D);a.D=a.D+2&65535;return b}
|
||||
function T(a,b,c,d){d=d||2;a.s[b]&&(void 0===c&&(a.f.Z=!0,a.G("Value for "+b+" is invalid"),G(a)),c=!a.f.O||a.f.Qa?n(c,d):"--------".substr(0,d),a.s[b].textContent!=c&&(a.s[b].textContent=c))}
|
||||
h.ba=function(a){this.Ka&&(a||!this.f.O||this.f.Qa)&&(T(this,"A",this.c),T(this,"B",this.h),T(this,"C",this.i),T(this,"D",this.j),T(this,"E",this.l),T(this,"H",this.m),T(this,"L",this.o),T(this,"SP",this.H,4),T(this,"PC",this.D,4),a=rb(this),T(this,"F",a,2),T(this,"SF",a&128,1),T(this,"ZF",a&64,1),T(this,"AF",a&16,1),T(this,"PF",a&4,1),T(this,"CF",a&1,1));if(a=this.s.speed)a.textContent=this.f.O&&this.b.$?this.b.$.toFixed(2)+"Mhz":"Stopped"};
|
||||
h.Xa=function(a){this.f.ya=!0;this.f.cb=!1;this.f.Ra=!1;this.R=this.a=a;this.C&&!a&&this.C.Ya();a||(this.Y|=4);do{if(this.T&&this.T&4){this.Y=this.a=0;break}this.Y=0;this.$a[R(this)].call(this)}while(0<this.a);return this.f.ya?this.R-this.a:void 0===this.f.ya?0:-1};u(function(){for(var a=C(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new nb(d);B(d,c)}});function U(){this.a-=4}function V(){this.D=this.D-1&65535;G(this)}
|
||||
var ob=[U,function(){tb(this,S(this));this.a-=10},function(){Q(this,sb(this),this.c);this.a-=7},function(){tb(this,sb(this)+1);this.a-=5},function(){this.h=L(this,this.h);this.a-=5},function(){this.h=M(this,this.h);this.a-=5},function(){this.h=R(this);this.a-=7},function(){var a=this.c<<1;this.c=a&255|a>>8;this.g=this.g&255|a&256;this.a-=4},U,function(){var a;K(this,a=J(this)+sb(this));this.g=this.g&255|a>>8&256;this.a-=10},function(){this.c=P(this,sb(this));this.a-=7},function(){tb(this,sb(this)-
|
||||
1);this.a-=5},function(){this.i=L(this,this.i);this.a-=5},function(){this.i=M(this,this.i);this.a-=5},function(){this.i=R(this);this.a-=7},function(){var a=this.c<<8&256;this.c=(a|this.c)>>1;this.g=this.g&255|a;this.a-=4},U,function(){vb(this,S(this));this.a-=10},function(){Q(this,ub(this),this.c);this.a-=7},function(){vb(this,ub(this)+1);this.a-=5},function(){this.j=L(this,this.j);this.a-=5},function(){this.j=M(this,this.j);this.a-=5},function(){this.j=R(this);this.a-=7},function(){var a=this.c<<
|
||||
1;this.c=a&255|this.g>>8;this.g=this.g&255|a&256;this.a-=4},U,function(){var a;K(this,a=J(this)+ub(this));this.g=this.g&255|a>>8&256;this.a-=10},function(){this.c=P(this,ub(this));this.a-=7},function(){vb(this,ub(this)-1);this.a-=5},function(){this.l=L(this,this.l);this.a-=5},function(){this.l=M(this,this.l);this.a-=5},function(){this.l=R(this);this.a-=7},function(){var a=this.c<<8&256;this.c=(this.g&256|this.c)>>1;this.g=this.g&255|a;this.a-=4},U,function(){K(this,S(this));this.a-=10},function(){var a=
|
||||
S(this),b=J(this),c=a&this.P,d=(a&this.X)>>>this.B;c<this.P?this.K[d].ib(c,b&65535,a):(this.K[d++].va(c,b&255,a),this.K[d&this.ia].va(0,b>>8&255,a+1));this.a-=16},function(){K(this,J(this)+1);this.a-=5},function(){this.m=L(this,this.m);this.a-=5},function(){this.m=M(this,this.m);this.a-=5},function(){this.m=R(this);this.a-=7},function(){var a=this.c,b=!!(this.g&256),c=!!((this.v^this.I)&16);9<(a&15)||c?(a+=6,c=!0):c=!1;160<=a||b?(a+=96,b=!0):b=!1;this.g=this.v=this.c=a&255;this.g=b?this.g|256:this.g&
|
||||
-257;this.I=c?~this.v&16|this.I&-17:this.v&16|this.I&-17;this.a-=4},U,function(){var a;K(this,a=J(this)+J(this));this.g=this.g&255|a>>8&256;this.a-=10},function(){K(this,wb(this,S(this)));this.a-=16},function(){K(this,J(this)-1);this.a-=5},function(){this.o=L(this,this.o);this.a-=5},function(){this.o=M(this,this.o);this.a-=5},function(){this.o=R(this);this.a-=7},function(){this.c=~this.c&255;this.a-=4},U,function(){this.H=S(this)&65535;this.a-=10},function(){Q(this,S(this),this.c);this.a-=13},function(){this.H=
|
||||
this.H+1&65535;this.a-=5},function(){var a=J(this);Q(this,a,L(this,P(this,a)));this.a-=10},function(){var a=J(this);Q(this,a,M(this,P(this,a)));this.a-=10},function(){Q(this,J(this),R(this));this.a-=10},function(){this.g|=256;this.a-=4},U,function(){var a;this.H=(a=J(this)+this.H)&65535;this.g=this.g&255|a>>8&256;this.a-=10},function(){this.c=P(this,S(this));this.a-=13},function(){this.H=this.H-1&65535;this.a-=5},function(){this.c=L(this,this.c);this.a-=5},function(){this.c=M(this,this.c);this.a-=
|
||||
5},function(){this.c=R(this);this.a-=7},function(){this.g=this.g&256?this.g&-257:this.g|256;this.a-=4},function(){this.a-=5},function(){this.h=this.i;this.a-=5},function(){this.h=this.j;this.a-=5},function(){this.h=this.l;this.a-=5},function(){this.h=this.m;this.a-=5},function(){this.h=this.o;this.a-=5},function(){this.h=P(this,J(this));this.a-=7},function(){this.h=this.c;this.a-=5},function(){this.i=this.h;this.a-=5},function(){this.a-=5},function(){this.i=this.j;this.a-=5},function(){this.i=this.l;
|
||||
this.a-=5},function(){this.i=this.m;this.a-=5},function(){this.i=this.o;this.a-=5},function(){this.i=P(this,J(this));this.a-=7},function(){this.i=this.c;this.a-=5},function(){this.j=this.h;this.a-=5},function(){this.j=this.i;this.a-=5},function(){this.a-=5},function(){this.j=this.l;this.a-=5},function(){this.j=this.m;this.a-=5},function(){this.j=this.o;this.a-=5},function(){this.j=P(this,J(this));this.a-=7},function(){this.j=this.c;this.a-=5},function(){this.l=this.h;this.a-=5},function(){this.l=
|
||||
this.i;this.a-=5},function(){this.l=this.j;this.a-=5},function(){this.a-=5},function(){this.l=this.m;this.a-=5},function(){this.l=this.o;this.a-=5},function(){this.l=P(this,J(this));this.a-=7},function(){this.l=this.c;this.a-=5},function(){this.m=this.h;this.a-=5},function(){this.m=this.i;this.a-=5},function(){this.m=this.j;this.a-=5},function(){this.m=this.l;this.a-=5},function(){this.a-=5},function(){this.m=this.o;this.a-=5},function(){this.m=P(this,J(this));this.a-=7},function(){this.m=this.c;
|
||||
this.a-=5},function(){this.o=this.h;this.a-=5},function(){this.o=this.i;this.a-=5},function(){this.o=this.j;this.a-=5},function(){this.o=this.l;this.a-=5},function(){this.o=this.m;this.a-=5},function(){this.a-=5},function(){this.o=P(this,J(this));this.a-=7},function(){this.o=this.c;this.a-=5},function(){Q(this,J(this),this.h);this.a-=7},function(){Q(this,J(this),this.i);this.a-=7},function(){Q(this,J(this),this.j);this.a-=7},function(){Q(this,J(this),this.l);this.a-=7},function(){Q(this,J(this),this.m);
|
||||
this.a-=7},function(){Q(this,J(this),this.o);this.a-=7},function(){this.T|=4;this.a-=7;this.ja&512||G(this)},function(){Q(this,J(this),this.c);this.a-=7},function(){this.c=this.h;this.a-=5},function(){this.c=this.i;this.a-=5},function(){this.c=this.j;this.a-=5},function(){this.c=this.l;this.a-=5},function(){this.c=this.m;this.a-=5},function(){this.c=this.o;this.a-=5},function(){this.c=P(this,J(this));this.a-=7},function(){this.a-=5},function(){this.c=N(this,this.c,this.h);this.a-=4},function(){this.c=
|
||||
N(this,this.c,this.i);this.a-=4},function(){this.c=N(this,this.c,this.j);this.a-=4},function(){this.c=N(this,this.c,this.l);this.a-=4},function(){this.c=N(this,this.c,this.m);this.a-=4},function(){this.c=N(this,this.c,this.o);this.a-=4},function(){this.c=N(this,this.c,P(this,J(this)));this.a-=7},function(){this.c=N(this,this.c,this.c);this.a-=4},function(){this.c=O(this,this.c,this.h);this.a-=4},function(){this.c=O(this,this.c,this.i);this.a-=4},function(){this.c=O(this,this.c,this.j);this.a-=4},
|
||||
function(){this.c=O(this,this.c,this.l);this.a-=4},function(){this.c=O(this,this.c,this.m);this.a-=4},function(){this.c=O(this,this.c,this.o);this.a-=4},function(){this.c=O(this,this.c,P(this,J(this)));this.a-=7},function(){this.c=O(this,this.c,this.c);this.a-=4},V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V];
|
||||
function W(a){v.call(this,"ROM",a,W);this.b=null;this.j=a.addr;this.c=a.size;this.g=a.alias;this.h=a.file;this.l=ba(this.h);if(this.h){a=this.h;var b=ca(this.l);"json"!=b&&"hex"!=b&&(a=ia()+"/api/v1/dump?file="+this.h+"&format=bytes&decimal=true");var c=this;p(a,null,!0,function(a,b,f){xb(c,a,b,f)})}}x(W);W.prototype.ma=function(a,b,c,d){this.A=b;this.a=c;this.J=d;yb(this)};W.prototype.W=function(){this.i&&(this.J&&this.J.a(this.id,this.j,this.c,this.i),delete this.i);return!0};W.prototype.V=function(){return!0};
|
||||
function xb(a,b,c,d){if(d)a.G("Unable to load system ROM (error "+d+": "+b+")");else{Da(a.Na,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,k=e.data;if(f)a.b=f;else if(k)for(a.b=Array(4*k.length),d=c=0;c<k.length;c++)a.b[d++]=k[c]&255,a.b[d++]=k[c]>>8&255,a.b[d++]=k[c]>>16&255,a.b[d++]=k[c]>>24&255;else a.b=e;a.i=e.symbols;if(!a.b.length){q("Empty ROM: "+b);return}if(1==a.b.length){q(a.b[0]);return}}catch(g){a.G("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.b=Array(b.length),e=0;e<b.length;e++)a.b[e]=aa(b[e]);yb(a)}}
|
||||
function yb(a){if(!Fa(a))if(!a.h)E(a);else if(a.b&&a.A){if(a.b.length!=a.c){var b="ROM size (0x"+n(a.b.length)+") does not match specified size ("+("0x"+n(a.c))+")";a.f.Z=!0;a.G(b)}else{b=a.j;if(Na(a.A,b,a.c,Ua)){for(var c=0;c<a.b.length;c++){var d=a.A,e=b+c;d.b[(e&d.h)>>>d.B].Za(e&d.l,a.b[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.g?b.push(a.g):null!=a.g&&a.g.length&&(b=a.g);for(c=0;c<b.length;c++){for(var f=a,d=b[c],e=f.A,k=f.c,g=[],l=f.j>>>e.B;0<k&&l<e.b.length;)g.push(e.b[l++]),k-=
|
||||
e.w;e=f.A;f=f.c;k=0;for(d>>>=e.B;0<f&&d<e.b.length;){l=g[k++];if(!l)break;e.b[d++]=l;f-=e.w}}delete a.b}}E(a)}}u(function(){for(var a=C(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new W(d);B(d,c)}});function zb(a){v.call(this,"RAM",a,zb);this.g=a.addr;this.c=a.size;this.b=!1}x(zb);h=zb.prototype;h.ma=function(a,b,c,d){this.A=b;this.a=c;this.J=d;E(this)};h.W=function(a,b){b||this.reset();return!0};h.V=function(a){return a?this.save():!0};
|
||||
h.reset=function(){!this.b&&this.c&&Na(this.A,this.g,this.c,1)&&(this.b=!0,this.status(Math.floor(this.c/1024)+"Kb allocated"));this.b||q("No RAM allocated")};h.save=function(){return null};h.restore=function(){return!0};u(function(){for(var a=C(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new zb(d);B(d,c)}});function Ab(a){v.call(this,"Keyboard",a,Ab);E(this)}x(Ab);u(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Ab(d);B(d,c)}});
|
||||
function Bb(a){v.call(this,"Video",a,Bb);E(this)}x(Bb);
|
||||
u(function(){for(var a=C(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=A(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=(window?window.navigator.userAgent:"").indexOf("MSIE")&&(c.onresize=function(a,
|
||||
b,c,d){return function(){b.style.height=(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||wa.aspect);f&&.3<=f&&3.33>=f&&(ra("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");oa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e.getContext("2d");d=new Bb(d);B(d,c)}});
|
||||
function H(a,b,c){this.id=a.id;this.key=Cb(a,b,c);this.J=a.J;Db(this,a.Wa)}function Cb(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
|
||||
H.prototype={constructor:H,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){Db(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,1);c=0}}};
|
||||
function Db(a,b){a[a.id]={};b&&I(a,"parms",b);a.a=!1}function Eb(a){var b=!0;if(la()){var c=JSON.stringify(a[a.id]);na(a.key,c)||(q("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function Fb(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){q(c.message||c),b=!1}return b}function X(a,b){return b?(a[a.id]=b,a.a=!0):a.a?!0:la()&&(b=ma(a.key))?(a[a.id]=b,a.a=!0):!1}function Y(a,b){return a[a.id][b]||null}function I(a,b,c){try{a[a.id][b]=c}catch(d){}}
|
||||
function Gb(a,b,c){v.call(this,"Computer",a,Gb);this.f.F=!1;Hb(this,b);this.v=eb(this,"autoPower",a);this.g=0;this.H=a.busWidth||a.buswidth;this.b=Ib;this.o=null;this.j=this.D=!1;this.I=eb(this,"url")||"";(Math.random()+.1).toString(36);this.c=Jb(this);if(this.a=z("CPU",this.id)){this.J=z("Debugger",this.id);this.K=[];for(b=null;b=Ja(this,"Video",b);)this.K.push(b);this.A=new La({id:this.Na+".bus",buswidth:this.H},this.a,this.J);var d,e=y(this.id);if((this.h=z("Panel",this.id))&&this.h.Ea)for(b=0;b<
|
||||
e.length;b++)d=e[b],d.G=this.h.G,d.L=this.h.L,d.Ea=this.h.Ea;for(b=0;b<e.length;b++)d=e[b],d.ma&&d.ma(this,this.A,this.a,this.J);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.m=d:this.b=parseInt(d,10));var f;if(a=eb(this,"state")||(f=!0,a.state))b=this.w=a,f||(this.j=!0,this.b=Ib),this.b&&(this.u=new H(this,Z),X(this.u)?b=null:delete this.u);!b&&this.b&&(b=Kb(this))&&(this.j=!0);if(b){var k=this;p(b,null,!0,function(a,b,c){c?(k.m=null,k.j=!1,k.G("Unable to load machine state from server (error "+
|
||||
c+(b?": "+(String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/g,"")):"")+")")):(k.o=b,k.D=!0);E(k)})}else E(this);this.s.power||(this.v=!0);!c&&this.v&&Lb(this,this.ta)}else q("Unable to find CPU component")}x(Gb);var Z="1.21.7",Ib=0;function Hb(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){q(d.message+" ("+c+")")}}a.l=b}
|
||||
function eb(a,b,c){var d=b.toLowerCase(),d=wa[b]||wa[d];void 0===d&&a.l&&(d=a.l[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function Lb(a,b,c){for(var d=y(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!Fa(f)){Fa(f,function(){Lb(a,b,c)});return}}b.call(a,c)}
|
||||
function Mb(a,b){var c=new H(a,Z,"validate");if(X(c)&&Fb(c)){var d=Y(c,"timestamp"),e=b?Y(b,"timestamp"):"unknown";d!=e&&(a.G("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}h=Gb.prototype;
|
||||
h.ta=function(a){void 0===a&&(a=this.b||(this.o?1:Ib));if(!this.g){this.g++;var b=!1,c=!1;this.C=!1;var d=this.u||new H(this,Z);if(-1==a)b=!0;else if(a>Ib){if(X(d,this.o)){this.i=new H(this,Z,"failsafe");X(this.i)&&(Nb(this,d),a=2,Db(this.i));I(this.i,"timestamp",ha());Eb(this.i);var e=this.b&&!this.j;if(1==a||ja("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Fb(d)){var f=Y(d,"code"),k=Y(d,"data");f&&("ok"==f?X(d,k):("error"==f&&"no machine state"!=
|
||||
k?(this.G("Error: "+k),"unable to verify user"==k&&(na("user",""),this.c=null)):this.L(f+": "+k),Db(d),X(d)?(c=Fb(d),e=!0):c=!1))}e&&Mb(this,c?d:null)}else 2==a&&d.clear()}else Mb(this);delete this.o;delete this.u}e=y(this.id);for(f=0;f<e.length;f++)k=e[f],k!==this&&k!=this.a&&(c=Ob(this,k,d,b,c));b=[d,a,c];-1!=a?Lb(this,this.Oa,b):this.Oa(b)}};
|
||||
function Ob(a,b,c,d,e){if(!b.f.F){b.f.F=!0;if(b.W){var f=null;e&&((f=Y(c,b.id))||(f=Y(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.W(f,d)&&f&&(q("Unable to restore state for "+b.type),a.w&&!a.D?(c.clear(),a.b=Ib,window&&window.location.reload()):a.C=!0,b.W(null),e=!1)}if(!d&&b.La)for(a=b.La.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
|
||||
h.Oa=function(a){var b=a[0],c=0>a[1];a=a[2];this.f.F=!0;var d=this.s.power;d&&(d.textContent="Shutdown");this.B||(this.L("PC8080 v"+Z+"\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>"),this.B=!0);this.a&&(Ob(this,this.a,b,c,a),ib(this.a));this.C&&(Nb(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.g=0};
|
||||
function Nb(a,b){if(ja("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.I,d=a.c||"",e=b.toString(),f={app:"PC8080"};f.ver=Z;f.url=c;f.user=d;f.type="bug";f.data=e;p("http://www.pcjs.org/api/v1/report",f,!0)}}
|
||||
function Pb(a,b,c){var d,e="none";if(a.g)return null;a.g--;var f=new H(a,Z),k=new H(a,Z,"validate"),g=ha();I(k,"timestamp",g);I(f,"timestamp",g);I(f,"version","1.21.7");I(f,"url",window?window.location.href:null);I(f,"browser",window?window.navigator.userAgent:"");a.a&&a.a.V&&(c&&G(a.a),d=a.a.V(b,c),"object"===typeof d&&I(f,a.a.id,d),c&&(a.a.f.F=!1,!1===d&&(e=null)));for(var g=y(a.id),l=0;l<g.length;l++){var m=g[l];m.f.F&&(m.V&&(d=m.V(b,c),"object"===typeof d&&I(f,m.id,d)),c&&(m.f.F=!1,!1===d&&(e=
|
||||
null)))}e&&(c?(g=d=!1,b?(a.c&&Qb(a,a.c,f.toString()),Eb(k)&&Eb(f)||(e=null,d=g=!0)):a.b&&(d=!0,g=3==a.b),d&&f.clear(g)):e=f.toString());c&&(a.f.F=!1,b=a.s.power)&&(b.textContent="Power");a.g=0;return e}h.reset=function(){this.A&&this.A.reset&&this.A.reset();for(var a=y(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.A&&c.reset&&c.reset()}};h.start=function(a,b){for(var c=y(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};
|
||||
h.stop=function(a,b){for(var c=y(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
|
||||
h.M=function(a,b,c){var d=this;switch(b){case "power":return this.s[b]=c,c.onclick=function(){d.g||(d.f.F?Pb(d,!1,!0):Lb(d,d.ta))},!0;case "reset":return this.s[b]=c,c.onclick=function(){if(d.f.F&&!d.g)if(d.b&&!d.m){var a=ja("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Pb(d,a,!0);!a&&d.w?window&&window.location.reload():d.ta(Ib)}else d.reset(),d.a&&ib(d.a)},!0;case "save":if(da(ia(),"pcjs.org")){c.parentNode.removeChild(c);break}this.s[b]=
|
||||
c;c.onclick=function(){var a=Jb(d,!0);if(a){var b=!!(d.b&&!d.m||d.w),c=Pb(d,b);b?Qb(d,a,c):d.G("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function Jb(a,b){var c=a.c;c||(c=ma("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=Rb(a,c))||a.G("The user ID is invalid."))):b&&a.G("Browser local storage is not available"));return c}
|
||||
function Rb(a,b){a.c=null;var c=p(ia()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(na("user",c.data),a.c=c.data)}catch(e){q(e.message+" ("+d+")")}return a.c}function Kb(a){var b=null;a.c&&(b=ia()+"/api/v1/user?req=load&user="+a.c+"&state="+Cb(a,Z));return b}
|
||||
function Qb(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Cb(a,Z);d.data=c;b=p(ia()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.G("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.G(c),na("user",""),a.c=null)}}
|
||||
function Ja(a,b,c){a=y(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}h.ba=function(a){this.a&&this.a.ba(a);this.h&&this.h.ba(a)};u(function(){for(var a=C(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=A(c),c=C(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],k=A(f),k=new Gb(k,d,!0);B(k,f);k.v&&Lb(k,k.ta)}});
|
||||
r.show.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=A(a[b]);(c=z("Computer",c.id))&&c.B&&!c.f.F&&c.ta(-1)}});r.exit.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=A(a[b]);(c=z("Computer",c.id))&&c.f.F&&Pb(c,!(!c.b||c.m),!0)}});var Sb=0;function Tb(a,b,c,d,e,f){e("Loading "+a+"...");p(a,null,!0,function(k,g,l){l?(g||(g="unable to load "+a+" ("+l+")"),f(g,null)):Ub(g,a,b,c,d,e,f)})}
|
||||
function Ub(a,b,c,d,e,f,k){function g(a,f){if(f)k(f,null);else{if(c){Da(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));
|
||||
g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(t){g=null,a=t.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);k(a,g)}}a?e?Vb(a,f,g):g(a,null):k("no data"+(b?" for file: "+b:""),null)}
|
||||
function Vb(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");p(e,null,!0,function(f,k,g){if(g||!k)c(a,"unable to resolve XML reference: "+d[0]+" ("+g+")");else{if(f=d[3])if(g=k.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=g[0],m,D=/( [a-z]+=)(['"])(.*?)\2/g;m=D.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);g[0]!=l&&(k=k.replace(g[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}k=k.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(d[0],k);Vb(a,b,c)}})}else c(a,null)}
|
||||
function Wb(a,b,c,d){function e(a){if(void 0===g){var b=k&&C(k,"machine-warning");g=b&&b[0]||k}g&&(g.innerHTML=fa(a))}function f(a){e("Error: "+a);l&&(--Sb||ta(!0));l=!1}var k,g,l=!0;Sb++;Ba[a]={};try{if(k=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var D=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css";t.styleSheet?t.styleSheet.cssText=m:t.appendChild(document.createTextNode(m));D.appendChild(t)}c||
|
||||
(c="/versions/pc8080/1.21.7/components.xsl");m=function(d,g){g?Tb(c,null,null,!1,e,function(d,m){if(m)if(Da(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(m);l?(k.outerHTML=l,--Sb||ta(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(g,document))?k.parentNode?(k.parentNode.replaceChild(l,k),--Sb||ta(!0)):f("invalid machine element: "+
|
||||
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Tb(b,a,d,!0,e,m):Ub(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(Ca){f(Ca.message)}return l}window.embedPC8080=function(a,b,c,d){ta(!1);return Wb(a,b,c,d)};window.enableEvents=ta;window.sendEvent=ua;
|
||||
function Xb(a,b,c,d){if(!c&&b){d.push(b);a=Ba[d[0]];b=null;for(var e in a)if(da(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?p(b,null,!0,function(a,b){Yb(b,d)}):Yb(null,d)}else q("Error ("+c+") requesting "+a)}
|
||||
function Yb(a,b){var c,d,e,f=b[0],k=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var g=Ba[f],l={},m;for(m in g){var D=g[m],t=ca(m);if("xml"==t){for(t=/[ \t]*<disk [^>]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=t.exec(g[m]);){var Ca=d[2];Ca&&(g[Ca]||(D=D.replace(d[0],"")))}d=m=ba(m)}else"xsl"==t&&(e=m=ba(m));l[m]=D}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&e?(m=JSON.stringify(l),k+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g,
|
||||
"©"),m=k,g=null,l="data:application/javascript,",l=oa("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),m&&(g=document.createElement("a"),"string"!=typeof g.download&&(g=null)),g?(g.href=l,g.download=m,document.body.appendChild(g),g.click(),document.body.removeChild(g),c="Check your Downloads folder for "+m+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(m?" ("+m+")":"")+"."),c+=', copy it to your web server as "'+k+'", and then add the following to your web page:\n\n',
|
||||
c+='<div id="'+f+'"></div>\n',c+="...\n",c+='<script type="text/javascript" src="'+k+'">\x3c/script>\n',c+='<script type="text/javascript">embedPC("'+f+'","'+d+'","'+e+'");\x3c/script>\n\n',c+="The machine should appear where the <div> is located.",q(c)):q("Missing XML/XSL resources")}
|
||||
window.savePC=function(a,b,c){var d=z("Computer",a),e=z("Debugger",a);if(d){var f=Pb(d,!0),k=d.l?JSON.stringify(d.l):null;b||(b="/versions/pcjs/1.21.7/pc"+(e?"-dbg":"")+".js");if(c&&c({state:f,Wa:k}))return!0;p(b,null,!0,function(c,d,e){Xb(c,d,e,[a,ba(b,!0),k,f])});return!0}q("Unable to identify machine '"+a+"'");return!1};})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue