1 // license:BSD-3-Clause
2 // copyright-holders:Krzysztof Strzecha
3 /*****************************************************************************
4  *
5  * includes/lviv.h
6  *
7  ****************************************************************************/
8 #ifndef MAME_INCLUDES_LVIV_H
9 #define MAME_INCLUDES_LVIV_H
10 
11 #pragma once
12 
13 #include "imagedev/cassette.h"
14 #include "imagedev/snapquik.h"
15 #include "machine/i8255.h"
16 #include "machine/ram.h"
17 #include "sound/spkrdev.h"
18 #include "emupal.h"
19 #include "screen.h"
20 
21 class lviv_state : public driver_device
22 {
23 public:
lviv_state(const machine_config & mconfig,device_type type,const char * tag)24 	lviv_state(const machine_config &mconfig, device_type type, const char *tag)
25 		: driver_device(mconfig, type, tag)
26 		, m_maincpu(*this, "maincpu")
27 		, m_ram(*this, RAM_TAG)
28 		, m_ppi(*this, "ppi8255_%u", 0U)
29 		, m_speaker(*this, "speaker")
30 		, m_cassette(*this, "cassette")
31 		, m_screen(*this, "screen")
32 		, m_palette(*this, "palette")
33 		, m_maincpu_region(*this, "maincpu")
34 		, m_bank(*this, "bank%u", 1U)
35 		, m_key(*this, "KEY%u", 0U)
36 		, m_joy_port(*this, "JOY")
37 	{ }
38 
39 	void lviv(machine_config &config);
40 
41 	DECLARE_INPUT_CHANGED_MEMBER(reset_button);
42 
43 private:
44 	void machine_reset() override;
45 	void machine_start() override;
46 
47 	void lviv_palette(palette_device &palette) const;
48 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
49 
50 	uint8_t io_r(offs_t offset);
51 	void io_w(offs_t offset, uint8_t data);
52 
53 	uint8_t ppi0_porta_r();
54 	uint8_t ppi0_portb_r();
55 	uint8_t ppi0_portc_r();
56 	uint8_t ppi1_porta_r();
57 	uint8_t ppi1_portb_r();
58 	uint8_t ppi1_portc_r();
59 
60 	void ppi0_porta_w(uint8_t data);
61 	void ppi0_portb_w(uint8_t data);
62 	void ppi0_portc_w(uint8_t data);
63 	void ppi1_porta_w(uint8_t data);
64 	void ppi1_portb_w(uint8_t data);
65 	void ppi1_portc_w(uint8_t data);
66 
67 	DECLARE_SNAPSHOT_LOAD_MEMBER(snapshot_cb);
68 
69 	void update_palette(uint8_t pal);
70 
71 	void update_memory();
72 	void setup_snapshot(uint8_t * data);
73 	void dump_registers();
74 	image_verify_result verify_snapshot(uint8_t * data, uint32_t size);
75 
76 	void io_map(address_map &map);
77 	void mem_map(address_map &map);
78 
79 	required_device<cpu_device> m_maincpu;
80 	required_device<ram_device> m_ram;
81 	required_device_array<i8255_device, 2> m_ppi;
82 	required_device<speaker_sound_device> m_speaker;
83 	required_device<cassette_image_device> m_cassette;
84 	required_device<screen_device> m_screen;
85 	required_device<palette_device> m_palette;
86 	required_memory_region m_maincpu_region;
87 	required_memory_bank_array<4> m_bank;
88 	required_ioport_array<12> m_key;
89 	required_ioport m_joy_port;
90 
91 	uint8_t* m_vram;
92 	uint16_t m_colortable[1][4];
93 	uint8_t m_ppi_port_outputs[2][3];
94 	uint8_t m_startup_mem_map;
95 
96 	/*----------- defined in video/lviv.c -----------*/
97 	static const rgb_t s_palette[8];
98 };
99 
100 #endif // MAME_INCLUDES_LVIV_H
101