src/mess/machine/lynx.c
| r14312 | r14313 | |
| 882 | 882 | Accumulate JKLM |
| 883 | 883 | */ |
| 884 | 884 | 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 | } |
| 885 | 911 | |
| 886 | 912 | left = state->m_suzy.data[MATH_B] | (state->m_suzy.data[MATH_A] << 8); |
| 887 | 913 | right = state->m_suzy.data[MATH_D] | (state->m_suzy.data[MATH_C] << 8); |
| r14312 | r14313 | |
| 1203 | 1229 | case MATH_M: |
| 1204 | 1230 | state->m_suzy.accumulate_overflow = FALSE; |
| 1205 | 1231 | 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 | 1232 | /* Writing to A will start a 16 bit multiply */ |
| 1225 | 1233 | /* If we are going to perform a signed multiplication, we also store the sign and convert the |
| 1226 | 1234 | number to an unsigned one */ |
| 1227 | 1235 | 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 | | } |
| 1242 | 1236 | lynx_multiply(state); |
| 1243 | 1237 | break; |
| 1244 | 1238 | /* Writing to E will start a 16 bit divide */ |