1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_NAMCOS86_H
4 #define MAME_INCLUDES_NAMCOS86_H
5 
6 #pragma once
7 
8 #include "cpu/m6800/m6801.h"
9 #include "machine/watchdog.h"
10 #include "sound/n63701x.h"
11 #include "sound/namco.h"
12 #include "emupal.h"
13 #include "tilemap.h"
14 
15 class namcos86_state : public driver_device
16 {
17 public:
namcos86_state(const machine_config & mconfig,device_type type,const char * tag)18 	namcos86_state(const machine_config &mconfig, device_type type, const char *tag)
19 		: driver_device(mconfig, type, tag)
20 		, m_cpu1(*this, "cpu1")
21 		, m_cpu2(*this, "cpu2")
22 		, m_mcu(*this, "mcu")
23 		, m_watchdog(*this, "watchdog")
24 		, m_cus30(*this, "namco")
25 		, m_gfxdecode(*this, "gfxdecode")
26 		, m_palette(*this, "palette")
27 		, m_63701x(*this, "namco2")
28 		, m_rthunder_videoram1(*this, "videoram1")
29 		, m_rthunder_videoram2(*this, "videoram2")
30 		, m_rthunder_spriteram(*this, "spriteram")
31 		, m_user1_ptr(*this, "user1")
32 		, m_leds(*this, "led%u", 0U)
33 	{ }
34 
35 	void genpeitd(machine_config &config);
36 	void wndrmomo(machine_config &config);
37 	void roishtar(machine_config &config);
38 	void rthunder(machine_config &config);
39 	void hopmappy(machine_config &config);
40 
41 	void init_namco86();
42 
43 private:
44 	void bankswitch1_w(uint8_t data);
45 	void bankswitch1_ext_w(uint8_t data);
46 	void bankswitch2_w(uint8_t data);
47 	uint8_t dsw0_r();
48 	uint8_t dsw1_r();
49 	void int_ack1_w(uint8_t data);
50 	void int_ack2_w(uint8_t data);
51 	void watchdog1_w(uint8_t data);
52 	void watchdog2_w(uint8_t data);
53 	void coin_w(uint8_t data);
54 	void led_w(uint8_t data);
55 	void cus115_w(offs_t offset, uint8_t data);
56 	void videoram1_w(offs_t offset, uint8_t data);
57 	void videoram2_w(offs_t offset, uint8_t data);
58 	void tilebank_select_w(offs_t offset, uint8_t data);
59 	void scroll0_w(offs_t offset, uint8_t data);
60 	void scroll1_w(offs_t offset, uint8_t data);
61 	void scroll2_w(offs_t offset, uint8_t data);
62 	void scroll3_w(offs_t offset, uint8_t data);
63 	void backcolor_w(uint8_t data);
64 	void spriteram_w(offs_t offset, uint8_t data);
65 
66 	TILE_GET_INFO_MEMBER(get_tile_info0);
67 	TILE_GET_INFO_MEMBER(get_tile_info1);
68 	TILE_GET_INFO_MEMBER(get_tile_info2);
69 	TILE_GET_INFO_MEMBER(get_tile_info3);
70 
71 	void namcos86_palette(palette_device &palette);
72 
73 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
74 	DECLARE_WRITE_LINE_MEMBER(screen_vblank);
75 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 	void scroll_w(offs_t offset, int data, int layer);
77 
78 	void common_mcu_map(address_map &map);
79 	void cpu1_map(address_map &map);
80 	void genpeitd_cpu2_map(address_map &map);
81 	void genpeitd_mcu_map(address_map &map);
82 	void hopmappy_cpu2_map(address_map &map);
83 	void hopmappy_mcu_map(address_map &map);
84 	void roishtar_cpu2_map(address_map &map);
85 	void roishtar_mcu_map(address_map &map);
86 	void rthunder_cpu2_map(address_map &map);
87 	void rthunder_mcu_map(address_map &map);
88 	void wndrmomo_cpu2_map(address_map &map);
89 	void wndrmomo_mcu_map(address_map &map);
90 
91 	virtual void machine_start() override;
92 	virtual void video_start() override;
93 
94 	required_device<cpu_device> m_cpu1;
95 	required_device<cpu_device> m_cpu2;
96 	required_device<hd63701v0_cpu_device> m_mcu;
97 	required_device<watchdog_timer_device> m_watchdog;
98 	required_device<namco_cus30_device> m_cus30;
99 	required_device<gfxdecode_device> m_gfxdecode;
100 	required_device<palette_device> m_palette;
101 	optional_device<namco_63701x_device> m_63701x;
102 	required_shared_ptr<uint8_t> m_rthunder_videoram1;
103 	required_shared_ptr<uint8_t> m_rthunder_videoram2;
104 	required_shared_ptr<uint8_t> m_rthunder_spriteram;
105 	optional_region_ptr<uint8_t> m_user1_ptr;
106 	output_finder<2> m_leds;
107 
108 	uint8_t *m_spriteram;
109 	int m_wdog;
110 	int m_tilebank;
111 	int m_xscroll[4];
112 	int m_yscroll[4];
113 	tilemap_t *m_bg_tilemap[4];
114 	int m_backcolor;
115 	const uint8_t *m_tile_address_prom;
116 	int m_copy_sprites;
117 
118 	inline void get_tile_info(tile_data &tileinfo,int tile_index,int layer,uint8_t *vram);
119 	void set_scroll(int layer);
120 };
121 
122 #endif // MAME_INCLUDES_NAMCOS86_H
123