~ubuntu-branches/debian/wheezy/mame/wheezy

« back to all changes in this revision

Viewing changes to src/mame/drivers/segas32.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:
369
369
 
370
370
/*************************************
371
371
 *
372
 
 *  Global variables
373
 
 *
374
 
 *************************************/
375
 
 
376
 
UINT8 *ga2_dpram;
377
 
UINT16 *system32_workram;
378
 
UINT16 *system32_protram;
379
 
 
380
 
 
381
 
 
382
 
/*************************************
383
 
 *
384
 
 *  Statics
385
 
 *
386
 
 *************************************/
387
 
 
388
 
static UINT8 *z80_shared_ram;
389
 
 
390
 
/* V60 interrupt controller */
391
 
static UINT8 v60_irq_control[0x10];
392
 
static timer_device *v60_irq_timer[2];
393
 
 
394
 
/* sound interrupt controller */
395
 
static UINT8 sound_irq_control[4];
396
 
static UINT8 sound_irq_input;
397
 
static UINT8 sound_dummy_value;
398
 
static UINT16 sound_bank;
399
 
 
400
 
 
401
 
/* I/O chips and custom I/O */
402
 
static UINT8 misc_io_data[2][0x10];
403
 
static read16_space_func custom_io_r[2];
404
 
static write16_space_func custom_io_w[2];
405
 
static UINT8 analog_bank;
406
 
static UINT8 analog_value[4];
407
 
static UINT8 sonic_last[6];
408
 
 
409
 
/* callbacks to handle output */
410
 
typedef void (*sys32_output_callback)(int which, UINT16 data);
411
 
static sys32_output_callback segas32_sw1_output, segas32_sw2_output, segas32_sw3_output;
412
 
 
413
 
static void (*system32_prot_vblank)(device_t *device);
414
 
 
415
 
 
416
 
/*************************************
417
 
 *
418
372
 *  Prototypes
419
373
 *
420
374
 *************************************/
421
375
 
422
 
static void signal_v60_irq(running_machine *machine, int data);
423
 
static void signal_sound_irq(running_machine *machine, int which);
 
376
static void signal_v60_irq(running_machine &machine, int data);
 
377
static void signal_sound_irq(running_machine &machine, int which);
424
378
 
425
379
 
426
380
 
432
386
 
433
387
static MACHINE_RESET( system32 )
434
388
{
 
389
        segas32_state *state = machine.driver_data<segas32_state>();
435
390
        /* initialize the interrupt controller */
436
 
        memset(v60_irq_control, 0xff, sizeof(v60_irq_control));
 
391
        memset(state->m_v60_irq_control, 0xff, sizeof(state->m_v60_irq_control));
437
392
 
438
393
        /* allocate timers */
439
 
        v60_irq_timer[0] = machine->device<timer_device>("v60_irq0");
440
 
        v60_irq_timer[1] = machine->device<timer_device>("v60_irq1");
 
394
        state->m_v60_irq_timer[0] = machine.device<timer_device>("v60_irq0");
 
395
        state->m_v60_irq_timer[1] = machine.device<timer_device>("v60_irq1");
441
396
 
442
397
        /* clear IRQ lines */
443
398
        cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
451
406
 *
452
407
 *************************************/
453
408
 
454
 
static void update_irq_state(running_machine *machine)
 
409
static void update_irq_state(running_machine &machine)
455
410
{
456
 
        UINT8 effirq = v60_irq_control[7] & ~v60_irq_control[6] & 0x1f;
 
411
        segas32_state *state = machine.driver_data<segas32_state>();
 
412
        UINT8 effirq = state->m_v60_irq_control[7] & ~state->m_v60_irq_control[6] & 0x1f;
457
413
        int vector;
458
414
 
459
415
        /* loop over interrupt vectors, finding the highest priority one with */
471
427
}
472
428
 
473
429
 
474
 
static void signal_v60_irq(running_machine *machine, int which)
 
430
static void signal_v60_irq(running_machine &machine, int which)
475
431
{
 
432
        segas32_state *state = machine.driver_data<segas32_state>();
476
433
        int i;
477
434
 
478
435
        /* see if this interrupt input is mapped to any vectors; if so, mark them */
479
436
        for (i = 0; i < 5; i++)
480
 
                if (v60_irq_control[i] == which)
481
 
                        v60_irq_control[7] |= 1 << i;
 
437
                if (state->m_v60_irq_control[i] == which)
 
438
                        state->m_v60_irq_control[7] |= 1 << i;
482
439
        update_irq_state(machine);
483
440
}
484
441
 
485
442
 
486
443
static TIMER_DEVICE_CALLBACK( signal_v60_irq_callback )
487
444
{
488
 
        signal_v60_irq(timer.machine, param);
 
445
        signal_v60_irq(timer.machine(), param);
489
446
}
490
447
 
491
448
 
492
449
static void int_control_w(address_space *space, int offset, UINT8 data)
493
450
{
 
451
        segas32_state *state = space->machine().driver_data<segas32_state>();
494
452
        int duration;
495
453
 
496
 
//  logerror("%06X:int_control_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data);
 
454
//  logerror("%06X:int_control_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data);
497
455
        switch (offset)
498
456
        {
499
457
                case 0:
501
459
                case 2:
502
460
                case 3:
503
461
                case 4:                 /* vectors */
504
 
                        v60_irq_control[offset] = data;
 
462
                        state->m_v60_irq_control[offset] = data;
505
463
                        break;
506
464
 
507
465
                case 5:                 /* unknown */
508
 
                        v60_irq_control[offset] = data;
 
466
                        state->m_v60_irq_control[offset] = data;
509
467
                        break;
510
468
 
511
469
                case 6:                 /* mask */
512
 
                        v60_irq_control[offset] = data;
513
 
                        update_irq_state(space->machine);
 
470
                        state->m_v60_irq_control[offset] = data;
 
471
                        update_irq_state(space->machine());
514
472
                        break;
515
473
 
516
474
                case 7:                 /* acknowledge */
517
 
                        v60_irq_control[offset] &= data;
518
 
                        update_irq_state(space->machine);
 
475
                        state->m_v60_irq_control[offset] &= data;
 
476
                        update_irq_state(space->machine());
519
477
                        break;
520
478
 
521
479
                case 8:
522
480
                case 9:                 /* timer 0 count */
523
 
                        v60_irq_control[offset] = data;
524
 
                        duration = v60_irq_control[8] + ((v60_irq_control[9] << 8) & 0xf00);
 
481
                        state->m_v60_irq_control[offset] = data;
 
482
                        duration = state->m_v60_irq_control[8] + ((state->m_v60_irq_control[9] << 8) & 0xf00);
525
483
                        if (duration)
526
484
                        {
527
 
                                attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration);
528
 
                                v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
 
485
                                attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration;
 
486
                                state->m_v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
529
487
                        }
530
488
                        break;
531
489
 
532
490
                case 10:
533
491
                case 11:                /* timer 1 count */
534
 
                        v60_irq_control[offset] = data;
535
 
                        duration = v60_irq_control[10] + ((v60_irq_control[11] << 8) & 0xf00);
 
492
                        state->m_v60_irq_control[offset] = data;
 
493
                        duration = state->m_v60_irq_control[10] + ((state->m_v60_irq_control[11] << 8) & 0xf00);
536
494
                        if (duration)
537
495
                        {
538
 
                                attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration);
539
 
                                v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
 
496
                                attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration;
 
497
                                state->m_v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
540
498
                        }
541
499
                        break;
542
500
 
544
502
                case 13:
545
503
                case 14:
546
504
                case 15:                /* signal IRQ to sound CPU */
547
 
                        signal_sound_irq(space->machine, SOUND_IRQ_V60);
 
505
                        signal_sound_irq(space->machine(), SOUND_IRQ_V60);
548
506
                        break;
549
507
        }
550
508
}
613
571
 
614
572
static INTERRUPT_GEN( start_of_vblank_int )
615
573
{
616
 
        signal_v60_irq(device->machine, MAIN_IRQ_VBSTART);
617
 
        system32_set_vblank(device->machine, 1);
618
 
        timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, end_of_vblank_int);
619
 
        if (system32_prot_vblank)
620
 
                (*system32_prot_vblank)(device);
 
574
        segas32_state *state = device->machine().driver_data<segas32_state>();
 
575
        signal_v60_irq(device->machine(), MAIN_IRQ_VBSTART);
 
576
        system32_set_vblank(device->machine(), 1);
 
577
        device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(0), FUNC(end_of_vblank_int));
 
578
        if (state->m_system32_prot_vblank)
 
579
                (*state->m_system32_prot_vblank)(device);
621
580
}
622
581
 
623
582
 
630
589
 
631
590
static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, UINT16 mem_mask)
632
591
{
 
592
        segas32_state *state = space->machine().driver_data<segas32_state>();
633
593
        static const char *const portnames[2][8] =
634
594
                        {
635
595
                                { "P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A" },
649
609
                case 0x0c/2:
650
610
                case 0x0e/2:
651
611
                        /* if the port is configured as an output, return the last thing written */
652
 
                        if (misc_io_data[which][0x1e/2] & (1 << offset))
653
 
                                return misc_io_data[which][offset];
 
612
                        if (state->m_misc_io_data[which][0x1e/2] & (1 << offset))
 
613
                                return state->m_misc_io_data[which][offset];
654
614
 
655
615
                        /* otherwise, return an input port */
656
 
                        return input_port_read_safe(space->machine, portnames[which][offset], 0xffff);
 
616
                        return input_port_read_safe(space->machine(), portnames[which][offset], 0xffff);
657
617
 
658
618
                /* 'SEGA' protection */
659
619
                case 0x10/2:
668
628
                /* CNT register & mirror */
669
629
                case 0x18/2:
670
630
                case 0x1c/2:
671
 
                        return misc_io_data[which][0x1c/2];
 
631
                        return state->m_misc_io_data[which][0x1c/2];
672
632
 
673
633
                /* port direction register & mirror */
674
634
                case 0x1a/2:
675
635
                case 0x1e/2:
676
 
                        return misc_io_data[which][0x1e/2];
 
636
                        return state->m_misc_io_data[which][0x1e/2];
677
637
        }
678
638
        return 0xffff;
679
639
}
681
641
 
682
642
static void common_io_chip_w(address_space *space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
683
643
{
 
644
        segas32_state *state = space->machine().driver_data<segas32_state>();
684
645
        UINT8 old;
685
646
 
686
647
        /* only LSB matters */
689
650
 
690
651
        /* generic implementation */
691
652
        offset &= 0x1f/2;
692
 
        old = misc_io_data[which][offset];
693
 
        misc_io_data[which][offset] = data;
 
653
        old = state->m_misc_io_data[which][offset];
 
654
        state->m_misc_io_data[which][offset] = data;
694
655
 
695
656
        switch (offset)
696
657
        {
701
662
                case 0x08/2:
702
663
                case 0x0a/2:
703
664
                case 0x0c/2:
704
 
                        if (segas32_sw2_output)
705
 
                                segas32_sw2_output(which, data);
 
665
                        if (state->m_sw2_output)
 
666
                                state->m_sw2_output(which, data);
706
667
                        break;
707
668
 
708
669
                /* miscellaneous output */
709
670
                case 0x06/2:
710
 
                        if (segas32_sw1_output)
711
 
                                segas32_sw1_output(which, data);
 
671
                        if (state->m_sw1_output)
 
672
                                state->m_sw1_output(which, data);
712
673
 
713
674
                        if (which == 0)
714
675
                        {
715
 
                                eeprom_device *device = space->machine->device<eeprom_device>("eeprom");
 
676
                                eeprom_device *device = space->machine().device<eeprom_device>("eeprom");
716
677
                                eeprom_write_bit(device, data & 0x80);
717
678
                                eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
718
679
                                eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
719
680
                        }
720
 
/*            coin_lockout_w(space->machine, 1 + 2*which, data & 0x08);
721
 
            coin_lockout_w(space->machine, 0 + 2*which, data & 0x04);*/
722
 
                        coin_counter_w(space->machine, 1 + 2*which, data & 0x02);
723
 
                        coin_counter_w(space->machine, 0 + 2*which, data & 0x01);
 
681
/*            coin_lockout_w(space->machine(), 1 + 2*which, data & 0x08);
 
682
            coin_lockout_w(space->machine(), 0 + 2*which, data & 0x04);*/
 
683
                        coin_counter_w(space->machine(), 1 + 2*which, data & 0x02);
 
684
                        coin_counter_w(space->machine(), 0 + 2*which, data & 0x01);
724
685
                        break;
725
686
 
726
687
                /* tile banking */
727
688
                case 0x0e/2:
728
689
                        if (which == 0)
729
 
                                system32_tilebank_external = data;
 
690
                                state->m_system32_tilebank_external = data;
730
691
                        else
731
692
                        {
732
693
                                /* multi-32 EEPROM access */
733
 
                                eeprom_device *device = space->machine->device<eeprom_device>("eeprom");
 
694
                                eeprom_device *device = space->machine().device<eeprom_device>("eeprom");
734
695
                                eeprom_write_bit(device, data & 0x80);
735
696
                                eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
736
697
                                eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
739
700
 
740
701
                /* CNT register */
741
702
                case 0x1c/2:
742
 
                        system32_displayenable[which] = (data & 0x02);
 
703
                        state->m_system32_displayenable[which] = (data & 0x02);
743
704
                        if (which == 0)
744
 
                                cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
 
705
                                cputag_set_input_line(space->machine(), "soundcpu", INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
745
706
                        break;
746
707
        }
747
708
}
800
761
 
801
762
static READ16_HANDLER( io_expansion_r )
802
763
{
803
 
        if (custom_io_r[0])
804
 
                return (*custom_io_r[0])(space, offset, mem_mask);
 
764
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
765
        if (state->m_custom_io_r[0])
 
766
                return (*state->m_custom_io_r[0])(space, offset, mem_mask);
805
767
        else
806
 
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
 
768
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
807
769
        return 0xffff;
808
770
}
809
771
 
810
772
 
811
773
static WRITE16_HANDLER( io_expansion_w )
812
774
{
 
775
        segas32_state *state = space->machine().driver_data<segas32_state>();
813
776
        /* only LSB matters */
814
777
        if (!ACCESSING_BITS_0_7)
815
778
        return;
816
779
 
817
 
        if (custom_io_w[0])
818
 
                (*custom_io_w[0])(space, offset, data, mem_mask);
 
780
        if (state->m_custom_io_w[0])
 
781
                (*state->m_custom_io_w[0])(space, offset, data, mem_mask);
819
782
        else
820
 
                logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
 
783
                logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
821
784
}
822
785
 
823
786
 
824
787
static READ32_HANDLER( io_expansion_0_r )
825
788
{
826
 
        if (custom_io_r[0])
827
 
                return (*custom_io_r[0])(space, offset*2+0, mem_mask) |
828
 
                          ((*custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16);
 
789
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
790
        if (state->m_custom_io_r[0])
 
791
                return (*state->m_custom_io_r[0])(space, offset*2+0, mem_mask) |
 
792
                          ((*state->m_custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16);
829
793
        else
830
 
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
 
794
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
831
795
        return 0xffffffff;
832
796
}
833
797
 
834
798
 
835
799
static WRITE32_HANDLER( io_expansion_0_w )
836
800
{
 
801
        segas32_state *state = space->machine().driver_data<segas32_state>();
837
802
        /* only LSB matters */
838
803
 
839
804
 
840
805
        if (ACCESSING_BITS_0_7)
841
806
        {
842
807
                /* harddunk uses bits 4,5 for output lamps */
843
 
                if (segas32_sw3_output)
844
 
                        segas32_sw3_output(0, data & 0xff);
 
808
                if (state->m_sw3_output)
 
809
                        state->m_sw3_output(0, data & 0xff);
845
810
 
846
 
                if (custom_io_w[0])
847
 
                        (*custom_io_w[0])(space, offset*2+0, data, mem_mask);
 
811
                if (state->m_custom_io_w[0])
 
812
                        (*state->m_custom_io_w[0])(space, offset*2+0, data, mem_mask);
848
813
                else
849
 
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
 
814
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
850
815
 
851
816
        }
852
817
        if (ACCESSING_BITS_16_23)
853
818
        {
854
 
                if (custom_io_w[0])
855
 
                        (*custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16);
 
819
                if (state->m_custom_io_w[0])
 
820
                        (*state->m_custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16);
856
821
                else
857
 
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
 
822
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
858
823
        }
859
824
}
860
825
 
861
826
 
862
827
static READ32_HANDLER( io_expansion_1_r )
863
828
{
864
 
        if (custom_io_r[1])
865
 
                return (*custom_io_r[1])(space, offset*2+0, mem_mask) |
866
 
                          ((*custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16);
 
829
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
830
        if (state->m_custom_io_r[1])
 
831
                return (*state->m_custom_io_r[1])(space, offset*2+0, mem_mask) |
 
832
                          ((*state->m_custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16);
867
833
        else
868
 
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
 
834
                logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(&space->device()), offset);
869
835
        return 0xffffffff;
870
836
}
871
837
 
872
838
 
873
839
static WRITE32_HANDLER( io_expansion_1_w )
874
840
{
 
841
        segas32_state *state = space->machine().driver_data<segas32_state>();
875
842
        /* only LSB matters */
876
843
        if (ACCESSING_BITS_0_7)
877
844
        {
878
 
                if (custom_io_w[1])
879
 
                        (*custom_io_w[1])(space, offset*2+0, data, mem_mask);
 
845
                if (state->m_custom_io_w[1])
 
846
                        (*state->m_custom_io_w[1])(space, offset*2+0, data, mem_mask);
880
847
                else
881
 
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
 
848
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
882
849
        }
883
850
        if (ACCESSING_BITS_16_23)
884
851
        {
885
 
                if (custom_io_w[1])
886
 
                        (*custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16);
 
852
                if (state->m_custom_io_w[1])
 
853
                        (*state->m_custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16);
887
854
                else
888
 
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
 
855
                        logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(&space->device()), offset, data & 0xff);
889
856
        }
890
857
}
891
858
 
899
866
 
900
867
static READ16_HANDLER( analog_custom_io_r )
901
868
{
 
869
        segas32_state *state = space->machine().driver_data<segas32_state>();
902
870
        UINT16 result;
903
871
        switch (offset)
904
872
        {
906
874
                case 0x12/2:
907
875
                case 0x14/2:
908
876
                case 0x16/2:
909
 
                        result = analog_value[offset & 3] | 0x7f;
910
 
                        analog_value[offset & 3] <<= 1;
 
877
                        result = state->m_analog_value[offset & 3] | 0x7f;
 
878
                        state->m_analog_value[offset & 3] <<= 1;
911
879
                        return result;
912
880
        }
913
 
        logerror("%06X:unknown analog_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask);
 
881
        logerror("%06X:unknown analog_custom_io_r(%X) & %04X\n", cpu_get_pc(&space->device()), offset*2, mem_mask);
914
882
        return 0xffff;
915
883
}
916
884
 
917
885
 
918
886
static WRITE16_HANDLER( analog_custom_io_w )
919
887
{
 
888
        segas32_state *state = space->machine().driver_data<segas32_state>();
920
889
        static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4" };
921
890
        switch (offset)
922
891
        {
924
893
                case 0x12/2:
925
894
                case 0x14/2:
926
895
                case 0x16/2:
927
 
                        analog_value[offset & 3] = input_port_read_safe(space->machine, names[offset & 3], 0);
 
896
                        state->m_analog_value[offset & 3] = input_port_read_safe(space->machine(), names[offset & 3], 0);
928
897
                        return;
929
898
        }
930
 
        logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
 
899
        logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(&space->device()), offset*2, data, mem_mask);
931
900
}
932
901
 
933
902
 
940
909
                case 0x22/2:
941
910
                case 0x24/2:
942
911
                case 0x26/2:
943
 
                        return input_port_read_safe(space->machine, names[offset & 3], 0xffff);
 
912
                        return input_port_read_safe(space->machine(), names[offset & 3], 0xffff);
944
913
        }
945
914
 
946
 
        logerror("%06X:unknown extra_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask);
 
915
        logerror("%06X:unknown extra_custom_io_r(%X) & %04X\n", cpu_get_pc(&space->device()), offset*2, mem_mask);
947
916
        return 0xffff;
948
917
}
949
918
 
950
919
 
951
920
static WRITE16_HANDLER( orunners_custom_io_w )
952
921
{
 
922
        segas32_state *state = space->machine().driver_data<segas32_state>();
953
923
        static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6", "ANALOG7", "ANALOG8" };
954
924
        switch (offset)
955
925
        {
957
927
                case 0x12/2:
958
928
                case 0x14/2:
959
929
                case 0x16/2:
960
 
                        analog_value[offset & 3] = input_port_read_safe(space->machine, names[analog_bank * 4 + (offset & 3)], 0);
 
930
                        state->m_analog_value[offset & 3] = input_port_read_safe(space->machine(), names[state->m_analog_bank * 4 + (offset & 3)], 0);
961
931
                        return;
962
932
 
963
933
                case 0x20/2:
964
 
                        analog_bank = data & 1;
 
934
                        state->m_analog_bank = data & 1;
965
935
                        return;
966
936
        }
967
 
        logerror("%06X:unknown orunners_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
 
937
        logerror("%06X:unknown orunners_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(&space->device()), offset*2, data, mem_mask);
968
938
}
969
939
 
970
940
 
971
941
static READ16_HANDLER( sonic_custom_io_r )
972
942
{
 
943
        segas32_state *state = space->machine().driver_data<segas32_state>();
973
944
        static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
974
945
 
975
946
        switch (offset)
980
951
                case 0x0c/2:
981
952
                case 0x10/2:
982
953
                case 0x14/2:
983
 
                        return (UINT8)(input_port_read(space->machine, names[offset/2]) - sonic_last[offset/2]);
 
954
                        return (UINT8)(input_port_read(space->machine(), names[offset/2]) - state->m_sonic_last[offset/2]);
984
955
        }
985
956
 
986
 
        logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask);
 
957
        logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", cpu_get_pc(&space->device()), offset*2, mem_mask);
987
958
        return 0xffff;
988
959
}
989
960
 
990
961
 
991
962
static WRITE16_HANDLER( sonic_custom_io_w )
992
963
{
 
964
        segas32_state *state = space->machine().driver_data<segas32_state>();
993
965
        static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
994
966
 
995
967
        switch (offset)
997
969
                case 0x00/2:
998
970
                case 0x08/2:
999
971
                case 0x10/2:
1000
 
                        sonic_last[offset/2 + 0] = input_port_read(space->machine, names[offset/2 + 0]);
1001
 
                        sonic_last[offset/2 + 1] = input_port_read(space->machine, names[offset/2 + 1]);
 
972
                        state->m_sonic_last[offset/2 + 0] = input_port_read(space->machine(), names[offset/2 + 0]);
 
973
                        state->m_sonic_last[offset/2 + 1] = input_port_read(space->machine(), names[offset/2 + 1]);
1002
974
                        return;
1003
975
        }
1004
976
 
1005
 
        logerror("%06X:unknown sonic_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
 
977
        logerror("%06X:unknown sonic_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(&space->device()), offset*2, data, mem_mask);
1006
978
}
1007
979
 
1008
980
 
1015
987
 
1016
988
static WRITE16_HANDLER( random_number_16_w )
1017
989
{
1018
 
//  mame_printf_debug("%06X:random_seed_w(%04X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
 
990
//  mame_printf_debug("%06X:random_seed_w(%04X) = %04X & %04X\n", cpu_get_pc(&space->device()), offset*2, data, mem_mask);
1019
991
}
1020
992
 
1021
993
static READ16_HANDLER( random_number_16_r )
1022
994
{
1023
 
        return space->machine->rand();
 
995
        return space->machine().rand();
1024
996
}
1025
997
 
1026
998
static WRITE32_HANDLER( random_number_32_w )
1027
999
{
1028
 
//  mame_printf_debug("%06X:random_seed_w(%04X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
 
1000
//  mame_printf_debug("%06X:random_seed_w(%04X) = %04X & %04X\n", cpu_get_pc(&space->device()), offset*2, data, mem_mask);
1029
1001
}
1030
1002
 
1031
1003
static READ32_HANDLER( random_number_32_r )
1032
1004
{
1033
 
        return space->machine->rand() ^ (space->machine->rand() << 16);
 
1005
        return space->machine().rand() ^ (space->machine().rand() << 16);
1034
1006
}
1035
1007
 
1036
1008
 
1043
1015
 
1044
1016
static READ16_HANDLER( shared_ram_16_r )
1045
1017
{
1046
 
        return z80_shared_ram[offset*2+0] | (z80_shared_ram[offset*2+1] << 8);
 
1018
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1019
        return state->m_z80_shared_ram[offset*2+0] | (state->m_z80_shared_ram[offset*2+1] << 8);
1047
1020
}
1048
1021
 
1049
1022
 
1050
1023
static WRITE16_HANDLER( shared_ram_16_w )
1051
1024
{
 
1025
        segas32_state *state = space->machine().driver_data<segas32_state>();
1052
1026
        if (ACCESSING_BITS_0_7)
1053
 
                z80_shared_ram[offset*2+0] = data;
 
1027
                state->m_z80_shared_ram[offset*2+0] = data;
1054
1028
        if (ACCESSING_BITS_8_15)
1055
 
                z80_shared_ram[offset*2+1] = data >> 8;
 
1029
                state->m_z80_shared_ram[offset*2+1] = data >> 8;
1056
1030
}
1057
1031
 
1058
1032
 
1059
1033
static READ32_HANDLER( shared_ram_32_r )
1060
1034
{
1061
 
        return z80_shared_ram[offset*4+0] | (z80_shared_ram[offset*4+1] << 8) |
1062
 
              (z80_shared_ram[offset*4+2] << 16) | (z80_shared_ram[offset*4+3] << 24);
 
1035
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1036
        return state->m_z80_shared_ram[offset*4+0] | (state->m_z80_shared_ram[offset*4+1] << 8) |
 
1037
              (state->m_z80_shared_ram[offset*4+2] << 16) | (state->m_z80_shared_ram[offset*4+3] << 24);
1063
1038
}
1064
1039
 
1065
1040
 
1066
1041
static WRITE32_HANDLER( shared_ram_32_w )
1067
1042
{
 
1043
        segas32_state *state = space->machine().driver_data<segas32_state>();
1068
1044
        if (ACCESSING_BITS_0_7)
1069
 
                z80_shared_ram[offset*4+0] = data;
 
1045
                state->m_z80_shared_ram[offset*4+0] = data;
1070
1046
        if (ACCESSING_BITS_8_15)
1071
 
                z80_shared_ram[offset*4+1] = data >> 8;
 
1047
                state->m_z80_shared_ram[offset*4+1] = data >> 8;
1072
1048
        if (ACCESSING_BITS_16_23)
1073
 
                z80_shared_ram[offset*4+2] = data >> 16;
 
1049
                state->m_z80_shared_ram[offset*4+2] = data >> 16;
1074
1050
        if (ACCESSING_BITS_24_31)
1075
 
                z80_shared_ram[offset*4+3] = data >> 24;
 
1051
                state->m_z80_shared_ram[offset*4+3] = data >> 24;
1076
1052
}
1077
1053
 
1078
1054
 
1083
1059
 *
1084
1060
 *************************************/
1085
1061
 
1086
 
static void update_sound_irq_state(running_machine *machine)
 
1062
static void update_sound_irq_state(running_machine &machine)
1087
1063
{
1088
 
        UINT8 effirq = sound_irq_input & ~sound_irq_control[3] & 0x07;
 
1064
        segas32_state *state = machine.driver_data<segas32_state>();
 
1065
        UINT8 effirq = state->m_sound_irq_input & ~state->m_sound_irq_control[3] & 0x07;
1089
1066
        int vector;
1090
1067
 
1091
1068
        /* loop over interrupt vectors, finding the highest priority one with */
1103
1080
}
1104
1081
 
1105
1082
 
1106
 
static void signal_sound_irq(running_machine *machine, int which)
 
1083
static void signal_sound_irq(running_machine &machine, int which)
1107
1084
{
 
1085
        segas32_state *state = machine.driver_data<segas32_state>();
1108
1086
        int i;
1109
1087
 
1110
1088
        /* see if this interrupt input is mapped to any vectors; if so, mark them */
1111
1089
        for (i = 0; i < 3; i++)
1112
 
                if (sound_irq_control[i] == which)
1113
 
                        sound_irq_input |= 1 << i;
 
1090
                if (state->m_sound_irq_control[i] == which)
 
1091
                        state->m_sound_irq_input |= 1 << i;
1114
1092
        update_sound_irq_state(machine);
1115
1093
}
1116
1094
 
1117
1095
 
1118
 
static void clear_sound_irq(running_machine *machine, int which)
 
1096
static void clear_sound_irq(running_machine &machine, int which)
1119
1097
{
 
1098
        segas32_state *state = machine.driver_data<segas32_state>();
1120
1099
        int i;
1121
1100
        for (i = 0; i < 3; i++)
1122
 
                if (sound_irq_control[i] == which)
1123
 
                        sound_irq_input &= ~(1 << i);
 
1101
                if (state->m_sound_irq_control[i] == which)
 
1102
                        state->m_sound_irq_input &= ~(1 << i);
1124
1103
        update_sound_irq_state(machine);
1125
1104
}
1126
1105
 
1127
1106
 
1128
1107
static WRITE8_HANDLER( sound_int_control_lo_w )
1129
1108
{
 
1109
        segas32_state *state = space->machine().driver_data<segas32_state>();
1130
1110
        /* odd offsets are interrupt acks */
1131
1111
        if (offset & 1)
1132
1112
        {
1133
 
                sound_irq_input &= data;
1134
 
                update_sound_irq_state(space->machine);
 
1113
                state->m_sound_irq_input &= data;
 
1114
                update_sound_irq_state(space->machine());
1135
1115
        }
1136
1116
 
1137
1117
        /* high offsets signal an IRQ to the v60 */
1138
1118
        if (offset & 4)
1139
 
                signal_v60_irq(space->machine, MAIN_IRQ_SOUND);
 
1119
                signal_v60_irq(space->machine(), MAIN_IRQ_SOUND);
1140
1120
}
1141
1121
 
1142
1122
 
1143
1123
static WRITE8_HANDLER( sound_int_control_hi_w )
1144
1124
{
1145
 
        sound_irq_control[offset] = data;
1146
 
        update_sound_irq_state(space->machine);
 
1125
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1126
        state->m_sound_irq_control[offset] = data;
 
1127
        update_sound_irq_state(space->machine());
1147
1128
}
1148
1129
 
1149
1130
 
1150
1131
static void ym3438_irq_handler(device_t *device, int state)
1151
1132
{
1152
1133
        if (state)
1153
 
                signal_sound_irq(device->machine, SOUND_IRQ_YM3438);
 
1134
                signal_sound_irq(device->machine(), SOUND_IRQ_YM3438);
1154
1135
        else
1155
 
                clear_sound_irq(device->machine, SOUND_IRQ_YM3438);
 
1136
                clear_sound_irq(device->machine(), SOUND_IRQ_YM3438);
1156
1137
}
1157
1138
 
1158
1139
 
1165
1146
 
1166
1147
static WRITE8_HANDLER( sound_bank_lo_w )
1167
1148
{
1168
 
        sound_bank = (sound_bank & ~0x3f) | (data & 0x3f);
1169
 
        memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * sound_bank);
 
1149
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1150
        state->m_sound_bank = (state->m_sound_bank & ~0x3f) | (data & 0x3f);
 
1151
        memory_set_bankptr(space->machine(), "bank1", space->machine().region("soundcpu")->base() + 0x100000 + 0x2000 * state->m_sound_bank);
1170
1152
}
1171
1153
 
1172
1154
 
1173
1155
static WRITE8_HANDLER( sound_bank_hi_w )
1174
1156
{
1175
 
        sound_bank = (sound_bank & 0x3f) | ((data & 0x04) << 4) | ((data & 0x03) << 7);
1176
 
        memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * sound_bank);
 
1157
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1158
        state->m_sound_bank = (state->m_sound_bank & 0x3f) | ((data & 0x04) << 4) | ((data & 0x03) << 7);
 
1159
        memory_set_bankptr(space->machine(), "bank1", space->machine().region("soundcpu")->base() + 0x100000 + 0x2000 * state->m_sound_bank);
1177
1160
}
1178
1161
 
1179
1162
 
1198
1181
 
1199
1182
static READ8_HANDLER( sound_dummy_r )
1200
1183
{
1201
 
        return sound_dummy_value;
 
1184
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1185
        return state->m_sound_dummy_value;
1202
1186
}
1203
1187
 
1204
1188
 
1205
1189
static WRITE8_HANDLER( sound_dummy_w )
1206
1190
{
1207
 
        sound_dummy_value = data;
 
1191
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
1192
        state->m_sound_dummy_value = data;
1208
1193
}
1209
1194
 
1210
1195
 
1215
1200
 *
1216
1201
 *************************************/
1217
1202
 
1218
 
static ADDRESS_MAP_START( system32_map, ADDRESS_SPACE_PROGRAM, 16 )
 
1203
static ADDRESS_MAP_START( system32_map, AS_PROGRAM, 16 )
1219
1204
        ADDRESS_MAP_UNMAP_HIGH
1220
1205
        AM_RANGE(0x000000, 0x1fffff) AM_ROM
1221
 
        AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE(&system32_workram)
1222
 
        AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE(&system32_videoram)
1223
 
        AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE(&system32_spriteram)
 
1206
        AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE_MEMBER(segas32_state, m_system32_workram)
 
1207
        AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE_MEMBER(segas32_state, m_system32_videoram)
 
1208
        AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE_MEMBER(segas32_state, m_system32_spriteram)
1224
1209
        AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(system32_sprite_control_r, system32_sprite_control_w)
1225
 
        AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE(&system32_paletteram[0])
 
1210
        AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[0])
1226
1211
        AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x0eff80) AM_READWRITE(system32_mixer_r, system32_mixer_w)
1227
1212
        AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_16_r, shared_ram_16_w)
1228
1213
        AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x0fff80) AM_READWRITE(io_chip_r, io_chip_w)
1233
1218
ADDRESS_MAP_END
1234
1219
 
1235
1220
 
1236
 
static ADDRESS_MAP_START( multi32_map, ADDRESS_SPACE_PROGRAM, 32 )
 
1221
static ADDRESS_MAP_START( multi32_map, AS_PROGRAM, 32 )
1237
1222
        ADDRESS_MAP_UNMAP_HIGH
1238
1223
        ADDRESS_MAP_GLOBAL_MASK(0xffffff)
1239
1224
        AM_RANGE(0x000000, 0x1fffff) AM_ROM
1240
1225
        AM_RANGE(0x200000, 0x21ffff) AM_MIRROR(0x0e0000) AM_RAM
1241
 
        AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE((UINT32 **)&system32_videoram)
1242
 
        AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE((UINT32 **)&system32_spriteram)
 
1226
        AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE_MEMBER(segas32_state, m_system32_videoram)
 
1227
        AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE_MEMBER(segas32_state, m_system32_spriteram)
1243
1228
        AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(multi32_sprite_control_r, multi32_sprite_control_w)
1244
 
        AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE((UINT32 **)&system32_paletteram[0])
 
1229
        AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[0])
1245
1230
        AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_0_w)
1246
 
        AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE((UINT32 **)&system32_paletteram[1])
 
1231
        AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE_MEMBER(segas32_state, m_system32_paletteram[1])
1247
1232
        AM_RANGE(0x690000, 0x69007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_1_w)
1248
1233
        AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_32_r, shared_ram_32_w)
1249
1234
        AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x07ff80) AM_READWRITE(io_chip_0_r, io_chip_0_w)
1263
1248
 *
1264
1249
 *************************************/
1265
1250
 
1266
 
static ADDRESS_MAP_START( system32_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
 
1251
static ADDRESS_MAP_START( system32_sound_map, AS_PROGRAM, 8 )
1267
1252
        AM_RANGE(0x0000, 0x9fff) AM_ROM AM_REGION("soundcpu", 0x100000)
1268
1253
        AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1")
1269
1254
        AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x0ff0) AM_DEVWRITE("rfsnd", rf5c68_w)
1270
1255
        AM_RANGE(0xd000, 0xdfff) AM_DEVREADWRITE("rfsnd", rf5c68_mem_r, rf5c68_mem_w)
1271
 
        AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE(&z80_shared_ram)
 
1256
        AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE_MEMBER(segas32_state, m_z80_shared_ram)
1272
1257
ADDRESS_MAP_END
1273
1258
 
1274
 
static ADDRESS_MAP_START( system32_sound_portmap, ADDRESS_SPACE_IO, 8 )
 
1259
static ADDRESS_MAP_START( system32_sound_portmap, AS_IO, 8 )
1275
1260
        ADDRESS_MAP_UNMAP_HIGH
1276
1261
        ADDRESS_MAP_GLOBAL_MASK(0xff)
1277
1262
        AM_RANGE(0x80, 0x83) AM_MIRROR(0x0c) AM_DEVREADWRITE("ym1", ym3438_r, ym3438_w)
1284
1269
ADDRESS_MAP_END
1285
1270
 
1286
1271
 
1287
 
static ADDRESS_MAP_START( multi32_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
 
1272
static ADDRESS_MAP_START( multi32_sound_map, AS_PROGRAM, 8 )
1288
1273
        AM_RANGE(0x0000, 0x9fff) AM_ROM AM_REGION("soundcpu", 0x100000)
1289
1274
        AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1")
1290
1275
        AM_RANGE(0xc000, 0xdfff) AM_DEVREADWRITE("sega", multipcm_r, multipcm_w)
1291
 
        AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE(&z80_shared_ram)
 
1276
        AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE_MEMBER(segas32_state, m_z80_shared_ram)
1292
1277
ADDRESS_MAP_END
1293
1278
 
1294
 
static ADDRESS_MAP_START( multi32_sound_portmap, ADDRESS_SPACE_IO, 8 )
 
1279
static ADDRESS_MAP_START( multi32_sound_portmap, AS_IO, 8 )
1295
1280
        ADDRESS_MAP_UNMAP_HIGH
1296
1281
        ADDRESS_MAP_GLOBAL_MASK(0xff)
1297
1282
        AM_RANGE(0x80, 0x83) AM_MIRROR(0x0c) AM_DEVREADWRITE("ymsnd", ym3438_r, ym3438_w)
1310
1295
 *
1311
1296
 *************************************/
1312
1297
 
1313
 
static ADDRESS_MAP_START( ga2_v25_map, ADDRESS_SPACE_PROGRAM, 8 )
 
1298
static ADDRESS_MAP_START( ga2_v25_map, AS_PROGRAM, 8 )
1314
1299
        AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_REGION("mcu", 0)
1315
 
        AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE(&ga2_dpram)
 
1300
        AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE_MEMBER(segas32_state, m_ga2_dpram)
1316
1301
        AM_RANGE(0xf0000, 0xfffff) AM_ROM AM_REGION("mcu", 0)
1317
1302
ADDRESS_MAP_END
1318
1303
 
2153
2138
 
2154
2139
// Both arescue and f1en appear to use an identical shared RAM system.
2155
2140
 
2156
 
static UINT16* dual_pcb_comms;
2157
2141
 
2158
2142
static WRITE16_HANDLER( dual_pcb_comms_w )
2159
2143
{
2160
 
        COMBINE_DATA(&dual_pcb_comms[offset]);
 
2144
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
2145
        COMBINE_DATA(&state->m_dual_pcb_comms[offset]);
2161
2146
}
2162
2147
 
2163
2148
static READ16_HANDLER( dual_pcb_comms_r )
2164
2149
{
2165
 
        return dual_pcb_comms[offset];
 
2150
        segas32_state *state = space->machine().driver_data<segas32_state>();
 
2151
        return state->m_dual_pcb_comms[offset];
2166
2152
}
2167
2153
 
2168
2154
 
2183
2169
 *
2184
2170
 *************************************/
2185
2171
 
2186
 
static MACHINE_CONFIG_START( system32, driver_device )
 
2172
static MACHINE_CONFIG_START( system32, segas32_state )
2187
2173
 
2188
2174
        /* basic machine hardware */
2189
2175
        MCFG_CPU_ADD("maincpu", V60, MASTER_CLOCK/2)
2210
2196
        MCFG_SCREEN_REFRESH_RATE(60)
2211
2197
        MCFG_SCREEN_SIZE(52*8, 262)
2212
2198
        MCFG_SCREEN_VISIBLE_AREA(0*8, 52*8-1, 0*8, 28*8-1)
 
2199
        MCFG_SCREEN_UPDATE(system32)
2213
2200
 
2214
2201
        MCFG_VIDEO_START(system32)
2215
 
        MCFG_VIDEO_UPDATE(system32)
2216
2202
 
2217
2203
        /* sound hardware */
2218
2204
        MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
2243
2229
MACHINE_CONFIG_END
2244
2230
 
2245
2231
 
2246
 
static MACHINE_CONFIG_START( multi32, driver_device )
 
2232
static MACHINE_CONFIG_START( multi32, segas32_state )
2247
2233
 
2248
2234
        /* basic machine hardware */
2249
2235
        MCFG_CPU_ADD("maincpu", V70, MULTI32_CLOCK/2)
2271
2257
        MCFG_SCREEN_REFRESH_RATE(60)
2272
2258
        MCFG_SCREEN_SIZE(52*8, 262)
2273
2259
        MCFG_SCREEN_VISIBLE_AREA(0*8, 52*8-1, 0*8, 28*8-1)
 
2260
        MCFG_SCREEN_UPDATE(multi32)
2274
2261
 
2275
2262
        MCFG_SCREEN_ADD("rscreen", RASTER)
2276
2263
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
2277
2264
        MCFG_SCREEN_REFRESH_RATE(60)
2278
2265
        MCFG_SCREEN_SIZE(52*8, 262)
2279
2266
        MCFG_SCREEN_VISIBLE_AREA(0*8, 52*8-1, 0*8, 28*8-1)
 
2267
        MCFG_SCREEN_UPDATE(multi32)
2280
2268
 
2281
2269
        MCFG_VIDEO_START(multi32)
2282
 
        MCFG_VIDEO_UPDATE(multi32)
2283
2270
 
2284
2271
        /* sound hardware */
2285
2272
        MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
3807
3794
 *
3808
3795
 *************************************/
3809
3796
 
3810
 
static void segas32_common_init(read16_space_func custom_r, write16_space_func custom_w)
 
3797
static void segas32_common_init(running_machine &machine, read16_space_func custom_r, write16_space_func custom_w)
3811
3798
{
 
3799
        segas32_state *state = machine.driver_data<segas32_state>();
3812
3800
        /* reset the custom handlers and other pointers */
3813
 
        custom_io_r[0] = custom_r;
3814
 
        custom_io_w[0] = custom_w;
3815
 
        system32_prot_vblank = NULL;
3816
 
        segas32_sw1_output = NULL;
3817
 
        segas32_sw2_output = NULL;
3818
 
        segas32_sw3_output = NULL;
 
3801
        state->m_custom_io_r[0] = custom_r;
 
3802
        state->m_custom_io_w[0] = custom_w;
 
3803
        state->m_system32_prot_vblank = NULL;
 
3804
        state->m_sw1_output = NULL;
 
3805
        state->m_sw2_output = NULL;
 
3806
        state->m_sw3_output = NULL;
3819
3807
}
3820
3808
 
3821
3809
 
4003
3991
 
4004
3992
static DRIVER_INIT( alien3 )
4005
3993
{
4006
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4007
 
        segas32_sw1_output = alien3_sw1_output;
 
3994
        segas32_state *state = machine.driver_data<segas32_state>();
 
3995
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
3996
        state->m_sw1_output = alien3_sw1_output;
4008
3997
}
4009
3998
 
4010
3999
static READ16_HANDLER( arescue_handshake_r )
4019
4008
 
4020
4009
static DRIVER_INIT( arescue )
4021
4010
{
4022
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4023
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00007, 0, 0, arescue_dsp_r, arescue_dsp_w);
4024
 
 
4025
 
        dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4026
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
4027
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
4028
 
 
4029
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810001, 0, 0, arescue_handshake_r);
4030
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x81000e, 0x81000f, 0, 0, arescue_slavebusy_r);
4031
 
 
4032
 
        segas32_sw1_output = arescue_sw1_output;
 
4011
        segas32_state *state = machine.driver_data<segas32_state>();
 
4012
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4013
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00007, FUNC(arescue_dsp_r), FUNC(arescue_dsp_w));
 
4014
 
 
4015
        state->m_dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
 
4016
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x810000, 0x810fff, FUNC(dual_pcb_comms_r), FUNC(dual_pcb_comms_w));
 
4017
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x818000, 0x818003, FUNC(dual_pcb_masterslave));
 
4018
 
 
4019
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x810000, 0x810001, FUNC(arescue_handshake_r));
 
4020
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x81000e, 0x81000f, FUNC(arescue_slavebusy_r));
 
4021
 
 
4022
        state->m_sw1_output = arescue_sw1_output;
4033
4023
}
4034
4024
 
4035
4025
 
4036
4026
static DRIVER_INIT( arabfgt )
4037
4027
{
4038
 
        segas32_common_init(extra_custom_io_r, NULL);
 
4028
        segas32_common_init(machine, extra_custom_io_r, NULL);
4039
4029
 
4040
4030
        /* install protection handlers */
4041
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00100, 0xa0011f, 0, 0, arf_wakeup_protection_r);
4042
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, arabfgt_protection_r, arabfgt_protection_w);
 
4031
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0xa00100, 0xa0011f, FUNC(arf_wakeup_protection_r));
 
4032
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00fff, FUNC(arabfgt_protection_r), FUNC(arabfgt_protection_w));
4043
4033
}
4044
4034
 
4045
4035
 
4046
4036
static DRIVER_INIT( brival )
4047
4037
{
4048
 
        segas32_common_init(extra_custom_io_r, NULL);
 
4038
        segas32_state *state = machine.driver_data<segas32_state>();
 
4039
        segas32_common_init(machine, extra_custom_io_r, NULL);
4049
4040
 
4050
4041
        /* install protection handlers */
4051
 
        system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2);
4052
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20ba00, 0x20ba07, 0, 0, brival_protection_r);
4053
 
        memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, brival_protection_w);
 
4042
        state->m_system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2);
 
4043
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x20ba00, 0x20ba07, FUNC(brival_protection_r));
 
4044
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xa00000, 0xa00fff, FUNC(brival_protection_w));
4054
4045
}
4055
4046
 
4056
4047
 
4057
4048
static DRIVER_INIT( darkedge )
4058
4049
{
4059
 
        segas32_common_init(extra_custom_io_r, NULL);
 
4050
        segas32_state *state = machine.driver_data<segas32_state>();
 
4051
        segas32_common_init(machine, extra_custom_io_r, NULL);
4060
4052
 
4061
4053
        /* install protection handlers */
4062
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, darkedge_protection_r, darkedge_protection_w);
4063
 
        system32_prot_vblank = darkedge_fd1149_vblank;
 
4054
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa7ffff, FUNC(darkedge_protection_r), FUNC(darkedge_protection_w));
 
4055
        state->m_system32_prot_vblank = darkedge_fd1149_vblank;
4064
4056
}
4065
4057
 
4066
4058
static DRIVER_INIT( dbzvrvs )
4067
4059
{
4068
 
        segas32_common_init(NULL, NULL);
 
4060
        segas32_common_init(machine, NULL, NULL);
4069
4061
 
4070
4062
        /* install protection handlers */
4071
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, dbzvrvs_protection_r, dbzvrvs_protection_w);
 
4063
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa7ffff, FUNC(dbzvrvs_protection_r), FUNC(dbzvrvs_protection_w));
4072
4064
}
4073
4065
 
4074
4066
static WRITE16_HANDLER( f1en_comms_echo_w )
4080
4072
 
4081
4073
static DRIVER_INIT( f1en )
4082
4074
{
4083
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4084
 
 
4085
 
        dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
4086
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
4087
 
        memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
4088
 
 
4089
 
        memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810048, 0x810049, 0, 0, f1en_comms_echo_w);
4090
 
 
4091
 
        segas32_sw1_output = radm_sw1_output;
 
4075
        segas32_state *state = machine.driver_data<segas32_state>();
 
4076
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4077
 
 
4078
        state->m_dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
 
4079
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x810000, 0x810fff, FUNC(dual_pcb_comms_r), FUNC(dual_pcb_comms_w));
 
4080
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x818000, 0x818003, FUNC(dual_pcb_masterslave));
 
4081
 
 
4082
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x810048, 0x810049, FUNC(f1en_comms_echo_w));
 
4083
 
 
4084
        state->m_sw1_output = radm_sw1_output;
4092
4085
}
4093
4086
 
4094
4087
 
4095
4088
static DRIVER_INIT( f1lap )
4096
4089
{
4097
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4098
 
        segas32_sw1_output = f1lap_sw1_output;
 
4090
        segas32_state *state = machine.driver_data<segas32_state>();
 
4091
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4092
        state->m_sw1_output = f1lap_sw1_output;
4099
4093
}
4100
4094
 
4101
4095
 
4102
4096
static DRIVER_INIT( ga2 )
4103
4097
{
4104
 
        segas32_common_init(extra_custom_io_r, NULL);
 
4098
        segas32_common_init(machine, extra_custom_io_r, NULL);
4105
4099
 
4106
4100
        decrypt_ga2_protrom(machine);
4107
 
        memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, ga2_dpram_r, ga2_dpram_w);
 
4101
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xa00000, 0xa00fff, FUNC(ga2_dpram_r), FUNC(ga2_dpram_w));
4108
4102
}
4109
4103
 
4110
4104
 
4111
4105
static DRIVER_INIT( harddunk )
4112
4106
{
4113
 
        segas32_common_init(extra_custom_io_r, NULL);
4114
 
        segas32_sw1_output = harddunk_sw1_output;
4115
 
        segas32_sw2_output = harddunk_sw2_output;
4116
 
        segas32_sw3_output = harddunk_sw3_output;
 
4107
        segas32_state *state = machine.driver_data<segas32_state>();
 
4108
        segas32_common_init(machine, extra_custom_io_r, NULL);
 
4109
        state->m_sw1_output = harddunk_sw1_output;
 
4110
        state->m_sw2_output = harddunk_sw2_output;
 
4111
        state->m_sw3_output = harddunk_sw3_output;
4117
4112
}
4118
4113
 
4119
4114
 
4120
4115
static DRIVER_INIT( holo )
4121
4116
{
4122
 
        segas32_common_init(NULL, NULL);
 
4117
        segas32_common_init(machine, NULL, NULL);
4123
4118
}
4124
4119
 
4125
4120
 
4126
4121
static DRIVER_INIT( jpark )
4127
4122
{
 
4123
        segas32_state *state = machine.driver_data<segas32_state>();
4128
4124
        /* Temp. Patch until we emulate the 'Drive Board', thanks to Malice */
4129
 
        UINT16 *pROM = (UINT16 *)machine->region("maincpu")->base();
 
4125
        UINT16 *pROM = (UINT16 *)machine.region("maincpu")->base();
4130
4126
 
4131
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
 
4127
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4132
4128
 
4133
4129
        pROM[0xC15A8/2] = 0xCD70;
4134
4130
        pROM[0xC15AA/2] = 0xD8CD;
4135
4131
 
4136
 
        segas32_sw1_output = jpark_sw1_output;
 
4132
        state->m_sw1_output = jpark_sw1_output;
4137
4133
}
4138
4134
 
4139
4135
 
4140
4136
static DRIVER_INIT( orunners )
4141
4137
{
4142
 
        segas32_common_init(analog_custom_io_r, orunners_custom_io_w);
4143
 
        segas32_sw1_output = orunners_sw1_output;
4144
 
        segas32_sw2_output = orunners_sw2_output;
 
4138
        segas32_state *state = machine.driver_data<segas32_state>();
 
4139
        segas32_common_init(machine, analog_custom_io_r, orunners_custom_io_w);
 
4140
        state->m_sw1_output = orunners_sw1_output;
 
4141
        state->m_sw2_output = orunners_sw2_output;
4145
4142
}
4146
4143
 
4147
4144
 
4148
4145
static DRIVER_INIT( radm )
4149
4146
{
4150
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4151
 
        segas32_sw1_output = radm_sw1_output;
4152
 
        segas32_sw2_output = radm_sw2_output;
 
4147
        segas32_state *state = machine.driver_data<segas32_state>();
 
4148
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4149
        state->m_sw1_output = radm_sw1_output;
 
4150
        state->m_sw2_output = radm_sw2_output;
4153
4151
}
4154
4152
 
4155
4153
 
4156
4154
static DRIVER_INIT( radr )
4157
4155
{
4158
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4159
 
        segas32_sw1_output = radm_sw1_output;
4160
 
        segas32_sw2_output = radr_sw2_output;
 
4156
        segas32_state *state = machine.driver_data<segas32_state>();
 
4157
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4158
        state->m_sw1_output = radm_sw1_output;
 
4159
        state->m_sw2_output = radr_sw2_output;
4161
4160
}
4162
4161
 
4163
4162
 
4164
4163
static DRIVER_INIT( scross )
4165
4164
{
4166
 
        multipcm_device *multipcm = machine->device<multipcm_device>("sega");
4167
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
4168
 
        memory_install_write8_device_handler(cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_PROGRAM), multipcm, 0xb0, 0xbf, 0, 0, scross_bank_w);
 
4165
        segas32_state *state = machine.driver_data<segas32_state>();
 
4166
        multipcm_device *multipcm = machine.device<multipcm_device>("sega");
 
4167
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
 
4168
        machine.device("soundcpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(*multipcm, 0xb0, 0xbf, FUNC(scross_bank_w));
4169
4169
 
4170
 
        segas32_sw1_output = scross_sw1_output;
4171
 
        segas32_sw2_output = scross_sw2_output;
 
4170
        state->m_sw1_output = scross_sw1_output;
 
4171
        state->m_sw2_output = scross_sw2_output;
4172
4172
}
4173
4173
 
4174
4174
 
4175
4175
static DRIVER_INIT( slipstrm )
4176
4176
{
4177
 
        segas32_common_init(analog_custom_io_r, analog_custom_io_w);
 
4177
        segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
4178
4178
}
4179
4179
 
4180
4180
 
4181
4181
static DRIVER_INIT( sonic )
4182
4182
{
4183
 
        segas32_common_init(sonic_custom_io_r, sonic_custom_io_w);
 
4183
        segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
4184
4184
 
4185
4185
        /* install protection handlers */
4186
 
        memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20E5C4, 0x20E5C5, 0, 0, sonic_level_load_protection);
 
4186
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x20E5C4, 0x20E5C5, FUNC(sonic_level_load_protection));
4187
4187
}
4188
4188
 
4189
4189
 
4190
4190
static DRIVER_INIT( sonicp )
4191
4191
{
4192
 
        segas32_common_init(sonic_custom_io_r, sonic_custom_io_w);
 
4192
        segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
4193
4193
}
4194
4194
 
4195
4195
 
4196
4196
static DRIVER_INIT( spidman )
4197
4197
{
4198
 
        segas32_common_init(extra_custom_io_r, NULL);
 
4198
        segas32_common_init(machine, extra_custom_io_r, NULL);
4199
4199
}
4200
4200
 
4201
4201
 
4202
4202
static DRIVER_INIT( svf )
4203
4203
{
4204
 
        segas32_common_init(NULL, NULL);
 
4204
        segas32_common_init(machine, NULL, NULL);
4205
4205
}
4206
4206
 
4207
4207
 
4208
4208
static DRIVER_INIT( jleague )
4209
4209
{
4210
 
        segas32_common_init(NULL, NULL);
4211
 
        memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20F700, 0x20F705, 0, 0, jleague_protection_w);
 
4210
        segas32_common_init(machine, NULL, NULL);
 
4211
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x20F700, 0x20F705, FUNC(jleague_protection_w));
4212
4212
}
4213
4213
 
4214
4214
 
4215
4215
static DRIVER_INIT( titlef )
4216
4216
{
4217
 
        segas32_common_init(NULL, NULL);
4218
 
        segas32_sw1_output = titlef_sw1_output;
4219
 
        segas32_sw2_output = titlef_sw2_output;
 
4217
        segas32_state *state = machine.driver_data<segas32_state>();
 
4218
        segas32_common_init(machine, NULL, NULL);
 
4219
        state->m_sw1_output = titlef_sw1_output;
 
4220
        state->m_sw2_output = titlef_sw2_output;
4220
4221
}
4221
4222
 
4222
4223