|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // ADPCM (MSM6258V)
9: //
10:
11: #pragma once
12:
13: #include "device.h"
14: #include "event.h"
15:
1.1.1.2 root 16: class DMACDevice;
17: class PPIDevice;
18:
1.1 root 19: class ADPCMDevice : public IODevice
20: {
21: using inherited = IODevice;
22:
1.1.1.4 ! root 23: static const uint32 baseaddr = 0xe92000;
1.1 root 24:
25: static const uint8 STAT_PLAY = 0x80;
26:
27: static const uint8 REC_START = 0x04;
28: static const uint8 PLAY_START = 0x02;
29: static const uint8 STOP = 0x01;
30:
31: public:
32: ADPCMDevice();
1.1.1.3 root 33: ~ADPCMDevice() override;
1.1 root 34:
1.1.1.2 root 35: bool Init() override;
1.1 root 36: void ResetHard(bool poweron) override;
37:
38: // CT1 によるクロック切り替え。OPM から呼ばれる。
39: void SetClock(bool);
40:
41: // DMAC から呼ばれる。
42: void AssertDACK(bool tc);
43: void NegateDACK();
44:
45: protected:
46: // BusIO インタフェース
47: static const uint32 NPORT = 2;
1.1.1.4 ! root 48: busdata ReadPort(uint32 offset);
! 49: busdata WritePort(uint32 offset, uint32 data);
! 50: busdata PeekPort(uint32 offset);
! 51: bool PokePort(uint32 offset, uint32 data);
1.1 root 52:
53: private:
54: void StartPlay();
55:
56: void EventCallback(Event&);
57:
58: bool playing {};
59: bool dack {};
60: int clk {};
61: int div {};
62:
1.1.1.2 root 63: DMACDevice *dmac {};
64: PPIDevice *ppi {};
65:
1.1 root 66: Event event { this };
67: };
68:
1.1.1.2 root 69: static inline ADPCMDevice *GetADPCMDevice() {
70: return Object::GetObject<ADPCMDevice>(OBJ_ADPCM);
71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.