1 // license:BSD-3-Clause
2 // copyright-holders:Miodrag Milanovic, Robbbert
3 /***************************************************************************
4
5 PK-8000
6
7 18/07/2009 Mostly working driver
8 12/05/2009 Skeleton driver.
9
10 ****************************************************************************/
11
12 #include "emu.h"
13 #include "includes/pk8000.h"
14
15 #include "cpu/i8085/i8085.h"
16 #include "machine/i8255.h"
17 #include "imagedev/cassette.h"
18 #include "sound/spkrdev.h"
19 #include "machine/ram.h"
20
21 #include "screen.h"
22 #include "speaker.h"
23
24 #include "formats/fmsx_cas.h"
25
26
27 class pk8000_state : public pk8000_base_state
28 {
29 public:
pk8000_state(const machine_config & mconfig,device_type type,const char * tag)30 pk8000_state(const machine_config &mconfig, device_type type, const char *tag)
31 : pk8000_base_state(mconfig, type, tag)
32 , m_cassette(*this, "cassette")
33 , m_ram(*this, RAM_TAG)
34 , m_speaker(*this, "speaker")
35 , m_region_maincpu(*this, "maincpu")
36 , m_banks(*this, "bank%u", 0U)
37 , m_io_joy1(*this, "JOY1")
38 , m_io_joy2(*this, "JOY2")
39 , m_keyboard(*this, "LINE%u", 0U)
40 { }
41
42 void pk8000(machine_config &config);
43
44 private:
45 u8 m_keyboard_line;
46
47 u8 joy_1_r();
48 u8 joy_2_r();
49 void _80_porta_w(u8 data);
50 u8 _80_portb_r();
51 void _80_portc_w(u8 data);
52
53 virtual void machine_start() override;
54 virtual void machine_reset() override;
55
56 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
57
58 INTERRUPT_GEN_MEMBER(interrupt);
59 IRQ_CALLBACK_MEMBER(irq_callback);
60
61 void pk8000_io(address_map &map);
62 void pk8000_mem(address_map &map);
63
64 required_device<cassette_image_device> m_cassette;
65 required_device<ram_device> m_ram;
66 required_device<speaker_sound_device> m_speaker;
67 required_memory_region m_region_maincpu;
68 required_memory_bank_array<8> m_banks;
69 required_ioport m_io_joy1;
70 required_ioport m_io_joy2;
71 required_ioport_array<10> m_keyboard;
72
73 void set_bank(u8 data);
74 };
75
76
77
set_bank(u8 data)78 void pk8000_state::set_bank(u8 data)
79 {
80 u8 *rom = m_region_maincpu->base();
81 u8 *ram = m_ram->pointer();
82 u8 block1 = data & 3;
83 u8 block2 = (data >> 2) & 3;
84 u8 block3 = (data >> 4) & 3;
85 u8 block4 = (data >> 6) & 3;
86
87 switch(block1) {
88 case 0:
89 m_banks[0]->set_base(rom);
90 m_banks[4]->set_base(ram);
91 break;
92 case 1: break;
93 case 2: break;
94 case 3:
95 m_banks[0]->set_base(ram);
96 m_banks[4]->set_base(ram);
97 break;
98 }
99
100 switch(block2) {
101 case 0:
102 m_banks[1]->set_base(rom + 0x4000);
103 m_banks[5]->set_base(ram + 0x4000);
104 break;
105 case 1: break;
106 case 2: break;
107 case 3:
108 m_banks[1]->set_base(ram + 0x4000);
109 m_banks[5]->set_base(ram + 0x4000);
110 break;
111 }
112 switch(block3) {
113 case 0:
114 m_banks[2]->set_base(rom + 0x8000);
115 m_banks[6]->set_base(ram + 0x8000);
116 break;
117 case 1: break;
118 case 2: break;
119 case 3:
120 m_banks[2]->set_base(ram + 0x8000);
121 m_banks[6]->set_base(ram + 0x8000);
122 break;
123 }
124 switch(block4) {
125 case 0:
126 m_banks[3]->set_base(rom + 0xc000);
127 m_banks[7]->set_base(ram + 0xc000);
128 break;
129 case 1: break;
130 case 2: break;
131 case 3:
132 m_banks[3]->set_base(ram + 0xc000);
133 m_banks[7]->set_base(ram + 0xc000);
134 break;
135 }
136 }
_80_porta_w(u8 data)137 void pk8000_state::_80_porta_w(u8 data)
138 {
139 set_bank(data);
140 }
141
_80_portb_r()142 u8 pk8000_state::_80_portb_r()
143 {
144 if(m_keyboard_line>9) {
145 return 0xff;
146 }
147 return m_keyboard[m_keyboard_line]->read();
148 }
149
_80_portc_w(u8 data)150 void pk8000_state::_80_portc_w(u8 data)
151 {
152 m_keyboard_line = data & 0x0f;
153
154 m_speaker->level_w(BIT(data, 7));
155
156 m_cassette->change_state((BIT(data, 4)) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
157 m_cassette->output((BIT(data, 6)) ? +1.0 : 0.0);
158 }
159
joy_1_r()160 u8 pk8000_state::joy_1_r()
161 {
162 u8 retVal = (m_cassette->input() > 0.0038 ? 0x80 : 0);
163 retVal |= m_io_joy1->read() & 0x7f;
164 return retVal;
165 }
joy_2_r()166 u8 pk8000_state::joy_2_r()
167 {
168 u8 retVal = (m_cassette->input() > 0.0038 ? 0x80 : 0);
169 retVal |= m_io_joy2->read() & 0x7f;
170 return retVal;
171 }
172
pk8000_mem(address_map & map)173 void pk8000_state::pk8000_mem(address_map &map)
174 {
175 map.unmap_value_high();
176 map(0x0000, 0x3fff).bankr("bank0").bankw("bank4");
177 map(0x4000, 0x7fff).bankr("bank1").bankw("bank5");
178 map(0x8000, 0xbfff).bankr("bank2").bankw("bank6");
179 map(0xc000, 0xffff).bankr("bank3").bankw("bank7");
180 }
181
pk8000_io(address_map & map)182 void pk8000_state::pk8000_io(address_map &map)
183 {
184 map.unmap_value_high();
185 map(0x80, 0x83).rw("ppi8255_1", FUNC(i8255_device::read), FUNC(i8255_device::write));
186 map(0x84, 0x87).rw("ppi8255_2", FUNC(i8255_device::read), FUNC(i8255_device::write));
187 map(0x88, 0x88).rw(FUNC(pk8000_state::video_color_r), FUNC(pk8000_state::video_color_w));
188 map(0x8c, 0x8c).r(FUNC(pk8000_state::joy_1_r));
189 map(0x8d, 0x8d).r(FUNC(pk8000_state::joy_2_r));
190 map(0x90, 0x90).rw(FUNC(pk8000_state::text_start_r), FUNC(pk8000_state::text_start_w));
191 map(0x91, 0x91).rw(FUNC(pk8000_state::chargen_start_r), FUNC(pk8000_state::chargen_start_w));
192 map(0x92, 0x92).rw(FUNC(pk8000_state::video_start_r), FUNC(pk8000_state::video_start_w));
193 map(0x93, 0x93).rw(FUNC(pk8000_state::color_start_r), FUNC(pk8000_state::color_start_w));
194 map(0xa0, 0xbf).rw(FUNC(pk8000_state::color_r), FUNC(pk8000_state::color_w));
195 // extras for pk8002
196 //map(0x8c, 0x8f). // cassette in 2x KR1533KP11
197 //map(0x94, 0x97). // video colour
198 //map(0x98, 0x9b).w // audio KR1533TM9, KR572PA1A, 2x KR555IR8
199 //map(0x9c, 0x9f).rw("ctc", FUNC(z80ctc_device::read), FUNC(z80ctc_device::write)); // part of the audio
200 }
201
202 /* Input ports */
203 static INPUT_PORTS_START( pk8000 )
204 PORT_START("LINE0")
PORT_CODE(KEYCODE_0)205 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0)
206 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1)
207 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
208 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3)
209 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4)
210 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
211 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6)
212 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7)
213 PORT_START("LINE1")
214 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)
215 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9)
216 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA)
217 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS)
218 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP)
219 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(":") PORT_CODE(KEYCODE_QUOTE)
220 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON)
221 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_SLASH)
222 PORT_START("LINE2")
223 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE)
224 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("|") PORT_CODE(KEYCODE_BACKSLASH)
225 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE)
226 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("~") PORT_CODE(KEYCODE_TILDE)
227 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_EQUALS)
228 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("@") PORT_CODE(KEYCODE_MINUS_PAD)
229 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A)
230 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B)
231 PORT_START("LINE3")
232 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C)
233 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D)
234 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E)
235 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F)
236 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G)
237 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H)
238 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I)
239 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J)
240 PORT_START("LINE4")
241 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K)
242 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L)
243 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M)
244 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N)
245 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O)
246 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P)
247 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q)
248 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R)
249 PORT_START("LINE5")
250 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S)
251 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T)
252 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U)
253 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V)
254 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W)
255 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X)
256 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y)
257 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z)
258 PORT_START("LINE6")
259 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Rg") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)
260 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Upr") PORT_CODE(KEYCODE_LCONTROL)
261 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Graf") PORT_CODE(KEYCODE_F10)
262 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Alf") PORT_CODE(KEYCODE_F9)
263 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("???") PORT_CODE(KEYCODE_LALT)
264 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1)
265 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2)
266 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3)
267 PORT_START("LINE7")
268 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4)
269 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5)
270 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC)
271 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB)
272 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Stop") PORT_CODE(KEYCODE_F12)
273 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("VSh") PORT_CODE(KEYCODE_BACKSPACE)
274 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Sel") PORT_CODE(KEYCODE_RCONTROL)
275 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER)
276 PORT_START("LINE8")
277 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Probel") PORT_CODE(KEYCODE_SPACE)
278 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Cls") PORT_CODE(KEYCODE_HOME)
279 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Ins") PORT_CODE(KEYCODE_INSERT)
280 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Del") PORT_CODE(KEYCODE_DEL)
281 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT)
282 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP)
283 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN)
284 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT)
285 PORT_START("LINE9")
286 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Up-Left") PORT_CODE(KEYCODE_7_PAD)
287 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Down-Right") PORT_CODE(KEYCODE_3_PAD)
288 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Menu") PORT_CODE(KEYCODE_5_PAD)
289 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Begin") PORT_CODE(KEYCODE_4_PAD)
290 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("End") PORT_CODE(KEYCODE_6_PAD)
291 PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("End page") PORT_CODE(KEYCODE_PGDN)
292 PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Begin page") PORT_CODE(KEYCODE_PGUP)
293 PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
294 PORT_START("JOY1")
295 PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP) PORT_PLAYER(1)
296 PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN) PORT_PLAYER(1)
297 PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT) PORT_PLAYER(1)
298 PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1)
299 PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1)
300 PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(1)
301 PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
302 PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
303 PORT_START("JOY2")
304 PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP) PORT_PLAYER(2)
305 PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN) PORT_PLAYER(2)
306 PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT) PORT_PLAYER(2)
307 PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2)
308 PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2)
309 PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(2)
310 PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
311 PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
312 INPUT_PORTS_END
313
314 INTERRUPT_GEN_MEMBER(pk8000_state::interrupt)
315 {
316 device.execute().set_input_line(0, HOLD_LINE);
317 }
318
IRQ_CALLBACK_MEMBER(pk8000_state::irq_callback)319 IRQ_CALLBACK_MEMBER(pk8000_state::irq_callback)
320 {
321 return 0xff;
322 }
323
324
machine_start()325 void pk8000_state::machine_start()
326 {
327 save_item(NAME(m_keyboard_line));
328 save_item(NAME(m_text_start));
329 save_item(NAME(m_chargen_start));
330 save_item(NAME(m_video_start));
331 save_item(NAME(m_color_start));
332 save_item(NAME(m_video_mode));
333 save_item(NAME(m_video_color));
334 save_item(NAME(m_color));
335 save_item(NAME(m_video_enable));
336 }
337
machine_reset()338 void pk8000_state::machine_reset()
339 {
340 set_bank(0);
341 }
342
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)343 u32 pk8000_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
344 {
345 return video_update(screen, bitmap, cliprect, m_ram->pointer());
346 }
347
pk8000(machine_config & config)348 void pk8000_state::pk8000(machine_config &config)
349 {
350 /* basic machine hardware */
351 I8080(config, m_maincpu, 1780000); // pk8002 = 10'220'000 / 8
352 m_maincpu->set_addrmap(AS_PROGRAM, &pk8000_state::pk8000_mem);
353 m_maincpu->set_addrmap(AS_IO, &pk8000_state::pk8000_io);
354 m_maincpu->set_vblank_int("screen", FUNC(pk8000_state::interrupt));
355 m_maincpu->set_irq_acknowledge_callback(FUNC(pk8000_state::irq_callback));
356
357 /* video hardware */
358 screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
359 screen.set_refresh_hz(50);
360 screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
361 screen.set_size(256+32, 192+32);
362 screen.set_visarea(0, 256+32-1, 0, 192+32-1);
363 screen.set_screen_update(FUNC(pk8000_state::screen_update));
364 screen.set_palette("palette");
365
366 PALETTE(config, "palette", FUNC(pk8000_state::pk8000_palette), 16);
367
368 i8255_device &ppi1(I8255(config, "ppi8255_1"));
369 ppi1.out_pa_callback().set(FUNC(pk8000_state::_80_porta_w));
370 ppi1.in_pb_callback().set(FUNC(pk8000_state::_80_portb_r));
371 ppi1.out_pc_callback().set(FUNC(pk8000_state::_80_portc_w));
372
373 i8255_device &ppi2(I8255(config, "ppi8255_2"));
374 ppi2.in_pa_callback().set(FUNC(pk8000_state::_84_porta_r));
375 ppi2.out_pa_callback().set(FUNC(pk8000_state::_84_porta_w));
376 ppi2.out_pc_callback().set(FUNC(pk8000_state::_84_portc_w));
377
378 /* audio hardware */
379 SPEAKER(config, "mono").front_center();
380 SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.50);
381
382 CASSETTE(config, m_cassette);
383 m_cassette->set_formats(fmsx_cassette_formats);
384 m_cassette->set_default_state(CASSETTE_PLAY);
385 m_cassette->add_route(ALL_OUTPUTS, "mono", 0.05);
386
387 /* internal ram */
388 RAM(config, RAM_TAG).set_default_size("64K");
389 }
390
391 /* ROM definition */
392 ROM_START( vesta )
393 ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
394 ROM_LOAD( "vesta.rom", 0x0000, 0x4000, CRC(fbf7e2cc) SHA1(4bc5873066124bd926c3c6aa2fd1a062c87af339))
395 ROM_END
396
397 ROM_START( hobby )
398 ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
399 ROM_LOAD( "hobby.rom", 0x0000, 0x4000, CRC(a25b4b2c) SHA1(0d86e6e4be8d1aa389bfa9dd79e3604a356729f7))
400 ROM_END
401
402 ROM_START( pk8002 )
403 ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
404 // there is actually 1 rom 0000-07ff (U3) mirrored to 0800,1000,1800, then another rom 2000-27ff (U4) mirrored to 2800,3000,3800
405 ROM_LOAD( "pk8002.rom", 0x0000, 0x4000, CRC(07b9ae71) SHA1(2137a41cc095c7aba58b7b109fce63f30a4568b2))
406 ROM_END
407
408 /* Driver */
409
410 /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
411 COMP( 1987, vesta, 0, 0, pk8000, pk8000, pk8000_state, empty_init, "BP EVM", "PK8000 Vesta", MACHINE_SUPPORTS_SAVE )
412 COMP( 1987, hobby, vesta, 0, pk8000, pk8000, pk8000_state, empty_init, "BP EVM", "PK8000 Sura/Hobby", MACHINE_SUPPORTS_SAVE )
413 COMP( 1987, pk8002, vesta, 0, pk8000, pk8000, pk8000_state, empty_init, "<unknown>", "PK8002 Elf", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE )
414