Exemple #1
0
static void copy_to_memory (int cpu, int addr, const UINT8 *source, int num_bytes)
{
	int i;
	for (i=0; i<num_bytes; i++)
	{
		cpunum_write_byte (cpu, addr+i, source[i]);
	}
}
Exemple #2
0
/* call hs_init when emulation starts, and when the game is reset */
void hs_init (void)
{
	struct mem_range *mem_range = state.mem_range;
	state.hiscores_have_been_loaded = 0;

	while (mem_range)
	{
		cpunum_write_byte(
			mem_range->cpu,
			mem_range->addr,
			~mem_range->start_value
		);

		cpunum_write_byte(
			mem_range->cpu,
			mem_range->addr + mem_range->num_bytes-1,
			~mem_range->end_value
		);
		mem_range = mem_range->next;
	}
}
static void galpani2_write_kaneko(void)
{
	cpunum_write_byte(0,0x100000,0x4b);
	cpunum_write_byte(0,0x100001,0x41);
	cpunum_write_byte(0,0x100002,0x4e);
	cpunum_write_byte(0,0x100003,0x45);
	cpunum_write_byte(0,0x100004,0x4b);
	cpunum_write_byte(0,0x100005,0x4f);
}
static void galpani2_mcu_nmi(void)
{
	UINT32 mcu_list, mcu_command, mcu_address, mcu_src, mcu_dst, mcu_size;

	/* "Last Check" */
	galpani2_write_kaneko();

	for ( mcu_list = 0x100020; mcu_list < (0x100020 + 0x40); mcu_list += 4 )
	{
		mcu_command		=	cpunum_read_byte(0, mcu_list + 1 );

		mcu_address		=	0x100000 +
							(cpunum_read_byte(0, mcu_list + 2)<<8) +
							(cpunum_read_byte(0, mcu_list + 3)<<0) ;

		switch (mcu_command)
		{
		case 0x00:
			break;

		case 0x0a:	// Copy N bytes from RAM1 to RAM2
			mcu_src		=	(cpunum_read_byte(0, mcu_address + 2)<<8) +
							(cpunum_read_byte(0, mcu_address + 3)<<0) ;

			mcu_dst		=	(cpunum_read_byte(0, mcu_address + 6)<<8) +
							(cpunum_read_byte(0, mcu_address + 7)<<0) ;

			mcu_size	=	(cpunum_read_byte(0, mcu_address + 8)<<8) +
							(cpunum_read_byte(0, mcu_address + 9)<<0) ;

			logerror("CPU #0 PC %06X : MCU executes command $A, %04X %02X-> %04x\n",activecpu_get_pc(),mcu_src,mcu_size,mcu_dst);

			for( ; mcu_size > 0 ; mcu_size-- )
			{
				mcu_src &= 0xffff;	mcu_dst &= 0xffff;
				cpunum_write_byte(1,0x100000 + mcu_dst,cpunum_read_byte(0,0x100000 + mcu_src));
				mcu_src ++;			mcu_dst ++;
			}

			/* Raise a "job done" flag */
			cpunum_write_byte(0,mcu_address+0,0xff);
			cpunum_write_byte(0,mcu_address+1,0xff);

			break;

		default:
			/* Raise a "job done" flag */
			cpunum_write_byte(0,mcu_address+0,0xff);
			cpunum_write_byte(0,mcu_address+1,0xff);

			logerror("CPU #0 PC %06X : MCU ERROR, unknown command %02X\n",activecpu_get_pc(),mcu_command);
		}

		/* Erase command? */
		cpunum_write_byte(0,mcu_list + 1,0x00);
	}
}
Exemple #5
0
static void write_buffer_to_dma(struct ide_state *ide)
{
	int bytesleft = IDE_DISK_SECTOR_SIZE;
	UINT8 *data = ide->buffer;

//	LOG(("Writing sector to %08X\n", ide->dma_address));

	/* loop until we've consumed all bytes */
	while (bytesleft--)
	{
		/* if we're out of space, grab the next descriptor */
		if (ide->dma_bytes_left == 0)
		{
			/* if we're out of buffer space, that's bad */
			if (ide->dma_last_buffer)
			{
				LOG(("DMA Out of buffer space!\n"));
				return;
			}

			/* fetch the address */
			ide->dma_address = cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor);
			ide->dma_address |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 8;
			ide->dma_address |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 16;
			ide->dma_address |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 24;
			ide->dma_address &= 0xfffffffe;

			/* fetch the length */
			ide->dma_bytes_left = cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor);
			ide->dma_bytes_left |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 8;
			ide->dma_bytes_left |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 16;
			ide->dma_bytes_left |= cpunum_read_byte(ide->dma_cpu, ide->dma_descriptor++ ^ ide->dma_address_xor) << 24;
			ide->dma_last_buffer = (ide->dma_bytes_left >> 31) & 1;
			ide->dma_bytes_left &= 0xfffe;
			if (ide->dma_bytes_left == 0)
				ide->dma_bytes_left = 0x10000;

//			LOG(("New DMA descriptor: address = %08X  bytes = %04X  last = %d\n", ide->dma_address, ide->dma_bytes_left, ide->dma_last_buffer));
		}

		/* write the next byte */
		cpunum_write_byte(ide->dma_cpu, ide->dma_address++, *data++);
		ide->dma_bytes_left--;
	}
}
void galpani2_mcu_run(void)
{
	int i,x;

	/* Write "KANEKO" to 100000-100005, but do not clash with ram test */

	x  = 0;

	for (i = 0x100000; i < 0x100007; i++)
		x |= cpunum_read_byte(0,i);

	if	( x == 0 )
	{
		galpani2_write_kaneko();
		cpunum_write_byte(1,0x100006,1);
		logerror("MCU executes CHECK0\n");
	}
}