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 <SDL.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -50,7 +52,7 @@ void Apu::Update() {
|
||||
ProcessSamples();
|
||||
}
|
||||
|
||||
void Apu::Notify(uint32_t address, uint8_t data) {
|
||||
void Apu::Notify(uint32_t address, uint16_t data) {
|
||||
if (address < 0x2140 || address > 0x2143) {
|
||||
return;
|
||||
}
|
||||
@@ -58,12 +60,11 @@ void Apu::Notify(uint32_t address, uint8_t data) {
|
||||
spc700_.write(offset, data);
|
||||
|
||||
// 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;
|
||||
switch (address) {
|
||||
case 0x2140:
|
||||
if (data == BEGIN_SIGNAL) {
|
||||
SignalReady();
|
||||
}
|
||||
SignalReady();
|
||||
break;
|
||||
case 0x2141:
|
||||
// TODO: Handle data byte transfer here
|
||||
@@ -135,7 +136,7 @@ void Apu::WriteDspMemory(uint16_t address, uint8_t value) {
|
||||
dsp_.WriteGlobalReg(address, value);
|
||||
}
|
||||
|
||||
} // namespace audio
|
||||
} // namespace audio
|
||||
} // namespace emu
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
@@ -60,7 +60,7 @@ class Apu : public Observer {
|
||||
void Init();
|
||||
void Reset();
|
||||
void Update();
|
||||
void Notify(uint32_t address, uint8_t data) override;
|
||||
void Notify(uint32_t address, uint16_t data) override;
|
||||
|
||||
void ProcessSamples();
|
||||
uint8_t FetchSampleForVoice(uint8_t voice_num);
|
||||
|
||||
@@ -50,7 +50,6 @@ using ImGui::Text;
|
||||
|
||||
void Emulator::Run() {
|
||||
if (!snes_.running() && rom()->is_loaded()) {
|
||||
snes_.SetupMemory(*rom());
|
||||
snes_.Init(*rom());
|
||||
}
|
||||
|
||||
@@ -78,7 +77,7 @@ void Emulator::RenderNavBar() {
|
||||
gui::zeml::Render(navbar_node);
|
||||
|
||||
if (ImGui::Button(ICON_MD_PLAY_ARROW)) {
|
||||
loading_ = true;
|
||||
running_ = true;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Start Emulation");
|
||||
@@ -86,7 +85,7 @@ void Emulator::RenderNavBar() {
|
||||
SameLine();
|
||||
|
||||
if (ImGui::Button(ICON_MD_PAUSE)) {
|
||||
snes_.SetCpuMode(1);
|
||||
running_ = false;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Pause Emulation");
|
||||
|
||||
@@ -94,7 +94,7 @@ class RomInfo {
|
||||
class Observer {
|
||||
public:
|
||||
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;
|
||||
@@ -401,7 +401,7 @@ class MemoryImpl : public Memory, public Loggable {
|
||||
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_) {
|
||||
observer->Notify(address, data);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ void Ppu::UpdateInternalState(int cycles) {
|
||||
}
|
||||
|
||||
void Ppu::RenderScanline() {
|
||||
/**
|
||||
for (int y = 0; y < 240; ++y) {
|
||||
for (int x = 0; x < 256; ++x) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Fetch tile data from VRAM, tile map from memory, palette data from CGRAM
|
||||
UpdateTileData();
|
||||
@@ -64,25 +66,18 @@ void Ppu::RenderScanline() {
|
||||
RenderBackground(layer);
|
||||
}
|
||||
|
||||
// Render the sprite layer, taking into account sprite priorities and
|
||||
// transparency
|
||||
RenderSprites(); // Renders the sprite layer into an internal sprite buffer
|
||||
|
||||
// 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
|
||||
RenderSprites();
|
||||
ApplyEffects();
|
||||
ComposeLayers();
|
||||
|
||||
// Display the frame buffer on the screen
|
||||
DisplayFrameBuffer();
|
||||
}
|
||||
|
||||
void Ppu::Notify(uint32_t address, uint8_t data) {
|
||||
void Ppu::Notify(uint32_t address, uint16_t data) {
|
||||
// Handle communication in the Ppu.
|
||||
if (address >= 0x2100 && address <= 0x213F) {
|
||||
SDL_Log("Ppu::Notify(0x%08x, 0x%04x)", address, data);
|
||||
// Handle register notification
|
||||
switch (address) {
|
||||
case INIDISP:
|
||||
@@ -380,35 +375,22 @@ void Ppu::UpdateTileData() {
|
||||
void Ppu::UpdateTileMapData() {}
|
||||
|
||||
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) {
|
||||
case 1:
|
||||
// Render the first background layer
|
||||
bg1_tilemap_info = BGSC(memory_.ReadByte(BG1SC));
|
||||
bg1_chr_data = BGNBA(memory_.ReadByte(BG12NBA));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
// Render the second background layer
|
||||
bg2_tilemap_info = BGSC(memory_.ReadByte(BG2SC));
|
||||
bg2_chr_data = BGNBA(memory_.ReadByte(BG12NBA));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// Render the third background layer
|
||||
bg3_tilemap_info = BGSC(memory_.ReadByte(BG3SC));
|
||||
bg3_chr_data = BGNBA(memory_.ReadByte(BG34NBA));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
// Render the fourth background layer
|
||||
bg4_tilemap_info = BGSC(memory_.ReadByte(BG4SC));
|
||||
bg4_chr_data = BGNBA(memory_.ReadByte(BG34NBA));
|
||||
|
||||
break;
|
||||
default:
|
||||
// Invalid layer, do nothing
|
||||
|
||||
@@ -289,7 +289,7 @@ class Ppu : public Observer, public SharedRom {
|
||||
// Renders a scanline of the screen
|
||||
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
|
||||
const std::vector<uint8_t>& GetFrameBuffer() const { return frame_buffer_; }
|
||||
|
||||
Reference in New Issue
Block a user