From 61a26b18989f44da3a245939166eaae5a1429511 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:39:57 -0800 Subject: midway/omegrace.cpp: Replaced input lookup table with encoder function. (#10728) --- src/mame/midway/omegrace.cpp | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/src/mame/midway/omegrace.cpp b/src/mame/midway/omegrace.cpp index 717eabbf8f1..7ddbf472028 100644 --- a/src/mame/midway/omegrace.cpp +++ b/src/mame/midway/omegrace.cpp @@ -109,8 +109,7 @@ 15 I encoder 1 (d7-d2) - The encoder is a 64 position Grey Code encoder, or a - pot and A to D converter. + The encoder is a 64 position Gray code encoder. Unlike the quadrature inputs on Atari and Sega games, Omega Race's controller is an absolute angle. @@ -126,8 +125,7 @@ 16 I encoder 2 (d5-d0) - The inputs aren't scrambled as they are on the 1 player - encoder + The encoder is a 64 position Gray code encoder. 17 I DIP SW C6 (coin/cocktail settings) @@ -269,6 +267,7 @@ private: TIMER_CALLBACK_MEMBER(periodic_int); uint8_t vg_go_r(); + static constexpr uint8_t encode_spinner(uint8_t data); uint8_t spinner1_r(); uint8_t spinner2_r(); void outputs_w(uint8_t data); @@ -327,38 +326,20 @@ uint8_t omegrace_state::vg_go_r() * *************************************/ -/* - * Encoder bit mappings - * The encoder is a 64 way switch, with the inputs scrambled - * on the input port (and shifted 2 bits to the left for the - * 1 player encoder) - * - * 3 6 5 4 7 2 for encoder 1 (shifted two bits left..) - * - * 1 4 3 2 5 0 for encoder 2 (not shifted..) - */ - -static const uint8_t spinnerTable[64] = +constexpr uint8_t omegrace_state::encode_spinner(uint8_t data) { - 0x00, 0x01, 0x05, 0x04, 0x06, 0x07, 0x17, 0x16, - 0x14, 0x15, 0x11, 0x10, 0x12, 0x13, 0x1b, 0x1a, - 0x18, 0x19, 0x1d, 0x1c, 0x1e, 0x1f, 0x3f, 0x3e, - 0x3c, 0x3d, 0x39, 0x38, 0x3a, 0x3b, 0x33, 0x32, - 0x30, 0x31, 0x35, 0x34, 0x36, 0x37, 0x27, 0x26, - 0x24, 0x25, 0x21, 0x20, 0x22, 0x23, 0x2b, 0x2a, - 0x28, 0x29, 0x2d, 0x2c, 0x2e, 0x2f, 0x0f, 0x0e, - 0x0c, 0x0d, 0x09, 0x08, 0x0a, 0x0b, 0x03, 0x02 -}; - + data &= 0x3f; + return data ^ (data >> 1) ^ 0x3f; // Inverted 6-bit Gray code +} uint8_t omegrace_state::spinner1_r() { - return spinnerTable[m_spinner[0]->read() & 0x3f] << 2; + return encode_spinner(m_spinner[0]->read()) << 2; } uint8_t omegrace_state::spinner2_r() { - return spinnerTable[m_spinner[1]->read() & 0x3f]; + return encode_spinner(m_spinner[1]->read()); } -- cgit v1.2.3