1 // license:BSD-3-Clause
2 // copyright-holders:Angelo Salese
3 /***************************************************************************
4
5 PC-9801 MEMSW interface
6
7 A CMOS-like interface that maps in the TVRAM area
8
9 Reference URL:
10 http://ohta.music.coocan.jp/packen/board/memsw.htm
11 Running the MON command under BASIC allows the user to change these
12 settings.
13 ssw -> for displaying current settings on screen;
14 ssw# -> to change the given #
15
16 List of settings, parenthesis for default if not zero
17 SW1 $A3FE2
18 xx-- ---- stop bit length (01)
19 --x- ---- parity specification
20 ---x ---- parity check
21 ---- xx-- data bit length (10)
22 ---- --x- communication method
23 ---- ---x X parameter
24
25 SW2 $A3FE6
26 x--- ---- S parameter
27 -x-- ---- line feed code when sending
28 --x- ---- line feed code when receiving
29 ---x ---- Japanese shift code
30 ---- xxxx transfer speed (0101)
31
32 SW3 $A3FEA
33 x--- ---- Operation when DEL code is received (input / output mode)
34 x--- ---- Operation when DEL code is received (terminal mode)
35 -x-- ---- Text screen color
36 --x- ---- Maximum operating frequency for V30 coprocessor
37 ---x ---- With or without V30 coprocessor
38 ---- x--- Coprocessor for 80286,386
39 ---- -xxx Conventional memory size (100)
40
41 SW4 $A3FEE
42 x--- ---- Expansion ROM CE000-CFFFF
43 -x-- ---- Expansion ROM CA000-CBFFF
44 --x- ---- Expansion ROM D4000-D5FFF
45 ---x ---- Expansion ROM D0000-D3FFF
46 ---- x--- Expansion ROM CC000-CFFFF
47 ---- -x-- Expansion ROM C8000-C9FFF
48 ---- --xx (Unused)
49
50 SW5 $A3FF2
51 xxxx ---- Select boot device (0000)
52 1100 ---- SCSI HDD #1
53 1011 ---- HDD #2
54 1010 ---- HDD #1
55 1000 ---- ROM BASIC
56 0110 ---- MO disk
57 0100 ---- 1MB FDD
58 0010 ---- 640K FDD
59 0000 ---- standard
60 ???? ---- ROM BASIC
61 ---- x--- Screen Hard copy color
62 ---- -x-- Use HDD user ID
63 ---- --x- Prioritize HDD with device name
64 ---- ---x PC-PR201 series used (1)
65
66 SW5 $A3FF6
67 --x- ---- Use modem-NCU control function
68 ---x ---- Extended screen hard copy function
69 ---- x--- Use monitor mode (Use extended monitor mode)
70 xx-- -xxx (Unused)
71
72
73 TODO:
74 - Is the mapping truly aligned to 2 bytes? Looks more like 4, needs real
75 HW verification.
76
77 ***************************************************************************/
78
79 #include "emu.h"
80 #include "pc9801_memsw.h"
81 #include "coreutil.h"
82
83 //**************************************************************************
84 // GLOBAL VARIABLES
85 //**************************************************************************
86
87 // device type definition
88 DEFINE_DEVICE_TYPE(PC9801_MEMSW, pc9801_memsw_device, "pc9801_memsw", "NEC PC-9801 Memory Switch device")
89
90
91 //**************************************************************************
92 // LIVE DEVICE
93 //**************************************************************************
94
95 //-------------------------------------------------
96 // pc9801_memsw_device - constructor
97 //-------------------------------------------------
98
pc9801_memsw_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)99 pc9801_memsw_device::pc9801_memsw_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
100 : device_t(mconfig, PC9801_MEMSW, tag, owner, clock),
101 device_nvram_interface(mconfig, *this)
102 {
103 }
104
105
106
107 //-------------------------------------------------
108 // device_start - device-specific startup
109 //-------------------------------------------------
110
device_start()111 void pc9801_memsw_device::device_start()
112 {
113 save_pointer(NAME(m_bram), m_bram_size);
114 }
115
116
117 //-------------------------------------------------
118 // device_reset - device-specific reset
119 //-------------------------------------------------
120
device_reset()121 void pc9801_memsw_device::device_reset()
122 {
123 }
124
125
nvram_default()126 void pc9801_memsw_device::nvram_default()
127 {
128 system_time systime;
129
130 const uint8_t default_memsw_data[0x10] =
131 {
132 0xe1, 0x48, 0xe1, 0x05,
133 0xe1, 0x04, 0xe1, 0x00,
134 0xe1, 0x01, 0xe1, 0x00,
135 0xe1, 0x00, 0xe1, 0x00
136 };
137
138 memcpy(m_bram, default_memsw_data, m_bram_size);
139
140 machine().current_datetime(systime);
141 m_bram[0xf] = dec_2_bcd(systime.local_time.year - 2000) & 0xff;
142 }
143
nvram_read(emu_file & file)144 void pc9801_memsw_device::nvram_read(emu_file &file)
145 {
146 file.read(m_bram, m_bram_size);
147 }
148
nvram_write(emu_file & file)149 void pc9801_memsw_device::nvram_write(emu_file &file)
150 {
151 file.write(m_bram, m_bram_size);
152 }
153
154 //**************************************************************************
155 // READ/WRITE HANDLERS
156 //**************************************************************************
157
read(uint8_t offset)158 uint8_t pc9801_memsw_device::read(uint8_t offset)
159 {
160 return m_bram[offset];
161 }
162
write(uint8_t offset,uint8_t data)163 void pc9801_memsw_device::write( uint8_t offset, uint8_t data )
164 {
165 m_bram[offset] = data;
166 }
167