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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
// license:BSD-3-Clause
// copyright-holders:David Haywood
/*
Excellent Systems Sprite chip
is this original hw or a clone of something?
possible chips:
ES 9207 & ES 9303 are near the sprite ROM (aquarium)
ES 9208 is near the tilemap ROM so probably not the sprite chip
todo: collapse to single draw function instead of one for each game
*/
#include "emu.h"
#include "excellent_spr.h"
#include "screen.h"
DEFINE_DEVICE_TYPE(EXCELLENT_SPRITE, excellent_spr_device, "excellent_spr", "Excellent 8-bit Sprite")
excellent_spr_device::excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, EXCELLENT_SPRITE, tag, owner, clock)
, device_gfx_interface(mconfig, *this, nullptr)
, device_video_interface(mconfig, *this)
, m_colpri_cb(*this)
, m_gfx_region(*this, DEVICE_SELF)
, m_colbase(0)
{
}
void excellent_spr_device::device_start()
{
/* 16x16x4 */
gfx_layout layout_16x16x4 =
{
16,16, /* 16*16 sprites */
0,
4, /* 4 bits per pixel */
// { 16, 48, 0, 32 },
{ 48, 16, 32, 0 },
{ STEP16(0,1) },
{ STEP16(0,16*4) },
16*16*4 /* every sprite takes 128 consecutive bytes */
};
layout_16x16x4.total = m_gfx_region->bytes() / ((16*16*4) / 8);
m_colpri_cb.resolve();
m_ram = make_unique_clear<u8[]>(0x1000);
save_pointer(NAME(m_ram), 0x1000);
set_gfx(0, std::make_unique<gfx_element>(&palette(), layout_16x16x4, m_gfx_region->base(), 0, 0x10, m_colbase));
}
u8 excellent_spr_device::read(offs_t offset)
{
return m_ram[offset];
}
void excellent_spr_device::write(offs_t offset, u8 data)
{
m_ram[offset] = data;
}
void excellent_spr_device::device_reset()
{
}
/****************************************************************
SPRITE DRAW ROUTINE
(8-bit)
Word | Bit(s) | Use
-----+-----------------+-----------------
0 | xxxxxxxx| X lo
1 | xxxxxxxx| X hi
2 | xxxxxxxx| Y lo
3 | xxxxxxxx| Y hi
4 | x.......| Disable
4 | ...x....| Flip Y
4 | ....x...| 1 = Y chain, 0 = X chain
4 | .....xxx| Chain size
5 | ??xxxxxx| Tile (low)
6 | xxxxxxxx| Tile (high)
7 | ....xxxx| Color Bank
****************************************************************/
void excellent_spr_device::aquarium_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs)
{
const bool priority = !m_colpri_cb.isnull();
int start, end, inc;
if (priority) { start = 0x1000 - 8; end = -8; inc = -8; }
else { start = 0; end = 0x1000; inc = +8; }
for (int offs = start; offs != end; offs += inc)
{
u32 code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8);
code &= 0x3fff;
if (!(m_ram[offs + 4] & 0x80)) /* active sprite ? */
{
int x = ((m_ram[offs + 0]) & 0xff) + (((m_ram[offs + 1]) & 0xff) << 8);
int y = ((m_ram[offs + 2]) & 0xff) + (((m_ram[offs + 3]) & 0xff) << 8);
/* Treat coords as signed */
if (x & 0x8000) x -= 0x10000;
if (y & 0x8000) y -= 0x10000;
u32 pri_mask = 0;
u32 colour = ((m_ram[offs + 7]) & 0x0f);
const u8 chain = (m_ram[offs + 4]) & 0x07;
const bool flipy = (m_ram[offs + 4]) & 0x10;
const bool flipx = (m_ram[offs + 4]) & 0x20;
if (priority)
m_colpri_cb(colour, pri_mask);
int curx = x;
int cury = y;
if (((m_ram[offs + 4]) & 0x08) && flipy)
cury += (chain * 16);
if (!(((m_ram[offs + 4]) & 0x08)) && flipx)
curx += (chain * 16);
for (int chain_pos = chain; chain_pos >= 0; chain_pos--)
{
if (priority)
{
gfx(0)->prio_transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury,
screen.priority(),pri_mask,0);
/* wrap around y */
gfx(0)->prio_transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury + 256,
screen.priority(),pri_mask,0);
}
else
{
gfx(0)->transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury,0);
/* wrap around y */
gfx(0)->transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury + 256,0);
}
code++;
if ((m_ram[offs + 4]) & 0x08) /* Y chain */
{
if (flipy)
cury -= 16;
else
cury += 16;
}
else /* X chain */
{
if (flipx)
curx -= 16;
else
curx += 16;
}
}
}
}
#if 0
if (rotate)
{
char buf[80];
sprintf(buf, "sprite rotate offs %04x ?", rotate);
popmessage(buf);
}
#endif
}
void excellent_spr_device::gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs)
{
const bool priority = !m_colpri_cb.isnull();
int start, end, inc;
if (priority) { start = 0x1000 - 8; end = -8; inc = -8; }
else { start = 0; end = 0x1000; inc = +8; }
for (int offs = start; offs != end; offs += inc)
{
u32 code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8);
code &= 0x3fff;
if (!(m_ram[offs + 4] & 0x80)) /* active sprite ? */
{
int x = ((m_ram[offs + 0]) & 0xff) + (((m_ram[offs + 1]) & 0xff) << 8);
int y = ((m_ram[offs + 2]) & 0xff) + (((m_ram[offs + 3]) & 0xff) << 8);
/* Treat coords as signed */
if (x & 0x8000) x -= 0x10000;
if (y & 0x8000) y -= 0x10000;
u32 pri_mask = 0;
u32 colour = ((m_ram[offs + 7]) & 0x0f);
const u8 chain = (m_ram[offs + 4]) & 0x07;
const bool flipy = (m_ram[offs + 4]) & 0x10;
const bool flipx = 0;
if (priority)
m_colpri_cb(colour, pri_mask);
int curx = x;
int cury = y;
if (((m_ram[offs + 4]) & 0x08) && flipy)
cury += (chain * 16);
for (int chain_pos = chain; chain_pos >= 0; chain_pos--)
{
if (priority)
{
gfx(0)->prio_transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury,
screen.priority(),pri_mask,0);
}
else
{
gfx(0)->transpen(bitmap,cliprect,
code,
colour,
flipx, flipy,
curx,cury,
0);
}
code++;
if ((m_ram[offs + 4]) & 0x08) /* Y chain */
{
if (flipy) cury -= 16;
else cury += 16;
}
else /* X chain */
{
curx += 16;
}
}
}
}
#if 0
if (rotate)
{
char buf[80];
sprintf(buf, "sprite rotate offs %04x ?", rotate);
popmessage(buf);
}
#endif
}
|