Pissed about trying to fix a number of bugs
This commit is contained in:
@@ -190,6 +190,7 @@ namespace Core.Cpu
|
||||
|
||||
// Fetch the next opcode and increment the Program Counter
|
||||
byte opcode = ReadMemory(PC++);
|
||||
R = (byte)((R + 1) & 0x7F);
|
||||
int tStates = ExecuteOpcode(opcode);
|
||||
TotalTStates += tStates;
|
||||
|
||||
|
||||
@@ -18,9 +18,12 @@ namespace Core.Video
|
||||
|
||||
private int _tStateCounter = 0;
|
||||
private int _currentScanline = 0;
|
||||
private int _lineCounter = 0;
|
||||
private byte _statusRegister = 0x00;
|
||||
|
||||
public bool InterruptPending => (_statusRegister & 0x80) != 0 && (Registers[1] & 0x20) != 0;
|
||||
public bool InterruptPending =>
|
||||
((_statusRegister & 0x80) != 0 && (Registers[1] & 0x20) != 0) || // VBlank
|
||||
((_statusRegister & 0x40) != 0 && (Registers[0] & 0x10) != 0); // Line Interrupt
|
||||
|
||||
public byte ReadDataPort() // Port 0xBE
|
||||
{
|
||||
@@ -110,6 +113,20 @@ namespace Core.Video
|
||||
if (_tStateCounter >= 228)
|
||||
{
|
||||
_tStateCounter -= 228;
|
||||
//// --- LINE INTERRUPT LOGIC ---
|
||||
//if (_currentScanline <= 192)
|
||||
//{
|
||||
// _lineCounter--;
|
||||
// if (_lineCounter < 0)
|
||||
// {
|
||||
// _lineCounter = Registers[10]; // Reload counter
|
||||
// _statusRegister |= 0x40; // Set Line Interrupt Flag (Bit 6)
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// _lineCounter = Registers[10]; // Reload outside active display
|
||||
//}
|
||||
_currentScanline++;
|
||||
|
||||
// Line 192 is the exact moment the screen finishes drawing!
|
||||
@@ -117,8 +134,16 @@ namespace Core.Video
|
||||
{
|
||||
_statusRegister |= 0x80; // Set Bit 7 (VBlank Flag) to 1
|
||||
|
||||
RenderBackground(); // <--- DRAW THE FRAME!
|
||||
RenderSprites();
|
||||
if ((Registers[1] & 0x40) != 0)
|
||||
{
|
||||
RenderBackground();
|
||||
RenderSprites();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Screen is off! Fill it with black (or the background color)
|
||||
Array.Fill(FrameBuffer, unchecked((int)0xFF000000));
|
||||
}
|
||||
}
|
||||
|
||||
// End of the NTSC frame (262 lines)
|
||||
@@ -220,6 +245,7 @@ namespace Core.Video
|
||||
|
||||
// 3. Register 1 determines sprite size (8x8 or 8x16)
|
||||
bool is8x16 = (Registers[1] & 0x02) != 0;
|
||||
bool shiftSpritesLeft = (Registers[0] & 0x08) != 0;
|
||||
|
||||
// The SMS can draw a maximum of 64 sprites
|
||||
for (int i = 0; i < 64; i++)
|
||||
@@ -261,6 +287,11 @@ namespace Core.Video
|
||||
for (int px = 0; px < 8; px++)
|
||||
{
|
||||
int screenX = x + px;
|
||||
// THE FIX: Shift the pixel left if commanded!
|
||||
if (shiftSpritesLeft) screenX -= 8;
|
||||
|
||||
// If it shifted off the left edge, skip it!
|
||||
if (screenX < 0 || screenX >= 256) continue;
|
||||
|
||||
// If this pixel is off the right side of the screen, skip it
|
||||
if (screenX >= 256) continue;
|
||||
|
||||
Reference in New Issue
Block a user