Closed Yazwh0 closed 1 year ago
You confused me briefly with the old code reference, the current code looks like this:
case 1: // PA
case 15:
i2c_step();
if (!debug) {
via_clear_pra_irqs(&via[0]);
}
if (via[0].registers[11] & 1) {
// CA1 is currently not connected to anything (?)
return 0;
} else {
return (~via[0].registers[3] & i2c_port.data_out) | // I2C Data: PA0=1 if DDR bit is 0 (input) and data_out is 1; usage of data_out and data_in is a bit confusing...
(via[0].registers[3] & i2c_port.data_in) | // I2C Data: PA0=1 if DDR bit is 1 (output) and data_in is 1
(~via[0].registers[3] & I2C_CLK_MASK) | // I2C Clock: PA1=1 if DDR bit is 0 (input), simulating an input pull-up
(via[0].registers[3] & i2c_port.clk_in) | // I2C Clock: PA1=1 if DDR bit is 1 (output) and clk_in is 1, simulating a pin driven by the VIA
Joystick_data;
}
But I agree it appears that it does not respect the direction for joystick data. I assume that means the fix should be to bitwise-AND the Joystick_data with ~via[0].registers[3]
.
The same error appears to occur at https://github.com/commanderx16/x16-emulator/blob/master/src/via.c#L292, so it may be worth filing a bug over there as well.
Already done. https://github.com/commanderx16/x16-emulator/issues/450
Should be fixed by 4871184defd4a01cb28d684ce8cc207b5f099661.
It only looks like it's considered for the I2C bits, not the joystick data.
In via.cpp: