Beispiel #1
0
/****************************************************************************
 * Execute cycles CPU cycles. Return number of cycles really executed
 ****************************************************************************/
static int cop410_execute(int cycles)
{
	UINT8 opcode;

	cop410_ICount = cycles;

	do
	{
		prevPC = PC;

		CALL_DEBUGGER(PC);

		opcode = ROM(PC);

		if (skipLBI == 1)
		{
			if (LBIops[opcode] == 0)
			{
				skipLBI = 0;
			}
			else {
				cop410_ICount -= opcode_map[opcode].cycles;

				PC += InstLen[opcode];
			}
		}

		if (skipLBI == 0)
		{
			int inst_cycles = opcode_map[opcode].cycles;
			PC++;
			(*(opcode_map[opcode].function))(opcode);
			cop410_ICount -= inst_cycles;

			// skip next instruction?

			if (skip == 1)
			{
				void *function = opcode_map[ROM(PC)].function;

				opcode = ROM(PC);

				if ((function == lqid) || (function == jid))
				{
					cop410_ICount -= 1;
				}
				else
				{
					cop410_ICount -= opcode_map[opcode].cycles;
				}
				PC += InstLen[opcode];

				skip = 0;
			}
		}
	} while (cop410_ICount > 0);

	return cycles - cop410_ICount;
}
Beispiel #2
0
INLINE void xad(void)
{
	UINT8 addr = ROM(PC++) & 0x3f;
	UINT8 t = A;
	A = RAM(addr);
	RAM(addr) = t;
}
Beispiel #3
0
INLINE void lqid(void)
{
	PUSH(PC + 1);
	PC = (UINT16)((PC & 0x300) | (A << 4) | M);
	WRITE_Q(ROM(PC));
	POP();
}
Beispiel #4
0
/****************************************************************************
 * Execute cycles CPU cycles. Return number of cycles really executed
 ****************************************************************************/
static int cop410_execute(int cycles)
{
	unsigned opcode;

	cop410_ICount = cycles;

	do
	{
		prevPC = PC;

		CALL_MAME_DEBUG;

		opcode = ROM(PC);

		if (skipLBI == 1)
		{
			if (LBIops[opcode] == 0)
			{
				skipLBI = 0;
			}
			else {
				cop410_ICount -=cop410_opcode_main[opcode].cycles;

				PC += InstLen[opcode];
			}
		}

		if (skipLBI == 0)
		{
			int inst_cycles = cop410_opcode_main[opcode].cycles;
			PC++;
			(*(cop410_opcode_main[opcode].function))();
			cop410_ICount -= inst_cycles;

			if (skip == 1) {
				opcode=ROM(PC);
				cop410_ICount -=cop410_opcode_main[opcode].cycles;
				PC += InstLen[opcode];
				skip = 0;
			}
		}
	} while (cop410_ICount>0);


	return cycles - cop410_ICount;
}
Beispiel #5
0
INLINE void jp(void)
{
	UINT8 op = ROM(prevPC);

	if (((PC & 0x3E0) >= 0x80) && ((PC & 0x3E0) < 0x100)) //JP pages 2,3
	{
		PC = (UINT16)((PC & 0x380) | (op & 0x7F));
	}
	else
	{
		if ((op & 0xC0) == 0xC0) //JP other pages
		{
			PC = (UINT16)((PC & 0x3C0) | (op & 0x3F));
		}
		else					//JSRP
		{
			PUSH((UINT16)(PC));
			PC = (UINT16)(0x80 | (op & 0x3F));
		}
	}
}
Beispiel #6
0
}


/* Default chip clock is 2119040 Hz */
/* At this clock chip generates exactly 440.0 Hz signal on 8' output when pitch data=0x21 */


/* ROM table to convert from pitch data into data for programmable counter and binary counter */
/* Chip has 88x12bits ROM   (addressing (in hex) from 0x00 to 0x57) */
#define ROM(counter,bindiv) (counter|(bindiv<<9))

static const UINT16 MSM5232_ROM[88]={
/* higher values are Programmable Counter data (9 bits) */
/* lesser values are Binary Counter shift data (3 bits) */

/* 0 */ ROM (506, 7),

/* 1 */ ROM (478, 7),/* 2 */ ROM (451, 7),/* 3 */ ROM (426, 7),/* 4 */ ROM (402, 7),
/* 5 */ ROM (379, 7),/* 6 */ ROM (358, 7),/* 7 */ ROM (338, 7),/* 8 */ ROM (319, 7),
/* 9 */ ROM (301, 7),/* A */ ROM (284, 7),/* B */ ROM (268, 7),/* C */ ROM (253, 7),

/* D */ ROM (478, 6),/* E */ ROM (451, 6),/* F */ ROM (426, 6),/*10 */ ROM (402, 6),
/*11 */ ROM (379, 6),/*12 */ ROM (358, 6),/*13 */ ROM (338, 6),/*14 */ ROM (319, 6),
/*15 */ ROM (301, 6),/*16 */ ROM (284, 6),/*17 */ ROM (268, 6),/*18 */ ROM (253, 6),

/*19 */ ROM (478, 5),/*1A */ ROM (451, 5),/*1B */ ROM (426, 5),/*1C */ ROM (402, 5),
/*1D */ ROM (379, 5),/*1E */ ROM (358, 5),/*1F */ ROM (338, 5),/*20 */ ROM (319, 5),
/*21 */ ROM (301, 5),/*22 */ ROM (284, 5),/*23 */ ROM (268, 5),/*24 */ ROM (253, 5),

/*25 */ ROM (478, 4),/*26 */ ROM (451, 4),/*27 */ ROM (426, 4),/*28 */ ROM (402, 4),
/*29 */ ROM (379, 4),/*2A */ ROM (358, 4),/*2B */ ROM (338, 4),/*2C */ ROM (319, 4),
Beispiel #7
0
rom::ROM rom::ROMFromFile(const std::string& filepath)
{
	Eigen::MatrixXd res;
	std::ifstream myfile (filepath.c_str());
	std::string line;
	double maxRadius_;
	int size_;
	double minx, miny, minz;
	double maxx, maxy, maxz;
	int axe1, axe2 , axe3;
	if (myfile.is_open())
	{
		if(myfile.good())
		{
			char r[255];
			getline (myfile, line);
			sscanf(line.c_str(),"%s",r);
			maxRadius_ = (double) (strtod (r, NULL));
		}
		else
		{
			std::string errmess("In file: " + filepath + "; file ended before finding radius");
			throw(new ROMException(errmess));
		}
		if(myfile.good())
		{
			char s[255];
			getline (myfile, line);
			sscanf(line.c_str(),"%s",s);
			size_ = (int) (strtod (s, NULL));

			getline (myfile, line);
			if(line.size()> 0)
			{
				line = remplacerVirgule(line);
				char caxe1[255],caxe2[255],caxe3[255];
				sscanf(line.c_str(),"%s %s %s",caxe1, caxe2, caxe3);
				axe1 = (int) strtod (caxe1, NULL);
				axe2 = (int) strtod (caxe2, NULL);
				axe3 = (int) strtod (caxe3, NULL);
			}
			getline (myfile, line);
			if(line.size()> 0)
			{
				line = remplacerVirgule(line);
				char cminx[255],cminy[255],cminz[255];
				char cmaxx[255],cmaxy[255],cmaxz[255];
				sscanf(line.c_str(),"%s %s %s %s %s %s",cminx, cmaxx, cminy, cmaxy, cminz, cmaxz);
				minx = (double) strtod (cminx, NULL);
				miny = (double) strtod (cminy, NULL);
				minz = (double) strtod (cminz, NULL);
				maxx = (double) strtod (cmaxx, NULL);
				maxy = (double) strtod (cmaxy, NULL);
				maxz = (double) strtod (cmaxz, NULL);
			}
		}
		res = ReadMatrix(size_, myfile);
		myfile.close();
	}
	else
	{
		std::string errmess("file not found: " + filepath);
		throw(new ROMException(errmess));
	}
	Eigen::MatrixXd A_ = res.block(0,0,size_,3);
	Eigen::VectorXd b_ = res.block(0,3,size_,1);
	return ROM(A_,b_,maxRadius_,minx, miny, minz, maxx, maxy, maxz, axe1, axe2, axe3);
}
Beispiel #8
0
INLINE void illegal(void)
{
	logerror("ICOP400:  PC = %04x,  Illegal opcode = %02x\n", PC-1, ROM(PC-1));
}
Beispiel #9
0
INLINE void JSR(UINT8 a8)
{
	PUSH(PC + 1);
	PC = (a8 << 8) | ROM(PC);
}
Beispiel #10
0
INLINE void JMP(UINT8 a8)
{
	PC = (a8 << 8) | ROM(PC);
}
Beispiel #11
0
INLINE void jid(void)
{
	UINT16 addr = (PC & 0x300) | (A << 4) | M;
	PC = (PC & 0x300) | ROM(addr);
}
Beispiel #12
0
static void cop410_op33(UINT8 opcode)
{
	UINT8 opcode33 = ROM(PC++);

	(*(opcode_33_map[opcode33].function))(opcode33);
}
Beispiel #13
0
static void cop410_op23(UINT8 opcode)
{
	UINT8 opcode23 = ROM(PC++);

	(*(opcode_23_map[opcode23].function))(opcode23);
}
Beispiel #14
0
static void cop410_op33(void)
{
	(*(cop410_opcode_op33[ROM(PC++)].function))();
}
Beispiel #15
0
/****************************************************************************
 * Execute cycles CPU cycles. Return number of cycles really executed
 ****************************************************************************/
static int cop420_execute(int cycles)
{
	unsigned opcode;

	cop420_ICount = cycles;

	do
	{
		prevPC = PC;

		CALL_MAME_DEBUG;

		opcode = ROM(PC);

		if (skipLBI == 1)
		{
			int is_lbi = 0;

			if (opcode == 0x33)
			{
				is_lbi = LBIops33[ROM(PC+1)];
			}
			else
			{
				is_lbi = LBIops[opcode];
			}

			if (is_lbi == 0)
			{
				skipLBI = 0;
			}
			else {
				cop420_ICount -= cop420_opcode_main[opcode].cycles;

				PC += InstLen[opcode];
			}
		}

		if (skipLBI == 0)
		{
			int inst_cycles = cop420_opcode_main[opcode].cycles;
			PC++;
			(*(cop420_opcode_main[opcode].function))();
			cop420_ICount -= inst_cycles;

			if (skip == 1) {
				opcode=ROM(PC);
				cop420_ICount -= cop420_opcode_main[opcode].cycles;
				PC += InstLen[opcode];
				skip = 0;
			}
		}

		/* counter handling */
		R.counter += cop420_opcode_main[opcode].cycles;
		if (R.counter > 1024)
		{
			R.timerlatch = 1;
			R.counter = 0;
		}

	} while (cop420_ICount > 0);

	return cycles - cop420_ICount;
}