docastle.c

来自「这个是延伸mame的在wince平台下的游戏模拟器的代码」· C语言 代码 · 共 68 行

C
68
字号
/***************************************************************************

  machine.c

  Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  I/O ports)

***************************************************************************/

#include "driver.h"
#include "timer.h"
#include "Z80/Z80.h"



static unsigned char buffer0[9],buffer1[9];



int docastle_shared0_r(int offset)
{
	/* this shouldn't be done, however it's the only way I've found */
	/* to make dip switches work in Do Run Run. */
	if (offset == 8)
	{
		cpu_cause_interrupt(1,Z80_NMI_INT);
		cpu_spinuntil_trigger(500);
	}

	return buffer0[offset];
}


int docastle_shared1_r(int offset)
{
	return buffer1[offset];
}


void docastle_shared0_w(int offset,int data)
{

	buffer0[offset] = data;

	if (offset == 8)
		/* awake the master CPU */
		cpu_trigger(500);
}


void docastle_shared1_w(int offset,int data)
{
	buffer1[offset] = data;

	if (offset == 8)
	{
		/* freeze execution of the master CPU until the slave has used the shared memory */
		cpu_spinuntil_trigger(500);
	}
}



void docastle_nmitrigger(int offset,int data)
{
	cpu_cause_interrupt(1,Z80_NMI_INT);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?