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

« back to all changes in this revision

Viewing changes to src/mame/video/cloud9.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( cloud9 )
19
19
{
20
 
        cloud9_state *state = machine->driver_data<cloud9_state>();
 
20
        cloud9_state *state = machine.driver_data<cloud9_state>();
21
21
        static const int resistances[3] = { 22000, 10000, 4700 };
22
22
 
23
23
        /* allocate second bank of videoram */
24
 
        state->videoram = auto_alloc_array(machine, UINT8, 0x8000);
25
 
        memory_set_bankptr(machine, "bank1", state->videoram);
 
24
        state->m_videoram = auto_alloc_array(machine, UINT8, 0x8000);
 
25
        memory_set_bankptr(machine, "bank1", state->m_videoram);
26
26
 
27
27
        /* get pointers to our PROMs */
28
 
        state->syncprom = machine->region("proms")->base() + 0x000;
29
 
        state->wpprom = machine->region("proms")->base() + 0x200;
30
 
        state->priprom = machine->region("proms")->base() + 0x300;
 
28
        state->m_syncprom = machine.region("proms")->base() + 0x000;
 
29
        state->m_wpprom = machine.region("proms")->base() + 0x200;
 
30
        state->m_priprom = machine.region("proms")->base() + 0x300;
31
31
 
32
32
        /* compute the color output resistor weights at startup */
33
33
        compute_resistor_weights(0,     255, -1.0,
34
 
                        3,      resistances, state->rweights, 1000, 0,
35
 
                        3,      resistances, state->gweights, 1000, 0,
36
 
                        3,      resistances, state->bweights, 1000, 0);
 
34
                        3,      resistances, state->m_rweights, 1000, 0,
 
35
                        3,      resistances, state->m_gweights, 1000, 0,
 
36
                        3,      resistances, state->m_bweights, 1000, 0);
37
37
 
38
38
        /* allocate a bitmap for drawing sprites */
39
 
        state->spritebitmap = machine->primary_screen->alloc_compatible_bitmap();
 
39
        state->m_spritebitmap = machine.primary_screen->alloc_compatible_bitmap();
40
40
 
41
41
        /* register for savestates */
42
 
        state_save_register_global_pointer(machine, state->videoram, 0x8000);
43
 
        state_save_register_global_array(machine, state->video_control);
44
 
        state_save_register_global_array(machine, state->bitmode_addr);
 
42
        state->save_pointer(NAME(state->m_videoram), 0x8000);
 
43
        state->save_item(NAME(state->m_video_control));
 
44
        state->save_item(NAME(state->m_bitmode_addr));
45
45
}
46
46
 
47
47
 
54
54
 
55
55
WRITE8_HANDLER( cloud9_video_control_w )
56
56
{
57
 
        cloud9_state *state = space->machine->driver_data<cloud9_state>();
 
57
        cloud9_state *state = space->machine().driver_data<cloud9_state>();
58
58
 
59
59
        /* only D7 matters */
60
 
        state->video_control[offset] = (data >> 7) & 1;
 
60
        state->m_video_control[offset] = (data >> 7) & 1;
61
61
}
62
62
 
63
63
 
70
70
 
71
71
WRITE8_HANDLER( cloud9_paletteram_w )
72
72
{
73
 
        cloud9_state *state = space->machine->driver_data<cloud9_state>();
 
73
        cloud9_state *state = space->machine().driver_data<cloud9_state>();
74
74
        int bit0, bit1, bit2;
75
75
        int r, g, b;
76
76
 
83
83
        bit0 = (~r >> 0) & 0x01;
84
84
        bit1 = (~r >> 1) & 0x01;
85
85
        bit2 = (~r >> 2) & 0x01;
86
 
        r = combine_3_weights(state->rweights, bit0, bit1, bit2);
 
86
        r = combine_3_weights(state->m_rweights, bit0, bit1, bit2);
87
87
 
88
88
        /* green component (inverted) */
89
89
        bit0 = (~g >> 0) & 0x01;
90
90
        bit1 = (~g >> 1) & 0x01;
91
91
        bit2 = (~g >> 2) & 0x01;
92
 
        g = combine_3_weights(state->gweights, bit0, bit1, bit2);
 
92
        g = combine_3_weights(state->m_gweights, bit0, bit1, bit2);
93
93
 
94
94
        /* blue component (inverted) */
95
95
        bit0 = (~b >> 0) & 0x01;
96
96
        bit1 = (~b >> 1) & 0x01;
97
97
        bit2 = (~b >> 2) & 0x01;
98
 
        b = combine_3_weights(state->bweights, bit0, bit1, bit2);
 
98
        b = combine_3_weights(state->m_bweights, bit0, bit1, bit2);
99
99
 
100
 
        palette_set_color(space->machine, offset & 0x3f, MAKE_RGB(r, g, b));
 
100
        palette_set_color(space->machine(), offset & 0x3f, MAKE_RGB(r, g, b));
101
101
}
102
102
 
103
103
 
109
109
 *
110
110
 *************************************/
111
111
 
112
 
INLINE void cloud9_write_vram( running_machine *machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
 
112
INLINE void cloud9_write_vram( running_machine &machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
113
113
{
114
 
        cloud9_state *state = machine->driver_data<cloud9_state>();
115
 
        UINT8 *dest = &state->videoram[0x0000 | (addr & 0x3fff)];
116
 
        UINT8 *dest2 = &state->videoram[0x4000 | (addr & 0x3fff)];
 
114
        cloud9_state *state = machine.driver_data<cloud9_state>();
 
115
        UINT8 *dest = &state->m_videoram[0x0000 | (addr & 0x3fff)];
 
116
        UINT8 *dest2 = &state->m_videoram[0x4000 | (addr & 0x3fff)];
117
117
        UINT8 promaddr = 0;
118
118
        UINT8 wpbits;
119
119
 
130
130
        Bit 0 = PIXA
131
131
    */
132
132
        promaddr |= bitmd << 7;
133
 
        promaddr |= state->video_control[4] << 6;
134
 
        promaddr |= state->video_control[6] << 5;
 
133
        promaddr |= state->m_video_control[4] << 6;
 
134
        promaddr |= state->m_video_control[6] << 5;
135
135
        promaddr |= ((addr & 0xf000) != 0x4000) << 4;
136
136
        promaddr |= ((addr & 0x3800) == 0x0000) << 3;
137
137
        promaddr |= ((addr & 0x0600) == 0x0600) << 2;
138
138
        promaddr |= (pixba << 0);
139
139
 
140
140
        /* look up the PROM result */
141
 
        wpbits = state->wpprom[promaddr];
 
141
        wpbits = state->m_wpprom[promaddr];
142
142
 
143
143
        /* write to the appropriate parts of VRAM depending on the result */
144
144
        if (!(wpbits & 1))
159
159
 *
160
160
 *************************************/
161
161
 
162
 
INLINE void bitmode_autoinc( running_machine *machine )
 
162
INLINE void bitmode_autoinc( running_machine &machine )
163
163
{
164
 
        cloud9_state *state = machine->driver_data<cloud9_state>();
 
164
        cloud9_state *state = machine.driver_data<cloud9_state>();
165
165
 
166
166
        /* auto increment in the x-direction if it's enabled */
167
 
        if (!state->video_control[0])   /* /AX */
168
 
                state->bitmode_addr[0]++;
 
167
        if (!state->m_video_control[0]) /* /AX */
 
168
                state->m_bitmode_addr[0]++;
169
169
 
170
170
        /* auto increment in the y-direction if it's enabled */
171
 
        if (!state->video_control[1])   /* /AY */
172
 
                state->bitmode_addr[1]++;
 
171
        if (!state->m_video_control[1]) /* /AY */
 
172
                state->m_bitmode_addr[1]++;
173
173
}
174
174
 
175
175
 
183
183
WRITE8_HANDLER( cloud9_videoram_w )
184
184
{
185
185
        /* direct writes to VRAM go through the write protect PROM as well */
186
 
        cloud9_write_vram(space->machine, offset, data, 0, 0);
 
186
        cloud9_write_vram(space->machine(), offset, data, 0, 0);
187
187
}
188
188
 
189
189
 
196
196
 
197
197
READ8_HANDLER( cloud9_bitmode_r )
198
198
{
199
 
        cloud9_state *state = space->machine->driver_data<cloud9_state>();
 
199
        cloud9_state *state = space->machine().driver_data<cloud9_state>();
200
200
 
201
201
        /* in bitmode, the address comes from the autoincrement latches */
202
 
        UINT16 addr = (state->bitmode_addr[1] << 6) | (state->bitmode_addr[0] >> 2);
 
202
        UINT16 addr = (state->m_bitmode_addr[1] << 6) | (state->m_bitmode_addr[0] >> 2);
203
203
 
204
204
        /* the appropriate pixel is selected into the upper 4 bits */
205
 
        UINT8 result = state->videoram[((~state->bitmode_addr[0] & 2) << 13) | addr] << ((state->bitmode_addr[0] & 1) * 4);
 
205
        UINT8 result = state->m_videoram[((~state->m_bitmode_addr[0] & 2) << 13) | addr] << ((state->m_bitmode_addr[0] & 1) * 4);
206
206
 
207
207
        /* autoincrement because /BITMD was selected */
208
 
        bitmode_autoinc(space->machine);
 
208
        bitmode_autoinc(space->machine());
209
209
 
210
210
        /* the upper 4 bits of the data lines are not driven so make them all 1's */
211
211
        return (result >> 4) | 0xf0;
214
214
 
215
215
WRITE8_HANDLER( cloud9_bitmode_w )
216
216
{
217
 
        cloud9_state *state = space->machine->driver_data<cloud9_state>();
 
217
        cloud9_state *state = space->machine().driver_data<cloud9_state>();
218
218
 
219
219
        /* in bitmode, the address comes from the autoincrement latches */
220
 
        UINT16 addr = (state->bitmode_addr[1] << 6) | (state->bitmode_addr[0] >> 2);
 
220
        UINT16 addr = (state->m_bitmode_addr[1] << 6) | (state->m_bitmode_addr[0] >> 2);
221
221
 
222
222
        /* the lower 4 bits of data are replicated to the upper 4 bits */
223
223
        data = (data & 0x0f) | (data << 4);
224
224
 
225
225
        /* write through the generic VRAM routine, passing the low 2 X bits as PIXB/PIXA */
226
 
        cloud9_write_vram(space->machine, addr, data, 1, state->bitmode_addr[0] & 3);
 
226
        cloud9_write_vram(space->machine(), addr, data, 1, state->m_bitmode_addr[0] & 3);
227
227
 
228
228
        /* autoincrement because /BITMD was selected */
229
 
        bitmode_autoinc(space->machine);
 
229
        bitmode_autoinc(space->machine());
230
230
}
231
231
 
232
232
 
233
233
WRITE8_HANDLER( cloud9_bitmode_addr_w )
234
234
{
235
 
        cloud9_state *state = space->machine->driver_data<cloud9_state>();
 
235
        cloud9_state *state = space->machine().driver_data<cloud9_state>();
236
236
 
237
237
        /* write through to video RAM and also to the addressing latches */
238
 
        cloud9_write_vram(space->machine, offset, data, 0, 0);
239
 
        state->bitmode_addr[offset] = data;
 
238
        cloud9_write_vram(space->machine(), offset, data, 0, 0);
 
239
        state->m_bitmode_addr[offset] = data;
240
240
}
241
241
 
242
242
 
247
247
 *
248
248
 *************************************/
249
249
 
250
 
VIDEO_UPDATE( cloud9 )
 
250
SCREEN_UPDATE( cloud9 )
251
251
{
252
 
        cloud9_state *state = screen->machine->driver_data<cloud9_state>();
253
 
        UINT8 *spriteaddr = state->spriteram;
254
 
        int flip = state->video_control[5] ? 0xff : 0x00;       /* PLAYER2 */
255
 
        pen_t black = get_black_pen(screen->machine);
 
252
        cloud9_state *state = screen->machine().driver_data<cloud9_state>();
 
253
        UINT8 *spriteaddr = state->m_spriteram;
 
254
        int flip = state->m_video_control[5] ? 0xff : 0x00;     /* PLAYER2 */
 
255
        pen_t black = get_black_pen(screen->machine());
256
256
        int x, y, offs;
257
257
 
258
258
        /* draw the sprites */
259
 
        bitmap_fill(state->spritebitmap, cliprect, 0x00);
 
259
        bitmap_fill(state->m_spritebitmap, cliprect, 0x00);
260
260
        for (offs = 0; offs < 0x20; offs++)
261
261
                if (spriteaddr[offs + 0x00] != 0)
262
262
                {
267
267
                        int which = spriteaddr[offs + 0x20];
268
268
                        int color = 0;
269
269
 
270
 
                        drawgfx_transpen(state->spritebitmap, cliprect, screen->machine->gfx[0], which, color, xflip, yflip, x, y, 0);
 
270
                        drawgfx_transpen(state->m_spritebitmap, cliprect, screen->machine().gfx[0], which, color, xflip, yflip, x, y, 0);
271
271
                        if (x >= 256 - 16)
272
 
                                drawgfx_transpen(state->spritebitmap, cliprect, screen->machine->gfx[0], which, color, xflip, yflip, x - 256, y, 0);
 
272
                                drawgfx_transpen(state->m_spritebitmap, cliprect, screen->machine().gfx[0], which, color, xflip, yflip, x - 256, y, 0);
273
273
                }
274
274
 
275
275
        /* draw the bitmap to the screen, looping over Y */
278
278
                UINT16 *dst = (UINT16 *)bitmap->base + y * bitmap->rowpixels;
279
279
 
280
280
                /* if we're in the VBLANK region, just fill with black */
281
 
                if (~state->syncprom[y] & 2)
 
281
                if (~state->m_syncprom[y] & 2)
282
282
                {
283
283
                        for (x = cliprect->min_x; x <= cliprect->max_x; x++)
284
284
                                dst[x] = black;
287
287
                /* non-VBLANK region: merge the sprites and the bitmap */
288
288
                else
289
289
                {
290
 
                        UINT16 *mosrc = (UINT16 *)state->spritebitmap->base + y * state->spritebitmap->rowpixels;
 
290
                        UINT16 *mosrc = (UINT16 *)state->m_spritebitmap->base + y * state->m_spritebitmap->rowpixels;
291
291
                        int effy = y ^ flip;
292
292
                        UINT8 *src[2];
293
293
 
294
294
                        /* two videoram arrays */
295
 
                        src[0] = &state->videoram[0x4000 | (effy * 64)];
296
 
                        src[1] = &state->videoram[0x0000 | (effy * 64)];
 
295
                        src[0] = &state->m_videoram[0x4000 | (effy * 64)];
 
296
                        src[1] = &state->m_videoram[0x0000 | (effy * 64)];
297
297
 
298
298
                        /* loop over X */
299
299
                        for (x = cliprect->min_x; x <= cliprect->max_x; x++)
316
316
                                                pix = mopix | 0x10;
317
317
 
318
318
                                        /* the high bit is the bank select */
319
 
                                        pix |= state->video_control[7] << 5;
 
319
                                        pix |= state->m_video_control[7] << 5;
320
320
 
321
321
                                        /* store the pixel value and also a priority value based on the topmost bit */
322
322
                                        dst[x] = pix;