On Tue, Apr 06, 1999 at 01:36:04PM +0100, Allan Skillman wrote:
> On the subject of the undocumented flag behavior, the commented out code 
> comes from the Z80 kernel in Xzx which was the original kernel used for
> the early versions of SimCoupe. I wonder where Ian got his info from,
> most of the stuff in xz80 is pretty spot on, Ian?

I wonder, too...  must have had a brainstorm. :-)  You will remember I used to
have the "dec b" and the "out" in the wrong order too.

All the weird and wonderful undocumented flag behaviour is apparently
written up in the cssfaq, although I am not online at the moment to check.
My guess at the parity flag for the INI instruction is nowhere near what is
written there.  As for the difference in zero flag between INI and OUTI, I
can only assume that it is wrong since such weird behaviour (at variance
with published docs) ought to have merited a comment in the code if it were
intentional.

There are a couple of other things I have fixed since the code was
incorporated in SimCoupe.

cbops.c

-#define bit(n,x) (f=(f&1)|((x&(1<<n))?0x10:0x54)|(x&0x28)|(x&0x80))
+#define bit(n,x) (f=(f&1)|((x&(1<<n))?n==7?0x90:0x10:0x54)|(x&0x28))

(This is the undocumented flag which makes the rhinos move backwards in Sabre
Wulf.)

z80ops.c

 #define cpa(x) /* 8-bit compare */ do{unsigned short y;\
                      unsigned char z=(x);\
                       y=(a-z)&0x1ff;\
-                      f=(y&0xa8)|(y>>8)|(((a&0x0f)<(z&0x0f))<<4)|\
+                      f=(y&0x80)|(z&0x28)|(y>>8)|(((a&0x0f)<(z&0x0f))<<4)|\
                         (((a^z)&0x80&(y^a))>>5)|2|((!y)<<6);\
                    } while(0)

(Fix for the undocumented flags in the CP instruction.)

imc

Reply via email to