|
|
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;
1.1.1.4 root 19: class TextScreen;
1.1 root 20:
21: class NewsCtlrDevice : public IODevice
22: {
23: using inherited = IODevice;
24:
1.1.1.5 ! root 25: // システムタイマーの周期
! 26: static const uint64 TIMER_PERIOD = 10_msec;
! 27:
1.1 root 28: public:
29: // LED 種別
30: static const uint LED_GREEN = 0x01;
31: static const uint LED_ORANGE = 0x02;
32:
33: public:
34: NewsCtlrDevice();
35: ~NewsCtlrDevice() override;
36:
37: bool Init() override;
38: void ResetHard(bool poweron) override;
39:
1.1.1.4 root 40: busdata Read(busaddr addr) override;
41: busdata Write(busaddr addr, uint32 data) override;
42: busdata Peek1(uint32 addr) override;
1.1 root 43:
1.1.1.2 root 44: uint GetLED() const { return led; }
1.1 root 45:
1.1.1.3 root 46: void MonitorUpdateNewsCtlr(TextScreen& screen, int y);
47:
1.1 root 48: private:
49: uint8 GetIDROM(uint32 addr) const;
50: uint8 GetDIPSW() const;
51: void WriteLED(uint32 data);
52: void WriteTimer(uint32 data);
53: void TimerCallback(Event&);
54: void ChangeInterrupt();
55:
56: // 割り込みコントローラ
57: NewsInterrupt *interrupt {};
58:
59: // 256 x 4bit ROM (ここではデータをバイト単位で保持する)
60: std::array<uint8, 128> oidrom {};
61:
1.1.1.2 root 62: uint led {};
1.1 root 63: // タイマー
64: bool timer_intr {};
65: bool timer_enable {};
66:
1.1.1.5 ! root 67: // システムタイマーが刻んている時刻。
! 68: uint64 stime {};
! 69:
! 70: // システムタイマーを実時間に同期する場合 true
! 71: bool sync_rt {};
! 72:
1.1 root 73: DipswDevice *dipsw {};
74:
75: Event timer_event { this };
76: };
77:
78: static inline NewsCtlrDevice *GetNewsCtlrDevice() {
79: return Object::GetObject<NewsCtlrDevice>(OBJ_NEWSCTLR);
80: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.