Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
02701 Core Trivial Always Dec 2, 2008, 16:14 Apr 13, 2019, 19:33
Tester hap View Status Public Platform MAME (Unofficial Binary)
Assigned To hap Resolution Fixed OS Windows XP/Vista 32-bit
Status [?] Resolved Driver
Version 0.128u4 Fixed in Version 0.133u3 Build I686
Fixed in Git Commit Github Pull Request #
Summary 02701: z80.c: SCF CCF X and Y flags
Description This affects all versions of MAME and MESS, I doubt any game relies on this, even ZEXALL doesn't catch it. SCF and CCF X and Y flags are wrong in MAME. Following information has been tested by me and confirmed by several guys in #openmsx freenode and #msxdev rizon IRC.

NEC: flags & A & 0x28
SGS/SHARP/ZiLOG: (flags | A) & 0x28
T9769C (Toshiba IC used in turboR): (flags & 0x28) | (A & 8)

What MAME does, is plain (A&0x28). The most common situation would be the 2nd one, so I suggest to implement that, until MAME emulates the trivial differences between chip brands, if ever.

change
OP(op,37) { z80->F = (z80->F & (SF|ZF|PF)) | CF | (z80->A & (YF|XF)); } /* SCF */
OP(op,3f) { z80->F = ((z80->F&(SF|ZF|PF|CF))|((z80->F&CF)<<4)|(z80->A&(YF|XF)))^CF; } /* CCF */

to:
OP(op,37) { z80->F = (z80->F & (SF|ZF|PF|XF|YF)) | CF | (z80->A & (YF|XF)); } /* SCF */
OP(op,3f) { z80->F = ((z80->F&(SF|ZF|PF|CF|XF|YF))|((z80->F&CF)<<4)|(z80->A&(YF|XF)))^CF; } /* CCF */
Steps To Reproduce
Additional Information
Github Commit
Flags
Regression Version
Affected Sets / Systems z80.c
Attached Files
? file icon u5_z80_39.diff (2,345 bytes) Dec 9, 2008, 19:05
[Show Content]
Relationships
There are no relationship linked to this issue.
Notes
8
User avatar
No.03196
Haze
Senior Tester
Dec 2, 2008, 16:18
MAME should emulate the difference between the chips, if documented. While it's highly unlikely that anything would depend on such behavior, it *should* be documented and selectable based on chip type.
User avatar
No.03260
hap
Developer
Dec 9, 2008, 15:02
diff with fix uploaded
User avatar
No.04809
Haze
Senior Tester
Aug 13, 2009, 22:10
hmm both should be supported really, depending on CPU type as both are confirmed to be real chip behaviors.
User avatar
No.04820
hap
Developer
Aug 16, 2009, 14:27
Z80 type selection can be added later, maybe by someone else. I'll put a TODO in z80.c
User avatar
No.16326
Edstrom
Developer
Apr 13, 2019, 11:30
Test software for this particular issue http://www.cpc-power.com/index.php?page=detail&onglet=dumps&num=12883
User avatar
No.16331
hap
Developer
Apr 13, 2019, 18:09
Is it this test? http://www.cpcwiki.eu/forum/technical-support/z80-defective-tests/
They say it fails with SCF/CCF on a real Zilog Z80 too, but passes on other brands.
User avatar
No.16332
Edstrom
Developer
Apr 13, 2019, 18:32
Yes it is the same test discussed there, here is my screenshot for MAME: https://i.imgur.com/lKiOgGU.png
We claim that we do NEC emualtions but that should pass then?
User avatar
No.16334
hap
Developer
Apr 13, 2019, 19:33
We claim to emulate the Zilog one.