1 // license:BSD-3-Clause
2 // copyright-holders:AJR
3 /*******************************************************************************
4 
5     Skeleton driver for Wyse WY-30+ terminal.
6 
7     This low-end video terminal is the successor to the WY-30, whose control
8     board features an entirely different hardware configuration.
9 
10 *******************************************************************************/
11 
12 #include "emu.h"
13 #include "cpu/mcs51/mcs51.h"
14 #include "machine/eepromser.h"
15 #include "screen.h"
16 
17 class wy30p_state : public driver_device
18 {
19 public:
wy30p_state(const machine_config & mconfig,device_type type,const char * tag)20 	wy30p_state(const machine_config &mconfig, device_type type, const char *tag)
21 		: driver_device(mconfig, type, tag)
22 		, m_eeprom(*this, "eeprom")
23 		, m_screen(*this, "screen")
24 	{
25 	}
26 
27 	void wy30p(machine_config &config);
28 
29 protected:
30 	virtual void machine_start() override;
31 	virtual void driver_start() override;
32 
33 private:
34 	u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
35 
36 	u8 p3_r();
37 	u8 de00_r();
38 
39 	void prog_map(address_map &map);
40 	void ext_map(address_map &map);
41 
42 	required_device<eeprom_serial_er5911_device> m_eeprom;
43 	required_device<screen_device> m_screen;
44 };
45 
46 
machine_start()47 void wy30p_state::machine_start()
48 {
49 }
50 
screen_update(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)51 u32 wy30p_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
52 {
53 	return 0;
54 }
55 
p3_r()56 u8 wy30p_state::p3_r()
57 {
58 	return 0xdf | (m_eeprom->do_read() << 5);
59 }
60 
de00_r()61 u8 wy30p_state::de00_r()
62 {
63 	return m_screen->vblank() << 7; // probably not correct
64 }
65 
prog_map(address_map & map)66 void wy30p_state::prog_map(address_map &map)
67 {
68 	map(0x0000, 0x3fff).mirror(0xc000).rom().region("program", 0);
69 }
70 
ext_map(address_map & map)71 void wy30p_state::ext_map(address_map &map)
72 {
73 	map(0x0000, 0x1fff).ram();
74 	map(0xa000, 0xa7ff).ram();
75 	map(0xde00, 0xde00).mirror(0xff).r(FUNC(wy30p_state::de00_r));
76 }
77 
78 
INPUT_PORTS_START(wy30p)79 static INPUT_PORTS_START(wy30p)
80 INPUT_PORTS_END
81 
82 
83 void wy30p_state::wy30p(machine_config &config)
84 {
85 	i8031_device &maincpu(I8031(config, "maincpu", 7.3728_MHz_XTAL));
86 	maincpu.set_addrmap(AS_PROGRAM, &wy30p_state::prog_map);
87 	maincpu.set_addrmap(AS_IO, &wy30p_state::ext_map);
88 	maincpu.port_in_cb<3>().set(FUNC(wy30p_state::p3_r));
89 	maincpu.port_out_cb<3>().set(m_eeprom, FUNC(eeprom_serial_er5911_device::cs_write)).bit(3);
90 	maincpu.port_out_cb<3>().append(m_eeprom, FUNC(eeprom_serial_er5911_device::clk_write)).bit(4);
91 	maincpu.port_out_cb<3>().append(m_eeprom, FUNC(eeprom_serial_er5911_device::di_write)).bit(5);
92 
93 	EEPROM_ER5911_8BIT(config, m_eeprom);
94 
95 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
96 	m_screen->set_raw(31.2795_MHz_XTAL * 2 / 3, 1050, 0, 800, 331, 0, 312); // divider and dimensions guessed
97 	m_screen->set_screen_update(FUNC(wy30p_state::screen_update));
98 }
99 
100 
101 // PCB: "© 1989 990710-01 REV.B1"
102 // CPU: Intel P8031AH
103 // Program EPROM: 250971-02 (M27128MFI) "© WYSE TECH 92' REV.A"
104 // Nonvolatile memory: CSI CAT59C11P
105 // RAM: TC5565APL-12, HY6116AP-15
106 // QFP gate array: 211019-02 (Oki M76V020) "© WYSE,1989"
107 // Jumper near gate array: "FONT SIZE" = "8Kx8" or "2Kx8" (J3)
108 // XTALs: 31.2795 (dot clock?), 7.3728 (for CPU)
109 // DB-25 connectors: "MDM" & "AUX"
110 ROM_START(wy30p)
111 	ROM_REGION(0x4000, "program", 0)
112 	ROM_LOAD("250971-02.u4", 0x0000, 0x4000, CRC(3666549c) SHA1(23c432da2083df4b355daf566dd6514d1f9a7690))
113 ROM_END
114 
driver_start()115 void wy30p_state::driver_start()
116 {
117 	uint8_t *rom = memregion("program")->base();
118 	for (offs_t base = 0x0000; base < 0x4000; base += 0x2000)
119 	{
120 		std::vector<uint8_t> orig(&rom[base], &rom[base + 0x2000]);
121 
122 		// Line swaps can be confusing...
123 		for (offs_t offset = 0; offset < 0x2000; offset++)
124 			rom[base | offset] = bitswap<8>(orig[bitswap<13>(offset, 8, 5, 0, 4, 3, 9, 7, 10, 11, 12, 2, 6, 1)], 3, 4, 5, 6, 7, 2, 1, 0);
125 	}
126 }
127 
128 COMP(1992, wy30p, 0, 0, wy30p, wy30p, wy30p_state, empty_init, "Wyse Technology", "WY-30+ (v1.8)", MACHINE_IS_SKELETON)
129