1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_RALLYX_H
4 #define MAME_INCLUDES_RALLYX_H
5 
6 #pragma once
7 
8 #include "audio/timeplt.h"
9 #include "sound/namco.h"
10 #include "sound/samples.h"
11 #include "emupal.h"
12 #include "screen.h"
13 #include "tilemap.h"
14 
15 class rallyx_state : public driver_device
16 {
17 public:
rallyx_state(const machine_config & mconfig,device_type type,const char * tag)18 	rallyx_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_videoram(*this, "videoram"),
21 		m_radarattr(*this, "radarattr"),
22 		m_maincpu(*this, "maincpu"),
23 		m_namco_sound(*this, "namco"),
24 		m_samples(*this, "samples"),
25 		m_timeplt_audio(*this, "timeplt_audio"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_palette(*this, "palette"),
28 		m_screen(*this, "screen")
29 	{ }
30 
31 	void commsega(machine_config &config);
32 	void jungler(machine_config &config);
33 	void locomotn(machine_config &config);
34 	void rallyx(machine_config &config);
35 	void tactcian(machine_config &config);
36 
37 private:
38 	// memory pointers
39 	required_shared_ptr<uint8_t> m_videoram;
40 	required_shared_ptr<uint8_t> m_radarattr;
41 	uint8_t *  m_spriteram;
42 	uint8_t *  m_spriteram2;
43 	uint8_t *  m_radarx;
44 	uint8_t *  m_radary;
45 
46 	// video-related
47 	tilemap_t  *m_bg_tilemap;
48 	tilemap_t  *m_fg_tilemap;
49 
50 	// misc
51 	static constexpr unsigned JUNGLER_MAX_STARS = 1000;
52 
53 	struct jungler_star
54 	{
55 		uint16_t x, y;
56 		uint8_t color;
57 	};
58 
59 	bool      m_last_bang;
60 	uint8_t   m_spriteram_base;
61 	bool      m_stars_enable;
62 	uint16_t  m_total_stars;
63 	uint8_t   m_drawmode_table[4];
64 	struct jungler_star m_stars[JUNGLER_MAX_STARS];
65 	bool      m_main_irq_mask;
66 
67 	// devices
68 	required_device<cpu_device> m_maincpu;
69 	optional_device<namco_device> m_namco_sound;
70 	optional_device<samples_device> m_samples;
71 	optional_device<timeplt_audio_device> m_timeplt_audio;
72 	required_device<gfxdecode_device> m_gfxdecode;
73 	required_device<palette_device> m_palette;
74 	required_device<screen_device> m_screen;
75 
76 	void rallyx_interrupt_vector_w(uint8_t data);
77 	void bang_w(int state);
78 	void irq_mask_w(int state);
79 	void nmi_mask_w(int state);
80 	void sound_on_w(int state);
81 	void flip_screen_w(int state);
82 	void coin_lockout_w(int state);
83 	void coin_counter_1_w(int state);
84 	void coin_counter_2_w(int state);
85 	void videoram_w(offs_t offset, uint8_t data);
86 	void scrollx_w(uint8_t data);
87 	void scrolly_w(uint8_t data);
88 	void stars_enable_w(int state);
89 	void rallyx_vblank_irq(int state);
90 	void jungler_vblank_irq(int state);
91 
92 	TILEMAP_MAPPER_MEMBER(fg_tilemap_scan);
93 	TILE_GET_INFO_MEMBER(rallyx_bg_get_tile_info);
94 	TILE_GET_INFO_MEMBER(rallyx_fg_get_tile_info);
95 	TILE_GET_INFO_MEMBER(locomotn_bg_get_tile_info);
96 	TILE_GET_INFO_MEMBER(locomotn_fg_get_tile_info);
97 
98 	DECLARE_MACHINE_START(rallyx);
99 	DECLARE_VIDEO_START(rallyx);
100 	DECLARE_VIDEO_START(jungler);
101 	DECLARE_VIDEO_START(locomotn);
102 	DECLARE_VIDEO_START(commsega);
103 
104 	void rallyx_palette(palette_device &palette) const;
105 	void jungler_palette(palette_device &palette) const;
106 	uint32_t screen_update_rallyx(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107 	uint32_t screen_update_jungler(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
108 	uint32_t screen_update_locomotn(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
109 	inline void rallyx_get_tile_info( tile_data &tileinfo, int tile_index, int ram_offs);
110 	inline void locomotn_get_tile_info(tile_data &tileinfo,int tile_index,int ram_offs);
111 	void calculate_star_field();
112 	void video_start_common();
113 	void plot_star( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, int color );
114 	void draw_stars( bitmap_ind16 &bitmap, const rectangle &cliprect );
115 	void rallyx_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
116 	void locomotn_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
117 	void rallyx_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect, bool transpen );
118 	void jungler_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect, bool transpen );
119 	void locomotn_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect, bool transpen );
120 
121 	void io_map(address_map &map);
122 	void jungler_map(address_map &map);
123 	void rallyx_map(address_map &map);
124 };
125 
126 #endif // MAME_INCLUDES_RALLYX_H
127