Created
December 25, 2013 05:58
-
-
Save brook2/8120544 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_link1/src/gb/cpu/mmio.cpp | |
--- higan_v093r11_sockpair/src/gb/cpu/mmio.cpp 2013-12-24 06:22:02.000000000 +0000 | |
+++ higan_v093r11_link1/src/gb/cpu/mmio.cpp 2013-12-25 04:58:08.783658144 +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 | |
diff -x higan -x '*.so' -x '*~' -x '*.o' -uNr higan_v093r11_sockpair/src/gb/cpu/timing.cpp higan_v093r11_link1/src/gb/cpu/timing.cpp | |
--- higan_v093r11_sockpair/src/gb/cpu/timing.cpp 2013-12-24 08:34:43.862134958 +0000 | |
+++ higan_v093r11_link1/src/gb/cpu/timing.cpp 2013-12-25 05:05:13.383674277 +0000 | |
@@ -69,11 +69,67 @@ | |
void CPU::timer_8192hz() { | |
if(status.serial_transfer && status.serial_clock) { | |
+ // internal clock | |
+ | |
+ int highest_bit = 0x80 & status.serial_data; | |
+ | |
+ char bit[2]; | |
+ if(highest_bit) bit[0] = '1'; | |
+ else bit[0] = '0'; | |
+ bit[1] = 0; | |
+ | |
+ write(sockSIO, bit, 1); | |
+ printf("socket %d w i: %s\n", sockSIO, bit); | |
+ | |
+ status.serial_data = status.serial_data << 1; | |
+ | |
+ char buf[2]; | |
+ buf[0] = '?'; | |
+ buf[1] = 0; | |
+ if(1 == recv(sockSIO, buf, 1, MSG_WAITALL)) { | |
+ printf("socket %d r i: %s\n", sockSIO, buf); | |
+ if(buf[0] == '1') status.serial_data |= 1; | |
+ } | |
+ | |
if(--status.serial_bits == 0) { | |
+ printf("i ! 0x%.2x\n", status.serial_data); | |
+ | |
status.serial_transfer = 0; | |
interrupt_raise(Interrupt::Serial); | |
} | |
} | |
+ else if(status.serial_transfer && !status.serial_clock) { | |
+ // external clock/recieve wait status | |
+ | |
+ // wait for SCK pulse | |
+ | |
+ char buf[2]; | |
+ buf[0] = '?'; | |
+ buf[1] = 0; | |
+ if(1 == recv(sockSIO, buf, 1, MSG_DONTWAIT)) { | |
+ printf("socket %d r e: %s\n", sockSIO, buf); | |
+ | |
+ int highest_bit = 0x80 & status.serial_data; | |
+ | |
+ char bit[2]; | |
+ if(highest_bit) bit[0] = '1'; | |
+ else bit[0] = '0'; | |
+ bit[1] = 0; | |
+ | |
+ write(sockSIO, bit, 1); | |
+ printf("socket %d w e: %s\n", sockSIO, bit); | |
+ | |
+ status.serial_data <<= 1; | |
+ if(buf[0] == '1') status.serial_data |= 1; | |
+ | |
+ if(--status.serial_bits == 0) { | |
+ printf("e ! 0x%.2x\n", status.serial_data); | |
+ | |
+ status.serial_transfer = 0; | |
+ interrupt_raise(Interrupt::Serial); | |
+ } | |
+ } | |
+ } | |
} | |
void CPU::timer_4096hz() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment