~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/video/ccastles.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
VIDEO_START( ccastles )
19
19
{
20
 
        ccastles_state *state = machine->driver_data<ccastles_state>();
 
20
        ccastles_state *state = machine.driver_data<ccastles_state>();
21
21
        static const int resistances[3] = { 22000, 10000, 4700 };
22
22
 
23
23
        /* get pointers to our PROMs */
24
 
        state->syncprom = machine->region("proms")->base() + 0x000;
25
 
        state->wpprom = machine->region("proms")->base() + 0x200;
26
 
        state->priprom = machine->region("proms")->base() + 0x300;
 
24
        state->m_syncprom = machine.region("proms")->base() + 0x000;
 
25
        state->m_wpprom = machine.region("proms")->base() + 0x200;
 
26
        state->m_priprom = machine.region("proms")->base() + 0x300;
27
27
 
28
28
        /* compute the color output resistor weights at startup */
29
29
        compute_resistor_weights(0,     255, -1.0,
30
 
                        3,      resistances, state->rweights, 1000, 0,
31
 
                        3,      resistances, state->gweights, 1000, 0,
32
 
                        3,      resistances, state->bweights, 1000, 0);
 
30
                        3,      resistances, state->m_rweights, 1000, 0,
 
31
                        3,      resistances, state->m_gweights, 1000, 0,
 
32
                        3,      resistances, state->m_bweights, 1000, 0);
33
33
 
34
34
        /* allocate a bitmap for drawing sprites */
35
 
        state->spritebitmap = machine->primary_screen->alloc_compatible_bitmap();
 
35
        state->m_spritebitmap = machine.primary_screen->alloc_compatible_bitmap();
36
36
 
37
37
        /* register for savestates */
38
 
        state_save_register_global_array(machine, state->video_control);
39
 
        state_save_register_global_array(machine, state->bitmode_addr);
40
 
        state_save_register_global(machine, state->hscroll);
41
 
        state_save_register_global(machine, state->vscroll);
 
38
        state->save_item(NAME(state->m_video_control));
 
39
        state->save_item(NAME(state->m_bitmode_addr));
 
40
        state->save_item(NAME(state->m_hscroll));
 
41
        state->save_item(NAME(state->m_vscroll));
42
42
}
43
43
 
44
44
 
51
51
 
52
52
WRITE8_HANDLER( ccastles_hscroll_w )
53
53
{
54
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
55
 
        space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos());
56
 
        state->hscroll = data;
 
54
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
 
55
        space->machine().primary_screen->update_partial(space->machine().primary_screen->vpos());
 
56
        state->m_hscroll = data;
57
57
}
58
58
 
59
59
 
60
60
WRITE8_HANDLER( ccastles_vscroll_w )
61
61
{
62
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
63
 
        state->vscroll = data;
 
62
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
 
63
        state->m_vscroll = data;
64
64
}
65
65
 
66
66
 
67
67
WRITE8_HANDLER( ccastles_video_control_w )
68
68
{
69
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
 
69
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
70
70
        /* only D3 matters */
71
 
        state->video_control[offset] = (data >> 3) & 1;
 
71
        state->m_video_control[offset] = (data >> 3) & 1;
72
72
}
73
73
 
74
74
 
81
81
 
82
82
WRITE8_HANDLER( ccastles_paletteram_w )
83
83
{
84
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
 
84
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
85
85
        int bit0, bit1, bit2;
86
86
        int r, g, b;
87
87
 
94
94
        bit0 = (~r >> 0) & 0x01;
95
95
        bit1 = (~r >> 1) & 0x01;
96
96
        bit2 = (~r >> 2) & 0x01;
97
 
        r = combine_3_weights(state->rweights, bit0, bit1, bit2);
 
97
        r = combine_3_weights(state->m_rweights, bit0, bit1, bit2);
98
98
 
99
99
        /* green component (inverted) */
100
100
        bit0 = (~g >> 0) & 0x01;
101
101
        bit1 = (~g >> 1) & 0x01;
102
102
        bit2 = (~g >> 2) & 0x01;
103
 
        g = combine_3_weights(state->gweights, bit0, bit1, bit2);
 
103
        g = combine_3_weights(state->m_gweights, bit0, bit1, bit2);
104
104
 
105
105
        /* blue component (inverted) */
106
106
        bit0 = (~b >> 0) & 0x01;
107
107
        bit1 = (~b >> 1) & 0x01;
108
108
        bit2 = (~b >> 2) & 0x01;
109
 
        b = combine_3_weights(state->bweights, bit0, bit1, bit2);
 
109
        b = combine_3_weights(state->m_bweights, bit0, bit1, bit2);
110
110
 
111
 
        palette_set_color(space->machine, offset & 0x1f, MAKE_RGB(r, g, b));
 
111
        palette_set_color(space->machine(), offset & 0x1f, MAKE_RGB(r, g, b));
112
112
}
113
113
 
114
114
 
120
120
 *
121
121
 *************************************/
122
122
 
123
 
INLINE void ccastles_write_vram( running_machine *machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
 
123
INLINE void ccastles_write_vram( running_machine &machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
124
124
{
125
 
        ccastles_state *state = machine->driver_data<ccastles_state>();
126
 
        UINT8 *dest = &state->videoram[addr & 0x7ffe];
 
125
        ccastles_state *state = machine.driver_data<ccastles_state>();
 
126
        UINT8 *dest = &state->m_videoram[addr & 0x7ffe];
127
127
        UINT8 promaddr = 0;
128
128
        UINT8 wpbits;
129
129
 
146
146
        promaddr |= (pixba << 0);
147
147
 
148
148
        /* look up the PROM result */
149
 
        wpbits = state->wpprom[promaddr];
 
149
        wpbits = state->m_wpprom[promaddr];
150
150
 
151
151
        /* write to the appropriate parts of VRAM depending on the result */
152
152
        if (!(wpbits & 1))
167
167
 *
168
168
 *************************************/
169
169
 
170
 
INLINE void bitmode_autoinc( running_machine *machine )
 
170
INLINE void bitmode_autoinc( running_machine &machine )
171
171
{
172
 
        ccastles_state *state = machine->driver_data<ccastles_state>();
 
172
        ccastles_state *state = machine.driver_data<ccastles_state>();
173
173
 
174
174
        /* auto increment in the x-direction if it's enabled */
175
 
        if (!state->video_control[0])   /* /AX */
 
175
        if (!state->m_video_control[0]) /* /AX */
176
176
        {
177
 
                if (!state->video_control[2])   /* /XINC */
178
 
                        state->bitmode_addr[0]++;
 
177
                if (!state->m_video_control[2]) /* /XINC */
 
178
                        state->m_bitmode_addr[0]++;
179
179
                else
180
 
                        state->bitmode_addr[0]--;
 
180
                        state->m_bitmode_addr[0]--;
181
181
        }
182
182
 
183
183
        /* auto increment in the y-direction if it's enabled */
184
 
        if (!state->video_control[1])   /* /AY */
 
184
        if (!state->m_video_control[1]) /* /AY */
185
185
        {
186
 
                if (!state->video_control[3])   /* /YINC */
187
 
                        state->bitmode_addr[1]++;
 
186
                if (!state->m_video_control[3]) /* /YINC */
 
187
                        state->m_bitmode_addr[1]++;
188
188
                else
189
 
                        state->bitmode_addr[1]--;
 
189
                        state->m_bitmode_addr[1]--;
190
190
        }
191
191
}
192
192
 
201
201
WRITE8_HANDLER( ccastles_videoram_w )
202
202
{
203
203
        /* direct writes to VRAM go through the write protect PROM as well */
204
 
        ccastles_write_vram(space->machine, offset, data, 0, 0);
 
204
        ccastles_write_vram(space->machine(), offset, data, 0, 0);
205
205
}
206
206
 
207
207
 
214
214
 
215
215
READ8_HANDLER( ccastles_bitmode_r )
216
216
{
217
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
 
217
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
218
218
 
219
219
        /* in bitmode, the address comes from the autoincrement latches */
220
 
        UINT16 addr = (state->bitmode_addr[1] << 7) | (state->bitmode_addr[0] >> 1);
 
220
        UINT16 addr = (state->m_bitmode_addr[1] << 7) | (state->m_bitmode_addr[0] >> 1);
221
221
 
222
222
        /* the appropriate pixel is selected into the upper 4 bits */
223
 
        UINT8 result = state->videoram[addr] << ((~state->bitmode_addr[0] & 1) * 4);
 
223
        UINT8 result = state->m_videoram[addr] << ((~state->m_bitmode_addr[0] & 1) * 4);
224
224
 
225
225
        /* autoincrement because /BITMD was selected */
226
 
        bitmode_autoinc(space->machine);
 
226
        bitmode_autoinc(space->machine());
227
227
 
228
228
        /* the low 4 bits of the data lines are not driven so make them all 1's */
229
229
        return result | 0x0f;
232
232
 
233
233
WRITE8_HANDLER( ccastles_bitmode_w )
234
234
{
235
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
 
235
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
236
236
 
237
237
        /* in bitmode, the address comes from the autoincrement latches */
238
 
        UINT16 addr = (state->bitmode_addr[1] << 7) | (state->bitmode_addr[0] >> 1);
 
238
        UINT16 addr = (state->m_bitmode_addr[1] << 7) | (state->m_bitmode_addr[0] >> 1);
239
239
 
240
240
        /* the upper 4 bits of data are replicated to the lower 4 bits */
241
241
        data = (data & 0xf0) | (data >> 4);
242
242
 
243
243
        /* write through the generic VRAM routine, passing the low 2 X bits as PIXB/PIXA */
244
 
        ccastles_write_vram(space->machine, addr, data, 1, state->bitmode_addr[0] & 3);
 
244
        ccastles_write_vram(space->machine(), addr, data, 1, state->m_bitmode_addr[0] & 3);
245
245
 
246
246
        /* autoincrement because /BITMD was selected */
247
 
        bitmode_autoinc(space->machine);
 
247
        bitmode_autoinc(space->machine());
248
248
}
249
249
 
250
250
 
251
251
WRITE8_HANDLER( ccastles_bitmode_addr_w )
252
252
{
253
 
        ccastles_state *state = space->machine->driver_data<ccastles_state>();
 
253
        ccastles_state *state = space->machine().driver_data<ccastles_state>();
254
254
 
255
255
        /* write through to video RAM and also to the addressing latches */
256
 
        ccastles_write_vram(space->machine, offset, data, 0, 0);
257
 
        state->bitmode_addr[offset] = data;
 
256
        ccastles_write_vram(space->machine(), offset, data, 0, 0);
 
257
        state->m_bitmode_addr[offset] = data;
258
258
}
259
259
 
260
260
 
265
265
 *
266
266
 *************************************/
267
267
 
268
 
VIDEO_UPDATE( ccastles )
 
268
SCREEN_UPDATE( ccastles )
269
269
{
270
 
        ccastles_state *state = screen->machine->driver_data<ccastles_state>();
271
 
        UINT8 *spriteaddr = &state->spriteram[state->video_control[7] * 0x100]; /* BUF1/BUF2 */
272
 
        int flip = state->video_control[4] ? 0xff : 0x00;       /* PLAYER2 */
273
 
        pen_t black = get_black_pen(screen->machine);
 
270
        ccastles_state *state = screen->machine().driver_data<ccastles_state>();
 
271
        UINT8 *spriteaddr = &state->m_spriteram[state->m_video_control[7] * 0x100];     /* BUF1/BUF2 */
 
272
        int flip = state->m_video_control[4] ? 0xff : 0x00;     /* PLAYER2 */
 
273
        pen_t black = get_black_pen(screen->machine());
274
274
        int x, y, offs;
275
275
 
276
276
        /* draw the sprites */
277
 
        bitmap_fill(state->spritebitmap, cliprect, 0x0f);
 
277
        bitmap_fill(state->m_spritebitmap, cliprect, 0x0f);
278
278
        for (offs = 0; offs < 320/2; offs += 4)
279
279
        {
280
280
                int x = spriteaddr[offs + 3];
282
282
                int which = spriteaddr[offs];
283
283
                int color = spriteaddr[offs + 2] >> 7;
284
284
 
285
 
                drawgfx_transpen(state->spritebitmap, cliprect, screen->machine->gfx[0], which, color, flip, flip, x, y, 7);
 
285
                drawgfx_transpen(state->m_spritebitmap, cliprect, screen->machine().gfx[0], which, color, flip, flip, x, y, 7);
286
286
        }
287
287
 
288
288
        /* draw the bitmap to the screen, looping over Y */
291
291
                UINT16 *dst = (UINT16 *)bitmap->base + y * bitmap->rowpixels;
292
292
 
293
293
                /* if we're in the VBLANK region, just fill with black */
294
 
                if (state->syncprom[y] & 1)
 
294
                if (state->m_syncprom[y] & 1)
295
295
                {
296
296
                        for (x = cliprect->min_x; x <= cliprect->max_x; x++)
297
297
                                dst[x] = black;
300
300
                /* non-VBLANK region: merge the sprites and the bitmap */
301
301
                else
302
302
                {
303
 
                        UINT16 *mosrc = (UINT16 *)state->spritebitmap->base + y * state->spritebitmap->rowpixels;
304
 
                        int effy = (((y - state->vblank_end) + (flip ? 0 : state->vscroll)) ^ flip) & 0xff;
 
303
                        UINT16 *mosrc = (UINT16 *)state->m_spritebitmap->base + y * state->m_spritebitmap->rowpixels;
 
304
                        int effy = (((y - state->m_vblank_end) + (flip ? 0 : state->m_vscroll)) ^ flip) & 0xff;
305
305
                        UINT8 *src;
306
306
 
307
307
                        /* the "POTATO" chip does some magic here; this is just a guess */
308
308
                        if (effy < 24)
309
309
                                effy = 24;
310
 
                        src = &state->videoram[effy * 128];
 
310
                        src = &state->m_videoram[effy * 128];
311
311
 
312
312
                        /* loop over X */
313
313
                        for (x = cliprect->min_x; x <= cliprect->max_x; x++)
319
319
                                /* otherwise, process normally */
320
320
                                else
321
321
                                {
322
 
                                        int effx = (state->hscroll + (x ^ flip)) & 255;
 
322
                                        int effx = (state->m_hscroll + (x ^ flip)) & 255;
323
323
 
324
324
                                        /* low 4 bits = left pixel, high 4 bits = right pixel */
325
325
                                        UINT8 pix = (src[effx / 2] >> ((effx & 1) * 4)) & 0x0f;
341
341
                                        prindex |= (mopix & 7) << 2;
342
342
                                        prindex |= (mopix & 8) >> 2;
343
343
                                        prindex |= (pix & 8) >> 3;
344
 
                                        prvalue = state->priprom[prindex];
 
344
                                        prvalue = state->m_priprom[prindex];
345
345
 
346
346
                                        /* Bit 1 of prvalue selects the low 4 bits of the final pixel */
347
347
                                        if (prvalue & 2)