summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/vsystem_spr2.h
blob: 876a82230eefa4d1391954a1f4cf596575405e58 (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
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, David Haywood
// Video System Sprites
#ifndef MAME_VIDEO_VSYSTEM_SPR2_H
#define MAME_VIDEO_VSYSTEM_SPR2_H

typedef device_delegate<uint32_t (uint32_t)> vsystem_tile2_indirection_delegate;

#define MCFG_VSYSTEM_SPR2_SET_TILE_INDIRECT(_class, _method) \
	downcast<vsystem_spr2_device &>(*device).set_tile_indirect_cb(vsystem_tile2_indirection_delegate(&_class::_method, #_class "::" #_method, nullptr, (_class *)nullptr));
#define MCFG_VSYSTEM_SPR2_SET_PRITYPE(_val) \
	downcast<vsystem_spr2_device &>(*device).set_pritype(_val);
#define MCFG_VSYSTEM_SPR2_SET_GFXREGION(_rgn) \
	downcast<vsystem_spr2_device &>(*device).set_gfx_region(_rgn);
#define MCFG_VSYSTEM_SPR2_SET_OFFSETS(_xoffs, _yoffs) \
	downcast<vsystem_spr2_device &>(*device).set_offsets(_xoffs,_yoffs);
#define MCFG_VSYSTEM_SPR2_GFXDECODE(_gfxtag) \
	downcast<vsystem_spr2_device &>(*device).set_gfxdecode_tag("^" _gfxtag);

class vsystem_spr2_device : public device_t
{
public:
	// configuration
	void set_gfxdecode_tag(const char *tag);
	void set_tile_indirect_cb(vsystem_tile2_indirection_delegate newtilecb);
	void set_pritype(int pritype);
	void set_gfx_region(int gfx_region);
	void set_offsets(int xoffs, int yoffs);

	vsystem_spr2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void turbofrc_draw_sprites(uint16_t const *spriteram3,  int spriteram3_bytes,  int spritepalettebank, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, int pri_param, bool flip_screen = false);
	void turbofrc_draw_sprites(uint16_t const *spriteram3,  int spriteram3_bytes,  int spritepalettebank, bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, int pri_param, bool flip_screen = false);

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

private:
	struct sprite_attributes
	{
		sprite_attributes() { }
		bool get(uint16_t const *ram);
		void handle_xsize_map_inc();

		int ox = 0;
		int xsize = 0;
		int zoomx = 0;
		int oy = 0;
		int ysize = 0;
		int zoomy = 0;
		int flipx = 0;
		int flipy = 0;
		int color = 0;
		int pri = 0;
		uint32_t map = 0;
	};

	uint32_t tile_callback_noindirect(uint32_t tile);

	template<class BitmapClass>
	void turbofrc_draw_sprites_common(uint16_t const *spriteram3,  int spriteram3_bytes, int spritepalettebank, BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, int pri_param, bool flip_screen);

	vsystem_tile2_indirection_delegate m_newtilecb;
	int m_pritype;
	int m_gfx_region;
	int m_xoffs, m_yoffs;

	sprite_attributes m_curr_sprite;

	required_device<gfxdecode_device> m_gfxdecode;
};


DECLARE_DEVICE_TYPE(VSYSTEM_SPR2, vsystem_spr2_device)

#endif // MAME_VIDEO_VSYSTEM_SPR2_H