public byte ReadRegister(UInt16 adr)
{
switch (adr)
{
case 0x00:
case 0x02:
case 0x04:
case 0x06:
case 0x08:
case 0x0a:
case 0x0c:
case 0x0e:
return (byte)mx[adr >> 1];
case 0x01:
case 0x03:
case 0x05:
case 0x07:
case 0x09:
case 0x0b:
case 0x0d:
case 0x0f:
return my[adr >> 1];
case 0x10: // Sprite X position MSB
return mx8;
case 0x11: // Control register 1
//return (byte)((ctrl1 & 0x7f) | ((raster_y & 0x100) >> 1)); 2009-01-24 PMB added casting to byte below
return (byte)((ctrl1 & 0x7f) | (byte)((raster_y & 0x100) >> 1));
case 0x12: // Raster counter
return (byte)raster_y;
case 0x13: // Light pen X
return lpx;
case 0x14: // Light pen Y
return lpy;
case 0x15: // Sprite enable
return me;
case 0x16: // Control register 2
return (byte)(ctrl2 | 0xc0);
case 0x17: // Sprite Y expansion
return mye;
case 0x18: // Memory pointers
return (byte)(vbase | 0x01);
case 0x19: // IRQ flags
return (byte)(irq_flag | 0x70);
case 0x1a: // IRQ mask
return (byte)(irq_mask | 0xf0);
case 0x1b: // Sprite data priority
return mdp;
case 0x1c: // Sprite multicolor
return mmc;
case 0x1d: // Sprite X expansion
return mxe;
case 0x1e:
{ // Sprite-sprite collision
byte ret = clx_spr;
clx_spr = 0; // Read and clear
return ret;
}
case 0x1f:
{ // Sprite-background collision
byte ret = clx_bgr;
clx_bgr = 0; // Read and clear
return ret;
}
case 0x20: return (byte)(ec | 0xf0);
case 0x21: return (byte)(b0c | 0xf0);
case 0x22: return (byte)(b1c | 0xf0);
case 0x23: return (byte)(b2c | 0xf0);
case 0x24: return (byte)(b3c | 0xf0);
case 0x25: return (byte)(mm0 | 0xf0);
case 0x26: return (byte)(mm1 | 0xf0);
case 0x27:
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
return (byte)(sc[adr - 0x27] | 0xf0);
default:
return 0xff;
}
}