public int DrawLine(int _rasterLine, bool _outputEnabled) { // returns number of CPU-Ticks - 40 for a "bad line"; else 0 VICState = GetState(); //if (!OutputEnabled()) // return 0; // UpdateRasterLine(_rasterLine); // UpdateRasterLine(_rasterLine - 3 + VICState.OffsetY); // <- works fine in choplifter (textmode -> graphicsmode switch) UpdateRasterLine(_rasterLine - 5); // <- works fine in choplifter (textmode -> graphicsmode switch) byte[] pixels = new byte[512]; int markRasterLine = RasterlineIRQ; //markRasterLine = RasterlineIRQ; if (_outputEnabled) { RenderLineToArray(_rasterLine, ref pixels); RenderBorderToArray(_rasterLine, ref pixels); // debug if (DebugOptions.RenderIRQRasterLine) { if (_rasterLine == markRasterLine) { for (int i = 0; i < VICState.FirstPixel; i += 3) { pixels[i] = 1; } } } CopyByteLineToBitmap(pixels, GetScreen(), _rasterLine); } if (IsBadLine(_rasterLine)) { return(40); } return(0); }
public VIC2_State GetState() { VIC2_State state = new VIC2_State(); state.OutputEnabled = (Read(0xd011, true) & BIT.B4) > 0; state.BorderColor = (Read(0xd020, true) & 0x0f); state.BackgrundColor = (Read(0xd021, true) & 0x0f); state.OffsetY = (Read(0xd011, true) & 0x07) - 3; state.OffsetX = (Read(0xd016, true) & 0x07); state.TextColumns = 38; if ((Read(0xd016, true) & 0x08) > 0) { state.TextColumns = 40; } state.TextRows = 24; if ((Read(0xd011, true) & BIT.B3) > 0) { state.TextRows = 25; } byte _D011 = Read(0xd011, true); byte _D016 = Read(0xd016, true); state.BMM = (_D011 & BIT.B5) > 0; state.ECM = (_D011 & BIT.B6) > 0; state.MCM = (_D016 & BIT.B4) > 0; // memory-bank state.BankBaseAddress = GetBankAddress(); byte VIC_D018_MemCtrl = Read(0xd018, true); state.ScreenAddress = ((VIC_D018_MemCtrl >> 4) & 0x0f) * 0x400; state.BitmapAddress = 0; if ((VIC_D018_MemCtrl & 8) > 0) { state.BitmapAddress += 0x2000; } state.CharMemAddress = ((VIC_D018_MemCtrl >> 1) & 0x07) * 0x800; state.CharMemAddress = GetCharMemAddress(); // rendering parameters state.HorStartPixel = Settings.BorderLeft + state.OffsetX; state.FirstPixel = Settings.BorderLeft; if (state.TextColumns == 38) { state.FirstPixel += 7; } state.LastPixel = state.FirstPixel + (8 * state.TextColumns) - 1; state.FirstScreenLine = 0; state.LastScreenLine = 199; if (state.TextRows == 24) { state.FirstScreenLine = 0; state.LastScreenLine = 191; /* * if ((D011_Status & 0x08) == 0) * { * minScreenLine = 6; * maxScreenLine = 196; * screenLine += 3; * } */ } return(state); }