1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5     Sega Zaxxon hardware
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_ZAXXON_H
9 #define MAME_INCLUDES_ZAXXON_H
10 
11 #pragma once
12 
13 #include "machine/74259.h"
14 #include "machine/i8255.h"
15 #include "sound/samples.h"
16 #include "emupal.h"
17 #include "tilemap.h"
18 
19 class zaxxon_state : public driver_device
20 {
21 public:
zaxxon_state(const machine_config & mconfig,device_type type,const char * tag)22 	zaxxon_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_mainlatch(*this, "mainlatch%u", 1),
26 		m_ppi(*this, "ppi8255"),
27 		m_samples(*this, "samples"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_palette(*this, "palette"),
30 		m_dials(*this, "DIAL.%u", 0),
31 		m_videoram(*this, "videoram"),
32 		m_spriteram(*this, "spriteram"),
33 		m_colorram(*this, "colorram"),
34 		m_decrypted_opcodes(*this, "decrypted_opcodes")
35 	{ }
36 
37 	void root(machine_config &config);
38 	void ixion(machine_config &config);
39 	void futspye(machine_config &config);
40 	void congo(machine_config &config);
41 	void szaxxon(machine_config &config);
42 	void razmataze(machine_config &config);
43 	void szaxxone(machine_config &config);
44 	void zaxxon(machine_config &config);
45 	void zaxxon_samples(machine_config &config);
46 	void congo_samples(machine_config &config);
47 
48 	void init_razmataz();
49 	void init_zaxxonj();
50 
51 	template <int Num> DECLARE_CUSTOM_INPUT_MEMBER(razmataz_dial_r);
52 	template <int Num> DECLARE_READ_LINE_MEMBER(zaxxon_coin_r);
53 	DECLARE_INPUT_CHANGED_MEMBER(service_switch);
54 	DECLARE_INPUT_CHANGED_MEMBER(zaxxon_coin_inserted);
55 
56 private:
57 	required_device<cpu_device> m_maincpu;
58 	required_device_array<ls259_device, 2> m_mainlatch;
59 	optional_device<i8255_device> m_ppi;
60 	optional_device<samples_device> m_samples;
61 	required_device<gfxdecode_device> m_gfxdecode;
62 	required_device<palette_device> m_palette;
63 
64 	optional_ioport_array<2> m_dials;
65 
66 	required_shared_ptr<uint8_t> m_videoram;
67 	optional_shared_ptr<uint8_t> m_spriteram;
68 	optional_shared_ptr<uint8_t> m_colorram;
69 	optional_shared_ptr<uint8_t> m_decrypted_opcodes;
70 
71 	uint8_t m_int_enabled;
72 	uint8_t m_coin_status[3];
73 
74 	uint8_t m_razmataz_dial_pos[2];
75 	uint16_t m_razmataz_counter;
76 
77 	uint8_t m_sound_state[3];
78 	uint8_t m_bg_enable;
79 	uint8_t m_bg_color;
80 	uint16_t m_bg_position;
81 	uint8_t m_fg_color;
82 	bool m_flip_screen;
83 
84 	uint8_t m_congo_fg_bank;
85 	uint8_t m_congo_color_bank;
86 	uint8_t m_congo_custom[4];
87 
88 	const uint8_t *m_color_codes;
89 	tilemap_t *m_fg_tilemap;
90 	tilemap_t *m_bg_tilemap;
91 	DECLARE_WRITE_LINE_MEMBER(int_enable_w);
92 	uint8_t razmataz_counter_r();
93 	void zaxxon_control_w(offs_t offset, uint8_t data);
94 	DECLARE_WRITE_LINE_MEMBER(coin_counter_a_w);
95 	DECLARE_WRITE_LINE_MEMBER(coin_counter_b_w);
96 	DECLARE_WRITE_LINE_MEMBER(coin_enable_w);
97 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
98 	DECLARE_WRITE_LINE_MEMBER(fg_color_w);
99 	void bg_position_w(offs_t offset, uint8_t data);
100 	DECLARE_WRITE_LINE_MEMBER(bg_color_w);
101 	DECLARE_WRITE_LINE_MEMBER(bg_enable_w);
102 	DECLARE_WRITE_LINE_MEMBER(congo_fg_bank_w);
103 	DECLARE_WRITE_LINE_MEMBER(congo_color_bank_w);
104 	void zaxxon_videoram_w(offs_t offset, uint8_t data);
105 	void congo_colorram_w(offs_t offset, uint8_t data);
106 	void congo_sprite_custom_w(address_space &space, offs_t offset, uint8_t data);
107 
108 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
109 	TILE_GET_INFO_MEMBER(zaxxon_get_fg_tile_info);
110 	TILE_GET_INFO_MEMBER(razmataz_get_fg_tile_info);
111 	TILE_GET_INFO_MEMBER(congo_get_fg_tile_info);
112 	virtual void machine_start() override;
113 	virtual void video_start() override;
114 	void zaxxon_palette(palette_device &palette);
115 	DECLARE_VIDEO_START(razmataz);
116 	DECLARE_VIDEO_START(congo);
117 	uint32_t screen_update_zaxxon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
118 	uint32_t screen_update_futspy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
119 	uint32_t screen_update_razmataz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
120 	uint32_t screen_update_congo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
121 	DECLARE_WRITE_LINE_MEMBER(vblank_int);
122 	void zaxxon_sound_a_w(uint8_t data);
123 	void zaxxon_sound_b_w(uint8_t data);
124 	void zaxxon_sound_c_w(uint8_t data);
125 	void congo_sound_b_w(uint8_t data);
126 	void congo_sound_c_w(uint8_t data);
127 	void video_start_common(tilemap_get_info_delegate &&fg_tile_info);
128 	void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int skew);
129 	inline int find_minimum_y(uint8_t value, int flip);
130 	inline int find_minimum_x(uint8_t value, int flip);
131 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, uint16_t flipxmask, uint16_t flipymask);
132 
133 	void congo_map(address_map &map);
134 	void congo_sound_map(address_map &map);
135 	void decrypted_opcodes_map(address_map &map);
136 	void ixion_map(address_map &map);
137 	void zaxxon_map(address_map &map);
138 };
139 
140 #endif // MAME_INCLUDES_ZAXXON_H
141