Created
December 25, 2013 05:59
-
-
Save brook2/8120549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -x higan -x '*.so' -x '*~' -x '*.o' -uNr higan_v093r11_sockpair/src/gb/cpu/mmio.cpp higan_v093r11_link3/src/gb/cpu/mmio.cpp | |
--- higan_v093r11_sockpair/src/gb/cpu/mmio.cpp 2013-12-24 06:22:02.000000000 +0000 | |
+++ higan_v093r11_link3/src/gb/cpu/mmio.cpp 2013-12-24 12:13:11.146768329 +0000 | |
@@ -53,12 +53,12 @@ | |
if(interface->tracer.open()) { | |
char buffer[1024]; | |
- sprintf(buffer, "SB R 0x%.2x\n", 0xff); | |
+ sprintf(buffer, "SB R 0x%.2x\n", status.serial_data); | |
interface->tracer.print(buffer); | |
interface->tracer.flush(); | |
} | |
- return 0xff; | |
+ return status.serial_data; | |
} | |
if(addr == 0xff02) { //SC | |
@@ -183,6 +183,11 @@ | |
interface->tracer.flush(); | |
} | |
+ // blocking prohibited writes breaks top ranking tennis even more | |
+ //if(status.serial_transfer) { | |
+ // return; | |
+ //} | |
+ | |
status.serial_data = data; | |
return; | |
} | |
@@ -195,9 +200,26 @@ | |
interface->tracer.flush(); | |
} | |
+ /* | |
+ // if an external timer send was cancelled drain a byte | |
+ if(status.serial_transfer && !(data & 0x80) && !status.serial_clock) { | |
+ unsigned char byte; | |
+ recv(sockSIOopp, &byte, 1, MSG_DONTWAIT); | |
+ } | |
+ /// seems to have no effect | |
+ */ | |
+ | |
status.serial_transfer = data & 0x80; | |
status.serial_clock = data & 0x01; | |
if(status.serial_transfer) status.serial_bits = 8; | |
+ | |
+ // this code makes track and field desync when you roll | |
+ //if(status.serial_transfer) { | |
+ // unsigned char byte; | |
+ // int limit = 1024; | |
+ // while(--limit && 1 == recv(sockSIO, &byte, 1, MSG_DONTWAIT)) {} | |
+ //} | |
+ | |
return; | |
} | |
diff -x higan -x '*.so' -x '*~' -x '*.o' -uNr higan_v093r11_sockpair/src/gb/cpu/timing.cpp higan_v093r11_link3/src/gb/cpu/timing.cpp | |
--- higan_v093r11_sockpair/src/gb/cpu/timing.cpp 2013-12-24 08:34:43.862134958 +0000 | |
+++ higan_v093r11_link3/src/gb/cpu/timing.cpp 2013-12-24 12:21:25.062792131 +0000 | |
@@ -69,10 +69,56 @@ | |
void CPU::timer_8192hz() { | |
if(status.serial_transfer && status.serial_clock) { | |
+ if(status.serial_bits == 8) { | |
+ unsigned char byte; | |
+ | |
+ byte = status.serial_data; | |
+ write(sockSIO, &byte, 1); | |
+ //printf("%d/I sent 0x%.2x\n", sockSIO, byte); | |
+ } | |
+ | |
if(--status.serial_bits == 0) { | |
+ unsigned char byte; | |
+ | |
+ byte = 0; | |
+ if(1 == recv(sockSIO, &byte, 1, MSG_WAITALL)) { // don't understand why this has to block but it made everything work | |
+ //int limit = 1024; | |
+ //while(--limit && 1 == recv(sockSIO, &byte, 1, MSG_DONTWAIT)) {} | |
+ // this draining broke track and field but will SCK fix it? | |
+ | |
+ status.serial_data = byte; | |
+ } | |
+ else { | |
+ //printf("%d/I failed to read\n", sockSIO); | |
+ status.serial_data = 0x00; | |
+ } | |
+ | |
+ status.serial_transfer = 0; | |
+ interrupt_raise(Interrupt::Serial); | |
+ } | |
+ } | |
+ else if(status.serial_transfer && !status.serial_clock) { | |
+ unsigned char byte = 0; | |
+ unsigned char byte2; | |
+ | |
+ if(1 == recv(sockSIO, &byte, 1, MSG_DONTWAIT)) { | |
+ //int limit = 1024; | |
+ //while(--limit && 1 == recv(sockSIO, &byte, 1, MSG_DONTWAIT)) {} | |
+ | |
+ //printf("%d/E got 0x%.2x\n", sockSIO, byte); | |
+ byte2 = status.serial_data; | |
+ status.serial_data = byte; | |
+ | |
+ write(sockSIO, &byte2, 1); | |
+ //printf("%d/E sent 0x%.2x\n", sockSIO, byte); | |
+ | |
+ status.serial_bits = 0; | |
status.serial_transfer = 0; | |
interrupt_raise(Interrupt::Serial); | |
} | |
+ else { | |
+ //printf("%d/E retrying\n", sockSIO); | |
+ } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment