1 // license:BSD-3-Clause
2 // copyright-holders:Wilbert Pol,Vas Crabb
3 /*****************************************************************************
4  *
5  * includes/osborne1.h
6  *
7  ****************************************************************************/
8 #ifndef MAME_INCLUDES_OSBORNE1_H
9 #define MAME_INCLUDES_OSBORNE1_H
10 
11 #pragma once
12 
13 #include "bus/ieee488/ieee488.h"
14 
15 #include "cpu/z80/z80.h"
16 
17 #include "imagedev/floppy.h"
18 
19 #include "machine/6821pia.h"
20 #include "machine/6850acia.h"
21 #include "machine/ram.h"
22 #include "machine/wd_fdc.h"
23 
24 #include "sound/spkrdev.h"
25 
26 #include "video/mc6845.h"
27 
28 #include "emupal.h"
29 #include "screen.h"
30 #include "tilemap.h"
31 
32 
33 class osborne1_state : public driver_device
34 {
35 public:
osborne1_state(const machine_config & mconfig,device_type type,const char * tag)36 	osborne1_state(const machine_config &mconfig, device_type type, const char *tag) :
37 		driver_device(mconfig, type, tag),
38 		m_ram(*this, RAM_TAG),
39 		m_screen(*this, "screen"),
40 		m_maincpu(*this, "maincpu"),
41 		m_pia0(*this, "pia_0"),
42 		m_pia1(*this, "pia_1"),
43 		m_gfxdecode(*this, "gfxdecode"),
44 		m_speaker(*this, "speaker"),
45 		m_acia(*this, "acia"),
46 		m_fdc(*this, "mb8877"),
47 		m_ieee(*this, IEEE488_TAG),
48 		m_floppy0(*this, "mb8877:0"),
49 		m_floppy1(*this, "mb8877:1"),
50 		m_keyb_row(*this, { "ROW0", "ROW1", "ROW3", "ROW4", "ROW5", "ROW2", "ROW6", "ROW7" }),
51 		m_btn_reset(*this, "RESET"),
52 		m_cnf(*this, "CNF"),
53 		m_region_maincpu(*this, "maincpu"),
54 		m_bank_0xxx(*this, "bank_0xxx"),
55 		m_bank_1xxx(*this, "bank_1xxx"),
56 		m_bank_fxxx(*this, "bank_fxxx"),
57 		m_p_chargen(*this, "chargen"),
58 		m_video_timer(nullptr),
59 		m_tilemap(nullptr),
60 		m_acia_rxc_txc_timer(nullptr)
61 	{
62 	}
63 
64 	void osborne1(machine_config &config);
65 
66 	DECLARE_INPUT_CHANGED_MEMBER(reset_key);
67 
68 protected:
69 	virtual void machine_start() override;
70 	virtual void machine_reset() override;
71 	virtual void video_start() override;
72 
73 	void osborne1_base(machine_config &config);
74 
75 	void osborne1_mem(address_map &map);
76 	void osborne1_op(address_map &map);
77 	void osborne1_io(address_map &map);
78 
79 	void bank_0xxx_w(offs_t offset, u8 data);
80 	void bank_1xxx_w(offs_t offset, u8 data);
81 	u8 bank_2xxx_3xxx_r(offs_t offset);
82 	void bank_2xxx_3xxx_w(offs_t offset, u8 data);
83 	void videoram_w(offs_t offset, u8 data);
84 	u8 opcode_r(offs_t offset);
85 	void bankswitch_w(offs_t offset, u8 data);
86 	DECLARE_WRITE_LINE_MEMBER(irqack_w);
87 
rom_mode()88 	bool rom_mode() const { return 0 != m_rom_mode; }
scroll_x()89 	u8 scroll_x() const { return m_scroll_x; }
90 
91 	template <int Width, unsigned Scale> void draw_rows(uint16_t col, bitmap_ind16 &bitmap, const rectangle &cliprect);
92 
93 	required_device<ram_device>             m_ram;
94 	required_device<screen_device>          m_screen;
95 	required_device<z80_device>             m_maincpu;
96 	required_device<pia6821_device>         m_pia0;
97 	required_device<pia6821_device>         m_pia1;
98 
99 private:
100 	u8 ieee_pia_pb_r();
101 	void ieee_pia_pb_w(u8 data);
102 	DECLARE_WRITE_LINE_MEMBER(ieee_pia_irq_a_func);
103 
104 	void video_pia_port_a_w(u8 data);
105 	void video_pia_port_b_w(u8 data);
106 	DECLARE_WRITE_LINE_MEMBER(video_pia_out_cb2_dummy);
107 	DECLARE_WRITE_LINE_MEMBER(video_pia_irq_a_func);
108 
109 	DECLARE_WRITE_LINE_MEMBER(serial_acia_irq_func);
110 
111 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
112 
113 	required_device<gfxdecode_device>       m_gfxdecode;
114 	required_device<speaker_sound_device>   m_speaker;
115 	required_device<acia6850_device>        m_acia;
116 	required_device<mb8877_device>          m_fdc;
117 	required_device<ieee488_device>         m_ieee;
118 	required_device<floppy_connector>       m_floppy0;
119 	required_device<floppy_connector>       m_floppy1;
120 
121 	TIMER_CALLBACK_MEMBER(video_callback);
122 	TIMER_CALLBACK_MEMBER(acia_rxc_txc_callback);
123 
124 	TILE_GET_INFO_MEMBER(get_tile_info);
125 
126 	bool set_rom_mode(u8 value);
127 	bool set_bit_9(u8 value);
128 	void update_irq();
129 	void update_acia_rxc_txc();
130 
131 	// user inputs
132 	required_ioport_array<8>    m_keyb_row;
133 	required_ioport             m_btn_reset;
134 
135 	// fake inputs for hardware configuration and things that need rewiring
136 	required_ioport             m_cnf;
137 
138 	// pieces of memory
139 	required_memory_region  m_region_maincpu;
140 	required_memory_bank    m_bank_0xxx;
141 	required_memory_bank    m_bank_1xxx;
142 	required_memory_bank    m_bank_fxxx;
143 	required_region_ptr<u8> m_p_chargen;
144 
145 	// configuration (reloaded on reset)
146 	u8              m_acia_rxc_txc_div;
147 	u8              m_acia_rxc_txc_p_low;
148 	u8              m_acia_rxc_txc_p_high;
149 
150 	// bank switch control bits
151 	u8              m_ub4a_q;
152 	u8              m_ub6a_q;
153 	u8              m_rom_mode;
154 	u8              m_bit_9;
155 
156 	// onboard video state
157 	u8              m_scroll_x;
158 	u8              m_scroll_y;
159 	u8              m_beep_state;
160 	emu_timer       *m_video_timer;
161 	tilemap_t       *m_tilemap;
162 
163 	// serial state
164 	u8              m_acia_irq_state;
165 	u8              m_acia_rxc_txc_state;
166 	emu_timer       *m_acia_rxc_txc_timer;
167 
168 	memory_access<16, 0, 0, ENDIANNESS_LITTLE>::cache m_mem_cache;
169 };
170 
171 
172 class osborne1sp_state : public osborne1_state
173 {
174 public:
osborne1sp_state(const machine_config & mconfig,device_type type,const char * tag)175 	osborne1sp_state(const machine_config &mconfig, device_type type, const char *tag) :
176 		osborne1_state(mconfig, type, tag)
177 	{
178 	}
179 
180 	void osborne1sp(machine_config &config);
181 
182 protected:
183 	virtual void machine_start() override;
184 	virtual void machine_reset() override;
185 
186 	void osborne1sp_mem(address_map &map);
187 
188 	u8 bank_2xxx_3xxx_r(offs_t offset);
189 	void bank_2xxx_3xxx_w(offs_t offset, u8 data);
190 
191 private:
192 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
193 
194 	// SCREEN-PAC registers
195 	u8              m_resolution;
196 	u8              m_hc_left;
197 };
198 
199 
200 class osborne1nv_state : public osborne1_state
201 {
202 public:
osborne1nv_state(const machine_config & mconfig,device_type type,const char * tag)203 	osborne1nv_state(const machine_config &mconfig, device_type type, const char *tag) :
204 		osborne1_state(mconfig, type, tag),
205 		m_palette(*this, "palette"),
206 		m_p_nuevo(*this, "nuevo")
207 	{
208 	}
209 
210 	void osborne1nv(machine_config &config);
211 
212 private:
213 	void osborne1nv_io(address_map &map);
214 
215 	MC6845_UPDATE_ROW(crtc_update_row);
216 	MC6845_ON_UPDATE_ADDR_CHANGED(crtc_update_addr_changed);
217 
218 	required_device<palette_device> m_palette;
219 	required_region_ptr<u8>         m_p_nuevo;
220 };
221 
222 #endif // MAME_INCLUDES_OSBORNE1_H
223