Made some progress. Car seems to not go wonky after crashing in Hard Drivin's Airborne with this code and i can drive around untill the timer runs out and the wheels seem to stay straight I've not tested it too much as in crashing with the wheel held all the way around to the left or the right because thats not how i play or anyone else i think? Been keeping my regular play style and if i forget to let go of the wheel when i crash theres a offset applied to the new_wheel output that keeps the centre point lined up with what the game is doing.
Original wheel edge bit latch code from harddriv_m.cpp here
And this is the modification i made for Hard Drivin's Airborne to work better and stop going out of alignment so much.
Seems to work fine in Street Drivin' too but that didn't have a wheel alignment issue after the last patch i did on it anyway and it doesn't set wheel edge to 0 when you crash so not a issue there or in any of the other ones really. This code might not play well with the compact versions because of how they do the wheel alignment I think you can just skip the wheel calibration setup and it should work anyway I applied a overclock in the source code for my own version of mame I'm testing and got the frame rate way higher in every one of them because i exceed the 400% limit on the GSP.
I made a dip switch that can toggle between 6 or 7 different types of wheel/sensitivity. I have my Logitech G923 wheel dialled in on it but not tidied the code up or labelled them appropriately yet i'll finish doing that later today or tomorrow after some sleep.
Original wheel edge bit latch code from harddriv_m.cpp here
Code: [Select]
uint16_t harddriv_state::hdc68k_wheel_r()
{
/* grab the new wheel value */
uint16_t new_wheel = m_12badc[0].read_safe(0xffff);
/* hack to display the wheel position */
if (machine().input().code_pressed(KEYCODE_LSHIFT))
popmessage("%04X", new_wheel);
/* if we crossed the center line, latch the edge bit */
if ((m_hdc68k_last_wheel / 0xf00) != (new_wheel / 0xf00))
m_hdc68k_wheel_edge = 1;
/* remember the last value and return the low 8 bits */
m_hdc68k_last_wheel = new_wheel;
return (new_wheel << 8) | 0xff;
}
And this is the modification i made for Hard Drivin's Airborne to work better and stop going out of alignment so much.
Code: [Select]
uint16_t harddriv_state::hdc68k_wheel_r()
{
static const uint16_t g_latchpoint = 0x8000; // Central point for wheel detection.
static int16_t wheel_offset = 0; // Cumulative offset to adjust the wheel position based on game events.
static bool last_wheel_edge = false; // To track the last state of crossing the center.
// Read the current wheel position from the 12-bit ADC port.
uint16_t new_wheel_raw = m_12badc[0].read_safe(0xffff) << 4;
// Apply the cumulative offset to align with the game's perceived center.
uint16_t new_wheel = new_wheel_raw + wheel_offset;
// Edge detection logic to detect being at or crossing the center point using raw ADC data.
if ((m_hdc68k_last_wheel < g_latchpoint && new_wheel_raw >= g_latchpoint) ||
(m_hdc68k_last_wheel > g_latchpoint && new_wheel_raw <= g_latchpoint) ||
new_wheel_raw == g_latchpoint) {
m_hdc68k_wheel_edge = 1; // Set edge flag when at or crossing the center based on raw input.
}
// Check if the wheel edge flag has changed from 1 to 0, as reset by the game.
if (last_wheel_edge && !m_hdc68k_wheel_edge) {
// Calculate the offset adjustment when the wheel is recalibrated.
int16_t new_offset_adjustment = g_latchpoint - new_wheel_raw;
// Apply the adjustment based on the current wheel position relative to the center
if (new_wheel_raw > g_latchpoint) {
// Wheel is to the left, need to decrease raw value towards the center
wheel_offset += abs(new_offset_adjustment); // Use addition to adjust back towards the center
} else {
// Wheel is to the right, need to increase raw value towards the center
wheel_offset -= abs(new_offset_adjustment); // Use subtraction if below the center
}
new_wheel = new_wheel_raw + wheel_offset; // Reapply the updated offset.
}
last_wheel_edge = m_hdc68k_wheel_edge; // Store the last known state of the wheel edge flag.
// Display current wheel information for debugging.
popmessage("Wheel Raw: %04X, Wheel Adjusted: %04X, Edge: %d, Offset: %X",
new_wheel_raw, new_wheel, m_hdc68k_wheel_edge, wheel_offset);
// Store the current wheel value for the next comparison.
m_hdc68k_last_wheel = new_wheel_raw; // Update last_wheel to the raw value to ensure proper comparison next cycle.
// Return the processed wheel value, formatted as required.
return (new_wheel << 4) | 0xff;
}
Seems to work fine in Street Drivin' too but that didn't have a wheel alignment issue after the last patch i did on it anyway and it doesn't set wheel edge to 0 when you crash so not a issue there or in any of the other ones really. This code might not play well with the compact versions because of how they do the wheel alignment I think you can just skip the wheel calibration setup and it should work anyway I applied a overclock in the source code for my own version of mame I'm testing and got the frame rate way higher in every one of them because i exceed the 400% limit on the GSP.
I made a dip switch that can toggle between 6 or 7 different types of wheel/sensitivity. I have my Logitech G923 wheel dialled in on it but not tidied the code up or labelled them appropriately yet i'll finish doing that later today or tomorrow after some sleep.