Previous 15994 Revisions Next

r14313 Thursday 2nd February, 2012 at 11:02:17 UTC by Miodrag Milanović
Moved sign conversion code inside multiply function (fixes stunrun) [Huygens]
[src/mess/machine]lynx.c

src/mess/machine/lynx.c
r14312r14313
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   }
885911
886912   left = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8);
887913   right = state->m_suzy.data[MATH_D] | (state->m_suzy.data[MATH_C] << 8);
r14312r14313
12031229      case MATH_M:
12041230         state->m_suzy.accumulate_overflow = FALSE;
12051231         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;
12241232      /* Writing to A will start a 16 bit multiply */
12251233      /* If we are going to perform a signed multiplication, we also store the sign and convert the
12261234        number to an unsigned one */
12271235      case MATH_A:
1228         if (state->m_suzy.signed_math)
1229         {
1230            UINT16 factor, temp;
1231            factor = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8);
1232            if ((factor - 1) & 0x8000)      /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
1233            {
1234               temp = (factor ^ 0xffff) + 1;
1235               state->m_sign_AB = - 1;
1236               state->m_suzy.data[MATH_B] = temp & 0xff;
1237               state->m_suzy.data[MATH_A] = temp >> 8;
1238            }
1239            else
1240               state->m_sign_AB = 1;
1241         }
12421236         lynx_multiply(state);
12431237         break;
12441238      /* Writing to E will start a 16 bit divide */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team