summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/taito_h.cpp
blob: 8153dc5893a116f8613afa2641734d95becb113d (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// license:BSD-3-Clause
// copyright-holders:Yochizo
/***************************************************************************

Functions to emulate the video hardware of the machine.

TODO
====

Harmonise draw_sprites code and offload it into taitoic.c, leaving this
as short as possible (TC0080VCO has sprites as well as tilemaps in its
address space).

Maybe wait until the Taito Air system is done - also uses TC0080VCO.

Why does syvalion draw_sprites ignore the zoomy value
(using zoomx instead) ???


Sprite ram notes
----------------

BG / chain RAM
-----------------------------------------
[0]  +0         +1
     -xxx xxxx  xxxx xxxx = tile number

[1]  +0         +1
     ---- ----  x--- ---- = flip Y
     ---- ----  -x-- ---- = flip X
     ---- ----  --xx xxxx = color


sprite RAM
--------------------------------------------------------------
 +0         +1         +2         +3
 ---x ----  ---- ----  ---- ----  ---- ---- = unknown
 ---- xx--  ---- ----  ---- ----  ---- ---- = chain y size
 ---- --xx  xxxx xxxx  ---- ----  ---- ---- = sprite x coords
 ---- ----  ---- ----  ---- --xx  xxxx xxxx = sprite y coords

 +4         +5         +6         +7
 --xx xxxx  ---- ----  ---- ----  ---- ---- = zoom x
 ---- ----  --xx xxxx  ---- ----  ---- ---- = zoom y
 ---- ----  ---- ----  ---x xxxx  xxxx xxxx = tile information offset


***************************************************************************/

#include "emu.h"
#include "includes/taito_h.h"


/***************************************************************************
  Screen refresh
***************************************************************************/

void taitoh_state::syvalion_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	for (int offs = 0x03f8 / 2; offs >= 0; offs -= 0x008 / 2)
	{
		m_tc0080vco->get_sprite_params(offs, false);

		if (m_tc0080vco->get_sprite_tile_offs())
		{
			m_tc0080vco->draw_single_sprite(bitmap, cliprect);
		}
	}
}

void taitoh_state::recordbr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
{
	for (int offs = 0x03f8 / 2; offs >= 0; offs -= 0x008 / 2)
	{
		if (offs <  0x01b0 && priority == 0)    continue;
		if (offs >= 0x01b0 && priority == 1)    continue;

		m_tc0080vco->get_sprite_params(offs, true);

		if (m_tc0080vco->get_sprite_tile_offs())
		{
			m_tc0080vco->draw_single_sprite(bitmap, cliprect);
		}
	}
}

void taitoh_state::dleague_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
{
	for (int offs = 0x03f8 / 2; offs >= 0; offs -= 0x008 / 2)
	{
		m_tc0080vco->get_sprite_params(offs, false);
		int pribit = (m_tc0080vco->sprram_r(offs + 0) & 0x1000) >> 12;

		if (m_tc0080vco->get_sprite_tile_offs())
		{
			if (m_tc0080vco->get_sprite_zoomx() < 63)
				pribit = 0;

			if (m_tc0080vco->scrram_r(0x0002) & 0x8000)
				pribit = 1;

			if (priority == pribit)
			{
				m_tc0080vco->draw_single_sprite(bitmap, cliprect);
			}
		}
	}
}



void taitoh_state::taitoh_log_vram()
{
#ifdef MAME_DEBUG
	// null function: the necessary pointers are now internal to taitoic.c
	// Recreate it there if wanted (add prototype to taitoic.h)
#endif
}


/**************************************************************************/

u32 taitoh_state::screen_update_syvalion(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	m_tc0080vco->tilemap_update();

	taitoh_log_vram();

	bitmap.fill(0, cliprect);

	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
	syvalion_draw_sprites(bitmap,cliprect);
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 2, 0, 0);

	return 0;
}


u32 taitoh_state::screen_update_recordbr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	m_tc0080vco->tilemap_update();

	taitoh_log_vram();

	bitmap.fill(0, cliprect);

#ifdef MAME_DEBUG
	if (!machine().input().code_pressed(KEYCODE_A))
		m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
	if (!machine().input().code_pressed(KEYCODE_S))
		recordbr_draw_sprites(bitmap, cliprect, 0);
	if (!machine().input().code_pressed(KEYCODE_D))
		m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
	if (!machine().input().code_pressed(KEYCODE_F))
		recordbr_draw_sprites(bitmap, cliprect, 1);
#else
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
	recordbr_draw_sprites(bitmap, cliprect, 0);
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
	recordbr_draw_sprites(bitmap, cliprect, 1);
#endif

	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 2, 0, 0);
	return 0;
}


u32 taitoh_state::screen_update_dleague(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	m_tc0080vco->tilemap_update();

	taitoh_log_vram();

	bitmap.fill(0, cliprect);

#ifdef MAME_DEBUG
	if (!machine().input().code_pressed(KEYCODE_A))
		m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
	if (!machine().input().code_pressed(KEYCODE_S))
		dleague_draw_sprites(bitmap, cliprect, 0);
	if (!machine().input().code_pressed(KEYCODE_D))
		m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
	if (!machine().input().code_pressed(KEYCODE_F))
		dleague_draw_sprites(bitmap, cliprect, 1);
#else
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
	dleague_draw_sprites (bitmap, cliprect, 0);
	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0);
	dleague_draw_sprites (bitmap, cliprect, 1);
#endif

	m_tc0080vco->tilemap_draw(screen, bitmap, cliprect, 2, 0, 0);
	return 0;
}