summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/decbac06.h
blob: 64f51dfc266135c761594394dc2a8c0120898de6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// license:BSD-3-Clause
// copyright-holders:Bryan McPhail, David Haywood
#ifndef MAME_VIDEO_DECOBAC06_H
#define MAME_VIDEO_DECOBAC06_H

#pragma once

#include <memory>

#define MCFG_BAC06_BOOTLEG_DISABLE_8x8 \
	deco_bac06_device::disable_8x8(*device);

#define MCFG_BAC06_BOOTLEG_DISABLE_16x16 \
	deco_bac06_device::disable_16x16(*device);

#define MCFG_BAC06_BOOTLEG_DISABLE_RC_SCROLL \
	deco_bac06_device::disable_rc_scroll(*device);


class deco_bac06_device : public device_t
{
public:
	deco_bac06_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// static configuration
	static void static_set_gfxdecode_tag(device_t &device, const char *tag);
	static void set_gfx_region_wide(device_t &device, int region8x8, int region16x16, int wide);

	std::unique_ptr<uint16_t[]> m_pf_data;
	std::unique_ptr<uint16_t[]> m_pf_rowscroll;
	std::unique_ptr<uint16_t[]> m_pf_colscroll;

	tilemap_t* m_pf8x8_tilemap[3];
	tilemap_t* m_pf16x16_tilemap[3];
	int    m_tile_region_8;
	int    m_tile_region_16;

	// some bootlegs (eg midresb / midresbj) don't appear to actually support the alt modes, they set them and end up with broken gfx on later levels.
	bool    m_supports_8x8;
	bool    m_supports_16x16;
	bool    m_supports_rc_scroll;

	static void disable_8x8(device_t &device)
	{
		deco_bac06_device &dev = downcast<deco_bac06_device &>(device);
		dev.m_supports_8x8 = false;
	}

	static void disable_16x16(device_t &device)
	{
		deco_bac06_device &dev = downcast<deco_bac06_device &>(device);
		dev.m_supports_16x16 = false;
	}

	static void disable_rc_scroll(device_t &device)
	{
		deco_bac06_device &dev = downcast<deco_bac06_device &>(device);
		dev.m_supports_rc_scroll = false;
	}

	void create_tilemaps(int region8x8,int region16x16);
	uint16_t m_pf_control_0[8];
	uint16_t m_pf_control_1[8];

	void deco_bac06_pf_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,int flags,uint16_t penmask, uint16_t pencondition,uint16_t colprimask, uint16_t colpricondition);
	void deco_bac06_pf_draw_bootleg(bitmap_ind16 &bitmap,const rectangle &cliprect,int flags, int mode, int type);


	/* I wonder if pf_control_0 is really registers, or a selection of pins.

	  For games with multiple chips typically the flip bit only gets set on one of the chips, but
	  is expected to apply to both (and often the sprites as well?)

	  Furthermore we have the m_rambank thing used by Stadium Hero which appears to be used to
	  control the upper address line on some external RAM even if it gets written to the control_0
	  area

	  For now we have this get_flip_state function so that drivers can query the bit and set other
	  flip flags accordingly
	*/
	uint8_t get_flip_state(void) { return m_pf_control_0[0]&0x80; };


	void set_colmask(int data) { m_gfxcolmask = data; }
	void set_bppmultmask( int mult, int mask ) { m_bppmult = mult; m_bppmask = mask; } // stadium hero has 3bpp tiles
	void set_flip_screen(bool flip);

	uint8_t m_gfxcolmask;
	int m_rambank; // external connection?
	bool m_flip_screen;

	/* 16-bit accessors */

	DECLARE_WRITE16_MEMBER( pf_control_0_w );
	DECLARE_READ16_MEMBER( pf_control_1_r );
	DECLARE_WRITE16_MEMBER( pf_control_1_w );

	DECLARE_WRITE16_MEMBER( pf_data_w );
	DECLARE_READ16_MEMBER( pf_data_r );
	DECLARE_WRITE16_MEMBER( pf_rowscroll_w );
	DECLARE_READ16_MEMBER( pf_rowscroll_r );
	DECLARE_WRITE16_MEMBER( pf_colscroll_w );
	DECLARE_READ16_MEMBER( pf_colscroll_r );

	/* 8-bit accessors */

	/* for dec8.c, pcktgal.c */
	DECLARE_READ8_MEMBER( pf_data_8bit_r );
	DECLARE_WRITE8_MEMBER( pf_data_8bit_w );

	DECLARE_WRITE8_MEMBER( pf_control0_8bit_w );
	DECLARE_READ8_MEMBER( pf_control1_8bit_r );
	DECLARE_WRITE8_MEMBER( pf_control1_8bit_w );

	DECLARE_READ8_MEMBER( pf_rowscroll_8bit_r );
	DECLARE_WRITE8_MEMBER( pf_rowscroll_8bit_w );

	/* for hippodrm (dec0.c) and actfancr / triothep (H6280 based games)*/
	DECLARE_WRITE8_MEMBER( pf_control0_8bit_packed_w );
	DECLARE_WRITE8_MEMBER( pf_control1_8bit_swap_w );
	DECLARE_READ8_MEMBER( pf_data_8bit_swap_r );
	DECLARE_WRITE8_MEMBER( pf_data_8bit_swap_w );
	DECLARE_READ8_MEMBER( pf_rowscroll_8bit_swap_r );
	DECLARE_WRITE8_MEMBER( pf_rowscroll_8bit_swap_w );

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	uint8_t m_gfxregion8x8;
	uint8_t m_gfxregion16x16;
	int m_wide;

	uint8_t m_bppmult;
	uint8_t m_bppmask;

	void custom_tilemap_draw(bitmap_ind16 &bitmap,
							const rectangle &cliprect,
							tilemap_t *tilemap_ptr,
							const uint16_t *rowscroll_ptr,
							const uint16_t *colscroll_ptr,
							const uint16_t *control0,
							const uint16_t *control1,
							int flags,
							uint16_t penmask, uint16_t pencondition,uint16_t colprimask, uint16_t colpricondition);

private:
	TILEMAP_MAPPER_MEMBER(tile_shape0_scan);
	TILEMAP_MAPPER_MEMBER(tile_shape1_scan);
	TILEMAP_MAPPER_MEMBER(tile_shape2_scan);
	TILEMAP_MAPPER_MEMBER(tile_shape0_8x8_scan);
	TILEMAP_MAPPER_MEMBER(tile_shape1_8x8_scan);
	TILEMAP_MAPPER_MEMBER(tile_shape2_8x8_scan);
	TILE_GET_INFO_MEMBER(get_pf8x8_tile_info);
	TILE_GET_INFO_MEMBER(get_pf16x16_tile_info);
	required_device<gfxdecode_device> m_gfxdecode;
};

DECLARE_DEVICE_TYPE(DECO_BAC06, deco_bac06_device)

#define MCFG_DECO_BAC06_GFXDECODE(_gfxtag) \
	deco_bac06_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);

#define MCFG_DECO_BAC06_GFX_REGION_WIDE(_8x8, _16x16, _wide) \
	deco_bac06_device::set_gfx_region_wide(*device, _8x8, _16x16, _wide);

#endif // MAME_VIDEO_DECOBAC06_H