Previous 15994 Revisions Next

r14325 Friday 3rd February, 2012 at 07:22:39 UTC by Miodrag Milanović
-lynx: cartslot changed to mandatory (real lynx will not power on without a game inserted) [Huygens]
moved sign detection back outside multiply function.
added sign flag updating on write to LSB of MATH_CD register.
[src/mess/machine]lynx.c

src/mess/machine/lynx.c
r14324r14325
882882    Accumulate  JKLM
883883    */
884884   state->m_suzy.accumulate_overflow = FALSE;
885   
886   if (state->m_suzy.signed_math)
887   {
888      UINT16 factor, temp;
889      factor = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8);
890      if ((factor - 1) & 0x8000)      /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
891      {
892         temp = (factor ^ 0xffff) + 1;
893         state->m_sign_AB = - 1;
894         state->m_suzy.data[MATH_B] = temp & 0xff;
895         state->m_suzy.data[MATH_A] = temp >> 8;
896      }
897      else
898         state->m_sign_AB = 1;
899         
900      factor = state->m_suzy.data[MATH_D] | (state->m_suzy.data[MATH_C] << 8);
901      if ((factor - 1) & 0x8000)      /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
902      {
903         temp = (factor ^ 0xffff) + 1;
904         state->m_sign_CD = - 1;
905         state->m_suzy.data[MATH_D] = temp & 0xff;
906         state->m_suzy.data[MATH_C] = temp >> 8;
907      }
908      else
909         state->m_sign_CD = 1;
910   }
911885
912886   left = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8);
913887   right = state->m_suzy.data[MATH_D] | (state->m_suzy.data[MATH_C] << 8);
r14324r14325
12291203      case MATH_M:
12301204         state->m_suzy.accumulate_overflow = FALSE;
12311205         break;
1206      case MATH_C:
1207         /* If we are going to perform a signed multiplication, we store the sign and convert the number
1208            to an unsigned one */
1209         if (state->m_suzy.signed_math)
1210         {
1211            UINT16 factor, temp;
1212            factor = state->m_suzy.data[MATH_D] | (state->m_suzy.data[MATH_C] << 8);
1213            if ((factor - 1) & 0x8000)      /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
1214            {
1215               temp = (factor ^ 0xffff) + 1;
1216               state->m_sign_CD = - 1;
1217               state->m_suzy.data[MATH_D] = temp & 0xff;
1218               state->m_suzy.data[MATH_C] = temp >> 8;
1219            }
1220            else
1221               state->m_sign_CD = 1;
1222         }
1223         break;
1224      case MATH_D:
1225      /* Documentation states that writing to the MATH_D will set MATH_C to zero but not update the sign flag.
1226      Implementing the sign detection as described in the documentation causes Stun Runners to not work.
1227      Either the sign error in the docs is not as described or writing to the lower byte does update the sign flag.
1228      Here I assume the sign flag gets updated. */
1229         if (data)
1230            state->m_sign_CD = 1;
1231         break;
12321232      /* Writing to A will start a 16 bit multiply */
12331233      /* If we are going to perform a signed multiplication, we also store the sign and convert the
12341234        number to an unsigned one */
12351235      case MATH_A:
1236         if (state->m_suzy.signed_math)
1237         {
1238            UINT16 factor, temp;
1239            factor = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8);
1240            if ((factor - 1) & 0x8000)      /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
1241            {
1242               temp = (factor ^ 0xffff) + 1;
1243               state->m_sign_AB = - 1;
1244               state->m_suzy.data[MATH_B] = temp & 0xff;
1245               state->m_suzy.data[MATH_A] = temp >> 8;
1246            }
1247            else
1248               state->m_sign_AB = 1;
1249         }
12361250         lynx_multiply(state);
12371251         break;
12381252      /* Writing to E will start a 16 bit divide */
r14324r14325
19321946   state->m_mikey.data[0x90] = 0x00;
19331947   state->m_mikey.data[0x92] = 0x00;
19341948
1935/*
1936    state->m_suzy.data[MATH_A] = 0xff;
1937    state->m_suzy.data[MATH_B] = 0xff;
1938    state->m_suzy.data[MATH_C] = 0xff;
1939    state->m_suzy.data[MATH_D] = 0xff;
1940
1941    state->m_suzy.data[MATH_E] = 0xff;
1942    state->m_suzy.data[MATH_F] = 0xff;
1943    state->m_suzy.data[MATH_G] = 0xff;
1944    state->m_suzy.data[MATH_H] = 0xff;
1945
1946    state->m_suzy.data[MATH_J] = 0xff;
1947    state->m_suzy.data[MATH_K] = 0xff;
1948    state->m_suzy.data[MATH_L] = 0xff;
1949    state->m_suzy.data[MATH_M] = 0xff;
1950    state->m_suzy.data[MATH_P] = 0xff;
1951*/
1952
19531949   lynx_uart_reset(state);
19541950
19551951   // hack to allow current object loading to work
r14324r14325
21312127MACHINE_CONFIG_FRAGMENT(lynx_cartslot)
21322128   MCFG_CARTSLOT_ADD("cart")
21332129   MCFG_CARTSLOT_EXTENSION_LIST("lnx,lyx")
2134   MCFG_CARTSLOT_NOT_MANDATORY
2130   MCFG_CARTSLOT_MANDATORY
21352131   MCFG_CARTSLOT_INTERFACE("lynx_cart")
21362132   MCFG_CARTSLOT_LOAD(lynx_cart)
21372133   MCFG_CARTSLOT_PARTIALHASH(lynx_partialhash)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team