|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.9 root 7: //
8: // PIO/PPI (i8255)
9: //
10:
1.1 root 11: #pragma once
12:
1.1.1.10! root 13: #include "device.h"
1.1.1.9 root 14: #include "monitor.h"
1.1 root 15:
16: // Intel 82C55 の仕様書にはコントロールポートからの読み出しは明記してある。
17: // NEC uPD8255 の仕様書にはコントロールポートからの読み出しについての記載が
18: // ない (禁止とも書いてない)。
1.1.1.7 root 19: class i8255Device : public IODevice
1.1 root 20: {
1.1.1.2 root 21: using inherited = IODevice;
1.1 root 22:
23: public:
1.1.1.7 root 24: i8255Device(const std::string& objname_);
1.1.1.5 root 25: virtual ~i8255Device() override;
1.1 root 26:
1.1.1.9 root 27: void ResetHard(bool poweron) override;
1.1.1.4 root 28:
1.1 root 29: protected:
30: // コントロールポートの読み出し
31: uint32 ReadCtrl() const { return ctrl; }
32: // コントロールポートへの書き込み
33: void WriteCtrl(uint32);
34: // PortC への個別書き込み
1.1.1.9 root 35: virtual void SetPC(int, int) = 0;
1.1 root 36:
37: // 7 6 5 4 3 2 1 0
38: // 1 AM AM AD CHD BM BD CLD
39: // | | | | | | +--- ポートC下位グループの方向。入力なら1
40: // | | | | | +------ ポートB の方向。入力なら1
41: // | | | | +--------- ポートB のモード。
42: // | | | +------------- ポートC上位グループの方向。入力なら1
43: // | | +---------------- ポートA の方向。入力なら1
44: // +--+------------------- ポートA のモード。
45: uint8 ctrl = 0; // コントロールポートの値
46:
47: static const uint DIR_IN = 1;
48: static const uint DIR_OUT = 0;
49: // グループA/B (ポートA/B) のモード
50: uint GetGroupAMode() const { return (ctrl >> 5) & 3; }
51: uint GetGroupBMode() const { return (ctrl >> 2) & 1; }
52: // ポート A/B/C上位/C下位 の入出力方向
53: uint PortADir() const { return (ctrl & 0x10) ? DIR_IN : DIR_OUT; }
54: uint PortBDir() const { return (ctrl & 0x02) ? DIR_IN : DIR_OUT; }
55: uint PortCHDir() const { return (ctrl & 0x08) ? DIR_IN : DIR_OUT; }
56: uint PortCLDir() const { return (ctrl & 0x01) ? DIR_IN : DIR_OUT; }
57: };
58:
59:
1.1.1.7 root 60: class PPIDevice : public i8255Device
1.1 root 61: {
1.1.1.2 root 62: using inherited = i8255Device;
1.1.1.9 root 63:
1.1 root 64: static const int baseaddr = 0xe9a000;
65:
66: public:
67: PPIDevice();
1.1.1.5 root 68: virtual ~PPIDevice() override;
1.1 root 69:
1.1.1.10! root 70: // ADPCM のサンプリングレートの 2bit を取得する
! 71: uint8 GetADPCMRate() const { return adpcm_rate; }
! 72:
1.1 root 73: protected:
74: // BusIO インタフェース
75: static const uint32 NPORT = 4;
1.1.1.6 root 76: uint64 Read(uint32 offset);
77: uint64 Write(uint32 offset, uint32 data);
78: uint64 Peek(uint32 offset);
1.1.1.9 root 79:
80: private:
81: void SetPC(int, int) override;
1.1.1.10! root 82:
! 83: bool pan_left {};
! 84: bool pan_right {};
! 85: uint adpcm_rate {};
1.1 root 86: };
87:
1.1.1.7 root 88: class PIO0Device : public i8255Device
1.1 root 89: {
1.1.1.2 root 90: using inherited = i8255Device;
1.1 root 91: public:
92: PIO0Device();
1.1.1.5 root 93: virtual ~PIO0Device() override;
1.1 root 94:
1.1.1.2 root 95: bool Init() override;
1.1.1.3 root 96:
1.1.1.9 root 97: // DIPSW #1-1 が Up なら true を返す (ROM エミュレーション用)
98: bool IsDIPSW11Up() const { return dipsw1[0]; }
1.1 root 99:
100: protected:
101: // BusIO インタフェース
102: static const uint32 NPORT = 4;
1.1.1.6 root 103: uint64 Read(uint32 offset);
104: uint64 Write(uint32 offset, uint32 data);
105: uint64 Peek(uint32 offset);
1.1 root 106:
107: private:
108: uint32 GetPA() const;
109: uint32 GetPB() const;
110: uint32 GetPC() const;
1.1.1.2 root 111: void SetPC(int, int) override;
1.1 root 112:
1.1.1.7 root 113: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
114:
1.1 root 115: bool dipsw1[8] {};
116: bool dipsw2[8] {};
1.1.1.8 root 117: bool msb_first {}; // DIP-SW の1番が MSB なら true (LUNA88K)
1.1.1.4 root 118: bool int1rq {}; // $01 INT1 割り込み要求
119: bool int1en {}; // $04 INT1 割り込み許可
120: bool int5rq {}; // $08 INT5 割り込み要求
121: bool int5en {}; // $10 INT5 割り込み許可
122: bool parity {}; // $40 パリティ有効/無効
123: bool xp_reset {}; // $80 XP リセット
1.1.1.7 root 124:
125: Monitor monitor { this };
1.1 root 126: };
127:
1.1.1.7 root 128: class PIO1Device : public i8255Device
1.1 root 129: {
1.1.1.2 root 130: using inherited = i8255Device;
1.1 root 131: public:
132: PIO1Device();
1.1.1.5 root 133: virtual ~PIO1Device() override;
1.1 root 134:
1.1.1.9 root 135: void ResetHard(bool poweron) override;
1.1.1.4 root 136:
1.1 root 137: protected:
138: // BusIO インタフェース
139: static const uint32 NPORT = 4;
1.1.1.6 root 140: uint64 Read(uint32 offset);
141: uint64 Write(uint32 offset, uint32 data);
142: uint64 Peek(uint32 offset);
1.1 root 143:
144: private:
1.1.1.2 root 145: void SetPC(int, int) override;
1.1 root 146:
1.1.1.4 root 147: bool power {}; // パワーダウン (false で電源オフ指示)
148: bool xp_intreq {}; // XP 割り込み要求。あり(true)なら %0
1.1 root 149: };
150:
1.1.1.9 root 151: extern PPIDevice *gPPI;
152: extern PIO0Device *gPIO0;
153: extern PIO1Device *gPIO1;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.