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

« back to all changes in this revision

Viewing changes to src/mame/audio/atarijsa.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:
71
71
static UINT8 ym2151_ct1;
72
72
static UINT8 ym2151_ct2;
73
73
 
74
 
static void update_all_volumes(running_machine *machine);
 
74
static void update_all_volumes(running_machine &machine);
75
75
 
76
76
static READ8_HANDLER( jsa1_io_r );
77
77
static WRITE8_HANDLER( jsa1_io_w );
87
87
 *
88
88
 *************************************/
89
89
 
90
 
static ADDRESS_MAP_START( jsa3_oki_map, 0, 8 )
 
90
static ADDRESS_MAP_START( jsa3_oki_map, AS_0, 8 )
91
91
        AM_RANGE(0x00000, 0x1ffff) AM_ROMBANK("bank12")
92
92
        AM_RANGE(0x20000, 0x3ffff) AM_ROMBANK("bank13")
93
93
ADDRESS_MAP_END
94
94
 
95
 
static ADDRESS_MAP_START( jsa3_oki2_map, 0, 8 )
 
95
static ADDRESS_MAP_START( jsa3_oki2_map, AS_0, 8 )
96
96
        AM_RANGE(0x00000, 0x1ffff) AM_ROMBANK("bank14")
97
97
        AM_RANGE(0x20000, 0x3ffff) AM_ROMBANK("bank15")
98
98
ADDRESS_MAP_END
105
105
 *
106
106
 *************************************/
107
107
 
108
 
static void init_save_state(running_machine *machine)
 
108
static void init_save_state(running_machine &machine)
109
109
{
110
110
        state_save_register_global(machine, overall_volume);
111
111
        state_save_register_global(machine, pokey_volume);
122
122
 *
123
123
 *************************************/
124
124
 
125
 
void atarijsa_init(running_machine *machine, const char *testport, int testmask)
 
125
void atarijsa_init(running_machine &machine, const char *testport, int testmask)
126
126
{
127
127
        UINT8 *rgn;
128
128
 
129
129
        /* copy in the parameters */
130
 
        jsacpu = machine->device<cpu_device>("jsa");
 
130
        jsacpu = machine.device<cpu_device>("jsa");
131
131
        assert_always(jsacpu != NULL, "Could not find JSA CPU!");
132
132
        test_port = testport;
133
133
        test_mask = testmask;
134
134
 
135
135
        /* predetermine the bank base */
136
 
        rgn = machine->region("jsa")->base();
 
136
        rgn = machine.region("jsa")->base();
137
137
        bank_base = &rgn[0x03000];
138
138
        bank_source_data = &rgn[0x10000];
139
139
 
140
140
        /* determine which sound hardware is installed */
141
 
        tms5220 = machine->device("tms");
142
 
        ym2151 = machine->device<ym2151_device>("ymsnd");
143
 
        pokey = machine->device<pokey_device>("pokey");
144
 
        oki6295 = machine->device<okim6295_device>("adpcm");
145
 
        oki6295_l = machine->device<okim6295_device>("adpcml");
146
 
        oki6295_r = machine->device<okim6295_device>("adpcmr");
 
141
        tms5220 = machine.device("tms");
 
142
        ym2151 = machine.device<ym2151_device>("ymsnd");
 
143
        pokey = machine.device<pokey_device>("pokey");
 
144
        oki6295 = machine.device<okim6295_device>("adpcm");
 
145
        oki6295_l = machine.device<okim6295_device>("adpcml");
 
146
        oki6295_r = machine.device<okim6295_device>("adpcmr");
147
147
 
148
148
        /* install POKEY memory handlers */
149
149
        if (pokey != NULL)
150
 
                memory_install_readwrite8_device_handler(cpu_get_address_space(jsacpu, ADDRESS_SPACE_PROGRAM), pokey, 0x2c00, 0x2c0f, 0, 0, pokey_r, pokey_w);
 
150
                jsacpu->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(*pokey, 0x2c00, 0x2c0f, FUNC(pokey_r), FUNC(pokey_w));
151
151
 
152
152
        init_save_state(machine);
153
153
        atarijsa_reset();
161
161
                /* the upper 128k is fixed, the lower 128k is bankswitched */
162
162
                for (rgn = 0; rgn < ARRAY_LENGTH(regions); rgn++)
163
163
                {
164
 
                        UINT8 *base = machine->region(regions[rgn])->base();
165
 
                        if (base != NULL && machine->region(regions[rgn])->bytes() >= 0x80000)
 
164
                        UINT8 *base = machine.region(regions[rgn])->base();
 
165
                        if (base != NULL && machine.region(regions[rgn])->bytes() >= 0x80000)
166
166
                        {
167
167
                                const char *bank = (rgn != 2) ? "bank12" : "bank14";
168
168
                                const char *bank_plus_1 = (rgn != 2) ? "bank13" : "bank15";
203
203
 
204
204
static READ8_HANDLER( jsa1_io_r )
205
205
{
206
 
        atarigen_state *atarigen = space->machine->driver_data<atarigen_state>();
 
206
        atarigen_state *atarigen = space->machine().driver_data<atarigen_state>();
207
207
        int result = 0xff;
208
208
 
209
209
        switch (offset & 0x206)
227
227
                0x02 = coin 2
228
228
                0x01 = coin 1
229
229
            */
230
 
                        result = input_port_read(space->machine, "JSAI");
231
 
                        if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80;
232
 
                        if (atarigen->cpu_to_sound_ready) result ^= 0x40;
233
 
                        if (atarigen->sound_to_cpu_ready) result ^= 0x20;
 
230
                        result = input_port_read(space->machine(), "JSAI");
 
231
                        if (!(input_port_read(space->machine(), test_port) & test_mask)) result ^= 0x80;
 
232
                        if (atarigen->m_cpu_to_sound_ready) result ^= 0x40;
 
233
                        if (atarigen->m_sound_to_cpu_ready) result ^= 0x20;
234
234
                        if ((tms5220 != NULL) && (tms5220_readyq_r(tms5220) == 0))
235
235
                                result |= 0x10;
236
236
                        else
298
298
                        }
299
299
 
300
300
                        /* reset the YM2151 if needed */
301
 
                        if ((data&1) == 0) devtag_reset(space->machine, "ymsnd");
 
301
                        if ((data&1) == 0) devtag_reset(space->machine(), "ymsnd");
302
302
 
303
303
                        /* coin counters */
304
 
                        coin_counter_w(space->machine, 1, (data >> 5) & 1);
305
 
                        coin_counter_w(space->machine, 0, (data >> 4) & 1);
 
304
                        coin_counter_w(space->machine(), 1, (data >> 5) & 1);
 
305
                        coin_counter_w(space->machine(), 0, (data >> 4) & 1);
306
306
 
307
307
                        /* update the bank */
308
308
                        memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
318
318
                        tms5220_volume = ((data >> 6) & 3) * 100 / 3;
319
319
                        pokey_volume = ((data >> 4) & 3) * 100 / 3;
320
320
                        ym2151_volume = ((data >> 1) & 7) * 100 / 7;
321
 
                        update_all_volumes(space->machine);
 
321
                        update_all_volumes(space->machine());
322
322
                        break;
323
323
        }
324
324
}
333
333
 
334
334
static READ8_HANDLER( jsa2_io_r )
335
335
{
336
 
        atarigen_state *atarigen = space->machine->driver_data<atarigen_state>();
 
336
        atarigen_state *atarigen = space->machine().driver_data<atarigen_state>();
337
337
        int result = 0xff;
338
338
 
339
339
        switch (offset & 0x206)
360
360
                0x02 = coin 2
361
361
                0x01 = coin 1
362
362
            */
363
 
                        result = input_port_read(space->machine, "JSAII");
364
 
                        if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80;
365
 
                        if (atarigen->cpu_to_sound_ready) result ^= 0x40;
366
 
                        if (atarigen->sound_to_cpu_ready) result ^= 0x20;
 
363
                        result = input_port_read(space->machine(), "JSAII");
 
364
                        if (!(input_port_read(space->machine(), test_port) & test_mask)) result ^= 0x80;
 
365
                        if (atarigen->m_cpu_to_sound_ready) result ^= 0x40;
 
366
                        if (atarigen->m_sound_to_cpu_ready) result ^= 0x20;
367
367
                        break;
368
368
 
369
369
                case 0x006:             /* /IRQACK */
419
419
            */
420
420
 
421
421
                        /* reset the YM2151 if needed */
422
 
                        if ((data&1) == 0) devtag_reset(space->machine, "ymsnd");
 
422
                        if ((data&1) == 0) devtag_reset(space->machine(), "ymsnd");
423
423
 
424
424
                        /* update the bank */
425
425
                        memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
426
426
 
427
427
                        /* coin counters */
428
 
                        coin_counter_w(space->machine, 1, (data >> 5) & 1);
429
 
                        coin_counter_w(space->machine, 0, (data >> 4) & 1);
 
428
                        coin_counter_w(space->machine(), 1, (data >> 5) & 1);
 
429
                        coin_counter_w(space->machine(), 0, (data >> 4) & 1);
430
430
 
431
431
                        /* update the OKI frequency */
432
432
                        if (oki6295 != NULL)
443
443
            */
444
444
                        ym2151_volume = ((data >> 1) & 7) * 100 / 7;
445
445
                        oki6295_volume = 50 + (data & 1) * 50;
446
 
                        update_all_volumes(space->machine);
 
446
                        update_all_volumes(space->machine());
447
447
                        break;
448
448
        }
449
449
}
458
458
 
459
459
static READ8_HANDLER( jsa3_io_r )
460
460
{
461
 
        atarigen_state *atarigen = space->machine->driver_data<atarigen_state>();
 
461
        atarigen_state *atarigen = space->machine().driver_data<atarigen_state>();
462
462
        int result = 0xff;
463
463
 
464
464
        switch (offset & 0x206)
483
483
                0x02 = coin L (active high)
484
484
                0x01 = coin R (active high)
485
485
            */
486
 
                        result = input_port_read(space->machine, "JSAIII");
487
 
                        if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x90;
488
 
                        if (atarigen->cpu_to_sound_ready) result ^= 0x40;
489
 
                        if (atarigen->sound_to_cpu_ready) result ^= 0x20;
 
486
                        result = input_port_read(space->machine(), "JSAIII");
 
487
                        if (!(input_port_read(space->machine(), test_port) & test_mask)) result ^= 0x90;
 
488
                        if (atarigen->m_cpu_to_sound_ready) result ^= 0x40;
 
489
                        if (atarigen->m_sound_to_cpu_ready) result ^= 0x20;
490
490
                        break;
491
491
 
492
492
                case 0x006:             /* /IRQACK */
511
511
        {
512
512
                case 0x000:             /* /RDV */
513
513
                        overall_volume = data * 100 / 127;
514
 
                        update_all_volumes(space->machine);
 
514
                        update_all_volumes(space->machine());
515
515
                        break;
516
516
 
517
517
                case 0x002:             /* /RDP */
544
544
            */
545
545
 
546
546
                        /* reset the YM2151 if needed */
547
 
                        if ((data&1) == 0) devtag_reset(space->machine, "ymsnd");
 
547
                        if ((data&1) == 0) devtag_reset(space->machine(), "ymsnd");
548
548
 
549
549
                        /* update the OKI bank */
550
550
                        if (oki6295 != NULL)
551
 
                                memory_set_bank(space->machine, "bank12", (memory_get_bank(space->machine, "bank12") & 2) | ((data >> 1) & 1));
 
551
                                memory_set_bank(space->machine(), "bank12", (memory_get_bank(space->machine(), "bank12") & 2) | ((data >> 1) & 1));
552
552
 
553
553
                        /* update the bank */
554
554
                        memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
555
555
 
556
556
                        /* coin counters */
557
 
                        coin_counter_w(space->machine, 1, (data >> 5) & 1);
558
 
                        coin_counter_w(space->machine, 0, (data >> 4) & 1);
 
557
                        coin_counter_w(space->machine(), 1, (data >> 5) & 1);
 
558
                        coin_counter_w(space->machine(), 0, (data >> 4) & 1);
559
559
 
560
560
                        /* update the OKI frequency */
561
561
                        if (oki6295 != NULL) oki6295->set_pin7(data & 8);
572
572
 
573
573
                        /* update the OKI bank */
574
574
                        if (oki6295 != NULL)
575
 
                                memory_set_bank(space->machine, "bank12", (memory_get_bank(space->machine, "bank12") & 1) | ((data >> 3) & 2));
 
575
                                memory_set_bank(space->machine(), "bank12", (memory_get_bank(space->machine(), "bank12") & 1) | ((data >> 3) & 2));
576
576
 
577
577
                        /* update the volumes */
578
578
                        ym2151_volume = ((data >> 1) & 7) * 100 / 7;
579
579
                        oki6295_volume = 50 + (data & 1) * 50;
580
 
                        update_all_volumes(space->machine);
 
580
                        update_all_volumes(space->machine());
581
581
                        break;
582
582
        }
583
583
}
592
592
 
593
593
static READ8_HANDLER( jsa3s_io_r )
594
594
{
595
 
        atarigen_state *atarigen = space->machine->driver_data<atarigen_state>();
 
595
        atarigen_state *atarigen = space->machine().driver_data<atarigen_state>();
596
596
        int result = 0xff;
597
597
 
598
598
        switch (offset & 0x206)
617
617
                0x02 = coin L (active high)
618
618
                0x01 = coin R (active high)
619
619
            */
620
 
                        result = input_port_read(space->machine, "JSAIII");
621
 
                        if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x90;
622
 
                        if (atarigen->cpu_to_sound_ready) result ^= 0x40;
623
 
                        if (atarigen->sound_to_cpu_ready) result ^= 0x20;
 
620
                        result = input_port_read(space->machine(), "JSAIII");
 
621
                        if (!(input_port_read(space->machine(), test_port) & test_mask)) result ^= 0x90;
 
622
                        if (atarigen->m_cpu_to_sound_ready) result ^= 0x40;
 
623
                        if (atarigen->m_sound_to_cpu_ready) result ^= 0x20;
624
624
                        break;
625
625
 
626
626
                case 0x006:             /* /IRQACK */
645
645
        {
646
646
                case 0x000:             /* /RDV */
647
647
                        overall_volume = data * 100 / 127;
648
 
                        update_all_volumes(space->machine);
 
648
                        update_all_volumes(space->machine());
649
649
                        break;
650
650
 
651
651
                case 0x002:             /* /RDP */
678
678
            */
679
679
 
680
680
                        /* reset the YM2151 if needed */
681
 
                        if ((data&1) == 0) devtag_reset(space->machine, "ymsnd");
 
681
                        if ((data&1) == 0) devtag_reset(space->machine(), "ymsnd");
682
682
 
683
683
                        /* update the OKI bank */
684
 
                        memory_set_bank(space->machine, "bank12", (memory_get_bank(space->machine, "bank12") & 2) | ((data >> 1) & 1));
 
684
                        memory_set_bank(space->machine(), "bank12", (memory_get_bank(space->machine(), "bank12") & 2) | ((data >> 1) & 1));
685
685
 
686
686
                        /* update the bank */
687
687
                        memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
688
688
 
689
689
                        /* coin counters */
690
 
                        coin_counter_w(space->machine, 1, (data >> 5) & 1);
691
 
                        coin_counter_w(space->machine, 0, (data >> 4) & 1);
 
690
                        coin_counter_w(space->machine(), 1, (data >> 5) & 1);
 
691
                        coin_counter_w(space->machine(), 0, (data >> 4) & 1);
692
692
 
693
693
                        /* update the OKI frequency */
694
694
                        oki6295_l->set_pin7(data & 8);
705
705
            */
706
706
 
707
707
                        /* update the OKI bank */
708
 
                        memory_set_bank(space->machine, "bank12", (memory_get_bank(space->machine, "bank12") & 1) | ((data >> 3) & 2));
709
 
                        memory_set_bank(space->machine, "bank14", data >> 6);
 
708
                        memory_set_bank(space->machine(), "bank12", (memory_get_bank(space->machine(), "bank12") & 1) | ((data >> 3) & 2));
 
709
                        memory_set_bank(space->machine(), "bank14", data >> 6);
710
710
 
711
711
                        /* update the volumes */
712
712
                        ym2151_volume = ((data >> 1) & 7) * 100 / 7;
713
713
                        oki6295_volume = 50 + (data & 1) * 50;
714
 
                        update_all_volumes(space->machine);
 
714
                        update_all_volumes(space->machine());
715
715
                        break;
716
716
        }
717
717
}
720
720
{
721
721
        ym2151_ct1 = data&0x1;
722
722
        ym2151_ct2 = (data&0x2)>>1;
723
 
        update_all_volumes(device->machine);
 
723
        update_all_volumes(device->machine());
724
724
}
725
725
 
726
726
 
730
730
 *
731
731
 *************************************/
732
732
 
733
 
static void update_all_volumes(running_machine *machine )
 
733
static void update_all_volumes(running_machine &machine )
734
734
{
735
735
        if (pokey != NULL) atarigen_set_pokey_vol(machine, (overall_volume * pokey_volume / 100) * ym2151_ct1);
736
736
        //if (pokey != NULL) atarigen_set_pokey_stereo_vol(machine, (overall_volume * pokey_volume / 100) * ym2151_ct1, (overall_volume * pokey_volume / 100) * ym2151_ct2);
748
748
 *
749
749
 *************************************/
750
750
 
751
 
static ADDRESS_MAP_START( atarijsa1_map, ADDRESS_SPACE_PROGRAM, 8 )
 
751
static ADDRESS_MAP_START( atarijsa1_map, AS_PROGRAM, 8 )
752
752
        AM_RANGE(0x0000, 0x1fff) AM_RAM
753
753
        AM_RANGE(0x2000, 0x2001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
754
754
        AM_RANGE(0x2800, 0x2bff) AM_READWRITE(jsa1_io_r, jsa1_io_w)
756
756
ADDRESS_MAP_END
757
757
 
758
758
 
759
 
static ADDRESS_MAP_START( atarijsa2_map, ADDRESS_SPACE_PROGRAM, 8 )
 
759
static ADDRESS_MAP_START( atarijsa2_map, AS_PROGRAM, 8 )
760
760
        AM_RANGE(0x0000, 0x1fff) AM_RAM
761
761
        AM_RANGE(0x2000, 0x2001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
762
762
        AM_RANGE(0x2800, 0x2bff) AM_READWRITE(jsa2_io_r, jsa2_io_w)
765
765
 
766
766
 
767
767
/* full map verified from schematics and Batman GALs */
768
 
static ADDRESS_MAP_START( atarijsa3_map, ADDRESS_SPACE_PROGRAM, 8 )
 
768
static ADDRESS_MAP_START( atarijsa3_map, AS_PROGRAM, 8 )
769
769
        AM_RANGE(0x0000, 0x1fff) AM_RAM
770
770
        AM_RANGE(0x2000, 0x2001) AM_MIRROR(0x07fe) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
771
771
        AM_RANGE(0x2800, 0x2fff) AM_READWRITE(jsa3_io_r, jsa3_io_w)
773
773
ADDRESS_MAP_END
774
774
 
775
775
 
776
 
static ADDRESS_MAP_START( atarijsa3s_map, ADDRESS_SPACE_PROGRAM, 8 )
 
776
static ADDRESS_MAP_START( atarijsa3s_map, AS_PROGRAM, 8 )
777
777
        AM_RANGE(0x0000, 0x1fff) AM_RAM
778
778
        AM_RANGE(0x2000, 0x2001) AM_MIRROR(0x07fe) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
779
779
        AM_RANGE(0x2800, 0x2fff) AM_READWRITE(jsa3s_io_r, jsa3s_io_w)
895
895
        MCFG_CPU_PROGRAM_MAP(atarijsa3_map)
896
896
 
897
897
        MCFG_DEVICE_MODIFY("adpcm")
898
 
        MCFG_DEVICE_ADDRESS_MAP(0, jsa3_oki_map)
 
898
        MCFG_DEVICE_ADDRESS_MAP(AS_0, jsa3_oki_map)
899
899
MACHINE_CONFIG_END
900
900
 
901
901
 
927
927
 
928
928
        MCFG_OKIM6295_ADD("adpcml", JSA_MASTER_CLOCK/3, OKIM6295_PIN7_HIGH)
929
929
        MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75)
930
 
        MCFG_DEVICE_ADDRESS_MAP(0, jsa3_oki_map)
 
930
        MCFG_DEVICE_ADDRESS_MAP(AS_0, jsa3_oki_map)
931
931
 
932
932
        MCFG_OKIM6295_ADD("adpcmr", JSA_MASTER_CLOCK/3, OKIM6295_PIN7_HIGH)
933
933
        MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75)
934
 
        MCFG_DEVICE_ADDRESS_MAP(0, jsa3_oki2_map)
 
934
        MCFG_DEVICE_ADDRESS_MAP(AS_0, jsa3_oki2_map)
935
935
MACHINE_CONFIG_END
936
936
 
937
937