spectrusty_peripherals/bus/ay/
serial128.rs

1/*
2    Copyright (C) 2020-2022  Rafal Michalski
3
4    This file is part of SPECTRUSTY, a Rust library for building emulators.
5
6    For the full copyright notice, see the lib.rs file.
7*/
8//! A collection of custom [Ay3_891xBusDevice] types for Spectrum's 128k with [SerialPorts128].
9use core::fmt;
10use spectrusty_core::bus::BusDevice;
11use crate::ay::{AyIoNullPort, Ay128kPortDecode};
12pub use crate::ay::serial128::SerialPorts128;
13pub use crate::serial::{NullSerialPort, Rs232Io, SerialKeypad};
14use super::Ay3_891xBusDevice;
15
16
17/// This type implements a [BusDevice][spectrusty_core::bus::BusDevice] emulating AY-3-8912 with an extension
18/// [keypad][SerialKeypad].
19pub type Ay3_8912Keypad<D> = Ay3_891xBusDevice<
20                                                Ay128kPortDecode,
21                                                SerialPorts128<
22                                                    SerialKeypad<<D as BusDevice>::Timestamp>,
23                                                    NullSerialPort<<D as BusDevice>::Timestamp>
24                                                >,
25                                                AyIoNullPort<<D as BusDevice>::Timestamp>, D>;
26
27/// This type implements a [BusDevice][spectrusty_core::bus::BusDevice] emulating AY-3-8912 with a [RS-232][Rs232Io]
28/// communication.
29pub type Ay3_8912Rs232<D, R, W> = Ay3_891xBusDevice<
30                                                Ay128kPortDecode,
31                                                SerialPorts128<
32                                                    NullSerialPort<<D as BusDevice>::Timestamp>,
33                                                    Rs232Io<<D as BusDevice>::Timestamp, R, W>
34                                                >,
35                                                AyIoNullPort<<D as BusDevice>::Timestamp>, D>;
36
37/// This type implements a [BusDevice][spectrusty_core::bus::BusDevice] emulating AY-3-8912 with extension
38/// [keypad][SerialKeypad] and [RS-232][Rs232Io] communication.
39pub type Ay3_8912KeypadRs232<D, R, W> = Ay3_891xBusDevice<
40                                                Ay128kPortDecode,
41                                                SerialPorts128<
42                                                    SerialKeypad<<D as BusDevice>::Timestamp>,
43                                                    Rs232Io<<D as BusDevice>::Timestamp, R, W>
44                                                >,
45                                                AyIoNullPort<<D as BusDevice>::Timestamp>, D>;
46
47impl<D: BusDevice> fmt::Display for Ay3_8912Keypad<D> {
48    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49        f.write_str("AY-3-8912 + Keypad")
50    }
51}
52
53impl<D: BusDevice, R, W> fmt::Display for Ay3_8912Rs232<D, R, W> {
54    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55        f.write_str("AY-3-8912 + RS-232")
56    }
57}
58
59impl<D: BusDevice, R, W> fmt::Display for Ay3_8912KeypadRs232<D, R, W> {
60    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61        f.write_str("AY-3-8912 + Keypad + RS-232")
62    }
63}