~ubuntu-branches/ubuntu/lucid/sdlmame/lucid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Cesare Falco
  • Date: 2009-11-03 17:10:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091103171015-6hop4ory5lxnumpn
Tags: 0.135-0ubuntu1
* New upstream release - Closes (LP: #403212)
* debian/watch: unstable releases are no longer detected
* mame.ini: added the cheat subdirectories to cheatpath so zipped
  cheatfiles will be searched too
* renamed crsshair subdirectory to crosshair to reflect upstream change
* mame.ini: renamed references to crosshair subdirectory (see above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
static int background_color, background_disable;
16
16
static tilemap *background_tilemap, *fix_tilemap;
17
17
static UINT8 deco16_io_ram[16];
 
18
extern UINT8 *prosoccr_charram;
 
19
extern UINT8 *prosport_bg_vram;
18
20
 
19
21
#if 0
20
22
void debug_print(bitmap_t *bitmap)
70
72
{
71
73
        int tile, color;
72
74
 
73
 
        tile = videoram[tile_index + 0x400] + ((videoram[tile_index] & 0x7) << 8);
74
 
        color = (videoram[tile_index] & 0x70) >> 4;
75
 
 
76
 
//if (tile & 0x300) tile -= 0x000;
77
 
//else if(tile & 0x200) tile -= 0x100;
78
 
//else if (tile & 0x100) tile -= 0x100;
79
 
//else tile += 0x200;
 
75
        tile = videoram[tile_index] + ((colorram[tile_index] & 0x7) << 8);
 
76
        color = (colorram[tile_index] & 0x70) >> 4;
80
77
 
81
78
        SET_TILE_INFO(0, tile, color, 0);
82
79
}
83
80
 
 
81
static TILE_GET_INFO( prosport_get_back_tile_info )
 
82
{
 
83
        int tile;
 
84
 
 
85
        /*
 
86
        robiza notes:
 
87
        - flip y (handled with a +0x10 tile banking) depends only by position of the tile in the screen
 
88
        - bits 0-3 are not used by gfx hardware; the value is the color of the pixel in the map (golf)
 
89
    */
 
90
 
 
91
        tile = (prosport_bg_vram[tile_index] & 0xf0)>>4;
 
92
 
 
93
        if (tile_index & 0x8) tile += 0x10;
 
94
 
 
95
        tile += deco16_io_ram[0]&0x20; //Pro Bowling bg tiles banking bit
 
96
 
 
97
        SET_TILE_INFO(8, tile, 0, 0);
 
98
}
 
99
 
84
100
/***************************************************************************/
85
101
 
86
102
WRITE8_HANDLER( deco16_io_w )
113
129
        }
114
130
}
115
131
 
 
132
WRITE8_HANDLER( prosoccr_io_w )
 
133
{
 
134
        deco16_io_ram[offset] = data;
 
135
        if (offset > 1 && offset < 6)
 
136
                tilemap_mark_all_tiles_dirty(background_tilemap);
 
137
 
 
138
//  popmessage("%02x %02x",deco16_io_ram[6],deco16_io_ram[7]);
 
139
 
 
140
        switch (offset)
 
141
        {
 
142
                case 6: /* unused here */
 
143
                        break;
 
144
                case 7:
 
145
                        background_disable = ~data & 0x10;
 
146
                        //sprite_priority = (data & 0x80)>>7;
 
147
                        /* -x-- --xx used during gameplay */
 
148
                        /* x--- ---- used on the attract mode */
 
149
                        break;
 
150
                case 8: /* Irq ack */
 
151
                        cputag_set_input_line(space->machine, "maincpu", DECO16_IRQ_LINE, CLEAR_LINE);
 
152
                        break;
 
153
                case 9: /* Sound */
 
154
                        soundlatch_w(space, 0, data);
 
155
                        cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
 
156
                        break;
 
157
        }
 
158
}
 
159
 
 
160
/* completely different i/o...*/
 
161
WRITE8_HANDLER( prosport_io_w )
 
162
{
 
163
        deco16_io_ram[offset] = data;
 
164
 
 
165
        switch (offset)
 
166
        {
 
167
                case 0:
 
168
                        //background_disable = ~data & 0x80;
 
169
                        flip_screen_set(space->machine, data & 0x80);
 
170
                        tilemap_mark_all_tiles_dirty(background_tilemap);
 
171
                        break;
 
172
                case 2: /* Sound */
 
173
                        soundlatch_w(space, 0, data);
 
174
                        cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
 
175
                        break;
 
176
                case 4: /* Irq ack */
 
177
                        cputag_set_input_line(space->machine, "maincpu", DECO16_IRQ_LINE, CLEAR_LINE);
 
178
                        break;
 
179
        }
 
180
}
 
181
 
116
182
WRITE8_HANDLER( liberate_videoram_w )
117
183
{
118
184
        videoram[offset] = data;
119
 
        tilemap_mark_tile_dirty(fix_tilemap, offset & 0x3ff);
 
185
        tilemap_mark_tile_dirty(fix_tilemap, offset);
 
186
}
 
187
 
 
188
WRITE8_HANDLER( liberate_colorram_w )
 
189
{
 
190
        colorram[offset] = data;
 
191
        tilemap_mark_tile_dirty(fix_tilemap, offset);
 
192
}
 
193
 
 
194
WRITE8_HANDLER( prosport_bg_vram_w )
 
195
{
 
196
        prosport_bg_vram[offset] = data;
 
197
        tilemap_mark_tile_dirty(background_tilemap, offset);
120
198
}
121
199
 
122
200
/***************************************************************************/
127
205
        fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
128
206
 
129
207
        tilemap_set_transparent_pen(fix_tilemap,0);
 
208
 
 
209
        prosoccr_charram = auto_alloc_array(machine, UINT8, 0x1800*2);
130
210
}
131
211
 
132
212
VIDEO_START( boomrang )
146
226
        tilemap_set_transparent_pen(fix_tilemap,0);
147
227
}
148
228
 
 
229
VIDEO_START( prosport )
 
230
{
 
231
        background_tilemap = tilemap_create(machine, prosport_get_back_tile_info,back_scan,16,16,32,32);
 
232
        fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
 
233
 
 
234
        tilemap_set_transparent_pen(fix_tilemap,0);
 
235
}
 
236
 
149
237
/***************************************************************************/
150
238
 
151
239
WRITE8_HANDLER( prosport_paletteram_w )
152
240
{
 
241
        paletteram[offset] = data;
 
242
 
153
243
        /* RGB output is inverted */
154
 
        paletteram_BBGGGRRR_w(space,offset,~data);
 
244
        palette_set_color_rgb(space->machine, offset, pal3bit(~data >> 0), pal3bit(~data >> 3), pal2bit(~data >> 6));
155
245
}
156
246
 
157
247
PALETTE_INIT( liberate )
191
281
        int offs;
192
282
 
193
283
        /* Sprites */
194
 
        for (offs = 0;offs < 0x800;offs += 4)
 
284
        for (offs = 0x000;offs < 0x800;offs += 4)
195
285
        {
196
286
                int multi,fx,fy,sx,sy,sy2,code,color;
197
287
 
238
328
                                sy2=sy+16;
239
329
                }
240
330
 
241
 
                drawgfx(bitmap,machine->gfx[1],
 
331
                drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
242
332
                                code,
243
333
                                        color,
244
334
                                        fx,fy,
245
 
                                        sx,sy,
246
 
                                        cliprect,TRANSPARENCY_PEN,0);
 
335
                                        sx,sy,0);
247
336
                if (multi)
248
 
                        drawgfx(bitmap,machine->gfx[1],
 
337
                        drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
249
338
                                        code+1,
250
339
                                        color,
251
340
                                        fx,fy,
252
 
                                        sx,sy2,
253
 
                                        cliprect,TRANSPARENCY_PEN,0);
 
341
                                        sx,sy2,0);
254
342
        }
255
343
}
256
344
 
257
345
static void prosport_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
258
346
{
259
 
        int offs,multi,fx,fy,sx,sy,sy2,code,code2,color;
 
347
        int offs,multi,fx,fy,sx,sy,sy2,code,code2,color,gfx_region;
260
348
 
261
349
        for (offs = 0x000;offs < 0x800;offs += 4)
262
350
        {
263
 
        //  if ((spriteram[offs+0]&1)!=1) continue;
 
351
                if ((spriteram[offs+0]&1)!=1) continue;
264
352
 
265
353
                code = spriteram[offs+1] + ((spriteram[offs+0]&0x3)<<8);
266
354
                code2=code+1;
267
355
 
 
356
                if(deco16_io_ram[0]&0x40) //dynamic ram-based gfxs for Pro Golf
 
357
                        gfx_region = 3+4;
 
358
                else
 
359
                        gfx_region = ((deco16_io_ram[0]&0x30)>>4)+4;
 
360
 
 
361
 
268
362
                multi = spriteram[offs+0] & 0x10;
269
363
 
270
364
                sy=spriteram[offs+2];
273
367
//      sy = (240-spriteram[offs+2]);//-16;
274
368
                sy = 240-sy;
275
369
 
276
 
                color = 1;//(spriteram[offs+0]&0x4)>>2;
 
370
                color = 1;//(deco16_io_ram[4] & 2)+1;//(spriteram[offs+0]&0x4)>>2;
277
371
 
278
 
                fx = 0;
279
 
                fy = spriteram[offs+0] & 0x04;
 
372
                fy = spriteram[offs+0] & 0x02;
 
373
                fx = spriteram[offs+0] & 0x04;
280
374
                multi = 0;// spriteram[offs+0] & 0x10;
281
375
 
282
376
//      if (multi) sy-=16;
283
 
                if (fy && multi) { code2=code; code++; }
 
377
                if ((fy && multi) || (fx && multi)) { code2=code; code++; }
284
378
 
285
379
                if (flip_screen_get(machine))
286
380
                {
295
389
                        sy2=sy+16;
296
390
                }
297
391
 
298
 
        drawgfx(bitmap,machine->gfx[1],
299
 
                        code,
 
392
        drawgfx_transpen(bitmap,cliprect,machine->gfx[gfx_region],
 
393
                                code,
300
394
                                color,
301
395
                                fx,fy,
302
 
                                sx,sy,
303
 
                                cliprect,TRANSPARENCY_PEN,0);
304
 
        if (multi)
305
 
                drawgfx(bitmap,machine->gfx[1],
 
396
                                sx,sy,0);
 
397
        if (multi)
 
398
                drawgfx_transpen(bitmap,cliprect,machine->gfx[gfx_region],
306
399
                                code2,
307
400
                                color,
308
401
                                fx,fy,
309
 
                                sx,sy2,
310
 
                                cliprect,TRANSPARENCY_PEN,0);
 
402
                                sx,sy2,0);
311
403
        }
312
404
}
313
405
 
353
445
                        sy2=sy+16;
354
446
                }
355
447
 
356
 
        drawgfx(bitmap,machine->gfx[1],
 
448
        drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
357
449
                        code,
358
450
                                color,
359
451
                                fx,fy,
360
 
                                sx,sy,
361
 
                                cliprect,TRANSPARENCY_PEN,0);
 
452
                                sx,sy,0);
362
453
        if (multi)
363
 
                drawgfx(bitmap,machine->gfx[1],
 
454
                drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
364
455
                                code2,
365
456
                                color,
366
457
                                fx,fy,
367
 
                                sx,sy2,
368
 
                                cliprect,TRANSPARENCY_PEN,0);
 
458
                                sx,sy2,0);
 
459
        }
 
460
}
 
461
 
 
462
static void prosoccr_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
 
463
{
 
464
        int offs,code,fx,fy,sx,sy;
 
465
 
 
466
        for (offs = 0x000;offs < 0x400;offs += 4)
 
467
        {
 
468
                if ((spriteram[offs+0]&1)!=1) continue;
 
469
 
 
470
                code = spriteram[offs+1];
 
471
                sy = 240 - spriteram[offs+2];
 
472
                sx = 240 - spriteram[offs+3];
 
473
                fx = spriteram[offs+0] & 4;
 
474
                fy = spriteram[offs+0] & 2;
 
475
 
 
476
        drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
 
477
                                code,
 
478
                                0,
 
479
                                fx,fy,
 
480
                                sx,sy,0);
369
481
        }
370
482
}
371
483
 
380
492
                bitmap_fill(bitmap,cliprect,32);
381
493
        else
382
494
                tilemap_draw(bitmap,cliprect,background_tilemap,0,0);
383
 
        boomrang_draw_sprites(screen->machine,bitmap,cliprect,0);
 
495
 
384
496
        tilemap_draw(bitmap,cliprect,fix_tilemap,0,0);
 
497
        prosoccr_draw_sprites(screen->machine,bitmap,cliprect);
 
498
 
385
499
        return 0;
386
500
}
387
501
 
388
502
VIDEO_UPDATE( prosport )
389
503
{
390
 
        int mx,my,tile,color,offs;
 
504
        int mx,my,tile,offs,gfx_region;
 
505
        int scrollx,scrolly;
391
506
 
392
507
        bitmap_fill(bitmap,cliprect,0);
393
508
 
394
 
        prosport_draw_sprites(screen->machine,bitmap,cliprect);
 
509
        offs = 0;
 
510
        /* TODO: what's bits 0 and 2 for? Internal scrolling state? */
 
511
        scrolly = ((deco16_io_ram[0] & 0x8)<<5);
 
512
        scrollx = ((deco16_io_ram[0] & 0x2)<<7) | (deco16_io_ram[1]);
 
513
 
 
514
        tilemap_set_scrolly(background_tilemap,0,scrolly);
 
515
        tilemap_set_scrollx(background_tilemap,0,-scrollx);
 
516
 
 
517
        tilemap_draw(bitmap,cliprect,background_tilemap,0,0);
 
518
 
 
519
//  popmessage("%d %02x %02x %02x %02x %02x %02x %02x %02x",scrollx,deco16_io_ram[0],deco16_io_ram[1],deco16_io_ram[2],deco16_io_ram[3]
 
520
//  ,deco16_io_ram[4],deco16_io_ram[5],deco16_io_ram[6],deco16_io_ram[7]);
395
521
 
396
522
        for (offs = 0;offs < 0x400;offs++)
397
523
        {
398
 
                tile=videoram[offs+0x400]+((videoram[offs]&0x3)<<8);
399
 
 
400
 
                tile+=((deco16_io_ram[0]&0x30)<<6);
401
 
 
402
 
                if (!tile) continue;
403
 
 
404
 
                color=1;//(videoram[offs]&0x70)>>4;
 
524
                tile=videoram[offs]+((colorram[offs]&0x3)<<8);
 
525
 
 
526
                if(deco16_io_ram[0]&0x40) //dynamic ram-based gfxs for Pro Golf
 
527
                        gfx_region = 3;
 
528
                else
 
529
                        gfx_region = ((deco16_io_ram[0]&0x30)>>4);
 
530
 
405
531
                my = (offs) % 32;
406
532
                mx = (offs) / 32;
407
533
 
408
 
                drawgfx(bitmap,screen->machine->gfx[0],
409
 
                                tile,1,0,0,248-8*mx,8*my,
410
 
                                cliprect,TRANSPARENCY_PEN,0);
 
534
                drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[gfx_region],
 
535
                                tile,1,0,0,248-8*mx,8*my,0);
411
536
        }
 
537
 
 
538
        prosport_draw_sprites(screen->machine,bitmap,cliprect);
 
539
 
412
540
        return 0;
413
541
}
414
542