--- nono/vm/adpcm.h 2026/04/29 17:05:14 1.1 +++ nono/vm/adpcm.h 2026/04/29 17:05:51 1.1.1.5 @@ -11,13 +11,15 @@ #pragma once #include "device.h" -#include "event.h" + +class DMACDevice; +class PPIDevice; class ADPCMDevice : public IODevice { using inherited = IODevice; - static const int baseaddr = 0xe92000; + static const uint32 baseaddr = 0xe92000; static const uint8 STAT_PLAY = 0x80; @@ -27,8 +29,9 @@ class ADPCMDevice : public IODevice public: ADPCMDevice(); - virtual ~ADPCMDevice() override; + ~ADPCMDevice() override; + bool Init() override; void ResetHard(bool poweron) override; // CT1 によるクロック切り替え。OPM から呼ばれる。 @@ -41,21 +44,27 @@ class ADPCMDevice : public IODevice protected: // BusIO インタフェース static const uint32 NPORT = 2; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); + bool PokePort(uint32 offset, uint32 data); private: void StartPlay(); - void EventCallback(Event&); + void EventCallback(Event *); bool playing {}; bool dack {}; int clk {}; int div {}; - Event event { this }; + DMACDevice *dmac {}; + PPIDevice *ppi {}; + + Event *event {}; }; -extern ADPCMDevice *gADPCM; +static inline ADPCMDevice *GetADPCMDevice() { + return Object::GetObject(OBJ_ADPCM); +}