Add Debugger interface, RoomObject class

- Log instructions to debugger using experiment flag
- Use BitmapManager for more functionality
- Draw framebuffer and integrated debugger
This commit is contained in:
scawful
2023-11-13 14:51:01 -05:00
parent 75ef4fd9b0
commit 299770922c
27 changed files with 740 additions and 234 deletions

View File

@@ -46,7 +46,11 @@ void PPU::UpdateInternalState(int cycles) {
void PPU::RenderScanline() {
for (int y = 0; y < 240; ++y) {
for (int x = 0; x < 256; ++x) {
frame_buffer_[y * 256 + x] = (x + y) % 256; // Simple gradient pattern
// Calculate the color index based on the x and y coordinates
uint8_t color_index = (x + y) % 8;
// Set the pixel in the frame buffer to the calculated color index
frame_buffer_[y * 256 + x] = color_index;
}
}
@@ -267,7 +271,12 @@ void PPU::ApplyEffects() {}
void PPU::ComposeLayers() {}
void PPU::DisplayFrameBuffer() {}
void PPU::DisplayFrameBuffer() {
if (!screen_->IsActive()) {
screen_->Create(256, 240, 24, frame_buffer_);
rom()->RenderBitmap(screen_.get());
}
}
} // namespace emu
} // namespace app

View File

@@ -8,6 +8,7 @@
#include "app/emu/clock.h"
#include "app/emu/memory/memory.h"
#include "app/emu/video/ppu_registers.h"
#include "app/rom.h"
namespace yaze {
namespace app {
@@ -234,7 +235,7 @@ struct BackgroundLayer {
const int kPpuClockSpeed = 5369318; // 5.369318 MHz
class PPU : public Observer {
class PPU : public Observer, public SharedROM {
public:
// Initializes the PPU with the necessary resources and dependencies
PPU(Memory& memory, Clock& clock) : memory_(memory), clock_(clock) {}
@@ -243,6 +244,8 @@ class PPU : public Observer {
void Init() {
clock_.SetFrequency(kPpuClockSpeed);
frame_buffer_.resize(256 * 240, 0);
screen_ = std::make_shared<gfx::Bitmap>(256, 240, 8, 0x100);
screen_->SetActive(false);
}
// Resets the PPU to its initial state
@@ -261,6 +264,8 @@ class PPU : public Observer {
// Returns the pixel data for the current frame
const std::vector<uint8_t>& GetFrameBuffer() const { return frame_buffer_; }
auto GetScreen() const { return screen_; }
private:
// Updates internal state based on PPU register settings
void UpdateModeSettings();
@@ -300,6 +305,7 @@ class PPU : public Observer {
std::vector<SpriteAttributes> sprites_;
std::vector<uint8_t> tile_data_;
std::vector<uint8_t> frame_buffer_;
std::shared_ptr<gfx::Bitmap> screen_;
uint16_t oam_address_;
uint16_t tile_data_size_;