summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/tecmo_mix.h
blob: bf5cdeebd282577b1400380bb3302b3bca4c70e2 (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:David Haywood
/* Tecmo Mixer */
#ifndef MAME_VIDEO_TECMO_MIX_H
#define MAME_VIDEO_TECMO_MIX_H

#pragma once


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

	void mix_bitmaps(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, palette_device &palette, bitmap_ind16* bitmap_bg, bitmap_ind16* bitmap_fg, bitmap_ind16* bitmap_tx, bitmap_ind16* bitmap_sp);
	void set_mixer_shifts(int sprpri_shift, int sprbln_shift, int sprcol_shift)
	{
		m_sprpri_shift = sprpri_shift;
		m_sprbln_shift = sprbln_shift;
		m_sprcol_shift = sprcol_shift;
	}
	void set_blendcols(int bgblend_comp, int fgblend_comp, int txblend_comp, int spblend_comp)
	{
		m_bgblend_comp = bgblend_comp;
		m_fgblend_comp = fgblend_comp;
		m_txblend_comp = txblend_comp;
		m_spblend_comp = spblend_comp;
	}
	void set_regularcols(int bgregular_comp, int fgregular_comp, int txregular_comp, int spregular_comp)
	{
		m_bgregular_comp = bgregular_comp;
		m_fgregular_comp = fgregular_comp;
		m_txregular_comp = txregular_comp;
		m_spregular_comp = spregular_comp;
	}
	void set_blendsource(int spblend_source, int fgblend_source)
	{
		m_spblend_source = spblend_source;
		m_fgblend_source = fgblend_source;
	}
	void set_revspritetile() { m_revspritetile = 3; }
	void set_bgpen(int bgpen) { m_bgpen = bgpen; }

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

	// mixer shifts
	int m_sprpri_shift;
	int m_sprbln_shift;
	int m_sprcol_shift;

	// when the blend bit is specified in the attribute the source blend palette for that sprite / fg pixel comes from these offsets instead
	int m_spblend_source;
	int m_fgblend_source;
	// the second blend component depends on the pixel we are blending with, the following palettes get used instead of the regular ones
	int m_bgblend_comp;
	int m_fgblend_comp;
	int m_txblend_comp;
	int m_spblend_comp;

	// otherwise the regular palettes are
	int m_bgregular_comp;
	int m_fgregular_comp;
	int m_txregular_comp;
	int m_spregular_comp;

	int m_revspritetile;
	int m_bgpen;

private:
	uint32_t sum_colors(const pen_t *pal, int c1_idx, int c2_idx);
};

DECLARE_DEVICE_TYPE(TECMO_MIXER, tecmo_mix_device)



#define MCFG_TECMO_MIXER_SHIFTS(_sprpri_shift, _sprbln_shift, _sprcol_shift) \
	downcast<tecmo_mix_device &>(*device).set_mixer_shifts(_sprpri_shift, _sprbln_shift, _sprcol_shift);

#define MCFG_TECMO_MIXER_BLENDCOLS(_bgblend_comp, _fgblend_comp, _txblend_comp, _spblend_comp) \
	downcast<tecmo_mix_device &>(*device).set_blendcols(_bgblend_comp, _fgblend_comp, _txblend_comp, _spblend_comp);

#define MCFG_TECMO_MIXER_REGULARCOLS(_bgregular_comp, _fgregular_comp, _txregular_comp, _spregular_comp) \
	downcast<tecmo_mix_device &>(*device).set_regularcols(_bgregular_comp, _fgregular_comp, _txregular_comp, _spregular_comp);

#define MCFG_TECMO_MIXER_BLENDSOURCE(_spblend_source, _fgblend_source) \
	downcast<tecmo_mix_device &>(*device).set_blendsource(_spblend_source, _fgblend_source);

#define MCFG_TECMO_MIXER_REVSPRITETILE \
	downcast<tecmo_mix_device &>(*device).set_revspritetile();

#define MCFG_TECMO_MIXER_BGPEN(_bgpen) \
	downcast<tecmo_mix_device &>(*device).set_bgpen(_bgpen);

#endif // MAME_VIDEO_TECMO_MIX_H