diff --git a/devices/awacs.h b/devices/awacs.h index e7b5822..83d3205 100644 --- a/devices/awacs.h +++ b/devices/awacs.h @@ -144,8 +144,8 @@ private: int auto_inc; }; - -class AwacsScreamer : public AwacsBase, public DMACallback { +/** AWACs Screamer sound codec. */ +class AwacsScreamer : public AwacsBase { public: AwacsScreamer(); ~AwacsScreamer(); @@ -153,7 +153,6 @@ public: uint32_t snd_ctrl_read(uint32_t offset, int size); void snd_ctrl_write(uint32_t offset, uint32_t value, int size); - /* DMACallback methods */ void dma_start(); void dma_end(); diff --git a/devices/dbdma.cpp b/devices/dbdma.cpp index 184eb21..f813b25 100644 --- a/devices/dbdma.cpp +++ b/devices/dbdma.cpp @@ -29,6 +29,12 @@ along with this program. If not, see . #include #include +void DMAChannel::set_callbacks(DbdmaCallback start_cb, DbdmaCallback stop_cb) +{ + this->start_cb = start_cb; + this->stop_cb = stop_cb; +} + void DMAChannel::get_next_cmd(uint32_t cmd_addr, DMACmd* p_cmd) { /* load DMACmd from physical memory */ memcpy((uint8_t*)p_cmd, mmu_get_dma_mem(cmd_addr, 16), 16); @@ -241,7 +247,7 @@ void DMAChannel::start() this->queue_len = 0; - this->dma_cb->dma_start(); + this->start_cb(); } void DMAChannel::resume() { @@ -259,5 +265,5 @@ void DMAChannel::abort() { void DMAChannel::pause() { LOG_F(INFO, "Pausing DMA channel"); - this->dma_cb->dma_end(); + this->stop_cb(); } diff --git a/devices/dbdma.h b/devices/dbdma.h index 53e9a30..2b2d743 100644 --- a/devices/dbdma.h +++ b/devices/dbdma.h @@ -31,6 +31,7 @@ along with this program. If not, see . #include "dmacore.h" #include +#include /** DBDMA Channel registers offsets */ enum DMAReg : uint32_t { @@ -60,21 +61,14 @@ typedef struct DMACmd { uint16_t xfer_stat; } DMACmd; -class DMACallback { -public: - virtual void dma_start(void) = 0; - virtual void dma_end(void) = 0; - //virtual void dma_push(uint8_t *buf, int size) = 0; - //virtual void dma_pull(uint8_t *buf, int size) = 0; -}; +typedef std::function DbdmaCallback; class DMAChannel : public DmaOutChannel { public: - DMAChannel(DMACallback* cb) { - this->dma_cb = cb; - }; + DMAChannel() = default; ~DMAChannel() = default; + void set_callbacks(DbdmaCallback start_cb, DbdmaCallback stop_cb); uint32_t reg_read(uint32_t offset, int size); void reg_write(uint32_t offset, uint32_t value, int size); @@ -91,7 +85,9 @@ protected: void pause(void); private: - DMACallback* dma_cb = 0; + std::function start_cb; // DMA channel start callback + std::function stop_cb; // DMA channel stop callback + uint16_t ch_stat = 0; uint32_t cmd_ptr = 0; diff --git a/devices/heathrow.cpp b/devices/heathrow.cpp index 0958395..f8fc229 100644 --- a/devices/heathrow.cpp +++ b/devices/heathrow.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-20 divingkatae and maximum +Copyright (C) 2018-21 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -25,13 +25,14 @@ along with this program. If not, see . #include "macio.h" #include "viacuda.h" #include +#include #include #include #include /** Heathrow Mac I/O device emulation. - Author: Max Poliakovski 2019 + Author: Max Poliakovski */ using namespace std; @@ -42,9 +43,14 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow") { this->viacuda = new ViaCuda(); gMachineObj->add_subdevice("ViaCuda", this->viacuda); + // initialize sound chip and its DMA output channel, then wire them together this->screamer = new AwacsScreamer(); - this->snd_out_dma = new DMAChannel(this->screamer); + this->snd_out_dma = new DMAChannel(); this->screamer->set_dma_out(this->snd_out_dma); + this->snd_out_dma->set_callbacks( + std::bind(&AwacsScreamer::dma_start, this->screamer), + std::bind(&AwacsScreamer::dma_end, this->screamer) + ); this->mesh = new MESHController(HeathrowMESHID); }