- --
Viewing Issue Advanced Details
[ Jump to Notes ]
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
|
u5_z80_39.diff (2,345 bytes) Dec 9, 2008, 19:05 [Show Content] [Hide Content]diff -Nru src/emu/cpu/z80/z80.c 2/src/emu/cpu/z80/z80.c --- src/emu/cpu/z80/z80.c 2008-12-08 16:13:46.000000000 +0100 +++ src/emu/cpu/z80/z80.c 2008-12-09 15:56:22.000000000 +0100 @@ -1,7 +1,7 @@ /***************************************************************************** * * z80.c - * Portable Z80 emulator V3.8 + * Portable Z80 emulator V3.9 * * Copyright Juergen Buchmueller, all rights reserved. * @@ -17,6 +17,12 @@ * terms of its usage and license at any time, including retroactively * - This entire notice must remain in the source code. * + * Changes in 3.9 + * - Fixed undocumented X and Y flags handling on SCF and CCF opcodes. [hap] + * It's slightly different depending on Z80 brand: + * SGS/SHARP/ZiLOG: (z80->A & (YF|XF)) | (z80->F & (YF|XF)) == implemented + * NEC: z80->A & z80->F & (YF|XF) + * T9769C (Toshiba IC in MSX turboR): (z80->A & XF) | (z80->F & (YF|XF)) * Changes in 3.8 [Miodrag Milanovic] * - Added MEMPTR register (according to informations provided * by Vladimir Kladov @@ -2959,7 +2965,7 @@ OP(op,34) { WM(z80, z80->HL, INC(z80, RM(z80, z80->HL))); } /* INC (HL) */ OP(op,35) { WM(z80, z80->HL, DEC(z80, RM(z80, z80->HL))); } /* DEC (HL) */ OP(op,36) { WM(z80, z80->HL, ARG(z80)); } /* LD (HL),n */ -OP(op,37) { z80->F = (z80->F & (SF|ZF|PF)) | CF | (z80->A & (YF|XF)); } /* SCF */ +OP(op,37) { z80->F = (z80->F & (SF|ZF|YF|XF|PF)) | CF | (z80->A & (YF|XF)); } /* SCF */ OP(op,38) { JR_COND(z80, z80->F & CF, 0x38); } /* JR C,o */ OP(op,39) { ADD16(z80, hl, sp); } /* ADD HL,SP */ @@ -2968,7 +2974,7 @@ OP(op,3c) { z80->A = INC(z80, z80->A); } /* INC A */ OP(op,3d) { z80->A = DEC(z80, z80->A); } /* DEC A */ OP(op,3e) { z80->A = ARG(z80); } /* LD A,n */ -OP(op,3f) { z80->F = ((z80->F&(SF|ZF|PF|CF))|((z80->F&CF)<<4)|(z80->A&(YF|XF)))^CF; } /* CCF */ +OP(op,3f) { z80->F = ((z80->F&(SF|ZF|YF|XF|PF|CF))|((z80->F&CF)<<4)|(z80->A&(YF|XF)))^CF; } /* CCF */ OP(op,40) { } /* LD B,B */ OP(op,41) { z80->B = z80->C; } /* LD B,C */ | ||||
Relationships
There are no relationship linked to this issue. |
Notes
8
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. |
---|---|
No.03260
hap Developer
Dec 9, 2008, 15:02
|
diff with fix uploaded |
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. |
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 |
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 |
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. |
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? |
No.16334
hap Developer
Apr 13, 2019, 19:33
|
We claim to emulate the Zilog one. |