1 // license:BSD-3-Clause
2 // copyright-holders:Acho A. Tang, Nicola Salmoria
3 /*************************************************************************
4 
5     Equites, Splendor Blast driver
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_EQUITES_H
9 #define MAME_INCLUDES_EQUITES_H
10 
11 #pragma once
12 
13 #include "machine/74259.h"
14 #include "machine/alpha8201.h"
15 #include "machine/timer.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 
21 class equites_state : public driver_device
22 {
23 public:
equites_state(const machine_config & mconfig,device_type type,const char * tag)24 	equites_state(const machine_config &mconfig, device_type type, const char *tag) :
25 		driver_device(mconfig, type, tag),
26 		m_bg_videoram(*this, "bg_videoram"),
27 		m_spriteram(*this, "spriteram"),
28 		m_spriteram_2(*this, "spriteram_2"),
29 		m_maincpu(*this, "maincpu"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_palette(*this, "palette"),
32 		m_screen(*this, "screen"),
33 		m_alpha_8201(*this, "alpha_8201"),
34 		m_mainlatch(*this, "mainlatch")
35 	{ }
36 
37 	/* memory pointers */
38 	required_shared_ptr<uint16_t> m_bg_videoram;
39 	std::unique_ptr<uint8_t[]> m_fg_videoram;    // 8bits
40 	required_shared_ptr<uint16_t> m_spriteram;
41 	optional_shared_ptr<uint16_t> m_spriteram_2;
42 
43 	/* video-related */
44 	tilemap_t *m_fg_tilemap;
45 	tilemap_t *m_bg_tilemap;
46 	uint8_t     m_bgcolor;
47 
48 	/* devices */
49 	required_device<cpu_device> m_maincpu;
50 	required_device<gfxdecode_device> m_gfxdecode;
51 	required_device<palette_device> m_palette;
52 	required_device<screen_device> m_screen;
53 	required_device<alpha_8201_device> m_alpha_8201;
54 	required_device<ls259_device> m_mainlatch;
55 
56 	uint16_t equites_spriteram_kludge_r();
57 	uint8_t equites_fg_videoram_r(offs_t offset);
58 	void equites_fg_videoram_w(offs_t offset, uint8_t data);
59 	void equites_bg_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
60 	void equites_bgcolor_w(offs_t offset, uint8_t data);
61 	void equites_scrollreg_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
62 	DECLARE_WRITE_LINE_MEMBER(flip_screen_w);
63 	void init_equites();
64 	TILE_GET_INFO_MEMBER(equites_fg_info);
65 	TILE_GET_INFO_MEMBER(equites_bg_info);
66 	DECLARE_VIDEO_START(equites);
67 	void equites_palette(palette_device &palette) const;
68 	uint32_t screen_update_equites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
69 	TIMER_DEVICE_CALLBACK_MEMBER(equites_scanline);
70 	void equites_draw_sprites_block(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end);
71 	void equites_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
72 	void unpack_block(const char *region, int offset, int size);
73 	void unpack_region(const char *region);
74 	void equites(machine_config &config);
75 	void bngotime(machine_config &config);
76 
77 protected:
78 	virtual void machine_start() override;
79 	void bngotime_map(address_map &map);
80 	void equites_map(address_map &map);
81 	void equites_common_map(address_map &map);
82 };
83 
84 class gekisou_state : public equites_state
85 {
86 public:
87 	using equites_state::equites_state;
88 	DECLARE_READ_LINE_MEMBER(gekisou_unknown_bit_r);
89 	void gekisou(machine_config &config);
90 
91 protected:
92 	virtual void machine_start() override;
93 	void gekisou_map(address_map &map);
94 	void gekisou_unknown_bit_w(offs_t offset, uint16_t data);
95 
96 private:
97 	int m_gekisou_unknown_bit;
98 };
99 
100 
101 class splndrbt_state : public equites_state
102 {
103 public:
104 	using equites_state::equites_state;
105 	void init_splndrbt();
106 	void splndrbt(machine_config &config);
107 
108 protected:
109 	virtual void machine_start() override;
110 	void splndrbt_map(address_map &map);
111 	DECLARE_WRITE_LINE_MEMBER(splndrbt_selchar_w);
112 	void splndrbt_bg_scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
113 	void splndrbt_bg_scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
114 	TILE_GET_INFO_MEMBER(splndrbt_fg_info);
115 	TILE_GET_INFO_MEMBER(splndrbt_bg_info);
116 	DECLARE_VIDEO_START(splndrbt);
117 	void splndrbt_palette(palette_device &palette) const;
118 	uint32_t screen_update_splndrbt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
119 	TIMER_DEVICE_CALLBACK_MEMBER(splndrbt_scanline);
120 	void splndrbt_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
121 	void splndrbt_copy_bg(bitmap_ind16 &dst_bitmap, const rectangle &cliprect);
122 
123 private:
124 	int       m_fg_char_bank;
125 	uint16_t  m_splndrbt_bg_scrollx;
126 	uint16_t  m_splndrbt_bg_scrolly;
127 };
128 
129 #endif // MAME_INCLUDES_EQUITES_H
130