1 // license:BSD-3-Clause
2 // copyright-holders:Phil Stroffolino
3 #ifndef MAME_INCLUDES_TSAMURAI_H
4 #define MAME_INCLUDES_TSAMURAI_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class tsamurai_state : public driver_device
13 {
14 public:
tsamurai_state(const machine_config & mconfig,device_type type,const char * tag)15 	tsamurai_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_maincpu(*this, "maincpu"),
18 		m_audiocpu(*this, "audiocpu"),
19 		m_audio2(*this, "audio2"),
20 		m_audio3(*this, "audio3"),
21 		m_gfxdecode(*this, "gfxdecode"),
22 		m_palette(*this, "palette"),
23 		m_soundlatch(*this, "soundlatch"),
24 		m_videoram(*this, "videoram"),
25 		m_colorram(*this, "colorram"),
26 		m_bg_videoram(*this, "bg_videoram"),
27 		m_spriteram(*this, "spriteram")
28 	{ }
29 
30 	void tsamurai(machine_config &config);
31 	void m660(machine_config &config);
32 	void vsgongf(machine_config &config);
33 
34 	void init_the26thz();
35 
36 private:
37 	// common
38 	DECLARE_WRITE_LINE_MEMBER(nmi_enable_w);
39 	DECLARE_WRITE_LINE_MEMBER(coin1_counter_w);
40 	DECLARE_WRITE_LINE_MEMBER(coin2_counter_w);
41 	DECLARE_WRITE_LINE_MEMBER(textbank1_w);
42 	void fg_videoram_w(offs_t offset, uint8_t data);
43 
44 	// tsamurai and m660 specific
45 	void bg_videoram_w(offs_t offset, uint8_t data);
46 	void fg_colorram_w(offs_t offset, uint8_t data);
47 	DECLARE_WRITE_LINE_MEMBER(flip_screen_w);
48 	void scrolly_w(uint8_t data);
49 	void scrollx_w(uint8_t data);
50 	void bgcolor_w(uint8_t data);
51 	uint8_t unknown_d806_r();
52 	uint8_t unknown_d900_r();
53 	uint8_t unknown_d938_r();
54 	void sound_command1_w(uint8_t data);
55 	void sound_command2_w(uint8_t data);
56 	uint8_t sound_command1_r();
57 	uint8_t sound_command2_r();
58 
59 	// tsamurai specific
60 	uint8_t tsamurai_unknown_d803_r();
61 
62 	// m660 specific
63 	DECLARE_WRITE_LINE_MEMBER(textbank2_w);
64 	uint8_t m660_unknown_d803_r();
65 	void m660_sound_command3_w(uint8_t data);
66 	uint8_t m660_sound_command3_r();
67 
68 	// vsgongf specific
69 	void vsgongf_color_w(uint8_t data);
70 	void vsgongf_sound_nmi_enable_w(uint8_t data);
71 	uint8_t vsgongf_a006_r();
72 	uint8_t vsgongf_a100_r();
73 	void vsgongf_sound_command_w(uint8_t data);
74 
75 	DECLARE_MACHINE_START(m660);
76 	DECLARE_MACHINE_START(tsamurai);
77 	DECLARE_MACHINE_START(vsgongf);
78 	DECLARE_VIDEO_START(m660);
79 	DECLARE_VIDEO_START(tsamurai);
80 	DECLARE_VIDEO_START(vsgongf);
81 
82 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
83 	uint32_t screen_update_vsgongf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
84 
85 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
86 	INTERRUPT_GEN_MEMBER(vsgongf_sound_interrupt);
87 
88 	void m660_map(address_map &map);
89 	void main_map(address_map &map);
90 	void sound1_m660_map(address_map &map);
91 	void sound1_map(address_map &map);
92 	void sound2_m660_map(address_map &map);
93 	void sound2_map(address_map &map);
94 	void sound3_m660_io_map(address_map &map);
95 	void sound3_m660_map(address_map &map);
96 	void sound_vsgongf_map(address_map &map);
97 	void vsgongf_audio_io_map(address_map &map);
98 	void vsgongf_map(address_map &map);
99 	void z80_io_map(address_map &map);
100 	void z80_m660_io_map(address_map &map);
101 
102 	virtual void machine_start() override;
103 	virtual void video_start() override;
104 
105 	required_device<cpu_device> m_maincpu;
106 	required_device<cpu_device> m_audiocpu;
107 	optional_device<cpu_device> m_audio2;
108 	optional_device<cpu_device> m_audio3;
109 	required_device<gfxdecode_device> m_gfxdecode;
110 	required_device<palette_device> m_palette;
111 	optional_device<generic_latch_8_device> m_soundlatch; // vsgongf only
112 
113 	required_shared_ptr<uint8_t> m_videoram;
114 	optional_shared_ptr<uint8_t> m_colorram;
115 	optional_shared_ptr<uint8_t> m_bg_videoram;
116 	required_shared_ptr<uint8_t> m_spriteram;
117 
118 	tilemap_t *m_background;
119 	tilemap_t *m_foreground;
120 
121 	//common
122 	int m_flicker;
123 	int m_textbank1;
124 	int m_nmi_enabled;
125 
126 	// tsamurai and m660 specific
127 	int m_bgcolor;
128 	int m_sound_command1;
129 	int m_sound_command2;
130 
131 	//m660 specific
132 	int m_textbank2;
133 	int m_sound_command3;
134 
135 	//vsgongf specific
136 	int m_vsgongf_sound_nmi_enabled;
137 	int m_vsgongf_color;
138 	int m_key_count; //debug only
139 
140 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
141 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
142 	TILE_GET_INFO_MEMBER(get_vsgongf_tile_info);
143 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
144 };
145 
146 #endif // MAME_INCLUDES_TSAMURAI_H
147