~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/video/atarig42.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    Atari G42 hardware
4
 
 
5
 
*****************************************************************************
6
 
 
7
 
    MO data has 12 bits total: MVID0-11
8
 
    MVID9-11 form the priority
9
 
    MVID0-9 form the color bits
10
 
 
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
14
 
 
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
18
 
 
19
 
****************************************************************************/
20
 
 
21
 
 
22
 
#include "emu.h"
23
 
#include "video/atarirle.h"
24
 
#include "includes/atarig42.h"
25
 
 
26
 
 
27
 
 
28
 
/*************************************
29
 
 *
30
 
 *  Tilemap callbacks
31
 
 *
32
 
 *************************************/
33
 
 
34
 
static TILE_GET_INFO( get_alpha_tile_info )
35
 
{
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);
42
 
}
43
 
 
44
 
 
45
 
static TILE_GET_INFO( get_playfield_tile_info )
46
 
{
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;
53
 
}
54
 
 
55
 
 
56
 
static TILEMAP_MAPPER( atarig42_playfield_scan )
57
 
{
58
 
        int bank = 1 - (col / (num_cols / 2));
59
 
        return bank * (num_rows * num_cols / 2) + row * (num_cols / 2) + (col % (num_cols / 2));
60
 
}
61
 
 
62
 
 
63
 
 
64
 
/*************************************
65
 
 *
66
 
 *  Video system start
67
 
 *
68
 
 *************************************/
69
 
 
70
 
VIDEO_START( atarig42 )
71
 
{
72
 
        atarig42_state *state = machine.driver_data<atarig42_state>();
73
 
 
74
 
        /* blend the playfields and free the temporary one */
75
 
        atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30);
76
 
 
77
 
        /* initialize the playfield */
78
 
        state->m_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarig42_playfield_scan,  8,8, 128,64);
79
 
 
80
 
        /* initialize the motion objects */
81
 
        state->m_rle = machine.device("rle");
82
 
 
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);
86
 
 
87
 
        /* save states */
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));
93
 
}
94
 
 
95
 
 
96
 
 
97
 
/*************************************
98
 
 *
99
 
 *  Periodic scanline updater
100
 
 *
101
 
 *************************************/
102
 
 
103
 
WRITE16_HANDLER( atarig42_mo_control_w )
104
 
{
105
 
        atarig42_state *state = space->machine().driver_data<atarig42_state>();
106
 
 
107
 
        logerror("MOCONT = %d (scan = %d)\n", data, space->machine().primary_screen->vpos());
108
 
 
109
 
        /* set the control value */
110
 
        COMBINE_DATA(&state->m_current_control);
111
 
}
112
 
 
113
 
 
114
 
void atarig42_scanline_update(screen_device &screen, int scanline)
115
 
{
116
 
        atarig42_state *state = screen.machine().driver_data<atarig42_state>();
117
 
        UINT16 *base = &state->m_alpha[(scanline / 8) * 64 + 48];
118
 
        int i;
119
 
 
120
 
        if (scanline == 0) logerror("-------\n");
121
 
 
122
 
        /* keep in range */
123
 
        if (base >= &state->m_alpha[0x800])
124
 
                return;
125
 
 
126
 
        /* update the playfield scrolls */
127
 
        for (i = 0; i < 8; i++)
128
 
        {
129
 
                UINT16 word;
130
 
 
131
 
                word = *base++;
132
 
                if (word & 0x8000)
133
 
                {
134
 
                        int newscroll = (word >> 5) & 0x3ff;
135
 
                        int newbank = word & 0x1f;
136
 
                        if (newscroll != state->m_playfield_xscroll)
137
 
                        {
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;
142
 
                        }
143
 
                        if (newbank != state->m_playfield_color_bank)
144
 
                        {
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;
149
 
                        }
150
 
                }
151
 
 
152
 
                word = *base++;
153
 
                if (word & 0x8000)
154
 
                {
155
 
                        int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff;
156
 
                        int newbank = word & 7;
157
 
                        if (newscroll != state->m_playfield_yscroll)
158
 
                        {
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;
163
 
                        }
164
 
                        if (newbank != state->m_playfield_tile_bank)
165
 
                        {
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;
170
 
                        }
171
 
                }
172
 
        }
173
 
}
174
 
 
175
 
 
176
 
 
177
 
/*************************************
178
 
 *
179
 
 *  Main refresh
180
 
 *
181
 
 *************************************/
182
 
 
183
 
SCREEN_UPDATE( atarig42 )
184
 
{
185
 
        atarig42_state *state = screen->machine().driver_data<atarig42_state>();
186
 
        bitmap_t *priority_bitmap = screen->machine().priority_bitmap;
187
 
 
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);
198
 
 
199
 
        /* copy the motion objects on top */
200
 
        {
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;
206
 
                int x, y;
207
 
 
208
 
                /* now blend with the playfield */
209
 
                for (y = top; y < bottom; y++)
210
 
                {
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++)
215
 
                                if (mo[x])
216
 
                                {
217
 
                                        int pfpri = pri[x];
218
 
                                        int mopri = mo[x] >> ATARIRLE_PRIORITY_SHIFT;
219
 
                                        if (mopri >= pfpri)
220
 
                                                pf[x] = mo[x] & ATARIRLE_DATA_MASK;
221
 
                                }
222
 
                }
223
 
        }
224
 
 
225
 
        /* add the alpha on top */
226
 
        tilemap_draw(bitmap, cliprect, state->m_alpha_tilemap, 0, 0);
227
 
        return 0;
228
 
}
229
 
 
230
 
SCREEN_EOF( atarig42 )
231
 
{
232
 
        atarig42_state *state = machine.driver_data<atarig42_state>();
233
 
 
234
 
        atarirle_eof(state->m_rle);
235
 
}