1
/***************************************************************************
5
*****************************************************************************
7
MO data has 12 bits total: MVID0-11
8
MVID9-11 form the priority
9
MVID0-9 form the color bits
11
PF data has 13 bits total: PF.VID0-12
12
PF.VID10-12 form the priority
13
PF.VID0-9 form the color bits
15
Upper bits come from the low 5 bits of the HSCROLL value in alpha RAM
16
Playfield bank comes from low 2 bits of the VSCROLL value in alpha RAM
17
For GX2, there are 4 bits of bank
19
****************************************************************************/
23
#include "video/atarirle.h"
24
#include "includes/atarig42.h"
28
/*************************************
32
*************************************/
34
static TILE_GET_INFO( get_alpha_tile_info )
36
atarig42_state *state = machine.driver_data<atarig42_state>();
37
UINT16 data = state->m_alpha[tile_index];
38
int code = data & 0xfff;
39
int color = (data >> 12) & 0x0f;
40
int opaque = data & 0x8000;
41
SET_TILE_INFO(1, code, color, opaque ? TILE_FORCE_LAYER0 : 0);
45
static TILE_GET_INFO( get_playfield_tile_info )
47
atarig42_state *state = machine.driver_data<atarig42_state>();
48
UINT16 data = state->m_playfield[tile_index];
49
int code = (state->m_playfield_tile_bank << 12) | (data & 0xfff);
50
int color = (state->m_playfield_base >> 5) + ((state->m_playfield_color_bank << 3) & 0x18) + ((data >> 12) & 7);
51
SET_TILE_INFO(0, code, color, (data >> 15) & 1);
52
tileinfo->category = (state->m_playfield_color_bank >> 2) & 7;
56
static TILEMAP_MAPPER( atarig42_playfield_scan )
58
int bank = 1 - (col / (num_cols / 2));
59
return bank * (num_rows * num_cols / 2) + row * (num_cols / 2) + (col % (num_cols / 2));
64
/*************************************
68
*************************************/
70
VIDEO_START( atarig42 )
72
atarig42_state *state = machine.driver_data<atarig42_state>();
74
/* blend the playfields and free the temporary one */
75
atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30);
77
/* initialize the playfield */
78
state->m_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarig42_playfield_scan, 8,8, 128,64);
80
/* initialize the motion objects */
81
state->m_rle = machine.device("rle");
83
/* initialize the alphanumerics */
84
state->m_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32);
85
tilemap_set_transparent_pen(state->m_alpha_tilemap, 0);
88
state->save_item(NAME(state->m_current_control));
89
state->save_item(NAME(state->m_playfield_tile_bank));
90
state->save_item(NAME(state->m_playfield_color_bank));
91
state->save_item(NAME(state->m_playfield_xscroll));
92
state->save_item(NAME(state->m_playfield_yscroll));
97
/*************************************
99
* Periodic scanline updater
101
*************************************/
103
WRITE16_HANDLER( atarig42_mo_control_w )
105
atarig42_state *state = space->machine().driver_data<atarig42_state>();
107
logerror("MOCONT = %d (scan = %d)\n", data, space->machine().primary_screen->vpos());
109
/* set the control value */
110
COMBINE_DATA(&state->m_current_control);
114
void atarig42_scanline_update(screen_device &screen, int scanline)
116
atarig42_state *state = screen.machine().driver_data<atarig42_state>();
117
UINT16 *base = &state->m_alpha[(scanline / 8) * 64 + 48];
120
if (scanline == 0) logerror("-------\n");
123
if (base >= &state->m_alpha[0x800])
126
/* update the playfield scrolls */
127
for (i = 0; i < 8; i++)
134
int newscroll = (word >> 5) & 0x3ff;
135
int newbank = word & 0x1f;
136
if (newscroll != state->m_playfield_xscroll)
138
if (scanline + i > 0)
139
screen.update_partial(scanline + i - 1);
140
tilemap_set_scrollx(state->m_playfield_tilemap, 0, newscroll);
141
state->m_playfield_xscroll = newscroll;
143
if (newbank != state->m_playfield_color_bank)
145
if (scanline + i > 0)
146
screen.update_partial(scanline + i - 1);
147
tilemap_mark_all_tiles_dirty(state->m_playfield_tilemap);
148
state->m_playfield_color_bank = newbank;
155
int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff;
156
int newbank = word & 7;
157
if (newscroll != state->m_playfield_yscroll)
159
if (scanline + i > 0)
160
screen.update_partial(scanline + i - 1);
161
tilemap_set_scrolly(state->m_playfield_tilemap, 0, newscroll);
162
state->m_playfield_yscroll = newscroll;
164
if (newbank != state->m_playfield_tile_bank)
166
if (scanline + i > 0)
167
screen.update_partial(scanline + i - 1);
168
tilemap_mark_all_tiles_dirty(state->m_playfield_tilemap);
169
state->m_playfield_tile_bank = newbank;
177
/*************************************
181
*************************************/
183
SCREEN_UPDATE( atarig42 )
185
atarig42_state *state = screen->machine().driver_data<atarig42_state>();
186
bitmap_t *priority_bitmap = screen->machine().priority_bitmap;
188
/* draw the playfield */
189
bitmap_fill(priority_bitmap, cliprect, 0);
190
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 0, 0);
191
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 1, 1);
192
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 2, 2);
193
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 3, 3);
194
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 4, 4);
195
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 5, 5);
196
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 6, 6);
197
tilemap_draw(bitmap, cliprect, state->m_playfield_tilemap, 7, 7);
199
/* copy the motion objects on top */
201
bitmap_t *mo_bitmap = atarirle_get_vram(state->m_rle, 0);
202
int left = cliprect->min_x;
203
int top = cliprect->min_y;
204
int right = cliprect->max_x + 1;
205
int bottom = cliprect->max_y + 1;
208
/* now blend with the playfield */
209
for (y = top; y < bottom; y++)
211
UINT16 *pf = (UINT16 *)bitmap->base + y * bitmap->rowpixels;
212
UINT16 *mo = (UINT16 *)mo_bitmap->base + y * mo_bitmap->rowpixels;
213
UINT8 *pri = (UINT8 *)priority_bitmap->base + priority_bitmap->rowpixels * y;
214
for (x = left; x < right; x++)
218
int mopri = mo[x] >> ATARIRLE_PRIORITY_SHIFT;
220
pf[x] = mo[x] & ATARIRLE_DATA_MASK;
225
/* add the alpha on top */
226
tilemap_draw(bitmap, cliprect, state->m_alpha_tilemap, 0, 0);
230
SCREEN_EOF( atarig42 )
232
atarig42_state *state = machine.driver_data<atarig42_state>();
234
atarirle_eof(state->m_rle);