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
|
// license:BSD-3-Clause
// copyright-holders:Mike Balfour, Patrick Lawrence, Brad Oliver
/*************************************************************************
Atari Football hardware
*************************************************************************/
#include "emu.h"
#include "includes/atarifb.h"
/*************************************
*
* Palette generation
*
*************************************/
void atarifb_state::atarifb_palette(palette_device &palette) const
{
// chars
palette.set_pen_color(0, rgb_t(0xff,0xff,0xff));
palette.set_pen_color(1, rgb_t(0x00,0x00,0x00));
// field
palette.set_pen_color(2, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(3, rgb_t(0xc0,0xc0,0xc0));
// sprites
palette.set_pen_color(4, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(5, rgb_t(0xff,0xff,0xff));
palette.set_pen_color(6, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(7, rgb_t(0x00,0x00,0x00));
// sprite masks
palette.set_pen_color(8, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(9, rgb_t(0x80,0x80,0x80));
palette.set_pen_color(10, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(11, rgb_t(0x00,0x00,0x00));
palette.set_pen_color(12, rgb_t(0x40,0x40,0x40));
palette.set_pen_color(13, rgb_t(0xff,0xff,0xff));
}
/*************************************
*
* Tilemap callbacks
*
*************************************/
void atarifb_state::get_tile_info_common( tile_data &tileinfo, tilemap_memory_index tile_index, uint8_t *alpha_videoram )
{
int code = alpha_videoram[tile_index] & 0x3f;
int flip = alpha_videoram[tile_index] & 0x40;
int disable = alpha_videoram[tile_index] & 0x80;
if (disable)
code = 0; /* I *know* this is a space */
tileinfo.set(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0));
}
TILE_GET_INFO_MEMBER(atarifb_state::alpha1_get_tile_info)
{
get_tile_info_common(tileinfo, tile_index, m_alphap1_videoram);
}
TILE_GET_INFO_MEMBER(atarifb_state::alpha2_get_tile_info)
{
get_tile_info_common(tileinfo, tile_index, m_alphap2_videoram);
}
TILE_GET_INFO_MEMBER(atarifb_state::field_get_tile_info)
{
int code = m_field_videoram[tile_index] & 0x3f;
int flipyx = m_field_videoram[tile_index] >> 6;
tileinfo.set(1, code, 0, TILE_FLIPYX(flipyx));
}
/*************************************
*
* Video RAM writes
*
*************************************/
void atarifb_state::atarifb_alpha1_videoram_w(offs_t offset, uint8_t data)
{
m_alphap1_videoram[offset] = data;
m_alpha1_tilemap->mark_tile_dirty(offset);
}
void atarifb_state::atarifb_alpha2_videoram_w(offs_t offset, uint8_t data)
{
m_alphap2_videoram[offset] = data;
m_alpha2_tilemap->mark_tile_dirty(offset);
}
void atarifb_state::atarifb_field_videoram_w(offs_t offset, uint8_t data)
{
m_field_videoram[offset] = data;
m_field_tilemap->mark_tile_dirty(offset);
}
/*************************************
*
* Video system start
*
*************************************/
void atarifb_state::video_start()
{
m_alpha1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(atarifb_state::alpha1_get_tile_info)), TILEMAP_SCAN_COLS, 8, 8, 3, 32);
m_alpha2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(atarifb_state::alpha2_get_tile_info)), TILEMAP_SCAN_COLS, 8, 8, 3, 32);
m_field_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(atarifb_state::field_get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
}
void atarifb_state::draw_playfield_and_alpha( bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset )
{
bitmap.fill(1, cliprect);
rectangle clip(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1);
clip &= cliprect;
int scroll_x[1];
int scroll_y[1];
scroll_x[0] = - *m_scroll_register + 32 + playfield_x_offset;
scroll_y[0] = 8 + playfield_y_offset;
copybitmap(bitmap, m_alpha1_tilemap->pixmap(), 0, 0, 35*8, 1*8, cliprect);
copybitmap(bitmap, m_alpha2_tilemap->pixmap(), 0, 0, 0*8, 1*8, cliprect);
copyscrollbitmap(bitmap, m_field_tilemap->pixmap(), 1, scroll_x, 1, scroll_y, clip);
}
void atarifb_state::draw_sprites_atarifb( bitmap_ind16 &bitmap, const rectangle &cliprect)
{
rectangle clip(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1);
clip &= cliprect;
for (int obj = 0; obj < 16; obj++)
{
int charcode = m_spriteram[obj * 2] & 0x3f;
int flipx = (m_spriteram[obj * 2] & 0x40);
int flipy = (m_spriteram[obj * 2] & 0x80);
int sx = m_spriteram[obj * 2 + 0x20] + 8 * 3;
int sy = 256 - m_spriteram[obj * 2 + 1];
m_gfxdecode->gfx(1)->transpen(bitmap, clip, charcode, 1, flipx, flipy, sx, sy, 0);
}
}
void atarifb_state::draw_sprites_soccer( bitmap_ind16 &bitmap, const rectangle &cliprect)
{
rectangle clip(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1);
clip &= cliprect;
for (int obj = 0; obj < 16; obj++)
{
int charcode = m_spriteram[obj * 2] & 0x3f;
int flipx = (m_spriteram[obj * 2] & 0x40);
int flipy = (m_spriteram[obj * 2] & 0x80);
int sx = m_spriteram[obj * 2 + 0x20] + 8 * 3;
int sy = 256 - m_spriteram[obj * 2 + 1] - 8;
/* There are 3 sets of 2 bits each, where the 2 bits represent */
/* black, dk grey, grey and white. I think the 3 sets determine the */
/* color of each bit in the sprite, but I haven't implemented it that way. */
int shade = m_spriteram[obj * 2 + 1 + 0x20];
m_gfxdecode->gfx(3)->transpen(bitmap, clip, charcode, shade & 7, flipx, flipy, sx, sy, 0);
m_gfxdecode->gfx(2)->transpen(bitmap, clip, charcode, shade >> 3 & 1, flipx, flipy, sx, sy, 0);
}
}
uint32_t atarifb_state::screen_update_atarifb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
draw_playfield_and_alpha(bitmap, cliprect, 0, 0);
draw_sprites_atarifb(bitmap, cliprect);
return 0;
}
uint32_t atarifb_state::screen_update_abaseb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
draw_playfield_and_alpha(bitmap, cliprect, -8, 0);
draw_sprites_atarifb(bitmap, cliprect);
return 0;
}
uint32_t atarifb_state::screen_update_soccer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
draw_playfield_and_alpha(bitmap, cliprect, 0, 0);
draw_sprites_soccer(bitmap, cliprect);
return 0;
}
|