@@ -498,6 +498,12 @@ namespace {
498
498
PHASE_NEGATIVE
499
499
};
500
500
501
+ enum {
502
+ FLOATRESULT=0 ,
503
+ DOUBLERESULT=1 ,
504
+ INTRESULT=2
505
+ };
506
+
501
507
class tek440x_state : public driver_device
502
508
{
503
509
public:
@@ -567,8 +573,10 @@ class tek440x_state : public driver_device
567
573
void mouse_w (u8 data);
568
574
void led_w (u8 data);
569
575
570
- void fpu_latch32_result (void *);
571
- void fpu_latch64_result (void *);
576
+ int fpu_latch32_result (void *);
577
+ int fpu_latch64_result (void *);
578
+ int fpu_latch32_int_result (void *);
579
+
572
580
u16 fpu_r (offs_t offset);
573
581
void fpu_w (offs_t offset, u16 data);
574
582
u16 videoaddr_r (offs_t offset);
@@ -646,6 +654,7 @@ class tek440x_state : public driver_device
646
654
bool m_kb_loop;
647
655
648
656
u16 m_fpuselect;
657
+ u16 m_fpustatus;
649
658
u16 m_operand;
650
659
u16 m_lswoperand[5 ];
651
660
u16 m_mswoperand[5 ];
@@ -1011,8 +1020,6 @@ void tek440x_state::mapcntl_w(u8 data)
1011
1020
1012
1021
}
1013
1022
1014
- enum {FLOATRESULT=0 , DOUBLERESULT=1 , INTRESULT=2 };
1015
-
1016
1023
enum {
1017
1024
FPCALC = 0xbe ,
1018
1025
FPCONV = 0x3e ,
@@ -1052,7 +1059,7 @@ enum {
1052
1059
1053
1060
void tek440x_state::fpu_w (offs_t offset, u16 data)
1054
1061
{
1055
- LOG ( " fpu_w: %08x <= 0x%04x\n " , offset, data);
1062
+ // LOGMASKED(LOG_FPU, "fpu_w: %08x <= 0x%04x\n", offset, data);
1056
1063
1057
1064
switch (offset)
1058
1065
{
@@ -1069,26 +1076,34 @@ void tek440x_state::fpu_w(offs_t offset, u16 data)
1069
1076
m_operand++;
1070
1077
break ;
1071
1078
1072
- // start op, can be FPCALC or FPCONV...
1079
+ // start op, can be FPCALC or FPCONV...possibly
1073
1080
case 6 :
1074
- m_result = 0 ;
1075
1081
m_fpuselect = data;
1082
+ m_result = 0 ;
1076
1083
m_operand = 0 ;
1077
1084
break ;
1078
1085
case 7 :
1079
1086
break ;
1080
1087
}
1081
1088
}
1082
1089
1083
- void tek440x_state::fpu_latch32_result (void *v)
1090
+ int tek440x_state::fpu_latch32_result (void *v)
1084
1091
{
1085
1092
m_result <<= 32 ;
1086
1093
m_result |= *(uint32_t *)v;
1094
+ return FLOATRESULT;
1087
1095
}
1088
1096
1089
- void tek440x_state::fpu_latch64_result (void *v)
1097
+ int tek440x_state::fpu_latch64_result (void *v)
1090
1098
{
1091
1099
m_result = *(uint64_t *)v;
1100
+ return DOUBLERESULT;
1101
+ }
1102
+
1103
+ int tek440x_state::fpu_latch32_int_result (void *v)
1104
+ {
1105
+ fpu_latch32_result (v);
1106
+ return INTRESULT;
1092
1107
}
1093
1108
1094
1109
#define CASE_ENUM (C ) case C: opname = #C; break
@@ -1105,6 +1120,29 @@ u16 tek440x_state::fpu_r(offs_t offset)
1105
1120
uint32_t v32;
1106
1121
uint64_t v64;
1107
1122
1123
+ // assembling operands
1124
+ if (m_operand >= 2 ) // has at least 1 32-bit operands
1125
+ {
1126
+ v32 = (m_mswoperand[1 ] << 16 ) | (m_lswoperand[1 ]);
1127
+ ai = v32;
1128
+ af = *(float *)&v32;
1129
+
1130
+ if (m_operand >= 3 ) // has at least 2 32-bit operands or 1 64-bit operand
1131
+ {
1132
+ v32 = (m_mswoperand[2 ] << 16 ) | (m_lswoperand[2 ]);
1133
+ bf = *(float *)&v32;
1134
+
1135
+ v64 = (((uint64_t )m_mswoperand[2 ]) << 48 ) | (((uint64_t )m_lswoperand[2 ])<<32 ) | (((uint64_t )m_mswoperand[1 ]) << 16 ) | (m_lswoperand[1 ]);
1136
+ ad = *(double *)&v64;
1137
+ }
1138
+
1139
+ if (m_operand == 5 ) // has 2 64-bit operands
1140
+ {
1141
+ v64 = (((uint64_t )m_mswoperand[4 ]) << 48 ) | (((uint64_t )m_lswoperand[4 ])<<32 ) | (((uint64_t )m_mswoperand[3 ]) << 16 ) | (m_lswoperand[3 ]);
1142
+ bd = *(double *)&v64;
1143
+ }
1144
+ }
1145
+
1108
1146
#ifdef DEBUG
1109
1147
const char *opname;
1110
1148
switch (m_lswoperand[0 ])
@@ -1138,36 +1176,15 @@ u16 tek440x_state::fpu_r(offs_t offset)
1138
1176
break ;
1139
1177
}
1140
1178
LOGMASKED (LOG_FPU," fpu_r: %s ************** %s \n " , m_fpuselect == FPCALC ? " FPCALC" : " FPCONV" , opname);
1179
+
1180
+ LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) float(%f) int(%d)\n " , m_operand, af, ai);
1181
+ if (m_operands >= 3 )
1182
+ LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) float(%f) float(%f) double(%lf) 0x%lx\n " , m_operand, af,bf, ad, v64);
1183
+ if (m_operands >= 5 )
1184
+ LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) double(%lf) double(%lf)\n " , m_operand, ad,bd);
1141
1185
#endif
1142
1186
1143
- // assembling operands
1144
- if (m_operand >= 2 ) // has at least 1 32-bit operands
1145
- {
1146
- v32 = (m_mswoperand[1 ] << 16 ) | (m_lswoperand[1 ]);
1147
- ai = v32;
1148
- af = *(float *)&v32;
1149
- LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) float(%f) int(%d)\n " , m_operand, af, ai);
1150
-
1151
- if (m_operand >= 3 ) // has at least 2 32-bit operands or 1 64-bit operand
1152
- {
1153
- v32 = (m_mswoperand[2 ] << 16 ) | (m_lswoperand[2 ]);
1154
- bf = *(float *)&v32;
1155
-
1156
- v64 = (((uint64_t )m_mswoperand[2 ]) << 48 ) | (((uint64_t )m_lswoperand[2 ])<<32 ) | (((uint64_t )m_mswoperand[1 ]) << 16 ) | (m_lswoperand[1 ]);
1157
- ad = *(double *)&v64;
1158
-
1159
- LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) float(%f) float(%f) double(%lf) 0x%lx\n " , m_operand, af,bf, ad, v64);
1160
- }
1161
-
1162
- if (m_operand == 5 ) // has 2 64-bit operands
1163
- {
1164
- v64 = (((uint64_t )m_mswoperand[4 ]) << 48 ) | (((uint64_t )m_lswoperand[4 ])<<32 ) | (((uint64_t )m_mswoperand[3 ]) << 16 ) | (m_lswoperand[3 ]);
1165
- bd = *(double *)&v64;
1166
1187
1167
- LOGMASKED (LOG_FPU," fpu_r: m_operand(%d) double(%lf) double(%lf)\n " , m_operand, ad,bd);
1168
- }
1169
- }
1170
-
1171
1188
// execute the functionality
1172
1189
int resulttype = FLOATRESULT;
1173
1190
int ci;
@@ -1177,128 +1194,138 @@ u16 tek440x_state::fpu_r(offs_t offset)
1177
1194
{
1178
1195
case FADD:
1179
1196
cf = bf + af;
1180
- fpu_latch32_result (&cf);
1181
- resulttype = FLOATRESULT;
1197
+ resulttype = fpu_latch32_result (&cf);
1198
+ FLOATRESULT;
1182
1199
break ;
1183
1200
case FSUB:
1184
1201
cf = bf - af;
1185
- fpu_latch32_result (&cf);
1202
+ resulttype = fpu_latch32_result (&cf);
1186
1203
resulttype = FLOATRESULT;
1187
1204
break ;
1188
1205
case FMUL:
1189
1206
cf = bf * af;
1190
- fpu_latch32_result (&cf);
1207
+ resulttype = fpu_latch32_result (&cf);
1191
1208
resulttype = FLOATRESULT;
1192
1209
break ;
1193
1210
case FDIV:
1194
1211
cf = bf / af;
1195
- fpu_latch32_result (&cf);
1212
+ resulttype = fpu_latch32_result (&cf);
1196
1213
resulttype = FLOATRESULT;
1197
1214
break ;
1198
1215
case FCMP:
1199
1216
ci = af > bf ? 1 : (af < bf ? -1 : 0 );
1200
- fpu_latch32_result (&ci);
1217
+ resulttype = fpu_latch32_result (&ci);
1201
1218
resulttype = FLOATRESULT;
1202
1219
break ;
1203
1220
1204
1221
case FNEG:
1205
1222
cf = -af;
1206
- fpu_latch32_result (&cf);
1223
+ resulttype = fpu_latch32_result (&cf);
1207
1224
resulttype = FLOATRESULT;
1208
1225
break ;
1209
1226
case FABS:
1210
1227
cf = fabs (af);
1211
- fpu_latch32_result (&cf);
1228
+ resulttype = fpu_latch32_result (&cf);
1212
1229
resulttype = FLOATRESULT;
1213
1230
break ;
1214
1231
1215
1232
case FItoF:
1216
1233
cf = (float )ai;
1217
- fpu_latch32_result (&cf);
1234
+ resulttype = fpu_latch32_result (&cf);
1218
1235
resulttype = FLOATRESULT;
1219
1236
break ;
1220
1237
case FFtoIr:
1221
1238
ci = (int )(af + 0 .5f );
1222
- fpu_latch32_result (&ci);
1239
+ resulttype = fpu_latch32_int_result (&ci);
1223
1240
resulttype = INTRESULT;
1224
1241
break ;
1225
1242
case FFtoIt:
1226
1243
ci = (int )(af);
1227
- fpu_latch32_result (&ci);
1244
+ resulttype = fpu_latch32_int_result (&ci);
1228
1245
resulttype = INTRESULT;
1229
1246
break ;
1230
1247
case FFtoIf:
1231
1248
ci = (int )floorf (af);
1232
- fpu_latch32_result (&ci);
1249
+ resulttype = fpu_latch32_int_result (&ci);
1233
1250
resulttype = INTRESULT;
1234
1251
break ;
1235
1252
1236
1253
case FFtoD:
1237
1254
cd = (double )af;
1238
- fpu_latch64_result (&cd);
1255
+ resulttype = fpu_latch64_result (&cd);
1239
1256
resulttype = DOUBLERESULT;
1240
1257
break ;
1241
1258
case FDtoF:
1242
1259
cf = (float )ad;
1243
- fpu_latch32_result (&cf);
1260
+ resulttype = fpu_latch32_result (&cf);
1261
+ resulttype = FLOATRESULT;
1244
1262
break ;
1245
1263
1246
1264
case DADD:
1247
1265
cd = bd + ad;
1248
- fpu_latch64_result (&cd);
1266
+ resulttype = fpu_latch64_result (&cd);
1249
1267
resulttype = DOUBLERESULT;
1250
1268
break ;
1251
1269
case DSUB:
1252
1270
cd = bd - ad;
1253
- fpu_latch64_result (&cd);
1271
+ resulttype = fpu_latch64_result (&cd);
1254
1272
resulttype = DOUBLERESULT;
1255
1273
break ;
1256
1274
case DMUL:
1257
1275
cd = bd * ad;
1258
- fpu_latch64_result (&cd);
1276
+ resulttype = fpu_latch64_result (&cd);
1259
1277
resulttype = DOUBLERESULT;
1260
1278
break ;
1261
1279
case DDIV:
1262
1280
cd = bd / ad;
1263
- fpu_latch64_result (&cd);
1281
+ resulttype = fpu_latch64_result (&cd);
1264
1282
resulttype = DOUBLERESULT;
1265
1283
break ;
1266
1284
case DCMP:
1267
1285
ci = ad > bd ? 1 : (ad < bd ? -1 : 0 );
1268
- fpu_latch32_result (&ci);
1286
+ resulttype = fpu_latch32_result (&ci);
1269
1287
resulttype = DOUBLERESULT;
1270
1288
break ;
1271
1289
1272
1290
case DNEG:
1273
1291
cd = -ad;
1274
- fpu_latch64_result (&cd);
1292
+ resulttype = fpu_latch64_result (&cd);
1275
1293
resulttype = DOUBLERESULT;
1276
1294
break ;
1277
1295
case DABS:
1278
1296
cd = fabs (ad);
1279
- fpu_latch64_result (&cd);
1297
+ resulttype = fpu_latch64_result (&cd);
1280
1298
resulttype = DOUBLERESULT;
1281
1299
break ;
1282
1300
1283
1301
case FItoD:
1284
1302
cd = (double )ai;
1285
- fpu_latch64_result (&cd);
1303
+ resulttype = fpu_latch64_result (&cd);
1286
1304
resulttype = DOUBLERESULT;
1287
1305
break ;
1288
1306
case FDtoIr:
1289
1307
ci = (int )(ad + 0.5 );
1290
- fpu_latch32_result (&ci);
1291
- resulttype = DOUBLERESULT ;
1308
+ resulttype = fpu_latch32_int_result (&ci);
1309
+ resulttype = INTRESULT ;
1292
1310
break ;
1293
1311
case FDtoIt:
1294
1312
ci = (int )(ad);
1295
- fpu_latch32_result (&ci);
1296
- resulttype = DOUBLERESULT ;
1313
+ resulttype = fpu_latch32_int_result (&ci);
1314
+ resulttype = INTRESULT ;
1297
1315
break ;
1298
1316
case FDtoIf:
1299
1317
ci = (int )floor (ad);
1300
- fpu_latch32_result (&ci);
1301
- resulttype = DOUBLERESULT;
1318
+ resulttype = fpu_latch32_int_result (&ci);
1319
+ resulttype = INTRESULT;
1320
+ break ;
1321
+
1322
+ case GETS:
1323
+ ai = m_fpustatus;
1324
+ resulttype = fpu_latch32_int_result (&ai);
1325
+ break ;
1326
+ case SETS:
1327
+ m_fpustatus = ai;
1328
+ resulttype = fpu_latch32_int_result (&ai);
1302
1329
break ;
1303
1330
1304
1331
default :
0 commit comments