1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 #ifndef MAME_INCLUDES_PACLAND_H
4 #define MAME_INCLUDES_PACLAND_H
5 
6 #pragma once
7 
8 #include "cpu/m6800/m6801.h"
9 #include "sound/namco.h"
10 #include "emupal.h"
11 #include "screen.h"
12 #include "tilemap.h"
13 
14 class pacland_state : public driver_device
15 {
16 public:
pacland_state(const machine_config & mconfig,device_type type,const char * tag)17 	pacland_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_mcu(*this, "mcu"),
21 		m_cus30(*this, "namco"),
22 		m_gfxdecode(*this, "gfxdecode"),
23 		m_screen(*this, "screen"),
24 		m_palette(*this, "palette"),
25 		m_videoram(*this, "videoram"),
26 		m_videoram2(*this, "videoram2"),
27 		m_spriteram(*this, "spriteram"),
28 		m_color_prom(*this, "proms"),
29 		m_leds(*this, "led%u", 0U)
30 	{ }
31 
32 	required_device<cpu_device> m_maincpu;
33 	required_device<hd63701v0_cpu_device> m_mcu;
34 	required_device<namco_cus30_device> m_cus30;
35 	required_device<gfxdecode_device> m_gfxdecode;
36 	required_device<screen_device> m_screen;
37 	required_device<palette_device> m_palette;
38 
39 	required_shared_ptr<uint8_t> m_videoram;
40 	required_shared_ptr<uint8_t> m_videoram2;
41 	required_shared_ptr<uint8_t> m_spriteram;
42 	required_region_ptr<uint8_t> m_color_prom;
43 
44 	output_finder<2> m_leds;
45 
46 	uint8_t m_palette_bank;
47 	tilemap_t *m_bg_tilemap;
48 	tilemap_t *m_fg_tilemap;
49 	bitmap_ind16 m_fg_bitmap;
50 	bitmap_ind16 m_sprite_bitmap;
51 	std::unique_ptr<uint32_t[]> m_transmask[3];
52 	uint16_t m_scroll0;
53 	uint16_t m_scroll1;
54 	uint8_t m_main_irq_mask;
55 	uint8_t m_mcu_irq_mask;
56 
57 	void subreset_w(offs_t offset, uint8_t data);
58 	void flipscreen_w(offs_t offset, uint8_t data);
59 	uint8_t input_r(offs_t offset);
60 	void coin_w(uint8_t data);
61 	void led_w(uint8_t data);
62 	void irq_1_ctrl_w(offs_t offset, uint8_t data);
63 	void irq_2_ctrl_w(offs_t offset, uint8_t data);
64 	void videoram_w(offs_t offset, uint8_t data);
65 	void videoram2_w(offs_t offset, uint8_t data);
66 	void scroll0_w(offs_t offset, uint8_t data);
67 	void scroll1_w(offs_t offset, uint8_t data);
68 	void bankswitch_w(uint8_t data);
69 
70 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
71 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
72 
73 	virtual void machine_start() override;
74 	virtual void video_start() override;
75 	void pacland_palette(palette_device &palette);
76 
77 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
78 
79 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
80 	void switch_palette();
81 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int whichmask);
82 	void draw_fg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
83 	void pacland(machine_config &config);
84 	void main_map(address_map &map);
85 	void mcu_map(address_map &map);
86 };
87 
88 #endif // MAME_INCLUDES_PACLAND_H
89