feat: Enhance ROM Loading with Validation and Disassembly Viewer Integration
- Added validation checks for ROM file existence and size constraints (minimum 32KB, maximum 8MB) during loading. - Integrated a new disassembly viewer to track and display executed instructions, enhancing debugging capabilities. - Updated CPU class to manage disassembly viewer instances, allowing for real-time instruction logging. - Improved emulator's CMake configuration to include new source files related to the disassembly viewer. - Enhanced pixel handling in the PPU to support BGRX format for better compatibility with SDL.
This commit is contained in:
@@ -207,18 +207,30 @@ void Ppu::HandlePixel(int x, int y) {
|
||||
}
|
||||
}
|
||||
int row = (y - 1) + (even_frame ? 0 : 239);
|
||||
|
||||
// SDL_PIXELFORMAT_ARGB8888 with pixelOutputFormat=0 (BGRX)
|
||||
// Memory layout: [B][G][R][A] at offsets 0,1,2,3 respectively
|
||||
// Convert 5-bit SNES color (0-31) to 8-bit (0-255) via (val << 3) | (val >> 2)
|
||||
// Two pixels per X position for hi-res support:
|
||||
// pixel1 at x*8 + 0..3, pixel2 at x*8 + 4..7
|
||||
|
||||
// First pixel (hi-res/main screen)
|
||||
pixelBuffer[row * 2048 + x * 8 + 0 + pixelOutputFormat] =
|
||||
((b2 << 3) | (b2 >> 2)) * brightness / 15;
|
||||
((b2 << 3) | (b2 >> 2)) * brightness / 15; // Blue channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 1 + pixelOutputFormat] =
|
||||
((g2 << 3) | (g2 >> 2)) * brightness / 15;
|
||||
((g2 << 3) | (g2 >> 2)) * brightness / 15; // Green channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 2 + pixelOutputFormat] =
|
||||
((r2 << 3) | (r2 >> 2)) * brightness / 15;
|
||||
((r2 << 3) | (r2 >> 2)) * brightness / 15; // Red channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 3 + pixelOutputFormat] = 0xFF; // Alpha (opaque)
|
||||
|
||||
// Second pixel (lo-res/subscreen)
|
||||
pixelBuffer[row * 2048 + x * 8 + 4 + pixelOutputFormat] =
|
||||
((b << 3) | (b >> 2)) * brightness / 15;
|
||||
((b << 3) | (b >> 2)) * brightness / 15; // Blue channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 5 + pixelOutputFormat] =
|
||||
((g << 3) | (g >> 2)) * brightness / 15;
|
||||
((g << 3) | (g >> 2)) * brightness / 15; // Green channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 6 + pixelOutputFormat] =
|
||||
((r << 3) | (r >> 2)) * brightness / 15;
|
||||
((r << 3) | (r >> 2)) * brightness / 15; // Red channel
|
||||
pixelBuffer[row * 2048 + x * 8 + 7 + pixelOutputFormat] = 0xFF; // Alpha (opaque)
|
||||
}
|
||||
|
||||
int Ppu::GetPixel(int x, int y, bool subscreen, int* r, int* g, int* b) {
|
||||
|
||||
@@ -258,8 +258,9 @@ class Ppu {
|
||||
// Initialize the frame buffer
|
||||
void Init() {
|
||||
frame_buffer_.resize(256 * 240, 0);
|
||||
// Set to XBGR format (1) for compatibility with SDL_PIXELFORMAT_ARGB8888
|
||||
pixelOutputFormat = 1;
|
||||
// Set to BGRX format (0) for compatibility with SDL_PIXELFORMAT_ARGB8888
|
||||
// Format 0 = BGRX: [B][G][R][A] byte order in memory (little-endian)
|
||||
pixelOutputFormat = 0;
|
||||
}
|
||||
|
||||
void Reset();
|
||||
|
||||
Reference in New Issue
Block a user