diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs index 16a6dfda18..cfb9ea5858 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs @@ -521,29 +521,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_access_write = false; VRAM_access_read = false; VRAM_access_write = false; + rendering_complete = false; } } - else + else if (!rendering_complete) { - if (cycle >= 85) + if (cycle == 85) { - if (cycle == 85) - { - // x-scroll is expected to be latched one cycle later - // this is fine since nothing has started in the rendering until the second cycle - // calculate the column number of the tile to start with - x_tile = scroll_x >> 3; - render_offset = scroll_x % 8; - } - - // render the screen and handle hblank - render(cycle - 85); + // x-scroll is expected to be latched one cycle later + // this is fine since nothing has started in the rendering until the second cycle + // calculate the column number of the tile to start with + x_tile = scroll_x >> 3; + render_offset = scroll_x % 8; } + + // render the screen and handle hblank + render(cycle - 85); } } else { - if (cycle <= 80) + if (cycle < 83) { if (cycle == 2) { @@ -571,14 +569,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { OAM_access_read = false; OAM_access_write = true; + rendering_complete = false; } - else + else if (cycle < 80) { // here OAM scanning is performed OAM_scan(cycle); } } - else if (cycle >= 83) + else if (!rendering_complete) { if (cycle == 84) { @@ -1226,7 +1225,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk read_case--; break; case 18: - // end of rendering + rendering_complete = true; break; } internal_cycle++; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs index 7db05adfd3..98c53b2b7a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -517,29 +517,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_access_write = false; VRAM_access_read = false; VRAM_access_write = false; + rendering_complete = false; } } - else + else if (!rendering_complete) { - if (cycle >= 85) + if (cycle == 85) { - if (cycle == 85) - { - // x-scroll is expected to be latched one cycle later - // this is fine since nothing has started in the rendering until the second cycle - // calculate the column number of the tile to start with - x_tile = scroll_x >> 3; - render_offset = scroll_x % 8; - } - - // render the screen and handle hblank - render(cycle - 85); + // x-scroll is expected to be latched one cycle later + // this is fine since nothing has started in the rendering until the second cycle + // calculate the column number of the tile to start with + x_tile = scroll_x >> 3; + render_offset = scroll_x % 8; } + + // render the screen and handle hblank + render(cycle - 85); } } else { - if (cycle <= 80) + if (cycle < 83) { if (cycle == 2) { @@ -567,15 +565,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { OAM_access_read = false; OAM_access_write = true; - VRAM_access_read = false; + + rendering_complete = false; } - else + else if (cycle < 80) { // here OAM scanning is performed OAM_scan(cycle); } } - else if (cycle >= 83) + else if (!rendering_complete) { if (cycle == 84) { @@ -584,6 +583,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_INT = false; OAM_access_write = false; VRAM_access_write = false; + VRAM_access_read = false; // x-scroll is expected to be latched one cycle later // this is fine since nothing has started in the rendering until the second cycle @@ -1194,7 +1194,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk read_case--; break; case 18: - // end of rendering + rendering_complete = true; break; } internal_cycle++; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index 19fb7de978..ebd77f4cf9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { for (int i = 0; i < 70224; i++) { - // These things do not change speed in GBC double spped mode + // These things do not change speed in GBC double speed mode audio.tick(); ppu.tick(); if (Use_MT) { mapper.Mapper_Tick(); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs index e4131f7a7c..e8463572be 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs @@ -292,29 +292,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_access_write = false; VRAM_access_read = false; VRAM_access_write = false; + rendering_complete = false; } } - else + else if (!rendering_complete) { - if (cycle >= 85) + if (cycle == 85) { - if (cycle == 85) - { - // x-scroll is expected to be latched one cycle later - // this is fine since nothing has started in the rendering until the second cycle - // calculate the column number of the tile to start with - x_tile = scroll_x >> 3; - render_offset = scroll_x % 8; - } - - // render the screen and handle hblank - render(cycle - 85); + // x-scroll is expected to be latched one cycle later + // this is fine since nothing has started in the rendering until the second cycle + // calculate the column number of the tile to start with + x_tile = scroll_x >> 3; + render_offset = scroll_x % 8; } + + // render the screen and handle hblank + render(cycle - 85); } } else { - if (cycle <= 80) + if (cycle < 83) { if (cycle == 2) { @@ -345,14 +343,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_access_read = false; OAM_access_write = true; VRAM_access_read = false; + rendering_complete = false; } - else + else if (cycle < 80) { // here OAM scanning is performed OAM_scan(cycle); } } - else if (cycle >= 83) + else if (!rendering_complete) { if (cycle == 84) { @@ -910,7 +909,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk read_case--; break; case 18: - // end of rendering + rendering_complete = true; break; } internal_cycle++; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs index d68782760b..cd4a5141cb 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs @@ -376,7 +376,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (addr >= 0xA000 && addr < 0xC000 && is_GBC) { // on GBC only, cart is accessible during DMA - return mapper.ReadMemoryHigh(addr); + return mapper.PeekMemoryHigh(addr); } if (addr >= 0xE000 && addr < 0xF000) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs index 5e87cf003e..01caa637b2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -16,6 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // TODO: need a test ROM for the details here public byte bus_return; + public bool rendering_complete; // register variables public byte LCDC; @@ -179,6 +180,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk ser.Sync(nameof(HDMA_active), ref HDMA_active); ser.Sync(nameof(clear_screen), ref clear_screen); ser.Sync(nameof(bus_return), ref bus_return); + ser.Sync(nameof(rendering_complete), ref rendering_complete); ser.Sync(nameof(LCDC), ref LCDC); ser.Sync(nameof(STAT), ref STAT); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs index ba2dd399ad..d65d562a00 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs @@ -9,7 +9,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public byte serial_control; public byte serial_data; - public bool serial_start; public bool can_pulse; public int serial_clock; public int serial_bits; @@ -39,65 +38,40 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk break; case 0xFF02: - if (((value & 0x80) > 0) && !serial_start) + if ((value & 0x1) == 1) { - serial_start = true; serial_bits = 8; - if ((value & 1) > 0) - { - if (((value & 2) > 0) && Core.GBC_compat) - { - clk_rate = 16; - serial_clock = (16 - (int)(Core.cpu.TotalExecutedCycles % 8)) + 1; - } - else - { - clk_rate = 512; - serial_clock = 512 - (int)(Core.cpu.TotalExecutedCycles % 256) + 1; - // there seems to be some clock inverting happening on some transfers - // not sure of the exact nature of it, here is one methor that gives correct result on one test rom but not others - /* - if (Core._syncSettings.GBACGB && Core.is_GBC) + if (((value & 2) > 0) && Core.GBC_compat) + { + clk_rate = 16; + serial_clock = (16 - (int)(Core.cpu.TotalExecutedCycles % 8)) + 1; + } + else + { + clk_rate = 512; + serial_clock = 512 - (int)(Core.cpu.TotalExecutedCycles % 256) + 1; + + // there seems to be some clock inverting happening on some transfers + // not sure of the exact nature of it, here is one methor that gives correct result on one test rom but not others + /* + if (Core._syncSettings.GBACGB && Core.is_GBC) + { + if ((Core.TotalExecutedCycles % 256) > 127) { - if ((Core.TotalExecutedCycles % 256) > 127) - { - serial_clock = (8 - (int)(Core.cpu.TotalExecutedCycles % 8)) + 1; - } + serial_clock = (8 - (int)(Core.cpu.TotalExecutedCycles % 8)) + 1; } - */ } - can_pulse = true; - } - else - { - clk_rate = -1; - serial_clock = clk_rate; - can_pulse = false; + */ } + can_pulse = true; } - else if (serial_start) + else { - if ((value & 1) > 0) - { - if (((value & 2) > 0) && Core.GBC_compat) - { - clk_rate = 16; - serial_clock = (16 - (int)(Core.cpu.TotalExecutedCycles % 8)) + 1; - } - else - { - clk_rate = 512; - serial_clock = 512 - (int)(Core.cpu.TotalExecutedCycles % 256) + 1; - } - can_pulse = true; - } - else - { - clk_rate = -1; - serial_clock = clk_rate; - can_pulse = false; - } + serial_bits = 8; + clk_rate = -1; + serial_clock = clk_rate; + can_pulse = false; } if (Core.GBC_compat) @@ -116,9 +90,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void serial_transfer_tick() { - if (serial_start) - { - if (serial_clock > 0) { serial_clock--; } + if (serial_clock > 0) + { + serial_clock--; if (serial_clock == 0) { @@ -131,7 +105,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (serial_bits == 0) { serial_control &= 0x7F; - serial_start = false; if (Core.REG_FFFF.Bit(3)) { Core.cpu.FlagI = true; } Core.REG_FF0F |= 0x08; @@ -150,10 +123,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { serial_control = 0x7E; serial_data = 0x00; - serial_start = false; - serial_clock = 0; - serial_bits = 0; - clk_rate = 16; + serial_clock = -1; + serial_bits = 8; + clk_rate = -1; going_out = 0; coming_in = 1; can_pulse = false; @@ -163,7 +135,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { ser.Sync(nameof(serial_control), ref serial_control); ser.Sync(nameof(serial_data), ref serial_data); - ser.Sync(nameof(serial_start), ref serial_start); ser.Sync(nameof(serial_clock), ref serial_clock); ser.Sync(nameof(serial_bits), ref serial_bits); ser.Sync(nameof(clk_rate), ref clk_rate); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs index 0992d34048..3cbbbf3958 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs @@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); - if ((R.serialport.clk_rate == -1) && R.serialport.serial_start && L.serialport.can_pulse) + if ((R.serialport.clk_rate == -1) && L.serialport.can_pulse) { R.serialport.serial_clock = L.serialport.serial_clock; R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); @@ -126,7 +126,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); - if ((L.serialport.clk_rate == -1) && L.serialport.serial_start && R.serialport.can_pulse) + if ((L.serialport.clk_rate == -1) && R.serialport.can_pulse) { L.serialport.serial_clock = R.serialport.serial_clock; L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs index f39a0071b2..27368a6f28 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs @@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start && L.serialport.can_pulse) + if ((C.serialport.clk_rate == -1) && L.serialport.can_pulse) { C.serialport.serial_clock = L.serialport.serial_clock; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -165,7 +165,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); - if ((L.serialport.clk_rate == -1) && L.serialport.serial_start && C.serialport.can_pulse) + if ((L.serialport.clk_rate == -1) && C.serialport.can_pulse) { L.serialport.serial_clock = C.serialport.serial_clock; L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); @@ -216,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); - if ((R.serialport.clk_rate == -1) && R.serialport.serial_start && C.serialport.can_pulse) + if ((R.serialport.clk_rate == -1) && C.serialport.can_pulse) { R.serialport.serial_clock = C.serialport.serial_clock; R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); @@ -232,7 +232,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start && R.serialport.can_pulse) + if ((C.serialport.clk_rate == -1) && R.serialport.can_pulse) { C.serialport.serial_clock = R.serialport.serial_clock; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -283,7 +283,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); - if ((L.serialport.clk_rate == -1) && L.serialport.serial_start && R.serialport.can_pulse) + if ((L.serialport.clk_rate == -1) && R.serialport.can_pulse) { L.serialport.serial_clock = R.serialport.serial_clock; L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); @@ -299,7 +299,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x L.serialport.going_out = (byte)(L.serialport.serial_data >> 7); - if ((R.serialport.clk_rate == -1) && R.serialport.serial_start && L.serialport.can_pulse) + if ((R.serialport.clk_rate == -1) && L.serialport.can_pulse) { R.serialport.serial_clock = L.serialport.serial_clock; R.serialport.going_out = (byte)(R.serialport.serial_data >> 7); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs index b4566001dc..a0b43dca89 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs @@ -1,5 +1,5 @@ using System; - +using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x @@ -169,6 +169,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x return true; } + // NOTE: this is HLE only and should be replaced eventually. It relies on information that a physical adapter does not have to sync transfers. + // I think the adapter can see the high bit of each tranfer byte on its port, so is probably using that for syncing. + // But, the details aren't known. public void do_frame_4x() { // advance one full frame @@ -262,21 +265,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else { - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start) + if ((A.serialport.clk_rate == -1) && A.serialport.serial_control.Bit(7)) { ready_to_transmit = true; if ((status_byte & 0x20) == 0x20) { - if (!((B.serialport.clk_rate == -1) && B.serialport.serial_start)) { ready_to_transmit = false; } + if (!((B.serialport.clk_rate == -1) && B.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } if ((status_byte & 0x40) == 0x40) { - if (!((C.serialport.clk_rate == -1) && C.serialport.serial_start)) { ready_to_transmit = false; } + if (!((C.serialport.clk_rate == -1) && C.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } if ((status_byte & 0x80) == 0x80) { - if (!((D.serialport.clk_rate == -1) && D.serialport.serial_start)) { ready_to_transmit = false; } + if (!((D.serialport.clk_rate == -1) && D.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } } @@ -297,7 +300,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x // first byte sent is 0xFE if (ping_player == 1) { - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start) + if ((A.serialport.clk_rate == -1) && A.serialport.serial_control.Bit(7)) { A.serialport.serial_clock = 1; A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); @@ -308,7 +311,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else if (ping_player == 2) { - if ((B.serialport.clk_rate == -1) && B.serialport.serial_start) + if ((B.serialport.clk_rate == -1) && B.serialport.serial_control.Bit(7)) { B.serialport.serial_clock = 1; B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); @@ -319,7 +322,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else if (ping_player == 3) { - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start) + if ((C.serialport.clk_rate == -1) && C.serialport.serial_control.Bit(7)) { C.serialport.serial_clock = 1; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -330,7 +333,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else { - if ((D.serialport.clk_rate == -1) && D.serialport.serial_start) + if ((D.serialport.clk_rate == -1) && D.serialport.serial_control.Bit(7)) { D.serialport.serial_clock = 1; D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); @@ -367,7 +370,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x // the next 3 bytes are the status byte (which may be updated in between each transfer) if (ping_player == 1) { - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start) + if ((A.serialport.clk_rate == -1) && A.serialport.serial_control.Bit(7)) { A.serialport.serial_clock = 1; A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); @@ -378,7 +381,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else if (ping_player == 2) { - if ((B.serialport.clk_rate == -1) && B.serialport.serial_start) + if ((B.serialport.clk_rate == -1) && B.serialport.serial_control.Bit(7)) { B.serialport.serial_clock = 1; B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); @@ -389,7 +392,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else if (ping_player == 3) { - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start) + if ((C.serialport.clk_rate == -1) && C.serialport.serial_control.Bit(7)) { C.serialport.serial_clock = 1; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -400,7 +403,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else { - if ((D.serialport.clk_rate == -1) && D.serialport.serial_start) + if ((D.serialport.clk_rate == -1) && D.serialport.serial_control.Bit(7)) { D.serialport.serial_clock = 1; D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); @@ -522,21 +525,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } else { - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start) + if ((A.serialport.clk_rate == -1) && A.serialport.serial_control.Bit(7)) { ready_to_transmit = true; if ((status_byte & 0x20) == 0x20) { - if (!((B.serialport.clk_rate == -1) && B.serialport.serial_start)) { ready_to_transmit = false; } + if (!((B.serialport.clk_rate == -1) && B.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } if ((status_byte & 0x40) == 0x40) { - if (!((C.serialport.clk_rate == -1) && C.serialport.serial_start)) { ready_to_transmit = false; } + if (!((C.serialport.clk_rate == -1) && C.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } if ((status_byte & 0x80) == 0x80) { - if (!((D.serialport.clk_rate == -1) && D.serialport.serial_start)) { ready_to_transmit = false; } + if (!((D.serialport.clk_rate == -1) && D.serialport.serial_control.Bit(7))) { ready_to_transmit = false; } } } @@ -671,7 +674,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); - if ((B.serialport.clk_rate == -1) && B.serialport.serial_start && A.serialport.can_pulse) + if ((B.serialport.clk_rate == -1) && A.serialport.can_pulse) { B.serialport.serial_clock = A.serialport.serial_clock; B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); @@ -687,7 +690,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start && B.serialport.can_pulse) + if ((A.serialport.clk_rate == -1) && B.serialport.can_pulse) { A.serialport.serial_clock = B.serialport.serial_clock; A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); @@ -709,7 +712,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); - if ((D.serialport.clk_rate == -1) && D.serialport.serial_start && C.serialport.can_pulse) + if ((D.serialport.clk_rate == -1) && C.serialport.can_pulse) { D.serialport.serial_clock = C.serialport.serial_clock; D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); @@ -725,7 +728,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start && D.serialport.can_pulse) + if ((C.serialport.clk_rate == -1) && D.serialport.can_pulse) { C.serialport.serial_clock = D.serialport.serial_clock; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -749,7 +752,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); - if ((D.serialport.clk_rate == -1) && D.serialport.serial_start && A.serialport.can_pulse) + if ((D.serialport.clk_rate == -1) && A.serialport.can_pulse) { D.serialport.serial_clock = A.serialport.serial_clock; D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); @@ -765,7 +768,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start && D.serialport.can_pulse) + if ((A.serialport.clk_rate == -1) && D.serialport.can_pulse) { A.serialport.serial_clock = D.serialport.serial_clock; A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); @@ -787,7 +790,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start && B.serialport.can_pulse) + if ((C.serialport.clk_rate == -1) && B.serialport.can_pulse) { C.serialport.serial_clock = B.serialport.serial_clock; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -803,7 +806,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); - if ((B.serialport.clk_rate == -1) && B.serialport.serial_start && C.serialport.can_pulse) + if ((B.serialport.clk_rate == -1) && C.serialport.can_pulse) { B.serialport.serial_clock = C.serialport.serial_clock; B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); @@ -827,7 +830,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); - if ((A.serialport.clk_rate == -1) && A.serialport.serial_start && C.serialport.can_pulse) + if ((A.serialport.clk_rate == -1) && C.serialport.can_pulse) { A.serialport.serial_clock = C.serialport.serial_clock; A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); @@ -843,7 +846,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x A.serialport.going_out = (byte)(A.serialport.serial_data >> 7); - if ((C.serialport.clk_rate == -1) && C.serialport.serial_start && A.serialport.can_pulse) + if ((C.serialport.clk_rate == -1) && A.serialport.can_pulse) { C.serialport.serial_clock = A.serialport.serial_clock; C.serialport.going_out = (byte)(C.serialport.serial_data >> 7); @@ -865,7 +868,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { B.serialport.going_out = (byte)(B.serialport.serial_data >> 7); - if ((D.serialport.clk_rate == -1) && D.serialport.serial_start && B.serialport.can_pulse) + if ((D.serialport.clk_rate == -1) && B.serialport.can_pulse) { D.serialport.serial_clock = B.serialport.serial_clock; D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); @@ -881,7 +884,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x D.serialport.going_out = (byte)(D.serialport.serial_data >> 7); - if ((B.serialport.clk_rate == -1) && B.serialport.serial_start && D.serialport.can_pulse) + if ((B.serialport.clk_rate == -1) && D.serialport.can_pulse) { B.serialport.serial_clock = D.serialport.serial_clock; B.serialport.going_out = (byte)(B.serialport.serial_data >> 7);