1 // license:BSD-3-Clause
2 // copyright-holders:Pierpaolo Prazzoli, Barry Rodewald
3 /*************************************************************************
4 
5     Malzak
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_MALZAK_H
9 #define MAME_INCLUDES_MALZAK_H
10 
11 #pragma once
12 
13 #include "cpu/s2650/s2650.h"
14 #include "machine/s2636.h"
15 #include "video/saa5050.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 class malzak_state : public driver_device
21 {
22 public:
malzak_state(const machine_config & mconfig,device_type type,const char * tag)23 	malzak_state(const machine_config &mconfig, device_type type, const char *tag)
24 		: driver_device(mconfig, type, tag)
25 		, m_maincpu(*this, "maincpu")
26 		, m_s2636(*this, "s2636%u", 0U)
27 		, m_trom(*this, "saa5050")
28 		, m_videoram(*this, "videoram")
29 		, m_gfxdecode(*this, "gfxdecode")
30 		, m_screen(*this, "screen")
31 		, m_palette(*this, "palette")
32 		, m_mainbank(*this, "mainbank")
33 	{ }
34 
35 	void malzak(machine_config &config);
36 	void malzak2(machine_config &config);
37 
38 protected:
39 	virtual void machine_start() override;
40 	virtual void machine_reset() override;
41 
42 private:
43 	/* devices */
44 	required_device<s2650_device> m_maincpu;
45 	required_device_array<s2636_device, 2> m_s2636;
46 	required_device<saa5050_device> m_trom;
47 	required_shared_ptr<uint8_t> m_videoram;
48 	required_device<gfxdecode_device> m_gfxdecode;
49 	required_device<screen_device> m_screen;
50 	required_device<palette_device> m_palette;
51 	required_memory_bank m_mainbank;
52 
53 	uint8_t fake_VRLE_r();
54 	uint8_t s2636_portA_r();
55 	uint8_t s2650_data_r();
56 	void port40_w(uint8_t data);
57 	void port60_w(uint8_t data);
58 	void portc0_w(uint8_t data);
59 	uint8_t collision_r();
60 	void playfield_w(offs_t offset, uint8_t data);
61 	uint8_t videoram_r(offs_t offset);
62 
63 	void palette_init(palette_device &palette) const;
64 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
65 	virtual void video_start() override;
66 
67 	void malzak2_map(address_map &map);
68 	void malzak_data_map(address_map &map);
69 	void malzak_io_map(address_map &map);
70 	void malzak_map(address_map &map);
71 
72 	TILE_GET_INFO_MEMBER(get_tile_info);
73 	std::unique_ptr<bitmap_rgb32> m_trom_bitmap;
74 	std::unique_ptr<bitmap_rgb32> m_playfield_bitmap;
75 	tilemap_t *m_playfield_tilemap;
76 	int m_playfield_code[256];
77 	int m_scrollx;
78 	int m_scrolly;
79 	int m_collision_counter;
80 	u8  m_playfield_bank;
81 };
82 
83 #endif // MAME_INCLUDES_MALZAK_H
84