Example #1
0
void ApuE0()
{
   // CLRV
   APUClearHalfCarry();
   APUClearOverflow();
   IAPU.PC++;
}
Example #2
0
// XXX: HalfCarry - BJ Fixed? Or is it between bits 7 and 8 for ADDW/SUBW?
void Apu7A()
{
   // ADDW YA,dp
   uint16_t Work16 = S9xAPUGetByteZ(OP1) + (S9xAPUGetByteZ(OP1 + 1) << 8);
   uint32_t Work32 = (uint32_t) IAPU.Registers.YA.W + Work16;
   IAPU._Carry = Work32 >= 0x10000;
   if (~(IAPU.Registers.YA.W ^ Work16) & (Work16 ^ (uint16_t) Work32) & 0x8000)
      APUSetOverflow();
   else
      APUClearOverflow();
   APUClearHalfCarry();
   if ((IAPU.Registers.YA.W ^ Work16 ^ (uint16_t) Work32) & 0x10)
      APUSetHalfCarry();
   IAPU.Registers.YA.W = (uint16_t) Work32;
   APUSetZN16(IAPU.Registers.YA.W);
   IAPU.PC += 2;
}
Example #3
0
void Apu9E()
{
   // DIV YA,X
   if (IAPU.Registers.X == 0)
   {
      APUSetOverflow();
      IAPU.Registers.YA.B.Y = 0xff;
      IAPU.Registers.YA.B.A = 0xff;
   }
   else
   {
      APUClearOverflow();
      uint8_t Work8 = IAPU.Registers.YA.W / IAPU.Registers.X;
      IAPU.Registers.YA.B.Y = IAPU.Registers.YA.W % IAPU.Registers.X;
      IAPU.Registers.YA.B.A = Work8;
   }
   // XXX How should Overflow, Half Carry, Zero and Negative flags be set??
   // APUSetZN16 (IAPU.Registers.YA.W);
   APUSetZN8(IAPU.Registers.YA.B.A);
   IAPU.PC++;
}
Example #4
0
// XXX: BJ: i think the old HalfCarry behavior was wrong...
// XXX: Or is it between bits 7 and 8 for ADDW/SUBW?
// XXX: Used Work32 instead of Int32 before. Fixed? [Neb]
void Apu9A()
{
   // SUBW YA,dp
   uint16_t Work16 = S9xAPUGetByteZ(OP1) + (S9xAPUGetByteZ(OP1 + 1) << 8);
   int32_t Int32 = (long) IAPU.Registers.YA.W - (long) Work16;
   APUClearHalfCarry();
   IAPU._Carry = Int32 >= 0;
   if (((IAPU.Registers.YA.W ^ Work16) & 0x8000) &&
         ((IAPU.Registers.YA.W ^ (uint16_t) Int32) & 0x8000))
      APUSetOverflow();
   else
      APUClearOverflow();
   if (((IAPU.Registers.YA.W ^ Work16) & 0x0080) &&
         ((IAPU.Registers.YA.W ^ (uint16_t) Int32) & 0x0080))
      APUSetHalfCarry();
   APUSetHalfCarry();
   if ((IAPU.Registers.YA.W ^ Work16 ^ (uint16_t) Int32) & 0x10)
      APUClearHalfCarry();
   IAPU.Registers.YA.W = (uint16_t) Int32;
   APUSetZN16(IAPU.Registers.YA.W);
   IAPU.PC += 2;
}
// XXX: BJ: i think the old HalfCarry behavior was wrong...
// XXX: Or is it between bits 7 and 8 for ADDW/SUBW?
void Apu9A()
{
   // SUBW YA,dp
   uint16 Work16 = S9xAPUGetByteZ(OP1) + (S9xAPUGetByteZ(OP1 + 1) << 8);
   long Int32 = (long) IAPU.YA.W - (long) Work16;
   APUClearHalfCarry();
   IAPU._Carry = Int32 >= 0;
   if (((IAPU.YA.W ^ Work16) & 0x8000) &&
         ((IAPU.YA.W ^ (uint16) Int32) & 0x8000))
      APUSetOverflow();
   else
      APUClearOverflow();
   //    if (((IAPU.YA.W ^ Work16) & 0x0080) &&
   //     ((IAPU.YA.W ^ (uint16) Int32) & 0x0080))
   // APUSetHalfCarry ();                              // notaz: strange here
   APUSetHalfCarry();
   //    if((IAPU.YA.W ^ Work16 ^ (uint16) Work32) & 0x10) // notaz: Work32?!
   if ((IAPU.YA.W ^ Work16 ^ (uint16) Int32) & 0x10)
      APUClearHalfCarry();
   IAPU.YA.W = (uint16) Int32;
   APUSetZN16(IAPU.YA.W);
   IAPU.PC += 2;
}