|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // DIPSW
9: //
10:
11: #pragma once
12:
13: #include "device.h"
14:
15: // DIPSW 共通クラス
16: class DipswDevice : public Device
17: {
18: using inherited = Device;
19: public:
1.1.1.2 root 20: explicit DipswDevice(int sz_);
1.1 root 21: ~DipswDevice() override;
22:
23: // 総数を返す。
24: int GetSize() const { return dipsw.size(); }
25:
26: // DIPSW n 番の値を取得/設定する。
27: // true/false の割り当て方は機種依存。
1.1.1.2 root 28: bool Get(uint n) const;
29: void Set(uint n, bool val);
1.1 root 30:
31: // DIPSW n 番の物理位置を取得/設定する。0 が上、1が下。
32: // これは GUI 用なので、値の向きはスクロールバーの position に由来。
1.1.1.2 root 33: int GetPosition(uint n) const;
34: void SetPosition(uint n, uint val);
1.1 root 35:
36: protected:
37: std::vector<bool> dipsw {};
38:
39: // 論理値と物理位置の対応。
40: // upside が true なら、上が true
41: // upside が false なら、上が false。
1.1.1.2 root 42: bool upside {};
1.1 root 43: };
44:
45: // LUNA の DIPSW
46: class LunaDipswDevice : public DipswDevice
47: {
48: using inherited = DipswDevice;
49: public:
50: LunaDipswDevice();
51: ~LunaDipswDevice() override;
52:
53: bool Init() override;
54: };
55:
56: // NEWS の DIPSW
57: class NewsDipswDevice : public DipswDevice
58: {
59: using inherited = DipswDevice;
60: public:
61: NewsDipswDevice();
62: ~NewsDipswDevice() override;
63:
64: bool Init() override;
65: };
66:
1.1.1.3 ! root 67: inline DipswDevice *GetDipswDevice() {
1.1 root 68: return Object::GetObject<DipswDevice>(OBJ_DIPSW);
69: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.