PPU upgrades, move Memory to own dir

This commit is contained in:
scawful
2023-08-27 15:24:27 -04:00
parent 190917ff6f
commit 5a4ecc5b20
14 changed files with 318 additions and 334 deletions

View File

@@ -1,11 +1,17 @@
#include <SDL_mixer.h>
#include <cstdint>
#include <memory>
#include <string>
#include <thread>
#include "app/emu/audio/apu.h"
#include "app/emu/audio/spc700.h"
#include "app/emu/clock.h"
#include "app/emu/cpu.h"
#include "app/emu/debug/debugger.h"
#include "app/emu/memory/dma.h"
#include "app/emu/memory/memory.h"
#include "app/emu/video/ppu.h"
#include "app/rom.h"
@@ -13,52 +19,6 @@ namespace yaze {
namespace app {
namespace emu {
// Direct Memory Address
class DMA {
public:
DMA() {
// Initialize DMA and HDMA channels
for (int i = 0; i < 8; ++i) {
channels[i].DMAPn = 0;
channels[i].BBADn = 0;
channels[i].UNUSEDn = 0;
channels[i].A1Tn = 0xFFFFFF;
channels[i].DASn = 0xFFFF;
channels[i].A2An = 0xFFFF;
channels[i].NLTRn = 0xFF;
}
}
// DMA Transfer Modes
enum class DMA_TRANSFER_TYPE {
OAM,
PPUDATA,
CGDATA,
FILL_VRAM,
CLEAR_VRAM,
RESET_VRAM
};
// Functions for handling DMA and HDMA transfers
void StartDMATransfer(uint8_t channels);
void EnableHDMATransfers(uint8_t channels);
// Structure for DMA and HDMA channel registers
struct Channel {
uint8_t DMAPn; // DMA/HDMA parameters
uint8_t BBADn; // B-bus address
uint8_t UNUSEDn; // Unused byte
uint32_t A1Tn; // DMA Current Address / HDMA Table Start Address
uint16_t DASn; // DMA Byte-Counter / HDMA indirect table address
uint16_t A2An; // HDMA Table Current Address
uint8_t NLTRn; // HDMA Line-Counter
};
Channel channels[8];
uint8_t MDMAEN = 0; // Start DMA transfer
uint8_t HDMAEN = 0; // Enable HDMA transfers
};
class SNES : public DMA {
public:
SNES() = default;
@@ -118,13 +78,13 @@ class SNES : public DMA {
ROMInfo rom_info_;
Debugger debugger;
// Currently loaded ROM
std::vector<uint8_t> rom_data;
// Byte flag to indicate if the VBlank routine should be executed or not
std::atomic<bool> v_blank_flag_;
// 32-bit counter to track the number of NMI interrupts (useful for clocks and
// timers)
// 32-bit counter to track the number of NMI interrupts
std::atomic<uint32_t> frame_counter_;
// Other private member variables