示例#1
0
文件: CPUMem.cpp 项目: Dervall/Nessie
BYTE CPUMem::read(WORD wAddress)
{
	if (wAddress < 0x2000) {
		return memory[wAddress];
	} else if (wAddress >= 0x8000 && wAddress < 0xC000) {
		return pPrgRomBank1[wAddress-0x8000];
	} else if (wAddress >= 0xC000 && wAddress <= 0xFFFF) {
		return pPrgRomBank2[wAddress-0xC000];
	} else {
		if (wAddress >= 0x2000 && wAddress <= 0x3FFF) {
			// Remove the mirroring and use the base addresses
			return ppuRegRead(0x2000 | (wAddress&7));
		} else if (wAddress == SPRDMA) {
			// TODO: Unknown results reading from SPRDMA..
			return openBus();
		} else if (wAddress == 0x4015)
		{
			NOT_IMPLEMENTED;
			return 0;
		}
		else if (wAddress == 0x4016)
		{
			return 0;
		}
	}

	// Bogus read
	NOT_IMPLEMENTED;
	return 0;
} 
示例#2
0
//main program
int main(int argc, char** argv)
{
	//open bus i2c
	int i2c_hdl;
	char *i2c_dev = "/dev/i2c-1";
	if((i2c_hdl = openBus(i2c_dev)) < 0)	//fail opening
	{
		perror("Failed opening i2c device");
		exit(1);
	}

	//write register
	unsigned char buff[10];
	buff[0] = 0x31;
	buff[1] = 0x0b;
	if(writeBytes(i2c_hdl, 0x53, buff, 2)>0)
	{
		printf("write 1 ok\n");
		/*
		buff[0] = 0x0b;
		if(writeBytes(i2c_hdl, 0x53, buff, 1)>0)
			printf("write 2 ok\n");
		*/
	}

	//close bus
	closeBus(i2c_hdl);

	return 0;
}
示例#3
0
u8 Cpu::mmio_read(u8 pos) {
	switch(pos) {
		case 1: return read_port_3F();
		case 2: return read_port_7E();
		case 3: return read_port_7F();
		case 6: return read_port_DC();
		case 7: return read_port_DD();
		case 8: return read_port_GG_0x0();
        case 15: return openBus();
	}
}
示例#4
0
文件: CPUMem.cpp 项目: Dervall/Nessie
BYTE CPUMem::ppuRegRead(WORD wAddress) {
	switch (wAddress) {
	case PPUCTRL:
		return openBus();	// The PPU control register is write only
	case PPUMASK:
		return openBus();
	case PPUSTATUS:
		return pPpu->readStatus();
	case OAMADDR:
		return openBus();
	case OAMDATA:
		return pPpu->readOAMData();
	case PPUSCROLL:
		NOT_IMPLEMENTED;	// I think this is open bus?!
		break;
	case PPUDATA:
		return pPpu->readPPUData();
	}

	NOT_IMPLEMENTED;
	return 0;
}
示例#5
0
//bus i2c init
int I2C_Init_Bus(char *dev_i2c_name, unsigned char *statusPeripheralOutput)
{
	int i2c_hdlx;
	
	if((i2c_hdlx = openBus(dev_i2c_name)) < 0)	//fail opening
	{
		printf("Failed opening i2c device");
		//return errno;
		*statusPeripheralOutput &= ~(1<<BIT_I2C_BUS_READY);
	}
	else
	{
		*statusPeripheralOutput |= (1<<BIT_I2C_BUS_READY);
		
	#if VERBOSE==1
		printf("i2c port opened\r\n");
	#endif 
	}
	
	return i2c_hdlx;
}
示例#6
0
u8 Cpu::read_port_3F() {
	return openBus();
}