bsnes/higan/sfc/coprocessor/icd/interface.cpp

87 lines
1.9 KiB
C++
Raw Normal View History

Update to v106r08 release. byuu says: Changelog: - Game Boy: fixed RAM/RTC saving¹ - Super Famicom: ICD2 renamed to ICD (there exists an SGB prototype with a functionally identical ICD1) - Sufami Turbo: removed short-circuiting when loading an unlinkable cartridge into slot A² - Super Game Boy: the 20971520hz clock of the SGB2 is now emulated - Super Famicom: BSC-1Lxx (SA1) boards now prompt for BS memory cartridges; and can make use of them³ - Super Famicom: fixed a potential for out-of-bounds reads with BS Memory flash carts ¹: I'm using a gross hack of replacing `type: ` with `type:` so that `memory(type=...)` will match without the extra spaces. I need to think about whether I want the BPath query syntax to strip whitespace or not. But longer term, I want to finalize game/memory's design, and build a higan/emulation/manifest parser that produces a nicer interface to reading manifests for all cores, which will make this irrelevant for higan anyway. ²: I don't think it's appropriate for higan to enforce this. Nothing stops you from inserting games that can't be linked into a real Sufami Turbo. I do short-circuit if you cancel the first load, but I may allow loading an empty slot A with a populated slot B. I think the BIOS does something when you do that. Probably just yells at you. ³: I know it's emulated correctly now, but I still don't know what the heck changes when you load the SD Gundam G Next - Unit & Map Collection BS Memory cartridge with SD Gundam G Next to actually test it.
2018-02-21 09:53:49 +00:00
auto ICD::lcdScanline() -> void {
if(GameBoy::ppu.status.ly > 143) return; //Vblank
if((GameBoy::ppu.status.ly & 7) == 0) {
writeBank = (writeBank + 1) & 3;
writeAddress = 0;
}
}
Update to v106r08 release. byuu says: Changelog: - Game Boy: fixed RAM/RTC saving¹ - Super Famicom: ICD2 renamed to ICD (there exists an SGB prototype with a functionally identical ICD1) - Sufami Turbo: removed short-circuiting when loading an unlinkable cartridge into slot A² - Super Game Boy: the 20971520hz clock of the SGB2 is now emulated - Super Famicom: BSC-1Lxx (SA1) boards now prompt for BS memory cartridges; and can make use of them³ - Super Famicom: fixed a potential for out-of-bounds reads with BS Memory flash carts ¹: I'm using a gross hack of replacing `type: ` with `type:` so that `memory(type=...)` will match without the extra spaces. I need to think about whether I want the BPath query syntax to strip whitespace or not. But longer term, I want to finalize game/memory's design, and build a higan/emulation/manifest parser that produces a nicer interface to reading manifests for all cores, which will make this irrelevant for higan anyway. ²: I don't think it's appropriate for higan to enforce this. Nothing stops you from inserting games that can't be linked into a real Sufami Turbo. I do short-circuit if you cancel the first load, but I may allow loading an empty slot A with a populated slot B. I think the BIOS does something when you do that. Probably just yells at you. ³: I know it's emulated correctly now, but I still don't know what the heck changes when you load the SD Gundam G Next - Unit & Map Collection BS Memory cartridge with SD Gundam G Next to actually test it.
2018-02-21 09:53:49 +00:00
auto ICD::lcdOutput(uint2 color) -> void {
uint y = writeAddress / 160;
uint x = writeAddress % 160;
uint addr = writeBank * 512 + y * 2 + x / 8 * 16;
output[addr + 0] = (output[addr + 0] << 1) | (bool)(color & 1);
output[addr + 1] = (output[addr + 1] << 1) | (bool)(color & 2);
writeAddress = (writeAddress + 1) % 1280;
}
Update to v106r08 release. byuu says: Changelog: - Game Boy: fixed RAM/RTC saving¹ - Super Famicom: ICD2 renamed to ICD (there exists an SGB prototype with a functionally identical ICD1) - Sufami Turbo: removed short-circuiting when loading an unlinkable cartridge into slot A² - Super Game Boy: the 20971520hz clock of the SGB2 is now emulated - Super Famicom: BSC-1Lxx (SA1) boards now prompt for BS memory cartridges; and can make use of them³ - Super Famicom: fixed a potential for out-of-bounds reads with BS Memory flash carts ¹: I'm using a gross hack of replacing `type: ` with `type:` so that `memory(type=...)` will match without the extra spaces. I need to think about whether I want the BPath query syntax to strip whitespace or not. But longer term, I want to finalize game/memory's design, and build a higan/emulation/manifest parser that produces a nicer interface to reading manifests for all cores, which will make this irrelevant for higan anyway. ²: I don't think it's appropriate for higan to enforce this. Nothing stops you from inserting games that can't be linked into a real Sufami Turbo. I do short-circuit if you cancel the first load, but I may allow loading an empty slot A with a populated slot B. I think the BIOS does something when you do that. Probably just yells at you. ³: I know it's emulated correctly now, but I still don't know what the heck changes when you load the SD Gundam G Next - Unit & Map Collection BS Memory cartridge with SD Gundam G Next to actually test it.
2018-02-21 09:53:49 +00:00
auto ICD::joypWrite(bool p15, bool p14) -> void {
//joypad handling
if(p15 == 1 && p14 == 1) {
if(joyp15Lock == 0 && joyp14Lock == 0) {
joyp15Lock = 1;
joyp14Lock = 1;
joypID = (joypID + 1) & 3;
}
}
if(p15 == 0 && p14 == 1) joyp15Lock = 0;
if(p15 == 1 && p14 == 0) joyp14Lock = 0;
//packet handling
if(p15 == 0 && p14 == 0) { //pulse
pulseLock = false;
packetOffset = 0;
bitOffset = 0;
strobeLock = true;
packetLock = false;
return;
}
if(pulseLock) return;
if(p15 == 1 && p14 == 1) {
strobeLock = false;
return;
}
if(strobeLock) {
if(p15 == 1 || p14 == 1) { //malformed packet
packetLock = false;
pulseLock = true;
bitOffset = 0;
packetOffset = 0;
} else {
return;
}
}
//p15:1, p14:0 = 0
//p15:0, p14:1 = 1
bool bit = (p15 == 0);
strobeLock = true;
if(packetLock) {
if(p15 == 1 && p14 == 0) {
if((joypPacket[0] >> 3) == 0x11) {
mltReq = joypPacket[1] & 3;
if(mltReq == 2) mltReq = 3;
joypID = 0;
}
if(packetSize < 64) packet[packetSize++] = joypPacket;
packetLock = false;
pulseLock = true;
}
return;
}
bitData = (bit << 7) | (bitData >> 1);
if(++bitOffset < 8) return;
bitOffset = 0;
joypPacket[packetOffset] = bitData;
if(++packetOffset < 16) return;
packetLock = true;
}