1 // license:BSD-3-Clause
2 // copyright-holders:AJR
3 /***********************************************************************************************************************************
4 
5     Skeleton driver for Wyse WY-55 and related terminals.
6 
7     The WY-55's custom video gate array is numbered 211019-05. The WY-185 is believed to run on similar hardware, though with
8     85 Hz and 60 Hz vertical refresh rates rather than 80 Hz and 70 Hz.
9 
10 ***********************************************************************************************************************************/
11 
12 #include "emu.h"
13 #include "cpu/mcs51/mcs51.h"
14 //#include "machine/ins8250.h"
15 #include "machine/nvram.h"
16 #include "screen.h"
17 
18 class wy55_state : public driver_device
19 {
20 public:
wy55_state(const machine_config & mconfig,device_type type,const char * tag)21 	wy55_state(const machine_config &mconfig, device_type type, const char *tag)
22 		: driver_device(mconfig, type, tag)
23 		, m_maincpu(*this, "maincpu")
24 		, m_screen(*this, "screen")
25 		, m_progbank(*this, "progbank")
26 	{
27 	}
28 
29 	void wy55(machine_config &config);
30 
31 protected:
32 	virtual void machine_start() override;
33 	virtual void driver_start() override;
34 
35 private:
36 	u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
37 
38 	void prog_map(address_map &map);
39 	void ext_map(address_map &map);
40 
41 	required_device<mcs51_cpu_device> m_maincpu;
42 	required_device<screen_device> m_screen;
43 	required_memory_bank m_progbank;
44 };
45 
46 
machine_start()47 void wy55_state::machine_start()
48 {
49 	m_progbank->configure_entries(0, 2, memregion("program")->base(), 0x10000);
50 	m_progbank->set_entry(0);
51 }
52 
screen_update(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)53 u32 wy55_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
54 {
55 	return 0;
56 }
57 
prog_map(address_map & map)58 void wy55_state::prog_map(address_map &map)
59 {
60 	map(0x0000, 0xffff).bankr("progbank");
61 }
62 
ext_map(address_map & map)63 void wy55_state::ext_map(address_map &map)
64 {
65 	map(0x0000, 0x1fff).ram().share("nvram0");
66 	map(0x8000, 0x9fff).ram().share("nvram1");
67 	map(0xa000, 0xbfff).ram().share("fontram");
68 	//map(0xf028, 0xf037).rw("uart", FUNC(pc16552_device::read), FUNC(pc16552_device::write));
69 }
70 
71 
INPUT_PORTS_START(wy55)72 static INPUT_PORTS_START(wy55)
73 INPUT_PORTS_END
74 
75 void wy55_state::wy55(machine_config &config)
76 {
77 	I8032(config, m_maincpu, 14.7456_MHz_XTAL);
78 	m_maincpu->set_addrmap(AS_PROGRAM, &wy55_state::prog_map);
79 	m_maincpu->set_addrmap(AS_IO, &wy55_state::ext_map);
80 	m_maincpu->port_out_cb<1>().set_membank("progbank").bit(2);
81 
82 	NVRAM(config, "nvram0", nvram_device::DEFAULT_ALL_0); // 8K SRAM + battery
83 	NVRAM(config, "nvram1", nvram_device::DEFAULT_ALL_0); // 8K SRAM + battery
84 
85 	//PC16552D(config, "uart", 14.7456_MHz_XTAL / 2); // 16C452 (divider not verified)
86 
87 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
88 	m_screen->set_raw(49.4235_MHz_XTAL, 1575, 0, 1188, 448, 0, 416);
89 	//m_screen->set_raw(49.4235_MHz_XTAL * 2 / 3, 1050, 0, 800, 392, 0, 338);
90 	m_screen->set_screen_update(FUNC(wy55_state::screen_update));
91 }
92 
93 
94 ROM_START(wy55)
95 	ROM_REGION(0x20000, "program", 0)
CRC(efe41862)96 	ROM_LOAD("251352-12.bin", 0x0000, 0x20000, CRC(efe41862) SHA1(52ee76d636b166fa10a37356aef81011a9b079cc)) // v2.1
97 ROM_END
98 
99 void wy55_state::driver_start()
100 {
101 	uint8_t *rom = memregion("program")->base();
102 	for (offs_t base = 0x00000; base < 0x20000; base += 0x4000)
103 	{
104 		std::vector<uint8_t> orig(&rom[base], &rom[base + 0x4000]);
105 
106 		for (offs_t offset = 0; offset < 0x4000; offset++)
107 			rom[base | offset] = bitswap<8>(orig[bitswap<14>(offset, 3, 8, 2, 0, 7, 4, 9, 10, 11, 12, 13, 5, 1, 6)], 3, 4, 5, 2, 6, 1, 7, 0);
108 	}
109 }
110 
111 COMP(1993, wy55, 0, 0, wy55, wy55, wy55_state, empty_init, "Wyse Technology", "WY-55 (v2.1)", MACHINE_IS_SKELETON)
112