diff --git a/Tools/Win32DiskImager/Win32DiskImager.exe b/Tools/Win32DiskImager/Win32DiskImager.exe index 2c838b36..72e53377 100644 Binary files a/Tools/Win32DiskImager/Win32DiskImager.exe and b/Tools/Win32DiskImager/Win32DiskImager.exe differ diff --git a/Tools/unix/zx/z80ops.h b/Tools/unix/zx/z80ops.h index a9687741..aac5d548 100644 --- a/Tools/unix/zx/z80ops.h +++ b/Tools/unix/zx/z80ops.h @@ -317,15 +317,43 @@ endinstr; instr(39,4); { - unsigned char incr=0, carry=cy; - if((f&0x10) || (a&0x0f)>9) incr=6; - if((f&1) || (a>>4)>9) incr|=0x60; - if(f&2)suba(incr,0); - else { - if(a>0x90 && (a&15)>9)incr|=0x60; - adda(incr,0); - } - f=((f|carry)&0xfb)|parity(a); + /* Frank D. Cringle's DAA implementation, converted from yaze 1.10 */ + unsigned int acu,temp,cbits; + + acu=a; + temp=(acu&15); + cbits=(f&1); + if(f&2) /* if N */ + { + /* last operation was a subtract */ + int hd=(cbits || (acu>0x99)); + if((f&16) || (temp>9)) + { /* adjust low digit */ + if(temp>5) f&=~16; + acu-=6; + acu&=0xff; + } + /* adjust high digit */ + if(hd) + acu-=0x160; + } + else + { + /* last operation was an add */ + if((f&16) || (temp>9)) + { + /* adjust low digit */ + if(temp>9) f|=16; else f&=~16; + acu+=6; + } + /* adjust high digit */ + if(cbits || ((acu&0x1f0)>0x90)) + acu+=0x60; + } + cbits|=((acu>>8)&1); + acu&=0xff; + a=acu; + f=((acu&0xa8)|((acu==0)<<6)|(f&0x12)|parity(a)|cbits); } endinstr; diff --git a/Tools/zx/zx-src.zip b/Tools/zx/zx-src.zip index a2887f97..7158ac73 100644 Binary files a/Tools/zx/zx-src.zip and b/Tools/zx/zx-src.zip differ diff --git a/Tools/zx/zx.exe b/Tools/zx/zx.exe index 73d83296..f33c7a19 100644 Binary files a/Tools/zx/zx.exe and b/Tools/zx/zx.exe differ diff --git a/Tools/zx/zxdbg.exe b/Tools/zx/zxdbg.exe index 3079b506..598ace60 100644 Binary files a/Tools/zx/zxdbg.exe and b/Tools/zx/zxdbg.exe differ