summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/kaneko_tmap.h
blob: 8a7b56f6e4f6ae12aff2af92e400445b6e699224 (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
// license:BSD-3-Clause
// copyright-holders:Luca Elia, David Haywood
#ifndef MAME_VIDEO_KANEKO_TMAP_H
#define MAME_VIDEO_KANEKO_TMAP_H

#pragma once



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

	// configuration
	void set_gfxdecode_tag(const char *tag);
	void set_gfx_region(int region);
	void set_offset(int dx, int dy, int xdim, int ydim);
	void set_invert_flip(int invert_flip); // for fantasia (bootleg)

	void get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_);
	void kaneko16_vram_w(offs_t offset, uint16_t data, uint16_t mem_mask, int _N_);

	// call to do the rendering etc.
	template<class _BitmapClass>
	void kaneko16_prepare_common(_BitmapClass &bitmap, const rectangle &cliprect);
	template<class _BitmapClass>
	void render_tilemap_chip_common(screen_device &screen, _BitmapClass &bitmap, const rectangle &cliprect, int pri);
	template<class _BitmapClass>
	void render_tilemap_chip_alt_common(screen_device &screen, _BitmapClass &bitmap, const rectangle &cliprect, int pri, int v2pri);

	void kaneko16_prepare(bitmap_ind16 &bitmap, const rectangle &cliprect);
	void kaneko16_prepare(bitmap_rgb32 &bitmap, const rectangle &cliprect);
	void render_tilemap_chip(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
	void render_tilemap_chip(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int pri);
	void render_tilemap_chip_alt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int v2pri);
	void render_tilemap_chip_alt(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int pri, int v2pri);


	// access
	DECLARE_READ16_MEMBER( kaneko_tmap_vram_r );
	DECLARE_WRITE16_MEMBER( kaneko_tmap_vram_w );

	DECLARE_READ16_MEMBER( kaneko_tmap_regs_r );
	DECLARE_WRITE16_MEMBER( kaneko_tmap_regs_w );

	DECLARE_WRITE16_MEMBER(kaneko16_vram_0_w);
	DECLARE_WRITE16_MEMBER(kaneko16_vram_1_w);

	DECLARE_READ16_MEMBER(kaneko16_vram_0_r);
	DECLARE_READ16_MEMBER(kaneko16_vram_1_r);

	DECLARE_READ16_MEMBER(kaneko16_scroll_0_r);
	DECLARE_READ16_MEMBER(kaneko16_scroll_1_r);

	DECLARE_WRITE16_MEMBER( kaneko16_scroll_0_w );
	DECLARE_WRITE16_MEMBER( kaneko16_scroll_1_w );

	DECLARE_WRITE16_MEMBER(galsnew_vram_0_tilebank_w);
	DECLARE_WRITE16_MEMBER(galsnew_vram_1_tilebank_w);



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

private:
	TILE_GET_INFO_MEMBER(get_tile_info_0);
	TILE_GET_INFO_MEMBER(get_tile_info_1);
	required_device<gfxdecode_device> m_gfxdecode;

	// set when creating device
	int m_tilebase;
	int m_dx, m_dy, m_xdim, m_ydim;
	int m_invert_flip;

	std::unique_ptr<uint16_t[]> m_vram[2];
	std::unique_ptr<uint16_t[]> m_vscroll[2];
	std::unique_ptr<uint16_t[]> m_regs;
	tilemap_t* m_tmap[2];
	uint16_t m_vram_tile_addition[2]; // galsnew
};


DECLARE_DEVICE_TYPE(KANEKO_TMAP, kaneko_view2_tilemap_device)

#define MCFG_KANEKO_TMAP_GFXDECODE(_gfxtag) \
	downcast<kaneko_view2_tilemap_device &>(*device).set_gfxdecode_tag("^" _gfxtag);
#define MCFG_KANEKO_TMAP_GFX_REGION(_region) \
	downcast<kaneko_view2_tilemap_device &>(*device).set_gfx_region(_region);
#define MCFG_KANEKO_TMAP_INVERT_FLIP(_invert) \
	downcast<kaneko_view2_tilemap_device &>(*device).set_invert_flip(_invert);
#define MCFG_KANEKO_TMAP_OFFSET(_dx, _dy, _xdim, _ydim) \
	downcast<kaneko_view2_tilemap_device &>(*device).set_offset(_dx, _dy, _xdim, _ydim);

#endif // MAME_VIDEO_KANEKO_TMAP_H