Increase NotifyObservers data arg to uint16_t from uint8_t
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "app/emu/audio/apu.h"
|
#include "app/emu/audio/apu.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -50,7 +52,7 @@ void Apu::Update() {
|
|||||||
ProcessSamples();
|
ProcessSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apu::Notify(uint32_t address, uint8_t data) {
|
void Apu::Notify(uint32_t address, uint16_t data) {
|
||||||
if (address < 0x2140 || address > 0x2143) {
|
if (address < 0x2140 || address > 0x2143) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,12 +60,11 @@ void Apu::Notify(uint32_t address, uint8_t data) {
|
|||||||
spc700_.write(offset, data);
|
spc700_.write(offset, data);
|
||||||
|
|
||||||
// HACK - This is a temporary solution to get the Apu to play audio
|
// HACK - This is a temporary solution to get the Apu to play audio
|
||||||
|
SDL_Log("Apu::Notify(0x%08x, 0x%04x)", address, data);
|
||||||
ports_[address - 0x2140] = data;
|
ports_[address - 0x2140] = data;
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case 0x2140:
|
case 0x2140:
|
||||||
if (data == BEGIN_SIGNAL) {
|
SignalReady();
|
||||||
SignalReady();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 0x2141:
|
case 0x2141:
|
||||||
// TODO: Handle data byte transfer here
|
// TODO: Handle data byte transfer here
|
||||||
@@ -135,7 +136,7 @@ void Apu::WriteDspMemory(uint16_t address, uint8_t value) {
|
|||||||
dsp_.WriteGlobalReg(address, value);
|
dsp_.WriteGlobalReg(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace audio
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -60,7 +60,7 @@ class Apu : public Observer {
|
|||||||
void Init();
|
void Init();
|
||||||
void Reset();
|
void Reset();
|
||||||
void Update();
|
void Update();
|
||||||
void Notify(uint32_t address, uint8_t data) override;
|
void Notify(uint32_t address, uint16_t data) override;
|
||||||
|
|
||||||
void ProcessSamples();
|
void ProcessSamples();
|
||||||
uint8_t FetchSampleForVoice(uint8_t voice_num);
|
uint8_t FetchSampleForVoice(uint8_t voice_num);
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ using ImGui::Text;
|
|||||||
|
|
||||||
void Emulator::Run() {
|
void Emulator::Run() {
|
||||||
if (!snes_.running() && rom()->is_loaded()) {
|
if (!snes_.running() && rom()->is_loaded()) {
|
||||||
snes_.SetupMemory(*rom());
|
|
||||||
snes_.Init(*rom());
|
snes_.Init(*rom());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ void Emulator::RenderNavBar() {
|
|||||||
gui::zeml::Render(navbar_node);
|
gui::zeml::Render(navbar_node);
|
||||||
|
|
||||||
if (ImGui::Button(ICON_MD_PLAY_ARROW)) {
|
if (ImGui::Button(ICON_MD_PLAY_ARROW)) {
|
||||||
loading_ = true;
|
running_ = true;
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("Start Emulation");
|
ImGui::SetTooltip("Start Emulation");
|
||||||
@@ -86,7 +85,7 @@ void Emulator::RenderNavBar() {
|
|||||||
SameLine();
|
SameLine();
|
||||||
|
|
||||||
if (ImGui::Button(ICON_MD_PAUSE)) {
|
if (ImGui::Button(ICON_MD_PAUSE)) {
|
||||||
snes_.SetCpuMode(1);
|
running_ = false;
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("Pause Emulation");
|
ImGui::SetTooltip("Pause Emulation");
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class RomInfo {
|
|||||||
class Observer {
|
class Observer {
|
||||||
public:
|
public:
|
||||||
virtual ~Observer() = default;
|
virtual ~Observer() = default;
|
||||||
virtual void Notify(uint32_t address, uint8_t data) = 0;
|
virtual void Notify(uint32_t address, uint16_t data) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr uint32_t kROMStart = 0x008000;
|
constexpr uint32_t kROMStart = 0x008000;
|
||||||
@@ -401,7 +401,7 @@ class MemoryImpl : public Memory, public Loggable {
|
|||||||
return address; // Return the original address if no mapping is defined
|
return address; // Return the original address if no mapping is defined
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyObservers(uint32_t address, uint8_t data) const {
|
void NotifyObservers(uint32_t address, uint16_t data) const {
|
||||||
for (auto observer : observers_) {
|
for (auto observer : observers_) {
|
||||||
observer->Notify(address, data);
|
observer->Notify(address, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ void Ppu::UpdateInternalState(int cycles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Ppu::RenderScanline() {
|
void Ppu::RenderScanline() {
|
||||||
|
/**
|
||||||
for (int y = 0; y < 240; ++y) {
|
for (int y = 0; y < 240; ++y) {
|
||||||
for (int x = 0; x < 256; ++x) {
|
for (int x = 0; x < 256; ++x) {
|
||||||
// Calculate the color index based on the x and y coordinates
|
// Calculate the color index based on the x and y coordinates
|
||||||
@@ -54,6 +55,7 @@ void Ppu::RenderScanline() {
|
|||||||
frame_buffer_[y * 256 + x] = color_index;
|
frame_buffer_[y * 256 + x] = color_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Fetch tile data from VRAM, tile map from memory, palette data from CGRAM
|
// Fetch tile data from VRAM, tile map from memory, palette data from CGRAM
|
||||||
UpdateTileData();
|
UpdateTileData();
|
||||||
@@ -64,25 +66,18 @@ void Ppu::RenderScanline() {
|
|||||||
RenderBackground(layer);
|
RenderBackground(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the sprite layer, taking into account sprite priorities and
|
RenderSprites();
|
||||||
// transparency
|
ApplyEffects();
|
||||||
RenderSprites(); // Renders the sprite layer into an internal sprite buffer
|
ComposeLayers();
|
||||||
|
|
||||||
// Apply effects to the layers, such as scaling, rotation, and blending
|
|
||||||
ApplyEffects(); // Applies effects to the layers based on the current mode
|
|
||||||
// and register settings
|
|
||||||
|
|
||||||
// Combine the layers into a single image and store it in the frame buffer
|
|
||||||
ComposeLayers(); // Combines the layers into a single image and stores it in
|
|
||||||
// the frame buffer
|
|
||||||
|
|
||||||
// Display the frame buffer on the screen
|
// Display the frame buffer on the screen
|
||||||
DisplayFrameBuffer();
|
DisplayFrameBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ppu::Notify(uint32_t address, uint8_t data) {
|
void Ppu::Notify(uint32_t address, uint16_t data) {
|
||||||
// Handle communication in the Ppu.
|
// Handle communication in the Ppu.
|
||||||
if (address >= 0x2100 && address <= 0x213F) {
|
if (address >= 0x2100 && address <= 0x213F) {
|
||||||
|
SDL_Log("Ppu::Notify(0x%08x, 0x%04x)", address, data);
|
||||||
// Handle register notification
|
// Handle register notification
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case INIDISP:
|
case INIDISP:
|
||||||
@@ -380,35 +375,22 @@ void Ppu::UpdateTileData() {
|
|||||||
void Ppu::UpdateTileMapData() {}
|
void Ppu::UpdateTileMapData() {}
|
||||||
|
|
||||||
void Ppu::RenderBackground(int layer) {
|
void Ppu::RenderBackground(int layer) {
|
||||||
auto bg1_tilemap_info = BGSC(0);
|
|
||||||
auto bg1_chr_data = BGNBA(0);
|
|
||||||
auto bg2_tilemap_info = BGSC(0);
|
|
||||||
auto bg2_chr_data = BGNBA(0);
|
|
||||||
auto bg3_tilemap_info = BGSC(0);
|
|
||||||
auto bg3_chr_data = BGNBA(0);
|
|
||||||
auto bg4_tilemap_info = BGSC(0);
|
|
||||||
auto bg4_chr_data = BGNBA(0);
|
|
||||||
|
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case 1:
|
case 1:
|
||||||
// Render the first background layer
|
// Render the first background layer
|
||||||
bg1_tilemap_info = BGSC(memory_.ReadByte(BG1SC));
|
|
||||||
bg1_chr_data = BGNBA(memory_.ReadByte(BG12NBA));
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Render the second background layer
|
// Render the second background layer
|
||||||
bg2_tilemap_info = BGSC(memory_.ReadByte(BG2SC));
|
|
||||||
bg2_chr_data = BGNBA(memory_.ReadByte(BG12NBA));
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Render the third background layer
|
// Render the third background layer
|
||||||
bg3_tilemap_info = BGSC(memory_.ReadByte(BG3SC));
|
|
||||||
bg3_chr_data = BGNBA(memory_.ReadByte(BG34NBA));
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// Render the fourth background layer
|
// Render the fourth background layer
|
||||||
bg4_tilemap_info = BGSC(memory_.ReadByte(BG4SC));
|
|
||||||
bg4_chr_data = BGNBA(memory_.ReadByte(BG34NBA));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Invalid layer, do nothing
|
// Invalid layer, do nothing
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ class Ppu : public Observer, public SharedRom {
|
|||||||
// Renders a scanline of the screen
|
// Renders a scanline of the screen
|
||||||
void RenderScanline();
|
void RenderScanline();
|
||||||
|
|
||||||
void Notify(uint32_t address, uint8_t data) override;
|
void Notify(uint32_t address, uint16_t data) override;
|
||||||
|
|
||||||
// Returns the pixel data for the current frame
|
// Returns the pixel data for the current frame
|
||||||
const std::vector<uint8_t>& GetFrameBuffer() const { return frame_buffer_; }
|
const std::vector<uint8_t>& GetFrameBuffer() const { return frame_buffer_; }
|
||||||
|
|||||||
@@ -324,7 +324,6 @@ class Emulator : public CommandHandler {
|
|||||||
step = true;
|
step = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
snes.SetupMemory(rom_);
|
|
||||||
snes.Init(rom_);
|
snes.Init(rom_);
|
||||||
|
|
||||||
if (!step) {
|
if (!step) {
|
||||||
|
|||||||
Reference in New Issue
Block a user