public ushort Render(VIC vic, ushort x, byte shift) { IVideoOutput output = vic.OutputDevice; ushort[] collision = vic.CollisionMatrix; byte b1, b2; vic.ReadVideoMatrix(out b1, out b2); _colors[0] = vic.GetBackgroundColor(0); _colors[1] = Pallete.CvtColors[b1 >> 4]; _colors[2] = Pallete.CvtColors[b1 & 0x0f]; _colors[3] = Pallete.CvtColors[b2]; ushort y = vic.Raster; uint pos = (uint)(y * VIC.X_RESOLUTION + x); uint bits = (uint)(vic.Memory.Read(vic.GetBitmapMemoryAddress((ushort)((vic.VC << 3) | vic.RC))) << (shift & ~1)); bits <<= 2; uint pixel = pixel = (bits & 0x300) >> 8; bool next = (shift & 1) != 0; for (uint lim = pos + 8 - shift; pos < lim; pos++) { output.OutputPixel(pos, _colors[pixel]); collision[pos] = (bits & 2) != 0 ? (ushort)CollisionState.Foreground : (ushort)0; if (next) { bits <<= 2; pixel = (bits & 0x300) >> 8; } next = !next; } return (ushort)(x + 8 - shift); }
public ushort Render(VIC vic, ushort x, byte shift) { IVideoOutput output = vic.OutputDevice; ushort[] collision = vic.CollisionMatrix; byte b1, b2; vic.ReadVideoMatrix(out b1, out b2); uint color0 = Pallete.CvtColors[b1 & 0x0f]; uint color1 = Pallete.CvtColors[b1 >> 4]; uint bits = (uint)(vic.Memory.Read(vic.GetBitmapMemoryAddress((ushort)((vic.VC << 3) | vic.RC))) << shift); ushort y = vic.Raster; uint pos = (uint)(y * VIC.X_RESOLUTION + x); for (uint lim = pos + 8; pos < lim; pos++) { bits <<= 1; uint pixel = bits & 0x100; output.OutputPixel(pos, pixel == 0 ? color0 : color1); collision[pos] = (ushort)pixel; } return (ushort)(x + 8 - shift); }