2011-10-01 12:06:48 +00:00
|
|
|
//BANDAI-FCG
|
|
|
|
|
|
|
|
struct BandaiFCG : Board {
|
2015-12-05 05:44:49 +00:00
|
|
|
BandaiFCG(Markup::Node& document) : Board(document) {
|
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
auto main() -> void {
|
2016-06-27 13:07:57 +00:00
|
|
|
if(irqCounterEnable) {
|
|
|
|
if(--irqCounter == 0xffff) {
|
Update to v099r04 release.
byuu says:
Changelog:
- lots of code cleanups to processor/r6502 (the switch.cpp file is only
halfway done ...)
- lots of code cleanups to fc/cpu
- removed fc/input
- implemented fc/controller
hex_usr, you may not like this, but I want to keep the controller port
and expansion port interface separate, like I do with the SNES. I realize
the NES' is used more for controllers, and the SNES' more for hardware
expansions, but ... they're not compatible pinouts and you can't really
connect one to the other.
Right now, I've only implemented the controller portion. I'll have to
get to the peripheral portion later.
Also, the gamepad implementation there now may be wrong. It's based off
the Super Famicom version obviously. I'm not sure if the Famicom has
different behavior with latching $4016 writes, or not. But, it works in
Mega Man II, so it's a start.
Everyone, be sure to remap your controls, and then set port 1 -> gamepad
after loading your first Famicom game with the new WIP.
2016-06-18 06:04:32 +00:00
|
|
|
cpu.irqLine(1);
|
2016-06-27 13:07:57 +00:00
|
|
|
irqCounterEnable = false;
|
2015-12-05 05:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-09 11:51:12 +00:00
|
|
|
|
|
|
|
tick();
|
2011-10-01 12:06:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto addrCIRAM(uint addr) const -> uint {
|
2015-12-05 05:44:49 +00:00
|
|
|
switch(mirror) {
|
|
|
|
case 0: return ((addr & 0x0400) >> 0) | (addr & 0x03ff);
|
|
|
|
case 1: return ((addr & 0x0800) >> 1) | (addr & 0x03ff);
|
|
|
|
case 2: return 0x0000 | (addr & 0x03ff);
|
|
|
|
case 3: return 0x0400 | (addr & 0x03ff);
|
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto readPRG(uint addr) -> uint8 {
|
2015-12-05 05:44:49 +00:00
|
|
|
if(addr & 0x8000) {
|
|
|
|
bool region = addr & 0x4000;
|
2016-06-27 13:07:57 +00:00
|
|
|
uint bank = (region == 0 ? prgBank : (uint8)0x0f);
|
2015-12-05 05:44:49 +00:00
|
|
|
return prgrom.read((bank << 14) | (addr & 0x3fff));
|
|
|
|
}
|
|
|
|
return cpu.mdr();
|
2011-10-01 12:06:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto writePRG(uint addr, uint8 data) -> void {
|
2015-12-05 05:44:49 +00:00
|
|
|
if(addr >= 0x6000) {
|
|
|
|
switch(addr & 15) {
|
|
|
|
case 0x00: case 0x01: case 0x02: case 0x03:
|
|
|
|
case 0x04: case 0x05: case 0x06: case 0x07:
|
2016-06-27 13:07:57 +00:00
|
|
|
chrBank[addr & 7] = data;
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
case 0x08:
|
2016-06-27 13:07:57 +00:00
|
|
|
prgBank = data & 0x0f;
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
case 0x09:
|
|
|
|
mirror = data & 0x03;
|
|
|
|
break;
|
|
|
|
case 0x0a:
|
Update to v099r04 release.
byuu says:
Changelog:
- lots of code cleanups to processor/r6502 (the switch.cpp file is only
halfway done ...)
- lots of code cleanups to fc/cpu
- removed fc/input
- implemented fc/controller
hex_usr, you may not like this, but I want to keep the controller port
and expansion port interface separate, like I do with the SNES. I realize
the NES' is used more for controllers, and the SNES' more for hardware
expansions, but ... they're not compatible pinouts and you can't really
connect one to the other.
Right now, I've only implemented the controller portion. I'll have to
get to the peripheral portion later.
Also, the gamepad implementation there now may be wrong. It's based off
the Super Famicom version obviously. I'm not sure if the Famicom has
different behavior with latching $4016 writes, or not. But, it works in
Mega Man II, so it's a start.
Everyone, be sure to remap your controls, and then set port 1 -> gamepad
after loading your first Famicom game with the new WIP.
2016-06-18 06:04:32 +00:00
|
|
|
cpu.irqLine(0);
|
2016-06-27 13:07:57 +00:00
|
|
|
irqCounterEnable = data & 0x01;
|
|
|
|
irqCounter = irqLatch;
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
case 0x0b:
|
2016-06-27 13:07:57 +00:00
|
|
|
irqLatch = (irqLatch & 0xff00) | (data << 0);
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
case 0x0c:
|
2016-06-27 13:07:57 +00:00
|
|
|
irqLatch = (irqLatch & 0x00ff) | (data << 8);
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
case 0x0d:
|
Update to v099r04 release.
byuu says:
Changelog:
- lots of code cleanups to processor/r6502 (the switch.cpp file is only
halfway done ...)
- lots of code cleanups to fc/cpu
- removed fc/input
- implemented fc/controller
hex_usr, you may not like this, but I want to keep the controller port
and expansion port interface separate, like I do with the SNES. I realize
the NES' is used more for controllers, and the SNES' more for hardware
expansions, but ... they're not compatible pinouts and you can't really
connect one to the other.
Right now, I've only implemented the controller portion. I'll have to
get to the peripheral portion later.
Also, the gamepad implementation there now may be wrong. It's based off
the Super Famicom version obviously. I'm not sure if the Famicom has
different behavior with latching $4016 writes, or not. But, it works in
Mega Man II, so it's a start.
Everyone, be sure to remap your controls, and then set port 1 -> gamepad
after loading your first Famicom game with the new WIP.
2016-06-18 06:04:32 +00:00
|
|
|
//todo: serial EEPROM support
|
2015-12-05 05:44:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto readCHR(uint addr) -> uint8 {
|
|
|
|
if(addr & 0x2000) return ppu.readCIRAM(addrCIRAM(addr));
|
|
|
|
addr = (chrBank[addr >> 10] << 10) | (addr & 0x03ff);
|
|
|
|
return Board::readCHR(addr);
|
2015-12-05 05:44:49 +00:00
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto writeCHR(uint addr, uint8 data) -> void {
|
|
|
|
if(addr & 0x2000) return ppu.writeCIRAM(addrCIRAM(addr), data);
|
|
|
|
addr = (chrBank[addr >> 10] << 10) | (addr & 0x03ff);
|
|
|
|
return Board::writeCHR(addr, data);
|
2015-12-05 05:44:49 +00:00
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
auto power() -> void {
|
|
|
|
reset();
|
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
auto reset() -> void {
|
2016-06-27 13:07:57 +00:00
|
|
|
for(auto& n : chrBank) n = 0;
|
|
|
|
prgBank = 0;
|
2015-12-05 05:44:49 +00:00
|
|
|
mirror = 0;
|
2016-06-27 13:07:57 +00:00
|
|
|
irqCounterEnable = 0;
|
|
|
|
irqCounter = 0;
|
|
|
|
irqLatch = 0;
|
2015-12-05 05:44:49 +00:00
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
auto serialize(serializer& s) -> void {
|
|
|
|
Board::serialize(s);
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
s.array(chrBank);
|
|
|
|
s.integer(prgBank);
|
2015-12-05 05:44:49 +00:00
|
|
|
s.integer(mirror);
|
2016-06-27 13:07:57 +00:00
|
|
|
s.integer(irqCounterEnable);
|
|
|
|
s.integer(irqCounter);
|
|
|
|
s.integer(irqLatch);
|
2015-12-05 05:44:49 +00:00
|
|
|
}
|
2011-10-01 12:06:48 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
uint8 chrBank[8];
|
|
|
|
uint8 prgBank;
|
2015-12-05 05:44:49 +00:00
|
|
|
uint2 mirror;
|
2016-06-27 13:07:57 +00:00
|
|
|
bool irqCounterEnable;
|
|
|
|
uint16 irqCounter;
|
|
|
|
uint16 irqLatch;
|
2011-10-01 12:06:48 +00:00
|
|
|
};
|