|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // NEWS の各種制御ポート(?)
9: //
10:
11: #pragma once
12:
13: #include "device.h"
14: #include "event.h"
15: #include <array>
16:
17: class DipswDevice;
18: class NewsInterrupt;
19:
20: class NewsCtlrDevice : public IODevice
21: {
22: using inherited = IODevice;
23:
24: public:
25: // LED 種別
26: static const uint LED_GREEN = 0x01;
27: static const uint LED_ORANGE = 0x02;
28:
29: public:
30: NewsCtlrDevice();
31: ~NewsCtlrDevice() override;
32:
33: bool Init() override;
34: void ResetHard(bool poweron) override;
35:
36: uint64 Read8(uint32 addr) override;
37: uint64 Write8(uint32 addr, uint32 data) override;
38: uint64 Peek8(uint32 addr) override;
39:
1.1.1.2 ! root 40: uint GetLED() const { return led; }
1.1 root 41:
42: private:
43: uint8 GetIDROM(uint32 addr) const;
44: uint8 GetDIPSW() const;
45: void WriteLED(uint32 data);
46: void WriteTimer(uint32 data);
47: void TimerCallback(Event&);
48: void ChangeInterrupt();
49:
50: // 割り込みコントローラ
51: NewsInterrupt *interrupt {};
52:
53: // 256 x 4bit ROM (ここではデータをバイト単位で保持する)
54: std::array<uint8, 128> oidrom {};
55:
1.1.1.2 ! root 56: uint led {};
1.1 root 57: // タイマー
58: bool timer_intr {};
59: bool timer_enable {};
60:
61: DipswDevice *dipsw {};
62:
63: Event timer_event { this };
64: };
65:
66: static inline NewsCtlrDevice *GetNewsCtlrDevice() {
67: return Object::GetObject<NewsCtlrDevice>(OBJ_NEWSCTLR);
68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.