summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/rbisland.cpp
blob: c326b856f014a635ed5972046e33f241c1a76320 (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
// license:BSD-3-Clause
// copyright-holders:Mike Coates
/***************************************************************************
  Functions to emulate video hardware on these Taito games:

  - rainbow islands
  - jumping (bootleg)

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

#include "emu.h"
#include "includes/rbisland.h"
#include "screen.h"

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

WRITE16_MEMBER(rbisland_state::rbisland_spritectrl_w)
{
	if (offset == 0)
	{
		/* bits 0 and 1 always set */
		/* bits 5-7 are the sprite palette bank */
		/* other bits unknown */

		m_pc090oj->set_sprite_ctrl((data & 0xe0) >> 5);
	}
}

WRITE16_MEMBER(rbisland_state::jumping_spritectrl_w)
{
	if (offset == 0)
	{
		/* bits 0 and 1 are set after 15 seconds */
		/* bits 5-7 are the sprite palette bank */
		/* other bits unknown */

		m_sprite_ctrl = data;
	}
}

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

uint32_t rbisland_state::screen_update_rainbow(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int layer[2];

	m_pc080sn->tilemap_update();

	layer[0] = 0;
	layer[1] = 1;

	screen.priority().fill(0, cliprect);

	m_pc080sn->tilemap_draw(screen, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1);
	m_pc080sn->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 2);

	m_pc090oj->draw_sprites(bitmap, cliprect, screen.priority(), 1);
	return 0;
}


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

Jumping uses different sprite controller
than Rainbow Island. - values are remapped
at address 0x2EA in the code. Apart from
physical layout, the main change is that
the Y settings are active low.

*/

VIDEO_START_MEMBER(rbisland_state,jumping)
{
	m_pc080sn->set_trans_pen(1, 15);

	m_sprite_ctrl = 0;
	m_sprites_flipscreen = 0;

	/* not 100% sure Jumping needs to save both... */
	save_item(NAME(m_sprite_ctrl));
	save_item(NAME(m_sprites_flipscreen));
}


uint32_t rbisland_state::screen_update_jumping(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	uint16_t *spriteram = m_spriteram;
	int offs, layer[2];
	int sprite_colbank = (m_sprite_ctrl & 0xe0) >> 1;

	m_pc080sn->tilemap_update();

	/* Override values, or foreground layer is in wrong position */
	m_pc080sn->set_scroll(1, 16, 0);

	layer[0] = 0;
	layer[1] = 1;

	screen.priority().fill(0, cliprect);

	m_pc080sn->tilemap_draw(screen, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 0);

	/* Draw the sprites. 128 sprites in total */
	for (offs = m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8)
	{
		int tile = spriteram[offs];
		if (tile < m_gfxdecode->gfx(1)->elements())
		{
			int sx,sy,color,data1;

			sy = ((spriteram[offs + 1] - 0xfff1) ^ 0xffff) & 0x1ff;
			if (sy > 400) sy = sy - 512;
			sx = (spriteram[offs + 2] - 0x38) & 0x1ff;
			if (sx > 400) sx = sx - 512;

			data1 = spriteram[offs + 3];
			color = (spriteram[offs + 4] & 0x0f) | sprite_colbank;

			m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
					tile,
					color,
					data1 & 0x40, data1 & 0x80,
					sx,sy+1,15);
		}
	}

	m_pc080sn->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 0);

#if 0
	{
		char buf[80];
		sprintf(buf,"sprite_ctrl: %04x", m_sprite_ctrl);
		popmessage(buf);
	}
#endif
	return 0;
}