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

« back to all changes in this revision

Viewing changes to src/mame/video/seta.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:
212
212
    ---- --1-       Coin #1 Counter
213
213
    ---- ---0       Coin #0 Counter     */
214
214
 
215
 
void seta_coin_lockout_w(running_machine *machine, int data)
 
215
void seta_coin_lockout_w(running_machine &machine, int data)
216
216
{
217
 
        seta_state *state = machine->driver_data<seta_state>();
 
217
        seta_state *state = machine.driver_data<seta_state>();
218
218
        static const char *const seta_nolockout[8] = { "blandia", "gundhara", "kamenrid", "zingzip", "eightfrc", "extdwnhl", "sokonuke", "zombraid"};
219
219
 
220
220
        /* Only compute seta_coin_lockout when confronted with a new gamedrv */
221
 
        if (state->driver != machine->gamedrv)
 
221
        if (!state->m_coin_lockout_initialized)
222
222
        {
 
223
                state->m_coin_lockout_initialized = true;
223
224
                int i;
224
 
                state->driver = machine->gamedrv;
225
225
 
226
 
                state->coin_lockout = 1;
 
226
                state->m_coin_lockout = 1;
227
227
                for (i=0; i<ARRAY_LENGTH(seta_nolockout); i++)
228
228
                {
229
 
                        if (strcmp(state->driver->name, seta_nolockout[i]) == 0 ||
230
 
                                strcmp(state->driver->parent, seta_nolockout[i]) == 0)
 
229
                        if (strcmp(machine.system().name, seta_nolockout[i]) == 0 ||
 
230
                                strcmp(machine.system().parent, seta_nolockout[i]) == 0)
231
231
                        {
232
 
                                state->coin_lockout = 0;
 
232
                                state->m_coin_lockout = 0;
233
233
                                break;
234
234
                        }
235
235
                }
239
239
        coin_counter_w          (machine, 1, (( data) >> 1) & 1 );
240
240
 
241
241
        /* blandia, gundhara, kamenrid & zingzip haven't the coin lockout device */
242
 
        if (    !state->coin_lockout )
 
242
        if (    !state->m_coin_lockout )
243
243
                return;
244
244
        coin_lockout_w          (machine, 0, ((~data) >> 2) & 1 );
245
245
        coin_lockout_w          (machine, 1, ((~data) >> 3) & 1 );
248
248
 
249
249
WRITE16_HANDLER( seta_vregs_w )
250
250
{
251
 
        seta_state *state = space->machine->driver_data<seta_state>();
252
 
        COMBINE_DATA(&state->vregs[offset]);
 
251
        seta_state *state = space->machine().driver_data<seta_state>();
 
252
        COMBINE_DATA(&state->m_vregs[offset]);
253
253
        switch (offset)
254
254
        {
255
255
                case 0/2:
264
264
        ---- ---- ---- ---0     Coin #0 Counter     */
265
265
                        if (ACCESSING_BITS_0_7)
266
266
                        {
267
 
                                device_t *x1_010 = space->machine->device("x1snd");
268
 
                                seta_coin_lockout_w (space->machine, data & 0x0f);
 
267
                                device_t *x1_010 = space->machine().device("x1snd");
 
268
                                seta_coin_lockout_w (space->machine(), data & 0x0f);
269
269
                                if (x1_010 != NULL)
270
270
                                        seta_sound_enable_w (x1_010, data & 0x20);
271
 
                                coin_counter_w(space->machine, 0,data & 0x01);
272
 
                                coin_counter_w(space->machine, 1,data & 0x02);
 
271
                                coin_counter_w(space->machine(), 0,data & 0x01);
 
272
                                coin_counter_w(space->machine(), 1,data & 0x02);
273
273
                        }
274
274
                        break;
275
275
 
289
289
 
290
290
                                new_bank = (data >> 3) & 0x7;
291
291
 
292
 
                                if (new_bank != state->samples_bank)
 
292
                                if (new_bank != state->m_samples_bank)
293
293
                                {
294
 
                                        UINT8 *rom = space->machine->region("x1snd")->base();
295
 
                                        int samples_len = space->machine->region("x1snd")->bytes();
 
294
                                        UINT8 *rom = space->machine().region("x1snd")->base();
 
295
                                        int samples_len = space->machine().region("x1snd")->bytes();
296
296
                                        int addr;
297
297
 
298
 
                                        state->samples_bank = new_bank;
 
298
                                        state->m_samples_bank = new_bank;
299
299
 
300
300
                                        if (samples_len == 0x240000)    /* blandia, eightfrc */
301
301
                                        {
305
305
                                                if ( (samples_len > 0x100000) && ((addr+0x40000) <= samples_len) )
306
306
                                                        memcpy(&rom[0xc0000],&rom[addr],0x40000);
307
307
                                                else
308
 
                                                        logerror("PC %06X - Invalid samples bank %02X !\n", cpu_get_pc(space->cpu), new_bank);
 
308
                                                        logerror("PC %06X - Invalid samples bank %02X !\n", cpu_get_pc(&space->device()), new_bank);
309
309
                                        }
310
310
                                        else if (samples_len == 0x480000)       /* zombraid */
311
311
                                        {
360
360
 
361
361
***************************************************************************/
362
362
 
363
 
INLINE void twineagl_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int offset )
 
363
INLINE void twineagl_tile_info( running_machine &machine, tile_data *tileinfo, int tile_index, int offset )
364
364
{
365
 
        seta_state *state = machine->driver_data<seta_state>();
366
 
        UINT16 *vram = state->vram_0 + offset;
 
365
        seta_state *state = machine.driver_data<seta_state>();
 
366
        UINT16 *vram = state->m_vram_0 + offset;
367
367
        UINT16 code =   vram[ tile_index ];
368
368
        UINT16 attr =   vram[ tile_index + 0x800 ];
369
369
        if ((code & 0x3e00) == 0x3e00)
370
 
                code = (code & 0xc07f) | ((state->twineagl_tilebank[(code & 0x0180) >> 7] >> 1) << 7);
 
370
                code = (code & 0xc07f) | ((state->m_twineagl_tilebank[(code & 0x0180) >> 7] >> 1) << 7);
371
371
        SET_TILE_INFO( 1, (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
372
372
}
373
373
 
375
375
static TILE_GET_INFO( twineagl_get_tile_info_1 ) { twineagl_tile_info( machine, tileinfo, tile_index, 0x1000 ); }
376
376
 
377
377
 
378
 
INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, int offset )
 
378
INLINE void get_tile_info( running_machine &machine, tile_data *tileinfo, int tile_index, int layer, int offset )
379
379
{
380
 
        seta_state *state = machine->driver_data<seta_state>();
 
380
        seta_state *state = machine.driver_data<seta_state>();
381
381
        int gfx = 1 + layer;
382
 
        UINT16 *vram = (layer == 0) ? state->vram_0 + offset : state->vram_2 + offset;
383
 
        UINT16 *vctrl = (layer == 0) ? state->vctrl_0 : state->vctrl_2;
 
382
        UINT16 *vram = (layer == 0) ? state->m_vram_0 + offset : state->m_vram_2 + offset;
 
383
        UINT16 *vctrl = (layer == 0) ? state->m_vctrl_0 : state->m_vctrl_2;
384
384
        UINT16 code =   vram[ tile_index ];
385
385
        UINT16 attr =   vram[ tile_index + 0x800 ];
386
386
 
387
 
        if(machine->gfx[gfx + ((vctrl[ 4/2 ] & 0x10) >> state->color_mode_shift)] != NULL)
 
387
        if(machine.gfx[gfx + ((vctrl[ 4/2 ] & 0x10) >> state->m_color_mode_shift)] != NULL)
388
388
        {
389
 
                gfx += (vctrl[ 4/2 ] & 0x10) >> state->color_mode_shift;
 
389
                gfx += (vctrl[ 4/2 ] & 0x10) >> state->m_color_mode_shift;
390
390
        }
391
391
        else
392
392
        {
393
393
                popmessage("Missing Color Mode = 1 for Layer = %d. Contact MAMETesters.",layer);
394
394
        }
395
395
 
396
 
        SET_TILE_INFO( gfx, state->tiles_offset + (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
 
396
        SET_TILE_INFO( gfx, state->m_tiles_offset + (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
397
397
}
398
398
 
399
399
static TILE_GET_INFO( get_tile_info_0 ) { get_tile_info( machine, tileinfo, tile_index, 0, 0x0000 ); }
404
404
 
405
405
WRITE16_HANDLER( seta_vram_0_w )
406
406
{
407
 
        seta_state *state = space->machine->driver_data<seta_state>();
 
407
        seta_state *state = space->machine().driver_data<seta_state>();
408
408
 
409
 
        COMBINE_DATA(&state->vram_0[offset]);
 
409
        COMBINE_DATA(&state->m_vram_0[offset]);
410
410
        if (offset & 0x1000)
411
 
                tilemap_mark_tile_dirty(state->tilemap_1, offset & 0x7ff);
 
411
                tilemap_mark_tile_dirty(state->m_tilemap_1, offset & 0x7ff);
412
412
        else
413
 
                tilemap_mark_tile_dirty(state->tilemap_0, offset & 0x7ff);
 
413
                tilemap_mark_tile_dirty(state->m_tilemap_0, offset & 0x7ff);
414
414
}
415
415
 
416
416
WRITE16_HANDLER( seta_vram_2_w )
417
417
{
418
 
        seta_state *state = space->machine->driver_data<seta_state>();
 
418
        seta_state *state = space->machine().driver_data<seta_state>();
419
419
 
420
 
        COMBINE_DATA(&state->vram_2[offset]);
 
420
        COMBINE_DATA(&state->m_vram_2[offset]);
421
421
        if (offset & 0x1000)
422
 
                tilemap_mark_tile_dirty(state->tilemap_3, offset & 0x7ff);
 
422
                tilemap_mark_tile_dirty(state->m_tilemap_3, offset & 0x7ff);
423
423
        else
424
 
                tilemap_mark_tile_dirty(state->tilemap_2, offset & 0x7ff);
 
424
                tilemap_mark_tile_dirty(state->m_tilemap_2, offset & 0x7ff);
425
425
}
426
426
 
427
427
WRITE16_HANDLER( twineagl_tilebank_w )
428
428
{
429
429
        if (ACCESSING_BITS_0_7)
430
430
        {
431
 
                seta_state *state = space->machine->driver_data<seta_state>();
 
431
                seta_state *state = space->machine().driver_data<seta_state>();
432
432
                data &= 0xff;
433
 
                if (state->twineagl_tilebank[offset] != data)
 
433
                if (state->m_twineagl_tilebank[offset] != data)
434
434
                {
435
 
                        state->twineagl_tilebank[offset] = data;
436
 
                        tilemap_mark_all_tiles_dirty_all(space->machine);
 
435
                        state->m_twineagl_tilebank[offset] = data;
 
436
                        tilemap_mark_all_tiles_dirty_all(space->machine());
437
437
                }
438
438
        }
439
439
}
443
443
/* 2 layers */
444
444
VIDEO_START( seta_2_layers )
445
445
{
446
 
        seta_state *state = machine->driver_data<seta_state>();
 
446
        seta_state *state = machine.driver_data<seta_state>();
447
447
 
448
448
        VIDEO_START_CALL( seta_no_layers );
449
449
 
451
451
       at any given time */
452
452
 
453
453
        /* layer 0 */
454
 
        state->tilemap_0 = tilemap_create(      machine, get_tile_info_0, tilemap_scan_rows,
 
454
        state->m_tilemap_0 = tilemap_create(    machine, get_tile_info_0, tilemap_scan_rows,
455
455
                                                                 16,16, 64,32 );
456
456
 
457
 
        state->tilemap_1 = tilemap_create(      machine, get_tile_info_1, tilemap_scan_rows,
 
457
        state->m_tilemap_1 = tilemap_create(    machine, get_tile_info_1, tilemap_scan_rows,
458
458
                                                                 16,16, 64,32 );
459
459
 
460
460
 
461
461
        /* layer 1 */
462
 
        state->tilemap_2 = tilemap_create(      machine, get_tile_info_2, tilemap_scan_rows,
463
 
                                                                 16,16, 64,32 );
464
 
 
465
 
        state->tilemap_3 = tilemap_create(      machine, get_tile_info_3, tilemap_scan_rows,
466
 
                                                                 16,16, 64,32 );
467
 
 
468
 
        state->tilemaps_flip = 0;
469
 
        state->color_mode_shift = 3;
470
 
 
471
 
        tilemap_set_transparent_pen(state->tilemap_0, 0);
472
 
        tilemap_set_transparent_pen(state->tilemap_1, 0);
473
 
        tilemap_set_transparent_pen(state->tilemap_2, 0);
474
 
        tilemap_set_transparent_pen(state->tilemap_3, 0);
 
462
        state->m_tilemap_2 = tilemap_create(    machine, get_tile_info_2, tilemap_scan_rows,
 
463
                                                                 16,16, 64,32 );
 
464
 
 
465
        state->m_tilemap_3 = tilemap_create(    machine, get_tile_info_3, tilemap_scan_rows,
 
466
                                                                 16,16, 64,32 );
 
467
 
 
468
        state->m_tilemaps_flip = 0;
 
469
        state->m_color_mode_shift = 3;
 
470
 
 
471
        tilemap_set_transparent_pen(state->m_tilemap_0, 0);
 
472
        tilemap_set_transparent_pen(state->m_tilemap_1, 0);
 
473
        tilemap_set_transparent_pen(state->m_tilemap_2, 0);
 
474
        tilemap_set_transparent_pen(state->m_tilemap_3, 0);
475
475
}
476
476
 
477
477
 
478
478
/* 1 layer */
479
479
VIDEO_START( seta_1_layer )
480
480
{
481
 
        seta_state *state = machine->driver_data<seta_state>();
 
481
        seta_state *state = machine.driver_data<seta_state>();
482
482
 
483
483
        VIDEO_START_CALL( seta_no_layers );
484
484
 
486
486
       at any given time */
487
487
 
488
488
        /* layer 0 */
489
 
        state->tilemap_0 = tilemap_create(      machine, get_tile_info_0, tilemap_scan_rows,
490
 
                                                                 16,16, 64,32 );
491
 
 
492
 
        state->tilemap_1 = tilemap_create(      machine, get_tile_info_1, tilemap_scan_rows,
493
 
                                                                 16,16, 64,32 );
494
 
 
495
 
        state->color_mode_shift = 4;
496
 
 
497
 
        tilemap_set_transparent_pen(state->tilemap_0, 0);
498
 
        tilemap_set_transparent_pen(state->tilemap_1, 0);
 
489
        state->m_tilemap_0 = tilemap_create(    machine, get_tile_info_0, tilemap_scan_rows,
 
490
                                                                 16,16, 64,32 );
 
491
 
 
492
        state->m_tilemap_1 = tilemap_create(    machine, get_tile_info_1, tilemap_scan_rows,
 
493
                                                                 16,16, 64,32 );
 
494
 
 
495
        state->m_color_mode_shift = 4;
 
496
 
 
497
        tilemap_set_transparent_pen(state->m_tilemap_0, 0);
 
498
        tilemap_set_transparent_pen(state->m_tilemap_1, 0);
499
499
}
500
500
 
501
501
VIDEO_START( twineagl_1_layer )
502
502
{
503
 
        seta_state *state = machine->driver_data<seta_state>();
 
503
        seta_state *state = machine.driver_data<seta_state>();
504
504
 
505
505
        VIDEO_START_CALL( seta_no_layers );
506
506
 
508
508
       at any given time */
509
509
 
510
510
        /* layer 0 */
511
 
        state->tilemap_0 = tilemap_create(      machine, twineagl_get_tile_info_0, tilemap_scan_rows,
512
 
                                                                 16,16, 64,32 );
513
 
 
514
 
        state->tilemap_1 = tilemap_create(      machine, twineagl_get_tile_info_1, tilemap_scan_rows,
515
 
                                                                 16,16, 64,32 );
516
 
 
517
 
        tilemap_set_transparent_pen(state->tilemap_0, 0);
518
 
        tilemap_set_transparent_pen(state->tilemap_1, 0);
 
511
        state->m_tilemap_0 = tilemap_create(    machine, twineagl_get_tile_info_0, tilemap_scan_rows,
 
512
                                                                 16,16, 64,32 );
 
513
 
 
514
        state->m_tilemap_1 = tilemap_create(    machine, twineagl_get_tile_info_1, tilemap_scan_rows,
 
515
                                                                 16,16, 64,32 );
 
516
 
 
517
        tilemap_set_transparent_pen(state->m_tilemap_0, 0);
 
518
        tilemap_set_transparent_pen(state->m_tilemap_1, 0);
519
519
}
520
520
 
521
521
 
522
522
/* NO layers, only sprites */
523
523
VIDEO_START( seta_no_layers )
524
524
{
525
 
        seta_state *state = machine->driver_data<seta_state>();
526
 
 
527
 
        state->tilemap_0 = 0;
528
 
        state->tilemap_1 = 0;
529
 
        state->tilemap_2 = 0;
530
 
        state->tilemap_3 = 0;
531
 
 
532
 
        state->tilemaps_flip = 0;
533
 
 
534
 
        state->global_offsets = game_offsets;
535
 
        while (state->global_offsets->gamename && strcmp(machine->gamedrv->name, state->global_offsets->gamename))
536
 
                state->global_offsets++;
537
 
        state->samples_bank = -1;       // set the samples bank to an out of range value at start-up
 
525
        seta_state *state = machine.driver_data<seta_state>();
 
526
 
 
527
        state->m_tilemap_0 = 0;
 
528
        state->m_tilemap_1 = 0;
 
529
        state->m_tilemap_2 = 0;
 
530
        state->m_tilemap_3 = 0;
 
531
 
 
532
        state->m_tilemaps_flip = 0;
 
533
 
 
534
        state->m_global_offsets = game_offsets;
 
535
        while (state->m_global_offsets->gamename && strcmp(machine.system().name, state->m_global_offsets->gamename))
 
536
                state->m_global_offsets++;
 
537
        state->m_samples_bank = -1;     // set the samples bank to an out of range value at start-up
538
538
}
539
539
 
540
540
VIDEO_START( oisipuzl_2_layers )
541
541
{
542
 
        seta_state *state = machine->driver_data<seta_state>();
 
542
        seta_state *state = machine.driver_data<seta_state>();
543
543
 
544
544
        VIDEO_START_CALL(seta_2_layers);
545
 
        state->tilemaps_flip = 1;
 
545
        state->m_tilemaps_flip = 1;
546
546
}
547
547
 
548
548
 
565
565
        int color, pen;
566
566
 
567
567
        /* allocate the colortable */
568
 
        machine->colortable = colortable_alloc(machine, 0x600);
 
568
        machine.colortable = colortable_alloc(machine, 0x600*2);
569
569
 
570
570
        for (color = 0; color < 0x20; color++)
 
571
        {
571
572
                for (pen = 0; pen < 0x40; pen++)
572
573
                {
573
574
                        // layer 2-3
574
 
                        colortable_entry_set_value(machine->colortable, 0x0200 + ((color << 6) | pen), 0x200 + ((color << 4) | (pen & 0x0f)));
575
 
                        colortable_entry_set_value(machine->colortable, 0x1200 + ((color << 6) | pen), 0x200 + pen);
 
575
                        colortable_entry_set_value(machine.colortable, 0x0200 + ((color << 6) | pen), 0x200 + ((color << 4) | (pen & 0x0f)));
 
576
                        colortable_entry_set_value(machine.colortable, 0x1200 + ((color << 6) | pen), 0x200 + pen);
576
577
 
577
578
                        // layer 0-1
578
 
                        colortable_entry_set_value(machine->colortable, 0x0a00 + ((color << 6) | pen), 0x400 + ((color << 4) | (pen & 0x0f)));
579
 
                        colortable_entry_set_value(machine->colortable, 0x1a00 + ((color << 6) | pen), 0x400 + pen);
 
579
                        colortable_entry_set_value(machine.colortable, 0x0a00 + ((color << 6) | pen), 0x400 + ((color << 4) | (pen & 0x0f)));
 
580
                        colortable_entry_set_value(machine.colortable, 0x1a00 + ((color << 6) | pen), 0x400 + pen);
580
581
                }
 
582
        }
 
583
 
 
584
        // setup the colortable for the effect palette.
 
585
        // what are used for palette from 0x800 to 0xBFF?
 
586
        for(int i = 0; i < 0x2200; i++)
 
587
        {
 
588
                colortable_entry_set_value(machine.colortable, 0x2200 + i, 0x600 + (i & 0x1ff));
 
589
        }
581
590
}
582
591
 
583
592
 
589
598
        int color, pen;
590
599
 
591
600
        /* allocate the colortable */
592
 
        machine->colortable = colortable_alloc(machine, 0x600);
 
601
        machine.colortable = colortable_alloc(machine, 0x600);
593
602
 
594
603
        for (color = 0; color < 0x20; color++)
595
604
                for (pen = 0; pen < 0x40; pen++)
596
605
                {
597
 
                        colortable_entry_set_value(machine->colortable, 0x0200 + ((color << 6) | pen), 0x400 + pen); // untested
598
 
                        colortable_entry_set_value(machine->colortable, 0x1200 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
606
                        colortable_entry_set_value(machine.colortable, 0x0200 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff)); // used?
 
607
                        colortable_entry_set_value(machine.colortable, 0x1200 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff));
599
608
 
600
 
                        colortable_entry_set_value(machine->colortable, 0x0a00 + ((color << 6) | pen), 0x200 + pen); // untested
601
 
                        colortable_entry_set_value(machine->colortable, 0x1a00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
609
                        colortable_entry_set_value(machine.colortable, 0x0a00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff)); // used?
 
610
                        colortable_entry_set_value(machine.colortable, 0x1a00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff));
602
611
                }
603
612
}
604
613
 
610
619
        int color, pen;
611
620
 
612
621
        /* allocate the colortable */
613
 
        machine->colortable = colortable_alloc(machine, 0x600);
 
622
        machine.colortable = colortable_alloc(machine, 0x600);
614
623
 
615
624
        for (color = 0; color < 0x20; color++)
616
625
                for (pen = 0; pen < 0x40; pen++)
617
626
                {
618
 
                        colortable_entry_set_value(machine->colortable, 0x0200 + ((color << 6) | pen), 0x400 + pen); // untested
619
 
                        colortable_entry_set_value(machine->colortable, 0x1200 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
627
                        colortable_entry_set_value(machine.colortable, 0x0200 + ((color << 6) | pen), 0x400 + (((color << 4) + pen) & 0x1ff)); // used by madshark
 
628
                        colortable_entry_set_value(machine.colortable, 0x1200 + ((color << 6) | pen), 0x400 + (((color << 4) + pen) & 0x1ff));
620
629
 
621
 
                        colortable_entry_set_value(machine->colortable, 0x0a00 + ((color << 6) | pen), 0x200 + pen); // untested
622
 
                        colortable_entry_set_value(machine->colortable, 0x1a00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
630
                        colortable_entry_set_value(machine.colortable, 0x0a00 + ((color << 6) | pen), 0x200 + (((color << 4) + pen) & 0x1ff)); // used by madshark
 
631
                        colortable_entry_set_value(machine.colortable, 0x1a00 + ((color << 6) | pen), 0x200 + (((color << 4) + pen) & 0x1ff));
623
632
                }
624
633
}
625
634
 
630
639
        int color, pen;
631
640
 
632
641
        /* allocate the colortable */
633
 
        machine->colortable = colortable_alloc(machine, 0x600);
 
642
        machine.colortable = colortable_alloc(machine, 0x600);
634
643
 
635
644
        for (color = 0; color < 0x20; color++)
636
645
                for (pen = 0; pen < 0x40; pen++)
637
646
                {
638
 
                        colortable_entry_set_value(machine->colortable, 0x400 + ((color << 6) | pen), 0x400 + pen); // untested
639
 
                        colortable_entry_set_value(machine->colortable, 0xc00 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
647
                        colortable_entry_set_value(machine.colortable, 0x400 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff)); // used?
 
648
                        colortable_entry_set_value(machine.colortable, 0xc00 + ((color << 6) | pen), 0x400 + ((((color & ~3) << 4) + pen) & 0x1ff));
640
649
                }
641
650
}
642
651
 
653
662
 
654
663
PALETTE_INIT( setaroul )
655
664
{
656
 
        machine->gfx[0]->color_granularity=16;
657
 
        machine->gfx[1]->color_granularity=16;
 
665
        machine.gfx[0]->color_granularity=16;
 
666
        machine.gfx[1]->color_granularity=16;
658
667
 
659
668
        PALETTE_INIT_CALL(inttoote);
660
669
}
665
674
        int x;
666
675
 
667
676
        /* allocate the colortable */
668
 
        machine->colortable = colortable_alloc(machine, 0x400);
 
677
        machine.colortable = colortable_alloc(machine, 0x400);
669
678
 
670
679
        /* DECODE PROM */
671
680
        for (x = 0; x < 0x200 ; x++)
675
684
                rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
676
685
 
677
686
                if (x >= 0x100)
678
 
                        colortable_palette_set_color(machine->colortable, x + 0x000, color);
 
687
                        colortable_palette_set_color(machine.colortable, x + 0x000, color);
679
688
                else
680
 
                        colortable_palette_set_color(machine->colortable, x + 0x300, color);
 
689
                        colortable_palette_set_color(machine.colortable, x + 0x300, color);
681
690
        }
682
691
 
683
692
        for (color = 0; color < 0x20; color++)
684
693
                for (pen = 0; pen < 0x40; pen++)
685
694
                {
686
 
                        colortable_entry_set_value(machine->colortable, 0x200 + ((color << 6) | pen), 0x200 + pen); // untested
687
 
                        colortable_entry_set_value(machine->colortable, 0xa00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff));
 
695
                        colortable_entry_set_value(machine.colortable, 0x200 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff)); // used?
 
696
                        colortable_entry_set_value(machine.colortable, 0xa00 + ((color << 6) | pen), 0x200 + ((((color & ~3) << 4) + pen) & 0x1ff));
688
697
                }
689
698
}
690
699
 
691
700
 
692
 
static void set_pens(running_machine *machine)
 
701
static void set_pens(running_machine &machine)
693
702
{
694
 
        seta_state *state = machine->driver_data<seta_state>();
 
703
        seta_state *state = machine.driver_data<seta_state>();
695
704
        offs_t i;
696
705
 
697
 
        for (i = 0; i < state->paletteram_size / 2; i++)
 
706
        for (i = 0; i < state->m_paletteram_size / 2; i++)
698
707
        {
699
 
                UINT16 data = state->paletteram[i];
 
708
                UINT16 data = state->m_paletteram[i];
700
709
 
701
710
                rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
702
711
 
703
 
                if (machine->colortable != NULL)
704
 
                        colortable_palette_set_color(machine->colortable, i, color);
 
712
                if (machine.colortable != NULL)
 
713
                        colortable_palette_set_color(machine.colortable, i, color);
705
714
                else
706
715
                        palette_set_color(machine, i, color);
707
716
        }
 
717
 
 
718
        if(state->m_paletteram2 != NULL)
 
719
        {
 
720
                for (i = 0; i < state->m_paletteram2_size / 2; i++)
 
721
                {
 
722
                        UINT16 data = state->m_paletteram2[i];
 
723
 
 
724
                        rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
 
725
 
 
726
                        if (machine.colortable != NULL)
 
727
                                colortable_palette_set_color(machine.colortable, i + state->m_paletteram_size / 2, color);
 
728
                        else
 
729
                                palette_set_color(machine, i + state->m_paletteram_size / 2, color);
 
730
                }
 
731
        }
708
732
}
709
733
 
710
734
 
711
 
static void usclssic_set_pens(running_machine *machine)
 
735
static void usclssic_set_pens(running_machine &machine)
712
736
{
713
 
        seta_state *state = machine->driver_data<seta_state>();
 
737
        seta_state *state = machine.driver_data<seta_state>();
714
738
        offs_t i;
715
739
 
716
740
        for (i = 0; i < 0x200; i++)
717
741
        {
718
 
                UINT16 data = state->paletteram[i];
 
742
                UINT16 data = state->m_paletteram[i];
719
743
 
720
744
                rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
721
745
 
722
746
                if (i >= 0x100)
723
 
                        colortable_palette_set_color(machine->colortable, i - 0x100, color);
 
747
                        colortable_palette_set_color(machine.colortable, i - 0x100, color);
724
748
                else
725
 
                        colortable_palette_set_color(machine->colortable, i + 0x200, color);
 
749
                        colortable_palette_set_color(machine.colortable, i + 0x200, color);
726
750
        }
727
751
}
728
752
 
737
761
***************************************************************************/
738
762
 
739
763
 
740
 
static void draw_sprites_map(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
 
764
static void draw_sprites_map(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
741
765
{
742
 
        seta_state *state = machine->driver_data<seta_state>();
743
 
        UINT16 *spriteram16 = state->spriteram;
 
766
        seta_state *state = machine.driver_data<seta_state>();
 
767
        UINT16 *spriteram16 = state->m_spriteram;
744
768
        int offs, col;
745
769
        int xoffs, yoffs;
746
770
 
747
 
        int total_color_codes   =       machine->config->m_gfxdecodeinfo[0].total_color_codes;
 
771
        int total_color_codes   =       machine.config().m_gfxdecodeinfo[0].total_color_codes;
748
772
 
749
773
        int ctrl        =       spriteram16[ 0x600/2 ];
750
774
        int ctrl2       =       spriteram16[ 0x602/2 ];
753
777
        int numcol      =       ctrl2 & 0x000f;
754
778
 
755
779
        /* Sprites Banking and/or Sprites Buffering */
756
 
        UINT16 *src = state->spriteram2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 );
 
780
        UINT16 *src = state->m_spriteram2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 );
757
781
 
758
782
        int upper       =       ( spriteram16[ 0x604/2 ] & 0xFF ) +
759
783
                                        ( spriteram16[ 0x606/2 ] & 0xFF ) * 256;
829
853
                        color   =       ( color >> (16-5) ) % total_color_codes;
830
854
                        code    =       (code & 0x3fff) + (bank * 0x4000);
831
855
 
832
 
                        drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
 
856
                        drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
833
857
                                        code,
834
858
                                        color,
835
859
                                        flipx, flipy,
842
866
 
843
867
 
844
868
 
845
 
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
 
869
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
846
870
{
847
 
        seta_state *state = machine->driver_data<seta_state>();
848
 
        UINT16 *spriteram16 = state->spriteram;
 
871
        seta_state *state = machine.driver_data<seta_state>();
 
872
        UINT16 *spriteram16 = state->m_spriteram;
849
873
        int offs;
850
874
        int xoffs, yoffs;
851
875
 
852
 
        int total_color_codes   =       machine->config->m_gfxdecodeinfo[0].total_color_codes;
 
876
        int total_color_codes   =       machine.config().m_gfxdecodeinfo[0].total_color_codes;
853
877
 
854
878
        int ctrl        =       spriteram16[ 0x600/2 ];
855
879
        int ctrl2       =       spriteram16[ 0x602/2 ];
857
881
        int flip        =       ctrl & 0x40;
858
882
 
859
883
        /* Sprites Banking and/or Sprites Buffering */
860
 
        UINT16 *src = state->spriteram2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 );
 
884
        UINT16 *src = state->m_spriteram2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 );
861
885
 
862
886
        int max_y       =       0xf0;
863
887
 
865
889
        draw_sprites_map(machine,bitmap,cliprect);
866
890
 
867
891
 
868
 
        xoffs = state->global_offsets->sprite_offs[flip ? 1 : 0];
 
892
        xoffs = state->m_global_offsets->sprite_offs[flip ? 1 : 0];
869
893
        yoffs = -2;
870
894
 
871
895
        for ( offs = (0x400-2)/2 ; offs >= 0/2; offs -= 2/2 )
883
907
 
884
908
                if (flip)
885
909
                {
886
 
                        y = (0x100 - machine->primary_screen->height()) + max_y - y;
 
910
                        y = (0x100 - machine.primary_screen->height()) + max_y - y;
887
911
                        flipx = !flipx;
888
912
                        flipy = !flipy;
889
913
                }
892
916
 
893
917
                y = max_y - y;
894
918
 
895
 
                drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
 
919
                drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
896
920
                                code,
897
921
                                color,
898
922
                                flipx, flipy,
901
925
 
902
926
}
903
927
 
904
 
 
 
928
static void draw_tilemap_palette_effect(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap_t *tilemap, int scrollx, int scrolly, int gfxnum, int flipscreen)
 
929
{
 
930
        int y;
 
931
        const gfx_element *gfx_tilemap = machine.gfx[gfxnum];
 
932
        const bitmap_t *src_bitmap = tilemap_get_pixmap(tilemap);
 
933
        int width_mask, height_mask;
 
934
        int opaque_mask = gfx_tilemap->color_granularity - 1;
 
935
        int pixel_effect_mask = gfx_tilemap->color_base + (gfx_tilemap->total_colors - 1) * gfx_tilemap->color_granularity;
 
936
        int p;
 
937
 
 
938
        width_mask = src_bitmap->width - 1;
 
939
        height_mask = src_bitmap->height - 1;
 
940
 
 
941
        for (y = cliprect->min_y; y <= cliprect->max_y; y++)
 
942
        {
 
943
                UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
 
944
 
 
945
                int x;
 
946
                for (x = cliprect->min_x; x <= cliprect->max_x; x++)
 
947
                {
 
948
                        if(!flipscreen)
 
949
                        {
 
950
                                p = *BITMAP_ADDR16(src_bitmap, (y + scrolly) & height_mask, (x + scrollx) & width_mask);
 
951
                        }
 
952
                        else
 
953
                        {
 
954
                                p = *BITMAP_ADDR16(src_bitmap, (y - scrolly - 256) & height_mask, (x - scrollx - 512) & width_mask);
 
955
                        }
 
956
 
 
957
                        // draw not transparent pixels
 
958
                        if(p & opaque_mask)
 
959
                        {
 
960
                                // pixels with the last color are not drawn and the 2nd palette is added to the current bitmap color
 
961
                                if((p & pixel_effect_mask) == pixel_effect_mask)
 
962
                                {
 
963
                                        dest[x] = machine.total_colors() / 2 + dest[x];
 
964
                                }
 
965
                                else
 
966
                                {
 
967
                                        dest[x] = machine.pens[p];
 
968
                                }
 
969
                        }
 
970
                }
 
971
        }
 
972
}
905
973
 
906
974
 
907
975
 
914
982
***************************************************************************/
915
983
 
916
984
/* For games without tilemaps */
917
 
VIDEO_UPDATE( seta_no_layers )
 
985
SCREEN_UPDATE( seta_no_layers )
918
986
{
919
 
        set_pens(screen->machine);
 
987
        set_pens(screen->machine());
920
988
        bitmap_fill(bitmap,cliprect,0x1f0);
921
 
        draw_sprites(screen->machine,bitmap,cliprect);
 
989
        draw_sprites(screen->machine(),bitmap,cliprect);
922
990
        return 0;
923
991
}
924
992
 
925
993
 
926
994
/* For games with 1 or 2 tilemaps */
927
 
static VIDEO_UPDATE( seta_layers )
 
995
static SCREEN_UPDATE( seta_layers )
928
996
{
929
 
        seta_state *state = screen->machine->driver_data<seta_state>();
 
997
        seta_state *state = screen->machine().driver_data<seta_state>();
930
998
        int layers_ctrl = -1;
931
 
        int enab_0, enab_1, x_0, x_1, y_0, y_1;
 
999
        int enab_0, enab_1, x_0, x_1=0, y_0, y_1=0;
932
1000
 
933
1001
        int order       =       0;
934
 
        int flip        =       (state->spriteram[ 0x600/2 ] & 0x40) >> 6;
 
1002
        int flip        =       (state->m_spriteram[ 0x600/2 ] & 0x40) >> 6;
935
1003
 
936
1004
        const rectangle &visarea = screen->visible_area();
937
1005
        int vis_dimy = visarea.max_y - visarea.min_y + 1;
938
1006
 
939
 
 
940
1007
        // check tilemaps color modes
941
1008
 
942
 
        if(state->current_tilemap_mode[0] != (state->vctrl_0[ 4/2 ] & 0x10))
 
1009
        if(state->m_current_tilemap_mode[0] != (state->m_vctrl_0[ 4/2 ] & 0x10))
943
1010
        {
944
 
                state->current_tilemap_mode[0] = state->vctrl_0[ 4/2 ] & 0x10;
945
 
                tilemap_mark_all_tiles_dirty(state->tilemap_0);
946
 
                tilemap_mark_all_tiles_dirty(state->tilemap_1);
 
1011
                state->m_current_tilemap_mode[0] = state->m_vctrl_0[ 4/2 ] & 0x10;
 
1012
                tilemap_mark_all_tiles_dirty(state->m_tilemap_0);
 
1013
                tilemap_mark_all_tiles_dirty(state->m_tilemap_1);
947
1014
        }
948
1015
 
949
 
        if(state->tilemap_2 != NULL && state->tilemap_3 != NULL)
 
1016
        if(state->m_tilemap_2 != NULL && state->m_tilemap_3 != NULL)
950
1017
        {
951
 
                if(state->current_tilemap_mode[1] != (state->vctrl_2[ 4/2 ] & 0x10))
 
1018
                if(state->m_current_tilemap_mode[1] != (state->m_vctrl_2[ 4/2 ] & 0x10))
952
1019
                {
953
 
                        state->current_tilemap_mode[1] = state->vctrl_2[ 4/2 ] & 0x10;
954
 
                        tilemap_mark_all_tiles_dirty(state->tilemap_2);
955
 
                        tilemap_mark_all_tiles_dirty(state->tilemap_3);
 
1020
                        state->m_current_tilemap_mode[1] = state->m_vctrl_2[ 4/2 ] & 0x10;
 
1021
                        tilemap_mark_all_tiles_dirty(state->m_tilemap_2);
 
1022
                        tilemap_mark_all_tiles_dirty(state->m_tilemap_3);
956
1023
                }
957
1024
        }
958
1025
 
959
 
        flip ^= state->tilemaps_flip;
960
 
 
961
 
        tilemap_set_flip_all(screen->machine, flip ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0 );
962
 
 
963
 
        x_0             =       state->vctrl_0[ 0/2 ];
964
 
        y_0             =       state->vctrl_0[ 2/2 ];
965
 
        enab_0  =       state->vctrl_0[ 4/2 ];
 
1026
        flip ^= state->m_tilemaps_flip;
 
1027
 
 
1028
        tilemap_set_flip_all(screen->machine(), flip ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0 );
 
1029
 
 
1030
        x_0             =       state->m_vctrl_0[ 0/2 ];
 
1031
        y_0             =       state->m_vctrl_0[ 2/2 ];
 
1032
        enab_0  =       state->m_vctrl_0[ 4/2 ];
966
1033
 
967
1034
        /* Only one tilemap per layer is enabled! */
968
 
        tilemap_set_enable(state->tilemap_0, (!(enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
969
 
        tilemap_set_enable(state->tilemap_1, ( (enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
 
1035
        tilemap_set_enable(state->m_tilemap_0, (!(enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
 
1036
        tilemap_set_enable(state->m_tilemap_1, ( (enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
970
1037
 
971
1038
        /* the hardware wants different scroll values when flipped */
972
1039
 
976
1043
                    fff0 0260 = -$10, $400-$190 -$10
977
1044
                    ffe8 0272 = -$18, $400-$190 -$18 + $1a      */
978
1045
 
979
 
        x_0 += 0x10 - state->global_offsets->tilemap_offs[flip ? 1 : 0];
 
1046
        x_0 += 0x10 - state->m_global_offsets->tilemap_offs[flip ? 1 : 0];
980
1047
        y_0 -= (256 - vis_dimy)/2;
981
1048
        if (flip)
982
1049
        {
984
1051
                y_0 = y_0 - vis_dimy;
985
1052
        }
986
1053
 
987
 
        tilemap_set_scrollx(state->tilemap_0, 0, x_0);
988
 
        tilemap_set_scrollx(state->tilemap_1, 0, x_0);
989
 
        tilemap_set_scrolly(state->tilemap_0, 0, y_0);
990
 
        tilemap_set_scrolly(state->tilemap_1, 0, y_0);
 
1054
        tilemap_set_scrollx(state->m_tilemap_0, 0, x_0);
 
1055
        tilemap_set_scrollx(state->m_tilemap_1, 0, x_0);
 
1056
        tilemap_set_scrolly(state->m_tilemap_0, 0, y_0);
 
1057
        tilemap_set_scrolly(state->m_tilemap_1, 0, y_0);
991
1058
 
992
 
        if (state->tilemap_2)
 
1059
        if (state->m_tilemap_2)
993
1060
        {
994
 
                x_1             =       state->vctrl_2[ 0/2 ];
995
 
                y_1             =       state->vctrl_2[ 2/2 ];
996
 
                enab_1  =       state->vctrl_2[ 4/2 ];
997
 
 
998
 
                tilemap_set_enable(state->tilemap_2, (!(enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
999
 
                tilemap_set_enable(state->tilemap_3, ( (enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
1000
 
 
1001
 
                x_1 += 0x10 - state->global_offsets->tilemap_offs[flip ? 1 : 0];
 
1061
                x_1             =       state->m_vctrl_2[ 0/2 ];
 
1062
                y_1             =       state->m_vctrl_2[ 2/2 ];
 
1063
                enab_1  =       state->m_vctrl_2[ 4/2 ];
 
1064
 
 
1065
                tilemap_set_enable(state->m_tilemap_2, (!(enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
 
1066
                tilemap_set_enable(state->m_tilemap_3, ( (enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
 
1067
 
 
1068
                x_1 += 0x10 - state->m_global_offsets->tilemap_offs[flip ? 1 : 0];
1002
1069
                y_1 -= (256 - vis_dimy)/2;
1003
1070
                if (flip)
1004
1071
                {
1006
1073
                        y_1 = y_1 - vis_dimy;
1007
1074
                }
1008
1075
 
1009
 
                tilemap_set_scrollx(state->tilemap_2, 0, x_1);
1010
 
                tilemap_set_scrollx(state->tilemap_3, 0, x_1);
1011
 
                tilemap_set_scrolly(state->tilemap_2, 0, y_1);
1012
 
                tilemap_set_scrolly(state->tilemap_3, 0, y_1);
 
1076
                tilemap_set_scrollx(state->m_tilemap_2, 0, x_1);
 
1077
                tilemap_set_scrollx(state->m_tilemap_3, 0, x_1);
 
1078
                tilemap_set_scrolly(state->m_tilemap_2, 0, y_1);
 
1079
                tilemap_set_scrolly(state->m_tilemap_3, 0, y_1);
1013
1080
 
1014
 
                order   =       state->vregs[ 2/2 ];
 
1081
                order   =       state->m_vregs[ 2/2 ];
1015
1082
        }
1016
1083
 
1017
1084
 
1018
1085
#ifdef MAME_DEBUG
1019
 
if (input_code_pressed(screen->machine, KEYCODE_Z))
 
1086
if (input_code_pressed(screen->machine(), KEYCODE_Z))
1020
1087
{       int msk = 0;
1021
 
        if (input_code_pressed(screen->machine, KEYCODE_Q))     msk |= 1;
1022
 
        if (input_code_pressed(screen->machine, KEYCODE_W))     msk |= 2;
1023
 
        if (input_code_pressed(screen->machine, KEYCODE_A))     msk |= 8;
 
1088
        if (input_code_pressed(screen->machine(), KEYCODE_Q))   msk |= 1;
 
1089
        if (input_code_pressed(screen->machine(), KEYCODE_W))   msk |= 2;
 
1090
        if (input_code_pressed(screen->machine(), KEYCODE_A))   msk |= 8;
1024
1091
        if (msk != 0) layers_ctrl &= msk;
1025
1092
 
1026
 
        if (state->tilemap_2)
 
1093
        if (state->m_tilemap_2)
1027
1094
                popmessage("VR:%04X-%04X-%04X L0:%04X L1:%04X",
1028
 
                        state->vregs[0], state->vregs[1], state->vregs[2], state->vctrl_0[4/2], state->vctrl_2[4/2]);
1029
 
        else if (state->tilemap_0)      popmessage("L0:%04X", state->vctrl_0[4/2]);
 
1095
                        state->m_vregs[0], state->m_vregs[1], state->m_vregs[2], state->m_vctrl_0[4/2], state->m_vctrl_2[4/2]);
 
1096
        else if (state->m_tilemap_0)    popmessage("L0:%04X", state->m_vctrl_0[4/2]);
1030
1097
}
1031
1098
#endif
1032
1099
 
1034
1101
 
1035
1102
        if (order & 1)  // swap the layers?
1036
1103
        {
1037
 
                if (state->tilemap_2)
 
1104
                if (state->m_tilemap_2)
1038
1105
                {
1039
 
                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_2, TILEMAP_DRAW_OPAQUE, 0);
1040
 
                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_3, TILEMAP_DRAW_OPAQUE, 0);
 
1106
                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_2, TILEMAP_DRAW_OPAQUE, 0);
 
1107
                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_3, TILEMAP_DRAW_OPAQUE, 0);
1041
1108
                }
1042
1109
 
1043
1110
                if (order & 2)  // layer-sprite priority?
1044
1111
                {
1045
 
                        if (layers_ctrl & 8)    draw_sprites(screen->machine,bitmap,cliprect);
1046
 
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_0, 0, 0);
1047
 
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_1, 0, 0);
 
1112
                        if (layers_ctrl & 8)    draw_sprites(screen->machine(),bitmap,cliprect);
 
1113
 
 
1114
                        if(order & 4)
 
1115
                        {
 
1116
                                popmessage("Missing palette effect. Contact MAMETesters.");
 
1117
                        }
 
1118
 
 
1119
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_0, 0, 0);
 
1120
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_1, 0, 0);
1048
1121
                }
1049
1122
                else
1050
1123
                {
1051
 
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_0,  0, 0);
1052
 
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_1,  0, 0);
1053
 
                        if (layers_ctrl & 8)    draw_sprites(screen->machine, bitmap,cliprect);
 
1124
                        if(order & 4)
 
1125
                        {
 
1126
                                popmessage("Missing palette effect. Contact MAMETesters.");
 
1127
                        }
 
1128
 
 
1129
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_0,  0, 0);
 
1130
                        if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_1,  0, 0);
 
1131
 
 
1132
                        if (layers_ctrl & 8)    draw_sprites(screen->machine(), bitmap,cliprect);
1054
1133
                }
1055
1134
        }
1056
1135
        else
1057
1136
        {
1058
 
                if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_0,  TILEMAP_DRAW_OPAQUE, 0);
1059
 
                if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->tilemap_1,  TILEMAP_DRAW_OPAQUE, 0);
 
1137
                if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_0,  TILEMAP_DRAW_OPAQUE, 0);
 
1138
                if (layers_ctrl & 1)    tilemap_draw(bitmap, cliprect, state->m_tilemap_1,  TILEMAP_DRAW_OPAQUE, 0);
1060
1139
 
1061
1140
                if (order & 2)  // layer-sprite priority?
1062
1141
                {
1063
 
                        if (layers_ctrl & 8)    draw_sprites(screen->machine, bitmap,cliprect);
1064
 
 
1065
 
                        if (state->tilemap_2)
1066
 
                        {
1067
 
                                if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_2, 0, 0);
1068
 
                                if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_3, 0, 0);
 
1142
                        if (layers_ctrl & 8)    draw_sprites(screen->machine(), bitmap,cliprect);
 
1143
 
 
1144
                        if((order & 4) && state->m_paletteram2 != NULL)
 
1145
                        {
 
1146
                                if(tilemap_get_enable(state->m_tilemap_2))
 
1147
                                {
 
1148
                                        draw_tilemap_palette_effect(screen->machine(), bitmap, cliprect, state->m_tilemap_2, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
 
1149
                                }
 
1150
                                else
 
1151
                                {
 
1152
                                        draw_tilemap_palette_effect(screen->machine(), bitmap, cliprect, state->m_tilemap_3, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
 
1153
                                }
 
1154
                        }
 
1155
                        else
 
1156
                        {
 
1157
                                if(order & 4)
 
1158
                                {
 
1159
                                        popmessage("Missing palette effect. Contact MAMETesters.");
 
1160
                                }
 
1161
 
 
1162
                                if (state->m_tilemap_2)
 
1163
                                {
 
1164
                                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_2, 0, 0);
 
1165
                                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_3, 0, 0);
 
1166
                                }
1069
1167
                        }
1070
1168
                }
1071
1169
                else
1072
1170
                {
1073
 
                        if (state->tilemap_2)
1074
 
                        {
1075
 
                                if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_2, 0, 0);
1076
 
                                if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->tilemap_3, 0, 0);
1077
 
                        }
1078
 
 
1079
 
                        if (layers_ctrl & 8)    draw_sprites(screen->machine, bitmap,cliprect);
 
1171
                        if((order & 4) && state->m_paletteram2 != NULL)
 
1172
                        {
 
1173
                                if(tilemap_get_enable(state->m_tilemap_2))
 
1174
                                {
 
1175
                                        draw_tilemap_palette_effect(screen->machine(), bitmap, cliprect, state->m_tilemap_2, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
 
1176
                                }
 
1177
                                else
 
1178
                                {
 
1179
                                        draw_tilemap_palette_effect(screen->machine(), bitmap, cliprect, state->m_tilemap_3, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
 
1180
                                }
 
1181
                        }
 
1182
                        else
 
1183
                        {
 
1184
                                if(order & 4)
 
1185
                                {
 
1186
                                        popmessage("Missing palette effect. Contact MAMETesters.");
 
1187
                                }
 
1188
 
 
1189
                                if (state->m_tilemap_2)
 
1190
                                {
 
1191
                                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_2, 0, 0);
 
1192
                                        if (layers_ctrl & 2)    tilemap_draw(bitmap, cliprect, state->m_tilemap_3, 0, 0);
 
1193
                                }
 
1194
                        }
 
1195
 
 
1196
                        if (layers_ctrl & 8)    draw_sprites(screen->machine(), bitmap,cliprect);
1080
1197
                }
1081
1198
        }
1082
1199
        return 0;
1083
1200
}
1084
1201
 
1085
1202
 
1086
 
VIDEO_UPDATE( seta )
1087
 
{
1088
 
        set_pens(screen->machine);
1089
 
        return VIDEO_UPDATE_CALL(seta_layers);
1090
 
}
1091
 
 
1092
 
 
1093
 
VIDEO_UPDATE( usclssic )
1094
 
{
1095
 
        usclssic_set_pens(screen->machine);
1096
 
        return VIDEO_UPDATE_CALL(seta_layers);
1097
 
}
1098
 
 
1099
 
 
1100
 
VIDEO_UPDATE( inttoote )
 
1203
SCREEN_UPDATE( seta )
 
1204
{
 
1205
        set_pens(screen->machine());
 
1206
        return SCREEN_UPDATE_CALL(seta_layers);
 
1207
}
 
1208
 
 
1209
 
 
1210
SCREEN_UPDATE( usclssic )
 
1211
{
 
1212
        usclssic_set_pens(screen->machine());
 
1213
        return SCREEN_UPDATE_CALL(seta_layers);
 
1214
}
 
1215
 
 
1216
 
 
1217
SCREEN_UPDATE( inttoote )
1101
1218
{
1102
1219
        /* no palette to set */
1103
 
        return VIDEO_UPDATE_CALL(seta_layers);
 
1220
        return SCREEN_UPDATE_CALL(seta_layers);
1104
1221
}