Previous 15994 Revisions Next

r15687 Friday 27th July, 2012 at 13:49:31 UTC by Curt Coder
Fixed AMD/ASD opcodes in the F8 CPU core. Status flags are set before the decimal correction factor is added, so only the carry flag is significant after a decimal addition opcode. [Sean Riddle]

[VIDBRAIN] Fixed graphics corruption in Lemonade Stand. [Sean Riddle]
[src/emu/cpu/f8]f8.c
[src/mess/video]uv201.c

src/emu/cpu/f8/f8.c
r15686r15687
11591159 ***************************************************/
11601160static void f8_amd(f8_Regs *cpustate)
11611161{
1162    UINT8 tmp = cpustate->a - 0x66, adj = 0x00;
1163    int sum;
1162
1163/*SKR from F8 Guide To programming description of AMD
1164
1165 binary add the addend to the binary sum of the augend and $66
1166   *NOTE* the binary addition of the augend to $66 is done before AMD is called
1167   record the status of the carry and intermediate carry
1168   add a factor to the sum based on the carry and intermediate carry:
1169     no carry, no intermediate carry, add $AA
1170     no carry, intermediate carry, add $A0
1171     carry, no intermediate carry, add $0A
1172     carry, intermediate carry, add $00
1173     any carry from the low-order digit is suppressed
1174   *NOTE* status flags are updated prior to the factor being added
1175*/
1176
1177    UINT8 augend=cpustate->a;
11641178    ROMC_02(cpustate);
1165    sum = (tmp & 0x0f) + (cpustate->dbus & 0x0f);
1166    if (sum > 0x09)
1167   adj += 0x06;
1168    sum = tmp + cpustate->dbus + adj;
1169    if (sum > 0x99)
1170   adj += 0x60;
1171    tmp += adj;
1179    UINT8 addend=cpustate->dbus;
1180    UINT8 tmp=addend+augend;
1181
1182    UINT8 c=0;              /* high order carry */
1183    UINT8 ic=0;             /* low order carry */
1184    if(((augend+addend)&0xff0)>0xf0)
1185    c=1;
1186    if((augend&0x0f)+(addend&0x0f)>0x0F)
1187    ic=1;
1188
11721189    CLR_OZCS;
1173    SET_OC(tmp,cpustate->dbus);
1174    cpustate->a = tmp + cpustate->dbus;
1175    SET_SZ(cpustate->a);
1190    SET_OC(augend,addend);
1191    SET_SZ(tmp);
1192
1193    if(c==0&&ic==0)
1194    tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f);
1195    if(c==0&&ic==1)
1196    tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f);
1197    if(c==1&&ic==0)
1198    tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f);
1199   
1200    cpustate->a = tmp;
11761201}
11771202
11781203/***************************************************
r15686r15687
13641389 ***************************************************/
13651390static void f8_asd(f8_Regs *cpustate, int r)
13661391{
1367   UINT8 tmp = cpustate->a - 0x66, adj = 0x00;
1368   int sum;
1369   ROMC_1C(cpustate, cS);
1370   sum = (tmp & 0x0f) + (cpustate->r[r] & 0x0f);
1371   if (sum > 0x09)
1372      adj += 0x06;
1373   sum = tmp + cpustate->r[r] + adj;
1374   if (sum > 0x99)
1375      adj += 0x60;
1376   tmp += adj;
1377   CLR_OZCS;
1378   SET_OC(tmp, cpustate->r[r]);
1379   cpustate->a = tmp + cpustate->r[r];
1380   SET_SZ(cpustate->a);
1392/*SKR from F8 Guide To programming description of AMD */
1393    UINT8 augend=cpustate->a;
1394    ROMC_1C(cpustate, cS);
1395    UINT8 addend=cpustate->r[r];
1396    UINT8 tmp=augend+addend;
1397
1398    UINT8 c=0;
1399    UINT8 ic=0;
1400    if(((augend+addend)&0xff0)>0xf0)
1401    c=1;
1402    if((augend&0x0f)+(addend&0x0f)>0x0F)
1403    ic=1;
1404
1405    CLR_OZCS;
1406    SET_OC(augend,addend);
1407    SET_SZ(tmp);
1408
1409    if(c==0&&ic==0)
1410    tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f);
1411    if(c==0&&ic==1)
1412    tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f);
1413    if(c==1&&ic==0)
1414    tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f);
1415   
1416    cpustate->a = tmp;
13811417}
13821418
13831419/***************************************************
r15686r15687
13861422 ***************************************************/
13871423static void f8_asd_isar(f8_Regs *cpustate)
13881424{
1389   UINT8 tmp = cpustate->a - 0x66, adj = 0x00;
1390   int sum;
1391   ROMC_1C(cpustate, cS);
1392   sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f);
1393   if (sum > 0x09)
1394      adj += 0x06;
1395   sum = tmp + cpustate->r[cpustate->is] + adj;
1396   if (sum > 0x99)
1397      adj += 0x60;
1398   tmp += adj;
1399   CLR_OZCS;
1400   SET_OC(tmp, cpustate->r[cpustate->is]);
1401   cpustate->a = tmp + cpustate->r[cpustate->is];
1402   SET_SZ(cpustate->a);
1425/*SKR from F8 Guide To programming description of AMD */
1426    UINT8 augend=cpustate->a;
1427    ROMC_1C(cpustate, cS);
1428    UINT8 addend=cpustate->r[cpustate->is];
1429    UINT8 tmp=augend+addend;
1430
1431    UINT8 c=0;
1432    UINT8 ic=0;
1433    if(((augend+addend)&0xff0)>0xf0)
1434    c=1;
1435    if((augend&0x0f)+(addend&0x0f)>0x0F)
1436    ic=1;
1437
1438    CLR_OZCS;
1439    SET_OC(augend,addend);
1440    SET_SZ(tmp);
1441
1442    if(c==0&&ic==0)
1443    tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f);
1444    if(c==0&&ic==1)
1445    tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f);
1446    if(c==1&&ic==0)
1447    tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f);
1448   
1449    cpustate->a = tmp;
14031450}
14041451
14051452/***************************************************
r15686r15687
14081455 ***************************************************/
14091456static void f8_asd_isar_i(f8_Regs *cpustate)
14101457{
1411   UINT8 tmp = cpustate->a - 0x66, adj = 0x00;
1412   int sum;
1413   ROMC_1C(cpustate, cS);
1414   sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f);
1415   if (sum > 0x09)
1416      adj += 0x06;
1417   sum = tmp + cpustate->r[cpustate->is] + adj;
1418   if (sum > 0x99)
1419      adj += 0x60;
1420   tmp += adj;
1421   CLR_OZCS;
1422   SET_OC(tmp, cpustate->r[cpustate->is]);
1423   cpustate->a = tmp + cpustate->r[cpustate->is];
1424   SET_SZ(cpustate->a);
1425   cpustate->is = (cpustate->is & 0x38) | ((cpustate->is + 1) & 0x07);
1458/*SKR from F8 Guide To programming description of AMD */
1459    UINT8 augend=cpustate->a;
1460    ROMC_1C(cpustate, cS);
1461    UINT8 addend=cpustate->r[cpustate->is];
1462    UINT8 tmp=augend+addend;
1463
1464    UINT8 c=0;
1465    UINT8 ic=0;
1466    if(((augend+addend)&0xff0)>0xf0)
1467    c=1;
1468    if((augend&0x0f)+(addend&0x0f)>0x0F)
1469    ic=1;
1470
1471    CLR_OZCS;
1472    SET_OC(augend,addend);
1473    SET_SZ(tmp);
1474
1475    if(c==0&&ic==0)
1476    tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f);
1477    if(c==0&&ic==1)
1478    tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f);
1479    if(c==1&&ic==0)
1480    tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f);
1481   
1482    cpustate->a = tmp;
1483    cpustate->is = (cpustate->is & 0x38) | ((cpustate->is + 1) & 0x07);
14261484}
14271485
14281486/***************************************************
r15686r15687
14311489 ***************************************************/
14321490static void f8_asd_isar_d(f8_Regs *cpustate)
14331491{
1434   UINT8 tmp = cpustate->a - 0x66, adj = 0x00;
1435   int sum;
1436   ROMC_1C(cpustate, cS);
1437   sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f);
1438   if (sum > 0x09)
1439      adj += 0x06;
1440   sum = tmp + cpustate->r[cpustate->is] + adj;
1441   if (sum > 0x99)
1442      adj += 0x60;
1443   tmp += adj;
1444   CLR_OZCS;
1445   SET_OC(tmp, cpustate->r[cpustate->is]);
1446   cpustate->a = tmp + cpustate->r[cpustate->is];
1447   SET_SZ(cpustate->a);
1448   cpustate->is = (cpustate->is & 0x38) | ((cpustate->is - 1) & 0x07);
1492/*SKR from F8 Guide To programming description of AMD */
1493    UINT8 augend=cpustate->a;
1494    ROMC_1C(cpustate, cS);
1495    UINT8 addend=cpustate->r[cpustate->is];
1496    UINT8 tmp=augend+addend;
1497
1498    UINT8 c=0;
1499    UINT8 ic=0;
1500    if(((augend+addend)&0xff0)>0xf0)
1501    c=1;
1502    if((augend&0x0f)+(addend&0x0f)>0x0F)
1503    ic=1;
1504
1505    CLR_OZCS;
1506    SET_OC(augend,addend);
1507    SET_SZ(tmp);
1508
1509    if(c==0&&ic==0)
1510    tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f);
1511    if(c==0&&ic==1)
1512    tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f);
1513    if(c==1&&ic==0)
1514    tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f);
1515   
1516    cpustate->a = tmp;
1517    cpustate->is = (cpustate->is & 0x38) | ((cpustate->is - 1) & 0x07);
14491518}
14501519
14511520/***************************************************
src/mess/video/uv201.c
r15686r15687
485485      UINT8 rp_lo = RAM_XORD(RAM_RP_LO);
486486      UINT16 rp = ((rp_hi_color << 8) | rp_lo) & 0x1fff;
487487 
488      if (rp < 0x800) rp |= 0x2000;
489 
488490      UINT8 dx_int_xcopy = RAM_XORD(RAM_DX_INT_XCOPY);
489491      int color = ((dx_int_xcopy & 0x60) >> 2) | (BIT(rp_hi_color, 5) << 2) | (BIT(rp_hi_color, 6) << 1) | (BIT(rp_hi_color, 7));
490492      UINT8 dx = dx_int_xcopy & 0x1f;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team