summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/fitfight.cpp
blob: 720fb53eabd994e8c77819fce81230389a39a0a2 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood
/* Fit of Fighting Video Hardware */

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


void fitfight_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer )
{
	gfx_element *gfx = m_gfxdecode->gfx(3);
	uint16_t *source = m_spriteram;
	uint16_t *finish = source + 0x800 / 2;

	while (source < finish)
	{
		int xpos, ypos, number, xflip, yflip, end, colr, prio;

		ypos = source[0];
		xpos = source[3];
		number = source[2];
		xflip = (source[1] & 0x0001) ^ 0x0001;
		yflip = (source[1] & 0x0002);
		prio = (source[1] & 0x0400) >> 10;
		colr = (source[1] & 0x00fc) >> 2;

		if (m_bbprot_kludge == 1)
			colr = (source[1] & 0x00f8) >> 3;

		end = source[0] & 0x8000;

		ypos = 0xff - ypos;

		xpos -= 38;//48;
		ypos -= 14;//16;

		if (end) break;
		if (prio == layer)
				gfx->transpen(bitmap,cliprect, number, colr, xflip, yflip, xpos, ypos, 0);

		source += 4;
	}
}

TILE_GET_INFO_MEMBER(fitfight_state::get_fof_bak_tile_info)
{
	int code = m_fof_bak_tileram[tile_index * 2 + 1];
	int colr = m_fof_bak_tileram[tile_index * 2] & 0x1f;
	int xflip = (m_fof_bak_tileram[tile_index * 2] & 0x0020) >> 5;
	xflip ^= 1;

	SET_TILE_INFO_MEMBER(2, code, colr, TILE_FLIPYX(xflip));
}

WRITE16_MEMBER(fitfight_state::fof_bak_tileram_w)
{
	COMBINE_DATA(&m_fof_bak_tileram[offset]);
	m_fof_bak_tilemap->mark_tile_dirty(offset / 2);
}


TILE_GET_INFO_MEMBER(fitfight_state::get_fof_mid_tile_info)
{
	int code = m_fof_mid_tileram[tile_index * 2 + 1];
	int colr = m_fof_mid_tileram[tile_index * 2] & 0x1f;
	int xflip = (m_fof_mid_tileram[tile_index * 2] & 0x0020) >> 5;
	xflip ^= 1;

	SET_TILE_INFO_MEMBER(1, code, colr, TILE_FLIPYX(xflip));
}

WRITE16_MEMBER(fitfight_state::fof_mid_tileram_w)
{
	COMBINE_DATA(&m_fof_mid_tileram[offset]);
	m_fof_mid_tilemap->mark_tile_dirty(offset / 2);
}

TILE_GET_INFO_MEMBER(fitfight_state::get_fof_txt_tile_info)
{
	int code = m_fof_txt_tileram[tile_index * 2 + 1];
	int colr = m_fof_txt_tileram[tile_index * 2] & 0x1f;
	int xflip = (m_fof_txt_tileram[tile_index * 2] & 0x0020) >> 5;
	xflip ^= 1;

	SET_TILE_INFO_MEMBER(0, code, colr, TILE_FLIPYX(xflip));
}

WRITE16_MEMBER(fitfight_state::fof_txt_tileram_w)
{
	COMBINE_DATA(&m_fof_txt_tileram[offset]);
	m_fof_txt_tilemap->mark_tile_dirty(offset / 2);
}

/* video start / update */

void fitfight_state::video_start()
{
	m_fof_bak_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(fitfight_state::get_fof_bak_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 128, 32);
	/* opaque */

	m_fof_mid_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(fitfight_state::get_fof_mid_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 128, 32);
	m_fof_mid_tilemap->set_transparent_pen(0);

	m_fof_txt_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(fitfight_state::get_fof_txt_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 128, 32);
	m_fof_txt_tilemap->set_transparent_pen(0);
}

uint32_t fitfight_state::screen_update_fitfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	/* scroll isn't right */

	int vblank;
	int scrollbak, scrollmid;

	vblank = (m_fof_700000[0] & 0x8000);

	if (vblank > 0)
		bitmap.fill(m_palette->black_pen(), cliprect);
	else {
//      if (machine().input().code_pressed(KEYCODE_Q))
//          scrollbak = ((m_fof_a00000[0] & 0xff00) >> 5) - ((m_fof_700000[0] & 0x0038) >> 3);
//      else if (machine().input().code_pressed(KEYCODE_W))
//          scrollbak = ((m_fof_a00000[0] & 0xff00) >> 5) + ((m_fof_700000[0] & 0x01c0) >> 6);
//      else if (machine().input().code_pressed(KEYCODE_E))
//          scrollbak = ((m_fof_a00000[0] & 0xff00) >> 5) - ((m_fof_700000[0] & 0x01c0) >> 6);
//      else if (machine().input().code_pressed(KEYCODE_R))
//          scrollbak = ((m_fof_a00000[0] & 0xff00) >> 5) + ((m_fof_700000[0] & 0x0038) >> 3);
//      else
		scrollbak = ((m_fof_a00000[0] & 0xffe0) >> 5);
		m_fof_bak_tilemap->set_scrollx(0, scrollbak );
		m_fof_bak_tilemap->set_scrolly(0, m_fof_a00000[0] & 0xff);
		m_fof_bak_tilemap->draw(screen, bitmap, cliprect, 0, 0);

		draw_sprites(bitmap, cliprect, 0);

//      if (machine().input().code_pressed(KEYCODE_A))
//          scrollmid = ((m_fof_900000[0] & 0xff00) >> 5) - ((m_fof_700000[0] & 0x01c0) >> 6);
//      else if (machine().input().code_pressed(KEYCODE_S))
//          scrollmid = ((m_fof_900000[0] & 0xff00) >> 5) + ((m_fof_700000[0] & 0x0038) >> 3);
//      else if (machine().input().code_pressed(KEYCODE_D))
//          scrollmid = ((m_fof_900000[0] & 0xff00) >> 5) - ((m_fof_700000[0] & 0x0038) >> 3);
//      else if (machine().input().code_pressed(KEYCODE_F))
//          scrollmid = ((m_fof_900000[0] & 0xff00) >> 5) + ((m_fof_700000[0] & 0x01c0) >> 6);
//      else
		scrollmid = ((m_fof_900000[0] & 0xffe0) >> 5);
		m_fof_mid_tilemap->set_scrollx(0, scrollmid );
		m_fof_mid_tilemap->set_scrolly(0, m_fof_900000[0] & 0xff);
//      if (!machine().input().code_pressed(KEYCODE_F))
		m_fof_mid_tilemap->draw(screen, bitmap, cliprect, 0, 0);

		draw_sprites(bitmap, cliprect, 1);

		m_fof_txt_tilemap->draw(screen, bitmap, cliprect, 0, 0);
	}
/*  popmessage ("Regs %04x %04x %04x %04x %04x %04x",
            m_fof_100000[0], m_fof_600000[0], m_fof_700000[0],
            m_fof_800000[0], m_fof_900000[0],
            m_fof_a00000[0] );
*/
	return 0;
}