33
33
#include "driver.h"
34
34
#include "cpu/m6502/m6502.h"
35
#include "sound/5220intf.h"
35
#include "sound/tms5220.h"
36
36
#include "sound/2151intf.h"
37
37
#include "sound/okim6295.h"
38
38
#include "sound/pokey.h"
59
59
static const device_config *oki6295;
60
60
static const device_config *oki6295_l, *oki6295_r;
62
static UINT32 oki6295_bank_base;
64
62
static UINT8 overall_volume;
65
63
static UINT8 pokey_volume;
66
64
static UINT8 ym2151_volume;
80
78
/*************************************
80
* OKI banked address map
82
*************************************/
84
static ADDRESS_MAP_START( jsa3_oki_map, 0, 8 )
85
AM_RANGE(0x00000, 0x1ffff) AM_ROMBANK(12)
86
AM_RANGE(0x20000, 0x3ffff) AM_ROMBANK(13)
89
static ADDRESS_MAP_START( jsa3_oki2_map, 0, 8 )
90
AM_RANGE(0x00000, 0x1ffff) AM_ROMBANK(14)
91
AM_RANGE(0x20000, 0x3ffff) AM_ROMBANK(15)
96
/*************************************
84
100
*************************************/
88
104
state_save_register_global(machine, speech_data);
89
105
state_save_register_global(machine, last_ctl);
91
state_save_register_global(machine, oki6295_bank_base);
93
107
state_save_register_global(machine, overall_volume);
94
108
state_save_register_global(machine, pokey_volume);
95
109
state_save_register_global(machine, ym2151_volume);
138
152
/* initialize JSA III ADPCM */
140
static const char *const regions[] = { "adpcm", "adcpml", "adpcmr" };
154
static const char *const regions[] = { "adpcm", "adpcml", "adpcmr" };
143
157
/* expand the ADPCM data to avoid lots of memcpy's during gameplay */
145
159
for (rgn = 0; rgn < ARRAY_LENGTH(regions); rgn++)
147
161
UINT8 *base = memory_region(machine, regions[rgn]);
148
if (base != NULL && memory_region_length(machine, regions[rgn]) >= 0x100000)
162
if (base != NULL && memory_region_length(machine, regions[rgn]) >= 0x80000)
150
memcpy(&base[0x00000], &base[0x80000], 0x20000);
151
memcpy(&base[0x40000], &base[0x80000], 0x20000);
152
memcpy(&base[0x80000], &base[0xa0000], 0x20000);
154
memcpy(&base[0x20000], &base[0xe0000], 0x20000);
155
memcpy(&base[0x60000], &base[0xe0000], 0x20000);
156
memcpy(&base[0xa0000], &base[0xe0000], 0x20000);
164
int banknum = (rgn != 2) ? 12 : 14;
165
memory_configure_bank(machine, banknum, 0, 2, base + 0x00000, 0x00000);
166
memory_configure_bank(machine, banknum, 2, 2, base + 0x20000, 0x20000);
167
memory_set_bankptr(machine, banknum + 1, base + 0x60000);
216
226
if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80;
217
227
if (atarigen_cpu_to_sound_ready) result ^= 0x40;
218
228
if (atarigen_sound_to_cpu_ready) result ^= 0x20;
219
if (tms5220 == NULL || tms5220_ready_r(tms5220)) result ^= 0x10;
229
if (tms5220 == NULL || !tms5220_readyq_r(tms5220)) result ^= 0x10;
222
232
case 0x006: /* /IRQACK */
522
532
/* update the OKI bank */
523
oki6295_bank_base = (0x40000 * ((data >> 1) & 1)) | (oki6295_bank_base & 0x80000);
524
if (oki6295 != NULL) okim6295_set_bank_base(oki6295, oki6295_bank_base);
534
memory_set_bank(space->machine, 12, (memory_get_bank(space->machine, 12) & 2) | ((data >> 1) & 1));
526
536
/* update the bank */
527
537
memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
547
557
/* update the OKI bank */
548
oki6295_bank_base = (0x80000 * ((data >> 4) & 1)) | (oki6295_bank_base & 0x40000);
549
if (oki6295 != NULL) okim6295_set_bank_base(oki6295, oki6295_bank_base);
559
memory_set_bank(space->machine, 12, (memory_get_bank(space->machine, 12) & 1) | ((data >> 3) & 2));
551
561
/* update the volumes */
552
562
ym2151_volume = ((data >> 1) & 7) * 100 / 7;
653
663
/* update the OKI bank */
654
oki6295_bank_base = (0x40000 * ((data >> 1) & 1)) | (oki6295_bank_base & 0x80000);
655
okim6295_set_bank_base(devtag_get_device(space->machine, "adpcml"), oki6295_bank_base);
664
memory_set_bank(space->machine, 12, (memory_get_bank(space->machine, 12) & 2) | ((data >> 1) & 1));
657
666
/* update the bank */
658
667
memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000);
679
688
/* update the OKI bank */
680
oki6295_bank_base = (0x80000 * ((data >> 4) & 1)) | (oki6295_bank_base & 0x40000);
681
okim6295_set_bank_base(devtag_get_device(space->machine, "adpcml"), oki6295_bank_base);
682
okim6295_set_bank_base(devtag_get_device(space->machine, "adpcmr"), 0x40000 * (data >> 6));
689
memory_set_bank(space->machine, 12, (memory_get_bank(space->machine, 12) & 1) | ((data >> 3) & 2));
690
memory_set_bank(space->machine, 14, data >> 6);
684
692
/* update the volumes */
685
693
ym2151_volume = ((data >> 1) & 7) * 100 / 7;
854
862
MACHINE_DRIVER_END
857
/* Used by Batman, Guardians of the 'Hood, Road Riot 4WD */
865
/* Used by Batman, Guardians of the 'Hood, Road Riot 4WD, Steel Talons */
858
866
MACHINE_DRIVER_START( jsa_iii_mono )
860
868
/* basic machine hardware */
861
869
MDRV_IMPORT_FROM(jsa_ii_mono)
862
870
MDRV_CPU_MODIFY("jsa")
863
871
MDRV_CPU_PROGRAM_MAP(atarijsa3_map)
873
MDRV_DEVICE_MODIFY("adpcm")
874
MDRV_DEVICE_ADDRESS_MAP(0, jsa3_oki_map)
864
875
MACHINE_DRIVER_END
875
886
MACHINE_DRIVER_END
878
/* Used by Space Lords, Moto Frenzy, Steel Talons, Road Riot's Revenge Rally */
889
/* Used by Space Lords, Moto Frenzy, Road Riot's Revenge Rally */
879
890
MACHINE_DRIVER_START( jsa_iiis_stereo )
881
892
/* basic machine hardware */
894
905
MDRV_SOUND_ADD("adpcml", OKIM6295, JSA_MASTER_CLOCK/3)
895
906
MDRV_SOUND_CONFIG(okim6295_interface_pin7high)
896
907
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75)
908
MDRV_DEVICE_ADDRESS_MAP(0, jsa3_oki_map)
898
910
MDRV_SOUND_ADD("adpcmr", OKIM6295, JSA_MASTER_CLOCK/3)
899
911
MDRV_SOUND_CONFIG(okim6295_interface_pin7high)
900
912
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75)
913
MDRV_DEVICE_ADDRESS_MAP(0, jsa3_oki2_map)
901
914
MACHINE_DRIVER_END