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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
// license:BSD-3-Clause
// copyright-holders:Allard van der Bas
/***************************************************************************
vastar.cpp
Functions to emulate the video hardware of the machine.
***************************************************************************/
#include "emu.h"
#include "includes/vastar.h"
/***************************************************************************
Callbacks for the TileMap code
***************************************************************************/
TILE_GET_INFO_MEMBER(vastar_state::get_fg_tile_info)
{
int code = m_fgvideoram[tile_index + 0x800] | (m_fgvideoram[tile_index + 0x400] << 8);
int color = m_fgvideoram[tile_index];
int fxy = (code & 0xc00) >> 10; // maybe, based on the other layers
tileinfo.set(0,
code,
color & 0x3f,
TILE_FLIPXY(fxy));
}
TILE_GET_INFO_MEMBER(vastar_state::get_bg1_tile_info)
{
int code = m_bg1videoram[tile_index + 0x800] | (m_bg1videoram[tile_index] << 8);
int color = m_bg1videoram[tile_index + 0xc00];
int fxy = (code & 0xc00) >> 10;
tileinfo.set(4,
code,
color & 0x3f,
TILE_FLIPXY(fxy));
}
TILE_GET_INFO_MEMBER(vastar_state::get_bg2_tile_info)
{
int code = m_bg2videoram[tile_index + 0x800] | (m_bg2videoram[tile_index] << 8);
int color = m_bg2videoram[tile_index + 0xc00];
int fxy = (code & 0xc00) >> 10;
tileinfo.set(3,
code,
color & 0x3f,
TILE_FLIPXY(fxy));
}
/***************************************************************************
Start the video hardware emulation.
***************************************************************************/
void vastar_state::video_start()
{
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(vastar_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8,8, 32,32);
m_bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(vastar_state::get_bg1_tile_info)), TILEMAP_SCAN_ROWS, 8,8, 32,32);
m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(vastar_state::get_bg2_tile_info)), TILEMAP_SCAN_ROWS, 8,8, 32,32);
m_fg_tilemap->set_transparent_pen(0);
m_bg1_tilemap->set_transparent_pen(0);
m_bg2_tilemap->set_transparent_pen(0);
m_bg1_tilemap->set_scroll_cols(32);
m_bg2_tilemap->set_scroll_cols(32);
}
/***************************************************************************
Memory handlers
***************************************************************************/
void vastar_state::fgvideoram_w(offs_t offset, uint8_t data)
{
m_fgvideoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset & 0x3ff);
}
void vastar_state::bg1videoram_w(offs_t offset, uint8_t data)
{
m_bg1videoram[offset] = data;
m_bg1_tilemap->mark_tile_dirty(offset & 0x3ff);
}
void vastar_state::bg2videoram_w(offs_t offset, uint8_t data)
{
m_bg2videoram[offset] = data;
m_bg2_tilemap->mark_tile_dirty(offset & 0x3ff);
}
/***************************************************************************
Display refresh
***************************************************************************/
// I wouldn't rule out the possibility of there being 2 sprite chips due to
// "offs & 0x20" being used to select the tile bank.
//
// for Planet Probe more cases appear correct if we draw the list in reverse
// order, but it's also possible we should be drawing 2 swapped lists in
// forward order instead
void vastar_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
{
// for (int offs = 0; offs < 0x40; offs += 2)
for (int offs = 0x40-2; offs >=0; offs -= 2)
{
int code = ((m_spriteram3[offs] & 0xfc) >> 2) + ((m_spriteram2[offs] & 0x01) << 6)
+ ((offs & 0x20) << 2);
int sx = m_spriteram3[offs + 1];
int sy = m_spriteram1[offs];
int color = m_spriteram1[offs + 1] & 0x3f;
int flipx = m_spriteram3[offs] & 0x02;
int flipy = m_spriteram3[offs] & 0x01;
if (flip_screen())
{
flipx = !flipx;
flipy = !flipy;
}
if (m_spriteram2[offs] & 0x08) /* double width */
{
if (!flip_screen())
sy = 224 - sy;
m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
code/2,
color,
flipx,flipy,
sx,sy,0);
/* redraw with wraparound */
m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
code/2,
color,
flipx,flipy,
sx,sy+256,0);
}
else
{
if (!flip_screen())
sy = 240 - sy;
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
code,
color,
flipx,flipy,
sx,sy,0);
}
}
}
uint32_t vastar_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
for (int i = 0;i < 32;i++)
{
m_bg1_tilemap->set_scrolly(i,m_bg1_scroll[i]);
m_bg2_tilemap->set_scrolly(i,m_bg2_scroll[i]);
}
switch (*m_sprite_priority)
{
case 0:
m_bg1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
draw_sprites(bitmap,cliprect);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0);
break;
case 1: // ?? planet probe
m_bg1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0);
draw_sprites(bitmap,cliprect);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0);
break;
case 2:
m_bg1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
draw_sprites(bitmap,cliprect);
m_bg1_tilemap->draw(screen, bitmap, cliprect, 0,0);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0);
break;
case 3:
m_bg1_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0);
draw_sprites(bitmap,cliprect);
break;
default:
logerror("Unimplemented priority %X\n", *m_sprite_priority);
break;
}
return 0;
}
|