diff options
| author | 2009-12-09 15:34:23 +0000 | |
|---|---|---|
| committer | 2009-12-09 15:34:23 +0000 | |
| commit | e349350227210df49e168d29d1b7e32044ec6af1 (patch) | |
| tree | 16d289364a22e53cd241c988dcc1cf71c55aabfe | |
| parent | 3781da05a5e495c6551f827cb5aa362bedf37b18 (diff) | |
Converted atari drivers over to using driver_data for the most
part. Some shared systems still exist with globals, but this
tackles the atarigen module and the variables local to each
driver.
Also added validity check that AM_BASE_MEMBER and AM_SIZE_MEMBER
items point within the bounds of the driver_data structure.
84 files changed, 3246 insertions, 2937 deletions
diff --git a/src/emu/validity.c b/src/emu/validity.c index 2b4ee64e74e..e789b199113 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -1384,6 +1384,18 @@ static int validate_devices(int drivnum, const machine_config *config, const inp error |= validate_tag(driver, "bank", entry->write.tag); if (entry->share != NULL) error |= validate_tag(driver, "share", entry->share); + + /* if there are base or size members, check that they are within bounds */ + if (entry->baseptroffs_plus1 != 0 && (entry->baseptroffs_plus1 - 1) >= config->driver_data_size) + { + mame_printf_error("%s: %s device '%s' %s space memory map has an out of bounds AM_BASE_MEMBER entry\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum]); + error = TRUE; + } + if (entry->sizeptroffs_plus1 != 0 && (entry->sizeptroffs_plus1 - 1) >= config->driver_data_size) + { + mame_printf_error("%s: %s device '%s' %s space memory map has an out of bounds AM_SIZE_MEMBER entry\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum]); + error = TRUE; + } } /* release the address map */ diff --git a/src/mame/audio/atarijsa.c b/src/mame/audio/atarijsa.c index 458a85077ae..261721888bb 100644 --- a/src/mame/audio/atarijsa.c +++ b/src/mame/audio/atarijsa.c @@ -200,6 +200,7 @@ void atarijsa_reset(void) static READ8_HANDLER( jsa1_io_r ) { + atarigen_state *atarigen = (atarigen_state *)space->machine->driver_data; int result = 0xff; switch (offset & 0x206) @@ -225,8 +226,8 @@ static READ8_HANDLER( jsa1_io_r ) */ result = input_port_read(space->machine, "JSAI"); if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80; - if (atarigen_cpu_to_sound_ready) result ^= 0x40; - if (atarigen_sound_to_cpu_ready) result ^= 0x20; + if (atarigen->cpu_to_sound_ready) result ^= 0x40; + if (atarigen->sound_to_cpu_ready) result ^= 0x20; if (tms5220 == NULL || !tms5220_readyq_r(tms5220)) result ^= 0x10; break; @@ -324,6 +325,7 @@ static WRITE8_HANDLER( jsa1_io_w ) static READ8_HANDLER( jsa2_io_r ) { + atarigen_state *atarigen = (atarigen_state *)space->machine->driver_data; int result = 0xff; switch (offset & 0x206) @@ -352,8 +354,8 @@ static READ8_HANDLER( jsa2_io_r ) */ result = input_port_read(space->machine, "JSAII"); if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x80; - if (atarigen_cpu_to_sound_ready) result ^= 0x40; - if (atarigen_sound_to_cpu_ready) result ^= 0x20; + if (atarigen->cpu_to_sound_ready) result ^= 0x40; + if (atarigen->sound_to_cpu_ready) result ^= 0x20; break; case 0x006: /* /IRQACK */ @@ -446,6 +448,7 @@ static WRITE8_HANDLER( jsa2_io_w ) static READ8_HANDLER( jsa3_io_r ) { + atarigen_state *atarigen = (atarigen_state *)space->machine->driver_data; int result = 0xff; switch (offset & 0x206) @@ -472,8 +475,8 @@ static READ8_HANDLER( jsa3_io_r ) */ result = input_port_read(space->machine, "JSAIII"); if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x90; - if (atarigen_cpu_to_sound_ready) result ^= 0x40; - if (atarigen_sound_to_cpu_ready) result ^= 0x20; + if (atarigen->cpu_to_sound_ready) result ^= 0x40; + if (atarigen->sound_to_cpu_ready) result ^= 0x20; break; case 0x006: /* /IRQACK */ @@ -577,6 +580,7 @@ static WRITE8_HANDLER( jsa3_io_w ) static READ8_HANDLER( jsa3s_io_r ) { + atarigen_state *atarigen = (atarigen_state *)space->machine->driver_data; int result = 0xff; switch (offset & 0x206) @@ -603,8 +607,8 @@ static READ8_HANDLER( jsa3s_io_r ) */ result = input_port_read(space->machine, "JSAIII"); if (!(input_port_read(space->machine, test_port) & test_mask)) result ^= 0x90; - if (atarigen_cpu_to_sound_ready) result ^= 0x40; - if (atarigen_sound_to_cpu_ready) result ^= 0x20; + if (atarigen->cpu_to_sound_ready) result ^= 0x40; + if (atarigen->sound_to_cpu_ready) result ^= 0x20; break; case 0x006: /* /IRQACK */ diff --git a/src/mame/audio/cyberbal.c b/src/mame/audio/cyberbal.c index 600e3ba7d6d..e786538d6d0 100644 --- a/src/mame/audio/cyberbal.c +++ b/src/mame/audio/cyberbal.c @@ -11,24 +11,20 @@ #include "includes/cyberbal.h" -static UINT8 *bank_base; -static UINT8 fast_68k_int, io_68k_int; -static UINT8 sound_data_from_68k, sound_data_from_6502; -static UINT8 sound_data_from_68k_ready, sound_data_from_6502_ready; - - static void update_sound_68k_interrupts(running_machine *machine); void cyberbal_sound_reset(running_machine *machine) { + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + /* reset the sound system */ - bank_base = &memory_region(machine, "audiocpu")[0x10000]; - memory_set_bankptr(machine, "bank8", &bank_base[0x0000]); - fast_68k_int = io_68k_int = 0; - sound_data_from_68k = sound_data_from_6502 = 0; - sound_data_from_68k_ready = sound_data_from_6502_ready = 0; + state->bank_base = &memory_region(machine, "audiocpu")[0x10000]; + memory_set_bankptr(machine, "soundbank", &state->bank_base[0x0000]); + state->fast_68k_int = state->io_68k_int = 0; + state->sound_data_from_68k = state->sound_data_from_6502 = 0; + state->sound_data_from_68k_ready = state->sound_data_from_6502_ready = 0; } @@ -41,26 +37,29 @@ void cyberbal_sound_reset(running_machine *machine) READ8_HANDLER( cyberbal_special_port3_r ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "JSAII"); if (!(input_port_read(space->machine, "IN0") & 0x8000)) temp ^= 0x80; - if (atarigen_cpu_to_sound_ready) temp ^= 0x40; - if (atarigen_sound_to_cpu_ready) temp ^= 0x20; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x40; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x20; return temp; } READ8_HANDLER( cyberbal_sound_6502_stat_r ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; int temp = 0xff; - if (sound_data_from_6502_ready) temp ^= 0x80; - if (sound_data_from_68k_ready) temp ^= 0x40; + if (state->sound_data_from_6502_ready) temp ^= 0x80; + if (state->sound_data_from_68k_ready) temp ^= 0x40; return temp; } WRITE8_HANDLER( cyberbal_sound_bank_select_w ) { - memory_set_bankptr(space->machine, "bank8", &bank_base[0x1000 * ((data >> 6) & 3)]); + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + memory_set_bankptr(space->machine, "soundbank", &state->bank_base[0x1000 * ((data >> 6) & 3)]); coin_counter_w(space->machine, 1, (data >> 5) & 1); coin_counter_w(space->machine, 0, (data >> 4) & 1); cputag_set_input_line(space->machine, "dac", INPUT_LINE_RESET, (data & 0x08) ? CLEAR_LINE : ASSERT_LINE); @@ -70,19 +69,22 @@ WRITE8_HANDLER( cyberbal_sound_bank_select_w ) READ8_HANDLER( cyberbal_sound_68k_6502_r ) { - sound_data_from_68k_ready = 0; - return sound_data_from_68k; + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + state->sound_data_from_68k_ready = 0; + return state->sound_data_from_68k; } WRITE8_HANDLER( cyberbal_sound_68k_6502_w ) { - sound_data_from_6502 = data; - sound_data_from_6502_ready = 1; + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + + state->sound_data_from_6502 = data; + state->sound_data_from_6502_ready = 1; - if (!io_68k_int) + if (!state->io_68k_int) { - io_68k_int = 1; + state->io_68k_int = 1; update_sound_68k_interrupts(space->machine); } } @@ -97,16 +99,18 @@ WRITE8_HANDLER( cyberbal_sound_68k_6502_w ) static void update_sound_68k_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "dac", 6, fast_68k_int ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "dac", 2, io_68k_int ? ASSERT_LINE : CLEAR_LINE); + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + cputag_set_input_line(machine, "dac", 6, state->fast_68k_int ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "dac", 2, state->io_68k_int ? ASSERT_LINE : CLEAR_LINE); } INTERRUPT_GEN( cyberbal_sound_68k_irq_gen ) { - if (!fast_68k_int) + cyberbal_state *state = (cyberbal_state *)device->machine->driver_data; + if (!state->fast_68k_int) { - fast_68k_int = 1; + state->fast_68k_int = 1; update_sound_68k_interrupts(device->machine); } } @@ -114,9 +118,10 @@ INTERRUPT_GEN( cyberbal_sound_68k_irq_gen ) WRITE16_HANDLER( cyberbal_io_68k_irq_ack_w ) { - if (io_68k_int) + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + if (state->io_68k_int) { - io_68k_int = 0; + state->io_68k_int = 0; update_sound_68k_interrupts(space->machine); } } @@ -124,34 +129,37 @@ WRITE16_HANDLER( cyberbal_io_68k_irq_ack_w ) READ16_HANDLER( cyberbal_sound_68k_r ) { - int temp = (sound_data_from_6502 << 8) | 0xff; + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + int temp = (state->sound_data_from_6502 << 8) | 0xff; - sound_data_from_6502_ready = 0; + state->sound_data_from_6502_ready = 0; - if (sound_data_from_6502_ready) temp ^= 0x08; - if (sound_data_from_68k_ready) temp ^= 0x04; + if (state->sound_data_from_6502_ready) temp ^= 0x08; + if (state->sound_data_from_68k_ready) temp ^= 0x04; return temp; } WRITE16_HANDLER( cyberbal_sound_68k_w ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; if (ACCESSING_BITS_8_15) { - sound_data_from_68k = (data >> 8) & 0xff; - sound_data_from_68k_ready = 1; + state->sound_data_from_68k = (data >> 8) & 0xff; + state->sound_data_from_68k_ready = 1; } } WRITE16_HANDLER( cyberbal_sound_68k_dac_w ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; const device_config *dac = devtag_get_device(space->machine, (offset & 8) ? "dac2" : "dac1"); dac_data_16_w(dac, (((data >> 3) & 0x800) | ((data >> 2) & 0x7ff)) << 4); - if (fast_68k_int) + if (state->fast_68k_int) { - fast_68k_int = 0; + state->fast_68k_int = 0; update_sound_68k_interrupts(space->machine); } } diff --git a/src/mame/audio/harddriv.c b/src/mame/audio/harddriv.c index b5cb894a5dc..9e6bc872755 100644 --- a/src/mame/audio/harddriv.c +++ b/src/mame/audio/harddriv.c @@ -15,34 +15,6 @@ #define CYCLES_PER_BIO (5000000 / BIO_FREQUENCY) -UINT16 *hdsnddsp_ram; - - -/************************************* - * - * Static globals - * - *************************************/ - -static UINT8 soundflag; -static UINT8 mainflag; -static UINT16 sounddata; -static UINT16 maindata; - -static UINT8 dacmute; -static UINT8 cramen; -static UINT8 irq68k; - -static offs_t sound_rom_offs; - -static UINT8 *rombase; -static UINT32 romsize; -static UINT16 *comram; - -static UINT64 last_bio_cycles; - - - /************************************* * * Driver init @@ -51,10 +23,9 @@ static UINT64 last_bio_cycles; void hdsnd_init(running_machine *machine) { - rombase = (UINT8 *)memory_region(machine, "serialroms"); - romsize = memory_region_length(machine, "serialroms"); - comram = auto_alloc_array(machine, UINT16, 0x400/2); - last_bio_cycles = 0; + harddriv_state *state = (harddriv_state *)machine->driver_data; + state->rombase = (UINT8 *)memory_region(machine, "serialroms"); + state->romsize = memory_region_length(machine, "serialroms"); } @@ -67,8 +38,9 @@ void hdsnd_init(running_machine *machine) static void update_68k_interrupts(running_machine *machine) { - cpu_set_input_line(hdcpu_sound, 1, mainflag ? ASSERT_LINE : CLEAR_LINE); - cpu_set_input_line(hdcpu_sound, 3, irq68k ? ASSERT_LINE : CLEAR_LINE); + harddriv_state *state = (harddriv_state *)machine->driver_data; + cpu_set_input_line(state->soundcpu, 1, state->mainflag ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->soundcpu, 3, state->irq68k ? ASSERT_LINE : CLEAR_LINE); } @@ -81,22 +53,25 @@ static void update_68k_interrupts(running_machine *machine) READ16_HANDLER( hd68k_snd_data_r ) { - soundflag = 0; - logerror("%06X:main read from sound=%04X\n", cpu_get_previouspc(space->cpu), sounddata); - return sounddata; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->soundflag = 0; + logerror("%06X:main read from sound=%04X\n", cpu_get_previouspc(space->cpu), state->sounddata); + return state->sounddata; } READ16_HANDLER( hd68k_snd_status_r ) { - return (mainflag << 15) | (soundflag << 14) | 0x1fff; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return (state->mainflag << 15) | (state->soundflag << 14) | 0x1fff; } static TIMER_CALLBACK( delayed_68k_w ) { - maindata = param; - mainflag = 1; + harddriv_state *state = (harddriv_state *)machine->driver_data; + state->maindata = param; + state->mainflag = 1; update_68k_interrupts(machine); } @@ -110,9 +85,10 @@ WRITE16_HANDLER( hd68k_snd_data_w ) WRITE16_HANDLER( hd68k_snd_reset_w ) { - cpu_set_input_line(hdcpu_sound, INPUT_LINE_RESET, ASSERT_LINE); - cpu_set_input_line(hdcpu_sound, INPUT_LINE_RESET, CLEAR_LINE); - mainflag = soundflag = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + cpu_set_input_line(state->soundcpu, INPUT_LINE_RESET, ASSERT_LINE); + cpu_set_input_line(state->soundcpu, INPUT_LINE_RESET, CLEAR_LINE); + state->mainflag = state->soundflag = 0; update_68k_interrupts(space->machine); logerror("%06X:Reset sound\n", cpu_get_previouspc(space->cpu)); } @@ -127,17 +103,19 @@ WRITE16_HANDLER( hd68k_snd_reset_w ) READ16_HANDLER( hdsnd68k_data_r ) { - mainflag = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->mainflag = 0; update_68k_interrupts(space->machine); - logerror("%06X:sound read from main=%04X\n", cpu_get_previouspc(space->cpu), maindata); - return maindata; + logerror("%06X:sound read from main=%04X\n", cpu_get_previouspc(space->cpu), state->maindata); + return state->maindata; } WRITE16_HANDLER( hdsnd68k_data_w ) { - COMBINE_DATA(&sounddata); - soundflag = 1; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->sounddata); + state->soundflag = 1; logerror("%06X:sound write to main=%04X\n", cpu_get_previouspc(space->cpu), data); } @@ -170,8 +148,9 @@ READ16_HANDLER( hdsnd68k_status_r ) // D14 = 'Sound Flag' // D13 = Test Switch // D12 = 5220 Ready Flag (0=Ready) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; logerror("%06X:hdsnd68k_status_r(%04X)\n", cpu_get_previouspc(space->cpu), offset); - return (mainflag << 15) | (soundflag << 14) | 0x2000 | 0;//((input_port_read(space->machine, "IN0") & 0x0020) << 8) | 0; + return (state->mainflag << 15) | (state->soundflag << 14) | 0x2000 | 0;//((input_port_read(space->machine, "IN0") & 0x0020) << 8) | 0; } @@ -184,6 +163,8 @@ READ16_HANDLER( hdsnd68k_status_r ) WRITE16_HANDLER( hdsnd68k_latches_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* bit 3 selects the value; data is ignored */ data = (offset >> 3) & 1; @@ -208,13 +189,13 @@ WRITE16_HANDLER( hdsnd68k_latches_w ) case 3: /* CRAMEN */ /* data == 0 means disable 68k access to COM320, 1 means enable */ - cramen = data; + state->cramen = data; break; case 4: /* RES320 */ logerror("%06X:RES320=%d\n", cpu_get_previouspc(space->cpu), data); - if (hdcpu_sounddsp != NULL) - cpu_set_input_line(hdcpu_sounddsp, INPUT_LINE_HALT, data ? CLEAR_LINE : ASSERT_LINE); + if (state->sounddsp != NULL) + cpu_set_input_line(state->sounddsp, INPUT_LINE_HALT, data ? CLEAR_LINE : ASSERT_LINE); break; case 7: /* LED */ @@ -231,7 +212,8 @@ WRITE16_HANDLER( hdsnd68k_speech_w ) WRITE16_HANDLER( hdsnd68k_irqclr_w ) { - irq68k = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->irq68k = 0; update_68k_interrupts(space->machine); } @@ -245,34 +227,40 @@ WRITE16_HANDLER( hdsnd68k_irqclr_w ) READ16_HANDLER( hdsnd68k_320ram_r ) { - return hdsnddsp_ram[offset & 0xfff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->sounddsp_ram[offset & 0xfff]; } WRITE16_HANDLER( hdsnd68k_320ram_w ) { - COMBINE_DATA(&hdsnddsp_ram[offset & 0xfff]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->sounddsp_ram[offset & 0xfff]); } READ16_HANDLER( hdsnd68k_320ports_r ) { - const address_space *iospace = cpu_get_address_space(hdcpu_sounddsp, ADDRESS_SPACE_IO); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + const address_space *iospace = cpu_get_address_space(state->sounddsp, ADDRESS_SPACE_IO); return memory_read_word(iospace, (offset & 7) << 1); } WRITE16_HANDLER( hdsnd68k_320ports_w ) { - const address_space *iospace = cpu_get_address_space(hdcpu_sounddsp, ADDRESS_SPACE_IO); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + const address_space *iospace = cpu_get_address_space(state->sounddsp, ADDRESS_SPACE_IO); memory_write_word(iospace, (offset & 7) << 1, data); } READ16_HANDLER( hdsnd68k_320com_r ) { - if (cramen) - return comram[offset & 0x1ff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + if (state->cramen) + return state->comram[offset & 0x1ff]; logerror("%06X:hdsnd68k_320com_r(%04X) -- not allowed\n", cpu_get_previouspc(space->cpu), offset); return 0xffff; @@ -281,8 +269,10 @@ READ16_HANDLER( hdsnd68k_320com_r ) WRITE16_HANDLER( hdsnd68k_320com_w ) { - if (cramen) - COMBINE_DATA(&comram[offset & 0x1ff]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + if (state->cramen) + COMBINE_DATA(&state->comram[offset & 0x1ff]); else logerror("%06X:hdsnd68k_320com_w(%04X)=%04X -- not allowed\n", cpu_get_previouspc(space->cpu), offset, data); } @@ -297,17 +287,18 @@ WRITE16_HANDLER( hdsnd68k_320com_w ) READ16_HANDLER( hdsnddsp_get_bio ) { - UINT64 cycles_since_last_bio = cpu_get_total_cycles(space->cpu) - last_bio_cycles; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT64 cycles_since_last_bio = cpu_get_total_cycles(space->cpu) - state->last_bio_cycles; INT32 cycles_until_bio = CYCLES_PER_BIO - cycles_since_last_bio; /* if we're not at the next BIO yet, advance us there */ if (cycles_until_bio > 0) { cpu_adjust_icount(space->cpu, -cycles_until_bio); - last_bio_cycles += CYCLES_PER_BIO; + state->last_bio_cycles += CYCLES_PER_BIO; } else - last_bio_cycles = cpu_get_total_cycles(space->cpu); + state->last_bio_cycles = cpu_get_total_cycles(space->cpu); return ASSERT_LINE; } @@ -321,8 +312,10 @@ READ16_HANDLER( hdsnddsp_get_bio ) WRITE16_DEVICE_HANDLER( hdsnddsp_dac_w ) { + harddriv_state *state = (harddriv_state *)device->machine->driver_data; + /* DAC L */ - if (!dacmute) + if (!state->dacmute) dac_signed_data_16_w(device, data ^ 0x8000); } @@ -337,7 +330,7 @@ WRITE16_HANDLER( hdsnddsp_comport_w ) WRITE16_HANDLER( hdsnddsp_mute_w ) { /* mute DAC audio, D0=1 */ -/* dacmute = data & 1; -- NOT STUFFED */ +/* state->dacmute = data & 1; -- NOT STUFFED */ logerror("%06X:mute DAC=%d\n", cpu_get_previouspc(space->cpu), data); } @@ -345,38 +338,42 @@ WRITE16_HANDLER( hdsnddsp_mute_w ) WRITE16_HANDLER( hdsnddsp_gen68kirq_w ) { /* generate 68k IRQ */ - irq68k = 1; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->irq68k = 1; update_68k_interrupts(space->machine); } WRITE16_HANDLER( hdsnddsp_soundaddr_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; if (offset == 0) { /* select sound ROM block */ - sound_rom_offs = (sound_rom_offs & 0xffff) | ((data & 15) << 16); + state->sound_rom_offs = (state->sound_rom_offs & 0xffff) | ((data & 15) << 16); } else { /* sound memory address */ - sound_rom_offs = (sound_rom_offs & ~0xffff) | (data & 0xffff); + state->sound_rom_offs = (state->sound_rom_offs & ~0xffff) | (data & 0xffff); } } READ16_HANDLER( hdsnddsp_rom_r ) { - if (sound_rom_offs < romsize) - return rombase[sound_rom_offs++] << 7; - sound_rom_offs++; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->sound_rom_offs < state->romsize) + return state->rombase[state->sound_rom_offs++] << 7; + state->sound_rom_offs++; return 0; } READ16_HANDLER( hdsnddsp_comram_r ) { - return comram[sound_rom_offs++ & 0x1ff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->comram[state->sound_rom_offs++ & 0x1ff]; } diff --git a/src/mame/drivers/arcadecl.c b/src/mame/drivers/arcadecl.c index 912e31e4cbc..d8d0b5a4a34 100644 --- a/src/mame/drivers/arcadecl.c +++ b/src/mame/drivers/arcadecl.c @@ -68,7 +68,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "arcadecl.h" #include "sound/okim6295.h" @@ -84,7 +83,8 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + rampart_state *state = (rampart_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -105,8 +105,10 @@ static void scanline_update(const device_config *screen, int scanline) static MACHINE_RESET( arcadecl ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + rampart_state *state = (rampart_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); } @@ -144,7 +146,7 @@ static WRITE16_HANDLER( latch_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&rampart_bitmap) + AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(rampart_state, bitmap) AM_RANGE(0x3c0000, 0x3c07ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x3e0000, 0x3e07ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x3e0800, 0x3effbf) AM_RAM @@ -159,7 +161,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x640026, 0x640027) AM_READ_PORT("TRACKY1") AM_RANGE(0x640040, 0x64004f) AM_WRITE(latch_w) AM_RANGE(0x640060, 0x64006f) AM_WRITE(atarigen_eeprom_enable_w) - AM_RANGE(0x641000, 0x641fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x641000, 0x641fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(rampart_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x642000, 0x642001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0xff00) AM_RANGE(0x646000, 0x646fff) AM_WRITE(atarigen_scanline_int_ack_w) AM_RANGE(0x647000, 0x647fff) AM_WRITE(watchdog_reset16_w) @@ -315,6 +317,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( arcadecl ) + MDRV_DRIVER_DATA(rampart_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK) @@ -387,15 +390,8 @@ ROM_END * *************************************/ -static DRIVER_INIT( arcadecl ) -{ - atarigen_eeprom_default = NULL; -} - - static DRIVER_INIT( sparkz ) { - atarigen_eeprom_default = NULL; memset(memory_region(machine, "gfx1"), 0, memory_region_length(machine, "gfx1")); } @@ -407,5 +403,5 @@ static DRIVER_INIT( sparkz ) * *************************************/ -GAME( 1992, arcadecl, 0, arcadecl, arcadecl, arcadecl, ROT0, "Atari Games", "Arcade Classics (prototype)", GAME_SUPPORTS_SAVE ) -GAME( 1992, sparkz, 0, arcadecl, sparkz, sparkz, ROT0, "Atari Games", "Sparkz (prototype)", GAME_SUPPORTS_SAVE ) +GAME( 1992, arcadecl, 0, arcadecl, arcadecl, 0, ROT0, "Atari Games", "Arcade Classics (prototype)", GAME_SUPPORTS_SAVE ) +GAME( 1992, sparkz, 0, arcadecl, sparkz, sparkz, ROT0, "Atari Games", "Sparkz (prototype)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/atarig1.c b/src/mame/drivers/atarig1.c index f502e7bbf4c..112e5aee622 100644 --- a/src/mame/drivers/atarig1.c +++ b/src/mame/drivers/atarig1.c @@ -20,7 +20,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "video/atarirle.h" #include "atarig1.h" @@ -29,44 +28,32 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT8 which_input; -static UINT16 *mo_command; - -static UINT16 *bslapstic_base; -static void *bslapstic_bank0; -static UINT8 bslapstic_bank; -static UINT8 bslapstic_primed; - - - -/************************************* - * * Initialization & interrupts * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + atarig1_state *state = (atarig1_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_START( atarig1 ) { - state_save_register_global(machine, which_input); + atarig1_state *state = (atarig1_state *)machine->driver_data; + state_save_register_global(machine, state->which_input); } static MACHINE_RESET( atarig1 ) { - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + atarig1_state *state = (atarig1_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, atarig1_scanline_update, 8); atarijsa_reset(); } @@ -88,8 +75,9 @@ static WRITE16_HANDLER( mo_control_w ) static WRITE16_HANDLER( mo_command_w ) { - COMBINE_DATA(mo_command); - atarirle_command_w(0, (data == 0 && atarig1_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); + atarig1_state *state = (atarig1_state *)space->machine->driver_data; + COMBINE_DATA(state->mo_command); + atarirle_command_w(0, (data == 0 && state->is_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); } @@ -102,8 +90,9 @@ static WRITE16_HANDLER( mo_command_w ) static READ16_HANDLER( special_port0_r ) { + atarig1_state *state = (atarig1_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "IN0"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x1000; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x1000; temp ^= 0x2000; /* A2DOK always high for now */ return temp; } @@ -111,21 +100,23 @@ static READ16_HANDLER( special_port0_r ) static WRITE16_HANDLER( a2d_select_w ) { - which_input = offset; + atarig1_state *state = (atarig1_state *)space->machine->driver_data; + state->which_input = offset; } static READ16_HANDLER( a2d_data_r ) { static const char *const adcnames[] = { "ADC0", "ADC1", "ADC2" }; + atarig1_state *state = (atarig1_state *)space->machine->driver_data; /* Pit Fighter has no A2D, just another input port */ - if (atarig1_pitfight) + if (state->is_pitfight) return input_port_read(space->machine, "ADC0"); /* otherwise, assume it's hydra */ - if (which_input < 3) - return input_port_read(space->machine, adcnames[which_input]) << 8; + if (state->which_input < 3) + return input_port_read(space->machine, adcnames[state->which_input]) << 8; return 0; } @@ -138,53 +129,55 @@ static READ16_HANDLER( a2d_data_r ) * *************************************/ -INLINE void update_bank(int bank) +INLINE void update_bank(atarig1_state *state, int bank) { /* if the bank has changed, copy the memory; Pit Fighter needs this */ - if (bank != bslapstic_bank) + if (bank != state->bslapstic_bank) { /* bank 0 comes from the copy we made earlier */ if (bank == 0) - memcpy(bslapstic_base, bslapstic_bank0, 0x2000); + memcpy(state->bslapstic_base, state->bslapstic_bank0, 0x2000); else - memcpy(bslapstic_base, &bslapstic_base[bank * 0x1000], 0x2000); + memcpy(state->bslapstic_base, &state->bslapstic_base[bank * 0x1000], 0x2000); /* remember the current bank */ - bslapstic_bank = bank; + state->bslapstic_bank = bank; } } static STATE_POSTLOAD( pitfighb_state_postload ) { - int bank = bslapstic_bank; - bslapstic_bank = -1; - update_bank(bank); + atarig1_state *state = (atarig1_state *)machine->driver_data; + int bank = state->bslapstic_bank; + state->bslapstic_bank = -1; + update_bank(state, bank); } static READ16_HANDLER( pitfighb_cheap_slapstic_r ) { - int result = bslapstic_base[offset & 0xfff]; + atarig1_state *state = (atarig1_state *)space->machine->driver_data; + int result = state->bslapstic_base[offset & 0xfff]; /* the cheap replacement slapstic just triggers on the simple banking */ /* addresses; a software patch ensure that this is good enough */ /* offset 0 primes the chip */ if (offset == 0) - bslapstic_primed = 1; + state->bslapstic_primed = TRUE; /* one of 4 bankswitchers produces the result */ - else if (bslapstic_primed) + else if (state->bslapstic_primed) { if (offset == 0x42) - update_bank(0), bslapstic_primed = 0; + update_bank(state, 0), state->bslapstic_primed = FALSE; else if (offset == 0x52) - update_bank(1), bslapstic_primed = 0; + update_bank(state, 1), state->bslapstic_primed = FALSE; else if (offset == 0x62) - update_bank(2), bslapstic_primed = 0; + update_bank(state, 2), state->bslapstic_primed = FALSE; else if (offset == 0x72) - update_bank(3), bslapstic_primed = 0; + update_bank(state, 3), state->bslapstic_primed = FALSE; } return result; } @@ -192,15 +185,17 @@ static READ16_HANDLER( pitfighb_cheap_slapstic_r ) static void pitfighb_cheap_slapstic_init(running_machine *machine) { + atarig1_state *state = (atarig1_state *)machine->driver_data; + /* install a read handler */ - bslapstic_base = memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x038000, 0x03ffff, 0, 0, pitfighb_cheap_slapstic_r); + state->bslapstic_base = memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x038000, 0x03ffff, 0, 0, pitfighb_cheap_slapstic_r); /* allocate memory for a copy of bank 0 */ - bslapstic_bank0 = auto_alloc_array(machine, UINT8, 0x2000); - memcpy(bslapstic_bank0, bslapstic_base, 0x2000); + state->bslapstic_bank0 = auto_alloc_array(machine, UINT8, 0x2000); + memcpy(state->bslapstic_bank0, state->bslapstic_base, 0x2000); /* not primed by default */ - bslapstic_primed = 0; + state->bslapstic_primed = FALSE; } @@ -225,13 +220,13 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfc0000, 0xfc0001) AM_READ(special_port0_r) AM_RANGE(0xfc8000, 0xfc8007) AM_READWRITE(a2d_data_r, a2d_select_w) AM_RANGE(0xfd0000, 0xfd0001) AM_READ(atarigen_sound_upper_r) - AM_RANGE(0xfd8000, 0xfdffff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfd8000, 0xfdffff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(atarig1_state, atarigen.eeprom, atarigen.eeprom_size) /* AM_RANGE(0xfe0000, 0xfe7fff) AM_READ(from_r)*/ AM_RANGE(0xfe8000, 0xfe89ff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xff0000, 0xff0fff) AM_WRITE(atarirle_0_spriteram_w) AM_BASE(&atarirle_0_spriteram) - AM_RANGE(0xff2000, 0xff2001) AM_WRITE(mo_command_w) AM_BASE(&mo_command) - AM_RANGE(0xff4000, 0xff5fff) AM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xff2000, 0xff2001) AM_WRITE(mo_command_w) AM_BASE_MEMBER(atarig1_state, mo_command) + AM_RANGE(0xff4000, 0xff5fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(atarig1_state, atarigen.playfield) + AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(atarig1_state, atarigen.alpha) AM_RANGE(0xff0000, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -412,6 +407,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( atarig1 ) + MDRV_DRIVER_DATA(atarig1_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz) @@ -1076,19 +1072,21 @@ ROM_END static void init_g1_common(running_machine *machine, offs_t slapstic_base, int slapstic, int is_pitfight) { - atarigen_eeprom_default = NULL; + atarig1_state *state = (atarig1_state *)machine->driver_data; + + state->atarigen.eeprom_default = NULL; if (slapstic == -1) { pitfighb_cheap_slapstic_init(machine); - state_save_register_global(machine, bslapstic_bank); - state_save_register_global(machine, bslapstic_primed); + state_save_register_global(machine, state->bslapstic_bank); + state_save_register_global(machine, state->bslapstic_primed); state_save_register_postload(machine, pitfighb_state_postload, NULL); } else if (slapstic != 0) atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), slapstic_base, 0, slapstic); atarijsa_init(machine, "IN0", 0x4000); - atarig1_pitfight = is_pitfight; + state->is_pitfight = is_pitfight; } static DRIVER_INIT( hydra ) { init_g1_common(machine, 0x078000, 116, 0); } diff --git a/src/mame/drivers/atarig42.c b/src/mame/drivers/atarig42.c index 5886295e219..6c07dc2ca68 100644 --- a/src/mame/drivers/atarig42.c +++ b/src/mame/drivers/atarig42.c @@ -20,7 +20,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "machine/asic65.h" #include "audio/atarijsa.h" #include "video/atarirle.h" @@ -29,38 +28,24 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT8 analog_data; -static UINT16 *mo_command; - -static int sloop_bank; -static int sloop_next_bank; -static int sloop_offset; -static int sloop_state; -static UINT16 *sloop_base; - - - -/************************************* - * * Initialization & interrupts * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 5, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + atarig42_state *state = (atarig42_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 5, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( atarig42 ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + atarig42_state *state = (atarig42_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, atarig42_scanline_update, 8); atarijsa_reset(); } @@ -75,9 +60,10 @@ static MACHINE_RESET( atarig42 ) static READ16_HANDLER( special_port2_r ) { + atarig42_state *state = (atarig42_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "IN2"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0020; - if (atarigen_sound_to_cpu_ready) temp ^= 0x0010; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0020; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x0010; temp ^= 0x0008; /* A2D.EOC always high for now */ return temp; } @@ -86,14 +72,16 @@ static READ16_HANDLER( special_port2_r ) static WRITE16_HANDLER( a2d_select_w ) { static const char *const portnames[] = { "A2D0", "A2D1" }; + atarig42_state *state = (atarig42_state *)space->machine->driver_data; - analog_data = input_port_read(space->machine, portnames[offset != 0]); + state->analog_data = input_port_read(space->machine, portnames[offset != 0]); } static READ16_HANDLER( a2d_data_r ) { - return analog_data << 8; + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + return state->analog_data << 8; } @@ -125,7 +113,8 @@ static WRITE16_HANDLER( io_latch_w ) static WRITE16_HANDLER( mo_command_w ) { - COMBINE_DATA(mo_command); + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + COMBINE_DATA(state->mo_command); atarirle_command_w(0, (data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); } @@ -139,16 +128,17 @@ static WRITE16_HANDLER( mo_command_w ) static DIRECT_UPDATE_HANDLER( sloop_direct_handler ) { + atarig42_state *state = (atarig42_state *)space->machine->driver_data; if (address < 0x80000) { - direct->raw = direct->decrypted = (UINT8 *)sloop_base; + direct->raw = direct->decrypted = (UINT8 *)state->sloop_base; return (offs_t)-1; } return address; } -static void roadriot_sloop_tweak(int offset) +static void roadriot_sloop_tweak(atarig42_state *state, int offset) { /* sequence 1: @@ -171,38 +161,38 @@ static void roadriot_sloop_tweak(int offset) { /* standard 68000 -> 68eee -> (bank) addressing */ case 0x68000/2: - sloop_state = 1; + state->sloop_state = 1; break; case 0x68eee/2: - if (sloop_state == 1) - sloop_state = 2; + if (state->sloop_state == 1) + state->sloop_state = 2; break; case 0x00124/2: - if (sloop_state == 2) + if (state->sloop_state == 2) { - sloop_next_bank = 0; - sloop_state = 3; + state->sloop_next_bank = 0; + state->sloop_state = 3; } break; case 0x00678/2: - if (sloop_state == 2) + if (state->sloop_state == 2) { - sloop_next_bank = 1; - sloop_state = 3; + state->sloop_next_bank = 1; + state->sloop_state = 3; } break; case 0x00abc/2: - if (sloop_state == 2) + if (state->sloop_state == 2) { - sloop_next_bank = 2; - sloop_state = 3; + state->sloop_next_bank = 2; + state->sloop_state = 3; } break; case 0x01024/2: - if (sloop_state == 2) + if (state->sloop_state == 2) { - sloop_next_bank = 3; - sloop_state = 3; + state->sloop_next_bank = 3; + state->sloop_state = 3; } break; @@ -215,36 +205,36 @@ static void roadriot_sloop_tweak(int offset) /* written if $ff8007 == 2 */ case 0x71166/2: /* written if $ff8007 == 3 */ - if (sloop_state == 3) - sloop_bank = sloop_next_bank; - sloop_state = 0; + if (state->sloop_state == 3) + state->sloop_bank = state->sloop_next_bank; + state->sloop_state = 0; break; /* bank offsets */ case 0x5edb4/2: - if (sloop_state == 0) + if (state->sloop_state == 0) { - sloop_state = 10; - sloop_offset = 0; + state->sloop_state = 10; + state->sloop_offset = 0; } - sloop_offset += 2; + state->sloop_offset += 2; break; case 0x5db0a/2: - if (sloop_state == 0) + if (state->sloop_state == 0) { - sloop_state = 10; - sloop_offset = 0; + state->sloop_state = 10; + state->sloop_offset = 0; } - sloop_offset += 1; + state->sloop_offset += 1; break; /* apply the offset */ case 0x5f042/2: - if (sloop_state == 10) + if (state->sloop_state == 10) { - sloop_bank = (sloop_bank + sloop_offset) & 3; - sloop_offset = 0; - sloop_state = 0; + state->sloop_bank = (state->sloop_bank + state->sloop_offset) & 3; + state->sloop_offset = 0; + state->sloop_state = 0; } break; @@ -262,17 +252,19 @@ static void roadriot_sloop_tweak(int offset) static READ16_HANDLER( roadriot_sloop_data_r ) { - roadriot_sloop_tweak(offset); + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + roadriot_sloop_tweak(state, offset); if (offset < 0x78000/2) - return sloop_base[offset]; + return state->sloop_base[offset]; else - return sloop_base[0x78000/2 + sloop_bank * 0x1000 + (offset & 0xfff)]; + return state->sloop_base[0x78000/2 + state->sloop_bank * 0x1000 + (offset & 0xfff)]; } static WRITE16_HANDLER( roadriot_sloop_data_w ) { - roadriot_sloop_tweak(offset); + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + roadriot_sloop_tweak(state, offset); } @@ -283,7 +275,7 @@ static WRITE16_HANDLER( roadriot_sloop_data_w ) * *************************************/ -static void guardians_sloop_tweak(int offset) +static void guardians_sloop_tweak(atarig42_state *state, int offset) { static UINT32 last_accesses[8]; @@ -300,36 +292,38 @@ static void guardians_sloop_tweak(int offset) if (last_accesses[0] == 0x7f7c0/2 && last_accesses[1] == 0x7f7ce/2 && last_accesses[2] == 0x7f7c2/2 && last_accesses[3] == 0x7f7cc/2 && last_accesses[4] == 0x7f7c4/2 && last_accesses[5] == 0x7f7ca/2 && last_accesses[6] == 0x7f7c6/2 && last_accesses[7] == 0x7f7c8/2) - sloop_bank = 0; + state->sloop_bank = 0; if (last_accesses[0] == 0x7f7d0/2 && last_accesses[1] == 0x7f7de/2 && last_accesses[2] == 0x7f7d2/2 && last_accesses[3] == 0x7f7dc/2 && last_accesses[4] == 0x7f7d4/2 && last_accesses[5] == 0x7f7da/2 && last_accesses[6] == 0x7f7d6/2 && last_accesses[7] == 0x7f7d8/2) - sloop_bank = 1; + state->sloop_bank = 1; if (last_accesses[0] == 0x7f7e0/2 && last_accesses[1] == 0x7f7ee/2 && last_accesses[2] == 0x7f7e2/2 && last_accesses[3] == 0x7f7ec/2 && last_accesses[4] == 0x7f7e4/2 && last_accesses[5] == 0x7f7ea/2 && last_accesses[6] == 0x7f7e6/2 && last_accesses[7] == 0x7f7e8/2) - sloop_bank = 2; + state->sloop_bank = 2; if (last_accesses[0] == 0x7f7f0/2 && last_accesses[1] == 0x7f7fe/2 && last_accesses[2] == 0x7f7f2/2 && last_accesses[3] == 0x7f7fc/2 && last_accesses[4] == 0x7f7f4/2 && last_accesses[5] == 0x7f7fa/2 && last_accesses[6] == 0x7f7f6/2 && last_accesses[7] == 0x7f7f8/2) - sloop_bank = 3; + state->sloop_bank = 3; } } static READ16_HANDLER( guardians_sloop_data_r ) { - guardians_sloop_tweak(offset); + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + guardians_sloop_tweak(state, offset); if (offset < 0x78000/2) - return sloop_base[offset]; + return state->sloop_base[offset]; else - return sloop_base[0x78000/2 + sloop_bank * 0x1000 + (offset & 0xfff)]; + return state->sloop_base[0x78000/2 + state->sloop_bank * 0x1000 + (offset & 0xfff)]; } static WRITE16_HANDLER( guardians_sloop_data_w ) { - guardians_sloop_tweak(offset); + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + guardians_sloop_tweak(state, offset); } @@ -357,12 +351,12 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xf40000, 0xf40001) AM_READ(asic65_io_r) AM_RANGE(0xf60000, 0xf60001) AM_READ(asic65_r) AM_RANGE(0xf80000, 0xf80003) AM_WRITE(asic65_data_w) - AM_RANGE(0xfa0000, 0xfa0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfa0000, 0xfa0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(atarig42_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xfc0000, 0xfc0fff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xff0000, 0xff0fff) AM_WRITE(atarirle_0_spriteram_w) AM_BASE(&atarirle_0_spriteram) - AM_RANGE(0xff2000, 0xff5fff) AM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) - AM_RANGE(0xff7000, 0xff7001) AM_WRITE(mo_command_w) AM_BASE(&mo_command) + AM_RANGE(0xff2000, 0xff5fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(atarig42_state, atarigen.playfield) + AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(atarig42_state, atarigen.alpha) + AM_RANGE(0xff7000, 0xff7001) AM_WRITE(mo_command_w) AM_BASE_MEMBER(atarig42_state, mo_command) AM_RANGE(0xff0000, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -507,6 +501,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( atarig42 ) + MDRV_DRIVER_DATA(atarig42_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz) @@ -680,14 +675,15 @@ static DRIVER_INIT( roadriot ) 0x01B0,0x0146,0x012E,0x1A00,0x01C8,0x01D0,0x0118,0x0D00, 0x0118,0x0100,0x01C8,0x01D0,0x0000 }; - atarigen_eeprom_default = default_eeprom; + atarig42_state *state = (atarig42_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "IN2", 0x0040); - atarig42_playfield_base = 0x400; - atarig42_motion_object_base = 0x200; - atarig42_motion_object_mask = 0x1ff; + state->playfield_base = 0x400; + state->motion_object_base = 0x200; + state->motion_object_mask = 0x1ff; - sloop_base = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, roadriot_sloop_data_r, roadriot_sloop_data_w); + state->sloop_base = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, roadriot_sloop_data_r, roadriot_sloop_data_w); memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), sloop_direct_handler); asic65_config(machine, ASIC65_ROMBASED); @@ -729,18 +725,19 @@ static DRIVER_INIT( guardian ) 0x01BE,0x016D,0x0142,0x0100,0x0120,0x0109,0x0110,0x0141, 0x0109,0x0100,0x0108,0x0134,0x0105,0x0148,0x1400,0x0000 }; - atarigen_eeprom_default = default_eeprom; + atarig42_state *state = (atarig42_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "IN2", 0x0040); - atarig42_playfield_base = 0x000; - atarig42_motion_object_base = 0x400; - atarig42_motion_object_mask = 0x3ff; + state->playfield_base = 0x000; + state->motion_object_base = 0x400; + state->motion_object_mask = 0x3ff; /* it looks like they jsr to $80000 as some kind of protection */ /* put an RTS there so we don't die */ *(UINT16 *)&memory_region(machine, "maincpu")[0x80000] = 0x4E75; - sloop_base = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, guardians_sloop_data_r, guardians_sloop_data_w); + state->sloop_base = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, guardians_sloop_data_r, guardians_sloop_data_w); memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), sloop_direct_handler); asic65_config(machine, ASIC65_GUARDIANS); diff --git a/src/mame/drivers/atarigt.c b/src/mame/drivers/atarigt.c index 51c667d201e..d413b719535 100644 --- a/src/mame/drivers/atarigt.c +++ b/src/mame/drivers/atarigt.c @@ -37,13 +37,6 @@ * *************************************/ -UINT8 atarigt_is_primrage; - -static UINT32 * mo_command; - -static void (*protection_w)(const address_space *space, offs_t offset, UINT16 data); -static void (*protection_r)(const address_space *space, offs_t offset, UINT16 *data); - static void cage_irq_callback(running_machine *machine, int reason); @@ -56,16 +49,19 @@ static void cage_irq_callback(running_machine *machine, int reason); static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 3, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + atarigt_state *state = (atarigt_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 3, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( atarigt ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigt_state *state = (atarigt_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, atarigt_scanline_update, 8); } @@ -106,9 +102,10 @@ static READ32_HANDLER( special_port2_r ) static READ32_HANDLER( special_port3_r ) { + atarigt_state *state = (atarigt_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "COIN"); - if (atarigen_video_int_state) temp ^= 0x0001; - if (atarigen_scanline_int_state) temp ^= 0x0002; + if (state->atarigen.video_int_state) temp ^= 0x0001; + if (state->atarigen.scanline_int_state) temp ^= 0x0002; return (temp << 16) | temp; } @@ -208,7 +205,8 @@ static WRITE32_HANDLER( latch_w ) static WRITE32_HANDLER( mo_command_w ) { - COMBINE_DATA(mo_command); + atarigt_state *state = (atarigt_state *)space->machine->driver_data; + COMBINE_DATA(state->mo_command); if (ACCESSING_BITS_0_15) atarirle_command_w(0, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); } @@ -551,20 +549,21 @@ if (LOG_PROTECTION) static READ32_HANDLER( colorram_protection_r ) { + atarigt_state *state = (atarigt_state *)space->machine->driver_data; offs_t address = 0xd80000 + offset * 4; UINT32 result32 = 0; UINT16 result; if (ACCESSING_BITS_16_31) { - result = atarigt_colorram_r(address); - (*protection_r)(space, address, &result); + result = atarigt_colorram_r(state, address); + (*state->protection_r)(space, address, &result); result32 |= result << 16; } if (ACCESSING_BITS_0_15) { - result = atarigt_colorram_r(address + 2); - (*protection_r)(space, address + 2, &result); + result = atarigt_colorram_r(state, address + 2); + (*state->protection_r)(space, address + 2, &result); result32 |= result; } @@ -574,19 +573,20 @@ static READ32_HANDLER( colorram_protection_r ) static WRITE32_HANDLER( colorram_protection_w ) { + atarigt_state *state = (atarigt_state *)space->machine->driver_data; offs_t address = 0xd80000 + offset * 4; if (ACCESSING_BITS_16_31) { if (!ignore_writes) - atarigt_colorram_w(address, data >> 16, mem_mask >> 16); - (*protection_w)(space, address, data >> 16); + atarigt_colorram_w(state, address, data >> 16, mem_mask >> 16); + (*state->protection_w)(space, address, data >> 16); } if (ACCESSING_BITS_0_15) { if (!ignore_writes) - atarigt_colorram_w(address + 2, data, mem_mask); - (*protection_w)(space, address + 2, data); + atarigt_colorram_w(state, address + 2, data, mem_mask); + (*state->protection_w)(space, address + 2, data); } } @@ -603,14 +603,14 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0xc00000, 0xc00003) AM_READWRITE(sound_data_r, sound_data_w) AM_RANGE(0xd00014, 0xd00017) AM_READ(analog_port0_r) AM_RANGE(0xd0001c, 0xd0001f) AM_READ(analog_port1_r) - AM_RANGE(0xd20000, 0xd20fff) AM_READWRITE(atarigen_eeprom_upper32_r, atarigen_eeprom32_w) AM_BASE((UINT32 **)&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xd20000, 0xd20fff) AM_READWRITE(atarigen_eeprom_upper32_r, atarigen_eeprom32_w) AM_BASE_SIZE_MEMBER(atarigt_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xd40000, 0xd4ffff) AM_WRITE(atarigen_eeprom_enable32_w) - AM_RANGE(0xd72000, 0xd75fff) AM_WRITE(atarigen_playfield32_w) AM_BASE(&atarigen_playfield32) - AM_RANGE(0xd76000, 0xd76fff) AM_WRITE(atarigen_alpha32_w) AM_BASE(&atarigen_alpha32) + AM_RANGE(0xd72000, 0xd75fff) AM_WRITE(atarigen_playfield32_w) AM_BASE_MEMBER(atarigt_state, atarigen.playfield32) + AM_RANGE(0xd76000, 0xd76fff) AM_WRITE(atarigen_alpha32_w) AM_BASE_MEMBER(atarigt_state, atarigen.alpha32) AM_RANGE(0xd78000, 0xd78fff) AM_WRITE(atarirle_0_spriteram32_w) AM_BASE(&atarirle_0_spriteram32) - AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_BASE(&mo_command) + AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_BASE_MEMBER(atarigt_state, mo_command) AM_RANGE(0xd70000, 0xd7ffff) AM_RAM - AM_RANGE(0xd80000, 0xdfffff) AM_READWRITE(colorram_protection_r, colorram_protection_w) AM_BASE((UINT32 **)&atarigt_colorram) + AM_RANGE(0xd80000, 0xdfffff) AM_READWRITE(colorram_protection_r, colorram_protection_w) AM_BASE_MEMBER(atarigt_state, colorram) AM_RANGE(0xe04000, 0xe04003) AM_WRITE(led_w) AM_RANGE(0xe08000, 0xe08003) AM_WRITE(latch_w) AM_RANGE(0xe0a000, 0xe0a003) AM_WRITE(atarigen_scanline_int_ack32_w) @@ -785,6 +785,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( atarigt ) + MDRV_DRIVER_DATA(atarigt_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, ATARI_CLOCK_50MHz/2) @@ -1239,15 +1240,17 @@ static WRITE32_HANDLER( tmek_pf_w ) static DRIVER_INIT( tmek ) { - atarigen_eeprom_default = NULL; - atarigt_is_primrage = 0; + atarigt_state *state = (atarigt_state *)machine->driver_data; + + state->atarigen.eeprom_default = NULL; + state->is_primrage = 0; cage_init(machine, 0x4fad); cage_set_irq_handler(cage_irq_callback); /* setup protection */ - protection_r = tmek_protection_r; - protection_w = tmek_protection_w; + state->protection_r = tmek_protection_r; + state->protection_w = tmek_protection_w; /* temp hack */ memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd72000, 0xd75fff, 0, 0, tmek_pf_w); @@ -1256,15 +1259,17 @@ static DRIVER_INIT( tmek ) static void primrage_init_common(running_machine *machine, offs_t cage_speedup) { - atarigen_eeprom_default = NULL; - atarigt_is_primrage = 1; + atarigt_state *state = (atarigt_state *)machine->driver_data; + + state->atarigen.eeprom_default = NULL; + state->is_primrage = 1; cage_init(machine, cage_speedup); cage_set_irq_handler(cage_irq_callback); /* install protection */ - protection_r = primrage_protection_r; - protection_w = primrage_protection_w; + state->protection_r = primrage_protection_r; + state->protection_w = primrage_protection_w; } static DRIVER_INIT( primrage ) { primrage_init_common(machine, 0x42f2); } diff --git a/src/mame/drivers/atarigx2.c b/src/mame/drivers/atarigx2.c index da66250d19f..e307664e4d1 100644 --- a/src/mame/drivers/atarigx2.c +++ b/src/mame/drivers/atarigx2.c @@ -21,7 +21,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "video/atarirle.h" #include "atarigx2.h" @@ -30,35 +29,24 @@ /************************************* * - * Statics - * - *************************************/ - -#if 0 -static UINT8 which_input; -#endif -static UINT32 * mo_command; -static UINT32 * protection_base; - - - -/************************************* - * * Initialization * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 5, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 5, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( atarigx2 ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, atarigx2_scanline_update, 8); atarijsa_reset(); } @@ -73,9 +61,10 @@ static MACHINE_RESET( atarigx2 ) static READ32_HANDLER( special_port2_r ) { + atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "SERVICE"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0020; - if (atarigen_sound_to_cpu_ready) temp ^= 0x0010; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0020; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x0010; temp ^= 0x0008; /* A2D.EOC always high for now */ return (temp << 16) | temp; } @@ -87,15 +76,7 @@ static READ32_HANDLER( special_port3_r ) return (temp << 16) | temp; } -#if 0 -static WRITE32_HANDLER( a2d_select_w ) -{ - if (ACCESSING_BITS_16_31) - which_input = offset * 2; - if (ACCESSING_BITS_0_15) - which_input = offset * 2 + 1; -} -#endif + static READ32_HANDLER( a2d_data_r ) { @@ -142,7 +123,8 @@ static WRITE32_HANDLER( latch_w ) static WRITE32_HANDLER( mo_command_w ) { - COMBINE_DATA(mo_command); + atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; + COMBINE_DATA(state->mo_command); if (ACCESSING_BITS_0_15) atarirle_command_w(0, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); } @@ -160,6 +142,7 @@ static UINT16 last_write_offset; static WRITE32_HANDLER( atarigx2_protection_w ) { + atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; { int pc = cpu_get_previouspc(space->cpu); // if (pc == 0x11cbe || pc == 0x11c30) @@ -171,16 +154,16 @@ static WRITE32_HANDLER( atarigx2_protection_w ) logerror("%06X:Protection W@%04X = %04X\n", pc, offset * 4 + 2, data); } - COMBINE_DATA(&protection_base[offset]); + COMBINE_DATA(&state->protection_base[offset]); if (ACCESSING_BITS_16_31) { - last_write = protection_base[offset] >> 16; + last_write = state->protection_base[offset] >> 16; last_write_offset = offset*2; } if (ACCESSING_BITS_0_15) { - last_write = protection_base[offset] & 0xffff; + last_write = state->protection_base[offset] & 0xffff; last_write_offset = offset*2+1; } } @@ -1116,7 +1099,8 @@ static READ32_HANDLER( atarigx2_protection_r ) { 0xffffffff, 0xffff } }; - UINT32 result = protection_base[offset]; + atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; + UINT32 result = state->protection_base[offset]; if (offset == 0x300) result |= 0x80000000; @@ -1163,14 +1147,14 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0xc80000, 0xc80fff) AM_RAM - AM_RANGE(0xca0000, 0xca0fff) AM_READWRITE(atarigx2_protection_r, atarigx2_protection_w) AM_BASE(&protection_base) + AM_RANGE(0xca0000, 0xca0fff) AM_READWRITE(atarigx2_protection_r, atarigx2_protection_w) AM_BASE_MEMBER(atarigx2_state, protection_base) AM_RANGE(0xd00000, 0xd1ffff) AM_READ(a2d_data_r) - AM_RANGE(0xd20000, 0xd20fff) AM_READWRITE(atarigen_eeprom_upper32_r, atarigen_eeprom32_w) AM_BASE((UINT32 **)&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xd20000, 0xd20fff) AM_READWRITE(atarigen_eeprom_upper32_r, atarigen_eeprom32_w) AM_BASE_SIZE_MEMBER(atarigx2_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xd40000, 0xd40fff) AM_RAM_WRITE(atarigen_666_paletteram32_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xd72000, 0xd75fff) AM_WRITE(atarigen_playfield32_w) AM_BASE(&atarigen_playfield32) - AM_RANGE(0xd76000, 0xd76fff) AM_WRITE(atarigen_alpha32_w) AM_BASE(&atarigen_alpha32) + AM_RANGE(0xd72000, 0xd75fff) AM_WRITE(atarigen_playfield32_w) AM_BASE_MEMBER(atarigx2_state, atarigen.playfield32) + AM_RANGE(0xd76000, 0xd76fff) AM_WRITE(atarigen_alpha32_w) AM_BASE_MEMBER(atarigx2_state, atarigen.alpha32) AM_RANGE(0xd78000, 0xd78fff) AM_WRITE(atarirle_0_spriteram32_w) AM_BASE(&atarirle_0_spriteram32) - AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_BASE(&mo_command) + AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_BASE_MEMBER(atarigx2_state, mo_command) AM_RANGE(0xd70000, 0xd7ffff) AM_RAM AM_RANGE(0xd80000, 0xd9ffff) AM_WRITE(atarigen_eeprom_enable32_w) AM_RANGE(0xe06000, 0xe06003) AM_WRITE(atarigen_sound_upper32_w) @@ -1401,6 +1385,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( atarigx2 ) + MDRV_DRIVER_DATA(atarigx2_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, ATARI_CLOCK_14MHz) @@ -2048,23 +2033,25 @@ ROM_END static DRIVER_INIT( spclords ) { - atarigen_eeprom_default = NULL; + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + atarijsa_init(machine, "SERVICE", 0x0040); - atarigx2_playfield_base = 0x000; - atarigx2_motion_object_base = 0x400; - atarigx2_motion_object_mask = 0x3ff; + state->playfield_base = 0x000; + state->motion_object_base = 0x400; + state->motion_object_mask = 0x3ff; } static DRIVER_INIT( motofren ) { - atarigen_eeprom_default = NULL; + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + atarijsa_init(machine, "SERVICE", 0x0040); - atarigx2_playfield_base = 0x400; - atarigx2_motion_object_base = 0x200; - atarigx2_motion_object_mask = 0x1ff; + state->playfield_base = 0x400; + state->motion_object_base = 0x200; + state->motion_object_mask = 0x1ff; /* L/W=!68.A23*!E.A22*!E.A21 = 000x xxxx = 000000-1fffff +68.A23*E.A22*E.A21*68.A20*68.A19*68.A18*68.A17 = 1111 111x = fe0000-ffffff @@ -2096,12 +2083,13 @@ static READ32_HANDLER( rrreveng_prot_r ) static DRIVER_INIT( rrreveng ) { - atarigen_eeprom_default = NULL; + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + atarijsa_init(machine, "SERVICE", 0x0040); - atarigx2_playfield_base = 0x000; - atarigx2_motion_object_base = 0x400; - atarigx2_motion_object_mask = 0x3ff; + state->playfield_base = 0x000; + state->motion_object_base = 0x400; + state->motion_object_mask = 0x3ff; memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xca0fc0, 0xca0fc3, 0, 0, rrreveng_prot_r); } diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c index e7fd8aa90da..bc786eeda4d 100644 --- a/src/mame/drivers/atarisy1.c +++ b/src/mame/drivers/atarisy1.c @@ -180,25 +180,6 @@ -/************************************* - * - * Statics - * - *************************************/ - -static UINT8 joystick_type; -static UINT8 trackball_type; - -static emu_timer *joystick_timer; -static UINT8 joystick_int; -static UINT8 joystick_int_enable; -static UINT8 joystick_value; - -static UINT8 tms5220_out_data; -static UINT8 tms5220_in_data; -static UINT8 tms5220_ctl; - - static TIMER_CALLBACK( delayed_joystick_int ); @@ -211,26 +192,29 @@ static TIMER_CALLBACK( delayed_joystick_int ); static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 2, joystick_int && joystick_int_enable ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 3, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 2, state->joystick_int && state->joystick_int_enable ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 3, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( atarisy1 ) { + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + /* initialize the system */ - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); /* reset the joystick parameters */ - joystick_value = 0; - joystick_timer = timer_alloc(machine, delayed_joystick_int, NULL); - joystick_int = 0; - joystick_int_enable = 0; + state->joystick_value = 0; + state->joystick_timer = timer_alloc(machine, delayed_joystick_int, NULL); + state->joystick_int = 0; + state->joystick_int_enable = 0; } @@ -243,45 +227,48 @@ static MACHINE_RESET( atarisy1 ) static TIMER_CALLBACK( delayed_joystick_int ) { - joystick_value = param; - joystick_int = 1; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + state->joystick_value = param; + state->joystick_int = 1; atarigen_update_interrupts(machine); } static READ16_HANDLER( joystick_r ) { + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; int newval = 0xff; static const char *const portnames[] = { "IN0", "IN1" }; /* digital joystick type */ - if (joystick_type == 1) + if (state->joystick_type == 1) newval = (input_port_read(space->machine, "IN0") & (0x80 >> offset)) ? 0xf0 : 0x00; /* Hall-effect analog joystick */ - else if (joystick_type == 2) + else if (state->joystick_type == 2) newval = input_port_read(space->machine, portnames[offset & 1]); /* Road Blasters gas pedal */ - else if (joystick_type == 3) + else if (state->joystick_type == 3) newval = input_port_read(space->machine, "IN1"); /* the A4 bit enables/disables joystick IRQs */ - joystick_int_enable = ((offset >> 3) & 1) ^ 1; + state->joystick_int_enable = ((offset >> 3) & 1) ^ 1; /* clear any existing interrupt and set a timer for a new one */ - joystick_int = 0; - timer_adjust_oneshot(joystick_timer, ATTOTIME_IN_USEC(50), newval); + state->joystick_int = 0; + timer_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval); atarigen_update_interrupts(space->machine); - return joystick_value; + return state->joystick_value; } static WRITE16_HANDLER( joystick_w ) { /* the A4 bit enables/disables joystick IRQs */ - joystick_int_enable = ((offset >> 3) & 1) ^ 1; + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; + state->joystick_int_enable = ((offset >> 3) & 1) ^ 1; } @@ -294,10 +281,11 @@ static WRITE16_HANDLER( joystick_w ) static READ16_HANDLER( trakball_r ) { + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; int result = 0xff; /* Marble Madness trackball type -- rotated 45 degrees! */ - if (trackball_type == 1) + if (state->trackball_type == 1) { static UINT8 cur[2][2]; int player = (offset >> 1) & 1; @@ -327,7 +315,7 @@ static READ16_HANDLER( trakball_r ) } /* Road Blasters steering wheel */ - else if (trackball_type == 2) + else if (state->trackball_type == 2) result = input_port_read(space->machine, "IN0"); return result; @@ -343,8 +331,9 @@ static READ16_HANDLER( trakball_r ) static READ16_HANDLER( port4_r ) { + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "F60000"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0080; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0080; return temp; } @@ -358,10 +347,11 @@ static READ16_HANDLER( port4_r ) static READ8_HANDLER( switch_6502_r ) { + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "1820"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x08; - if (atarigen_sound_to_cpu_ready) temp ^= 0x10; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x08; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x10; if (!(input_port_read(space->machine, "F60000") & 0x0040)) temp ^= 0x80; return temp; @@ -392,28 +382,31 @@ static READ8_HANDLER( switch_6502_r ) static WRITE8_DEVICE_HANDLER( via_pa_w ) { - tms5220_out_data = data; + atarisy1_state *state = (atarisy1_state *)device->machine->driver_data; + state->tms5220_out_data = data; } static READ8_DEVICE_HANDLER( via_pa_r ) { - return tms5220_in_data; + atarisy1_state *state = (atarisy1_state *)device->machine->driver_data; + return state->tms5220_in_data; } static WRITE8_DEVICE_HANDLER( via_pb_w ) { - UINT8 old = tms5220_ctl; - tms5220_ctl = data; + atarisy1_state *state = (atarisy1_state *)device->machine->driver_data; + UINT8 old = state->tms5220_ctl; + state->tms5220_ctl = data; /* write strobe */ - if (!(old & 1) && (tms5220_ctl & 1)) - tms5220_data_w(device, 0, tms5220_out_data); + if (!(old & 1) && (state->tms5220_ctl & 1)) + tms5220_data_w(device, 0, state->tms5220_out_data); /* read strobe */ - if (!(old & 2) && (tms5220_ctl & 2)) - tms5220_in_data = tms5220_status_r(device, 0); + if (!(old & 2) && (state->tms5220_ctl & 2)) + state->tms5220_in_data = tms5220_status_r(device, 0); /* bit 4 is connected to an up-counter, clocked by SYCLKB */ data = 5 | ((data >> 3) & 2); @@ -462,19 +455,19 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x080000, 0x087fff) AM_ROM /* slapstic maps here */ AM_RANGE(0x2e0000, 0x2e0001) AM_READ(atarisy1_int3state_r) AM_RANGE(0x400000, 0x401fff) AM_RAM - AM_RANGE(0x800000, 0x800001) AM_WRITE(atarisy1_xscroll_w) AM_BASE(&atarigen_xscroll) - AM_RANGE(0x820000, 0x820001) AM_WRITE(atarisy1_yscroll_w) AM_BASE(&atarigen_yscroll) + AM_RANGE(0x800000, 0x800001) AM_WRITE(atarisy1_xscroll_w) AM_BASE_MEMBER(atarisy1_state, atarigen.xscroll) + AM_RANGE(0x820000, 0x820001) AM_WRITE(atarisy1_yscroll_w) AM_BASE_MEMBER(atarisy1_state, atarigen.yscroll) AM_RANGE(0x840000, 0x840001) AM_WRITE(atarisy1_priority_w) - AM_RANGE(0x860000, 0x860001) AM_WRITE(atarisy1_bankselect_w) AM_BASE(&atarisy1_bankselect) + AM_RANGE(0x860000, 0x860001) AM_WRITE(atarisy1_bankselect_w) AM_BASE_MEMBER(atarisy1_state, bankselect) AM_RANGE(0x880000, 0x880001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x8a0000, 0x8a0001) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0x8c0000, 0x8c0001) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x900000, 0x9fffff) AM_RAM - AM_RANGE(0xa00000, 0xa01fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xa00000, 0xa01fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(atarisy1_state, atarigen.playfield) AM_RANGE(0xa02000, 0xa02fff) AM_RAM_WRITE(atarisy1_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0xa03000, 0xa03fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xa03000, 0xa03fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(atarisy1_state, atarigen.alpha) AM_RANGE(0xb00000, 0xb007ff) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xf00000, 0xf00fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xf00000, 0xf00fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(atarisy1_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xf20000, 0xf20007) AM_READ(trakball_r) AM_RANGE(0xf40000, 0xf4001f) AM_READWRITE(joystick_r, joystick_w) AM_RANGE(0xf60000, 0xf60003) AM_READ(port4_r) @@ -750,6 +743,7 @@ static const ym2151_interface ym2151_config = *************************************/ static MACHINE_DRIVER_START( atarisy1 ) + MDRV_DRIVER_DATA(atarisy1_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2) @@ -2327,61 +2321,67 @@ ROM_END static DRIVER_INIT( marble ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 103); - joystick_type = 0; /* none */ - trackball_type = 1; /* rotated */ + state->joystick_type = 0; /* none */ + state->trackball_type = 1; /* rotated */ } static DRIVER_INIT( peterpak ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 107); - joystick_type = 1; /* digital */ - trackball_type = 0; /* none */ + state->joystick_type = 1; /* digital */ + state->trackball_type = 0; /* none */ } static DRIVER_INIT( indytemp ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 105); - joystick_type = 1; /* digital */ - trackball_type = 0; /* none */ + state->joystick_type = 1; /* digital */ + state->trackball_type = 0; /* none */ } static DRIVER_INIT( roadrunn ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 108); - joystick_type = 2; /* analog */ - trackball_type = 0; /* none */ + state->joystick_type = 2; /* analog */ + state->trackball_type = 0; /* none */ } static DRIVER_INIT( roadb109 ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 109); - joystick_type = 3; /* pedal */ - trackball_type = 2; /* steering wheel */ + state->joystick_type = 3; /* pedal */ + state->trackball_type = 2; /* steering wheel */ } static DRIVER_INIT( roadb110 ) { - atarigen_eeprom_default = NULL; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x080000, 0, 110); - joystick_type = 3; /* pedal */ - trackball_type = 2; /* steering wheel */ + state->joystick_type = 3; /* pedal */ + state->trackball_type = 2; /* steering wheel */ } diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c index 9f0facbab8e..b404f08b6d2 100644 --- a/src/mame/drivers/atarisy2.c +++ b/src/mame/drivers/atarisy2.c @@ -126,7 +126,6 @@ #include "driver.h" #include "cpu/m6502/m6502.h" #include "cpu/t11/t11.h" -#include "machine/atarigen.h" #include "slapstic.h" #include "atarisy2.h" #include "sound/tms5220.h" @@ -142,32 +141,6 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT8 interrupt_enable; -static UINT16 *bankselect; - -static INT8 pedal_count; - -static UINT8 has_tms5220; -static UINT8 tms5220_data; -static UINT8 tms5220_data_strobe; - -static UINT8 which_adc; - -static UINT8 p2portwr_state; -static UINT8 p2portrd_state; - -static UINT16 *rombank1, *rombank2; - -static UINT8 sound_reset_state; - - - -/************************************* - * * Prototypes * *************************************/ @@ -184,22 +157,24 @@ static STATE_POSTLOAD( bankselect_postload ); static void update_interrupts(running_machine *machine) { - if (atarigen_video_int_state) + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + + if (state->atarigen.video_int_state) cputag_set_input_line(machine, "maincpu", 3, ASSERT_LINE); else cputag_set_input_line(machine, "maincpu", 3, CLEAR_LINE); - if (atarigen_scanline_int_state) + if (state->atarigen.scanline_int_state) cputag_set_input_line(machine, "maincpu", 2, ASSERT_LINE); else cputag_set_input_line(machine, "maincpu", 2, CLEAR_LINE); - if (p2portwr_state) + if (state->p2portwr_state) cputag_set_input_line(machine, "maincpu", 1, ASSERT_LINE); else cputag_set_input_line(machine, "maincpu", 1, CLEAR_LINE); - if (p2portrd_state) + if (state->p2portrd_state) cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); else cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); @@ -215,11 +190,12 @@ static void update_interrupts(running_machine *machine) static void scanline_update(const device_config *screen, int scanline) { + atarisy2_state *state = (atarisy2_state *)screen->machine->driver_data; if (scanline <= video_screen_get_height(screen)) { /* generate the 32V interrupt (IRQ 2) */ if ((scanline % 64) == 0) - if (interrupt_enable & 4) + if (state->interrupt_enable & 4) atarigen_scanline_int_gen(cputag_get_cpu(screen->machine, "maincpu")); } } @@ -234,10 +210,12 @@ static void scanline_update(const device_config *screen, int scanline) static DIRECT_UPDATE_HANDLER( atarisy2_direct_handler ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + /* make sure slapstic area looks like ROM */ if (address >= 0x8000 && address < 0x8200) { - direct->raw = direct->decrypted = (UINT8 *)atarisy2_slapstic - 0x8000; + direct->raw = direct->decrypted = (UINT8 *)state->slapstic_base - 0x8000; return ~0; } return address; @@ -246,32 +224,35 @@ static DIRECT_UPDATE_HANDLER( atarisy2_direct_handler ) static MACHINE_START( atarisy2 ) { - state_save_register_global(machine, interrupt_enable); - state_save_register_global(machine, tms5220_data); - state_save_register_global(machine, tms5220_data_strobe); - state_save_register_global(machine, which_adc); - state_save_register_global(machine, p2portwr_state); - state_save_register_global(machine, p2portrd_state); + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + state_save_register_global(machine, state->interrupt_enable); + state_save_register_global(machine, state->tms5220_data); + state_save_register_global(machine, state->tms5220_data_strobe); + state_save_register_global(machine, state->which_adc); + state_save_register_global(machine, state->p2portwr_state); + state_save_register_global(machine, state->p2portrd_state); state_save_register_postload(machine, bankselect_postload, NULL); - state_save_register_global(machine, sound_reset_state); + state_save_register_global(machine, state->sound_reset_state); } static MACHINE_RESET( atarisy2 ) { - atarigen_eeprom_reset(); + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_sound_io_reset(cputag_get_cpu(machine, "soundcpu")); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 64); memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), atarisy2_direct_handler); - tms5220_data_strobe = 1; + state->tms5220_data_strobe = 1; - p2portwr_state = 0; - p2portrd_state = 0; + state->p2portwr_state = 0; + state->p2portrd_state = 0; - which_adc = 0; + state->which_adc = 0; } @@ -284,8 +265,10 @@ static MACHINE_RESET( atarisy2 ) static INTERRUPT_GEN( vblank_int ) { + atarisy2_state *state = (atarisy2_state *)device->machine->driver_data; + /* clock the VBLANK through */ - if (interrupt_enable & 8) + if (state->interrupt_enable & 8) atarigen_video_int_gen(device); } @@ -293,7 +276,8 @@ static INTERRUPT_GEN( vblank_int ) static WRITE16_HANDLER( int0_ack_w ) { /* reset sound IRQ */ - p2portrd_state = 0; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + state->p2portrd_state = 0; atarigen_update_interrupts(space->machine); } @@ -308,7 +292,8 @@ static WRITE16_HANDLER( int1_ack_w ) static TIMER_CALLBACK( delayed_int_enable_w ) { - interrupt_enable = param; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + state->interrupt_enable = param; } @@ -348,23 +333,25 @@ static WRITE16_HANDLER( bankselect_w ) 0x8e000, 0x86000, 0x7e000, 0x76000 }; - int newword = bankselect[offset]; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + int newword = state->bankselect[offset]; UINT8 *base; COMBINE_DATA(&newword); - bankselect[offset] = newword; + state->bankselect[offset] = newword; base = &memory_region(space->machine, "maincpu")[bankoffset[(newword >> 10) & 0x3f]]; - memcpy(offset ? rombank2 : rombank1, base, 0x2000); + memcpy(offset ? state->rombank2 : state->rombank1, base, 0x2000); } static STATE_POSTLOAD( bankselect_postload ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + atarisy2_state *state = (atarisy2_state *)machine->driver_data; - bankselect_w(space, 0, bankselect[0], 0xffff); - bankselect_w(space, 1, bankselect[1], 0xffff); + bankselect_w(space, 0, state->bankselect[0], 0xffff); + bankselect_w(space, 1, state->bankselect[1], 0xffff); } @@ -377,10 +364,11 @@ static STATE_POSTLOAD( bankselect_postload ) static READ16_HANDLER( switch_r ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; int result = input_port_read(space->machine, "1800") | (input_port_read(space->machine, "1801") << 8); - if (atarigen_cpu_to_sound_ready) result ^= 0x20; - if (atarigen_sound_to_cpu_ready) result ^= 0x10; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x20; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x10; return result; } @@ -388,11 +376,12 @@ static READ16_HANDLER( switch_r ) static READ8_HANDLER( switch_6502_r ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; int result = input_port_read(space->machine, "1840"); - if (atarigen_cpu_to_sound_ready) result ^= 0x01; - if (atarigen_sound_to_cpu_ready) result ^= 0x02; - if (!has_tms5220 || !tms5220_readyq_r(devtag_get_device(space->machine, "tms"))) result ^= 0x04; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x01; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x02; + if (!state->has_tms5220 || !tms5220_readyq_r(devtag_get_device(space->machine, "tms"))) result ^= 0x04; if (!(input_port_read(space->machine, "1801") & 0x80)) result ^= 0x10; return result; @@ -401,9 +390,9 @@ static READ8_HANDLER( switch_6502_r ) static WRITE8_HANDLER( switch_6502_w ) { - (void)offset; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; - if (has_tms5220) + if (state->has_tms5220) { data = 12 | ((data >> 5) & 1); tms5220_set_frequency(devtag_get_device(space->machine, "tms"), MASTER_CLOCK/4 / (16 - data) / 2); @@ -420,26 +409,29 @@ static WRITE8_HANDLER( switch_6502_w ) static WRITE16_HANDLER( adc_strobe_w ) { - which_adc = offset & 3; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + state->which_adc = offset & 3; } static READ16_HANDLER( adc_r ) { static const char *const adcnames[] = { "ADC0", "ADC1", "ADC2", "ADC3" }; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; - if (which_adc < pedal_count) - return ~input_port_read(space->machine, adcnames[which_adc]); + if (state->which_adc < state->pedal_count) + return ~input_port_read(space->machine, adcnames[state->which_adc]); - return input_port_read(space->machine, adcnames[which_adc]) | 0xff00; + return input_port_read(space->machine, adcnames[state->which_adc]) | 0xff00; } static READ8_HANDLER( leta_r ) { static const char *const letanames[] = { "LETA0", "LETA1", "LETA2", "LETA3" }; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; - if (pedal_count == -1) /* 720 */ + if (state->pedal_count == -1) /* 720 */ { /* special thanks to MAME Analog+ for the mapping code */ switch (offset & 3) @@ -620,28 +612,32 @@ static WRITE8_HANDLER( mixer_w ) static WRITE8_HANDLER( sound_reset_w ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + /* if no change, do nothing */ - if ((data & 1) == sound_reset_state) + if ((data & 1) == state->sound_reset_state) return; - sound_reset_state = data & 1; + state->sound_reset_state = data & 1; /* only track the 0 -> 1 transition */ - if (sound_reset_state == 0) + if (state->sound_reset_state == 0) return; /* a large number of signals are reset when this happens */ atarigen_sound_io_reset(cputag_get_cpu(space->machine, "soundcpu")); devtag_reset(space->machine, "ymsnd"); mixer_w(space, 0, 0); - tms5220_data = 0; - tms5220_data_strobe = 0; + state->tms5220_data = 0; + state->tms5220_data_strobe = 0; } static READ16_HANDLER( sound_r ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + /* clear the p2portwr state on a p1portrd */ - p2portwr_state = 0; + state->p2portwr_state = 0; atarigen_update_interrupts(space->machine); /* handle it normally otherwise */ @@ -651,8 +647,10 @@ static READ16_HANDLER( sound_r ) static WRITE8_HANDLER( sound_6502_w ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + /* clock the state through */ - p2portwr_state = (interrupt_enable & 2) != 0; + state->p2portwr_state = (state->interrupt_enable & 2) != 0; atarigen_update_interrupts(space->machine); /* handle it normally otherwise */ @@ -662,8 +660,10 @@ static WRITE8_HANDLER( sound_6502_w ) static READ8_HANDLER( sound_6502_r ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + /* clock the state through */ - p2portrd_state = (interrupt_enable & 1) != 0; + state->p2portrd_state = (state->interrupt_enable & 1) != 0; atarigen_update_interrupts(space->machine); /* handle it normally otherwise */ @@ -680,18 +680,20 @@ static READ8_HANDLER( sound_6502_r ) static WRITE8_HANDLER( tms5220_w ) { - tms5220_data = data; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + state->tms5220_data = data; } static WRITE8_HANDLER( tms5220_strobe_w ) { - if (!(offset & 1) && tms5220_data_strobe && has_tms5220) + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + if (!(offset & 1) && state->tms5220_data_strobe && state->has_tms5220) { const device_config *tms = devtag_get_device(space->machine, "tms"); - tms5220_data_w(tms, 0, tms5220_data); + tms5220_data_w(tms, 0, state->tms5220_data); } - tms5220_data_strobe = offset & 1; + state->tms5220_data_strobe = offset & 1; } @@ -720,7 +722,7 @@ static WRITE8_HANDLER( coincount_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0000, 0x0fff) AM_RAM AM_RANGE(0x1000, 0x11ff) AM_MIRROR(0x0200) AM_RAM_WRITE(atarisy2_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x1400, 0x1403) AM_MIRROR(0x007c) AM_READWRITE(adc_r, bankselect_w) AM_BASE(&bankselect) + AM_RANGE(0x1400, 0x1403) AM_MIRROR(0x007c) AM_READWRITE(adc_r, bankselect_w) AM_BASE_MEMBER(atarisy2_state, bankselect) AM_RANGE(0x1480, 0x1487) AM_MIRROR(0x0078) AM_WRITE(adc_strobe_w) AM_RANGE(0x1580, 0x1581) AM_MIRROR(0x001e) AM_WRITE(int0_ack_w) AM_RANGE(0x15a0, 0x15a1) AM_MIRROR(0x001e) AM_WRITE(int1_ack_w) @@ -728,14 +730,14 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x15e0, 0x15e1) AM_MIRROR(0x001e) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0x1600, 0x1601) AM_MIRROR(0x007e) AM_WRITE(int_enable_w) AM_RANGE(0x1680, 0x1681) AM_MIRROR(0x007e) AM_WRITE(atarigen_sound_w) - AM_RANGE(0x1700, 0x1701) AM_MIRROR(0x007e) AM_WRITE(atarisy2_xscroll_w) AM_BASE(&atarigen_xscroll) - AM_RANGE(0x1780, 0x1781) AM_MIRROR(0x007e) AM_WRITE(atarisy2_yscroll_w) AM_BASE(&atarigen_yscroll) + AM_RANGE(0x1700, 0x1701) AM_MIRROR(0x007e) AM_WRITE(atarisy2_xscroll_w) AM_BASE_MEMBER(atarisy2_state, atarigen.xscroll) + AM_RANGE(0x1780, 0x1781) AM_MIRROR(0x007e) AM_WRITE(atarisy2_yscroll_w) AM_BASE_MEMBER(atarisy2_state, atarigen.yscroll) AM_RANGE(0x1800, 0x1801) AM_MIRROR(0x03fe) AM_READWRITE(switch_r, watchdog_reset16_w) AM_RANGE(0x1c00, 0x1c01) AM_MIRROR(0x03fe) AM_READ(sound_r) AM_RANGE(0x2000, 0x3fff) AM_READWRITE(atarisy2_videoram_r, atarisy2_videoram_w) - AM_RANGE(0x4000, 0x5fff) AM_ROM AM_BASE(&rombank1) - AM_RANGE(0x6000, 0x7fff) AM_ROM AM_BASE(&rombank2) - AM_RANGE(0x8000, 0x81ff) AM_READWRITE(atarisy2_slapstic_r, atarisy2_slapstic_w) AM_BASE(&atarisy2_slapstic) + AM_RANGE(0x4000, 0x5fff) AM_ROM AM_BASE_MEMBER(atarisy2_state, rombank1) + AM_RANGE(0x6000, 0x7fff) AM_ROM AM_BASE_MEMBER(atarisy2_state, rombank2) + AM_RANGE(0x8000, 0x81ff) AM_READWRITE(atarisy2_slapstic_r, atarisy2_slapstic_w) AM_BASE_MEMBER(atarisy2_state, slapstic_base) AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -750,7 +752,7 @@ ADDRESS_MAP_END /* full memory map derived from schematics */ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x0fff) AM_MIRROR(0x2000) AM_RAM - AM_RANGE(0x1000, 0x17ff) AM_MIRROR(0x2000) AM_RAM AM_BASE((UINT8 **)&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x1000, 0x17ff) AM_MIRROR(0x2000) AM_RAM AM_BASE_SIZE_MEMBER(atarisy2_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x2780) AM_DEVREADWRITE("pokey1", pokey_r, pokey_w) AM_RANGE(0x1810, 0x1813) AM_MIRROR(0x278c) AM_READ(leta_r) AM_RANGE(0x1830, 0x183f) AM_MIRROR(0x2780) AM_DEVREADWRITE("pokey2", pokey_r, pokey_w) @@ -1141,6 +1143,7 @@ static const struct t11_setup t11_data = static MACHINE_DRIVER_START( atarisy2 ) + MDRV_DRIVER_DATA(atarisy2_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", T11, MASTER_CLOCK/2) @@ -3035,9 +3038,10 @@ static DRIVER_INIT( paperboy ) 0x0000 }; int i; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; UINT8 *cpu1 = memory_region(machine, "maincpu"); - atarigen_eeprom_default = compressed_default_eeprom; + state->atarigen.eeprom_default = compressed_default_eeprom; slapstic_init(machine, 105); /* expand the 16k program ROMs into full 64k chunks */ @@ -3048,8 +3052,8 @@ static DRIVER_INIT( paperboy ) memcpy(&cpu1[i + 0x18000], &cpu1[i], 0x8000); } - pedal_count = 0; - has_tms5220 = 1; + state->pedal_count = 0; + state->has_tms5220 = 1; } @@ -3084,28 +3088,30 @@ static DRIVER_INIT( 720 ) 0x0152,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x06ff, 0x0000 }; - atarigen_eeprom_default = compressed_default_eeprom; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + state->atarigen.eeprom_default = compressed_default_eeprom; slapstic_init(machine, 107); - pedal_count = -1; - has_tms5220 = 1; + state->pedal_count = -1; + state->has_tms5220 = 1; } static void ssprint_init_common(running_machine *machine, const UINT16 *default_eeprom) { + atarisy2_state *state = (atarisy2_state *)machine->driver_data; int i; UINT8 *cpu1 = memory_region(machine, "maincpu"); - atarigen_eeprom_default = default_eeprom; + state->atarigen.eeprom_default = default_eeprom; slapstic_init(machine, 108); /* expand the 32k program ROMs into full 64k chunks */ for (i = 0x10000; i < 0x90000; i += 0x20000) memcpy(&cpu1[i + 0x10000], &cpu1[i], 0x10000); - pedal_count = 3; - has_tms5220 = 0; + state->pedal_count = 3; + state->has_tms5220 = 0; } static DRIVER_INIT( ssprint ) @@ -3219,27 +3225,30 @@ static DRIVER_INIT( csprint ) 0x0186,0x0100,0x011B,0x01BC,0x011D,0x011F,0x0000 }; int i; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; UINT8 *cpu1 = memory_region(machine, "maincpu"); - atarigen_eeprom_default = compressed_default_eeprom; + state->atarigen.eeprom_default = compressed_default_eeprom; slapstic_init(machine, 109); /* expand the 32k program ROMs into full 64k chunks */ for (i = 0x10000; i < 0x90000; i += 0x20000) memcpy(&cpu1[i + 0x10000], &cpu1[i], 0x10000); - pedal_count = 2; - has_tms5220 = 0; + state->pedal_count = 2; + state->has_tms5220 = 0; } static DRIVER_INIT( apb ) { - atarigen_eeprom_default = NULL; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + + state->atarigen.eeprom_default = NULL; slapstic_init(machine, 110); - pedal_count = 2; - has_tms5220 = 1; + state->pedal_count = 2; + state->has_tms5220 = 1; } diff --git a/src/mame/drivers/badlands.c b/src/mame/drivers/badlands.c index 1101c3e67db..ffd02e58b8d 100644 --- a/src/mame/drivers/badlands.c +++ b/src/mame/drivers/badlands.c @@ -165,7 +165,6 @@ Measurements - #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" #include "cpu/m6502/m6502.h" -#include "machine/atarigen.h" #include "badlands.h" #include "sound/2151intf.h" @@ -173,27 +172,15 @@ Measurements - /************************************* * - * Statics - * - *************************************/ - -static UINT8 pedal_value[2]; - -static UINT8 *bank_base; -static UINT8 *bank_source_data; - - - -/************************************* - * * Initialization * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + badlands_state *state = (badlands_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -211,14 +198,16 @@ static void scanline_update(const device_config *screen, int scanline) static MACHINE_RESET( badlands ) { - pedal_value[0] = pedal_value[1] = 0x80; + badlands_state *state = (badlands_state *)machine->driver_data; + + state->pedal_value[0] = state->pedal_value[1] = 0x80; - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); - memcpy(bank_base, &bank_source_data[0x0000], 0x1000); + memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); } @@ -231,15 +220,16 @@ static MACHINE_RESET( badlands ) static INTERRUPT_GEN( vblank_int ) { + badlands_state *state = (badlands_state *)device->machine->driver_data; int pedal_state = input_port_read(device->machine, "PEDALS"); int i; /* update the pedals once per frame */ for (i = 0; i < 2; i++) { - pedal_value[i]--; + state->pedal_value[i]--; if (pedal_state & (1 << i)) - pedal_value[i]++; + state->pedal_value[i]++; } atarigen_video_int_gen(device); @@ -255,21 +245,24 @@ static INTERRUPT_GEN( vblank_int ) static READ16_HANDLER( sound_busy_r ) { + badlands_state *state = (badlands_state *)space->machine->driver_data; int temp = 0xfeff; - if (atarigen_cpu_to_sound_ready) temp ^= 0x0100; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0100; return temp; } static READ16_HANDLER( pedal_0_r ) { - return pedal_value[0]; + badlands_state *state = (badlands_state *)space->machine->driver_data; + return state->pedal_value[0]; } static READ16_HANDLER( pedal_1_r ) { - return pedal_value[1]; + badlands_state *state = (badlands_state *)space->machine->driver_data; + return state->pedal_value[1]; } @@ -282,6 +275,7 @@ static READ16_HANDLER( pedal_1_r ) static READ8_HANDLER( audio_io_r ) { + badlands_state *state = (badlands_state *)space->machine->driver_data; int result = 0xff; switch (offset & 0x206) @@ -307,8 +301,8 @@ static READ8_HANDLER( audio_io_r ) */ result = input_port_read(space->machine, "AUDIO"); if (!(input_port_read(space->machine, "FE4000") & 0x0080)) result ^= 0x90; - if (atarigen_cpu_to_sound_ready) result ^= 0x40; - if (atarigen_sound_to_cpu_ready) result ^= 0x20; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x40; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x20; result ^= 0x10; break; @@ -330,6 +324,8 @@ static READ8_HANDLER( audio_io_r ) static WRITE8_HANDLER( audio_io_w ) { + badlands_state *state = (badlands_state *)space->machine->driver_data; + switch (offset & 0x206) { case 0x000: /* n/c */ @@ -362,7 +358,7 @@ static WRITE8_HANDLER( audio_io_w ) */ /* update the bank */ - memcpy(bank_base, &bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); + memcpy(state->bank_base, &state->bank_source_data[0x1000 * ((data >> 6) & 3)], 0x1000); break; } } @@ -378,7 +374,7 @@ static WRITE8_HANDLER( audio_io_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0xfc0000, 0xfc1fff) AM_READWRITE(sound_busy_r, atarigen_sound_reset_w) - AM_RANGE(0xfd0000, 0xfd1fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfd0000, 0xfd1fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(badlands_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xfe0000, 0xfe1fff) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xfe2000, 0xfe3fff) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0xfe4000, 0xfe5fff) AM_READ_PORT("FE4000") @@ -391,7 +387,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfec000, 0xfedfff) AM_WRITE(badlands_pf_bank_w) AM_RANGE(0xfee000, 0xfeffff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0xffc000, 0xffc3ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(badlands_state, atarigen.playfield) AM_RANGE(0xfff000, 0xfff1ff) AM_RAM_WRITE(atarimo_0_spriteram_expanded_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xfff200, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -498,6 +494,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( badlands ) + MDRV_DRIVER_DATA(badlands_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -581,11 +578,11 @@ ROM_END static DRIVER_INIT( badlands ) { - atarigen_eeprom_default = NULL; + badlands_state *state = (badlands_state *)machine->driver_data; /* initialize the audio system */ - bank_base = &memory_region(machine, "audiocpu")[0x03000]; - bank_source_data = &memory_region(machine, "audiocpu")[0x10000]; + state->bank_base = &memory_region(machine, "audiocpu")[0x03000]; + state->bank_source_data = &memory_region(machine, "audiocpu")[0x10000]; } @@ -645,14 +642,14 @@ static ADDRESS_MAP_START( bootleg_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfe4006, 0xfe4007) AM_READ(badlandb_unk_r ) - AM_RANGE(0xfd0000, 0xfd1fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfd0000, 0xfd1fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(badlands_state, atarigen.eeprom, atarigen.eeprom_size) //AM_RANGE(0xfe0000, 0xfe1fff) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xfe2000, 0xfe3fff) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0xfec000, 0xfedfff) AM_WRITE(badlands_pf_bank_w) AM_RANGE(0xfee000, 0xfeffff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0xffc000, 0xffc3ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(badlands_state, atarigen.playfield) AM_RANGE(0xfff000, 0xfff1ff) AM_RAM_WRITE(atarimo_0_spriteram_expanded_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xfff200, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -676,7 +673,8 @@ GFXDECODE_END static void update_interrupts_bootleg(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); + badlands_state *state = (badlands_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -693,17 +691,19 @@ static void scanline_update_bootleg(const device_config *screen, int scanline) static MACHINE_RESET( badlandb ) { -// pedal_value[0] = pedal_value[1] = 0x80; + badlands_state *state = (badlands_state *)machine->driver_data; +// state->pedal_value[0] = state->pedal_value[1] = 0x80; - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts_bootleg); + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts_bootleg); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update_bootleg, 32); // atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); -// memcpy(bank_base, &bank_source_data[0x0000], 0x1000); +// memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); } static MACHINE_DRIVER_START( badlandb ) + MDRV_DRIVER_DATA(badlands_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 2800000/2) @@ -773,10 +773,4 @@ ROM_START( badlandsb ) ROM_END -static DRIVER_INIT( badlandb ) -{ - atarigen_eeprom_default = NULL; -} - - -GAME( 1989, badlandsb, badlands, badlandb, badlands, badlandb, ROT0, "[Atari Games] (Playmark bootleg)", "Bad Lands (bootleg)", GAME_NOT_WORKING ) +GAME( 1989, badlandsb, badlands, badlandb, badlands, 0, ROT0, "[Atari Games] (Playmark bootleg)", "Bad Lands (bootleg)", GAME_NOT_WORKING ) diff --git a/src/mame/drivers/batman.c b/src/mame/drivers/batman.c index 2e6bd16f4d5..ccc00e2f476 100644 --- a/src/mame/drivers/batman.c +++ b/src/mame/drivers/batman.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "batman.h" @@ -27,37 +26,29 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT16 latch_data; - - - -/************************************* - * * Initialization * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + batman_state *state = (batman_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( batman ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); - atarivc_reset(machine->primary_screen, atarivc_eof_data, 2); + batman_state *state = (batman_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); atarigen_scanline_timer_reset(machine->primary_screen, batman_scanline_update, 8); atarijsa_reset(); atarigen_init_save_state(machine); - state_save_register_global(machine, latch_data); - + state_save_register_global(machine, state->latch_data); } @@ -89,30 +80,32 @@ static WRITE16_HANDLER( batman_atarivc_w ) static READ16_HANDLER( special_port2_r ) { + batman_state *state = (batman_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); - if (atarigen_sound_to_cpu_ready) result ^= 0x0010; - if (atarigen_cpu_to_sound_ready) result ^= 0x0020; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x0010; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0020; return result; } static WRITE16_HANDLER( latch_w ) { - int oldword = latch_data; - COMBINE_DATA(&latch_data); + batman_state *state = (batman_state *)space->machine->driver_data; + int oldword = state->latch_data; + COMBINE_DATA(&state->latch_data); /* bit 4 is connected to the /RESET pin on the 6502 */ - if (latch_data & 0x0010) + if (state->latch_data & 0x0010) cputag_set_input_line(space->machine, "jsa", INPUT_LINE_RESET, CLEAR_LINE); else cputag_set_input_line(space->machine, "jsa", INPUT_LINE_RESET, ASSERT_LINE); /* alpha bank is selected by the upper 4 bits */ - if ((oldword ^ latch_data) & 0x7000) + if ((oldword ^ state->latch_data) & 0x7000) { video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); - tilemap_mark_all_tiles_dirty(atarigen_alpha_tilemap); - batman_alpha_tile_bank = (latch_data >> 12) & 7; + tilemap_mark_all_tiles_dirty(state->atarigen.alpha_tilemap); + state->alpha_tile_bank = (state->latch_data >> 12) & 7; } } @@ -132,7 +125,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_GLOBAL_MASK(0x3fffff) AM_RANGE(0x000000, 0x0bffff) AM_ROM AM_RANGE(0x100000, 0x10ffff) AM_MIRROR(0x010000) AM_RAM - AM_RANGE(0x120000, 0x120fff) AM_MIRROR(0x01f000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x120000, 0x120fff) AM_MIRROR(0x01f000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(batman_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x260000, 0x260001) AM_MIRROR(0x11ff8c) AM_READ_PORT("260000") AM_RANGE(0x260002, 0x260003) AM_MIRROR(0x11ff8c) AM_READ_PORT("260002") AM_RANGE(0x260010, 0x260011) AM_MIRROR(0x11ff8e) AM_READ(special_port2_r) @@ -142,13 +135,13 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x260060, 0x260061) AM_MIRROR(0x11ff8e) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x2a0000, 0x2a0001) AM_MIRROR(0x11fffe) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_MIRROR(0x100000) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3effc0, 0x3effff) AM_MIRROR(0x100000) AM_READWRITE(batman_atarivc_r, batman_atarivc_w) AM_BASE(&atarivc_data) - AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE(&atarigen_playfield2) - AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0x3f4000, 0x3f5fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3effc0, 0x3effff) AM_MIRROR(0x100000) AM_READWRITE(batman_atarivc_r, batman_atarivc_w) AM_BASE_MEMBER(batman_state, atarigen.atarivc_data) + AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(batman_state, atarigen.playfield2) + AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(batman_state, atarigen.playfield) + AM_RANGE(0x3f4000, 0x3f5fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(batman_state, atarigen.playfield_upper) AM_RANGE(0x3f6000, 0x3f7fff) AM_MIRROR(0x100000) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0x3f8000, 0x3f8fef) AM_MIRROR(0x100000) AM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) - AM_RANGE(0x3f8f00, 0x3f8f7f) AM_MIRROR(0x100000) AM_BASE(&atarivc_eof_data) + AM_RANGE(0x3f8000, 0x3f8fef) AM_MIRROR(0x100000) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(batman_state, atarigen.alpha) + AM_RANGE(0x3f8f00, 0x3f8f7f) AM_MIRROR(0x100000) AM_BASE_MEMBER(batman_state, atarigen.atarivc_eof_data) AM_RANGE(0x3f8f80, 0x3f8fff) AM_MIRROR(0x100000) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0x3f0000, 0x3fffff) AM_MIRROR(0x100000) AM_RAM ADDRESS_MAP_END @@ -232,6 +225,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( batman ) + MDRV_DRIVER_DATA(batman_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz) @@ -344,7 +338,8 @@ static DRIVER_INIT( batman ) 0x0150,0x0218,0x01D0,0x0100,0x01D0,0x0300,0x01D0,0x0600, 0x01D0,0x02C8,0x0000 }; - atarigen_eeprom_default = default_eeprom; + batman_state *state = (batman_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "260010", 0x0040); } diff --git a/src/mame/drivers/beathead.c b/src/mame/drivers/beathead.c index 3afb2988163..d4c676673ad 100644 --- a/src/mame/drivers/beathead.c +++ b/src/mame/drivers/beathead.c @@ -162,9 +162,11 @@ static TIMER_CALLBACK( scanline_callback ) static MACHINE_RESET( beathead ) { + beathead_state *state = (beathead_state *)machine->driver_data; + /* reset the common subsystems */ - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarijsa_reset(); /* the code is temporarily mapped at 0 at startup */ @@ -269,9 +271,10 @@ static WRITE32_HANDLER( eeprom_enable_w ) static READ32_HANDLER( input_2_r ) { + beathead_state *state = (beathead_state *)space->machine->driver_data; int result = input_port_read(space->machine, "IN2"); - if (atarigen_sound_to_cpu_ready) result ^= 0x10; - if (atarigen_cpu_to_sound_ready) result ^= 0x20; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x10; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x20; return result; } @@ -336,7 +339,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x41000220, 0x41000227) AM_WRITE(coin_count_w) AM_RANGE(0x41000300, 0x41000303) AM_READ(input_2_r) AM_RANGE(0x41000304, 0x41000307) AM_READ_PORT("IN3") - AM_RANGE(0x41000400, 0x41000403) AM_WRITEONLY AM_BASE(&beathead_palette_select) + AM_RANGE(0x41000400, 0x41000403) AM_WRITEONLY AM_BASE_MEMBER(beathead_state, palette_select) AM_RANGE(0x41000500, 0x41000503) AM_WRITE(eeprom_enable_w) AM_RANGE(0x41000600, 0x41000603) AM_WRITE(beathead_finescroll_w) AM_RANGE(0x41000700, 0x41000703) AM_WRITE(watchdog_reset32_w) @@ -347,7 +350,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x8f900000, 0x8f97ffff) AM_WRITE(beathead_vram_transparent_w) AM_RANGE(0x8f980000, 0x8f9fffff) AM_RAM AM_BASE_GENERIC(videoram) AM_RANGE(0x8fb80000, 0x8fbfffff) AM_WRITE(beathead_vram_bulk_w) - AM_RANGE(0x8fff8000, 0x8fff8003) AM_WRITEONLY AM_BASE(&beathead_vram_bulk_latch) + AM_RANGE(0x8fff8000, 0x8fff8003) AM_WRITEONLY AM_BASE_MEMBER(beathead_state, vram_bulk_latch) AM_RANGE(0x9e280000, 0x9e2fffff) AM_WRITE(beathead_vram_copy_w) ADDRESS_MAP_END @@ -407,6 +410,7 @@ INPUT_PORTS_END *************************************/ static MACHINE_DRIVER_START( beathead ) + MDRV_DRIVER_DATA(beathead_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", ASAP, ATARI_CLOCK_14MHz) @@ -510,7 +514,6 @@ static READ32_HANDLER( movie_speedup_r ) static DRIVER_INIT( beathead ) { /* initialize the common systems */ - atarigen_eeprom_default = NULL; atarijsa_init(machine, "IN2", 0x0040); /* prepare the speedups */ diff --git a/src/mame/drivers/blstroid.c b/src/mame/drivers/blstroid.c index 0814ac26c37..92fe6698ba0 100644 --- a/src/mame/drivers/blstroid.c +++ b/src/mame/drivers/blstroid.c @@ -33,9 +33,10 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 4, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + blstroid_state *state = (blstroid_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -47,8 +48,10 @@ static WRITE16_HANDLER( blstroid_halt_until_hblank_0_w ) static MACHINE_RESET( blstroid ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + blstroid_state *state = (blstroid_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, blstroid_scanline_update, 8); atarijsa_reset(); } @@ -64,9 +67,10 @@ static MACHINE_RESET( blstroid ) static READ16_HANDLER( inputs_r ) { static const char *const iptnames[] = { "IN0", "IN1" }; + blstroid_state *state = (blstroid_state *)space->machine->driver_data; int temp = input_port_read(space->machine, iptnames[offset & 1]); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0040; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0040; if (atarigen_get_hblank(space->machine->primary_screen)) temp ^= 0x0010; return temp; } @@ -87,7 +91,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xff8200, 0xff8201) AM_MIRROR(0x7f81fe) AM_WRITE(atarigen_scanline_int_ack_w) AM_RANGE(0xff8400, 0xff8401) AM_MIRROR(0x7f81fe) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0xff8600, 0xff8601) AM_MIRROR(0x7f81fe) AM_WRITE(atarigen_eeprom_enable_w) - AM_RANGE(0xff8800, 0xff89ff) AM_MIRROR(0x7f8000) AM_WRITEONLY AM_BASE(&blstroid_priorityram) + AM_RANGE(0xff8800, 0xff89ff) AM_MIRROR(0x7f8000) AM_WRITEONLY AM_BASE_MEMBER(blstroid_state, priorityram) AM_RANGE(0xff8a00, 0xff8a01) AM_MIRROR(0x7f81fe) AM_WRITE(atarigen_sound_w) AM_RANGE(0xff8c00, 0xff8c01) AM_MIRROR(0x7f81fe) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0xff8e00, 0xff8e01) AM_MIRROR(0x7f81fe) AM_WRITE(blstroid_halt_until_hblank_0_w) @@ -96,8 +100,8 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xff9804, 0xff9805) AM_MIRROR(0x7f83f8) AM_READ_PORT("DIAL1") AM_RANGE(0xff9c00, 0xff9c03) AM_MIRROR(0x7f83fc) AM_READ(inputs_r) AM_RANGE(0xffa000, 0xffa3ff) AM_MIRROR(0x7f8c00) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xffb000, 0xffb3ff) AM_MIRROR(0x7f8c00) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) - AM_RANGE(0xffc000, 0xffcfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xffb000, 0xffb3ff) AM_MIRROR(0x7f8c00) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(blstroid_state, atarigen.eeprom, atarigen.eeprom_size) + AM_RANGE(0xffc000, 0xffcfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(blstroid_state, atarigen.playfield) AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xffe000, 0xffffff) AM_MIRROR(0x7f8000) AM_RAM ADDRESS_MAP_END @@ -191,6 +195,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( blstroid ) + MDRV_DRIVER_DATA(blstroid_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -420,7 +425,6 @@ ROM_END static DRIVER_INIT( blstroid ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "IN0", 0x80); } diff --git a/src/mame/drivers/cyberbal.c b/src/mame/drivers/cyberbal.c index c505d39d524..eb24f73a4ac 100644 --- a/src/mame/drivers/cyberbal.c +++ b/src/mame/drivers/cyberbal.c @@ -25,7 +25,6 @@ #include "sound/2151intf.h" #include "sound/dac.h" #include "rendlay.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "cyberbal.h" @@ -38,16 +37,19 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "extra", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "extra", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( cyberbal ) { - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, cyberbal_scanline_update, 8); atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); @@ -60,15 +62,18 @@ static MACHINE_RESET( cyberbal ) static void cyberb2p_update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 3, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 3, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( cyberb2p ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(cyberb2p_update_interrupts); + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, cyberb2p_update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, cyberbal_scanline_update, 8); atarijsa_reset(); } @@ -83,24 +88,27 @@ static MACHINE_RESET( cyberb2p ) static READ16_HANDLER( special_port0_r ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "IN0"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0080; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0080; return temp; } static READ16_HANDLER( special_port2_r ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "IN2"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x2000; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x2000; return temp; } static READ16_HANDLER( sound_state_r ) { + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; int temp = 0xffff; - if (atarigen_cpu_to_sound_ready) temp ^= 0xffff; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0xffff; return temp; } @@ -127,7 +135,7 @@ static WRITE16_HANDLER( p2_reset_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0xfc0000, 0xfc0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfc0000, 0xfc0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(cyberbal_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xfc8000, 0xfcffff) AM_READ(atarigen_sound_upper_r) AM_RANGE(0xfd0000, 0xfd1fff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0xfd2000, 0xfd3fff) AM_WRITE(atarigen_sound_reset_w) @@ -136,14 +144,14 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfd8000, 0xfd9fff) AM_WRITE(atarigen_sound_upper_w) AM_RANGE(0xfe0000, 0xfe0fff) AM_READ(special_port0_r) AM_RANGE(0xfe1000, 0xfe1fff) AM_READ_PORT("IN1") - AM_RANGE(0xfe8000, 0xfe8fff) AM_RAM_WRITE(cyberbal_paletteram_1_w) AM_SHARE("share1") AM_BASE(&cyberbal_paletteram_1) - AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(cyberbal_paletteram_0_w) AM_SHARE("share2") AM_BASE(&cyberbal_paletteram_0) - AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield2_w) AM_SHARE("share3") AM_BASE(&atarigen_playfield2) - AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha2_w) AM_SHARE("share4") AM_BASE(&atarigen_alpha2) + AM_RANGE(0xfe8000, 0xfe8fff) AM_RAM_WRITE(cyberbal_paletteram_1_w) AM_SHARE("share1") AM_BASE_MEMBER(cyberbal_state, paletteram_1) + AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(cyberbal_paletteram_0_w) AM_SHARE("share2") AM_BASE_MEMBER(cyberbal_state, paletteram_0) + AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield2_w) AM_SHARE("share3") AM_BASE_MEMBER(cyberbal_state, atarigen.playfield2) + AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha2_w) AM_SHARE("share4") AM_BASE_MEMBER(cyberbal_state, atarigen.alpha2) AM_RANGE(0xff3000, 0xff37ff) AM_RAM_WRITE(atarimo_1_spriteram_w) AM_SHARE("share5") AM_BASE(&atarimo_1_spriteram) AM_RANGE(0xff3800, 0xff3fff) AM_RAM AM_SHARE("share6") - AM_RANGE(0xff4000, 0xff5fff) AM_RAM_WRITE(atarigen_playfield_w) AM_SHARE("share7") AM_BASE(&atarigen_playfield) - AM_RANGE(0xff6000, 0xff6fff) AM_RAM_WRITE(atarigen_alpha_w) AM_SHARE("share8") AM_BASE(&atarigen_alpha) + AM_RANGE(0xff4000, 0xff5fff) AM_RAM_WRITE(atarigen_playfield_w) AM_SHARE("share7") AM_BASE_MEMBER(cyberbal_state, atarigen.playfield) + AM_RANGE(0xff6000, 0xff6fff) AM_RAM_WRITE(atarigen_alpha_w) AM_SHARE("share8") AM_BASE_MEMBER(cyberbal_state, atarigen.alpha) AM_RANGE(0xff7000, 0xff77ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_SHARE("share9") AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xff7800, 0xff9fff) AM_RAM AM_SHARE("share10") AM_RANGE(0xffa000, 0xffbfff) AM_READONLY AM_WRITENOP AM_SHARE("share11") @@ -196,7 +204,7 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x2c02, 0x2c03) AM_READ(cyberbal_special_port3_r) AM_RANGE(0x2c04, 0x2c05) AM_READ(cyberbal_sound_68k_6502_r) AM_RANGE(0x2c06, 0x2c07) AM_READ(cyberbal_sound_6502_stat_r) - AM_RANGE(0x3000, 0x3fff) AM_ROMBANK("bank8") + AM_RANGE(0x3000, 0x3fff) AM_ROMBANK("soundbank") AM_RANGE(0x4000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -231,7 +239,7 @@ static ADDRESS_MAP_START( cyberb2p_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfc2000, 0xfc2003) AM_READ_PORT("IN1") AM_RANGE(0xfc4000, 0xfc4003) AM_READ(special_port2_r) AM_RANGE(0xfc6000, 0xfc6003) AM_READ(atarigen_sound_upper_r) - AM_RANGE(0xfc8000, 0xfc8fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfc8000, 0xfc8fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(cyberbal_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xfca000, 0xfcafff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xfd0000, 0xfd0003) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0xfd2000, 0xfd2003) AM_WRITE(atarigen_sound_reset_w) @@ -239,8 +247,8 @@ static ADDRESS_MAP_START( cyberb2p_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfd6000, 0xfd6003) AM_WRITE(atarigen_video_int_ack_w) AM_RANGE(0xfd8000, 0xfd8003) AM_WRITE(atarigen_sound_upper_w) AM_RANGE(0xfe0000, 0xfe0003) AM_READ(sound_state_r) - AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(cyberbal_state, atarigen.playfield) + AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(cyberbal_state, atarigen.alpha) AM_RANGE(0xff3000, 0xff37ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xff3800, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -408,6 +416,7 @@ static const ym2151_interface ym2151_config = *************************************/ static MACHINE_DRIVER_START( cyberbal ) + MDRV_DRIVER_DATA(cyberbal_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -467,6 +476,7 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( cyberb2p ) + MDRV_DRIVER_DATA(cyberbal_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -971,21 +981,24 @@ static const UINT16 default_eeprom[] = static DRIVER_INIT( cyberbal ) { - atarigen_eeprom_default = default_eeprom; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x018000, 0, 0); } static DRIVER_INIT( cyberbt ) { - atarigen_eeprom_default = default_eeprom; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x018000, 0, 116); } static DRIVER_INIT( cyberb2p ) { - atarigen_eeprom_default = default_eeprom; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "IN2", 0x8000); } diff --git a/src/mame/drivers/eprom.c b/src/mame/drivers/eprom.c index 0cb696d4a31..f1a140b80cd 100644 --- a/src/mame/drivers/eprom.c +++ b/src/mame/drivers/eprom.c @@ -25,7 +25,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "eprom.h" @@ -33,35 +32,29 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT16 *sync_data; - - - -/************************************* - * * Initialization * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); + eprom_state *state = (eprom_state *)machine->driver_data; + + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); if (cputag_get_cpu(machine, "extra") != NULL) - cputag_set_input_line(machine, "extra", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "extra", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( klaxp ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + eprom_state *state = (eprom_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, eprom_scanline_update, 8); atarijsa_reset(); atarigen_init_save_state(machine); @@ -70,8 +63,9 @@ static MACHINE_RESET( klaxp ) static MACHINE_RESET( eprom ) { + eprom_state *state = (eprom_state *)machine->driver_data; MACHINE_RESET_CALL(klaxp); - state_save_register_global_pointer(machine, sync_data, 2); + state_save_register_global_pointer(machine, state->sync_data, 2); } @@ -84,10 +78,11 @@ static MACHINE_RESET( eprom ) static READ16_HANDLER( special_port1_r ) { + eprom_state *state = (eprom_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); - if (atarigen_sound_to_cpu_ready) result ^= 0x0004; - if (atarigen_cpu_to_sound_ready) result ^= 0x0008; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x0004; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0008; result ^= 0x0010; return result; @@ -114,6 +109,8 @@ static READ16_HANDLER( adc_r ) static WRITE16_HANDLER( eprom_latch_w ) { + eprom_state *state = (eprom_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7 && (cputag_get_cpu(space->machine, "extra") != NULL)) { /* bit 0: reset extra CPU */ @@ -123,10 +120,10 @@ static WRITE16_HANDLER( eprom_latch_w ) cputag_set_input_line(space->machine, "extra", INPUT_LINE_RESET, ASSERT_LINE); /* bits 1-4: screen intensity */ - eprom_screen_intensity = (data & 0x1e) >> 1; + state->screen_intensity = (data & 0x1e) >> 1; /* bit 5: video disable */ - eprom_video_disable = (data & 0x20); + state->video_disable = (data & 0x20); } } @@ -140,17 +137,19 @@ static WRITE16_HANDLER( eprom_latch_w ) static READ16_HANDLER( sync_r ) { - return sync_data[offset]; + eprom_state *state = (eprom_state *)space->machine->driver_data; + return state->sync_data[offset]; } static WRITE16_HANDLER( sync_w ) { - int oldword = sync_data[offset]; + eprom_state *state = (eprom_state *)space->machine->driver_data; + int oldword = state->sync_data[offset]; int newword = oldword; COMBINE_DATA(&newword); - sync_data[offset] = newword; + state->sync_data[offset] = newword; if ((oldword & 0xff00) != (newword & 0xff00)) cpu_yield(space->cpu); } @@ -165,7 +164,7 @@ static WRITE16_HANDLER( sync_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x09ffff) AM_ROM - AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(eprom_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x16cc00, 0x16cc01) AM_RAM AM_SHARE("share2") AM_RANGE(0x160000, 0x16ffff) AM_RAM AM_SHARE("share1") AM_RANGE(0x1f0000, 0x1fffff) AM_WRITE(atarigen_eeprom_enable_w) @@ -179,18 +178,18 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x360020, 0x360021) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3f0000, 0x3f1fff) AM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0x3f0000, 0x3f1fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(eprom_state, atarigen.playfield) AM_RANGE(0x3f2000, 0x3f3fff) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0x3f4000, 0x3f4f7f) AM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0x3f4000, 0x3f4f7f) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(eprom_state, atarigen.alpha) AM_RANGE(0x3f4f80, 0x3f4fff) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) - AM_RANGE(0x3f8000, 0x3f9fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3f8000, 0x3f9fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(eprom_state, atarigen.playfield_upper) AM_RANGE(0x3f0000, 0x3f9fff) AM_RAM ADDRESS_MAP_END static ADDRESS_MAP_START( guts_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x09ffff) AM_ROM - AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(eprom_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x16cc00, 0x16cc01) AM_RAM AM_SHARE("share2") AM_RANGE(0x160000, 0x16ffff) AM_RAM AM_SHARE("share1") AM_RANGE(0x1f0000, 0x1fffff) AM_WRITE(atarigen_eeprom_enable_w) @@ -204,10 +203,10 @@ static ADDRESS_MAP_START( guts_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x360020, 0x360021) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM AM_BASE_GENERIC(paletteram) - AM_RANGE(0xff0000, 0xff1fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) - AM_RANGE(0xff8000, 0xff9fff) AM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xff0000, 0xff1fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(eprom_state, atarigen.playfield_upper) + AM_RANGE(0xff8000, 0xff9fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(eprom_state, atarigen.playfield) AM_RANGE(0xffa000, 0xffbfff) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0xffc000, 0xffcf7f) AM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xffc000, 0xffcf7f) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(eprom_state, atarigen.alpha) AM_RANGE(0xffcf80, 0xffcfff) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0xff0000, 0xff1fff) AM_RAM AM_RANGE(0xff8000, 0xffffff) AM_RAM @@ -223,7 +222,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( extra_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x16cc00, 0x16cc01) AM_READWRITE(sync_r, sync_w) AM_SHARE("share2") AM_BASE(&sync_data) + AM_RANGE(0x16cc00, 0x16cc01) AM_READWRITE(sync_r, sync_w) AM_SHARE("share2") AM_BASE_MEMBER(eprom_state, sync_data) AM_RANGE(0x160000, 0x16ffff) AM_RAM AM_SHARE("share1") AM_RANGE(0x260000, 0x26000f) AM_READ_PORT("260000") AM_RANGE(0x260010, 0x26001f) AM_READ(special_port1_r) @@ -411,6 +410,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( eprom ) + MDRV_DRIVER_DATA(eprom_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -445,6 +445,7 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( klaxp ) + MDRV_DRIVER_DATA(eprom_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -476,6 +477,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( guts ) + MDRV_DRIVER_DATA(eprom_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(guts_map) @@ -725,25 +728,24 @@ ROM_END static DRIVER_INIT( eprom ) { - atarigen_eeprom_default = NULL; + eprom_state *state = (eprom_state *)machine->driver_data; + atarijsa_init(machine, "260010", 0x0002); /* install CPU synchronization handlers */ - sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w); - sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "extra", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w); + state->sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w); + state->sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "extra", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w); } static DRIVER_INIT( klaxp ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "260010", 0x0002); } static DRIVER_INIT( guts ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "260010", 0x0002); } diff --git a/src/mame/drivers/foodf.c b/src/mame/drivers/foodf.c index 18aa21a5ad7..fc742d3cc5a 100644 --- a/src/mame/drivers/foodf.c +++ b/src/mame/drivers/foodf.c @@ -85,17 +85,6 @@ /************************************* * - * Statics - * - *************************************/ - -static emu_timer *scanline_timer; -static UINT8 whichport = 0; - - - -/************************************* - * * NVRAM * *************************************/ @@ -115,14 +104,16 @@ static READ16_HANDLER( nvram_r ) static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 3, atarigen_scanline_int_state && atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); + foodf_state *state = (foodf_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 3, state->atarigen.scanline_int_state && state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); } static TIMER_CALLBACK( scanline_update ) { + foodf_state *state = (foodf_state *)machine->driver_data; int scanline = param; /* WARNING: the timing of this is not perfectly accurate; it should fire on @@ -139,21 +130,23 @@ static TIMER_CALLBACK( scanline_update ) scanline = 0; /* set a timer for it */ - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); } static MACHINE_START( foodf ) { - state_save_register_global(machine, whichport); - scanline_timer = timer_alloc(machine, scanline_update, NULL); + foodf_state *state = (foodf_state *)machine->driver_data; + state_save_register_global(machine, state->whichport); + state->scanline_timer = timer_alloc(machine, scanline_update, NULL); } static MACHINE_RESET( foodf ) { - atarigen_interrupt_reset(update_interrupts); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + foodf_state *state = (foodf_state *)machine->driver_data; + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); } @@ -166,9 +159,10 @@ static MACHINE_RESET( foodf ) static WRITE16_HANDLER( digital_w ) { + foodf_state *state = (foodf_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - foodf_set_flip(data & 0x01); + foodf_set_flip(state, data & 0x01); /* bit 1 = UPDATE */ @@ -196,14 +190,16 @@ static WRITE16_HANDLER( digital_w ) static READ16_HANDLER( analog_r ) { static const char *const portnames[] = { "STICK0_X", "STICK1_X", "STICK0_Y", "STICK1_Y" }; + foodf_state *state = (foodf_state *)space->machine->driver_data; - return input_port_read(space->machine, portnames[whichport]); + return input_port_read(space->machine, portnames[state->whichport]); } static WRITE16_HANDLER( analog_w ) { - whichport = offset ^ 3; + foodf_state *state = (foodf_state *)space->machine->driver_data; + state->whichport = offset ^ 3; } @@ -219,7 +215,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x014000, 0x014fff) AM_MIRROR(0x3e3000) AM_RAM AM_RANGE(0x018000, 0x018fff) AM_MIRROR(0x3e3000) AM_RAM AM_RANGE(0x01c000, 0x01c0ff) AM_MIRROR(0x3e3f00) AM_RAM AM_BASE_GENERIC(spriteram) - AM_RANGE(0x800000, 0x8007ff) AM_MIRROR(0x03f800) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0x800000, 0x8007ff) AM_MIRROR(0x03f800) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(foodf_state, atarigen.playfield) AM_RANGE(0x900000, 0x9001ff) AM_MIRROR(0x03fe00) AM_RAM_READ(nvram_r) AM_BASE_SIZE_GENERIC(nvram) AM_RANGE(0x940000, 0x940007) AM_MIRROR(0x023ff8) AM_READ(analog_r) AM_RANGE(0x944000, 0x944007) AM_MIRROR(0x023ff8) AM_WRITE(analog_w) @@ -358,6 +354,7 @@ static const pokey_interface pokey_config = *************************************/ static MACHINE_DRIVER_START( foodf ) + MDRV_DRIVER_DATA(foodf_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK/2) diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index 8cf18bc74aa..05049bd4eb7 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -121,7 +121,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" #include "cpu/m6502/m6502.h" -#include "machine/atarigen.h" #include "sound/tms5220.h" #include "sound/2151intf.h" #include "sound/pokey.h" @@ -135,7 +134,6 @@ * *************************************/ -static UINT16 sound_reset_val; @@ -147,8 +145,9 @@ static UINT16 sound_reset_val; static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + gauntlet_state *state = (gauntlet_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -166,11 +165,13 @@ static void scanline_update(const device_config *screen, int scanline) static MACHINE_RESET( gauntlet ) { - sound_reset_val = 1; + gauntlet_state *state = (gauntlet_state *)machine->driver_data; - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + state->sound_reset_val = 1; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); } @@ -185,9 +186,10 @@ static MACHINE_RESET( gauntlet ) static READ16_HANDLER( port4_r ) { + gauntlet_state *state = (gauntlet_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "803008"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0020; - if (atarigen_sound_to_cpu_ready) temp ^= 0x0010; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0020; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x0010; return temp; } @@ -201,14 +203,15 @@ static READ16_HANDLER( port4_r ) static WRITE16_HANDLER( sound_reset_w ) { + gauntlet_state *state = (gauntlet_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - int oldword = sound_reset_val; - COMBINE_DATA(&sound_reset_val); + int oldword = state->sound_reset_val; + COMBINE_DATA(&state->sound_reset_val); - if ((oldword ^ sound_reset_val) & 1) + if ((oldword ^ state->sound_reset_val) & 1) { - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (sound_reset_val & 1) ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (state->sound_reset_val & 1) ? CLEAR_LINE : ASSERT_LINE); atarigen_sound_reset(space->machine); } } @@ -224,10 +227,11 @@ static WRITE16_HANDLER( sound_reset_w ) static READ8_HANDLER( switch_6502_r ) { + gauntlet_state *state = (gauntlet_state *)space->machine->driver_data; int temp = 0x30; - if (atarigen_cpu_to_sound_ready) temp ^= 0x80; - if (atarigen_sound_to_cpu_ready) temp ^= 0x40; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x80; + if (state->atarigen.sound_to_cpu_ready) temp ^= 0x40; if (!tms5220_readyq_r(devtag_get_device(space->machine, "tms"))) temp ^= 0x20; if (!(input_port_read(space->machine, "803008") & 0x0008)) temp ^= 0x10; @@ -296,7 +300,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) /* MBUS */ AM_RANGE(0x800000, 0x801fff) AM_MIRROR(0x2fc000) AM_RAM - AM_RANGE(0x802000, 0x802fff) AM_MIRROR(0x2fc000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x802000, 0x802fff) AM_MIRROR(0x2fc000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(gauntlet_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x803000, 0x803001) AM_MIRROR(0x2fcef0) AM_READ_PORT("803000") AM_RANGE(0x803002, 0x803003) AM_MIRROR(0x2fcef0) AM_READ_PORT("803002") AM_RANGE(0x803004, 0x803005) AM_MIRROR(0x2fcef0) AM_READ_PORT("803004") @@ -310,14 +314,14 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x803170, 0x803171) AM_MIRROR(0x2fce8e) AM_WRITE(atarigen_sound_w) /* VBUS */ - AM_RANGE(0x900000, 0x901fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0x900000, 0x901fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(gauntlet_state, atarigen.playfield) AM_RANGE(0x902000, 0x903fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x904000, 0x904fff) AM_MIRROR(0x2c8000) AM_RAM - AM_RANGE(0x905f6e, 0x905f6f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(gauntlet_yscroll_w) AM_BASE(&atarigen_yscroll) - AM_RANGE(0x905000, 0x905f7f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0x905f6e, 0x905f6f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(gauntlet_yscroll_w) AM_BASE_MEMBER(gauntlet_state, atarigen.yscroll) + AM_RANGE(0x905000, 0x905f7f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(gauntlet_state, atarigen.alpha) AM_RANGE(0x905f80, 0x905fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0x910000, 0x9107ff) AM_MIRROR(0x2cf800) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x930000, 0x930001) AM_MIRROR(0x2cfffe) AM_WRITE(gauntlet_xscroll_w) AM_BASE(&atarigen_xscroll) + AM_RANGE(0x930000, 0x930001) AM_MIRROR(0x2cfffe) AM_WRITE(gauntlet_xscroll_w) AM_BASE_MEMBER(gauntlet_state, atarigen.xscroll) ADDRESS_MAP_END @@ -500,6 +504,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( gauntlet ) + MDRV_DRIVER_DATA(gauntlet_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2) @@ -1608,8 +1613,9 @@ ROM_END static void gauntlet_common_init(running_machine *machine, int slapstic, int vindctr2) { + gauntlet_state *state = (gauntlet_state *)machine->driver_data; UINT8 *rom = memory_region(machine, "maincpu"); - atarigen_eeprom_default = NULL; + state->atarigen.eeprom_default = NULL; atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x038000, 0, slapstic); /* swap the top and bottom halves of the main CPU ROM images */ @@ -1620,7 +1626,7 @@ static void gauntlet_common_init(running_machine *machine, int slapstic, int vin atarigen_swap_mem(rom + 0x070000, rom + 0x078000, 0x8000); /* indicate whether or not we are vindicators 2 */ - vindctr2_screen_refresh = vindctr2; + state->vindctr2_screen_refresh = vindctr2; } diff --git a/src/mame/drivers/harddriv.c b/src/mame/drivers/harddriv.c index 50b01cbb598..83d2d7cf9e6 100644 --- a/src/mame/drivers/harddriv.c +++ b/src/mame/drivers/harddriv.c @@ -306,7 +306,7 @@ static ADDRESS_MAP_START( driver_68k_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w) AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w) AM_RANGE(0xff0000, 0xff001f) AM_READWRITE(hd68k_duart_r, hd68k_duart_w) - AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE_SIZE_MEMBER(harddriv_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xff8000, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -316,17 +316,17 @@ static ADDRESS_MAP_START( driver_gsp_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x00000000, 0x0000200f) AM_NOP /* hit during self-test */ AM_RANGE(0x02000000, 0x0207ffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_1bpp_w) AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, hdgsp_io_w) - AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE(&hdgsp_control_lo) - AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE(&hdgsp_control_hi) - AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE(&hdgsp_paletteram_lo) - AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE(&hdgsp_paletteram_hi) - AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_BASE((UINT16 **)&hdgsp_vram) AM_SIZE(&hdgsp_vram_size) + AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_control_lo) + AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_control_hi) + AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_lo) + AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_hi) + AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_BASE_SIZE_MEMBER(harddriv_state, gsp_vram, gsp_vram_size) ADDRESS_MAP_END static ADDRESS_MAP_START( driver_msp_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_SHARE("share1") AM_BASE(&hdmsp_ram) + AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_SHARE("share1") AM_BASE_MEMBER(harddriv_state, msp_ram) AM_RANGE(0x00700000, 0x007fffff) AM_RAM AM_SHARE("share1") AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, tms34010_io_register_w) AM_RANGE(0xfff00000, 0xffffffff) AM_RAM AM_SHARE("share1") @@ -354,7 +354,7 @@ static ADDRESS_MAP_START( multisync_68k_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w) AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w) AM_RANGE(0xff0000, 0xff001f) AM_READWRITE(hd68k_duart_r, hd68k_duart_w) - AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xff4000, 0xff4fff) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE_SIZE_MEMBER(harddriv_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xff8000, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -364,11 +364,11 @@ static ADDRESS_MAP_START( multisync_gsp_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x00000000, 0x0000200f) AM_NOP /* hit during self-test */ AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w) AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, hdgsp_io_w) - AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE(&hdgsp_control_lo) - AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE(&hdgsp_control_hi) - AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE(&hdgsp_paletteram_lo) - AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE(&hdgsp_paletteram_hi) - AM_RANGE(0xff800000, 0xffbfffff) AM_MIRROR(0x0400000) AM_RAM AM_BASE((UINT16 **)&hdgsp_vram) AM_SIZE(&hdgsp_vram_size) + AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_control_lo) + AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_control_hi) + AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_lo) + AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_hi) + AM_RANGE(0xff800000, 0xffbfffff) AM_MIRROR(0x0400000) AM_RAM AM_BASE_SIZE_MEMBER(harddriv_state, gsp_vram, gsp_vram_size) ADDRESS_MAP_END @@ -392,7 +392,7 @@ static ADDRESS_MAP_START( multisync2_68k_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(hd68k_gsp_io_r, hd68k_gsp_io_w) AM_RANGE(0xc04000, 0xc07fff) AM_READWRITE(hd68k_msp_io_r, hd68k_msp_io_w) AM_RANGE(0xfc0000, 0xfc001f) AM_READWRITE(hd68k_duart_r, hd68k_duart_w) - AM_RANGE(0xfd0000, 0xfd0fff) AM_MIRROR(0x004000) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xfd0000, 0xfd0fff) AM_MIRROR(0x004000) AM_READWRITE(hd68k_zram_r, hd68k_zram_w) AM_BASE_SIZE_MEMBER(harddriv_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xff0000, 0xffffff) AM_RAM ADDRESS_MAP_END @@ -403,11 +403,11 @@ static ADDRESS_MAP_START( multisync2_gsp_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x00000000, 0x0000200f) AM_NOP /* hit during self-test */ AM_RANGE(0x02000000, 0x020fffff) AM_READWRITE(hdgsp_vram_2bpp_r, hdgsp_vram_2bpp_w) AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, hdgsp_io_w) - AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE(&hdgsp_control_lo) - AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE(&hdgsp_control_hi) - AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE(&hdgsp_paletteram_lo) - AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE(&hdgsp_paletteram_hi) - AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_BASE((UINT16 **)&hdgsp_vram) AM_SIZE(&hdgsp_vram_size) + AM_RANGE(0xf4000000, 0xf40000ff) AM_READWRITE(hdgsp_control_lo_r, hdgsp_control_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_control_lo) + AM_RANGE(0xf4800000, 0xf48000ff) AM_READWRITE(hdgsp_control_hi_r, hdgsp_control_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_control_hi) + AM_RANGE(0xf5000000, 0xf5000fff) AM_READWRITE(hdgsp_paletteram_lo_r, hdgsp_paletteram_lo_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_lo) + AM_RANGE(0xf5800000, 0xf5800fff) AM_READWRITE(hdgsp_paletteram_hi_r, hdgsp_paletteram_hi_w) AM_BASE_MEMBER(harddriv_state, gsp_paletteram_hi) + AM_RANGE(0xff800000, 0xffffffff) AM_RAM AM_BASE_SIZE_MEMBER(harddriv_state, gsp_vram, gsp_vram_size) ADDRESS_MAP_END @@ -420,13 +420,13 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( adsp_program_map, ADDRESS_SPACE_PROGRAM, 32 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&hdadsp_pgm_memory) + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(harddriv_state, adsp_pgm_memory) ADDRESS_MAP_END static ADDRESS_MAP_START( adsp_data_map, ADDRESS_SPACE_DATA, 16 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&hdadsp_data_memory) + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(harddriv_state, adsp_data_memory) AM_RANGE(0x2000, 0x2fff) AM_READWRITE(hdadsp_special_r, hdadsp_special_w) ADDRESS_MAP_END @@ -440,13 +440,13 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( ds3_program_map, ADDRESS_SPACE_PROGRAM, 32 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&hdadsp_pgm_memory) + AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE_MEMBER(harddriv_state, adsp_pgm_memory) ADDRESS_MAP_END static ADDRESS_MAP_START( ds3_data_map, ADDRESS_SPACE_DATA, 16 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&hdadsp_data_memory) + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(harddriv_state, adsp_data_memory) AM_RANGE(0x3800, 0x3bff) AM_RAM /* internal RAM */ AM_RANGE(0x3fe0, 0x3fff) AM_READWRITE(hdds3_control_r, hdds3_control_w) /* adsp control regs */ AM_RANGE(0x2000, 0x3fff) AM_READWRITE(hdds3_special_r, hdds3_special_w) @@ -543,7 +543,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( driversnd_dsp_program_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x000, 0xfff) AM_RAM AM_BASE(&hdsnddsp_ram) + AM_RANGE(0x000, 0xfff) AM_RAM AM_BASE_MEMBER(harddriv_state, sounddsp_ram) ADDRESS_MAP_END @@ -1004,6 +1004,7 @@ INPUT_PORTS_END /* Driver board without MSP (used by Race Drivin' cockpit) */ static MACHINE_DRIVER_START( driver_nomsp ) + MDRV_DRIVER_DATA(harddriv_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68010, 32000000/4) @@ -3371,14 +3372,15 @@ ROM_END /* COMMON INIT: find all the CPUs */ static void find_cpus(running_machine *machine) { - hdcpu_main = cputag_get_cpu(machine, "maincpu"); - hdcpu_gsp = cputag_get_cpu(machine, "gsp"); - hdcpu_msp = cputag_get_cpu(machine, "msp"); - hdcpu_adsp = cputag_get_cpu(machine, "adsp"); - hdcpu_sound = cputag_get_cpu(machine, "soundcpu"); - hdcpu_sounddsp = cputag_get_cpu(machine, "sounddsp"); - hdcpu_jsa = cputag_get_cpu(machine, "jsa"); - hdcpu_dsp32 = cputag_get_cpu(machine, "dsp32"); + harddriv_state *state = (harddriv_state *)machine->driver_data; + state->maincpu = cputag_get_cpu(machine, "maincpu"); + state->gsp = cputag_get_cpu(machine, "gsp"); + state->msp = cputag_get_cpu(machine, "msp"); + state->adsp = cputag_get_cpu(machine, "adsp"); + state->soundcpu = cputag_get_cpu(machine, "soundcpu"); + state->sounddsp = cputag_get_cpu(machine, "sounddsp"); + state->jsacpu = cputag_get_cpu(machine, "jsa"); + state->dsp32 = cputag_get_cpu(machine, "dsp32"); } @@ -3393,31 +3395,35 @@ static const UINT16 default_eeprom[] = /* COMMON INIT: initialize the original "driver" main board */ static void init_driver(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* assume we're first to be called */ find_cpus(machine); /* note that we're not multisync and set the default EEPROM data */ - hdgsp_multisync = 0; - atarigen_eeprom_default = default_eeprom; + state->gsp_multisync = FALSE; + state->atarigen.eeprom_default = default_eeprom; } /* COMMON INIT: initialize the later "multisync" main board */ static void init_multisync(running_machine *machine, int compact_inputs) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* assume we're first to be called */ find_cpus(machine); /* note that we're multisync and set the default EEPROM data */ - hdgsp_multisync = 1; - atarigen_eeprom_default = default_eeprom; + state->gsp_multisync = TRUE; + state->atarigen.eeprom_default = default_eeprom; /* install handlers for the compact driving games' inputs */ if (compact_inputs) { - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x400000, 0x400001, 0, 0, hdc68k_wheel_r); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x408000, 0x408001, 0, 0, hdc68k_wheel_edge_reset_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hdc68k_port1_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x400000, 0x400001, 0, 0, hdc68k_wheel_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x408000, 0x408001, 0, 0, hdc68k_wheel_edge_reset_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hdc68k_port1_r); } } @@ -3425,48 +3431,52 @@ static void init_multisync(running_machine *machine, int compact_inputs) /* COMMON INIT: initialize the ADSP/ADSP2 board */ static void init_adsp(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* install ADSP program RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x800000, 0x807fff, 0, 0, hd68k_adsp_program_r, hd68k_adsp_program_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x800000, 0x807fff, 0, 0, hd68k_adsp_program_r, hd68k_adsp_program_w); /* install ADSP data RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x808000, 0x80bfff, 0, 0, hd68k_adsp_data_r, hd68k_adsp_data_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x808000, 0x80bfff, 0, 0, hd68k_adsp_data_r, hd68k_adsp_data_w); /* install ADSP serial buffer RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x810000, 0x813fff, 0, 0, hd68k_adsp_buffer_r, hd68k_adsp_buffer_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x810000, 0x813fff, 0, 0, hd68k_adsp_buffer_r, hd68k_adsp_buffer_w); /* install ADSP control locations */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x818000, 0x81801f, 0, 0, hd68k_adsp_control_w); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x818060, 0x81807f, 0, 0, hd68k_adsp_irq_clear_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x838000, 0x83ffff, 0, 0, hd68k_adsp_irq_state_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x818000, 0x81801f, 0, 0, hd68k_adsp_control_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x818060, 0x81807f, 0, 0, hd68k_adsp_irq_clear_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x838000, 0x83ffff, 0, 0, hd68k_adsp_irq_state_r); } /* COMMON INIT: initialize the DS3 board */ static void init_ds3(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* install ADSP program RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x800000, 0x807fff, 0, 0, hd68k_ds3_program_r, hd68k_ds3_program_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x800000, 0x807fff, 0, 0, hd68k_ds3_program_r, hd68k_ds3_program_w); /* install ADSP data RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x808000, 0x80bfff, 0, 0, hd68k_adsp_data_r, hd68k_adsp_data_w); - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x80c000, 0x80dfff, 0, 0, hdds3_special_r, hdds3_special_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x808000, 0x80bfff, 0, 0, hd68k_adsp_data_r, hd68k_adsp_data_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x80c000, 0x80dfff, 0, 0, hdds3_special_r, hdds3_special_w); /* install ADSP control locations */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x820000, 0x8207ff, 0, 0, hd68k_ds3_gdata_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x820800, 0x820fff, 0, 0, hd68k_ds3_girq_state_r); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x820000, 0x8207ff, 0, 0, hd68k_ds3_gdata_w); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x821000, 0x8217ff, 0, 0, hd68k_adsp_irq_clear_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x822000, 0x8227ff, 0, 0, hd68k_ds3_sdata_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x822800, 0x822fff, 0, 0, hd68k_ds3_sirq_state_r); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x822000, 0x8227ff, 0, 0, hd68k_ds3_sdata_w); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x823800, 0x823fff, 0, 0, hd68k_ds3_control_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x820000, 0x8207ff, 0, 0, hd68k_ds3_gdata_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x820800, 0x820fff, 0, 0, hd68k_ds3_girq_state_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x820000, 0x8207ff, 0, 0, hd68k_ds3_gdata_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x821000, 0x8217ff, 0, 0, hd68k_adsp_irq_clear_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x822000, 0x8227ff, 0, 0, hd68k_ds3_sdata_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x822800, 0x822fff, 0, 0, hd68k_ds3_sirq_state_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x822000, 0x8227ff, 0, 0, hd68k_ds3_sdata_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x823800, 0x823fff, 0, 0, hd68k_ds3_control_w); /* if we have a sound DSP, boot it */ - if (hdcpu_sound != NULL && cpu_get_type(hdcpu_sound) == CPU_ADSP2105) - adsp2105_load_boot_data((UINT8 *)(hdcpu_sound->region + 0x10000), (UINT32 *)hdcpu_sound->region); + if (state->soundcpu != NULL && cpu_get_type(state->soundcpu) == CPU_ADSP2105) + adsp2105_load_boot_data((UINT8 *)(state->soundcpu->region + 0x10000), (UINT32 *)state->soundcpu->region); - if (hdcpu_sounddsp != NULL && cpu_get_type(hdcpu_sounddsp) == CPU_ADSP2105) - adsp2105_load_boot_data((UINT8 *)(hdcpu_sounddsp->region + 0x10000), (UINT32 *)hdcpu_sounddsp->region); + if (state->sounddsp != NULL && cpu_get_type(state->sounddsp) == CPU_ADSP2105) + adsp2105_load_boot_data((UINT8 *)(state->sounddsp->region + 0x10000), (UINT32 *)state->sounddsp->region); /* @@ -3540,30 +3550,31 @@ static void init_ds3(running_machine *machine) /* COMMON INIT: initialize the DSK add-on board */ static void init_dsk(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; UINT8 *usr3 = memory_region(machine, "user3"); /* install ASIC61 */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x85c000, 0x85c7ff, 0, 0, hd68k_dsk_dsp32_r, hd68k_dsk_dsp32_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x85c000, 0x85c7ff, 0, 0, hd68k_dsk_dsp32_r, hd68k_dsk_dsp32_w); /* install control registers */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x85c800, 0x85c81f, 0, 0, hd68k_dsk_control_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x85c800, 0x85c81f, 0, 0, hd68k_dsk_control_w); /* install extra RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x900000, 0x90ffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w); - hddsk_ram = (UINT16 *)(usr3 + 0x40000); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x900000, 0x90ffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w); + state->dsk_ram = (UINT16 *)(usr3 + 0x40000); /* install extra ZRAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x910000, 0x910fff, 0, 0, hd68k_dsk_zram_r, hd68k_dsk_zram_w); - hddsk_zram = (UINT16 *)(usr3 + 0x50000); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x910000, 0x910fff, 0, 0, hd68k_dsk_zram_r, hd68k_dsk_zram_w); + state->dsk_zram = (UINT16 *)(usr3 + 0x50000); /* install ASIC65 */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x914000, 0x917fff, 0, 0, asic65_data_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x914000, 0x917fff, 0, 0, asic65_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x918000, 0x91bfff, 0, 0, asic65_io_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x914000, 0x917fff, 0, 0, asic65_data_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x914000, 0x917fff, 0, 0, asic65_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x918000, 0x91bfff, 0, 0, asic65_io_r); /* install extra ROM */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x940000, 0x9fffff, 0, 0, hd68k_dsk_small_rom_r); - hddsk_rom = (UINT16 *)(usr3 + 0x00000); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x940000, 0x9fffff, 0, 0, hd68k_dsk_small_rom_r); + state->dsk_rom = (UINT16 *)(usr3 + 0x00000); /* set up the ASIC65 */ asic65_config(machine, ASIC65_STANDARD); @@ -3573,26 +3584,27 @@ static void init_dsk(running_machine *machine) /* COMMON INIT: initialize the DSK II add-on board */ static void init_dsk2(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; UINT8 *usr3 = memory_region(machine, "user3"); /* install ASIC65 */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x824000, 0x824003, 0, 0, asic65_data_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x824000, 0x824003, 0, 0, asic65_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x825000, 0x825001, 0, 0, asic65_io_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x824000, 0x824003, 0, 0, asic65_data_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x824000, 0x824003, 0, 0, asic65_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x825000, 0x825001, 0, 0, asic65_io_r); /* install ASIC61 */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x827000, 0x8277ff, 0, 0, hd68k_dsk_dsp32_r, hd68k_dsk_dsp32_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x827000, 0x8277ff, 0, 0, hd68k_dsk_dsp32_r, hd68k_dsk_dsp32_w); /* install control registers */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x827800, 0x82781f, 0, 0, hd68k_dsk_control_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x827800, 0x82781f, 0, 0, hd68k_dsk_control_w); /* install extra RAM */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x880000, 0x8bffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w); - hddsk_ram = (UINT16 *)(usr3 + 0x100000); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x880000, 0x8bffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w); + state->dsk_ram = (UINT16 *)(usr3 + 0x100000); /* install extra ROM */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x900000, 0x9fffff, 0, 0, hd68k_dsk_rom_r); - hddsk_rom = (UINT16 *)(usr3 + 0x000000); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x900000, 0x9fffff, 0, 0, hd68k_dsk_rom_r); + state->dsk_rom = (UINT16 *)(usr3 + 0x000000); /* set up the ASIC65 */ asic65_config(machine, ASIC65_STANDARD); @@ -3602,28 +3614,32 @@ static void init_dsk2(running_machine *machine) /* COMMON INIT: initialize the DSPCOM add-on board */ static void init_dspcom(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* install ASIC65 */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x900000, 0x900003, 0, 0, asic65_data_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x900000, 0x900003, 0, 0, asic65_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x901000, 0x910001, 0, 0, asic65_io_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x900000, 0x900003, 0, 0, asic65_data_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x900000, 0x900003, 0, 0, asic65_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x901000, 0x910001, 0, 0, asic65_io_r); /* set up the ASIC65 */ asic65_config(machine, ASIC65_STEELTAL); /* install DSPCOM control */ - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x904000, 0x90401f, 0, 0, hddspcom_control_w); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x904000, 0x90401f, 0, 0, hddspcom_control_w); } /* COMMON INIT: initialize the original "driver" sound board */ static void init_driver_sound(running_machine *machine) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + hdsnd_init(machine); /* install sound handlers */ - memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x840000, 0x840001, 0, 0, hd68k_snd_data_r, hd68k_snd_data_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x844000, 0x844001, 0, 0, hd68k_snd_status_r); - memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x84c000, 0x84c001, 0, 0, hd68k_snd_reset_w); + memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x840000, 0x840001, 0, 0, hd68k_snd_data_r, hd68k_snd_data_w); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x844000, 0x844001, 0, 0, hd68k_snd_status_r); + memory_install_write16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x84c000, 0x84c001, 0, 0, hd68k_snd_reset_w); } @@ -3637,73 +3653,78 @@ static void init_driver_sound(running_machine *machine) static DRIVER_INIT( harddriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_driver(machine); init_adsp(machine); init_driver_sound(machine); /* set up gsp speedup handler */ - hdgsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); - hdgsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); - hdgsp_speedup_pc = 0xffc00f10; + state->gsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); + state->gsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); + memory_install_read16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); + state->gsp_speedup_pc = 0xffc00f10; /* set up msp speedup handler */ - hdmsp_speedup_addr = memory_install_write16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_r); - hdmsp_speedup_pc = 0x00723b00; + state->msp_speedup_addr = memory_install_write16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_w); + memory_install_read16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_r); + state->msp_speedup_pc = 0x00723b00; /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); } static DRIVER_INIT( harddrvc ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 1); init_adsp(machine); init_driver_sound(machine); /* set up gsp speedup handler */ - hdgsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); - hdgsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); - hdgsp_speedup_pc = 0xfff40ff0; + state->gsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); + state->gsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); + memory_install_read16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); + state->gsp_speedup_pc = 0xfff40ff0; /* set up msp speedup handler */ - hdmsp_speedup_addr = memory_install_write16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_r); - hdmsp_speedup_pc = 0x00723b00; + state->msp_speedup_addr = memory_install_write16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_w); + memory_install_read16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x00751b00, 0x00751b0f, 0, 0, hdmsp_speedup_r); + state->msp_speedup_pc = 0x00723b00; /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); } static DRIVER_INIT( stunrun ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 0); init_adsp(machine); atarijsa_init(machine, "IN0", 0x0020); /* set up gsp speedup handler */ - hdgsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); - hdgsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); - hdgsp_speedup_pc = 0xfff41070; + state->gsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup1_w); + state->gsp_speedup_addr[1] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfffcfc00, 0xfffcfc0f, 0, 0, hdgsp_speedup2_w); + memory_install_read16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff9fc00, 0xfff9fc0f, 0, 0, hdgsp_speedup_r); + state->gsp_speedup_pc = 0xfff41070; /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); } -static UINT32 *rddsp32_speedup; -static offs_t rddsp32_speedup_pc; static READ32_HANDLER( rddsp32_speedup_r ) { - if (cpu_get_pc(space->cpu) == rddsp32_speedup_pc && (*rddsp32_speedup >> 16) == 0) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (cpu_get_pc(space->cpu) == state->rddsp32_speedup_pc && (*state->rddsp32_speedup >> 16) == 0) { UINT32 r14 = cpu_get_reg(space->cpu, DSP32_R14); UINT32 r1 = memory_read_word(space, r14 - 0x14); @@ -3716,14 +3737,16 @@ static READ32_HANDLER( rddsp32_speedup_r ) cpu_adjust_icount(space->cpu, -cycles_to_burn); memory_write_word(space, r14 - 0x14, r1 + cycles_to_burn / 17); } - msp_speedup_count[0]++; + state->msp_speedup_count[0]++; } - return *rddsp32_speedup; + return *state->rddsp32_speedup; } static DRIVER_INIT( racedriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_driver(machine); init_adsp(machine); @@ -3732,23 +3755,25 @@ static DRIVER_INIT( racedriv ) /* set up the slapstic */ slapstic_init(machine, 117); - hd68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); + state->m68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); /* synchronization */ - rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); - rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); + state->rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); + state->rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); /* set up dsp32 speedup handlers */ - rddsp32_speedup = memory_install_read32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613e04, 0x613e07, 0, 0, rddsp32_speedup_r); - rddsp32_speedup_pc = 0x6054b0; + state->rddsp32_speedup = memory_install_read32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613e04, 0x613e07, 0, 0, rddsp32_speedup_r); + state->rddsp32_speedup_pc = 0x6054b0; } static void racedrvc_init_common(running_machine *machine, offs_t gsp_protection) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 1); init_adsp(machine); @@ -3757,26 +3782,26 @@ static void racedrvc_init_common(running_machine *machine, offs_t gsp_protection /* set up the slapstic */ slapstic_init(machine, 117); - hd68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); + state->m68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); /* synchronization */ - rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); - rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); + state->rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); + state->rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); /* set up protection hacks */ - hdgsp_protection = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), gsp_protection, gsp_protection + 0x0f, 0, 0, hdgsp_protection_w); + state->gsp_protection = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), gsp_protection, gsp_protection + 0x0f, 0, 0, hdgsp_protection_w); /* set up gsp speedup handler */ - hdgsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff76f60, 0xfff76f6f, 0, 0, rdgsp_speedup1_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff76f60, 0xfff76f6f, 0, 0, rdgsp_speedup1_r); - hdgsp_speedup_pc = 0xfff43a00; + state->gsp_speedup_addr[0] = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff76f60, 0xfff76f6f, 0, 0, rdgsp_speedup1_w); + memory_install_read16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff76f60, 0xfff76f6f, 0, 0, rdgsp_speedup1_r); + state->gsp_speedup_pc = 0xfff43a00; /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); /* set up dsp32 speedup handlers */ - rddsp32_speedup = memory_install_read32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613e04, 0x613e07, 0, 0, rddsp32_speedup_r); - rddsp32_speedup_pc = 0x6054b0; + state->rddsp32_speedup = memory_install_read32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613e04, 0x613e07, 0, 0, rddsp32_speedup_r); + state->rddsp32_speedup_pc = 0x6054b0; } static DRIVER_INIT( racedrvc ) { racedrvc_init_common(machine, 0xfff95cd0); } @@ -3792,43 +3817,45 @@ static READ16_HANDLER( steeltal_dummy_r ) static void steeltal_init_common(running_machine *machine, offs_t ds3_transfer_pc, int proto_sloop) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 0); init_ds3(machine); init_dspcom(machine); atarijsa_init(machine, "IN0", 0x0020); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x908000, 0x908001, 0, 0, steeltal_dummy_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x908000, 0x908001, 0, 0, steeltal_dummy_r); /* set up the SLOOP */ if (!proto_sloop) { - hd68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, st68k_sloop_r, st68k_sloop_w); - st68k_sloop_alt_base = memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x4e000, 0x4ffff, 0, 0, st68k_sloop_alt_r); + state->m68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, st68k_sloop_r, st68k_sloop_w); + state->m68k_sloop_alt_base = memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x4e000, 0x4ffff, 0, 0, st68k_sloop_alt_r); } else - hd68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, st68k_protosloop_r, st68k_protosloop_w); + state->m68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, st68k_protosloop_r, st68k_protosloop_w); /* synchronization */ - stmsp_sync[0] = &hdmsp_ram[TOWORD(0x80010)]; - memory_install_write16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x80010, 0x8007f, 0, 0, stmsp_sync0_w); - stmsp_sync[1] = &hdmsp_ram[TOWORD(0x99680)]; - memory_install_write16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x99680, 0x9968f, 0, 0, stmsp_sync1_w); - stmsp_sync[2] = &hdmsp_ram[TOWORD(0x99d30)]; - memory_install_write16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x99d30, 0x99d4f, 0, 0, stmsp_sync2_w); + state->stmsp_sync[0] = &state->msp_ram[TOWORD(0x80010)]; + memory_install_write16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x80010, 0x8007f, 0, 0, stmsp_sync0_w); + state->stmsp_sync[1] = &state->msp_ram[TOWORD(0x99680)]; + memory_install_write16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x99680, 0x9968f, 0, 0, stmsp_sync1_w); + state->stmsp_sync[2] = &state->msp_ram[TOWORD(0x99d30)]; + memory_install_write16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x99d30, 0x99d4f, 0, 0, stmsp_sync2_w); /* set up protection hacks */ - hdgsp_protection = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff965d0, 0xfff965df, 0, 0, hdgsp_protection_w); + state->gsp_protection = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff965d0, 0xfff965df, 0, 0, hdgsp_protection_w); /* set up msp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_msp, ADDRESS_SPACE_PROGRAM), 0x80020, 0x8002f, 0, 0, stmsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->msp, ADDRESS_SPACE_PROGRAM), 0x80020, 0x8002f, 0, 0, stmsp_speedup_r); /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); - hdds3_speedup_addr = &hdadsp_data_memory[0x1f99]; - hdds3_speedup_pc = 0xff; - hdds3_transfer_pc = ds3_transfer_pc; + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); + state->ds3_speedup_addr = &state->adsp_data_memory[0x1f99]; + state->ds3_speedup_pc = 0xff; + state->ds3_transfer_pc = ds3_transfer_pc; } @@ -3839,6 +3866,8 @@ static DRIVER_INIT( steeltap ) { steeltal_init_common(machine, 0x52290, 1); } static DRIVER_INIT( strtdriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 1); init_ds3(machine); @@ -3846,73 +3875,77 @@ static DRIVER_INIT( strtdriv ) /* set up the slapstic */ slapstic_init(machine, 117); - hd68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); + state->m68k_slapstic_base = memory_install_readwrite16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xe0000, 0xfffff, 0, 0, rd68k_slapstic_r, rd68k_slapstic_w); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); /* synchronization */ - rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); - rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); + state->rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613c00, 0x613c03, 0, 0, rddsp32_sync0_w); + state->rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x613e00, 0x613e03, 0, 0, rddsp32_sync1_w); /* set up protection hacks */ - hdgsp_protection = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff960a0, 0xfff960af, 0, 0, hdgsp_protection_w); + state->gsp_protection = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff960a0, 0xfff960af, 0, 0, hdgsp_protection_w); /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); - hdds3_speedup_addr = &hdadsp_data_memory[0x1f99]; - hdds3_speedup_pc = 0xff; - hdds3_transfer_pc = 0x43672; + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); + state->ds3_speedup_addr = &state->adsp_data_memory[0x1f99]; + state->ds3_speedup_pc = 0xff; + state->ds3_transfer_pc = 0x43672; } static DRIVER_INIT( hdrivair ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 1); init_ds3(machine); init_dsk2(machine); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); /* synchronization */ - rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x21fe00, 0x21fe03, 0, 0, rddsp32_sync0_w); - rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x21ff00, 0x21ff03, 0, 0, rddsp32_sync1_w); + state->rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x21fe00, 0x21fe03, 0, 0, rddsp32_sync0_w); + state->rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x21ff00, 0x21ff03, 0, 0, rddsp32_sync1_w); /* set up protection hacks */ - hdgsp_protection = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff943f0, 0xfff943ff, 0, 0, hdgsp_protection_w); + state->gsp_protection = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff943f0, 0xfff943ff, 0, 0, hdgsp_protection_w); /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); - hdds3_speedup_addr = &hdadsp_data_memory[0x1f99]; - hdds3_speedup_pc = 0x2da; - hdds3_transfer_pc = 0x407b8; + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1f99, 0x1f99, 0, 0, hdds3_speedup_r); + state->ds3_speedup_addr = &state->adsp_data_memory[0x1f99]; + state->ds3_speedup_pc = 0x2da; + state->ds3_transfer_pc = 0x407b8; } static DRIVER_INIT( hdrivaip ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* initialize the boards */ init_multisync(machine, 1); init_ds3(machine); init_dsk2(machine); - memory_install_read16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); + memory_install_read16_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0xa80000, 0xafffff, 0, 0, hda68k_port1_r); /* synchronization */ - rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x21fe00, 0x21fe03, 0, 0, rddsp32_sync0_w); - rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(hdcpu_dsp32, ADDRESS_SPACE_PROGRAM), 0x21ff00, 0x21ff03, 0, 0, rddsp32_sync1_w); + state->rddsp32_sync[0] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x21fe00, 0x21fe03, 0, 0, rddsp32_sync0_w); + state->rddsp32_sync[1] = memory_install_write32_handler(cpu_get_address_space(state->dsp32, ADDRESS_SPACE_PROGRAM), 0x21ff00, 0x21ff03, 0, 0, rddsp32_sync1_w); /* set up protection hacks */ - hdgsp_protection = memory_install_write16_handler(cpu_get_address_space(hdcpu_gsp, ADDRESS_SPACE_PROGRAM), 0xfff916c0, 0xfff916cf, 0, 0, hdgsp_protection_w); + state->gsp_protection = memory_install_write16_handler(cpu_get_address_space(state->gsp, ADDRESS_SPACE_PROGRAM), 0xfff916c0, 0xfff916cf, 0, 0, hdgsp_protection_w); /* set up adsp speedup handlers */ - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); - memory_install_read16_handler(cpu_get_address_space(hdcpu_adsp, ADDRESS_SPACE_DATA), 0x1f9a, 0x1f9a, 0, 0, hdds3_speedup_r); - hdds3_speedup_addr = &hdadsp_data_memory[0x1f9a]; - hdds3_speedup_pc = 0x2d9; - hdds3_transfer_pc = 0X407da; + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1fff, 0x1fff, 0, 0, hdadsp_speedup_r); + memory_install_read16_handler(cpu_get_address_space(state->adsp, ADDRESS_SPACE_DATA), 0x1f9a, 0x1f9a, 0, 0, hdds3_speedup_r); + state->ds3_speedup_addr = &state->adsp_data_memory[0x1f9a]; + state->ds3_speedup_pc = 0x2d9; + state->ds3_transfer_pc = 0X407da; } diff --git a/src/mame/drivers/klax.c b/src/mame/drivers/klax.c index 99286e67472..2e574e278ed 100644 --- a/src/mame/drivers/klax.c +++ b/src/mame/drivers/klax.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "klax.h" #include "sound/okim6295.h" @@ -33,7 +32,8 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state || atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + klax_state *state = (klax_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.video_int_state || state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -61,8 +61,10 @@ static WRITE16_HANDLER( interrupt_ack_w ) static MACHINE_RESET( klax ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + klax_state *state = (klax_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); } @@ -76,7 +78,7 @@ static MACHINE_RESET( klax ) static ADDRESS_MAP_START( klax_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r,atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r,atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(klax_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x1f0000, 0x1fffff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x260000, 0x260001) AM_READ_PORT("P1") AM_WRITE(klax_latch_w) AM_RANGE(0x260002, 0x260003) AM_READ_PORT("P2") @@ -84,9 +86,9 @@ static ADDRESS_MAP_START( klax_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x2e0000, 0x2e0001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x360000, 0x360001) AM_WRITE(interrupt_ack_w) AM_RANGE(0x3e0000, 0x3e07ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3f0000, 0x3f0f7f) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0x3f0000, 0x3f0f7f) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(klax_state, atarigen.playfield) AM_RANGE(0x3f0f80, 0x3f0fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) - AM_RANGE(0x3f1000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3f1000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(klax_state, atarigen.playfield_upper) AM_RANGE(0x3f2000, 0x3f27ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x3f2800, 0x3f3fff) AM_RAM ADDRESS_MAP_END @@ -156,6 +158,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( klax ) + MDRV_DRIVER_DATA(klax_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -348,25 +351,12 @@ ROM_END /************************************* * - * Driver initialization - * - *************************************/ - -static DRIVER_INIT( klax ) -{ - atarigen_eeprom_default = NULL; -} - - - -/************************************* - * * Game driver(s) * *************************************/ -GAME( 1989, klax, 0, klax, klax, klax, ROT0, "Atari Games", "Klax (set 1)", 0 ) -GAME( 1989, klax2, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (set 2)", 0 ) -GAME( 1989, klax3, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (set 3)", 0 ) -GAME( 1989, klaxj, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (Japan)", 0 ) -GAME( 1989, klaxd, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (Germany)", 0 ) +GAME( 1989, klax, 0, klax, klax, 0, ROT0, "Atari Games", "Klax (set 1)", 0 ) +GAME( 1989, klax2, klax, klax, klax, 0, ROT0, "Atari Games", "Klax (set 2)", 0 ) +GAME( 1989, klax3, klax, klax, klax, 0, ROT0, "Atari Games", "Klax (set 3)", 0 ) +GAME( 1989, klaxj, klax, klax, klax, 0, ROT0, "Atari Games", "Klax (Japan)", 0 ) +GAME( 1989, klaxd, klax, klax, klax, 0, ROT0, "Atari Games", "Klax (Germany)", 0 ) diff --git a/src/mame/drivers/offtwall.c b/src/mame/drivers/offtwall.c index a3b3d799472..0f5756ec608 100644 --- a/src/mame/drivers/offtwall.c +++ b/src/mame/drivers/offtwall.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "offtwall.h" @@ -33,8 +32,9 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + offtwall_state *state = (offtwall_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -47,9 +47,11 @@ static void update_interrupts(running_machine *machine) static MACHINE_RESET( offtwall ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); - atarivc_reset(machine->primary_screen, atarivc_eof_data, 1); + offtwall_state *state = (offtwall_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 1); atarijsa_reset(); } @@ -82,8 +84,9 @@ static WRITE16_HANDLER( offtwall_atarivc_w ) static READ16_HANDLER( special_port3_r ) { + offtwall_state *state = (offtwall_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); - if (atarigen_cpu_to_sound_ready) result ^= 0x0020; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0020; return result; } @@ -269,7 +272,7 @@ static READ16_HANDLER( unknown_verify_r ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x037fff) AM_ROM AM_RANGE(0x038000, 0x03ffff) AM_READ(bankrom_r) AM_REGION("maincpu", 0x38000) AM_BASE(&bankrom_base) - AM_RANGE(0x120000, 0x120fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x120000, 0x120fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(offtwall_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x260000, 0x260001) AM_READ_PORT("260000") AM_RANGE(0x260002, 0x260003) AM_READ_PORT("260002") AM_RANGE(0x260010, 0x260011) AM_READ(special_port3_r) @@ -283,11 +286,11 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x260060, 0x260061) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(offtwall_atarivc_r, offtwall_atarivc_w) AM_BASE(&atarivc_data) - AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE(&atarivc_eof_data) + AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(offtwall_atarivc_r, offtwall_atarivc_w) AM_BASE_MEMBER(offtwall_state, atarigen.atarivc_data) + AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE_MEMBER(offtwall_state, atarigen.playfield) + AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE_MEMBER(offtwall_state, atarigen.atarivc_eof_data) AM_RANGE(0x3f5f80, 0x3f5fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) - AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(offtwall_state, atarigen.playfield_upper) AM_RANGE(0x3f8000, 0x3fcfff) AM_RAM AM_RANGE(0x3fd000, 0x3fd7ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x3fd800, 0x3fffff) AM_RAM @@ -395,6 +398,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( offtwall ) + MDRV_DRIVER_DATA(offtwall_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -491,7 +495,9 @@ static const UINT16 default_eeprom[] = static DRIVER_INIT( offtwall ) { - atarigen_eeprom_default = default_eeprom; + offtwall_state *state = (offtwall_state *)machine->driver_data; + + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "260010", 0x0040); /* install son-of-slapstic workarounds */ @@ -503,7 +509,9 @@ static DRIVER_INIT( offtwall ) static DRIVER_INIT( offtwalc ) { - atarigen_eeprom_default = default_eeprom; + offtwall_state *state = (offtwall_state *)machine->driver_data; + + state->atarigen.eeprom_default = default_eeprom; atarijsa_init(machine, "260010", 0x0040); /* install son-of-slapstic workarounds */ diff --git a/src/mame/drivers/rampart.c b/src/mame/drivers/rampart.c index e340fb9971d..2720345601e 100644 --- a/src/mame/drivers/rampart.c +++ b/src/mame/drivers/rampart.c @@ -24,7 +24,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "rampart.h" #include "sound/okim6295.h" #include "sound/2413intf.h" @@ -41,7 +40,8 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + rampart_state *state = (rampart_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -62,9 +62,11 @@ static void scanline_update(const device_config *screen, int scanline) static MACHINE_RESET( rampart ) { - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + rampart_state *state = (rampart_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); } @@ -128,7 +130,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_GLOBAL_MASK(0x7fffff) AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x140000, 0x147fff) AM_MIRROR(0x438000) AM_ROM /* slapstic goes here */ - AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&rampart_bitmap) + AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(rampart_state, bitmap) AM_RANGE(0x220000, 0x3bffff) AM_WRITENOP /* the code blasts right through this when initializing */ AM_RANGE(0x3c0000, 0x3c07ff) AM_MIRROR(0x019800) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x3e0000, 0x3e07ff) AM_MIRROR(0x010000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) @@ -137,7 +139,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x3e3f80, 0x3effff) AM_MIRROR(0x010000) AM_RAM AM_RANGE(0x460000, 0x460001) AM_MIRROR(0x019ffe) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0xff00) AM_RANGE(0x480000, 0x480003) AM_MIRROR(0x019ffc) AM_DEVWRITE8("ymsnd", ym2413_w, 0xff00) - AM_RANGE(0x500000, 0x500fff) AM_MIRROR(0x019000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x500000, 0x500fff) AM_MIRROR(0x019000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(rampart_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x5a6000, 0x5a6001) AM_MIRROR(0x019ffe) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x640000, 0x640001) AM_MIRROR(0x019ffe) AM_WRITE(latch_w) AM_RANGE(0x640000, 0x640001) AM_MIRROR(0x019ffc) AM_READ_PORT("IN0") @@ -334,6 +336,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( rampart ) + MDRV_DRIVER_DATA(rampart_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK/2) @@ -486,9 +489,10 @@ static DRIVER_INIT( rampart ) 0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00, 0x0000 }; + rampart_state *state = (rampart_state *)machine->driver_data; UINT8 *rom = memory_region(machine, "maincpu"); - atarigen_eeprom_default = compressed_default_eeprom; + state->atarigen.eeprom_default = compressed_default_eeprom; memcpy(&rom[0x140000], &rom[0x40000], 0x8000); atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x140000, 0x438000, 118); } diff --git a/src/mame/drivers/relief.c b/src/mame/drivers/relief.c index 6125ab92453..d40b6405ac2 100644 --- a/src/mame/drivers/relief.c +++ b/src/mame/drivers/relief.c @@ -27,25 +27,14 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT8 ym2413_volume; -static UINT8 overall_volume; -static UINT32 adpcm_bank_base; - - - -/************************************* - * * Interrupt handling * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + relief_state *state = (relief_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -77,14 +66,16 @@ static WRITE16_HANDLER( relief_atarivc_w ) static MACHINE_RESET( relief ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); - atarivc_reset(machine->primary_screen, atarivc_eof_data, 2); + relief_state *state = (relief_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); okim6295_set_bank_base(devtag_get_device(machine, "oki"), 0); - ym2413_volume = 15; - overall_volume = 127; - adpcm_bank_base = 0; + state->ym2413_volume = 15; + state->overall_volume = 127; + state->adpcm_bank_base = 0; } @@ -97,8 +88,9 @@ static MACHINE_RESET( relief ) static READ16_HANDLER( special_port2_r ) { + relief_state *state = (relief_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); - if (atarigen_cpu_to_sound_ready) result ^= 0x0020; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0020; if (!(result & 0x0080) || atarigen_get_hblank(space->machine->primary_screen)) result ^= 0x0001; return result; } @@ -113,26 +105,28 @@ static READ16_HANDLER( special_port2_r ) static WRITE16_HANDLER( audio_control_w ) { + relief_state *state = (relief_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - ym2413_volume = (data >> 1) & 15; - atarigen_set_ym2413_vol(space->machine, (ym2413_volume * overall_volume * 100) / (127 * 15)); - adpcm_bank_base = (0x040000 * ((data >> 6) & 3)) | (adpcm_bank_base & 0x100000); + state->ym2413_volume = (data >> 1) & 15; + atarigen_set_ym2413_vol(space->machine, (state->ym2413_volume * state->overall_volume * 100) / (127 * 15)); + state->adpcm_bank_base = (0x040000 * ((data >> 6) & 3)) | (state->adpcm_bank_base & 0x100000); } if (ACCESSING_BITS_8_15) - adpcm_bank_base = (0x100000 * ((data >> 8) & 1)) | (adpcm_bank_base & 0x0c0000); + state->adpcm_bank_base = (0x100000 * ((data >> 8) & 1)) | (state->adpcm_bank_base & 0x0c0000); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), adpcm_bank_base); + okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), state->adpcm_bank_base); } static WRITE16_HANDLER( audio_volume_w ) { + relief_state *state = (relief_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - overall_volume = data & 127; - atarigen_set_ym2413_vol(space->machine, (ym2413_volume * overall_volume * 100) / (127 * 15)); - atarigen_set_oki6295_vol(space->machine, overall_volume * 100 / 127); + state->overall_volume = data & 127; + atarigen_set_ym2413_vol(space->machine, (state->ym2413_volume * state->overall_volume * 100) / (127 * 15)); + atarigen_set_oki6295_vol(space->machine, state->overall_volume * 100 / 127); } } @@ -152,7 +146,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x140010, 0x140011) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x140020, 0x140021) AM_WRITE(audio_volume_w) AM_RANGE(0x140030, 0x140031) AM_WRITE(audio_control_w) - AM_RANGE(0x180000, 0x180fff) AM_READWRITE(atarigen_eeprom_upper_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x180000, 0x180fff) AM_READWRITE(atarigen_eeprom_upper_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(relief_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x1c0030, 0x1c0031) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x260000, 0x260001) AM_READ_PORT("260000") AM_RANGE(0x260002, 0x260003) AM_READ_PORT("260002") @@ -160,13 +154,13 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x260012, 0x260013) AM_READ_PORT("260012") AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(relief_atarivc_r, relief_atarivc_w) AM_BASE(&atarivc_data) - AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE(&atarigen_playfield2) - AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(relief_atarivc_r, relief_atarivc_w) AM_BASE_MEMBER(relief_state, atarigen.atarivc_data) + AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(relief_state, atarigen.playfield2) + AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(relief_state, atarigen.playfield) + AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(relief_state, atarigen.playfield_upper) AM_RANGE(0x3f6000, 0x3f67ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x3f6800, 0x3f8eff) AM_RAM - AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE(&atarivc_eof_data) + AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE_MEMBER(relief_state, atarigen.atarivc_eof_data) AM_RANGE(0x3f8f80, 0x3f8fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0x3f9000, 0x3fffff) AM_RAM ADDRESS_MAP_END @@ -293,6 +287,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( relief ) + MDRV_DRIVER_DATA(relief_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -402,9 +397,10 @@ ROM_END static void init_common(running_machine *machine, const UINT16 *def_eeprom) { + relief_state *state = (relief_state *)machine->driver_data; UINT8 *sound_base = memory_region(machine, "oki"); - atarigen_eeprom_default = def_eeprom; + state->atarigen.eeprom_default = def_eeprom; /* expand the ADPCM data to avoid lots of memcpy's during gameplay */ /* the upper 128k is fixed, the lower 128k is bankswitched */ diff --git a/src/mame/drivers/shuuz.c b/src/mame/drivers/shuuz.c index 2b50a801734..0e66a3e2316 100644 --- a/src/mame/drivers/shuuz.c +++ b/src/mame/drivers/shuuz.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "shuuz.h" #include "sound/okim6295.h" @@ -33,7 +32,8 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + shuuz_state *state = (shuuz_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -65,9 +65,11 @@ static WRITE16_HANDLER( shuuz_atarivc_w ) static MACHINE_RESET( shuuz ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); - atarivc_reset(machine->primary_screen, atarivc_eof_data, 1); + shuuz_state *state = (shuuz_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 1); } @@ -131,7 +133,7 @@ static READ16_HANDLER( special_port0_r ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x100000, 0x100fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x100000, 0x100fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(shuuz_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x101000, 0x101fff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x102000, 0x102001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x103000, 0x103003) AM_READ(leta_r) @@ -140,11 +142,11 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x106000, 0x106001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x107000, 0x107007) AM_NOP AM_RANGE(0x3e0000, 0x3e087f) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(shuuz_atarivc_r, shuuz_atarivc_w) AM_BASE(&atarivc_data) - AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE(&atarivc_eof_data) + AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(shuuz_atarivc_r, shuuz_atarivc_w) AM_BASE_MEMBER(shuuz_state, atarigen.atarivc_data) + AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE_MEMBER(shuuz_state, atarigen.playfield) + AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE_MEMBER(shuuz_state, atarigen.atarivc_eof_data) AM_RANGE(0x3f5f80, 0x3f5fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) - AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(shuuz_state, atarigen.playfield_upper) AM_RANGE(0x3f8000, 0x3fcfff) AM_RAM AM_RANGE(0x3fd000, 0x3fd3ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0x3fd400, 0x3fffff) AM_RAM @@ -251,6 +253,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( shuuz ) + MDRV_DRIVER_DATA(shuuz_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -346,22 +349,9 @@ ROM_END /************************************* * - * Driver init - * - *************************************/ - -static DRIVER_INIT( shuuz ) -{ - atarigen_eeprom_default = NULL; -} - - - -/************************************* - * * Game driver(s) * *************************************/ -GAME( 1990, shuuz, 0, shuuz, shuuz, shuuz, ROT0, "Atari Games", "Shuuz (version 8.0)", 0 ) -GAME( 1990, shuuz2, shuuz, shuuz, shuuz2, shuuz, ROT0, "Atari Games", "Shuuz (version 7.1)", 0 ) +GAME( 1990, shuuz, 0, shuuz, shuuz, 0, ROT0, "Atari Games", "Shuuz (version 8.0)", 0 ) +GAME( 1990, shuuz2, shuuz, shuuz, shuuz2, 0, ROT0, "Atari Games", "Shuuz (version 7.1)", 0 ) diff --git a/src/mame/drivers/skullxbo.c b/src/mame/drivers/skullxbo.c index 98af4eee8f4..e2f174a9c43 100644 --- a/src/mame/drivers/skullxbo.c +++ b/src/mame/drivers/skullxbo.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "skullxbo.h" @@ -33,9 +32,10 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 4, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + skullxbo_state *state = (skullxbo_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } @@ -47,11 +47,12 @@ static TIMER_CALLBACK( irq_gen ) static void alpha_row_update(const device_config *screen, int scanline) { - UINT16 *check = &atarigen_alpha[(scanline / 8) * 64 + 42]; + skullxbo_state *state = (skullxbo_state *)screen->machine->driver_data; + UINT16 *check = &state->atarigen.alpha[(scanline / 8) * 64 + 42]; /* check for interrupts in the alpha ram */ /* the interrupt occurs on the HBLANK of the 6th scanline following */ - if (check < &atarigen_alpha[0x7c0] && (*check & 0x8000)) + if (check < &state->atarigen.alpha[0x7c0] && (*check & 0x8000)) { int width = video_screen_get_width(screen); attotime period = video_screen_get_time_until_pos(screen, video_screen_get_vpos(screen) + 6, width * 0.9); @@ -71,8 +72,10 @@ static WRITE16_HANDLER( skullxbo_halt_until_hblank_0_w ) static MACHINE_RESET( skullxbo ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + skullxbo_state *state = (skullxbo_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, alpha_row_update, 8); atarijsa_reset(); } @@ -87,8 +90,9 @@ static MACHINE_RESET( skullxbo ) static READ16_HANDLER( special_port1_r ) { + skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "FF5802"); - if (atarigen_cpu_to_sound_ready) temp ^= 0x0040; + if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0040; if (atarigen_get_hblank(space->machine->primary_screen)) temp ^= 0x0010; return temp; } @@ -123,7 +127,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xff1400, 0xff17ff) AM_WRITE(atarigen_sound_w) AM_RANGE(0xff1800, 0xff1bff) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0xff1c00, 0xff1c7f) AM_WRITE(skullxbo_playfieldlatch_w) - AM_RANGE(0xff1c80, 0xff1cff) AM_WRITE(skullxbo_xscroll_w) AM_BASE(&atarigen_xscroll) + AM_RANGE(0xff1c80, 0xff1cff) AM_WRITE(skullxbo_xscroll_w) AM_BASE_MEMBER(skullxbo_state, atarigen.xscroll) AM_RANGE(0xff1d00, 0xff1d7f) AM_WRITE(atarigen_scanline_int_ack_w) AM_RANGE(0xff1d80, 0xff1dff) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xff1e00, 0xff1e7f) AM_WRITE(skullxbo_playfieldlatch_w) @@ -131,16 +135,16 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xff1f00, 0xff1f7f) AM_WRITE(atarigen_scanline_int_ack_w) AM_RANGE(0xff1f80, 0xff1fff) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xff4000, 0xff47ff) AM_WRITE(skullxbo_yscroll_w) AM_BASE(&atarigen_yscroll) + AM_RANGE(0xff4000, 0xff47ff) AM_WRITE(skullxbo_yscroll_w) AM_BASE_MEMBER(skullxbo_state, atarigen.yscroll) AM_RANGE(0xff4800, 0xff4fff) AM_WRITE(skullxbo_mobwr_w) - AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xff6000, 0xff6fff) AM_WRITE(atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(skullxbo_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xff5000, 0xff5001) AM_READ(atarigen_sound_r) AM_RANGE(0xff5800, 0xff5801) AM_READ_PORT("FF5800") AM_RANGE(0xff5802, 0xff5803) AM_READ(special_port1_r) AM_RANGE(0xff6000, 0xff6fff) AM_READ(atarigen_eeprom_r) - AM_RANGE(0xff8000, 0xff9fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0xffa000, 0xffbfff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE(&atarigen_playfield_upper) - AM_RANGE(0xffc000, 0xffcf7f) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xff8000, 0xff9fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(skullxbo_state, atarigen.playfield) + AM_RANGE(0xffa000, 0xffbfff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(skullxbo_state, atarigen.playfield_upper) + AM_RANGE(0xffc000, 0xffcf7f) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(skullxbo_state, atarigen.alpha) AM_RANGE(0xffcf80, 0xffcfff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xffe000, 0xffffff) AM_RAM @@ -244,6 +248,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( skullxbo ) + MDRV_DRIVER_DATA(skullxbo_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -608,7 +613,6 @@ ROM_END static DRIVER_INIT( skullxbo ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "FF5802", 0x0080); memset(memory_region(machine, "gfx1") + 0x170000, 0, 0x20000); } diff --git a/src/mame/drivers/thunderj.c b/src/mame/drivers/thunderj.c index e367aced501..e101053646c 100644 --- a/src/mame/drivers/thunderj.c +++ b/src/mame/drivers/thunderj.c @@ -33,17 +33,20 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "extra", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + thunderj_state *state = (thunderj_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "extra", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( thunderj ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); - atarivc_reset(machine->primary_screen, atarivc_eof_data, 2); + thunderj_state *state = (thunderj_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); + atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); atarijsa_reset(); } @@ -57,10 +60,11 @@ static MACHINE_RESET( thunderj ) static READ16_HANDLER( special_port2_r ) { + thunderj_state *state = (thunderj_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260012"); - if (atarigen_sound_to_cpu_ready) result ^= 0x0004; - if (atarigen_cpu_to_sound_ready) result ^= 0x0008; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x0004; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0008; result ^= 0x0010; return result; @@ -69,6 +73,8 @@ static READ16_HANDLER( special_port2_r ) static WRITE16_HANDLER( latch_w ) { + thunderj_state *state = (thunderj_state *)space->machine->driver_data; + /* reset extra CPU */ if (ACCESSING_BITS_0_7) { @@ -79,11 +85,11 @@ static WRITE16_HANDLER( latch_w ) cputag_set_input_line(space->machine, "extra", INPUT_LINE_RESET, ASSERT_LINE); /* bits 2-5 are the alpha bank */ - if (thunderj_alpha_tile_bank != ((data >> 2) & 7)) + if (state->alpha_tile_bank != ((data >> 2) & 7)) { video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); - tilemap_mark_all_tiles_dirty(atarigen_alpha_tilemap); - thunderj_alpha_tile_bank = (data >> 2) & 7; + tilemap_mark_all_tiles_dirty(state->atarigen.alpha_tilemap); + state->alpha_tile_bank = (data >> 2) & 7; } } } @@ -137,7 +143,7 @@ static WRITE16_HANDLER( thunderj_atarivc_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x09ffff) AM_ROM - AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(thunderj_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x160000, 0x16ffff) AM_RAM AM_SHARE("share1") AM_RANGE(0x1f0000, 0x1fffff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x260000, 0x26000f) AM_READ_PORT("260000") @@ -149,13 +155,13 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x360020, 0x360021) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM_WRITE(atarigen_666_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(thunderj_atarivc_r, thunderj_atarivc_w) AM_BASE(&atarivc_data) - AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE(&atarigen_playfield2) - AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE(&atarigen_playfield_upper) + AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(thunderj_atarivc_r, thunderj_atarivc_w) AM_BASE_MEMBER(thunderj_state, atarigen.atarivc_data) + AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(thunderj_state, atarigen.playfield2) + AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(thunderj_state, atarigen.playfield) + AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(thunderj_state, atarigen.playfield_upper) AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0x3f8000, 0x3f8eff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) - AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE(&atarivc_eof_data) + AM_RANGE(0x3f8000, 0x3f8eff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(thunderj_state, atarigen.alpha) + AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE_MEMBER(thunderj_state, atarigen.atarivc_eof_data) AM_RANGE(0x3f8f80, 0x3f8fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0x3f9000, 0x3fffff) AM_RAM ADDRESS_MAP_END @@ -269,6 +275,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( thunderj ) + MDRV_DRIVER_DATA(thunderj_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -396,7 +403,6 @@ ROM_END static DRIVER_INIT( thunderj ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "260012", 0x0002); } diff --git a/src/mame/drivers/toobin.c b/src/mame/drivers/toobin.c index a2594c42340..c8b056c165e 100644 --- a/src/mame/drivers/toobin.c +++ b/src/mame/drivers/toobin.c @@ -29,32 +29,25 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT16 *interrupt_scan; - - - -/************************************* - * * Initialization & interrupts * *************************************/ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 3, atarigen_scanline_int_state && atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + toobin_state *state = (toobin_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 3, state->atarigen.scanline_int_state && state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( toobin ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + toobin_state *state = (toobin_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarijsa_reset(); } @@ -68,14 +61,15 @@ static MACHINE_RESET( toobin ) static WRITE16_HANDLER( interrupt_scan_w ) { - int oldword = interrupt_scan[offset]; + toobin_state *state = (toobin_state *)space->machine->driver_data; + int oldword = state->interrupt_scan[offset]; int newword = oldword; COMBINE_DATA(&newword); /* if something changed, update the word in memory */ if (oldword != newword) { - interrupt_scan[offset] = newword; + state->interrupt_scan[offset] = newword; atarigen_scanline_int_set(space->machine->primary_screen, newword & 0x1ff); } } @@ -90,9 +84,10 @@ static WRITE16_HANDLER( interrupt_scan_w ) static READ16_HANDLER( special_port1_r ) { + toobin_state *state = (toobin_state *)space->machine->driver_data; int result = input_port_read(space->machine, "FF9000"); if (atarigen_get_hblank(space->machine->primary_screen)) result ^= 0x8000; - if (atarigen_cpu_to_sound_ready) result ^= 0x2000; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x2000; return result; } @@ -108,25 +103,25 @@ static READ16_HANDLER( special_port1_r ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_GLOBAL_MASK(0xc7ffff) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0xc00000, 0xc07fff) AM_RAM_WRITE(atarigen_playfield_large_w) AM_BASE(&atarigen_playfield) - AM_RANGE(0xc08000, 0xc097ff) AM_MIRROR(0x046000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xc00000, 0xc07fff) AM_RAM_WRITE(atarigen_playfield_large_w) AM_BASE_MEMBER(toobin_state, atarigen.playfield) + AM_RANGE(0xc08000, 0xc097ff) AM_MIRROR(0x046000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(toobin_state, atarigen.alpha) AM_RANGE(0xc09800, 0xc09fff) AM_MIRROR(0x046000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) AM_RANGE(0xc10000, 0xc107ff) AM_MIRROR(0x047800) AM_RAM_WRITE(toobin_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xff6000, 0xff6001) AM_READNOP /* who knows? read at controls time */ AM_RANGE(0xff8000, 0xff8001) AM_MIRROR(0x4500fe) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xff8100, 0xff8101) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_sound_w) AM_RANGE(0xff8300, 0xff8301) AM_MIRROR(0x45003e) AM_WRITE(toobin_intensity_w) - AM_RANGE(0xff8340, 0xff8341) AM_MIRROR(0x45003e) AM_WRITE(interrupt_scan_w) AM_BASE(&interrupt_scan) + AM_RANGE(0xff8340, 0xff8341) AM_MIRROR(0x45003e) AM_WRITE(interrupt_scan_w) AM_BASE_MEMBER(toobin_state, interrupt_scan) AM_RANGE(0xff8380, 0xff8381) AM_MIRROR(0x45003e) AM_WRITE(toobin_slip_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0xff83c0, 0xff83c1) AM_MIRROR(0x45003e) AM_WRITE(atarigen_scanline_int_ack_w) AM_RANGE(0xff8400, 0xff8401) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0xff8500, 0xff8501) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_eeprom_enable_w) - AM_RANGE(0xff8600, 0xff8601) AM_MIRROR(0x4500fe) AM_WRITE(toobin_xscroll_w) AM_BASE(&atarigen_xscroll) - AM_RANGE(0xff8700, 0xff8701) AM_MIRROR(0x4500fe) AM_WRITE(toobin_yscroll_w) AM_BASE(&atarigen_yscroll) + AM_RANGE(0xff8600, 0xff8601) AM_MIRROR(0x4500fe) AM_WRITE(toobin_xscroll_w) AM_BASE_MEMBER(toobin_state, atarigen.xscroll) + AM_RANGE(0xff8700, 0xff8701) AM_MIRROR(0x4500fe) AM_WRITE(toobin_yscroll_w) AM_BASE_MEMBER(toobin_state, atarigen.yscroll) AM_RANGE(0xff8800, 0xff8801) AM_MIRROR(0x4507fe) AM_READ_PORT("FF8800") AM_RANGE(0xff9000, 0xff9001) AM_MIRROR(0x4507fe) AM_READ(special_port1_r) AM_RANGE(0xff9800, 0xff9801) AM_MIRROR(0x4507fe) AM_READ(atarigen_sound_r) - AM_RANGE(0xffa000, 0xffafff) AM_MIRROR(0x451000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xffa000, 0xffafff) AM_MIRROR(0x451000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(toobin_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xffc000, 0xffffff) AM_MIRROR(0x450000) AM_RAM ADDRESS_MAP_END @@ -223,6 +218,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( toobin ) + MDRV_DRIVER_DATA(toobin_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68010, MASTER_CLOCK/4) @@ -602,7 +598,6 @@ ROM_END static DRIVER_INIT( toobin ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "FF9000", 0x1000); } diff --git a/src/mame/drivers/vindictr.c b/src/mame/drivers/vindictr.c index e387a80ecf2..7b6f8f70561 100644 --- a/src/mame/drivers/vindictr.c +++ b/src/mame/drivers/vindictr.c @@ -19,7 +19,6 @@ #include "driver.h" #include "cpu/m68000/m68000.h" -#include "machine/atarigen.h" #include "audio/atarijsa.h" #include "vindictr.h" @@ -33,15 +32,18 @@ static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 4, atarigen_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + vindictr_state *state = (vindictr_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 4, state->atarigen.scanline_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 6, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( vindictr ) { - atarigen_eeprom_reset(); - atarigen_interrupt_reset(update_interrupts); + vindictr_state *state = (vindictr_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, vindictr_scanline_update, 8); atarijsa_reset(); } @@ -56,9 +58,10 @@ static MACHINE_RESET( vindictr ) static READ16_HANDLER( port1_r ) { + vindictr_state *state = (vindictr_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); - if (atarigen_sound_to_cpu_ready) result ^= 0x0004; - if (atarigen_cpu_to_sound_ready) result ^= 0x0008; + if (state->atarigen.sound_to_cpu_ready) result ^= 0x0004; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0008; result ^= 0x0010; return result; } @@ -75,7 +78,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_GLOBAL_MASK(0x3fffff) AM_RANGE(0x000000, 0x05ffff) AM_ROM - AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0x0e0000, 0x0e0fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(vindictr_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0x1f0000, 0x1fffff) AM_WRITE(atarigen_eeprom_enable_w) AM_RANGE(0x260000, 0x26000f) AM_READ_PORT("260000") AM_RANGE(0x260010, 0x26001f) AM_READ(port1_r) @@ -87,9 +90,9 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x360020, 0x360021) AM_WRITE(atarigen_sound_reset_w) AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w) AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM_WRITE(vindictr_paletteram_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(vindictr_state, atarigen.playfield) AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0x3f4000, 0x3f4f7f) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0x3f4000, 0x3f4f7f) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(vindictr_state, atarigen.alpha) AM_RANGE(0x3f4f80, 0x3f4fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram) AM_RANGE(0x3f5000, 0x3f7fff) AM_MIRROR(0x8000) AM_RAM ADDRESS_MAP_END @@ -185,6 +188,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( vindictr ) + MDRV_DRIVER_DATA(vindictr_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2) @@ -532,7 +536,6 @@ ROM_END static DRIVER_INIT( vindictr ) { - atarigen_eeprom_default = NULL; atarijsa_init(machine, "260010", 0x0002); } diff --git a/src/mame/drivers/xybots.c b/src/mame/drivers/xybots.c index f613681ce62..55e4f868433 100644 --- a/src/mame/drivers/xybots.c +++ b/src/mame/drivers/xybots.c @@ -23,8 +23,6 @@ #include "audio/atarijsa.h" #include "xybots.h" -static int h256; - /************************************* @@ -35,16 +33,19 @@ static int h256; static void update_interrupts(running_machine *machine) { - cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); + xybots_state *state = (xybots_state *)machine->driver_data; + cputag_set_input_line(machine, "maincpu", 1, state->atarigen.video_int_state ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(machine, "maincpu", 2, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); } static MACHINE_RESET( xybots ) { - atarigen_eeprom_reset(); - atarigen_slapstic_reset(); - atarigen_interrupt_reset(update_interrupts); + xybots_state *state = (xybots_state *)machine->driver_data; + + atarigen_eeprom_reset(&state->atarigen); + atarigen_slapstic_reset(&state->atarigen); + atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarijsa_reset(); } @@ -58,10 +59,11 @@ static MACHINE_RESET( xybots ) static READ16_HANDLER( special_port1_r ) { + xybots_state *state = (xybots_state *)space->machine->driver_data; int result = input_port_read(space->machine, "FFE200"); - if (atarigen_cpu_to_sound_ready) result ^= 0x0200; - result ^= h256 ^= 0x0400; + if (state->atarigen.cpu_to_sound_ready) result ^= 0x0200; + result ^= state->h256 ^= 0x0400; return result; } @@ -79,12 +81,12 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x007fff) AM_MIRROR(0x7c0000) AM_ROM AM_RANGE(0x008000, 0x00ffff) AM_MIRROR(0x7c0000) AM_ROM /* slapstic maps here */ AM_RANGE(0x010000, 0x03ffff) AM_MIRROR(0x7c0000) AM_ROM - AM_RANGE(0xff8000, 0xff8fff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE(&atarigen_alpha) + AM_RANGE(0xff8000, 0xff8fff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(xybots_state, atarigen.alpha) AM_RANGE(0xff9000, 0xffadff) AM_MIRROR(0x7f8000) AM_RAM AM_RANGE(0xffae00, 0xffafff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram) - AM_RANGE(0xffb000, 0xffbfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE(&atarigen_playfield) + AM_RANGE(0xffb000, 0xffbfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(xybots_state, atarigen.playfield) AM_RANGE(0xffc000, 0xffc7ff) AM_MIRROR(0x7f8800) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE(&atarigen_eeprom) AM_SIZE(&atarigen_eeprom_size) + AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_BASE_SIZE_MEMBER(xybots_state, atarigen.eeprom, atarigen.eeprom_size) AM_RANGE(0xffe000, 0xffe0ff) AM_MIRROR(0x7f8000) AM_READ(atarigen_sound_r) AM_RANGE(0xffe100, 0xffe1ff) AM_MIRROR(0x7f8000) AM_READ_PORT("FFE100") AM_RANGE(0xffe200, 0xffe2ff) AM_MIRROR(0x7f8000) AM_READ(special_port1_r) @@ -184,6 +186,7 @@ GFXDECODE_END *************************************/ static MACHINE_DRIVER_START( xybots ) + MDRV_DRIVER_DATA(xybots_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) @@ -383,8 +386,8 @@ ROM_END static DRIVER_INIT( xybots ) { - h256 = 0x0400; - atarigen_eeprom_default = NULL; + xybots_state *state = (xybots_state *)machine->driver_data; + state->h256 = 0x0400; atarigen_slapstic_init(cputag_get_cpu(machine, "maincpu"), 0x008000, 0, 107); atarijsa_init(machine, "FFE200", 0x0100); } diff --git a/src/mame/includes/atarig1.h b/src/mame/includes/atarig1.h index 711f601148f..dfcac38189f 100644 --- a/src/mame/includes/atarig1.h +++ b/src/mame/includes/atarig1.h @@ -4,6 +4,30 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _atarig1_state atarig1_state; +struct _atarig1_state +{ + atarigen_state atarigen; + UINT8 is_pitfight; + + UINT8 which_input; + UINT16 * mo_command; + + UINT16 * bslapstic_base; + void * bslapstic_bank0; + UINT8 bslapstic_bank; + UINT8 bslapstic_primed; + + int pfscroll_xoffset; + UINT16 current_control; + UINT8 playfield_tile_bank; + UINT16 playfield_xscroll; + UINT16 playfield_yscroll; +}; + + /*----------- defined in video/atarig1.c -----------*/ WRITE16_HANDLER( atarig1_mo_control_w ); @@ -12,5 +36,3 @@ VIDEO_START( atarig1 ); VIDEO_UPDATE( atarig1 ); void atarig1_scanline_update(const device_config *screen, int scanline); - -extern UINT8 atarig1_pitfight; diff --git a/src/mame/includes/atarig42.h b/src/mame/includes/atarig42.h index 7f245f53cf8..5f3ee49daaf 100644 --- a/src/mame/includes/atarig42.h +++ b/src/mame/includes/atarig42.h @@ -4,11 +4,34 @@ *************************************************************************/ -/*----------- defined in video/atarig42.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _atarig42_state atarig42_state; +struct _atarig42_state +{ + atarigen_state atarigen; + UINT16 playfield_base; + UINT16 motion_object_base; + UINT16 motion_object_mask; + + UINT16 current_control; + UINT8 playfield_tile_bank; + UINT8 playfield_color_bank; + UINT16 playfield_xscroll; + UINT16 playfield_yscroll; + + UINT8 analog_data; + UINT16 * mo_command; -extern UINT16 atarig42_playfield_base; -extern UINT16 atarig42_motion_object_base; -extern UINT16 atarig42_motion_object_mask; + int sloop_bank; + int sloop_next_bank; + int sloop_offset; + int sloop_state; + UINT16 * sloop_base; +}; + + +/*----------- defined in video/atarig42.c -----------*/ VIDEO_START( atarig42 ); VIDEO_UPDATE( atarig42 ); diff --git a/src/mame/includes/atarigt.h b/src/mame/includes/atarigt.h index e9cd1e85c8e..ccdc8b50331 100644 --- a/src/mame/includes/atarigt.h +++ b/src/mame/includes/atarigt.h @@ -4,17 +4,43 @@ *************************************************************************/ -/*----------- defined in drivers/atarigt.c -----------*/ +#include "machine/atarigen.h" -extern UINT8 atarigt_is_primrage; +#define CRAM_ENTRIES 0x4000 +#define TRAM_ENTRIES 0x4000 +#define MRAM_ENTRIES 0x8000 -/*----------- defined in video/atarigt.c -----------*/ +typedef struct _atarigt_state atarigt_state; +struct _atarigt_state +{ + atarigen_state atarigen; + UINT8 is_primrage; + UINT16 * colorram; + + bitmap_t * pf_bitmap; + bitmap_t * an_bitmap; + + UINT8 playfield_tile_bank; + UINT8 playfield_color_bank; + UINT16 playfield_xscroll; + UINT16 playfield_yscroll; + + UINT32 tram_checksum; + + UINT32 expanded_mram[MRAM_ENTRIES * 3]; -extern UINT16 *atarigt_colorram; + UINT32 * mo_command; + + void (*protection_w)(const address_space *space, offs_t offset, UINT16 data); + void (*protection_r)(const address_space *space, offs_t offset, UINT16 *data); +}; + + +/*----------- defined in video/atarigt.c -----------*/ -void atarigt_colorram_w(offs_t address, UINT16 data, UINT16 mem_mask); -UINT16 atarigt_colorram_r(offs_t address); +void atarigt_colorram_w(atarigt_state *state, offs_t address, UINT16 data, UINT16 mem_mask); +UINT16 atarigt_colorram_r(atarigt_state *state, offs_t address); VIDEO_START( atarigt ); VIDEO_UPDATE( atarigt ); diff --git a/src/mame/includes/atarigx2.h b/src/mame/includes/atarigx2.h index 942bb79c580..1f8d20422c3 100644 --- a/src/mame/includes/atarigx2.h +++ b/src/mame/includes/atarigx2.h @@ -1,14 +1,31 @@ /************************************************************************* - Atari G42 hardware + Atari GX2 hardware *************************************************************************/ -/*----------- defined in video/atarigx2.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _atarigx2_state atarigx2_state; +struct _atarigx2_state +{ + atarigen_state atarigen; + UINT16 playfield_base; + UINT16 motion_object_base; + UINT16 motion_object_mask; + + UINT32 * mo_command; + UINT32 * protection_base; -extern UINT16 atarigx2_playfield_base; -extern UINT16 atarigx2_motion_object_base; -extern UINT16 atarigx2_motion_object_mask; + UINT16 current_control; + UINT8 playfield_tile_bank; + UINT8 playfield_color_bank; + UINT16 playfield_xscroll; + UINT16 playfield_yscroll; +}; + + +/*----------- defined in video/atarigx2.c -----------*/ VIDEO_START( atarigx2 ); VIDEO_UPDATE( atarigx2 ); diff --git a/src/mame/includes/atarisy1.h b/src/mame/includes/atarisy1.h index be134856ae9..baeb2245238 100644 --- a/src/mame/includes/atarisy1.h +++ b/src/mame/includes/atarisy1.h @@ -4,9 +4,45 @@ *************************************************************************/ -/*----------- defined in video/atarisy1.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _atarisy1_state atarisy1_state; +struct _atarisy1_state +{ + atarigen_state atarigen; + + UINT16 * bankselect; + + UINT8 joystick_type; + UINT8 trackball_type; + + emu_timer * joystick_timer; + UINT8 joystick_int; + UINT8 joystick_int_enable; + UINT8 joystick_value; + + UINT8 tms5220_out_data; + UINT8 tms5220_in_data; + UINT8 tms5220_ctl; -extern UINT16 *atarisy1_bankselect; + /* playfield parameters */ + UINT16 playfield_lookup[256]; + UINT8 playfield_tile_bank; + UINT16 playfield_priority_pens; + emu_timer * yscroll_reset_timer; + + /* INT3 tracking */ + int next_timer_scanline; + emu_timer * scanline_timer; + emu_timer * int3off_timer; + + /* graphics bank tracking */ + UINT8 bank_gfx[3][8]; + UINT8 bank_color_shift[MAX_GFX_ELEMENTS]; +}; + + +/*----------- defined in video/atarisy1.c -----------*/ READ16_HANDLER( atarisy1_int3state_r ); diff --git a/src/mame/includes/atarisy2.h b/src/mame/includes/atarisy2.h index a8ff1279b41..1f1d61a25c6 100644 --- a/src/mame/includes/atarisy2.h +++ b/src/mame/includes/atarisy2.h @@ -4,6 +4,41 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _atarisy2_state atarisy2_state; +struct _atarisy2_state +{ + atarigen_state atarigen; + + UINT16 * slapstic_base; + + UINT8 interrupt_enable; + UINT16 * bankselect; + + INT8 pedal_count; + + UINT8 has_tms5220; + UINT8 tms5220_data; + UINT8 tms5220_data_strobe; + + UINT8 which_adc; + + UINT8 p2portwr_state; + UINT8 p2portrd_state; + + UINT16 * rombank1; + UINT16 * rombank2; + + UINT8 sound_reset_state; + + emu_timer * yscroll_reset_timer; + UINT32 playfield_tile_bank[2]; + UINT32 videobank; + UINT16 vram[0x8000/2]; +}; + + /*----------- defined in video/atarisy2.c -----------*/ READ16_HANDLER( atarisy2_slapstic_r ); @@ -17,5 +52,3 @@ WRITE16_HANDLER( atarisy2_paletteram_w ); VIDEO_START( atarisy2 ); VIDEO_UPDATE( atarisy2 ); - -extern UINT16 *atarisy2_slapstic; diff --git a/src/mame/includes/badlands.h b/src/mame/includes/badlands.h index 77a077aacbc..1a61c09725f 100644 --- a/src/mame/includes/badlands.h +++ b/src/mame/includes/badlands.h @@ -4,6 +4,22 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _badlands_state badlands_state; +struct _badlands_state +{ + atarigen_state atarigen; + + UINT8 pedal_value[2]; + + UINT8 * bank_base; + UINT8 * bank_source_data; + + UINT8 playfield_tile_bank; +}; + + /*----------- defined in video/badlands.c -----------*/ WRITE16_HANDLER( badlands_pf_bank_w ); diff --git a/src/mame/includes/batman.h b/src/mame/includes/batman.h index e2298b36908..8a410420d3c 100644 --- a/src/mame/includes/batman.h +++ b/src/mame/includes/batman.h @@ -4,9 +4,20 @@ *************************************************************************/ -/*----------- defined in video/batman.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _batman_state batman_state; +struct _batman_state +{ + atarigen_state atarigen; + + UINT16 latch_data; -extern UINT8 batman_alpha_tile_bank; + UINT8 alpha_tile_bank; +}; + + +/*----------- defined in video/batman.c -----------*/ VIDEO_START( batman ); VIDEO_UPDATE( batman ); diff --git a/src/mame/includes/beathead.h b/src/mame/includes/beathead.h index 134e9566ab3..e5498e0b02b 100644 --- a/src/mame/includes/beathead.h +++ b/src/mame/includes/beathead.h @@ -4,10 +4,19 @@ *************************************************************************/ -/*----------- defined in video/beathead.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _beathead_state beathead_state; +struct _beathead_state +{ + atarigen_state atarigen; + + UINT32 * vram_bulk_latch; + UINT32 * palette_select; +}; -extern UINT32 * beathead_vram_bulk_latch; -extern UINT32 * beathead_palette_select; + +/*----------- defined in video/beathead.c -----------*/ VIDEO_START( beathead ); VIDEO_UPDATE( beathead ); diff --git a/src/mame/includes/blstroid.h b/src/mame/includes/blstroid.h index 2ecc14665fe..c6c338760c6 100644 --- a/src/mame/includes/blstroid.h +++ b/src/mame/includes/blstroid.h @@ -4,11 +4,20 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _blstroid_state blstroid_state; +struct _blstroid_state +{ + atarigen_state atarigen; + + UINT16 * priorityram; +}; + + /*----------- defined in video/blstroid.c -----------*/ VIDEO_START( blstroid ); VIDEO_UPDATE( blstroid ); void blstroid_scanline_update(const device_config *screen, int scanline); - -extern UINT16 *blstroid_priorityram; diff --git a/src/mame/includes/cyberbal.h b/src/mame/includes/cyberbal.h index 840154ae0ff..d2376c81155 100644 --- a/src/mame/includes/cyberbal.h +++ b/src/mame/includes/cyberbal.h @@ -4,6 +4,30 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _cyberbal_state cyberbal_state; +struct _cyberbal_state +{ + atarigen_state atarigen; + + UINT16 * paletteram_0; + UINT16 * paletteram_1; + UINT16 current_slip[2]; + UINT8 playfield_palette_bank[2]; + UINT16 playfield_xscroll[2]; + UINT16 playfield_yscroll[2]; + + UINT8 * bank_base; + UINT8 fast_68k_int; + UINT8 io_68k_int; + UINT8 sound_data_from_68k; + UINT8 sound_data_from_6502; + UINT8 sound_data_from_68k_ready; + UINT8 sound_data_from_6502_ready; +}; + + /*----------- defined in audio/cyberbal.c -----------*/ @@ -35,6 +59,3 @@ VIDEO_START( cyberb2p ); VIDEO_UPDATE( cyberbal ); void cyberbal_scanline_update(const device_config *screen, int scanline); - -extern UINT16 *cyberbal_paletteram_0; -extern UINT16 *cyberbal_paletteram_1; diff --git a/src/mame/includes/eprom.h b/src/mame/includes/eprom.h index 12b888a21d9..2f88eaaec01 100644 --- a/src/mame/includes/eprom.h +++ b/src/mame/includes/eprom.h @@ -4,6 +4,18 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _eprom_state eprom_state; +struct _eprom_state +{ + atarigen_state atarigen; + int screen_intensity; + int video_disable; + UINT16 * sync_data; +}; + + /*----------- defined in video/eprom.c -----------*/ VIDEO_START( eprom ); @@ -13,6 +25,3 @@ VIDEO_START( guts ); VIDEO_UPDATE( guts ); void eprom_scanline_update(const device_config *screen, int scanline); - -extern int eprom_screen_intensity; -extern int eprom_video_disable; diff --git a/src/mame/includes/foodf.h b/src/mame/includes/foodf.h index 7bf0415c4c8..6c4d42efea0 100644 --- a/src/mame/includes/foodf.h +++ b/src/mame/includes/foodf.h @@ -4,10 +4,27 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _foodf_state foodf_state; +struct _foodf_state +{ + atarigen_state atarigen; + + double rweights[3]; + double gweights[3]; + double bweights[2]; + UINT8 playfield_flip; + + emu_timer * scanline_timer; + UINT8 whichport; +}; + + /*----------- defined in video/foodf.c -----------*/ WRITE16_HANDLER( foodf_paletteram_w ); -void foodf_set_flip(int flip); +void foodf_set_flip(foodf_state *state, int flip); VIDEO_START( foodf ); VIDEO_UPDATE( foodf ); diff --git a/src/mame/includes/gauntlet.h b/src/mame/includes/gauntlet.h index b47ab9c3738..e16d841a66a 100644 --- a/src/mame/includes/gauntlet.h +++ b/src/mame/includes/gauntlet.h @@ -4,9 +4,20 @@ *************************************************************************/ -/*----------- defined in video/gauntlet.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _gauntlet_state gauntlet_state; +struct _gauntlet_state +{ + atarigen_state atarigen; + UINT16 sound_reset_val; + UINT8 vindctr2_screen_refresh; + UINT8 playfield_tile_bank; + UINT8 playfield_color_bank; +}; -extern UINT8 vindctr2_screen_refresh; + +/*----------- defined in video/gauntlet.c -----------*/ WRITE16_HANDLER( gauntlet_xscroll_w ); WRITE16_HANDLER( gauntlet_yscroll_w ); diff --git a/src/mame/includes/harddriv.h b/src/mame/includes/harddriv.h index 0708f950862..723cefebf4a 100644 --- a/src/mame/includes/harddriv.h +++ b/src/mame/includes/harddriv.h @@ -5,49 +5,160 @@ **************************************************************************/ #include "cpu/tms34010/tms34010.h" +#include "machine/atarigen.h" + +typedef struct _harddriv_state harddriv_state; +struct _harddriv_state +{ + atarigen_state atarigen; + + const device_config * maincpu; + const device_config * gsp; + const device_config * msp; + const device_config * adsp; + const device_config * soundcpu; + const device_config * sounddsp; + const device_config * jsacpu; + const device_config * dsp32; + + UINT8 hd34010_host_access; + UINT8 dsk_pio_access; + + UINT16 * msp_ram; + UINT16 * dsk_ram; + UINT16 * dsk_rom; + UINT16 * dsk_zram; + UINT16 * m68k_slapstic_base; + UINT16 * m68k_sloop_alt_base; + + UINT16 * adsp_data_memory; + UINT32 * adsp_pgm_memory; + + UINT16 * gsp_protection; + UINT16 * stmsp_sync[3]; + + UINT16 * gsp_speedup_addr[2]; + offs_t gsp_speedup_pc; + + UINT16 * msp_speedup_addr; + offs_t msp_speedup_pc; + + UINT16 * ds3_speedup_addr; + offs_t ds3_speedup_pc; + offs_t ds3_transfer_pc; + + UINT32 * rddsp32_sync[2]; + + UINT32 gsp_speedup_count[4]; + UINT32 msp_speedup_count[4]; + UINT32 adsp_speedup_count[4]; + + UINT16 * sounddsp_ram; + + UINT8 gsp_multisync; + UINT8 * gsp_vram; + UINT16 * gsp_control_lo; + UINT16 * gsp_control_hi; + UINT16 * gsp_paletteram_lo; + UINT16 * gsp_paletteram_hi; + size_t gsp_vram_size; + + /* driver state */ + UINT32 * rddsp32_speedup; + offs_t rddsp32_speedup_pc; + + /* machine state */ + UINT8 irq_state; + UINT8 gsp_irq_state; + UINT8 msp_irq_state; + UINT8 adsp_irq_state; + UINT8 duart_irq_state; + + UINT8 duart_read_data[16]; + UINT8 duart_write_data[16]; + UINT8 duart_output_port; + emu_timer * duart_timer; + + UINT8 last_gsp_shiftreg; + + UINT8 m68k_zp1; + UINT8 m68k_zp2; + UINT8 m68k_adsp_buffer_bank; + + UINT8 adsp_halt; + UINT8 adsp_br; + UINT8 adsp_xflag; + UINT16 adsp_sim_address; + UINT16 adsp_som_address; + UINT32 adsp_eprom_base; + + UINT16 * sim_memory; + UINT32 sim_memory_size; + UINT16 som_memory[0x8000/2]; + UINT16 * adsp_pgm_memory_word; + + UINT8 ds3_gcmd; + UINT8 ds3_gflag; + UINT8 ds3_g68irqs; + UINT8 ds3_gfirqs; + UINT8 ds3_g68flag; + UINT8 ds3_send; + UINT8 ds3_reset; + UINT16 ds3_gdata; + UINT16 ds3_g68data; + UINT32 ds3_sim_address; + + UINT16 adc_control; + UINT8 adc8_select; + UINT8 adc8_data; + UINT8 adc12_select; + UINT8 adc12_byte; + UINT16 adc12_data; + + UINT16 hdc68k_last_wheel; + UINT16 hdc68k_last_port1; + UINT8 hdc68k_wheel_edge; + UINT8 hdc68k_shifter_state; + + UINT8 st68k_sloop_bank; + offs_t st68k_last_alt_sloop_offset; + + #define MAX_MSP_SYNC 16 + UINT32 * dataptr[MAX_MSP_SYNC]; + UINT32 dataval[MAX_MSP_SYNC]; + int next_msp_sync; + + /* audio state */ + UINT8 soundflag; + UINT8 mainflag; + UINT16 sounddata; + UINT16 maindata; + + UINT8 dacmute; + UINT8 cramen; + UINT8 irq68k; + + offs_t sound_rom_offs; + + UINT8 * rombase; + UINT32 romsize; + UINT16 comram[0x400/2]; + UINT64 last_bio_cycles; + + /* video state */ + offs_t vram_mask; + + UINT8 shiftreg_enable; + + UINT32 mask_table[65536 * 4]; + UINT8 * gsp_shiftreg_source; + + INT8 gfx_finescroll; + UINT8 gfx_palettebank; +}; -/*----------- defined in machine/harddriv.c -----------*/ - -extern const device_config *hdcpu_main; -extern const device_config *hdcpu_gsp; -extern const device_config *hdcpu_msp; -extern const device_config *hdcpu_adsp; -extern const device_config *hdcpu_sound; -extern const device_config *hdcpu_sounddsp; -extern const device_config *hdcpu_jsa; -extern const device_config *hdcpu_dsp32; - -extern UINT8 hd34010_host_access; -extern UINT8 hddsk_pio_access; - -extern UINT16 *hdmsp_ram; -extern UINT16 *hddsk_ram; -extern UINT16 *hddsk_rom; -extern UINT16 *hddsk_zram; -extern UINT16 *hd68k_slapstic_base; -extern UINT16 *st68k_sloop_alt_base; - -extern UINT16 *hdadsp_data_memory; -extern UINT32 *hdadsp_pgm_memory; - -extern UINT16 *hdgsp_protection; -extern UINT16 *stmsp_sync[3]; - -extern UINT16 *hdgsp_speedup_addr[2]; -extern offs_t hdgsp_speedup_pc; -extern UINT16 *hdmsp_speedup_addr; -extern offs_t hdmsp_speedup_pc; - -extern UINT16 *hdds3_speedup_addr; -extern offs_t hdds3_speedup_pc; -extern offs_t hdds3_transfer_pc; - -extern UINT32 *rddsp32_sync[2]; - -extern UINT32 gsp_speedup_count[4]; -extern UINT32 msp_speedup_count[4]; -extern UINT32 adsp_speedup_count[4]; +/*----------- defined in machine/harddriv.c -----------*/ /* Driver/Multisync board */ MACHINE_START( harddriv ); @@ -175,8 +286,6 @@ READ16_HANDLER( hdds3_speedup_r ); void hdsnd_init(running_machine *machine); -extern UINT16 *hdsnddsp_ram; - READ16_HANDLER( hd68k_snd_data_r ); READ16_HANDLER( hd68k_snd_status_r ); WRITE16_HANDLER( hd68k_snd_data_w ); @@ -215,14 +324,6 @@ READ16_HANDLER( hdsnddsp_compare_r ); /*----------- defined in video/harddriv.c -----------*/ -extern UINT8 hdgsp_multisync; -extern UINT8 *hdgsp_vram; -extern UINT16 *hdgsp_control_lo; -extern UINT16 *hdgsp_control_hi; -extern UINT16 *hdgsp_paletteram_lo; -extern UINT16 *hdgsp_paletteram_hi; -extern size_t hdgsp_vram_size; - VIDEO_START( harddriv ); void hdgsp_write_to_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); void hdgsp_read_from_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); diff --git a/src/mame/includes/klax.h b/src/mame/includes/klax.h index 489f4ade753..cb18b637bcd 100644 --- a/src/mame/includes/klax.h +++ b/src/mame/includes/klax.h @@ -4,6 +4,15 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _klax_state klax_state; +struct _klax_state +{ + atarigen_state atarigen; +}; + + /*----------- defined in video/klax.c -----------*/ WRITE16_HANDLER( klax_latch_w ); diff --git a/src/mame/includes/offtwall.h b/src/mame/includes/offtwall.h index 174cdb9b35e..e8b80f8357e 100644 --- a/src/mame/includes/offtwall.h +++ b/src/mame/includes/offtwall.h @@ -4,6 +4,15 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _offtwall_state offtwall_state; +struct _offtwall_state +{ + atarigen_state atarigen; +}; + + /*----------- defined in video/offtwall.c -----------*/ VIDEO_START( offtwall ); diff --git a/src/mame/includes/rampart.h b/src/mame/includes/rampart.h index 88687873d1d..3223ec401b7 100644 --- a/src/mame/includes/rampart.h +++ b/src/mame/includes/rampart.h @@ -4,6 +4,17 @@ *************************************************************************/ +#include "machine/atarigen.h" + +/* shared with arcadecl hardware */ +typedef struct _rampart_state rampart_state; +struct _rampart_state +{ + atarigen_state atarigen; + UINT16 * bitmap; + UINT8 has_mo; +}; + /*----------- defined in video/rampart.c -----------*/ @@ -11,5 +22,3 @@ VIDEO_START( rampart ); VIDEO_UPDATE( rampart ); void rampart_bitmap_render(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect); - -extern UINT16 *rampart_bitmap; diff --git a/src/mame/includes/relief.h b/src/mame/includes/relief.h index f54df774776..26146f73d30 100644 --- a/src/mame/includes/relief.h +++ b/src/mame/includes/relief.h @@ -4,6 +4,19 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _relief_state relief_state; +struct _relief_state +{ + atarigen_state atarigen; + + UINT8 ym2413_volume; + UINT8 overall_volume; + UINT32 adpcm_bank_base; +}; + + /*----------- defined in video/relief.c -----------*/ VIDEO_START( relief ); diff --git a/src/mame/includes/shuuz.h b/src/mame/includes/shuuz.h index bd23751d17b..42cea3ec098 100644 --- a/src/mame/includes/shuuz.h +++ b/src/mame/includes/shuuz.h @@ -4,6 +4,15 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _shuuz_state shuuz_state; +struct _shuuz_state +{ + atarigen_state atarigen; +}; + + /*----------- defined in video/shuuz.c -----------*/ VIDEO_START( shuuz ); diff --git a/src/mame/includes/skullxbo.h b/src/mame/includes/skullxbo.h index 712c2f1773d..6bde689dc39 100644 --- a/src/mame/includes/skullxbo.h +++ b/src/mame/includes/skullxbo.h @@ -4,6 +4,15 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _skullxbo_state skullxbo_state; +struct _skullxbo_state +{ + atarigen_state atarigen; +}; + + /*----------- defined in video/skullxbo.c -----------*/ WRITE16_HANDLER( skullxbo_playfieldlatch_w ); diff --git a/src/mame/includes/thunderj.h b/src/mame/includes/thunderj.h index 9ae544168a4..9abad0d0e5f 100644 --- a/src/mame/includes/thunderj.h +++ b/src/mame/includes/thunderj.h @@ -4,9 +4,17 @@ *************************************************************************/ -/*----------- defined in video/thunderj.c -----------*/ +#include "machine/atarigen.h" + +typedef struct _thunderj_state thunderj_state; +struct _thunderj_state +{ + atarigen_state atarigen; + UINT8 alpha_tile_bank; +}; -extern UINT8 thunderj_alpha_tile_bank; + +/*----------- defined in video/thunderj.c -----------*/ VIDEO_START( thunderj ); VIDEO_UPDATE( thunderj ); diff --git a/src/mame/includes/toobin.h b/src/mame/includes/toobin.h index 68a8c4a7c51..c0b791c2391 100644 --- a/src/mame/includes/toobin.h +++ b/src/mame/includes/toobin.h @@ -4,6 +4,20 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _toobin_state toobin_state; +struct _toobin_state +{ + atarigen_state atarigen; + + UINT16 * interrupt_scan; + + double brightness; + bitmap_t * pfbitmap; +}; + + /*----------- defined in video/toobin.c -----------*/ WRITE16_HANDLER( toobin_paletteram_w ); diff --git a/src/mame/includes/vindictr.h b/src/mame/includes/vindictr.h index 7e3fa9f461e..abec05afdf6 100644 --- a/src/mame/includes/vindictr.h +++ b/src/mame/includes/vindictr.h @@ -4,6 +4,19 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _vindictr_state vindictr_state; +struct _vindictr_state +{ + atarigen_state atarigen; + + UINT8 playfield_tile_bank; + UINT16 playfield_xscroll; + UINT16 playfield_yscroll; +}; + + /*----------- defined in video/vindictr.c -----------*/ WRITE16_HANDLER( vindictr_paletteram_w ); diff --git a/src/mame/includes/xybots.h b/src/mame/includes/xybots.h index 6df4f58e8d8..f2086e1de41 100644 --- a/src/mame/includes/xybots.h +++ b/src/mame/includes/xybots.h @@ -4,6 +4,17 @@ *************************************************************************/ +#include "machine/atarigen.h" + +typedef struct _xybots_state xybots_state; +struct _xybots_state +{ + atarigen_state atarigen; + + int h256; +}; + + /*----------- defined in video/xybots.c -----------*/ VIDEO_START( xybots ); diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index 04dd26ee851..224e7bf0356 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -29,94 +29,13 @@ /*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -UINT8 atarigen_scanline_int_state; -UINT8 atarigen_sound_int_state; -UINT8 atarigen_video_int_state; - -const UINT16 * atarigen_eeprom_default; -UINT16 * atarigen_eeprom; -size_t atarigen_eeprom_size; - -UINT8 atarigen_cpu_to_sound_ready; -UINT8 atarigen_sound_to_cpu_ready; - -UINT16 * atarigen_playfield; -UINT16 * atarigen_playfield2; -UINT16 * atarigen_playfield_upper; -UINT16 * atarigen_alpha; -UINT16 * atarigen_alpha2; -UINT16 * atarigen_xscroll; -UINT16 * atarigen_yscroll; - -UINT32 * atarigen_playfield32; -UINT32 * atarigen_alpha32; - -tilemap * atarigen_playfield_tilemap; -tilemap * atarigen_playfield2_tilemap; -tilemap * atarigen_alpha_tilemap; -tilemap * atarigen_alpha2_tilemap; - -UINT16 * atarivc_data; -UINT16 * atarivc_eof_data; -struct atarivc_state_desc atarivc_state; - - - -/*************************************************************************** - STATIC VARIABLES -***************************************************************************/ - -static atarigen_int_func update_int_callback; - -static UINT8 eeprom_unlocked; - -static UINT8 atarigen_slapstic_num; -static UINT16 * atarigen_slapstic; -static UINT8 atarigen_slapstic_bank; -static void * atarigen_slapstic_bank0; -static offs_t atarigen_slapstic_last_pc; -static offs_t atarigen_slapstic_last_address; -static offs_t atarigen_slapstic_base; -static offs_t atarigen_slapstic_mirror; - -static const device_config * sound_cpu; -static UINT8 atarigen_cpu_to_sound; -static UINT8 atarigen_sound_to_cpu; -static UINT8 timed_int; -static UINT8 ym2151_int; - -static atarigen_scanline_func scanline_callback; -static UINT32 scanlines_per_callback; - -static UINT32 actual_vc_latch0; -static UINT32 actual_vc_latch1; -static UINT8 atarivc_playfields; - -static UINT32 playfield_latch; -static UINT32 playfield2_latch; - -static const device_config * scanline_interrupt_timer_screens[ATARIMO_MAX]; -static emu_timer * scanline_interrupt_timers[ATARIMO_MAX]; - -static const device_config * scanline_timer_screens[ATARIMO_MAX]; -static emu_timer * scanline_timers[ATARIMO_MAX]; - -static const device_config * atarivc_eof_update_timer_screens[ATARIMO_MAX]; -static emu_timer * atarivc_eof_update_timers[ATARIMO_MAX]; - - - -/*************************************************************************** STATIC FUNCTION DECLARATIONS ***************************************************************************/ static TIMER_CALLBACK( scanline_interrupt_callback ); -static void decompress_eeprom_word(const UINT16 *data); -static void decompress_eeprom_byte(const UINT16 *data); +static void decompress_eeprom_word(UINT16 *dest, const UINT16 *data); +static void decompress_eeprom_byte(UINT8 *dest, const UINT16 *data); static void update_6502_irq(running_machine *machine); static TIMER_CALLBACK( delayed_sound_reset ); @@ -144,23 +63,23 @@ static TIMER_CALLBACK( atarivc_eof_update ); the interrupt sources. ---------------------------------------------------------------*/ -void atarigen_interrupt_reset(atarigen_int_func update_int) +void atarigen_interrupt_reset(atarigen_state *state, atarigen_int_func update_int) { int i; /* set the callback */ - update_int_callback = update_int; + state->update_int_callback = update_int; /* reset the interrupt states */ - atarigen_video_int_state = atarigen_sound_int_state = atarigen_scanline_int_state = 0; + state->video_int_state = state->sound_int_state = state->scanline_int_state = 0; /* clear the timers */ for (i = 0; i < ATARIMO_MAX; i++) { - scanline_interrupt_timer_screens[i] = NULL; - scanline_interrupt_timers[i] = NULL; - scanline_timer_screens[i] = NULL; - scanline_timers[i] = NULL; + state->scanline_interrupt_timer_screens[i] = NULL; + state->scanline_interrupt_timers[i] = NULL; + state->scanline_timer_screens[i] = NULL; + state->scanline_timers[i] = NULL; } } @@ -173,7 +92,8 @@ void atarigen_interrupt_reset(atarigen_int_func update_int) void atarigen_update_interrupts(running_machine *machine) { - (*update_int_callback)(machine); + atarigen_state *state = (atarigen_state *)machine->driver_data; + (*state->update_int_callback)(machine); } @@ -184,17 +104,18 @@ void atarigen_update_interrupts(running_machine *machine) static emu_timer *get_scanline_interrupt_timer_for_screen(const device_config *screen) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; int i; /* find the index of the timer that matches the screen */ for (i = 0; i < ATARIMO_MAX; i++) { /* matching */ - if (scanline_interrupt_timer_screens[i] == screen) + if (state->scanline_interrupt_timer_screens[i] == screen) break; /* no more */ - if (scanline_interrupt_timer_screens[i] == NULL) + if (state->scanline_interrupt_timer_screens[i] == NULL) break; } @@ -202,14 +123,14 @@ static emu_timer *get_scanline_interrupt_timer_for_screen(const device_config *s assert(i != ATARIMO_MAX); /* need to create? */ - if (scanline_interrupt_timer_screens[i] == NULL) + if (state->scanline_interrupt_timer_screens[i] == NULL) { - scanline_interrupt_timer_screens[i] = screen; - scanline_interrupt_timers[i] = timer_alloc(screen->machine, scanline_interrupt_callback, (void *)screen); + state->scanline_interrupt_timer_screens[i] = screen; + state->scanline_interrupt_timers[i] = timer_alloc(screen->machine, scanline_interrupt_callback, (void *)screen); } /* found it */ - return scanline_interrupt_timers[i]; + return state->scanline_interrupt_timers[i]; } @@ -232,8 +153,9 @@ void atarigen_scanline_int_set(const device_config *screen, int scanline) INTERRUPT_GEN( atarigen_scanline_int_gen ) { - atarigen_scanline_int_state = 1; - (*update_int_callback)(device->machine); + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + state->scanline_int_state = 1; + (*state->update_int_callback)(device->machine); } @@ -244,14 +166,16 @@ INTERRUPT_GEN( atarigen_scanline_int_gen ) WRITE16_HANDLER( atarigen_scanline_int_ack_w ) { - atarigen_scanline_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->scanline_int_state = 0; + (*state->update_int_callback)(space->machine); } WRITE32_HANDLER( atarigen_scanline_int_ack32_w ) { - atarigen_scanline_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->scanline_int_state = 0; + (*state->update_int_callback)(space->machine); } @@ -262,8 +186,9 @@ WRITE32_HANDLER( atarigen_scanline_int_ack32_w ) INTERRUPT_GEN( atarigen_sound_int_gen ) { - atarigen_sound_int_state = 1; - (*update_int_callback)(device->machine); + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + state->sound_int_state = 1; + (*state->update_int_callback)(device->machine); } @@ -274,14 +199,16 @@ INTERRUPT_GEN( atarigen_sound_int_gen ) WRITE16_HANDLER( atarigen_sound_int_ack_w ) { - atarigen_sound_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->sound_int_state = 0; + (*state->update_int_callback)(space->machine); } WRITE32_HANDLER( atarigen_sound_int_ack32_w ) { - atarigen_sound_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->sound_int_state = 0; + (*state->update_int_callback)(space->machine); } @@ -292,8 +219,9 @@ WRITE32_HANDLER( atarigen_sound_int_ack32_w ) INTERRUPT_GEN( atarigen_video_int_gen ) { - atarigen_video_int_state = 1; - (*update_int_callback)(device->machine); + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + state->video_int_state = 1; + (*state->update_int_callback)(device->machine); } @@ -304,14 +232,16 @@ INTERRUPT_GEN( atarigen_video_int_gen ) WRITE16_HANDLER( atarigen_video_int_ack_w ) { - atarigen_video_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->video_int_state = 0; + (*state->update_int_callback)(space->machine); } WRITE32_HANDLER( atarigen_video_int_ack32_w ) { - atarigen_video_int_state = 0; - (*update_int_callback)(space->machine); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->video_int_state = 0; + (*state->update_int_callback)(space->machine); } @@ -342,9 +272,9 @@ static TIMER_CALLBACK( scanline_interrupt_callback ) is cleared when we reset. ---------------------------------------------------------------*/ -void atarigen_eeprom_reset(void) +void atarigen_eeprom_reset(atarigen_state *state) { - eeprom_unlocked = 0; + state->eeprom_unlocked = 0; } @@ -356,12 +286,14 @@ void atarigen_eeprom_reset(void) WRITE16_HANDLER( atarigen_eeprom_enable_w ) { - eeprom_unlocked = 1; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->eeprom_unlocked = 1; } WRITE32_HANDLER( atarigen_eeprom_enable32_w ) { - eeprom_unlocked = 1; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->eeprom_unlocked = 1; } @@ -374,23 +306,27 @@ WRITE32_HANDLER( atarigen_eeprom_enable32_w ) WRITE16_HANDLER( atarigen_eeprom_w ) { - if (!eeprom_unlocked) + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + + if (!state->eeprom_unlocked) return; - COMBINE_DATA(&atarigen_eeprom[offset]); - eeprom_unlocked = 0; + COMBINE_DATA(&state->eeprom[offset]); + state->eeprom_unlocked = 0; } WRITE32_HANDLER( atarigen_eeprom32_w ) { - if (!eeprom_unlocked) + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + + if (!state->eeprom_unlocked) return; - COMBINE_DATA(&atarigen_eeprom[offset * 2 + 1]); + COMBINE_DATA(&state->eeprom[offset * 2 + 1]); data >>= 16; mem_mask >>= 16; - COMBINE_DATA(&atarigen_eeprom[offset * 2]); - eeprom_unlocked = 0; + COMBINE_DATA(&state->eeprom[offset * 2]); + state->eeprom_unlocked = 0; } @@ -401,17 +337,20 @@ WRITE32_HANDLER( atarigen_eeprom32_w ) READ16_HANDLER( atarigen_eeprom_r ) { - return atarigen_eeprom[offset] | 0xff00; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + return state->eeprom[offset] | 0xff00; } READ16_HANDLER( atarigen_eeprom_upper_r ) { - return atarigen_eeprom[offset] | 0x00ff; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + return state->eeprom[offset] | 0x00ff; } READ32_HANDLER( atarigen_eeprom_upper32_r ) { - return (atarigen_eeprom[offset * 2] << 16) | atarigen_eeprom[offset * 2 + 1] | 0x00ff00ff; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + return (state->eeprom[offset * 2] << 16) | state->eeprom[offset * 2 + 1] | 0x00ff00ff; } @@ -421,22 +360,23 @@ READ32_HANDLER( atarigen_eeprom_upper32_r ) NVRAM_HANDLER( atarigen ) { + atarigen_state *state = (atarigen_state *)machine->driver_data; if (read_or_write) - mame_fwrite(file, atarigen_eeprom, atarigen_eeprom_size); + mame_fwrite(file, state->eeprom, state->eeprom_size); else if (file) - mame_fread(file, atarigen_eeprom, atarigen_eeprom_size); + mame_fread(file, state->eeprom, state->eeprom_size); else { /* all 0xff's work for most games */ - memset(atarigen_eeprom, 0xff, atarigen_eeprom_size); + memset(state->eeprom, 0xff, state->eeprom_size); /* anything else must be decompressed */ - if (atarigen_eeprom_default) + if (state->eeprom_default) { - if (atarigen_eeprom_default[0] == 0) - decompress_eeprom_byte(atarigen_eeprom_default + 1); + if (state->eeprom_default[0] == 0) + decompress_eeprom_byte((UINT8 *)state->eeprom, state->eeprom_default + 1); else - decompress_eeprom_word(atarigen_eeprom_default + 1); + decompress_eeprom_word(state->eeprom, state->eeprom_default + 1); } } } @@ -447,9 +387,8 @@ NVRAM_HANDLER( atarigen ) that has every other byte invalid. ---------------------------------------------------------------*/ -void decompress_eeprom_word(const UINT16 *data) +void decompress_eeprom_word(UINT16 *dest, const UINT16 *data) { - UINT16 *dest = (UINT16 *)atarigen_eeprom; UINT16 value; while ((value = *data++) != 0) @@ -468,9 +407,8 @@ void decompress_eeprom_word(const UINT16 *data) that is byte-packed. ---------------------------------------------------------------*/ -void decompress_eeprom_byte(const UINT16 *data) +void decompress_eeprom_byte(UINT8 *dest, const UINT16 *data) { - UINT8 *dest = (UINT8 *)atarigen_eeprom; UINT16 value; while ((value = *data++) != 0) @@ -489,42 +427,45 @@ void decompress_eeprom_byte(const UINT16 *data) SLAPSTIC HANDLING ***************************************************************************/ -INLINE void update_bank(int bank) +INLINE void update_bank(atarigen_state *state, int bank) { /* if the bank has changed, copy the memory; Pit Fighter needs this */ - if (bank != atarigen_slapstic_bank) + if (bank != state->slapstic_bank) { /* bank 0 comes from the copy we made earlier */ if (bank == 0) - memcpy(atarigen_slapstic, atarigen_slapstic_bank0, 0x2000); + memcpy(state->slapstic, state->slapstic_bank0, 0x2000); else - memcpy(atarigen_slapstic, &atarigen_slapstic[bank * 0x1000], 0x2000); + memcpy(state->slapstic, &state->slapstic[bank * 0x1000], 0x2000); /* remember the current bank */ - atarigen_slapstic_bank = bank; + state->slapstic_bank = bank; } } static STATE_POSTLOAD( slapstic_postload ) { - update_bank(slapstic_bank()); + atarigen_state *state = (atarigen_state *)machine->driver_data; + update_bank(state, slapstic_bank()); } static DIRECT_UPDATE_HANDLER( atarigen_slapstic_setdirect ) { + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + /* if we jump to an address in the slapstic region, tweak the slapstic at that address and return ~0; this will cause us to be called on subsequent fetches as well */ - address &= ~atarigen_slapstic_mirror; - if (address >= atarigen_slapstic_base && address < atarigen_slapstic_base + 0x8000) + address &= ~state->slapstic_mirror; + if (address >= state->slapstic_base && address < state->slapstic_base + 0x8000) { offs_t pc = cpu_get_previouspc(space->cpu); - if (pc != atarigen_slapstic_last_pc || address != atarigen_slapstic_last_address) + if (pc != state->slapstic_last_pc || address != state->slapstic_last_address) { - atarigen_slapstic_last_pc = pc; - atarigen_slapstic_last_address = address; + state->slapstic_last_pc = pc; + state->slapstic_last_address = address; atarigen_slapstic_r(space, (address >> 1) & 0x3fff, 0xffff); } return ~0; @@ -542,9 +483,11 @@ static DIRECT_UPDATE_HANDLER( atarigen_slapstic_setdirect ) void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mirror, int chipnum) { + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + /* reset in case we have no state */ - atarigen_slapstic_num = chipnum; - atarigen_slapstic = NULL; + state->slapstic_num = chipnum; + state->slapstic = NULL; /* if we have a chip, install it */ if (chipnum != 0) @@ -553,18 +496,18 @@ void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mir slapstic_init(device->machine, chipnum); /* install the memory handlers */ - atarigen_slapstic = memory_install_readwrite16_handler(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), base, base + 0x7fff, 0, mirror, atarigen_slapstic_r, atarigen_slapstic_w); + state->slapstic = memory_install_readwrite16_handler(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), base, base + 0x7fff, 0, mirror, atarigen_slapstic_r, atarigen_slapstic_w); /* allocate memory for a copy of bank 0 */ - atarigen_slapstic_bank0 = auto_alloc_array(device->machine, UINT8, 0x2000); - memcpy(atarigen_slapstic_bank0, atarigen_slapstic, 0x2000); + state->slapstic_bank0 = auto_alloc_array(device->machine, UINT8, 0x2000); + memcpy(state->slapstic_bank0, state->slapstic, 0x2000); /* ensure we recopy memory for the bank */ - atarigen_slapstic_bank = 0xff; + state->slapstic_bank = 0xff; /* install an opcode base handler if we are a 68000 or variant */ - atarigen_slapstic_base = base; - atarigen_slapstic_mirror = mirror; + state->slapstic_base = base; + state->slapstic_mirror = mirror; memory_set_direct_update_handler(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), atarigen_slapstic_setdirect); } } @@ -575,12 +518,12 @@ void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mir active and resets its state. ---------------------------------------------------------------*/ -void atarigen_slapstic_reset(void) +void atarigen_slapstic_reset(atarigen_state *state) { - if (atarigen_slapstic_num != 0) + if (state->slapstic_num != 0) { slapstic_reset(); - update_bank(slapstic_bank()); + update_bank(state, slapstic_bank()); } } @@ -593,7 +536,8 @@ void atarigen_slapstic_reset(void) WRITE16_HANDLER( atarigen_slapstic_w ) { - update_bank(slapstic_tweak(space, offset)); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + update_bank(state, slapstic_tweak(space, offset)); } @@ -605,10 +549,11 @@ WRITE16_HANDLER( atarigen_slapstic_w ) READ16_HANDLER( atarigen_slapstic_r ) { /* fetch the result from the current bank first */ - int result = atarigen_slapstic[offset & 0xfff]; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + int result = state->slapstic[offset & 0xfff]; /* then determine the new one */ - update_bank(slapstic_tweak(space, offset)); + update_bank(state, slapstic_tweak(space, offset)); return result; } @@ -624,15 +569,17 @@ READ16_HANDLER( atarigen_slapstic_r ) void atarigen_sound_io_reset(const device_config *device) { + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + /* remember which CPU is the sound CPU */ - sound_cpu = device; + state->sound_cpu = device; /* reset the internal interrupts states */ - timed_int = ym2151_int = 0; + state->timed_int = state->ym2151_int = 0; /* reset the sound I/O states */ - atarigen_cpu_to_sound = atarigen_sound_to_cpu = 0; - atarigen_cpu_to_sound_ready = atarigen_sound_to_cpu_ready = 0; + state->cpu_to_sound = state->sound_to_cpu = 0; + state->cpu_to_sound_ready = state->sound_to_cpu_ready = 0; } @@ -643,7 +590,8 @@ void atarigen_sound_io_reset(const device_config *device) INTERRUPT_GEN( atarigen_6502_irq_gen ) { - timed_int = 1; + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + state->timed_int = 1; update_6502_irq(device->machine); } @@ -655,14 +603,16 @@ INTERRUPT_GEN( atarigen_6502_irq_gen ) READ8_HANDLER( atarigen_6502_irq_ack_r ) { - timed_int = 0; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->timed_int = 0; update_6502_irq(space->machine); return 0; } WRITE8_HANDLER( atarigen_6502_irq_ack_w ) { - timed_int = 0; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->timed_int = 0; update_6502_irq(space->machine); } @@ -674,7 +624,8 @@ WRITE8_HANDLER( atarigen_6502_irq_ack_w ) void atarigen_ym2151_irq_gen(const device_config *device, int irq) { - ym2151_int = irq; + atarigen_state *state = (atarigen_state *)device->machine->driver_data; + state->ym2151_int = irq; update_6502_irq(device->machine); } @@ -736,23 +687,26 @@ WRITE32_HANDLER( atarigen_sound_upper32_w ) READ16_HANDLER( atarigen_sound_r ) { - atarigen_sound_to_cpu_ready = 0; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->sound_to_cpu_ready = 0; atarigen_sound_int_ack_w(space, 0, 0, 0xffff); - return atarigen_sound_to_cpu | 0xff00; + return state->sound_to_cpu | 0xff00; } READ16_HANDLER( atarigen_sound_upper_r ) { - atarigen_sound_to_cpu_ready = 0; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->sound_to_cpu_ready = 0; atarigen_sound_int_ack_w(space, 0, 0, 0xffff); - return (atarigen_sound_to_cpu << 8) | 0x00ff; + return (state->sound_to_cpu << 8) | 0x00ff; } READ32_HANDLER( atarigen_sound_upper32_r ) { - atarigen_sound_to_cpu_ready = 0; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->sound_to_cpu_ready = 0; atarigen_sound_int_ack32_w(space, 0, 0, 0xffff); - return (atarigen_sound_to_cpu << 24) | 0x00ffffff; + return (state->sound_to_cpu << 24) | 0x00ffffff; } @@ -774,9 +728,10 @@ WRITE8_HANDLER( atarigen_6502_sound_w ) READ8_HANDLER( atarigen_6502_sound_r ) { - atarigen_cpu_to_sound_ready = 0; - cpu_set_input_line(sound_cpu, INPUT_LINE_NMI, CLEAR_LINE); - return atarigen_cpu_to_sound; + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + state->cpu_to_sound_ready = 0; + cpu_set_input_line(state->sound_cpu, INPUT_LINE_NMI, CLEAR_LINE); + return state->cpu_to_sound; } @@ -789,10 +744,11 @@ READ8_HANDLER( atarigen_6502_sound_r ) static void update_6502_irq(running_machine *machine) { - if (timed_int || ym2151_int) - cpu_set_input_line(sound_cpu, M6502_IRQ_LINE, ASSERT_LINE); + atarigen_state *state = (atarigen_state *)machine->driver_data; + if (state->timed_int || state->ym2151_int) + cpu_set_input_line(state->sound_cpu, M6502_IRQ_LINE, ASSERT_LINE); else - cpu_set_input_line(sound_cpu, M6502_IRQ_LINE, CLEAR_LINE); + cpu_set_input_line(state->sound_cpu, M6502_IRQ_LINE, CLEAR_LINE); } @@ -803,17 +759,18 @@ static void update_6502_irq(running_machine *machine) static TIMER_CALLBACK( delayed_sound_reset ) { - const address_space *space = cpu_get_address_space(sound_cpu, ADDRESS_SPACE_PROGRAM); + atarigen_state *state = (atarigen_state *)machine->driver_data; + const address_space *space = cpu_get_address_space(state->sound_cpu, ADDRESS_SPACE_PROGRAM); /* unhalt and reset the sound CPU */ if (param == 0) { - cpu_set_input_line(sound_cpu, INPUT_LINE_HALT, CLEAR_LINE); - cpu_set_input_line(sound_cpu, INPUT_LINE_RESET, PULSE_LINE); + cpu_set_input_line(state->sound_cpu, INPUT_LINE_HALT, CLEAR_LINE); + cpu_set_input_line(state->sound_cpu, INPUT_LINE_RESET, PULSE_LINE); } /* reset the sound write state */ - atarigen_sound_to_cpu_ready = 0; + state->sound_to_cpu_ready = 0; atarigen_sound_int_ack_w(space, 0, 0, 0xffff); /* allocate a high frequency timer until a response is generated */ @@ -829,14 +786,16 @@ static TIMER_CALLBACK( delayed_sound_reset ) static TIMER_CALLBACK( delayed_sound_w ) { + atarigen_state *state = (atarigen_state *)machine->driver_data; + /* warn if we missed something */ - if (atarigen_cpu_to_sound_ready) + if (state->cpu_to_sound_ready) logerror("Missed command from 68010\n"); /* set up the states and signal an NMI to the sound CPU */ - atarigen_cpu_to_sound = param; - atarigen_cpu_to_sound_ready = 1; - cpu_set_input_line(sound_cpu, INPUT_LINE_NMI, ASSERT_LINE); + state->cpu_to_sound = param; + state->cpu_to_sound_ready = 1; + cpu_set_input_line(state->sound_cpu, INPUT_LINE_NMI, ASSERT_LINE); /* allocate a high frequency timer until a response is generated */ /* the main CPU is *very* sensistive to the timing of the response */ @@ -851,13 +810,15 @@ static TIMER_CALLBACK( delayed_sound_w ) static TIMER_CALLBACK( delayed_6502_sound_w ) { + atarigen_state *state = (atarigen_state *)machine->driver_data; + /* warn if we missed something */ - if (atarigen_sound_to_cpu_ready) + if (state->sound_to_cpu_ready) logerror("Missed result from 6502\n"); /* set up the states and signal the sound interrupt to the main CPU */ - atarigen_sound_to_cpu = param; - atarigen_sound_to_cpu_ready = 1; + state->sound_to_cpu = param; + state->sound_to_cpu_ready = 1; atarigen_sound_int_gen(cputag_get_cpu(machine, "maincpu")); } @@ -925,17 +886,18 @@ void atarigen_set_oki6295_vol(running_machine *machine, int volume) static emu_timer *get_scanline_timer_for_screen(const device_config *screen) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; int i; /* find the index of the timer that matches the screen */ for (i = 0; i < ATARIMO_MAX; i++) { /* matching */ - if (scanline_timer_screens[i] == screen) + if (state->scanline_timer_screens[i] == screen) break; /* no more */ - if (scanline_timer_screens[i] == NULL) + if (state->scanline_timer_screens[i] == NULL) break; } @@ -943,14 +905,14 @@ static emu_timer *get_scanline_timer_for_screen(const device_config *screen) assert(i != ATARIMO_MAX); /* need to create? */ - if (scanline_timer_screens[i] == NULL) + if (state->scanline_timer_screens[i] == NULL) { - scanline_timer_screens[i] = screen; - scanline_timers[i] = timer_alloc(screen->machine, scanline_timer_callback, (void *)screen); + state->scanline_timer_screens[i] = screen; + state->scanline_timers[i] = timer_alloc(screen->machine, scanline_timer_callback, (void *)screen); } /* found it */ - return scanline_timers[i]; + return state->scanline_timers[i]; } @@ -960,12 +922,14 @@ static emu_timer *get_scanline_timer_for_screen(const device_config *screen) void atarigen_scanline_timer_reset(const device_config *screen, atarigen_scanline_func update_graphics, int frequency) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + /* set the scanline callback */ - scanline_callback = update_graphics; - scanlines_per_callback = frequency; + state->scanline_callback = update_graphics; + state->scanlines_per_callback = frequency; /* set a timer to go off at scanline 0 */ - if (scanline_callback != NULL) + if (state->scanline_callback != NULL) { emu_timer *timer = get_scanline_timer_for_screen(screen); timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); @@ -984,16 +948,17 @@ void atarigen_scanline_timer_reset(const device_config *screen, atarigen_scanlin static TIMER_CALLBACK( scanline_timer_callback ) { + atarigen_state *state = (atarigen_state *)machine->driver_data; const device_config *screen = (const device_config *)ptr; int scanline = param; /* callback */ - if (scanline_callback != NULL) + if (state->scanline_callback != NULL) { - (*scanline_callback)(screen, scanline); + (*state->scanline_callback)(screen, scanline); /* generate another */ - scanline += scanlines_per_callback; + scanline += state->scanlines_per_callback; if (scanline >= video_screen_get_height(screen)) scanline = 0; timer_adjust_oneshot(get_scanline_timer_for_screen(screen), video_screen_get_time_until_pos(screen, scanline, 0), scanline); @@ -1013,17 +978,18 @@ static TIMER_CALLBACK( scanline_timer_callback ) static emu_timer *get_atarivc_eof_update_timer_for_screen(const device_config *screen) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; int i; /* find the index of the timer that matches the screen */ for (i = 0; i < ATARIMO_MAX; i++) { /* matching */ - if (atarivc_eof_update_timer_screens[i] == screen) + if (state->atarivc_eof_update_timer_screens[i] == screen) break; /* no more */ - if (atarivc_eof_update_timer_screens[i] == NULL) + if (state->atarivc_eof_update_timer_screens[i] == NULL) break; } @@ -1031,14 +997,14 @@ static emu_timer *get_atarivc_eof_update_timer_for_screen(const device_config *s assert(i != ATARIMO_MAX); /* need to create? */ - if (atarivc_eof_update_timer_screens[i] == NULL) + if (state->atarivc_eof_update_timer_screens[i] == NULL) { - atarivc_eof_update_timer_screens[i] = screen; - atarivc_eof_update_timers[i] = timer_alloc(screen->machine, atarivc_eof_update, (void *)screen); + state->atarivc_eof_update_timer_screens[i] = screen; + state->atarivc_eof_update_timers[i] = timer_alloc(screen->machine, atarivc_eof_update, (void *)screen); } /* found it */ - return atarivc_eof_update_timers[i]; + return state->atarivc_eof_update_timers[i]; } @@ -1049,26 +1015,27 @@ static emu_timer *get_atarivc_eof_update_timer_for_screen(const device_config *s static TIMER_CALLBACK( atarivc_eof_update ) { + atarigen_state *state = (atarigen_state *)machine->driver_data; const device_config *screen = (const device_config *)ptr; emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen); int i; /* echo all the commands to the video controller */ for (i = 0; i < 0x1c; i++) - if (atarivc_eof_data[i]) - atarivc_common_w(screen, i, atarivc_eof_data[i]); + if (state->atarivc_eof_data[i]) + atarivc_common_w(screen, i, state->atarivc_eof_data[i]); /* update the scroll positions */ - atarimo_set_xscroll(0, atarivc_state.mo_xscroll); - atarimo_set_yscroll(0, atarivc_state.mo_yscroll); + atarimo_set_xscroll(0, state->atarivc_state.mo_xscroll); + atarimo_set_yscroll(0, state->atarivc_state.mo_yscroll); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, atarivc_state.pf0_xscroll); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, atarivc_state.pf0_yscroll); + tilemap_set_scrollx(state->playfield_tilemap, 0, state->atarivc_state.pf0_xscroll); + tilemap_set_scrolly(state->playfield_tilemap, 0, state->atarivc_state.pf0_yscroll); - if (atarivc_playfields > 1) + if (state->atarivc_playfields > 1) { - tilemap_set_scrollx(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_xscroll); - tilemap_set_scrolly(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_yscroll); + tilemap_set_scrollx(state->playfield2_tilemap, 0, state->atarivc_state.pf1_xscroll); + tilemap_set_scrolly(state->playfield2_tilemap, 0, state->atarivc_state.pf1_yscroll); } timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); @@ -1095,29 +1062,30 @@ static TIMER_CALLBACK( atarivc_eof_update ) void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; int i; /* this allows us to manually reset eof_data to NULL if it's not used */ - atarivc_eof_data = eof_data; - atarivc_playfields = playfields; + state->atarivc_eof_data = eof_data; + state->atarivc_playfields = playfields; /* clear the RAM we use */ - memset(atarivc_data, 0, 0x40); - memset(&atarivc_state, 0, sizeof(atarivc_state)); + memset(state->atarivc_data, 0, 0x40); + memset(&state->atarivc_state, 0, sizeof(state->atarivc_state)); /* reset the latches */ - atarivc_state.latch1 = atarivc_state.latch2 = -1; - actual_vc_latch0 = actual_vc_latch1 = -1; + state->atarivc_state.latch1 = state->atarivc_state.latch2 = -1; + state->actual_vc_latch0 = state->actual_vc_latch1 = -1; /* clear the timers */ for (i = 0; i < ATARIMO_MAX; i++) { - atarivc_eof_update_timer_screens[i] = NULL; - atarivc_eof_update_timers[i] = NULL; + state->atarivc_eof_update_timer_screens[i] = NULL; + state->atarivc_eof_update_timers[i] = NULL; } /* start a timer to go off a little before scanline 0 */ - if (atarivc_eof_data) + if (state->atarivc_eof_data) { emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen); timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); @@ -1132,7 +1100,8 @@ void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields void atarivc_w(const device_config *screen, offs_t offset, UINT16 data, UINT16 mem_mask) { - int oldword = atarivc_data[offset]; + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + int oldword = state->atarivc_data[offset]; int newword = oldword; COMBINE_DATA(&newword); @@ -1148,8 +1117,9 @@ void atarivc_w(const device_config *screen, offs_t offset, UINT16 data, UINT16 m static void atarivc_common_w(const device_config *screen, offs_t offset, UINT16 newword) { - int oldword = atarivc_data[offset]; - atarivc_data[offset] = newword; + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + int oldword = state->atarivc_data[offset]; + state->atarivc_data[offset] = newword; /* switch off the offset */ switch (offset) @@ -1171,17 +1141,17 @@ static void atarivc_common_w(const device_config *screen, offs_t offset, UINT16 case 0x0a: /* reset the latches when disabled */ - atarigen_set_playfield_latch((newword & 0x0080) ? actual_vc_latch0 : -1); - atarigen_set_playfield2_latch((newword & 0x0080) ? actual_vc_latch1 : -1); + atarigen_set_playfield_latch(state, (newword & 0x0080) ? state->actual_vc_latch0 : -1); + atarigen_set_playfield2_latch(state, (newword & 0x0080) ? state->actual_vc_latch1 : -1); /* check for rowscroll enable */ - atarivc_state.rowscroll_enable = (newword & 0x2000) >> 13; + state->atarivc_state.rowscroll_enable = (newword & 0x2000) >> 13; /* check for palette banking */ - if (atarivc_state.palette_bank != (((newword & 0x0400) >> 10) ^ 1)) + if (state->atarivc_state.palette_bank != (((newword & 0x0400) >> 10) ^ 1)) { video_screen_update_partial(screen, video_screen_get_vpos(screen)); - atarivc_state.palette_bank = ((newword & 0x0400) >> 10) ^ 1; + state->atarivc_state.palette_bank = ((newword & 0x0400) >> 10) ^ 1; } break; @@ -1192,47 +1162,47 @@ static void atarivc_common_w(const device_config *screen, offs_t offset, UINT16 switch (newword & 15) { case 9: - atarivc_state.mo_xscroll = (newword >> 7) & 0x1ff; + state->atarivc_state.mo_xscroll = (newword >> 7) & 0x1ff; break; case 10: - atarivc_state.pf1_xscroll_raw = (newword >> 7) & 0x1ff; - atarivc_update_pf_xscrolls(); + state->atarivc_state.pf1_xscroll_raw = (newword >> 7) & 0x1ff; + atarivc_update_pf_xscrolls(state); break; case 11: - atarivc_state.pf0_xscroll_raw = (newword >> 7) & 0x1ff; - atarivc_update_pf_xscrolls(); + state->atarivc_state.pf0_xscroll_raw = (newword >> 7) & 0x1ff; + atarivc_update_pf_xscrolls(state); break; case 13: - atarivc_state.mo_yscroll = (newword >> 7) & 0x1ff; + state->atarivc_state.mo_yscroll = (newword >> 7) & 0x1ff; break; case 14: - atarivc_state.pf1_yscroll = (newword >> 7) & 0x1ff; + state->atarivc_state.pf1_yscroll = (newword >> 7) & 0x1ff; break; case 15: - atarivc_state.pf0_yscroll = (newword >> 7) & 0x1ff; + state->atarivc_state.pf0_yscroll = (newword >> 7) & 0x1ff; break; } break; /* latch 1 value */ case 0x1c: - actual_vc_latch0 = -1; - actual_vc_latch1 = newword; - atarigen_set_playfield_latch((atarivc_data[0x0a] & 0x80) ? actual_vc_latch0 : -1); - atarigen_set_playfield2_latch((atarivc_data[0x0a] & 0x80) ? actual_vc_latch1 : -1); + state->actual_vc_latch0 = -1; + state->actual_vc_latch1 = newword; + atarigen_set_playfield_latch(state, (state->atarivc_data[0x0a] & 0x80) ? state->actual_vc_latch0 : -1); + atarigen_set_playfield2_latch(state, (state->atarivc_data[0x0a] & 0x80) ? state->actual_vc_latch1 : -1); break; /* latch 2 value */ case 0x1d: - actual_vc_latch0 = newword; - actual_vc_latch1 = -1; - atarigen_set_playfield_latch((atarivc_data[0x0a] & 0x80) ? actual_vc_latch0 : -1); - atarigen_set_playfield2_latch((atarivc_data[0x0a] & 0x80) ? actual_vc_latch1 : -1); + state->actual_vc_latch0 = newword; + state->actual_vc_latch1 = -1; + atarigen_set_playfield_latch(state, (state->atarivc_data[0x0a] & 0x80) ? state->actual_vc_latch0 : -1); + atarigen_set_playfield2_latch(state, (state->atarivc_data[0x0a] & 0x80) ? state->actual_vc_latch1 : -1); break; /* scanline IRQ ack here */ @@ -1257,6 +1227,8 @@ static void atarivc_common_w(const device_config *screen, offs_t offset, UINT16 UINT16 atarivc_r(const device_config *screen, offs_t offset) { + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + logerror("vc_r(%02X)\n", offset); /* a read from offset 0 returns the current scanline */ @@ -1273,7 +1245,7 @@ UINT16 atarivc_r(const device_config *screen, offs_t offset) return result; } else - return atarivc_data[offset]; + return state->atarivc_data[offset]; } @@ -1288,23 +1260,26 @@ UINT16 atarivc_r(const device_config *screen, offs_t offset) WRITE16_HANDLER( atarigen_alpha_w ) { - COMBINE_DATA(&atarigen_alpha[offset]); - tilemap_mark_tile_dirty(atarigen_alpha_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->alpha[offset]); + tilemap_mark_tile_dirty(state->alpha_tilemap, offset); } WRITE32_HANDLER( atarigen_alpha32_w ) { - COMBINE_DATA(&atarigen_alpha32[offset]); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->alpha32[offset]); if (ACCESSING_BITS_16_31) - tilemap_mark_tile_dirty(atarigen_alpha_tilemap, offset * 2); + tilemap_mark_tile_dirty(state->alpha_tilemap, offset * 2); if (ACCESSING_BITS_0_15) - tilemap_mark_tile_dirty(atarigen_alpha_tilemap, offset * 2 + 1); + tilemap_mark_tile_dirty(state->alpha_tilemap, offset * 2 + 1); } WRITE16_HANDLER( atarigen_alpha2_w ) { - COMBINE_DATA(&atarigen_alpha2[offset]); - tilemap_mark_tile_dirty(atarigen_alpha2_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->alpha2[offset]); + tilemap_mark_tile_dirty(state->alpha2_tilemap, offset); } @@ -1314,14 +1289,14 @@ WRITE16_HANDLER( atarigen_alpha2_w ) playfield handlers below. ---------------------------------------------------------------*/ -void atarigen_set_playfield_latch(int data) +void atarigen_set_playfield_latch(atarigen_state *state, int data) { - playfield_latch = data; + state->playfield_latch = data; } -void atarigen_set_playfield2_latch(int data) +void atarigen_set_playfield2_latch(atarigen_state *state, int data) { - playfield2_latch = data; + state->playfield2_latch = data; } @@ -1332,23 +1307,26 @@ void atarigen_set_playfield2_latch(int data) WRITE16_HANDLER( atarigen_playfield_w ) { - COMBINE_DATA(&atarigen_playfield[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset); } WRITE32_HANDLER( atarigen_playfield32_w ) { - COMBINE_DATA(&atarigen_playfield32[offset]); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield32[offset]); if (ACCESSING_BITS_16_31) - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset * 2); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset * 2); if (ACCESSING_BITS_0_15) - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset * 2 + 1); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset * 2 + 1); } WRITE16_HANDLER( atarigen_playfield2_w ) { - COMBINE_DATA(&atarigen_playfield2[offset]); - tilemap_mark_tile_dirty(atarigen_playfield2_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield2[offset]); + tilemap_mark_tile_dirty(state->playfield2_tilemap, offset); } @@ -1360,8 +1338,9 @@ WRITE16_HANDLER( atarigen_playfield2_w ) WRITE16_HANDLER( atarigen_playfield_large_w ) { - COMBINE_DATA(&atarigen_playfield[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset / 2); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset / 2); } @@ -1373,8 +1352,9 @@ WRITE16_HANDLER( atarigen_playfield_large_w ) WRITE16_HANDLER( atarigen_playfield_upper_w ) { - COMBINE_DATA(&atarigen_playfield_upper[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield_upper[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset); } @@ -1386,9 +1366,10 @@ WRITE16_HANDLER( atarigen_playfield_upper_w ) WRITE16_HANDLER( atarigen_playfield_dual_upper_w ) { - COMBINE_DATA(&atarigen_playfield_upper[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset); - tilemap_mark_tile_dirty(atarigen_playfield2_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + COMBINE_DATA(&state->playfield_upper[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset); + tilemap_mark_tile_dirty(state->playfield2_tilemap, offset); } @@ -1401,11 +1382,13 @@ WRITE16_HANDLER( atarigen_playfield_dual_upper_w ) WRITE16_HANDLER( atarigen_playfield_latched_lsb_w ) { - COMBINE_DATA(&atarigen_playfield[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; - if (playfield_latch != -1) - atarigen_playfield_upper[offset] = (atarigen_playfield_upper[offset] & ~0x00ff) | (playfield_latch & 0x00ff); + COMBINE_DATA(&state->playfield[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset); + + if (state->playfield_latch != -1) + state->playfield_upper[offset] = (state->playfield_upper[offset] & ~0x00ff) | (state->playfield_latch & 0x00ff); } @@ -1418,11 +1401,13 @@ WRITE16_HANDLER( atarigen_playfield_latched_lsb_w ) WRITE16_HANDLER( atarigen_playfield_latched_msb_w ) { - COMBINE_DATA(&atarigen_playfield[offset]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + + COMBINE_DATA(&state->playfield[offset]); + tilemap_mark_tile_dirty(state->playfield_tilemap, offset); - if (playfield_latch != -1) - atarigen_playfield_upper[offset] = (atarigen_playfield_upper[offset] & ~0xff00) | (playfield_latch & 0xff00); + if (state->playfield_latch != -1) + state->playfield_upper[offset] = (state->playfield_upper[offset] & ~0xff00) | (state->playfield_latch & 0xff00); } @@ -1435,11 +1420,13 @@ WRITE16_HANDLER( atarigen_playfield_latched_msb_w ) WRITE16_HANDLER( atarigen_playfield2_latched_msb_w ) { - COMBINE_DATA(&atarigen_playfield2[offset]); - tilemap_mark_tile_dirty(atarigen_playfield2_tilemap, offset); + atarigen_state *state = (atarigen_state *)space->machine->driver_data; + + COMBINE_DATA(&state->playfield2[offset]); + tilemap_mark_tile_dirty(state->playfield2_tilemap, offset); - if (playfield2_latch != -1) - atarigen_playfield_upper[offset] = (atarigen_playfield_upper[offset] & ~0xff00) | (playfield2_latch & 0xff00); + if (state->playfield2_latch != -1) + state->playfield_upper[offset] = (state->playfield_upper[offset] & ~0xff00) | (state->playfield2_latch & 0xff00); } @@ -1658,45 +1645,47 @@ void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0, void atarigen_init_save_state(running_machine *machine) { - state_save_register_global(machine, atarigen_scanline_int_state); - state_save_register_global(machine, atarigen_sound_int_state); - state_save_register_global(machine, atarigen_video_int_state); - - state_save_register_global(machine, atarigen_cpu_to_sound_ready); - state_save_register_global(machine, atarigen_sound_to_cpu_ready); - - state_save_register_global(machine, atarivc_state.latch1); /* latch #1 value (-1 means disabled) */ - state_save_register_global(machine, atarivc_state.latch2); /* latch #2 value (-1 means disabled) */ - state_save_register_global(machine, atarivc_state.rowscroll_enable); /* true if row-scrolling is enabled */ - state_save_register_global(machine, atarivc_state.palette_bank); /* which palette bank is enabled */ - state_save_register_global(machine, atarivc_state.pf0_xscroll); /* playfield 1 xscroll */ - state_save_register_global(machine, atarivc_state.pf0_xscroll_raw); /* playfield 1 xscroll raw value */ - state_save_register_global(machine, atarivc_state.pf0_yscroll); /* playfield 1 yscroll */ - state_save_register_global(machine, atarivc_state.pf1_xscroll); /* playfield 2 xscroll */ - state_save_register_global(machine, atarivc_state.pf1_xscroll_raw); /* playfield 2 xscroll raw value */ - state_save_register_global(machine, atarivc_state.pf1_yscroll); /* playfield 2 yscroll */ - state_save_register_global(machine, atarivc_state.mo_xscroll); /* sprite xscroll */ - state_save_register_global(machine, atarivc_state.mo_yscroll); /* sprite xscroll */ - - state_save_register_global(machine, eeprom_unlocked); - - state_save_register_global(machine, atarigen_slapstic_num); - state_save_register_global(machine, atarigen_slapstic_bank); - state_save_register_global(machine, atarigen_slapstic_last_pc); - state_save_register_global(machine, atarigen_slapstic_last_address); - - state_save_register_global(machine, atarigen_cpu_to_sound); - state_save_register_global(machine, atarigen_sound_to_cpu); - state_save_register_global(machine, timed_int); - state_save_register_global(machine, ym2151_int); - - state_save_register_global(machine, scanlines_per_callback); - - state_save_register_global(machine, actual_vc_latch0); - state_save_register_global(machine, actual_vc_latch1); - - state_save_register_global(machine, playfield_latch); - state_save_register_global(machine, playfield2_latch); + atarigen_state *state = (atarigen_state *)machine->driver_data; + + state_save_register_global(machine, state->scanline_int_state); + state_save_register_global(machine, state->sound_int_state); + state_save_register_global(machine, state->video_int_state); + + state_save_register_global(machine, state->cpu_to_sound_ready); + state_save_register_global(machine, state->sound_to_cpu_ready); + + state_save_register_global(machine, state->atarivc_state.latch1); /* latch #1 value (-1 means disabled) */ + state_save_register_global(machine, state->atarivc_state.latch2); /* latch #2 value (-1 means disabled) */ + state_save_register_global(machine, state->atarivc_state.rowscroll_enable); /* true if row-scrolling is enabled */ + state_save_register_global(machine, state->atarivc_state.palette_bank); /* which palette bank is enabled */ + state_save_register_global(machine, state->atarivc_state.pf0_xscroll); /* playfield 1 xscroll */ + state_save_register_global(machine, state->atarivc_state.pf0_xscroll_raw); /* playfield 1 xscroll raw value */ + state_save_register_global(machine, state->atarivc_state.pf0_yscroll); /* playfield 1 yscroll */ + state_save_register_global(machine, state->atarivc_state.pf1_xscroll); /* playfield 2 xscroll */ + state_save_register_global(machine, state->atarivc_state.pf1_xscroll_raw); /* playfield 2 xscroll raw value */ + state_save_register_global(machine, state->atarivc_state.pf1_yscroll); /* playfield 2 yscroll */ + state_save_register_global(machine, state->atarivc_state.mo_xscroll); /* sprite xscroll */ + state_save_register_global(machine, state->atarivc_state.mo_yscroll); /* sprite xscroll */ + + state_save_register_global(machine, state->eeprom_unlocked); + + state_save_register_global(machine, state->slapstic_num); + state_save_register_global(machine, state->slapstic_bank); + state_save_register_global(machine, state->slapstic_last_pc); + state_save_register_global(machine, state->slapstic_last_address); + + state_save_register_global(machine, state->cpu_to_sound); + state_save_register_global(machine, state->sound_to_cpu); + state_save_register_global(machine, state->timed_int); + state_save_register_global(machine, state->ym2151_int); + + state_save_register_global(machine, state->scanlines_per_callback); + + state_save_register_global(machine, state->actual_vc_latch0); + state_save_register_global(machine, state->actual_vc_latch1); + + state_save_register_global(machine, state->playfield_latch); + state_save_register_global(machine, state->playfield2_latch); /* need a postload to reset the state */ state_save_register_postload(machine, slapstic_postload, NULL); diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h index 5b74e118233..faf1187028f 100644 --- a/src/mame/machine/atarigen.h +++ b/src/mame/machine/atarigen.h @@ -49,41 +49,79 @@ struct atarivc_state_desc }; - -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -extern UINT8 atarigen_scanline_int_state; -extern UINT8 atarigen_sound_int_state; -extern UINT8 atarigen_video_int_state; - -extern const UINT16 * atarigen_eeprom_default; -extern UINT16 * atarigen_eeprom; -extern size_t atarigen_eeprom_size; - -extern UINT8 atarigen_cpu_to_sound_ready; -extern UINT8 atarigen_sound_to_cpu_ready; - -extern UINT16 * atarigen_playfield; -extern UINT16 * atarigen_playfield2; -extern UINT16 * atarigen_playfield_upper; -extern UINT16 * atarigen_alpha; -extern UINT16 * atarigen_alpha2; -extern UINT16 * atarigen_xscroll; -extern UINT16 * atarigen_yscroll; - -extern UINT32 * atarigen_playfield32; -extern UINT32 * atarigen_alpha32; - -extern tilemap * atarigen_playfield_tilemap; -extern tilemap * atarigen_playfield2_tilemap; -extern tilemap * atarigen_alpha_tilemap; -extern tilemap * atarigen_alpha2_tilemap; - -extern UINT16 * atarivc_data; -extern UINT16 * atarivc_eof_data; -extern struct atarivc_state_desc atarivc_state; +typedef struct _atarigen_state atarigen_state; +struct _atarigen_state +{ + UINT8 scanline_int_state; + UINT8 sound_int_state; + UINT8 video_int_state; + + const UINT16 * eeprom_default; + UINT16 * eeprom; + size_t eeprom_size; + + UINT8 cpu_to_sound_ready; + UINT8 sound_to_cpu_ready; + + UINT16 * playfield; + UINT16 * playfield2; + UINT16 * playfield_upper; + UINT16 * alpha; + UINT16 * alpha2; + UINT16 * xscroll; + UINT16 * yscroll; + + UINT32 * playfield32; + UINT32 * alpha32; + + tilemap * playfield_tilemap; + tilemap * playfield2_tilemap; + tilemap * alpha_tilemap; + tilemap * alpha2_tilemap; + + UINT16 * atarivc_data; + UINT16 * atarivc_eof_data; + struct atarivc_state_desc atarivc_state; + + /* internal state */ + atarigen_int_func update_int_callback; + + UINT8 eeprom_unlocked; + + UINT8 slapstic_num; + UINT16 * slapstic; + UINT8 slapstic_bank; + void * slapstic_bank0; + offs_t slapstic_last_pc; + offs_t slapstic_last_address; + offs_t slapstic_base; + offs_t slapstic_mirror; + + const device_config * sound_cpu; + UINT8 cpu_to_sound; + UINT8 sound_to_cpu; + UINT8 timed_int; + UINT8 ym2151_int; + + atarigen_scanline_func scanline_callback; + UINT32 scanlines_per_callback; + + UINT32 actual_vc_latch0; + UINT32 actual_vc_latch1; + UINT8 atarivc_playfields; + + UINT32 playfield_latch; + UINT32 playfield2_latch; + + const device_config * scanline_interrupt_timer_screens[ATARIMO_MAX]; + emu_timer * scanline_interrupt_timers[ATARIMO_MAX]; + + const device_config * scanline_timer_screens[ATARIMO_MAX]; + emu_timer * scanline_timers[ATARIMO_MAX]; + + const device_config * atarivc_eof_update_timer_screens[ATARIMO_MAX]; + emu_timer * atarivc_eof_update_timers[ATARIMO_MAX]; +}; @@ -95,7 +133,7 @@ extern struct atarivc_state_desc atarivc_state; INTERRUPT HANDLING ---------------------------------------------------------------*/ -void atarigen_interrupt_reset(atarigen_int_func update_int); +void atarigen_interrupt_reset(atarigen_state *state, atarigen_int_func update_int); void atarigen_update_interrupts(running_machine *machine); void atarigen_scanline_int_set(const device_config *screen, int scanline); @@ -116,7 +154,7 @@ WRITE32_HANDLER( atarigen_video_int_ack32_w ); EEPROM HANDLING ---------------------------------------------------------------*/ -void atarigen_eeprom_reset(void); +void atarigen_eeprom_reset(atarigen_state *state); WRITE16_HANDLER( atarigen_eeprom_enable_w ); WRITE16_HANDLER( atarigen_eeprom_w ); @@ -135,7 +173,7 @@ NVRAM_HANDLER( atarigen ); ---------------------------------------------------------------*/ void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mirror, int chipnum); -void atarigen_slapstic_reset(void); +void atarigen_slapstic_reset(atarigen_state *state); WRITE16_HANDLER( atarigen_slapstic_w ); READ16_HANDLER( atarigen_slapstic_r ); @@ -187,10 +225,10 @@ void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields void atarivc_w(const device_config *screen, offs_t offset, UINT16 data, UINT16 mem_mask); UINT16 atarivc_r(const device_config *screen, offs_t offset); -INLINE void atarivc_update_pf_xscrolls(void) +INLINE void atarivc_update_pf_xscrolls(atarigen_state *state) { - atarivc_state.pf0_xscroll = atarivc_state.pf0_xscroll_raw + ((atarivc_state.pf1_xscroll_raw) & 7); - atarivc_state.pf1_xscroll = atarivc_state.pf1_xscroll_raw + 4; + state->atarivc_state.pf0_xscroll = state->atarivc_state.pf0_xscroll_raw + ((state->atarivc_state.pf1_xscroll_raw) & 7); + state->atarivc_state.pf1_xscroll = state->atarivc_state.pf1_xscroll_raw + 4; } @@ -201,8 +239,8 @@ INLINE void atarivc_update_pf_xscrolls(void) WRITE16_HANDLER( atarigen_alpha_w ); WRITE32_HANDLER( atarigen_alpha32_w ); WRITE16_HANDLER( atarigen_alpha2_w ); -void atarigen_set_playfield_latch(int data); -void atarigen_set_playfield2_latch(int data); +void atarigen_set_playfield_latch(atarigen_state *state, int data); +void atarigen_set_playfield2_latch(atarigen_state *state, int data); WRITE16_HANDLER( atarigen_playfield_w ); WRITE32_HANDLER( atarigen_playfield32_w ); WRITE16_HANDLER( atarigen_playfield_large_w ); diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c index 042d2b122c1..ddd0207d827 100644 --- a/src/mame/machine/harddriv.c +++ b/src/mame/machine/harddriv.c @@ -32,110 +32,10 @@ /************************************* * - * External definitions - * - *************************************/ - -/* externally accessible */ -const device_config *hdcpu_main; -const device_config *hdcpu_gsp; -const device_config *hdcpu_msp; -const device_config *hdcpu_adsp; -const device_config *hdcpu_sound; -const device_config *hdcpu_sounddsp; -const device_config *hdcpu_jsa; -const device_config *hdcpu_dsp32; - -UINT8 hd34010_host_access; -UINT8 hddsk_pio_access; - -UINT16 *hdmsp_ram; -UINT16 *hddsk_ram; -UINT16 *hddsk_rom; -UINT16 *hddsk_zram; -UINT16 *hd68k_slapstic_base; -UINT16 *st68k_sloop_alt_base; - -UINT16 *hdadsp_data_memory; -UINT32 *hdadsp_pgm_memory; - -UINT16 *hdgsp_protection; -UINT16 *stmsp_sync[3]; - -UINT16 *hdgsp_speedup_addr[2]; -offs_t hdgsp_speedup_pc; - -UINT16 *hdmsp_speedup_addr; -offs_t hdmsp_speedup_pc; - -UINT16 *hdds3_speedup_addr; -offs_t hdds3_speedup_pc; -offs_t hdds3_transfer_pc; - -UINT32 *rddsp32_sync[2]; - -UINT32 gsp_speedup_count[4]; -UINT32 msp_speedup_count[4]; -UINT32 adsp_speedup_count[4]; - - -/************************************* - * * Static globals * *************************************/ -static UINT8 irq_state; -static UINT8 gsp_irq_state; -static UINT8 msp_irq_state; -static UINT8 adsp_irq_state; -static UINT8 duart_irq_state; - -static UINT8 duart_read_data[16]; -static UINT8 duart_write_data[16]; -static UINT8 duart_output_port; -static emu_timer *duart_timer; - -static UINT8 last_gsp_shiftreg; - -static UINT8 m68k_zp1, m68k_zp2; -static UINT8 m68k_adsp_buffer_bank; - -static UINT8 adsp_halt, adsp_br; -static UINT8 adsp_xflag; - -static UINT16 adsp_sim_address; -static UINT16 adsp_som_address; -static UINT32 adsp_eprom_base; - -static UINT16 *sim_memory; -static UINT16 *som_memory; -static UINT32 sim_memory_size; -static UINT16 *adsp_pgm_memory_word; - -static UINT8 ds3_gcmd, ds3_gflag, ds3_g68irqs, ds3_gfirqs, ds3_g68flag, ds3_send, ds3_reset; -static UINT16 ds3_gdata, ds3_g68data; -static UINT32 ds3_sim_address; - -static UINT16 adc_control; -static UINT8 adc8_select; -static UINT8 adc8_data; -static UINT8 adc12_select; -static UINT8 adc12_byte; -static UINT16 adc12_data; - -static UINT16 hdc68k_last_wheel; -static UINT16 hdc68k_last_port1; -static UINT8 hdc68k_wheel_edge; -static UINT8 hdc68k_shifter_state; - -static UINT8 st68k_sloop_bank = 0; -static offs_t st68k_last_alt_sloop_offset; - -#define MAX_MSP_SYNC 16 -static UINT32 *dataptr[MAX_MSP_SYNC]; -static UINT32 dataval[MAX_MSP_SYNC]; -static int next_msp_sync; static void hd68k_update_interrupts(running_machine *machine); static TIMER_CALLBACK( duart_callback ); @@ -155,47 +55,50 @@ static TIMER_CALLBACK( duart_callback ); MACHINE_START( harddriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* predetermine memory regions */ - sim_memory = (UINT16 *)memory_region(machine, "user1"); - som_memory = auto_alloc_array(machine, UINT16, 0x8000/2); - sim_memory_size = memory_region_length(machine, "user1") / 2; - adsp_pgm_memory_word = (UINT16 *)((UINT8 *)hdadsp_pgm_memory + 1); + state->sim_memory = (UINT16 *)memory_region(machine, "user1"); + state->sim_memory_size = memory_region_length(machine, "user1") / 2; + state->adsp_pgm_memory_word = (UINT16 *)((UINT8 *)state->adsp_pgm_memory + 1); } MACHINE_RESET( harddriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; + /* generic reset */ - atarigen_eeprom_reset(); + atarigen_eeprom_reset(&state->atarigen); slapstic_reset(); - atarigen_interrupt_reset(hd68k_update_interrupts); + atarigen_interrupt_reset(&state->atarigen, hd68k_update_interrupts); /* halt several of the DSPs to start */ - if (hdcpu_adsp != NULL) cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, ASSERT_LINE); - if (hdcpu_dsp32 != NULL) cpu_set_input_line(hdcpu_dsp32, INPUT_LINE_HALT, ASSERT_LINE); - if (hdcpu_sounddsp != NULL) cpu_set_input_line(hdcpu_sounddsp, INPUT_LINE_HALT, ASSERT_LINE); + if (state->adsp != NULL) cpu_set_input_line(state->adsp, INPUT_LINE_HALT, ASSERT_LINE); + if (state->dsp32 != NULL) cpu_set_input_line(state->dsp32, INPUT_LINE_HALT, ASSERT_LINE); + if (state->sounddsp != NULL) cpu_set_input_line(state->sounddsp, INPUT_LINE_HALT, ASSERT_LINE); /* if we found a 6502, reset the JSA board */ - if (hdcpu_jsa != NULL) + if (state->jsacpu != NULL) atarijsa_reset(); - last_gsp_shiftreg = 0; + state->last_gsp_shiftreg = 0; - m68k_adsp_buffer_bank = 0; + state->m68k_adsp_buffer_bank = 0; /* reset IRQ states */ - irq_state = gsp_irq_state = msp_irq_state = adsp_irq_state = duart_irq_state = 0; + state->irq_state = state->gsp_irq_state = state->msp_irq_state = state->adsp_irq_state = state->duart_irq_state = 0; /* reset the DUART */ - memset(duart_read_data, 0, sizeof(duart_read_data)); - memset(duart_write_data, 0, sizeof(duart_write_data)); - duart_output_port = 0; - duart_timer = timer_alloc(machine, duart_callback, NULL); + memset(state->duart_read_data, 0, sizeof(state->duart_read_data)); + memset(state->duart_write_data, 0, sizeof(state->duart_write_data)); + state->duart_output_port = 0; + state->duart_timer = timer_alloc(machine, duart_callback, NULL); /* reset the ADSP/DSIII/DSIV boards */ - adsp_halt = 1; - adsp_br = 0; - adsp_xflag = 0; + state->adsp_halt = 1; + state->adsp_br = 0; + state->adsp_xflag = 0; } @@ -208,39 +111,44 @@ MACHINE_RESET( harddriv ) static void hd68k_update_interrupts(running_machine *machine) { - cpu_set_input_line(hdcpu_main, 1, msp_irq_state ? ASSERT_LINE : CLEAR_LINE); - cpu_set_input_line(hdcpu_main, 2, adsp_irq_state ? ASSERT_LINE : CLEAR_LINE); - cpu_set_input_line(hdcpu_main, 3, gsp_irq_state ? ASSERT_LINE : CLEAR_LINE); - cpu_set_input_line(hdcpu_main, 4, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE); /* /LINKIRQ on STUN Runner */ - cpu_set_input_line(hdcpu_main, 5, irq_state ? ASSERT_LINE : CLEAR_LINE); - cpu_set_input_line(hdcpu_main, 6, duart_irq_state ? ASSERT_LINE : CLEAR_LINE); + harddriv_state *state = (harddriv_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 1, state->msp_irq_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 2, state->adsp_irq_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 3, state->gsp_irq_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 4, state->atarigen.sound_int_state ? ASSERT_LINE : CLEAR_LINE); /* /LINKIRQ on STUN Runner */ + cpu_set_input_line(state->maincpu, 5, state->irq_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 6, state->duart_irq_state ? ASSERT_LINE : CLEAR_LINE); } INTERRUPT_GEN( hd68k_irq_gen ) { - irq_state = 1; + harddriv_state *state = (harddriv_state *)device->machine->driver_data; + state->irq_state = 1; atarigen_update_interrupts(device->machine); } WRITE16_HANDLER( hd68k_irq_ack_w ) { - irq_state = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->irq_state = 0; atarigen_update_interrupts(space->machine); } -void hdgsp_irq_gen(const device_config *device, int state) +void hdgsp_irq_gen(const device_config *device, int irqstate) { - gsp_irq_state = state; + harddriv_state *state = (harddriv_state *)device->machine->driver_data; + state->gsp_irq_state = irqstate; atarigen_update_interrupts(device->machine); } -void hdmsp_irq_gen(const device_config *device, int state) +void hdmsp_irq_gen(const device_config *device, int irqstate) { - msp_irq_state = state; + harddriv_state *state = (harddriv_state *)device->machine->driver_data; + state->msp_irq_state = irqstate; atarigen_update_interrupts(device->machine); } @@ -254,21 +162,23 @@ void hdmsp_irq_gen(const device_config *device, int state) READ16_HANDLER( hd68k_gsp_io_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; UINT16 result; offset = (offset / 2) ^ 1; - hd34010_host_access = 1; - result = tms34010_host_r(hdcpu_gsp, offset); - hd34010_host_access = 0; + state->hd34010_host_access = TRUE; + result = tms34010_host_r(state->gsp, offset); + state->hd34010_host_access = FALSE; return result; } WRITE16_HANDLER( hd68k_gsp_io_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; offset = (offset / 2) ^ 1; - hd34010_host_access = 1; - tms34010_host_w(hdcpu_gsp, offset, data); - hd34010_host_access = 0; + state->hd34010_host_access = TRUE; + tms34010_host_w(state->gsp, offset, data); + state->hd34010_host_access = FALSE; } @@ -281,23 +191,25 @@ WRITE16_HANDLER( hd68k_gsp_io_w ) READ16_HANDLER( hd68k_msp_io_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; UINT16 result; offset = (offset / 2) ^ 1; - hd34010_host_access = 1; - result = (hdcpu_msp != NULL) ? tms34010_host_r(hdcpu_msp, offset) : 0xffff; - hd34010_host_access = 0; + state->hd34010_host_access = TRUE; + result = (state->msp != NULL) ? tms34010_host_r(state->msp, offset) : 0xffff; + state->hd34010_host_access = FALSE; return result; } WRITE16_HANDLER( hd68k_msp_io_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; offset = (offset / 2) ^ 1; - if (hdcpu_msp != NULL) + if (state->msp != NULL) { - hd34010_host_access = 1; - tms34010_host_w(hdcpu_msp, offset, data); - hd34010_host_access = 0; + state->hd34010_host_access = TRUE; + tms34010_host_w(state->msp, offset, data); + state->hd34010_host_access = FALSE; } } @@ -335,38 +247,40 @@ READ16_HANDLER( hd68k_port0_r ) READ16_HANDLER( hdc68k_port1_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; UINT16 result = input_port_read(space->machine, "a80000"); - UINT16 diff = result ^ hdc68k_last_port1; + UINT16 diff = result ^ state->hdc68k_last_port1; /* if a new shifter position is selected, use it */ /* if it's the same shifter position as last time, go back to neutral */ if ((diff & 0x0100) && !(result & 0x0100)) - hdc68k_shifter_state = (hdc68k_shifter_state == 1) ? 0 : 1; + state->hdc68k_shifter_state = (state->hdc68k_shifter_state == 1) ? 0 : 1; if ((diff & 0x0200) && !(result & 0x0200)) - hdc68k_shifter_state = (hdc68k_shifter_state == 2) ? 0 : 2; + state->hdc68k_shifter_state = (state->hdc68k_shifter_state == 2) ? 0 : 2; if ((diff & 0x0400) && !(result & 0x0400)) - hdc68k_shifter_state = (hdc68k_shifter_state == 4) ? 0 : 4; + state->hdc68k_shifter_state = (state->hdc68k_shifter_state == 4) ? 0 : 4; if ((diff & 0x0800) && !(result & 0x0800)) - hdc68k_shifter_state = (hdc68k_shifter_state == 8) ? 0 : 8; + state->hdc68k_shifter_state = (state->hdc68k_shifter_state == 8) ? 0 : 8; /* merge in the new shifter value */ - result = (result | 0x0f00) ^ (hdc68k_shifter_state << 8); + result = (result | 0x0f00) ^ (state->hdc68k_shifter_state << 8); /* merge in the wheel edge latch bit */ - if (hdc68k_wheel_edge) + if (state->hdc68k_wheel_edge) result ^= 0x4000; - hdc68k_last_port1 = result; + state->hdc68k_last_port1 = result; return result; } READ16_HANDLER( hda68k_port1_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; UINT16 result = input_port_read(space->machine, "a80000"); /* merge in the wheel edge latch bit */ - if (hdc68k_wheel_edge) + if (state->hdc68k_wheel_edge) result ^= 0x4000; return result; @@ -375,6 +289,8 @@ READ16_HANDLER( hda68k_port1_r ) READ16_HANDLER( hdc68k_wheel_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* grab the new wheel value and upconvert to 12 bits */ UINT16 new_wheel = input_port_read(space->machine, "12BADC0") << 4; @@ -383,30 +299,33 @@ READ16_HANDLER( hdc68k_wheel_r ) popmessage("%04X", new_wheel); /* if we crossed the center line, latch the edge bit */ - if ((hdc68k_last_wheel / 0xf0) != (new_wheel / 0xf0)) - hdc68k_wheel_edge = 1; + if ((state->hdc68k_last_wheel / 0xf0) != (new_wheel / 0xf0)) + state->hdc68k_wheel_edge = 1; /* remember the last value and return the low 8 bits */ - hdc68k_last_wheel = new_wheel; + state->hdc68k_last_wheel = new_wheel; return (new_wheel << 8) | 0xff; } READ16_HANDLER( hd68k_adc8_r ) { - return adc8_data; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->adc8_data; } READ16_HANDLER( hd68k_adc12_r ) { - return adc12_byte ? ((adc12_data >> 8) & 0x0f) : (adc12_data & 0xff); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->adc12_byte ? ((state->adc12_data >> 8) & 0x0f) : (state->adc12_data & 0xff); } READ16_HANDLER( hd68k_sound_reset_r ) { - if (hdcpu_jsa != NULL) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->jsacpu != NULL) atarijsa_reset(); return ~0; } @@ -423,25 +342,26 @@ WRITE16_HANDLER( hd68k_adc_control_w ) { static const char *const adc8names[] = { "8BADC0", "8BADC1", "8BADC2", "8BADC3", "8BADC4", "8BADC5", "8BADC6", "8BADC7" }; static const char *const adc12names[] = { "12BADC0", "12BADC1", "12BADC2", "12BADC3" }; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; - COMBINE_DATA(&adc_control); + COMBINE_DATA(&state->adc_control); /* handle a write to the 8-bit ADC address select */ - if (adc_control & 0x08) + if (state->adc_control & 0x08) { - adc8_select = adc_control & 0x07; - adc8_data = input_port_read(space->machine, adc8names[adc8_select]); + state->adc8_select = state->adc_control & 0x07; + state->adc8_data = input_port_read(space->machine, adc8names[state->adc8_select]); } /* handle a write to the 12-bit ADC address select */ - if (adc_control & 0x40) + if (state->adc_control & 0x40) { - adc12_select = (adc_control >> 4) & 0x03; - adc12_data = input_port_read(space->machine, adc12names[adc12_select]) << 4; + state->adc12_select = (state->adc_control >> 4) & 0x03; + state->adc12_data = input_port_read(space->machine, adc12names[state->adc12_select]) << 4; } /* bit 7 selects which byte of the 12 bit data to read */ - adc12_byte = (adc_control >> 7) & 1; + state->adc12_byte = (state->adc_control >> 7) & 1; } @@ -488,6 +408,8 @@ WRITE16_HANDLER( hd68k_wr2_write ) WRITE16_HANDLER( hd68k_nwr_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* bit 3 selects the value; data is ignored */ data = (offset >> 3) & 1; @@ -504,20 +426,20 @@ WRITE16_HANDLER( hd68k_nwr_w ) case 3: /* LC2 */ break; case 4: /* ZP1 */ - m68k_zp1 = data; + state->m68k_zp1 = data; break; case 5: /* ZP2 */ - m68k_zp2 = data; + state->m68k_zp2 = data; break; case 6: /* /GSPRES */ logerror("Write to /GSPRES(%d)\n", data); - if (hdcpu_gsp != NULL) - cpu_set_input_line(hdcpu_gsp, INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE); + if (state->gsp != NULL) + cpu_set_input_line(state->gsp, INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE); break; case 7: /* /MSPRES */ logerror("Write to /MSPRES(%d)\n", data); - if (hdcpu_msp != NULL) - cpu_set_input_line(hdcpu_msp, INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE); + if (state->msp != NULL) + cpu_set_input_line(state->msp, INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE); break; } } @@ -526,7 +448,8 @@ WRITE16_HANDLER( hd68k_nwr_w ) WRITE16_HANDLER( hdc68k_wheel_edge_reset_w ) { /* reset the edge latch */ - hdc68k_wheel_edge = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->hdc68k_wheel_edge = 0; } @@ -539,14 +462,16 @@ WRITE16_HANDLER( hdc68k_wheel_edge_reset_w ) READ16_HANDLER( hd68k_zram_r ) { - return atarigen_eeprom[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->atarigen.eeprom[offset]; } WRITE16_HANDLER( hd68k_zram_w ) { - if (m68k_zp1 == 0 && m68k_zp2 == 1) - COMBINE_DATA(&atarigen_eeprom[offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->m68k_zp1 == 0 && state->m68k_zp2 == 1) + COMBINE_DATA(&state->atarigen.eeprom[offset]); } @@ -583,42 +508,44 @@ WRITE16_HANDLER( hd68k_zram_w ) */ -INLINE int duart_clock(void) +INLINE int duart_clock(harddriv_state *state) { - int mode = (duart_write_data[0x04] >> 4) & 7; + int mode = (state->duart_write_data[0x04] >> 4) & 7; if (mode != 3) logerror("DUART: unsupported clock mode %d\n", mode); return DUART_CLOCK / 16; } -INLINE attotime duart_clock_period(void) +INLINE attotime duart_clock_period(harddriv_state *state) { - return ATTOTIME_IN_HZ(duart_clock()); + return ATTOTIME_IN_HZ(duart_clock(state)); } static TIMER_CALLBACK( duart_callback ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; logerror("DUART timer fired\n"); - if (duart_write_data[0x05] & 0x08) + if (state->duart_write_data[0x05] & 0x08) { logerror("DUART interrupt generated\n"); - duart_read_data[0x05] |= 0x08; - duart_irq_state = (duart_read_data[0x05] & duart_write_data[0x05]) != 0; + state->duart_read_data[0x05] |= 0x08; + state->duart_irq_state = (state->duart_read_data[0x05] & state->duart_write_data[0x05]) != 0; atarigen_update_interrupts(machine); } - timer_adjust_oneshot(duart_timer, attotime_mul(duart_clock_period(), 65536), 0); + timer_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), 65536), 0); } READ16_HANDLER( hd68k_duart_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; switch (offset) { case 0x00: /* Mode Register A (MR1A, MR2A) */ case 0x08: /* Mode Register B (MR1B, MR2B) */ - return (duart_write_data[0x00] << 8) | 0x00ff; + return (state->duart_write_data[0x00] << 8) | 0x00ff; case 0x01: /* Status Register A (SRA) */ case 0x02: /* Clock-Select Register A 1 (CSRA) */ case 0x03: /* Receiver Buffer A (RBA) */ @@ -631,24 +558,24 @@ READ16_HANDLER( hd68k_duart_r ) case 0x0b: /* Receiver Buffer B (RBB) */ case 0x0c: /* Interrupt-Vector Register (IVR) */ case 0x0d: /* Input Port (IP) */ - return (duart_read_data[offset] << 8) | 0x00ff; + return (state->duart_read_data[offset] << 8) | 0x00ff; case 0x0e: /* Start-Counter Command 3 */ { - int reps = (duart_write_data[0x06] << 8) | duart_write_data[0x07]; - timer_adjust_oneshot(duart_timer, attotime_mul(duart_clock_period(), reps), 0); - logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(), reps))); + int reps = (state->duart_write_data[0x06] << 8) | state->duart_write_data[0x07]; + timer_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), reps), 0); + logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(state), reps))); return 0x00ff; } case 0x0f: /* Stop-Counter Command 3 */ { - int reps = attotime_to_double(attotime_mul(timer_timeleft(duart_timer), duart_clock())); - timer_adjust_oneshot(duart_timer, attotime_never, 0); - duart_read_data[0x06] = reps >> 8; - duart_read_data[0x07] = reps & 0xff; + int reps = attotime_to_double(attotime_mul(timer_timeleft(state->duart_timer), duart_clock(state))); + timer_adjust_oneshot(state->duart_timer, attotime_never, 0); + state->duart_read_data[0x06] = reps >> 8; + state->duart_read_data[0x07] = reps & 0xff; logerror("DUART timer stopped (final count=%04X)\n", reps); } - duart_read_data[0x05] &= ~0x08; - duart_irq_state = (duart_read_data[0x05] & duart_write_data[0x05]) != 0; + state->duart_read_data[0x05] &= ~0x08; + state->duart_irq_state = (state->duart_read_data[0x05] & state->duart_write_data[0x05]) != 0; atarigen_update_interrupts(space->machine); return 0x00ff; } @@ -658,10 +585,11 @@ READ16_HANDLER( hd68k_duart_r ) WRITE16_HANDLER( hd68k_duart_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; if (ACCESSING_BITS_8_15) { int newdata = (data >> 8) & 0xff; - duart_write_data[offset] = newdata; + state->duart_write_data[offset] = newdata; switch (offset) { @@ -681,10 +609,10 @@ WRITE16_HANDLER( hd68k_duart_w ) case 0x0d: /* Output Port Configuration Register (OPCR) */ break; case 0x0e: /* Output Port Register (OPR): Bit Set Command 3 */ - duart_output_port |= newdata; + state->duart_output_port |= newdata; break; case 0x0f: /* Output Port Register (OPR): Bit Reset Command 3 */ - duart_output_port &= ~newdata; + state->duart_output_port &= ~newdata; break; } logerror("DUART write %02X @ %02X\n", (data >> 8) & 0xff, offset); @@ -703,13 +631,15 @@ WRITE16_HANDLER( hd68k_duart_w ) WRITE16_HANDLER( hdgsp_io_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* detect an enabling of the shift register and force yielding */ if (offset == REG_DPYCTL) { UINT8 new_shiftreg = (data >> 11) & 1; - if (new_shiftreg != last_gsp_shiftreg) + if (new_shiftreg != state->last_gsp_shiftreg) { - last_gsp_shiftreg = new_shiftreg; + state->last_gsp_shiftreg = new_shiftreg; if (new_shiftreg) cpu_yield(space->cpu); } @@ -732,10 +662,12 @@ WRITE16_HANDLER( hdgsp_io_w ) WRITE16_HANDLER( hdgsp_protection_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* this memory address is incremented whenever a protection check fails */ /* after it reaches a certain value, the GSP will randomly trash a */ /* register; we just prevent it from ever going above 0 */ - *hdgsp_protection = 0; + *state->gsp_protection = 0; } @@ -748,26 +680,28 @@ WRITE16_HANDLER( hdgsp_protection_w ) static TIMER_CALLBACK( stmsp_sync_update ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; int which = param >> 28; offs_t offset = (param >> 16) & 0xfff; UINT16 data = param; - stmsp_sync[which][offset] = data; - cpu_triggerint(hdcpu_msp); + state->stmsp_sync[which][offset] = data; + cpu_triggerint(state->msp); } INLINE void stmsp_sync_w(const address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int which) { - UINT16 newdata = stmsp_sync[which][offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT16 newdata = state->stmsp_sync[which][offset]; COMBINE_DATA(&newdata); /* if being written from the 68000, synchronize on it */ - if (hd34010_host_access) + if (state->hd34010_host_access) timer_call_after_resynch(space->machine, NULL, newdata | (offset << 16) | (which << 28), stmsp_sync_update); /* otherwise, just update */ else - stmsp_sync[which][offset] = newdata; + state->stmsp_sync[which][offset] = newdata; } @@ -803,14 +737,16 @@ WRITE16_HANDLER( stmsp_sync2_w ) READ16_HANDLER( hd68k_adsp_program_r ) { - UINT32 word = hdadsp_pgm_memory[offset/2]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 word = state->adsp_pgm_memory[offset/2]; return (!(offset & 1)) ? (word >> 16) : (word & 0xffff); } WRITE16_HANDLER( hd68k_adsp_program_w ) { - UINT32 *base = &hdadsp_pgm_memory[offset/2]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 *base = &state->adsp_pgm_memory[offset/2]; UINT32 oldword = *base; UINT16 temp; @@ -839,20 +775,23 @@ WRITE16_HANDLER( hd68k_adsp_program_w ) READ16_HANDLER( hd68k_adsp_data_r ) { - return hdadsp_data_memory[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->adsp_data_memory[offset]; } WRITE16_HANDLER( hd68k_adsp_data_w ) { - COMBINE_DATA(&hdadsp_data_memory[offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + COMBINE_DATA(&state->adsp_data_memory[offset]); /* any write to $1FFF is taken to be a trigger; synchronize the CPUs */ if (offset == 0x1fff) { logerror("%06X:ADSP sync address written (%04X)\n", cpu_get_previouspc(space->cpu), data); timer_call_after_resynch(space->machine, NULL, 0, 0); - cpu_triggerint(hdcpu_adsp); + cpu_triggerint(state->adsp); } else logerror("%06X:ADSP W@%04X (%04X)\n", cpu_get_previouspc(space->cpu), offset, data); @@ -868,14 +807,16 @@ WRITE16_HANDLER( hd68k_adsp_data_w ) READ16_HANDLER( hd68k_adsp_buffer_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; /* logerror("hd68k_adsp_buffer_r(%04X)\n", offset);*/ - return som_memory[m68k_adsp_buffer_bank * 0x2000 + offset]; + return state->som_memory[state->m68k_adsp_buffer_bank * 0x2000 + offset]; } WRITE16_HANDLER( hd68k_adsp_buffer_w ) { - COMBINE_DATA(&som_memory[m68k_adsp_buffer_bank * 0x2000 + offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->som_memory[state->m68k_adsp_buffer_bank * 0x2000 + offset]); } @@ -888,13 +829,14 @@ WRITE16_HANDLER( hd68k_adsp_buffer_w ) static TIMER_CALLBACK( deferred_adsp_bank_switch ) { - if (LOG_COMMANDS && m68k_adsp_buffer_bank != param && input_code_pressed(machine, KEYCODE_L)) + harddriv_state *state = (harddriv_state *)machine->driver_data; + if (LOG_COMMANDS && state->m68k_adsp_buffer_bank != param && input_code_pressed(machine, KEYCODE_L)) { static FILE *commands; if (!commands) commands = fopen("commands.log", "w"); if (commands) { - INT16 *base = (INT16 *)&som_memory[param * 0x2000]; + INT16 *base = (INT16 *)&state->som_memory[param * 0x2000]; INT16 *end = base + (UINT16)*base; INT16 *current = base + 1; INT16 *table = base + 1 + (UINT16)*current++; @@ -932,13 +874,15 @@ static TIMER_CALLBACK( deferred_adsp_bank_switch ) } } - m68k_adsp_buffer_bank = param; + state->m68k_adsp_buffer_bank = param; logerror("ADSP bank = %d\n", param); } WRITE16_HANDLER( hd68k_adsp_control_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* bit 3 selects the value; data is ignored */ int val = (offset >> 3) & 1; @@ -959,13 +903,13 @@ WRITE16_HANDLER( hd68k_adsp_control_w ) case 5: /* connected to the /BR (bus request) line; this effectively halts */ /* the ADSP at the next instruction boundary */ - adsp_br = !val; - logerror("ADSP /BR = %d\n", !adsp_br); - if (adsp_br || adsp_halt) - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, ASSERT_LINE); + state->adsp_br = !val; + logerror("ADSP /BR = %d\n", !state->adsp_br); + if (state->adsp_br || state->adsp_halt) + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, ASSERT_LINE); else { - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, CLEAR_LINE); + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, CLEAR_LINE); /* a yield in this case is not enough */ /* we would need to increase the interleaving otherwise */ /* note that this only affects the test mode */ @@ -976,13 +920,13 @@ WRITE16_HANDLER( hd68k_adsp_control_w ) case 6: /* connected to the /HALT line; this effectively halts */ /* the ADSP at the next instruction boundary */ - adsp_halt = !val; - logerror("ADSP /HALT = %d\n", !adsp_halt); - if (adsp_br || adsp_halt) - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, ASSERT_LINE); + state->adsp_halt = !val; + logerror("ADSP /HALT = %d\n", !state->adsp_halt); + if (state->adsp_br || state->adsp_halt) + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, ASSERT_LINE); else { - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, CLEAR_LINE); + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, CLEAR_LINE); /* a yield in this case is not enough */ /* we would need to increase the interleaving otherwise */ /* note that this only affects the test mode */ @@ -992,7 +936,7 @@ WRITE16_HANDLER( hd68k_adsp_control_w ) case 7: logerror("ADSP reset = %d\n", val); - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); + cpu_set_input_line(state->adsp, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); cpu_yield(space->cpu); break; @@ -1005,17 +949,19 @@ WRITE16_HANDLER( hd68k_adsp_control_w ) WRITE16_HANDLER( hd68k_adsp_irq_clear_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; logerror("%06X:68k clears ADSP interrupt\n", cpu_get_previouspc(space->cpu)); - adsp_irq_state = 0; + state->adsp_irq_state = 0; atarigen_update_interrupts(space->machine); } READ16_HANDLER( hd68k_adsp_irq_state_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int result = 0xfffd; - if (adsp_xflag) result ^= 2; - if (adsp_irq_state) result ^= 1; + if (state->adsp_xflag) result ^= 2; + if (state->adsp_irq_state) result ^= 1; logerror("%06X:68k reads ADSP interrupt state = %04x\n", cpu_get_previouspc(space->cpu), result); return result; } @@ -1030,11 +976,12 @@ READ16_HANDLER( hd68k_adsp_irq_state_r ) READ16_HANDLER( hdadsp_special_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; switch (offset & 7) { case 0: /* /SIMBUF */ - if (adsp_eprom_base + adsp_sim_address < sim_memory_size) - return sim_memory[adsp_eprom_base + adsp_sim_address++]; + if (state->adsp_eprom_base + state->adsp_sim_address < state->sim_memory_size) + return state->sim_memory[state->adsp_eprom_base + state->adsp_sim_address++]; else return 0xff; @@ -1057,32 +1004,33 @@ READ16_HANDLER( hdadsp_special_r ) WRITE16_HANDLER( hdadsp_special_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; switch (offset & 7) { case 1: /* /SIMCLK */ - adsp_sim_address = data; + state->adsp_sim_address = data; break; case 2: /* SOMLATCH */ - som_memory[(m68k_adsp_buffer_bank ^ 1) * 0x2000 + (adsp_som_address++ & 0x1fff)] = data; + state->som_memory[(state->m68k_adsp_buffer_bank ^ 1) * 0x2000 + (state->adsp_som_address++ & 0x1fff)] = data; break; case 3: /* /SOMCLK */ - adsp_som_address = data; + state->adsp_som_address = data; break; case 5: /* /XOUT */ - adsp_xflag = data & 1; + state->adsp_xflag = data & 1; break; case 6: /* /GINT */ logerror("%04X:ADSP signals interrupt\n", cpu_get_previouspc(space->cpu)); - adsp_irq_state = 1; + state->adsp_irq_state = 1; atarigen_update_interrupts(space->machine); break; case 7: /* /MP */ - adsp_eprom_base = 0x10000 * data; + state->adsp_eprom_base = 0x10000 * data; break; default: @@ -1104,18 +1052,19 @@ WRITE16_HANDLER( hdadsp_special_w ) * *************************************/ -static void update_ds3_irq(void) +static void update_ds3_irq(harddriv_state *state) { /* update the IRQ2 signal to the ADSP2101 */ - if (!(!ds3_g68flag && ds3_g68irqs) && !(ds3_gflag && ds3_gfirqs)) - cpu_set_input_line(hdcpu_adsp, ADSP2100_IRQ2, ASSERT_LINE); + if (!(!state->ds3_g68flag && state->ds3_g68irqs) && !(state->ds3_gflag && state->ds3_gfirqs)) + cpu_set_input_line(state->adsp, ADSP2100_IRQ2, ASSERT_LINE); else - cpu_set_input_line(hdcpu_adsp, ADSP2100_IRQ2, CLEAR_LINE); + cpu_set_input_line(state->adsp, ADSP2100_IRQ2, CLEAR_LINE); } WRITE16_HANDLER( hd68k_ds3_control_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int val = (offset >> 3) & 1; switch (offset & 7) @@ -1131,12 +1080,12 @@ WRITE16_HANDLER( hd68k_ds3_control_w ) case 2: /* connected to the /BR (bus request) line; this effectively halts */ /* the ADSP at the next instruction boundary */ - adsp_br = !val; - if (adsp_br) - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, ASSERT_LINE); + state->adsp_br = !val; + if (state->adsp_br) + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, ASSERT_LINE); else { - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_HALT, CLEAR_LINE); + cpu_set_input_line(state->adsp, INPUT_LINE_HALT, CLEAR_LINE); /* a yield in this case is not enough */ /* we would need to increase the interleaving otherwise */ /* note that this only affects the test mode */ @@ -1145,17 +1094,17 @@ WRITE16_HANDLER( hd68k_ds3_control_w ) break; case 3: - cpu_set_input_line(hdcpu_adsp, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); - if (val && !ds3_reset) + cpu_set_input_line(state->adsp, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); + if (val && !state->ds3_reset) { - ds3_gflag = 0; - ds3_gcmd = 0; - ds3_gfirqs = 0; - ds3_g68irqs = !ds3_gfirqs; - ds3_send = 0; - update_ds3_irq(); + state->ds3_gflag = 0; + state->ds3_gcmd = 0; + state->ds3_gfirqs = 0; + state->ds3_g68irqs = !state->ds3_gfirqs; + state->ds3_send = 0; + update_ds3_irq(state); } - ds3_reset = val; + state->ds3_reset = val; cpu_yield(space->cpu); logerror("DS III reset = %d\n", val); break; @@ -1180,50 +1129,52 @@ WRITE16_HANDLER( hd68k_ds3_control_w ) READ16_HANDLER( hd68k_ds3_girq_state_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int result = 0x0fff; - if (ds3_g68flag) result ^= 0x8000; - if (ds3_gflag) result ^= 0x4000; - if (ds3_g68irqs) result ^= 0x2000; - if (!adsp_irq_state) result ^= 0x1000; + if (state->ds3_g68flag) result ^= 0x8000; + if (state->ds3_gflag) result ^= 0x4000; + if (state->ds3_g68irqs) result ^= 0x2000; + if (!state->adsp_irq_state) result ^= 0x1000; return result; } READ16_HANDLER( hd68k_ds3_gdata_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; offs_t pc = cpu_get_pc(space->cpu); - ds3_gflag = 0; - update_ds3_irq(); + state->ds3_gflag = 0; + update_ds3_irq(state); - logerror("%06X:hd68k_ds3_gdata_r(%04X)\n", cpu_get_previouspc(space->cpu), ds3_gdata); + logerror("%06X:hd68k_ds3_gdata_r(%04X)\n", cpu_get_previouspc(space->cpu), state->ds3_gdata); /* attempt to optimize the transfer if conditions are right */ - if (space->cpu == cputag_get_cpu(space->machine, "maincpu") && pc == hdds3_transfer_pc && - !(!ds3_g68flag && ds3_g68irqs) && !(ds3_gflag && ds3_gfirqs)) + if (space->cpu == cputag_get_cpu(space->machine, "maincpu") && pc == state->ds3_transfer_pc && + !(!state->ds3_g68flag && state->ds3_g68irqs) && !(state->ds3_gflag && state->ds3_gfirqs)) { UINT32 destaddr = cpu_get_reg(space->cpu, M68K_A1); UINT16 count68k = cpu_get_reg(space->cpu, M68K_D1); - UINT16 mstat = cpu_get_reg(hdcpu_adsp, ADSP2100_MSTAT); - UINT16 i6 = cpu_get_reg(hdcpu_adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC); - UINT16 l6 = cpu_get_reg(hdcpu_adsp, ADSP2100_L6) - 1; - UINT16 m7 = cpu_get_reg(hdcpu_adsp, ADSP2100_M7); + UINT16 mstat = cpu_get_reg(state->adsp, ADSP2100_MSTAT); + UINT16 i6 = cpu_get_reg(state->adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC); + UINT16 l6 = cpu_get_reg(state->adsp, ADSP2100_L6) - 1; + UINT16 m7 = cpu_get_reg(state->adsp, ADSP2100_M7); logerror("%06X:optimizing 68k transfer, %d words\n", cpu_get_previouspc(space->cpu), count68k); - while (count68k > 0 && hdadsp_data_memory[0x16e6] > 0) + while (count68k > 0 && state->adsp_data_memory[0x16e6] > 0) { - memory_write_word(space, destaddr, ds3_gdata); + memory_write_word(space, destaddr, state->ds3_gdata); { - hdadsp_data_memory[0x16e6]--; - ds3_gdata = hdadsp_pgm_memory[i6] >> 8; + state->adsp_data_memory[0x16e6]--; + state->ds3_gdata = state->adsp_pgm_memory[i6] >> 8; i6 = (i6 & ~l6) | ((i6 + m7) & l6); } count68k--; } cpu_set_reg(space->cpu, M68K_D1, count68k); - cpu_set_reg(hdcpu_adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6); - adsp_speedup_count[1]++; + cpu_set_reg(state->adsp, (mstat & 1) ? ADSP2100_MR0 : ADSP2100_MR0_SEC, i6); + state->adsp_speedup_count[1]++; } /* if we just cleared the IRQ, we are going to do some VERY timing critical reads */ @@ -1232,19 +1183,21 @@ READ16_HANDLER( hd68k_ds3_gdata_r ) cpu_spinuntil_trigger(space->cpu, DS3_TRIGGER); cpuexec_triggertime(space->machine, DS3_TRIGGER, ATTOTIME_IN_USEC(5)); - return ds3_gdata; + return state->ds3_gdata; } WRITE16_HANDLER( hd68k_ds3_gdata_w ) { - logerror("%06X:hd68k_ds3_gdata_w(%04X)\n", cpu_get_previouspc(space->cpu), ds3_gdata); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; - COMBINE_DATA(&ds3_g68data); - ds3_g68flag = 1; - ds3_gcmd = offset & 1; - cpu_triggerint(hdcpu_adsp); - update_ds3_irq(); + logerror("%06X:hd68k_ds3_gdata_w(%04X)\n", cpu_get_previouspc(space->cpu), state->ds3_gdata); + + COMBINE_DATA(&state->ds3_g68data); + state->ds3_g68flag = 1; + state->ds3_gcmd = offset & 1; + cpu_triggerint(state->adsp); + update_ds3_irq(state); } @@ -1280,26 +1233,27 @@ WRITE16_HANDLER( hd68k_ds3_sdata_w ) READ16_HANDLER( hdds3_special_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int result; switch (offset & 7) { case 0: - ds3_g68flag = 0; - update_ds3_irq(); - return ds3_g68data; + state->ds3_g68flag = 0; + update_ds3_irq(state); + return state->ds3_g68data; case 1: result = 0x0fff; - if (ds3_gcmd) result ^= 0x8000; - if (ds3_g68flag) result ^= 0x4000; - if (ds3_gflag) result ^= 0x2000; + if (state->ds3_gcmd) result ^= 0x8000; + if (state->ds3_g68flag) result ^= 0x4000; + if (state->ds3_gflag) result ^= 0x2000; return result; case 6: - logerror("ADSP r @ %04x\n", ds3_sim_address); - if (ds3_sim_address < sim_memory_size) - return sim_memory[ds3_sim_address]; + logerror("ADSP r @ %04x\n", state->ds3_sim_address); + if (state->ds3_sim_address < state->sim_memory_size) + return state->sim_memory[state->ds3_sim_address]; else return 0xff; } @@ -1309,16 +1263,18 @@ READ16_HANDLER( hdds3_special_r ) WRITE16_HANDLER( hdds3_special_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* IMPORTANT! these data values also write through to the underlying RAM */ - hdadsp_data_memory[offset] = data; + state->adsp_data_memory[offset] = data; switch (offset & 7) { case 0: logerror("%04X:ADSP sets gdata to %04X\n", cpu_get_previouspc(space->cpu), data); - ds3_gdata = data; - ds3_gflag = 1; - update_ds3_irq(); + state->ds3_gdata = data; + state->ds3_gflag = 1; + update_ds3_irq(state); /* once we've written data, trigger the main CPU to wake up again */ cpuexec_trigger(space->machine, DS3_TRIGGER); @@ -1326,26 +1282,26 @@ WRITE16_HANDLER( hdds3_special_w ) case 1: logerror("%04X:ADSP sets interrupt = %d\n", cpu_get_previouspc(space->cpu), (data >> 1) & 1); - adsp_irq_state = (data >> 1) & 1; + state->adsp_irq_state = (data >> 1) & 1; hd68k_update_interrupts(space->machine); break; case 2: - ds3_send = (data >> 0) & 1; + state->ds3_send = (data >> 0) & 1; break; case 3: - ds3_gfirqs = (data >> 1) & 1; - ds3_g68irqs = !ds3_gfirqs; - update_ds3_irq(); + state->ds3_gfirqs = (data >> 1) & 1; + state->ds3_g68irqs = !state->ds3_gfirqs; + update_ds3_irq(state); break; case 4: - ds3_sim_address = (ds3_sim_address & 0xffff0000) | (data & 0xffff); + state->ds3_sim_address = (state->ds3_sim_address & 0xffff0000) | (data & 0xffff); break; case 5: - ds3_sim_address = (ds3_sim_address & 0xffff) | ((data << 16) & 0x00070000); + state->ds3_sim_address = (state->ds3_sim_address & 0xffff) | ((data << 16) & 0x00070000); break; } } @@ -1374,7 +1330,8 @@ WRITE16_HANDLER( hdds3_control_w ) READ16_HANDLER( hd68k_ds3_program_r ) { - UINT32 *base = &hdadsp_pgm_memory[offset & 0x1fff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 *base = &state->adsp_pgm_memory[offset & 0x1fff]; UINT32 word = *base; return (!(offset & 0x2000)) ? (word >> 8) : (word & 0xff); } @@ -1382,7 +1339,8 @@ READ16_HANDLER( hd68k_ds3_program_r ) WRITE16_HANDLER( hd68k_ds3_program_w ) { - UINT32 *base = &hdadsp_pgm_memory[offset & 0x1fff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 *base = &state->adsp_pgm_memory[offset & 0x1fff]; UINT32 oldword = *base; UINT16 temp; @@ -1416,7 +1374,8 @@ WRITE16_HANDLER( hd68k_ds3_program_w ) void hddsk_update_pif(const device_config *device, UINT32 pins) { - atarigen_sound_int_state = ((pins & DSP32_OUTPUT_PIF) != 0); + atarigen_state *atarigen = (atarigen_state *)device->machine->driver_data; + atarigen->sound_int_state = ((pins & DSP32_OUTPUT_PIF) != 0); hd68k_update_interrupts(device->machine); } @@ -1430,15 +1389,16 @@ void hddsk_update_pif(const device_config *device, UINT32 pins) WRITE16_HANDLER( hd68k_dsk_control_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int val = (offset >> 3) & 1; switch (offset & 7) { case 0: /* DSPRESTN */ - cpu_set_input_line(hdcpu_dsp32, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); + cpu_set_input_line(state->dsp32, INPUT_LINE_RESET, val ? CLEAR_LINE : ASSERT_LINE); break; case 1: /* DSPZN */ - cpu_set_input_line(hdcpu_dsp32, INPUT_LINE_HALT, val ? CLEAR_LINE : ASSERT_LINE); + cpu_set_input_line(state->dsp32, INPUT_LINE_HALT, val ? CLEAR_LINE : ASSERT_LINE); break; case 2: /* ZW1 */ @@ -1470,37 +1430,43 @@ WRITE16_HANDLER( hd68k_dsk_control_w ) READ16_HANDLER( hd68k_dsk_ram_r ) { - return hddsk_ram[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->dsk_ram[offset]; } WRITE16_HANDLER( hd68k_dsk_ram_w ) { - COMBINE_DATA(&hddsk_ram[offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->dsk_ram[offset]); } READ16_HANDLER( hd68k_dsk_zram_r ) { - return hddsk_zram[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->dsk_zram[offset]; } WRITE16_HANDLER( hd68k_dsk_zram_w ) { - COMBINE_DATA(&hddsk_zram[offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->dsk_zram[offset]); } READ16_HANDLER( hd68k_dsk_small_rom_r ) { - return hddsk_rom[offset & 0x1ffff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->dsk_rom[offset & 0x1ffff]; } READ16_HANDLER( hd68k_dsk_rom_r ) { - return hddsk_rom[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->dsk_rom[offset]; } @@ -1513,18 +1479,20 @@ READ16_HANDLER( hd68k_dsk_rom_r ) WRITE16_HANDLER( hd68k_dsk_dsp32_w ) { - hddsk_pio_access = 1; - dsp32c_pio_w(hdcpu_dsp32, offset, data); - hddsk_pio_access = 0; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + state->dsk_pio_access = TRUE; + dsp32c_pio_w(state->dsp32, offset, data); + state->dsk_pio_access = FALSE; } READ16_HANDLER( hd68k_dsk_dsp32_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; UINT16 result; - hddsk_pio_access = 1; - result = dsp32c_pio_r(hdcpu_dsp32, offset); - hddsk_pio_access = 0; + state->dsk_pio_access = TRUE; + result = dsp32c_pio_r(state->dsp32, offset); + state->dsk_pio_access = FALSE; return result; } @@ -1537,39 +1505,42 @@ READ16_HANDLER( hd68k_dsk_dsp32_r ) static TIMER_CALLBACK( rddsp32_sync_cb ) { - *dataptr[param] = dataval[param]; + harddriv_state *state = (harddriv_state *)machine->driver_data; + *state->dataptr[param] = state->dataval[param]; } WRITE32_HANDLER( rddsp32_sync0_w ) { - if (hddsk_pio_access) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->dsk_pio_access) { - UINT32 *dptr = &rddsp32_sync[0][offset]; + UINT32 *dptr = &state->rddsp32_sync[0][offset]; UINT32 newdata = *dptr; COMBINE_DATA(&newdata); - dataptr[next_msp_sync % MAX_MSP_SYNC] = dptr; - dataval[next_msp_sync % MAX_MSP_SYNC] = newdata; - timer_call_after_resynch(space->machine, NULL, next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); + state->dataptr[state->next_msp_sync % MAX_MSP_SYNC] = dptr; + state->dataval[state->next_msp_sync % MAX_MSP_SYNC] = newdata; + timer_call_after_resynch(space->machine, NULL, state->next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); } else - COMBINE_DATA(&rddsp32_sync[0][offset]); + COMBINE_DATA(&state->rddsp32_sync[0][offset]); } WRITE32_HANDLER( rddsp32_sync1_w ) { - if (hddsk_pio_access) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->dsk_pio_access) { - UINT32 *dptr = &rddsp32_sync[1][offset]; + UINT32 *dptr = &state->rddsp32_sync[1][offset]; UINT32 newdata = *dptr; COMBINE_DATA(&newdata); - dataptr[next_msp_sync % MAX_MSP_SYNC] = dptr; - dataval[next_msp_sync % MAX_MSP_SYNC] = newdata; - timer_call_after_resynch(space->machine, NULL, next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); + state->dataptr[state->next_msp_sync % MAX_MSP_SYNC] = dptr; + state->dataval[state->next_msp_sync % MAX_MSP_SYNC] = newdata; + timer_call_after_resynch(space->machine, NULL, state->next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); } else - COMBINE_DATA(&rddsp32_sync[1][offset]); + COMBINE_DATA(&state->rddsp32_sync[1][offset]); } @@ -1621,8 +1592,9 @@ WRITE16_HANDLER( rd68k_slapstic_w ) READ16_HANDLER( rd68k_slapstic_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int bank = slapstic_tweak(space, offset & 0x3fff) * 0x4000; - return hd68k_slapstic_base[bank + (offset & 0x3fff)]; + return state->m68k_slapstic_base[bank + (offset & 0x3fff)]; } @@ -1633,7 +1605,7 @@ READ16_HANDLER( rd68k_slapstic_r ) * *************************************/ -static int st68k_sloop_tweak(offs_t offset) +static int st68k_sloop_tweak(harddriv_state *state, offs_t offset) { static int last_offset; @@ -1642,63 +1614,66 @@ static int st68k_sloop_tweak(offs_t offset) switch (offset) { case 0x78e8: - st68k_sloop_bank = 0; + state->st68k_sloop_bank = 0; break; case 0x6ca4: - st68k_sloop_bank = 1; + state->st68k_sloop_bank = 1; break; case 0x15ea: - st68k_sloop_bank = 2; + state->st68k_sloop_bank = 2; break; case 0x6b28: - st68k_sloop_bank = 3; + state->st68k_sloop_bank = 3; break; } } last_offset = offset; - return st68k_sloop_bank; + return state->st68k_sloop_bank; } WRITE16_HANDLER( st68k_sloop_w ) { - st68k_sloop_tweak(offset & 0x3fff); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + st68k_sloop_tweak(state, offset & 0x3fff); } READ16_HANDLER( st68k_sloop_r ) { - int bank = st68k_sloop_tweak(offset) * 0x4000; - return hd68k_slapstic_base[bank + (offset & 0x3fff)]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int bank = st68k_sloop_tweak(state, offset) * 0x4000; + return state->m68k_slapstic_base[bank + (offset & 0x3fff)]; } READ16_HANDLER( st68k_sloop_alt_r ) { - if (st68k_last_alt_sloop_offset == 0x00fe) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + if (state->st68k_last_alt_sloop_offset == 0x00fe) { switch (offset*2) { case 0x22c: - st68k_sloop_bank = 0; + state->st68k_sloop_bank = 0; break; case 0x1e2: - st68k_sloop_bank = 1; + state->st68k_sloop_bank = 1; break; case 0x1fa: - st68k_sloop_bank = 2; + state->st68k_sloop_bank = 2; break; case 0x206: - st68k_sloop_bank = 3; + state->st68k_sloop_bank = 3; break; } } - st68k_last_alt_sloop_offset = offset*2; - return st68k_sloop_alt_base[offset]; + state->st68k_last_alt_sloop_offset = offset*2; + return state->m68k_sloop_alt_base[offset]; } -static int st68k_protosloop_tweak(offs_t offset) +static int st68k_protosloop_tweak(harddriv_state *state, offs_t offset) { static int last_offset; @@ -1707,34 +1682,36 @@ static int st68k_protosloop_tweak(offs_t offset) switch (offset) { case 0x0001: - st68k_sloop_bank = 0; + state->st68k_sloop_bank = 0; break; case 0x0002: - st68k_sloop_bank = 1; + state->st68k_sloop_bank = 1; break; case 0x0003: - st68k_sloop_bank = 2; + state->st68k_sloop_bank = 2; break; case 0x0004: - st68k_sloop_bank = 3; + state->st68k_sloop_bank = 3; break; } } last_offset = offset; - return st68k_sloop_bank; + return state->st68k_sloop_bank; } WRITE16_HANDLER( st68k_protosloop_w ) { - st68k_protosloop_tweak(offset & 0x3fff); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + st68k_protosloop_tweak(state, offset & 0x3fff); } READ16_HANDLER( st68k_protosloop_r ) { - int bank = st68k_protosloop_tweak(offset) * 0x4000; - return hd68k_slapstic_base[bank + (offset & 0x3fff)]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int bank = st68k_protosloop_tweak(state, offset) * 0x4000; + return state->m68k_slapstic_base[bank + (offset & 0x3fff)]; } @@ -1755,14 +1732,15 @@ READ16_HANDLER( st68k_protosloop_r ) READ16_HANDLER( hdgsp_speedup_r ) { - int result = hdgsp_speedup_addr[0][offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int result = state->gsp_speedup_addr[0][offset]; /* if both this address and the other important address are not $ffff */ /* then we can spin until something gets written */ - if (result != 0xffff && hdgsp_speedup_addr[1][0] != 0xffff && - space->cpu == hdcpu_gsp && cpu_get_pc(space->cpu) == hdgsp_speedup_pc) + if (result != 0xffff && state->gsp_speedup_addr[1][0] != 0xffff && + space->cpu == state->gsp && cpu_get_pc(space->cpu) == state->gsp_speedup_pc) { - gsp_speedup_count[0]++; + state->gsp_speedup_count[0]++; cpu_spinuntil_int(space->cpu); } @@ -1772,21 +1750,25 @@ READ16_HANDLER( hdgsp_speedup_r ) WRITE16_HANDLER( hdgsp_speedup1_w ) { - COMBINE_DATA(&hdgsp_speedup_addr[0][offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + COMBINE_DATA(&state->gsp_speedup_addr[0][offset]); /* if $ffff is written, send an "interrupt" trigger to break us out of the spin loop */ - if (hdgsp_speedup_addr[0][offset] == 0xffff) - cpu_triggerint(hdcpu_gsp); + if (state->gsp_speedup_addr[0][offset] == 0xffff) + cpu_triggerint(state->gsp); } WRITE16_HANDLER( hdgsp_speedup2_w ) { - COMBINE_DATA(&hdgsp_speedup_addr[1][offset]); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + COMBINE_DATA(&state->gsp_speedup_addr[1][offset]); /* if $ffff is written, send an "interrupt" trigger to break us out of the spin loop */ - if (hdgsp_speedup_addr[1][offset] == 0xffff) - cpu_triggerint(hdcpu_gsp); + if (state->gsp_speedup_addr[1][offset] == 0xffff) + cpu_triggerint(state->gsp); } @@ -1801,13 +1783,14 @@ WRITE16_HANDLER( hdgsp_speedup2_w ) READ16_HANDLER( rdgsp_speedup1_r ) { - int result = hdgsp_speedup_addr[0][offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int result = state->gsp_speedup_addr[0][offset]; /* if this address is equal to $f000, spin until something gets written */ - if (space->cpu == hdcpu_gsp && cpu_get_pc(space->cpu) == hdgsp_speedup_pc && + if (space->cpu == state->gsp && cpu_get_pc(space->cpu) == state->gsp_speedup_pc && (result & 0xff) < cpu_get_reg(space->cpu, TMS34010_A1)) { - gsp_speedup_count[0]++; + state->gsp_speedup_count[0]++; cpu_spinuntil_int(space->cpu); } @@ -1817,9 +1800,10 @@ READ16_HANDLER( rdgsp_speedup1_r ) WRITE16_HANDLER( rdgsp_speedup1_w ) { - COMBINE_DATA(&hdgsp_speedup_addr[0][offset]); - if (space->cpu != hdcpu_gsp) - cpu_triggerint(hdcpu_gsp); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->gsp_speedup_addr[0][offset]); + if (space->cpu != state->gsp) + cpu_triggerint(state->gsp); } @@ -1837,11 +1821,12 @@ WRITE16_HANDLER( rdgsp_speedup1_w ) READ16_HANDLER( hdmsp_speedup_r ) { - int data = hdmsp_speedup_addr[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int data = state->msp_speedup_addr[offset]; - if (data == 0 && space->cpu == hdcpu_msp && cpu_get_pc(space->cpu) == hdmsp_speedup_pc) + if (data == 0 && space->cpu == state->msp && cpu_get_pc(space->cpu) == state->msp_speedup_pc) { - msp_speedup_count[0]++; + state->msp_speedup_count[0]++; cpu_spinuntil_int(space->cpu); } @@ -1851,32 +1836,35 @@ READ16_HANDLER( hdmsp_speedup_r ) WRITE16_HANDLER( hdmsp_speedup_w ) { - COMBINE_DATA(&hdmsp_speedup_addr[offset]); - if (offset == 0 && hdmsp_speedup_addr[offset] != 0) - cpu_triggerint(hdcpu_msp); + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + COMBINE_DATA(&state->msp_speedup_addr[offset]); + if (offset == 0 && state->msp_speedup_addr[offset] != 0) + cpu_triggerint(state->msp); } READ16_HANDLER( stmsp_speedup_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* assumes: stmsp_sync[0] -> $80010, stmsp_sync[1] -> $99680, stmsp_sync[2] -> $99d30 */ - if (stmsp_sync[0][0] == 0 && /* 80010 */ - stmsp_sync[0][1] == 0 && /* 80020 */ - stmsp_sync[0][2] == 0 && /* 80030 */ - stmsp_sync[0][3] == 0 && /* 80040 */ - stmsp_sync[0][4] == 0 && /* 80050 */ - stmsp_sync[0][5] == 0 && /* 80060 */ - stmsp_sync[0][6] == 0 && /* 80070 */ - stmsp_sync[1][0] == 0 && /* 99680 */ - stmsp_sync[2][0] == 0xffff && /* 99d30 */ - stmsp_sync[2][1] == 0xffff && /* 99d40 */ - stmsp_sync[2][2] == 0 && /* 99d50 */ + if (state->stmsp_sync[0][0] == 0 && /* 80010 */ + state->stmsp_sync[0][1] == 0 && /* 80020 */ + state->stmsp_sync[0][2] == 0 && /* 80030 */ + state->stmsp_sync[0][3] == 0 && /* 80040 */ + state->stmsp_sync[0][4] == 0 && /* 80050 */ + state->stmsp_sync[0][5] == 0 && /* 80060 */ + state->stmsp_sync[0][6] == 0 && /* 80070 */ + state->stmsp_sync[1][0] == 0 && /* 99680 */ + state->stmsp_sync[2][0] == 0xffff && /* 99d30 */ + state->stmsp_sync[2][1] == 0xffff && /* 99d40 */ + state->stmsp_sync[2][2] == 0 && /* 99d50 */ cpu_get_pc(space->cpu) == 0x3c0) { - msp_speedup_count[0]++; + state->msp_speedup_count[0]++; cpu_spinuntil_int(space->cpu); } - return stmsp_sync[0][1]; + return state->stmsp_sync[0][1]; } @@ -1894,11 +1882,12 @@ READ16_HANDLER( stmsp_speedup_r ) READ16_HANDLER( hdadsp_speedup_r ) { - int data = hdadsp_data_memory[0x1fff]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int data = state->adsp_data_memory[0x1fff]; - if (data == 0xffff && space->cpu == hdcpu_adsp && cpu_get_pc(space->cpu) <= 0x3b) + if (data == 0xffff && space->cpu == state->adsp && cpu_get_pc(space->cpu) <= 0x3b) { - adsp_speedup_count[0]++; + state->adsp_speedup_count[0]++; cpu_spinuntil_int(space->cpu); } @@ -1908,11 +1897,12 @@ READ16_HANDLER( hdadsp_speedup_r ) READ16_HANDLER( hdds3_speedup_r ) { - int data = *hdds3_speedup_addr; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int data = *state->ds3_speedup_addr; - if (data != 0 && space->cpu == hdcpu_adsp && cpu_get_pc(space->cpu) == hdds3_speedup_pc) + if (data != 0 && space->cpu == state->adsp && cpu_get_pc(space->cpu) == state->ds3_speedup_pc) { - adsp_speedup_count[2]++; + state->adsp_speedup_count[2]++; cpu_spinuntil_int(space->cpu); } diff --git a/src/mame/video/arcadecl.c b/src/mame/video/arcadecl.c index 1be08e23636..c08e3a1537c 100644 --- a/src/mame/video/arcadecl.c +++ b/src/mame/video/arcadecl.c @@ -9,23 +9,12 @@ #include "driver.h" -#include "machine/atarigen.h" #include "arcadecl.h" /************************************* * - * Statics - * - *************************************/ - -static UINT8 has_mo; - - - -/************************************* - * * Video system start * *************************************/ @@ -68,6 +57,7 @@ VIDEO_START( arcadecl ) 0, /* resulting value to indicate "special" */ 0, /* callback routine for special entries */ }; + rampart_state *state = (rampart_state *)machine->driver_data; /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -75,7 +65,7 @@ VIDEO_START( arcadecl ) /* set the intial scroll offset */ atarimo_set_xscroll(0, -4); atarimo_set_yscroll(0, 0x110); - has_mo = (machine->gfx[0]->total_elements > 10); + state->has_mo = (machine->gfx[0]->total_elements > 10); } @@ -88,11 +78,13 @@ VIDEO_START( arcadecl ) VIDEO_UPDATE( arcadecl ) { + rampart_state *state = (rampart_state *)screen->machine->driver_data; + /* draw the playfield */ rampart_bitmap_render(screen->machine, bitmap, cliprect); /* draw and merge the MO */ - if (has_mo) + if (state->has_mo) { atarimo_rect_list rectlist; bitmap_t *mobitmap; diff --git a/src/mame/video/atarig1.c b/src/mame/video/atarig1.c index d3ced74186c..4ec329e2968 100644 --- a/src/mame/video/atarig1.c +++ b/src/mame/video/atarig1.c @@ -12,37 +12,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT8 atarig1_pitfight; - - - -/************************************* - * - * Statics - * - *************************************/ - -static int pfscroll_xoffset; -static UINT16 current_control; -static UINT8 playfield_tile_bank; -static UINT16 playfield_xscroll; -static UINT16 playfield_yscroll; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + atarig1_state *state = (atarig1_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0xfff; int color = (data >> 12) & 0x0f; int opaque = data & 0x8000; @@ -52,8 +29,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = (playfield_tile_bank << 12) | (data & 0xfff); + atarig1_state *state = (atarig1_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = (state->playfield_tile_bank << 12) | (data & 0xfff); int color = (data >> 12) & 7; SET_TILE_INFO(0, code, color, (data >> 15) & 1); } @@ -109,32 +87,29 @@ VIDEO_START( atarig1 ) {{ 0 }}, /* mask for the priority */ {{ 0 }} /* mask for the VRAM target */ }; + atarig1_state *state = (atarig1_state *)machine->driver_data; /* blend the playfields and free the temporary one */ atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x10); /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,64); /* initialize the motion objects */ - atarirle_init(machine, 0, atarig1_pitfight ? &modesc_pitfight : &modesc_hydra); + atarirle_init(machine, 0, state->is_pitfight ? &modesc_pitfight : &modesc_hydra); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* reset statics */ - current_control = 0; - pfscroll_xoffset = atarig1_pitfight ? 2 : 0; - playfield_tile_bank = 0; - playfield_xscroll = 0; - playfield_yscroll = 0; + state->pfscroll_xoffset = state->is_pitfight ? 2 : 0; /* state saving */ - state_save_register_global(machine, current_control); - state_save_register_global(machine, playfield_tile_bank); - state_save_register_global(machine, playfield_xscroll); - state_save_register_global(machine, playfield_yscroll); + state_save_register_global(machine, state->current_control); + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_xscroll); + state_save_register_global(machine, state->playfield_yscroll); } @@ -147,22 +122,25 @@ VIDEO_START( atarig1 ) WRITE16_HANDLER( atarig1_mo_control_w ) { + atarig1_state *state = (atarig1_state *)space->machine->driver_data; + logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); /* set the control value */ - COMBINE_DATA(¤t_control); + COMBINE_DATA(&state->current_control); } void atarig1_scanline_update(const device_config *screen, int scanline) { - UINT16 *base = &atarigen_alpha[(scanline / 8) * 64 + 48]; + atarig1_state *state = (atarig1_state *)screen->machine->driver_data; + UINT16 *base = &state->atarigen.alpha[(scanline / 8) * 64 + 48]; int i; //if (scanline == 0) logerror("-------\n"); /* keep in range */ - if (base >= &atarigen_alpha[0x800]) + if (base >= &state->atarigen.alpha[0x800]) return; video_screen_update_partial(screen, MAX(scanline - 1, 0)); @@ -175,12 +153,12 @@ void atarig1_scanline_update(const device_config *screen, int scanline) word = *base++; if (word & 0x8000) { - int newscroll = ((word >> 6) + pfscroll_xoffset) & 0x1ff; - if (newscroll != playfield_xscroll) + int newscroll = ((word >> 6) + state->pfscroll_xoffset) & 0x1ff; + if (newscroll != state->playfield_xscroll) { video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll); - playfield_xscroll = newscroll; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_xscroll = newscroll; } } @@ -190,17 +168,17 @@ void atarig1_scanline_update(const device_config *screen, int scanline) { int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff; int newbank = word & 7; - if (newscroll != playfield_yscroll) + if (newscroll != state->playfield_yscroll) { video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); - playfield_yscroll = newscroll; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_yscroll = newscroll; } - if (newbank != playfield_tile_bank) + if (newbank != state->playfield_tile_bank) { video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_tile_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_tile_bank = newbank; } } } @@ -216,13 +194,15 @@ void atarig1_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( atarig1 ) { + atarig1_state *state = (atarig1_state *)screen->machine->driver_data; + /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* copy the motion objects on top */ copybitmap_trans(bitmap, atarirle_get_vram(0, 0), 0, 0, 0, 0, cliprect, 0); /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/atarig42.c b/src/mame/video/atarig42.c index 85874898692..0a1e1ad0539 100644 --- a/src/mame/video/atarig42.c +++ b/src/mame/video/atarig42.c @@ -27,28 +27,10 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 atarig42_playfield_base; -UINT16 atarig42_motion_object_base; -UINT16 atarig42_motion_object_mask; - - - -/************************************* - * * Statics * *************************************/ -static UINT16 current_control; -static UINT8 playfield_tile_bank; -static UINT8 playfield_color_bank; -static UINT16 playfield_xscroll; -static UINT16 playfield_yscroll; - /************************************* @@ -59,7 +41,8 @@ static UINT16 playfield_yscroll; static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + atarig42_state *state = (atarig42_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0xfff; int color = (data >> 12) & 0x0f; int opaque = data & 0x8000; @@ -69,11 +52,12 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = (playfield_tile_bank << 12) | (data & 0xfff); - int color = (atarig42_playfield_base >> 5) + ((playfield_color_bank << 3) & 0x18) + ((data >> 12) & 7); + atarig42_state *state = (atarig42_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = (state->playfield_tile_bank << 12) | (data & 0xfff); + int color = (state->playfield_base >> 5) + ((state->playfield_color_bank << 3) & 0x18) + ((data >> 12) & 7); SET_TILE_INFO(0, code, color, (data >> 15) & 1); - tileinfo->category = (playfield_color_bank >> 2) & 7; + tileinfo->category = (state->playfield_color_bank >> 2) & 7; } @@ -113,6 +97,7 @@ VIDEO_START( atarig42 ) {{ 0,0x0e00,0,0,0,0,0,0 }}, /* mask for the priority */ {{ 0 }} /* mask for the VRAM target */ }; + atarig42_state *state = (atarig42_state *)machine->driver_data; atarirle_desc adjusted_modesc = modesc; int i; @@ -120,24 +105,17 @@ VIDEO_START( atarig42 ) atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30); /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarig42_playfield_scan, 8,8, 128,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarig42_playfield_scan, 8,8, 128,64); /* initialize the motion objects */ - adjusted_modesc.palettebase = atarig42_motion_object_base; + adjusted_modesc.palettebase = state->motion_object_base; for (i = 0; i < 8; i++) - adjusted_modesc.colormask.data[i] &= atarig42_motion_object_mask; + adjusted_modesc.colormask.data[i] &= state->motion_object_mask; atarirle_init(machine, 0, &adjusted_modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); - - /* reset statics */ - current_control = 0; - playfield_tile_bank = 0; - playfield_color_bank = 0; - playfield_xscroll = 0; - playfield_yscroll = 0; + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -150,22 +128,25 @@ VIDEO_START( atarig42 ) WRITE16_HANDLER( atarig42_mo_control_w ) { + atarig42_state *state = (atarig42_state *)space->machine->driver_data; + logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); /* set the control value */ - COMBINE_DATA(¤t_control); + COMBINE_DATA(&state->current_control); } void atarig42_scanline_update(const device_config *screen, int scanline) { - UINT16 *base = &atarigen_alpha[(scanline / 8) * 64 + 48]; + atarig42_state *state = (atarig42_state *)screen->machine->driver_data; + UINT16 *base = &state->atarigen.alpha[(scanline / 8) * 64 + 48]; int i; if (scanline == 0) logerror("-------\n"); /* keep in range */ - if (base >= &atarigen_alpha[0x800]) + if (base >= &state->atarigen.alpha[0x800]) return; /* update the playfield scrolls */ @@ -178,19 +159,19 @@ void atarig42_scanline_update(const device_config *screen, int scanline) { int newscroll = (word >> 5) & 0x3ff; int newbank = word & 0x1f; - if (newscroll != playfield_xscroll) + if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll); - playfield_xscroll = newscroll; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_xscroll = newscroll; } - if (newbank != playfield_color_bank) + if (newbank != state->playfield_color_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_color_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_color_bank = newbank; } } @@ -199,19 +180,19 @@ void atarig42_scanline_update(const device_config *screen, int scanline) { int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff; int newbank = word & 7; - if (newscroll != playfield_yscroll) + if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); - playfield_yscroll = newscroll; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_yscroll = newscroll; } - if (newbank != playfield_tile_bank) + if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_tile_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_tile_bank = newbank; } } } @@ -227,18 +208,19 @@ void atarig42_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( atarig42 ) { + atarig42_state *state = (atarig42_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 1, 1); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 2, 2); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 3, 3); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 4, 4); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 5, 5); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 6, 6); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 7, 7); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 1, 1); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 2, 2); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 3, 3); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 4, 4); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 5, 5); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 6, 6); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 7, 7); /* copy the motion objects on top */ { @@ -267,6 +249,6 @@ VIDEO_UPDATE( atarig42 ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/atarigt.c b/src/mame/video/atarigt.c index 5a00edf72d4..d97e7695778 100644 --- a/src/mame/video/atarigt.c +++ b/src/mame/video/atarigt.c @@ -24,52 +24,15 @@ #include "atarigt.h" - /************************************* * * Constants * *************************************/ -#define CRAM_ENTRIES 0x4000 -#define TRAM_ENTRIES 0x4000 -#define MRAM_ENTRIES 0x8000 - - - -/************************************* - * - * Globals we own - * - *************************************/ - -UINT16 *atarigt_colorram; - - - -/************************************* - * - * Statics - * - *************************************/ - -static bitmap_t *pf_bitmap; -static bitmap_t *an_bitmap; - -static UINT8 playfield_tile_bank; -static UINT8 playfield_color_bank; -static UINT16 playfield_xscroll; -static UINT16 playfield_yscroll; - -static UINT32 tram_checksum; -static UINT16 *cram, *tram; -static UINT32 *mram; - -static pen_t *substitute_pens; - -static UINT32 *expanded_mram; - -static UINT8 rshift, gshift, bshift; +#define RSHIFT 16 +#define GSHIFT 8 +#define BSHIFT 0 @@ -81,7 +44,8 @@ static UINT8 rshift, gshift, bshift; static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha32[tile_index / 2] >> (16 * (~tile_index & 1)); + atarigt_state *state = (atarigt_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha32[tile_index / 2] >> (16 * (~tile_index & 1)); int code = data & 0xfff; int color = (data >> 12) & 0x0f; SET_TILE_INFO(1, code, color, 0); @@ -90,8 +54,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield32[tile_index / 2] >> (16 * (~tile_index & 1)); - int code = (playfield_tile_bank << 12) | (data & 0xfff); + atarigt_state *state = (atarigt_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield32[tile_index / 2] >> (16 * (~tile_index & 1)); + int code = (state->playfield_tile_bank << 12) | (data & 0xfff); int color = (data >> 12) & 7; SET_TILE_INFO(0, code, color, (data >> 15) & 1); } @@ -133,30 +98,29 @@ VIDEO_START( atarigt ) {{ 0,0x0e00,0,0,0,0,0,0 }}, /* mask for the priority */ {{ 0,0x8000,0,0,0,0,0,0 }} /* mask for the VRAM target */ }; + atarigt_state *state = (atarigt_state *)machine->driver_data; atarirle_desc adjusted_modesc = modesc; + pen_t *substitute_pens; int i, width, height; /* blend the playfields and free the temporary one */ atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30); /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarigt_playfield_scan, 8,8, 128,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarigt_playfield_scan, 8,8, 128,64); /* initialize the motion objects */ atarirle_init(machine, 0, &adjusted_modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); /* allocate temp bitmaps */ width = video_screen_get_width(machine->primary_screen); height = video_screen_get_height(machine->primary_screen); - pf_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); - an_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); - - /* allocate memory */ - expanded_mram = auto_alloc_array(machine, UINT32, MRAM_ENTRIES * 3); + state->pf_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); + state->an_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); /* map pens 1:1 */ substitute_pens = auto_alloc_array(machine, pen_t, 65536); @@ -164,18 +128,8 @@ VIDEO_START( atarigt ) substitute_pens[i] = i; machine->pens = substitute_pens; - /* compute shift values */ - rshift = 16; - gshift = 8; - bshift = 0; - /* reset statics */ - playfield_tile_bank = 0; - playfield_color_bank = 0; - playfield_xscroll = 0; - playfield_yscroll = 0; - tram_checksum = 0; - memset(atarigt_colorram, 0, 0x80000); + memset(state->colorram, 0, 0x80000); } @@ -186,34 +140,34 @@ VIDEO_START( atarigt ) * *************************************/ -void atarigt_colorram_w(offs_t address, UINT16 data, UINT16 mem_mask) +void atarigt_colorram_w(atarigt_state *state, offs_t address, UINT16 data, UINT16 mem_mask) { UINT16 olddata; /* update the raw data */ address = (address & 0x7ffff) / 2; - olddata = atarigt_colorram[address]; - COMBINE_DATA(&atarigt_colorram[address]); + olddata = state->colorram[address]; + COMBINE_DATA(&state->colorram[address]); /* update the TRAM checksum */ if (address >= 0x10000 && address < 0x14000) - tram_checksum += atarigt_colorram[address] - olddata; + state->tram_checksum += state->colorram[address] - olddata; /* update expanded MRAM */ else if (address >= 0x20000 && address < 0x28000) { - expanded_mram[0 * MRAM_ENTRIES + (address & 0x7fff)] = (atarigt_colorram[address] >> 8) << rshift; - expanded_mram[1 * MRAM_ENTRIES + (address & 0x7fff)] = (atarigt_colorram[address] & 0xff) << gshift; + state->expanded_mram[0 * MRAM_ENTRIES + (address & 0x7fff)] = (state->colorram[address] >> 8) << RSHIFT; + state->expanded_mram[1 * MRAM_ENTRIES + (address & 0x7fff)] = (state->colorram[address] & 0xff) << GSHIFT; } else if (address >= 0x30000 && address < 0x38000) - expanded_mram[2 * MRAM_ENTRIES + (address & 0x7fff)] = (atarigt_colorram[address] & 0xff) << bshift; + state->expanded_mram[2 * MRAM_ENTRIES + (address & 0x7fff)] = (state->colorram[address] & 0xff) << BSHIFT; } -UINT16 atarigt_colorram_r(offs_t address) +UINT16 atarigt_colorram_r(atarigt_state *state, offs_t address) { address &= 0x7ffff; - return atarigt_colorram[address / 2]; + return state->colorram[address / 2]; } @@ -226,11 +180,12 @@ UINT16 atarigt_colorram_r(offs_t address) void atarigt_scanline_update(const device_config *screen, int scanline) { - UINT32 *base = &atarigen_alpha32[(scanline / 8) * 32 + 24]; + atarigt_state *state = (atarigt_state *)screen->machine->driver_data; + UINT32 *base = &state->atarigen.alpha32[(scanline / 8) * 32 + 24]; int i; /* keep in range */ - if (base >= &atarigen_alpha32[0x400]) + if (base >= &state->atarigen.alpha32[0x400]) return; /* update the playfield scrolls */ @@ -242,19 +197,19 @@ void atarigt_scanline_update(const device_config *screen, int scanline) { int newscroll = (word >> 21) & 0x3ff; int newbank = (word >> 16) & 0x1f; - if (newscroll != playfield_xscroll) + if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll); - playfield_xscroll = newscroll; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_xscroll = newscroll; } - if (newbank != playfield_color_bank) + if (newbank != state->playfield_color_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_palette_offset(atarigen_playfield_tilemap, (newbank & 0x1f) << 8); - playfield_color_bank = newbank; + tilemap_set_palette_offset(state->atarigen.playfield_tilemap, (newbank & 0x1f) << 8); + state->playfield_color_bank = newbank; } } @@ -262,19 +217,19 @@ void atarigt_scanline_update(const device_config *screen, int scanline) { int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff; int newbank = word & 15; - if (newscroll != playfield_yscroll) + if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); - playfield_yscroll = newscroll; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_yscroll = newscroll; } - if (newbank != playfield_tile_bank) + if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_tile_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_tile_bank = newbank; } } } @@ -566,34 +521,37 @@ PrimRage GALs: VIDEO_UPDATE( atarigt ) { + atarigt_state *state = (atarigt_state *)screen->machine->driver_data; bitmap_t *mo_bitmap = atarirle_get_vram(0, 0); bitmap_t *tm_bitmap = atarirle_get_vram(0, 1); + UINT16 *cram, *tram; int color_latch; + UINT32 *mram; int x, y; /* draw the playfield */ - tilemap_draw(pf_bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(state->pf_bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw the alpha layer */ - tilemap_draw(an_bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(state->an_bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* cache pointers */ - color_latch = atarigt_colorram[0x30000/2]; - cram = (UINT16 *)&atarigt_colorram[0x00000/2] + 0x2000 * ((color_latch >> 3) & 1); - tram = (UINT16 *)&atarigt_colorram[0x20000/2] + 0x1000 * ((color_latch >> 4) & 3); - mram = expanded_mram + 0x2000 * ((color_latch >> 6) & 3); + color_latch = state->colorram[0x30000/2]; + cram = (UINT16 *)&state->colorram[0x00000/2] + 0x2000 * ((color_latch >> 3) & 1); + tram = (UINT16 *)&state->colorram[0x20000/2] + 0x1000 * ((color_latch >> 4) & 3); + mram = state->expanded_mram + 0x2000 * ((color_latch >> 6) & 3); /* now do the nasty blend */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) { - UINT16 *an = (UINT16 *)an_bitmap->base + y * an_bitmap->rowpixels; - UINT16 *pf = (UINT16 *)pf_bitmap->base + y * pf_bitmap->rowpixels; + UINT16 *an = (UINT16 *)state->an_bitmap->base + y * state->an_bitmap->rowpixels; + UINT16 *pf = (UINT16 *)state->pf_bitmap->base + y * state->pf_bitmap->rowpixels; UINT16 *mo = (UINT16 *)mo_bitmap->base + y * mo_bitmap->rowpixels; UINT16 *tm = (UINT16 *)tm_bitmap->base + y * tm_bitmap->rowpixels; UINT32 *dst = (UINT32 *)bitmap->base + y * bitmap->rowpixels; /* Primal Rage: no TRAM, slightly different priorities */ - if (atarigt_is_primrage) + if (state->is_primrage) { for (x = cliprect->min_x; x <= cliprect->max_x; x++) { @@ -620,7 +578,7 @@ VIDEO_UPDATE( atarigt ) /* final override */ if (color_latch & 7) if (!(pf[x] & 0x3f) || !(pf[x] & 0x2000)) - rgb = (0xff << rshift) | (0xff << gshift) | (0xff << bshift); + rgb = (0xff << RSHIFT) | (0xff << GSHIFT) | (0xff << BSHIFT); dst[x] = rgb; } @@ -678,7 +636,7 @@ VIDEO_UPDATE( atarigt ) /* final override */ if (color_latch & 7) if (!(pf[x] & 0x3f) || !(pf[x] & 0x2000)) - rgb = (0xff << rshift) | (0xff << gshift) | (0xff << bshift); + rgb = (0xff << RSHIFT) | (0xff << GSHIFT) | (0xff << BSHIFT); dst[x] = rgb; } diff --git a/src/mame/video/atarigx2.c b/src/mame/video/atarigx2.c index b4b347c5f61..ea4b5cfc940 100644 --- a/src/mame/video/atarigx2.c +++ b/src/mame/video/atarigx2.c @@ -14,7 +14,7 @@ Upper bits come from the low 5 bits of the HSCROLL value in alpha RAM Playfield bank comes from low 2 bits of the VSCROLL value in alpha RAM - For GX2, there are 4 bits of bank + For GX2, there are 4 bits of bank1 ****************************************************************************/ @@ -27,39 +27,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 atarigx2_playfield_base; -UINT16 atarigx2_motion_object_base; -UINT16 atarigx2_motion_object_mask; - - - -/************************************* - * - * Statics - * - *************************************/ - -static UINT16 current_control; -static UINT8 playfield_tile_bank; -static UINT8 playfield_color_bank; -static UINT16 playfield_xscroll; -static UINT16 playfield_yscroll; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha32[tile_index / 2] >> (16 * (~tile_index & 1)); + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha32[tile_index / 2] >> (16 * (~tile_index & 1)); int code = data & 0xfff; int color = (data >> 12) & 0x0f; int opaque = data & 0x8000; @@ -69,11 +44,12 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield32[tile_index / 2] >> (16 * (~tile_index & 1)); - int code = (playfield_tile_bank << 12) | (data & 0xfff); - int color = (atarigx2_playfield_base >> 5) + ((playfield_color_bank << 3) & 0x18) + ((data >> 12) & 7); + atarigx2_state *state = (atarigx2_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield32[tile_index / 2] >> (16 * (~tile_index & 1)); + int code = (state->playfield_tile_bank << 12) | (data & 0xfff); + int color = (state->playfield_base >> 5) + ((state->playfield_color_bank << 3) & 0x18) + ((data >> 12) & 7); SET_TILE_INFO(0, code, color, (data >> 15) & 1); - tileinfo->category = (playfield_color_bank >> 2) & 7; + tileinfo->category = (state->playfield_color_bank >> 2) & 7; } @@ -113,6 +89,7 @@ VIDEO_START( atarigx2 ) {{ 0,0x0e00,0,0,0,0,0,0 }}, /* mask for the priority */ {{ 0 }} /* mask for the VRAM target */ }; + atarigx2_state *state = (atarigx2_state *)machine->driver_data; atarirle_desc adjusted_modesc = modesc; int i; @@ -120,24 +97,17 @@ VIDEO_START( atarigx2 ) atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30); /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarigx2_playfield_scan, 8,8, 128,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, atarigx2_playfield_scan, 8,8, 128,64); /* initialize the motion objects */ - adjusted_modesc.palettebase = atarigx2_motion_object_base; + adjusted_modesc.palettebase = state->motion_object_base; for (i = 0; i < 8; i++) - adjusted_modesc.colormask.data[i] &= atarigx2_motion_object_mask; + adjusted_modesc.colormask.data[i] &= state->motion_object_mask; atarirle_init(machine, 0, &adjusted_modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); - - /* reset statics */ - current_control = 0; - playfield_tile_bank = 0; - playfield_color_bank = 0; - playfield_xscroll = 0; - playfield_yscroll = 0; + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -150,22 +120,25 @@ VIDEO_START( atarigx2 ) WRITE16_HANDLER( atarigx2_mo_control_w ) { + atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; + logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); /* set the control value */ - COMBINE_DATA(¤t_control); + COMBINE_DATA(&state->current_control); } void atarigx2_scanline_update(const device_config *screen, int scanline) { - UINT32 *base = &atarigen_alpha32[(scanline / 8) * 32 + 24]; + atarigx2_state *state = (atarigx2_state *)screen->machine->driver_data; + UINT32 *base = &state->atarigen.alpha32[(scanline / 8) * 32 + 24]; int i; if (scanline == 0) logerror("-------\n"); /* keep in range */ - if (base >= &atarigen_alpha32[0x400]) + if (base >= &state->atarigen.alpha32[0x400]) return; /* update the playfield scrolls */ @@ -177,19 +150,19 @@ void atarigx2_scanline_update(const device_config *screen, int scanline) { int newscroll = (word >> 21) & 0x3ff; int newbank = (word >> 16) & 0x1f; - if (newscroll != playfield_xscroll) + if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll); - playfield_xscroll = newscroll; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_xscroll = newscroll; } - if (newbank != playfield_color_bank) + if (newbank != state->playfield_color_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_color_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_color_bank = newbank; } } @@ -197,19 +170,19 @@ void atarigx2_scanline_update(const device_config *screen, int scanline) { int newscroll = ((word >> 6) - (scanline + i)) & 0x1ff; int newbank = word & 15; - if (newscroll != playfield_yscroll) + if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); - playfield_yscroll = newscroll; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_yscroll = newscroll; } - if (newbank != playfield_tile_bank) + if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) video_screen_update_partial(screen, scanline + i - 1); - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); - playfield_tile_bank = newbank; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); + state->playfield_tile_bank = newbank; } } } @@ -225,18 +198,19 @@ void atarigx2_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( atarigx2 ) { + atarigx2_state *state = (atarigx2_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 1, 1); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 2, 2); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 3, 3); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 4, 4); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 5, 5); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 6, 6); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 7, 7); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 1, 1); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 2, 2); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 3, 3); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 4, 4); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 5, 5); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 6, 6); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 7, 7); /* copy the motion objects on top */ { @@ -260,6 +234,6 @@ VIDEO_UPDATE( atarigx2 ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c index 540937c000b..cf1a1ddceb0 100644 --- a/src/mame/video/atarisy1.c +++ b/src/mame/video/atarisy1.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "atarisy1.h" @@ -35,35 +34,10 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 *atarisy1_bankselect; - - - -/************************************* - * * Statics * *************************************/ -/* playfield parameters */ -static UINT16 playfield_lookup[256]; -static UINT8 playfield_tile_bank; -static UINT16 playfield_priority_pens; -static emu_timer *yscroll_reset_timer; - -/* INT3 tracking */ -static int next_timer_scanline; -static emu_timer *scanline_timer; -static emu_timer *int3off_timer; - -/* graphics bank tracking */ -static UINT8 bank_gfx[3][8]; -static UINT8 bank_color_shift[MAX_GFX_ELEMENTS]; - static const gfx_layout objlayout_4bpp = { 8,8, /* 8*8 sprites */ @@ -122,7 +96,8 @@ static TIMER_CALLBACK( reset_yscroll_callback ); static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = (data >> 10) & 0x07; int opaque = data & 0x2000; @@ -132,11 +107,12 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - UINT16 lookup = playfield_lookup[((data >> 8) & 0x7f) | (playfield_tile_bank << 7)]; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + UINT16 lookup = state->playfield_lookup[((data >> 8) & 0x7f) | (state->playfield_tile_bank << 7)]; int gfxindex = (lookup >> 8) & 15; int code = ((lookup & 0xff) << 8) | (data & 0xff); - int color = 0x20 + (((lookup >> 12) & 15) << bank_color_shift[gfxindex]); + int color = 0x20 + (((lookup >> 12) & 15) << state->bank_color_shift[gfxindex]); SET_TILE_INFO(gfxindex, code, color, (data >> 15) & 1); } @@ -187,23 +163,24 @@ VIDEO_START( atarisy1 ) 0 /* callback routine for special entries */ }; + atarisy1_state *state = (atarisy1_state *)machine->driver_data; UINT16 motable[256]; UINT16 *codelookup; UINT8 *colorlookup, *gfxlookup; int i, size; /* first decode the graphics */ - decode_gfx(machine, playfield_lookup, motable); + decode_gfx(machine, state->playfield_lookup, motable); /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* modify the motion object code lookup */ codelookup = atarimo_get_code_lookup(0, &size); @@ -221,10 +198,10 @@ VIDEO_START( atarisy1 ) /* reset the statics */ atarimo_set_yscroll(0, 256); - next_timer_scanline = -1; - scanline_timer = timer_alloc(machine, int3_callback, NULL); - int3off_timer = timer_alloc(machine, int3off_callback, NULL); - yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); + state->next_timer_scanline = -1; + state->scanline_timer = timer_alloc(machine, int3_callback, NULL); + state->int3off_timer = timer_alloc(machine, int3off_callback, NULL); + state->yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); } @@ -237,7 +214,8 @@ VIDEO_START( atarisy1 ) WRITE16_HANDLER( atarisy1_bankselect_w ) { - UINT16 oldselect = *atarisy1_bankselect; + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; + UINT16 oldselect = *state->bankselect; UINT16 newselect = oldselect, diff; int scanline = video_screen_get_vpos(space->machine->primary_screen); @@ -263,12 +241,12 @@ WRITE16_HANDLER( atarisy1_bankselect_w ) /* playfield bank select */ if (diff & 0x0004) { - playfield_tile_bank = (newselect >> 2) & 1; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank = (newselect >> 2) & 1; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } /* stash the new value */ - *atarisy1_bankselect = newselect; + *state->bankselect = newselect; } @@ -281,14 +259,15 @@ WRITE16_HANDLER( atarisy1_bankselect_w ) WRITE16_HANDLER( atarisy1_priority_w ) { - UINT16 oldpens = playfield_priority_pens; + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; + UINT16 oldpens = state->playfield_priority_pens; UINT16 newpens = oldpens; /* force a partial update in case this changes mid-screen */ COMBINE_DATA(&newpens); if (oldpens != newpens) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); - playfield_priority_pens = newpens; + state->playfield_priority_pens = newpens; } @@ -301,7 +280,8 @@ WRITE16_HANDLER( atarisy1_priority_w ) WRITE16_HANDLER( atarisy1_xscroll_w ) { - UINT16 oldscroll = *atarigen_xscroll; + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.xscroll; UINT16 newscroll = oldscroll; /* force a partial update in case this changes mid-screen */ @@ -310,10 +290,10 @@ WRITE16_HANDLER( atarisy1_xscroll_w ) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* set the new scroll value */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); /* update the data */ - *atarigen_xscroll = newscroll; + *state->atarigen.xscroll = newscroll; } @@ -326,13 +306,15 @@ WRITE16_HANDLER( atarisy1_xscroll_w ) static TIMER_CALLBACK( reset_yscroll_callback ) { - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, param); + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, param); } WRITE16_HANDLER( atarisy1_yscroll_w ) { - UINT16 oldscroll = *atarigen_yscroll; + atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; int scanline = video_screen_get_vpos(space->machine->primary_screen); int adjusted_scroll; @@ -346,14 +328,14 @@ WRITE16_HANDLER( atarisy1_yscroll_w ) adjusted_scroll = newscroll; if (scanline <= video_screen_get_visible_area(space->machine->primary_screen)->max_y) adjusted_scroll -= (scanline + 1); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, adjusted_scroll); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, adjusted_scroll); /* but since we've adjusted it, we must reset it to the normal value once we hit scanline 0 again */ - timer_adjust_oneshot(yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll); + timer_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll); /* update the data */ - *atarigen_yscroll = newscroll; + *state->atarigen.yscroll = newscroll; } @@ -414,16 +396,17 @@ static TIMER_CALLBACK( int3off_callback ) static TIMER_CALLBACK( int3_callback ) { + atarisy1_state *state = (atarisy1_state *)machine->driver_data; int scanline = param; /* update the state */ atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu")); /* set a timer to turn it off */ - timer_adjust_oneshot(int3off_timer, video_screen_get_scan_period(machine->primary_screen), 0); + timer_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(machine->primary_screen), 0); /* determine the time of the next one */ - next_timer_scanline = -1; + state->next_timer_scanline = -1; update_timers(machine, scanline); } @@ -437,7 +420,8 @@ static TIMER_CALLBACK( int3_callback ) READ16_HANDLER( atarisy1_int3state_r ) { - return atarigen_scanline_int_state ? 0x0080 : 0x0000; + atarigen_state *atarigen = (atarigen_state *)space->machine->driver_data; + return atarigen->scanline_int_state ? 0x0080 : 0x0000; } @@ -450,6 +434,7 @@ READ16_HANDLER( atarisy1_int3state_r ) static void update_timers(running_machine *machine, int scanline) { + atarisy1_state *state = (atarisy1_state *)machine->driver_data; UINT16 *base = &atarimo_0_spriteram[atarimo_get_bank(0) * 64 * 4]; int link = 0, best = scanline, found = 0; UINT8 spritevisit[64]; @@ -493,15 +478,15 @@ static void update_timers(running_machine *machine, int scanline) best = -1; /* update the timer */ - if (best != next_timer_scanline) + if (best != state->next_timer_scanline) { - next_timer_scanline = best; + state->next_timer_scanline = best; /* set a new one */ if (best != -1) - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best); + timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best); else - timer_adjust_oneshot(scanline_timer, attotime_never, 0); + timer_adjust_oneshot(state->scanline_timer, attotime_never, 0); } } @@ -515,12 +500,13 @@ static void update_timers(running_machine *machine, int scanline) VIDEO_UPDATE( atarisy1 ) { + atarisy1_state *state = (atarisy1_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -544,7 +530,7 @@ VIDEO_UPDATE( atarisy1 ) else { /* priority pens for playfield color 0 */ - if ((pf[x] & 0xf8) != 0 || !(playfield_priority_pens & (1 << (pf[x] & 0x07)))) + if ((pf[x] & 0xf8) != 0 || !(state->playfield_priority_pens & (1 << (pf[x] & 0x07)))) pf[x] = mo[x]; } @@ -554,7 +540,7 @@ VIDEO_UPDATE( atarisy1 ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } @@ -568,12 +554,13 @@ VIDEO_UPDATE( atarisy1 ) static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *molookup) { + atarisy1_state *state = (atarisy1_state *)machine->driver_data; UINT8 *prom1 = &memory_region(machine, "proms")[0x000]; UINT8 *prom2 = &memory_region(machine, "proms")[0x200]; int obj, i; /* reset the globals */ - memset(&bank_gfx[0][0], 0, sizeof(bank_gfx)); + memset(&state->bank_gfx[0][0], 0, sizeof(state->bank_gfx)); /* loop for two sets of objects */ for (obj = 0; obj < 2; obj++) @@ -630,6 +617,7 @@ static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *moloo static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp) { + atarisy1_state *state = (atarisy1_state *)machine->driver_data; const UINT8 *srcdata; int bank_index, gfx_index; @@ -655,8 +643,8 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp) return 0; /* find the bank */ - if (bank_gfx[bpp - 4][bank_index]) - return bank_gfx[bpp - 4][bank_index]; + if (state->bank_gfx[bpp - 4][bank_index]) + return state->bank_gfx[bpp - 4][bank_index]; /* if the bank is out of range, call it 0 */ if (0x80000 * (bank_index - 1) >= memory_region_length(machine, "tiles")) @@ -690,8 +678,8 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp) /* set the color information */ machine->gfx[gfx_index]->color_granularity = 8; - bank_color_shift[gfx_index] = bpp - 3; + state->bank_color_shift[gfx_index] = bpp - 3; /* set the entry and return it */ - return bank_gfx[bpp - 4][bank_index] = gfx_index; + return state->bank_gfx[bpp - 4][bank_index] = gfx_index; } diff --git a/src/mame/video/atarisy2.c b/src/mame/video/atarisy2.c index 3f99018a0a0..5e63cf0afde 100644 --- a/src/mame/video/atarisy2.c +++ b/src/mame/video/atarisy2.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "slapstic.h" #include "atarisy2.h" @@ -13,29 +12,6 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 *atarisy2_slapstic; - - - -/************************************* - * - * Statics - * - *************************************/ - -static emu_timer *yscroll_reset_timer; -static UINT32 playfield_tile_bank[2]; -static UINT32 videobank; -static UINT16 *vram; - - - -/************************************* - * * Prototypes * *************************************/ @@ -52,7 +28,8 @@ static TIMER_CALLBACK( reset_yscroll_callback ); static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = (data >> 13) & 0x07; SET_TILE_INFO(2, code, color, 0); @@ -61,8 +38,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = playfield_tile_bank[(data >> 10) & 1] + (data & 0x3ff); + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = state->playfield_tile_bank[(data >> 10) & 1] + (data & 0x3ff); int color = (data >> 11) & 7; SET_TILE_INFO(0, code, color, 0); tileinfo->category = (~data >> 14) & 3; @@ -114,32 +92,31 @@ VIDEO_START( atarisy2 ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + atarisy2_state *state = (atarisy2_state *)machine->driver_data; - /* allocate banked memory */ - vram = auto_alloc_array(machine, UINT16, 0x8000/2); - memset(vram, 0, 0x8000); - atarigen_alpha = &vram[0x0000]; - atarimo_0_spriteram = &vram[0x0c00]; - atarigen_playfield = &vram[0x2000]; + /* initialize banked memory */ + state->atarigen.alpha = &state->vram[0x0000]; + atarimo_0_spriteram = &state->vram[0x0c00]; + state->atarigen.playfield = &state->vram[0x2000]; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 128,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 128,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,48); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,48); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* reset the statics */ - yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); - videobank = 0; + state->yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); + state->videobank = 0; /* save states */ - state_save_register_global_array(machine, playfield_tile_bank); - state_save_register_global(machine, videobank); - state_save_register_global_pointer(machine, vram, 0x8000/2); + state_save_register_global_array(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->videobank); + state_save_register_global_array(machine, state->vram); } @@ -152,7 +129,8 @@ VIDEO_START( atarisy2 ) WRITE16_HANDLER( atarisy2_xscroll_w ) { - UINT16 oldscroll = *atarigen_xscroll; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.xscroll; UINT16 newscroll = oldscroll; COMBINE_DATA(&newscroll); @@ -161,29 +139,31 @@ WRITE16_HANDLER( atarisy2_xscroll_w ) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* update the playfield scrolling - hscroll is clocked on the following scanline */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll >> 6); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll >> 6); /* update the playfield banking */ - if (playfield_tile_bank[0] != (newscroll & 0x0f) * 0x400) + if (state->playfield_tile_bank[0] != (newscroll & 0x0f) * 0x400) { - playfield_tile_bank[0] = (newscroll & 0x0f) * 0x400; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank[0] = (newscroll & 0x0f) * 0x400; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } /* update the data */ - *atarigen_xscroll = newscroll; + *state->atarigen.xscroll = newscroll; } static TIMER_CALLBACK( reset_yscroll_callback ) { - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, param); + atarisy2_state *state = (atarisy2_state *)machine->driver_data; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, param); } WRITE16_HANDLER( atarisy2_yscroll_w ) { - UINT16 oldscroll = *atarigen_yscroll; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; COMBINE_DATA(&newscroll); @@ -193,19 +173,19 @@ WRITE16_HANDLER( atarisy2_yscroll_w ) /* if bit 4 is zero, the scroll value is clocked in right away */ if (!(newscroll & 0x10)) - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, (newscroll >> 6) - video_screen_get_vpos(space->machine->primary_screen)); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, (newscroll >> 6) - video_screen_get_vpos(space->machine->primary_screen)); else - timer_adjust_oneshot(yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll >> 6); + timer_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll >> 6); /* update the playfield banking */ - if (playfield_tile_bank[1] != (newscroll & 0x0f) * 0x400) + if (state->playfield_tile_bank[1] != (newscroll & 0x0f) * 0x400) { - playfield_tile_bank[1] = (newscroll & 0x0f) * 0x400; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank[1] = (newscroll & 0x0f) * 0x400; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } /* update the data */ - *atarigen_yscroll = newscroll; + *state->atarigen.yscroll = newscroll; } @@ -253,21 +233,24 @@ WRITE16_HANDLER( atarisy2_paletteram_w ) READ16_HANDLER( atarisy2_slapstic_r ) { - int result = atarisy2_slapstic[offset]; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + int result = state->slapstic_base[offset]; slapstic_tweak(space, offset); /* an extra tweak for the next opcode fetch */ - videobank = slapstic_tweak(space, 0x1234) * 0x1000; + state->videobank = slapstic_tweak(space, 0x1234) * 0x1000; return result; } WRITE16_HANDLER( atarisy2_slapstic_w ) { + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + slapstic_tweak(space, offset); /* an extra tweak for the next opcode fetch */ - videobank = slapstic_tweak(space, 0x1234) * 0x1000; + state->videobank = slapstic_tweak(space, 0x1234) * 0x1000; } @@ -280,19 +263,21 @@ WRITE16_HANDLER( atarisy2_slapstic_w ) READ16_HANDLER( atarisy2_videoram_r ) { - return vram[offset | videobank]; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + return state->vram[offset | state->videobank]; } WRITE16_HANDLER( atarisy2_videoram_w ) { - int offs = offset | videobank; + atarisy2_state *state = (atarisy2_state *)space->machine->driver_data; + int offs = offset | state->videobank; /* alpharam? */ if (offs < 0x0c00) { - COMBINE_DATA(&atarigen_alpha[offs]); - tilemap_mark_tile_dirty(atarigen_alpha_tilemap, offs); + COMBINE_DATA(&state->atarigen.alpha[offs]); + tilemap_mark_tile_dirty(state->atarigen.alpha_tilemap, offs); } /* spriteram? */ @@ -308,14 +293,14 @@ WRITE16_HANDLER( atarisy2_videoram_w ) else if (offs >= 0x2000) { offs -= 0x2000; - COMBINE_DATA(&atarigen_playfield[offs]); - tilemap_mark_tile_dirty(atarigen_playfield_tilemap, offs); + COMBINE_DATA(&state->atarigen.playfield[offs]); + tilemap_mark_tile_dirty(state->atarigen.playfield_tilemap, offs); } /* generic case */ else { - COMBINE_DATA(&vram[offs]); + COMBINE_DATA(&state->vram[offs]); } } @@ -329,6 +314,7 @@ WRITE16_HANDLER( atarisy2_videoram_w ) VIDEO_UPDATE( atarisy2 ) { + atarisy2_state *state = (atarisy2_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; atarimo_rect_list rectlist; bitmap_t *mobitmap; @@ -336,10 +322,10 @@ VIDEO_UPDATE( atarisy2 ) /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 1, 1); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 2, 2); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 3, 3); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 1, 1); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 2, 2); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 3, 3); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -372,6 +358,6 @@ VIDEO_UPDATE( atarisy2 ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/badlands.c b/src/mame/video/badlands.c index d64ac7f1a88..5a95b987810 100644 --- a/src/mame/video/badlands.c +++ b/src/mame/video/badlands.c @@ -5,31 +5,21 @@ ***************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "includes/badlands.h" /************************************* * - * Local variables - * - *************************************/ - -static UINT8 playfield_tile_bank; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = (data & 0x1fff) + ((data & 0x1000) ? (playfield_tile_bank << 12) : 0); + badlands_state *state = (badlands_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = (data & 0x1fff) + ((data & 0x1000) ? (state->playfield_tile_bank << 12) : 0); int color = (data >> 13) & 0x07; SET_TILE_INFO(0, code, color, 0); } @@ -80,9 +70,10 @@ VIDEO_START( badlands ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + badlands_state *state = (badlands_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,32); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,32); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -98,12 +89,13 @@ VIDEO_START( badlands ) WRITE16_HANDLER( badlands_pf_bank_w ) { + badlands_state *state = (badlands_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) - if (playfield_tile_bank != (data & 1)) + if (state->playfield_tile_bank != (data & 1)) { video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); - playfield_tile_bank = data & 1; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank = data & 1; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } } @@ -117,12 +109,13 @@ WRITE16_HANDLER( badlands_pf_bank_w ) VIDEO_UPDATE( badlands ) { + badlands_state *state = (badlands_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); diff --git a/src/mame/video/batman.c b/src/mame/video/batman.c index cd5b1b6ce91..50894de9a16 100644 --- a/src/mame/video/batman.c +++ b/src/mame/video/batman.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "batman.h" #include "thunderj.h" @@ -13,24 +12,15 @@ /************************************* * - * Globals - * - *************************************/ - -UINT8 batman_alpha_tile_bank; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; - int code = ((data & 0x400) ? (batman_alpha_tile_bank * 0x400) : 0) + (data & 0x3ff); + batman_state *state = (batman_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; + int code = ((data & 0x400) ? (state->alpha_tile_bank * 0x400) : 0) + (data & 0x3ff); int color = (data >> 11) & 0x0f; int opaque = data & 0x8000; SET_TILE_INFO(2, code, color, opaque ? TILE_FORCE_LAYER0 : 0); @@ -39,8 +29,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] & 0xff; + batman_state *state = (batman_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] & 0xff; int code = data1 & 0x7fff; int color = 0x10 + (data2 & 0x0f); SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -50,8 +41,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) static TILE_GET_INFO( get_playfield2_tile_info ) { - UINT16 data1 = atarigen_playfield2[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + batman_state *state = (batman_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield2[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = data2 & 0x0f; SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -104,20 +96,21 @@ VIDEO_START( batman ) 0, /* resulting value to indicate "special" */ NULL /* callback routine for special entries */ }; + batman_state *state = (batman_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the second playfield */ - atarigen_playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); - tilemap_set_transparent_pen(atarigen_playfield2_tilemap, 0); + state->atarigen.playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); + tilemap_set_transparent_pen(state->atarigen.playfield2_tilemap, 0); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -130,10 +123,12 @@ VIDEO_START( batman ) void batman_scanline_update(const device_config *screen, int scanline) { + batman_state *state = (batman_state *)screen->machine->driver_data; + /* update the scanline parameters */ - if (scanline <= video_screen_get_visible_area(screen)->max_y && atarivc_state.rowscroll_enable) + if (scanline <= video_screen_get_visible_area(screen)->max_y && state->atarigen.atarivc_state.rowscroll_enable) { - UINT16 *base = &atarigen_alpha[scanline / 8 * 64 + 48]; + UINT16 *base = &state->atarigen.alpha[scanline / 8 * 64 + 48]; int scan, i; for (scan = 0; scan < 8; scan++, scanline++) @@ -145,46 +140,46 @@ void batman_scanline_update(const device_config *screen, int scanline) case 9: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.mo_xscroll = (data >> 7) & 0x1ff; - atarimo_set_xscroll(0, atarivc_state.mo_xscroll); + state->atarigen.atarivc_state.mo_xscroll = (data >> 7) & 0x1ff; + atarimo_set_xscroll(0, state->atarigen.atarivc_state.mo_xscroll); break; case 10: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.pf1_xscroll_raw = (data >> 7) & 0x1ff; - atarivc_update_pf_xscrolls(); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, atarivc_state.pf0_xscroll); - tilemap_set_scrollx(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_xscroll); + state->atarigen.atarivc_state.pf1_xscroll_raw = (data >> 7) & 0x1ff; + atarivc_update_pf_xscrolls(&state->atarigen); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_xscroll); + tilemap_set_scrollx(state->atarigen.playfield2_tilemap, 0, state->atarigen.atarivc_state.pf1_xscroll); break; case 11: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.pf0_xscroll_raw = (data >> 7) & 0x1ff; - atarivc_update_pf_xscrolls(); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, atarivc_state.pf0_xscroll); + state->atarigen.atarivc_state.pf0_xscroll_raw = (data >> 7) & 0x1ff; + atarivc_update_pf_xscrolls(&state->atarigen); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_xscroll); break; case 13: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.mo_yscroll = (data >> 7) & 0x1ff; - atarimo_set_yscroll(0, atarivc_state.mo_yscroll); + state->atarigen.atarivc_state.mo_yscroll = (data >> 7) & 0x1ff; + atarimo_set_yscroll(0, state->atarigen.atarivc_state.mo_yscroll); break; case 14: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.pf1_yscroll = (data >> 7) & 0x1ff; - tilemap_set_scrolly(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_yscroll); + state->atarigen.atarivc_state.pf1_yscroll = (data >> 7) & 0x1ff; + tilemap_set_scrolly(state->atarigen.playfield2_tilemap, 0, state->atarigen.atarivc_state.pf1_yscroll); break; case 15: if (scanline > 0) video_screen_update_partial(screen, scanline - 1); - atarivc_state.pf0_yscroll = (data >> 7) & 0x1ff; - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, atarivc_state.pf0_yscroll); + state->atarigen.atarivc_state.pf0_yscroll = (data >> 7) & 0x1ff; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_yscroll); break; } } @@ -201,6 +196,7 @@ void batman_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( batman ) { + batman_state *state = (batman_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; atarimo_rect_list rectlist; bitmap_t *mobitmap; @@ -208,14 +204,14 @@ VIDEO_UPDATE( batman ) /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0x00); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 1, 0x01); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 2, 0x02); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 3, 0x03); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 0, 0x80); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 1, 0x84); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 2, 0x88); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 3, 0x8c); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0x00); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 1, 0x01); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 2, 0x02); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 3, 0x03); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 0, 0x80); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 1, 0x84); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 2, 0x88); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 3, 0x8c); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -288,7 +284,7 @@ VIDEO_UPDATE( batman ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* now go back and process the upper bit of MO priority */ rectlist.rect -= rectlist.numrects; diff --git a/src/mame/video/beathead.c b/src/mame/video/beathead.c index 178c84bd906..217ab5b85f4 100644 --- a/src/mame/video/beathead.c +++ b/src/mame/video/beathead.c @@ -11,17 +11,6 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT32 * beathead_vram_bulk_latch; -UINT32 * beathead_palette_select; - - - -/************************************* - * * Statics * *************************************/ @@ -67,6 +56,8 @@ WRITE32_HANDLER( beathead_vram_transparent_w ) WRITE32_HANDLER( beathead_vram_bulk_w ) { + beathead_state *state = (beathead_state *)space->machine->driver_data; + /* it appears that writes to this area pass in a mask for 4 words in VRAM */ /* allowing them to be filled from a preset latch */ offset &= ~3; @@ -77,7 +68,7 @@ WRITE32_HANDLER( beathead_vram_bulk_w ) space->machine->generic.videoram.u32[offset+0] = space->machine->generic.videoram.u32[offset+1] = space->machine->generic.videoram.u32[offset+2] = - space->machine->generic.videoram.u32[offset+3] = *beathead_vram_bulk_latch; + space->machine->generic.videoram.u32[offset+3] = *state->vram_bulk_latch; else logerror("Detected bulk VRAM write with mask %08x\n", data); } @@ -181,13 +172,14 @@ WRITE32_HANDLER( beathead_hsync_ram_w ) VIDEO_UPDATE( beathead ) { + beathead_state *state = (beathead_state *)screen->machine->driver_data; UINT8 *videoram = screen->machine->generic.videoram.u8; int x, y; /* generate the final screen */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) { - pen_t pen_base = (*beathead_palette_select & 0x7f) * 256; + pen_t pen_base = (*state->palette_select & 0x7f) * 256; UINT16 scanline[336]; /* blanking */ diff --git a/src/mame/video/blstroid.c b/src/mame/video/blstroid.c index b52c4921eac..2430c5a90a1 100644 --- a/src/mame/video/blstroid.c +++ b/src/mame/video/blstroid.c @@ -12,23 +12,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 *blstroid_priorityram; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; + blstroid_state *state = (blstroid_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; int code = data & 0x1fff; int color = (data >> 13) & 0x07; SET_TILE_INFO(0, code, color, 0); @@ -80,9 +71,10 @@ VIDEO_START( blstroid ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + blstroid_state *state = (blstroid_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 16,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 16,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -115,11 +107,12 @@ static TIMER_CALLBACK( irq_on ) void blstroid_scanline_update(const device_config *screen, int scanline) { + blstroid_state *state = (blstroid_state *)screen->machine->driver_data; int offset = (scanline / 8) * 64 + 40; /* check for interrupts */ if (offset < 0x1000) - if (atarigen_playfield[offset] & 0x8000) + if (state->atarigen.playfield[offset] & 0x8000) { int width, vpos; attotime period_on; @@ -152,12 +145,13 @@ void blstroid_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( blstroid ) { + blstroid_state *state = (blstroid_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -174,7 +168,7 @@ VIDEO_UPDATE( blstroid ) priority address = HPPPMMMM */ int priaddr = ((pf[x] & 8) << 4) | (pf[x] & 0x70) | ((mo[x] & 0xf0) >> 4); - if (blstroid_priorityram[priaddr] & 1) + if (state->priorityram[priaddr] & 1) pf[x] = mo[x]; /* erase behind ourselves */ diff --git a/src/mame/video/cyberbal.c b/src/mame/video/cyberbal.c index 35928b57bba..129c61acf6d 100644 --- a/src/mame/video/cyberbal.c +++ b/src/mame/video/cyberbal.c @@ -15,37 +15,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 *cyberbal_paletteram_0; -UINT16 *cyberbal_paletteram_1; - - - -/************************************* - * - * Statics - * - *************************************/ - -static UINT16 current_slip[2]; -static UINT8 playfield_palette_bank[2]; -static UINT16 playfield_xscroll[2]; -static UINT16 playfield_yscroll[2]; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0xfff; int color = (data >> 12) & 0x07; SET_TILE_INFO(2, code, color, (data >> 15) & 1); @@ -54,7 +31,8 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_alpha2_tile_info ) { - UINT16 data = atarigen_alpha2[tile_index]; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha2[tile_index]; int code = data & 0xfff; int color = (data >> 12) & 0x07; SET_TILE_INFO(2, code, 0x80 | color, (data >> 15) & 1); @@ -63,7 +41,8 @@ static TILE_GET_INFO( get_alpha2_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; int code = data & 0x1fff; int color = (data >> 11) & 0x0f; SET_TILE_INFO(0, code, color, (data >> 15) & 1); @@ -72,7 +51,8 @@ static TILE_GET_INFO( get_playfield_tile_info ) static TILE_GET_INFO( get_playfield2_tile_info ) { - UINT16 data = atarigen_playfield2[tile_index]; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield2[tile_index]; int code = data & 0x1fff; int color = (data >> 11) & 0x0f; SET_TILE_INFO(0, code, 0x80 | color, (data >> 15) & 1); @@ -161,40 +141,37 @@ static void video_start_cyberbal_common(running_machine* machine, int screens) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + cyberbal_state *state = (cyberbal_state *)machine->driver_data; /* set the slip variables */ - atarimo_0_slipram = ¤t_slip[0]; - atarimo_1_slipram = ¤t_slip[1]; + atarimo_0_slipram = &state->current_slip[0]; + atarimo_1_slipram = &state->current_slip[1]; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 16,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 16,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &mo0desc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 16,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 16,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* allocate the second screen if necessary */ if (screens == 2) { /* initialize the playfield */ - atarigen_playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_rows, 16,8, 64,64); - tilemap_set_scrollx(atarigen_playfield2_tilemap, 0, 0); + state->atarigen.playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_rows, 16,8, 64,64); + tilemap_set_scrollx(state->atarigen.playfield2_tilemap, 0, 0); /* initialize the motion objects */ atarimo_init(machine, 1, &mo1desc); /* initialize the alphanumerics */ - atarigen_alpha2_tilemap = tilemap_create(machine, get_alpha2_tile_info, tilemap_scan_rows, 16,8, 64,32); - tilemap_set_scrollx(atarigen_alpha2_tilemap, 0, 0); - tilemap_set_transparent_pen(atarigen_alpha2_tilemap, 0); + state->atarigen.alpha2_tilemap = tilemap_create(machine, get_alpha2_tile_info, tilemap_scan_rows, 16,8, 64,32); + tilemap_set_scrollx(state->atarigen.alpha2_tilemap, 0, 0); + tilemap_set_transparent_pen(state->atarigen.alpha2_tilemap, 0); } - - /* reset statics */ - current_slip[0] = 0; - current_slip[1] = 0; } @@ -245,25 +222,29 @@ INLINE void set_palette_entry(running_machine *machine, int entry, UINT16 value) WRITE16_HANDLER( cyberbal_paletteram_0_w ) { - COMBINE_DATA(&cyberbal_paletteram_0[offset]); - set_palette_entry(space->machine, offset, cyberbal_paletteram_0[offset]); + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + COMBINE_DATA(&state->paletteram_0[offset]); + set_palette_entry(space->machine, offset, state->paletteram_0[offset]); } READ16_HANDLER( cyberbal_paletteram_0_r ) { - return cyberbal_paletteram_0[offset]; + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + return state->paletteram_0[offset]; } WRITE16_HANDLER( cyberbal_paletteram_1_w ) { - COMBINE_DATA(&cyberbal_paletteram_1[offset]); - set_palette_entry(space->machine, offset + 0x800, cyberbal_paletteram_1[offset]); + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + COMBINE_DATA(&state->paletteram_1[offset]); + set_palette_entry(space->machine, offset + 0x800, state->paletteram_1[offset]); } READ16_HANDLER( cyberbal_paletteram_1_r ) { - return cyberbal_paletteram_1[offset]; + cyberbal_state *state = (cyberbal_state *)space->machine->driver_data; + return state->paletteram_1[offset]; } @@ -276,13 +257,14 @@ READ16_HANDLER( cyberbal_paletteram_1_r ) void cyberbal_scanline_update(const device_config *screen, int scanline) { + cyberbal_state *state = (cyberbal_state *)screen->machine->driver_data; int i; const device_config *update_screen; /* loop over screens */ for (i = 0, update_screen = video_screen_first(screen->machine->config); update_screen != NULL; i++, update_screen = video_screen_next(update_screen)) { - UINT16 *vram = i ? atarigen_alpha2 : atarigen_alpha; + UINT16 *vram = i ? state->atarigen.alpha2 : state->atarigen.alpha; UINT16 *base = &vram[((scanline - 8) / 8) * 64 + 47]; /* keep in range */ @@ -294,44 +276,44 @@ void cyberbal_scanline_update(const device_config *screen, int scanline) /* update the current parameters */ if (!(base[3] & 1)) { - if (((base[3] >> 1) & 7) != playfield_palette_bank[i]) + if (((base[3] >> 1) & 7) != state->playfield_palette_bank[i]) { if (scanline > 0) video_screen_update_partial(update_screen, scanline - 1); - playfield_palette_bank[i] = (base[3] >> 1) & 7; - tilemap_set_palette_offset(i ? atarigen_playfield2_tilemap : atarigen_playfield_tilemap, playfield_palette_bank[i] << 8); + state->playfield_palette_bank[i] = (base[3] >> 1) & 7; + tilemap_set_palette_offset(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, state->playfield_palette_bank[i] << 8); } } if (!(base[4] & 1)) { int newscroll = 2 * (((base[4] >> 7) + 4) & 0x1ff); - if (newscroll != playfield_xscroll[i]) + if (newscroll != state->playfield_xscroll[i]) { if (scanline > 0) video_screen_update_partial(update_screen, scanline - 1); - tilemap_set_scrollx(i ? atarigen_playfield2_tilemap : atarigen_playfield_tilemap, 0, newscroll); - playfield_xscroll[i] = newscroll; + tilemap_set_scrollx(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_xscroll[i] = newscroll; } } if (!(base[5] & 1)) { /* a new vscroll latches the offset into a counter; we must adjust for this */ int newscroll = ((base[5] >> 7) - (scanline)) & 0x1ff; - if (newscroll != playfield_yscroll[i]) + if (newscroll != state->playfield_yscroll[i]) { if (scanline > 0) video_screen_update_partial(update_screen, scanline - 1); - tilemap_set_scrolly(i ? atarigen_playfield2_tilemap : atarigen_playfield_tilemap, 0, newscroll); - playfield_yscroll[i] = newscroll; + tilemap_set_scrolly(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, 0, newscroll); + state->playfield_yscroll[i] = newscroll; } } if (!(base[7] & 1)) { - if (current_slip[i] != base[7]) + if (state->current_slip[i] != base[7]) { if (scanline > 0) video_screen_update_partial(update_screen, scanline - 1); - current_slip[i] = base[7]; + state->current_slip[i] = base[7]; } } } @@ -347,6 +329,7 @@ void cyberbal_scanline_update(const device_config *screen, int scanline) static void update_one_screen(const device_config *screen, bitmap_t *bitmap, const rectangle *cliprect) { + cyberbal_state *state = (cyberbal_state *)screen->machine->driver_data; atarimo_rect_list rectlist; rectangle tempclip = *cliprect; bitmap_t *mobitmap; @@ -359,7 +342,7 @@ static void update_one_screen(const device_config *screen, bitmap_t *bitmap, con left_screen = devtag_get_device(screen->machine, "screen"); /* draw the playfield */ - tilemap_draw(bitmap, cliprect, (screen == left_screen) ? atarigen_playfield_tilemap : atarigen_playfield2_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, (screen == left_screen) ? state->atarigen.playfield_tilemap : state->atarigen.playfield2_tilemap, 0, 0); /* draw the MOs -- note some kludging to get this to work correctly for 2 screens */ mooffset = 0; @@ -392,7 +375,7 @@ static void update_one_screen(const device_config *screen, bitmap_t *bitmap, con } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, (screen == left_screen) ? atarigen_alpha_tilemap : atarigen_alpha2_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, (screen == left_screen) ? state->atarigen.alpha_tilemap : state->atarigen.alpha2_tilemap, 0, 0); } diff --git a/src/mame/video/eprom.c b/src/mame/video/eprom.c index 05d34dfa360..3cf16c50c98 100644 --- a/src/mame/video/eprom.c +++ b/src/mame/video/eprom.c @@ -5,15 +5,10 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "eprom.h" #include "thunderj.h" -int eprom_screen_intensity; -int eprom_video_disable; - - /************************************* * * Palette @@ -22,6 +17,7 @@ int eprom_video_disable; static void update_palette(running_machine *machine) { + eprom_state *state = (eprom_state *)machine->driver_data; int color; for (color = 0; color < 0x800; ++color) @@ -35,7 +31,7 @@ static void update_palette(running_machine *machine) * This is, however, good enough to match the video and description * of MAMETesters bug #02677. */ - i = (((data >> 12) & 15) + 1) * (4 - eprom_screen_intensity); + i = (((data >> 12) & 15) + 1) * (4 - state->screen_intensity); if (i < 0) i = 0; @@ -57,7 +53,8 @@ static void update_palette(running_machine *machine) static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + eprom_state *state = (eprom_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = ((data >> 10) & 0x0f) | ((data >> 9) & 0x20); int opaque = data & 0x8000; @@ -67,8 +64,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + eprom_state *state = (eprom_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = 0x10 + (data2 & 0x0f); SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -77,8 +75,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) static TILE_GET_INFO( guts_get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + eprom_state *state = (eprom_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = 0x10 + (data2 & 0x0f); SET_TILE_INFO(2, code, color, (data1 >> 15) & 1); @@ -130,22 +129,17 @@ VIDEO_START( eprom ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + eprom_state *state = (eprom_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); - - /* global brightess (not used by klax and guts) */ - eprom_screen_intensity = 0; - - /* video disabled (not used?) */ - eprom_video_disable = 0; + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -187,22 +181,17 @@ VIDEO_START( guts ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + eprom_state *state = (eprom_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, guts_get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, guts_get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); - - /* global brightess (not used by guts) */ - eprom_screen_intensity = 0; - - /* video disable (not used by guts) */ - eprom_video_disable = 0; + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -215,13 +204,15 @@ VIDEO_START( guts ) void eprom_scanline_update(const device_config *screen, int scanline) { + eprom_state *state = (eprom_state *)screen->machine->driver_data; + /* update the playfield */ if (scanline == 0) { - int xscroll = (atarigen_alpha[0x780] >> 7) & 0x1ff; - int yscroll = (atarigen_alpha[0x781] >> 7) & 0x1ff; - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, xscroll); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, yscroll); + int xscroll = (state->atarigen.alpha[0x780] >> 7) & 0x1ff; + int yscroll = (state->atarigen.alpha[0x781] >> 7) & 0x1ff; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, xscroll); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, yscroll); atarimo_set_xscroll(0, xscroll); atarimo_set_yscroll(0, yscroll); } @@ -237,11 +228,12 @@ void eprom_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( eprom ) { + eprom_state *state = (eprom_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; - if (eprom_video_disable) + if (state->video_disable) { bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); return 0; @@ -250,7 +242,7 @@ VIDEO_UPDATE( eprom ) update_palette(screen->machine); /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -359,7 +351,7 @@ VIDEO_UPDATE( eprom ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* now go back and process the upper bit of MO priority */ rectlist.rect -= rectlist.numrects; @@ -391,11 +383,12 @@ VIDEO_UPDATE( eprom ) VIDEO_UPDATE( guts ) { + eprom_state *state = (eprom_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; - if (eprom_video_disable) + if (state->video_disable) { bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); return 0; @@ -404,7 +397,7 @@ VIDEO_UPDATE( guts ) update_palette(screen->machine); /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -432,7 +425,7 @@ VIDEO_UPDATE( guts ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* now go back and process the upper bit of MO priority */ rectlist.rect -= rectlist.numrects; diff --git a/src/mame/video/foodf.c b/src/mame/video/foodf.c index 2e959b7ee2d..d234fd8e432 100644 --- a/src/mame/video/foodf.c +++ b/src/mame/video/foodf.c @@ -5,16 +5,10 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "foodf.h" #include "video/resnet.h" -static double rweights[3], gweights[3], bweights[2]; -static UINT8 playfield_flip; - - - /************************************* * * Tilemap callbacks @@ -23,10 +17,11 @@ static UINT8 playfield_flip; static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; + foodf_state *state = (foodf_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; int code = (data & 0xff) | ((data >> 7) & 0x100); int color = (data >> 8) & 0x3f; - SET_TILE_INFO(0, code, color, playfield_flip ? (TILE_FLIPX | TILE_FLIPY) : 0); + SET_TILE_INFO(0, code, color, state->playfield_flip ? (TILE_FLIPX | TILE_FLIPY) : 0); } @@ -40,21 +35,21 @@ static TILE_GET_INFO( get_playfield_tile_info ) VIDEO_START( foodf ) { static const int resistances[3] = { 1000, 470, 220 }; + foodf_state *state = (foodf_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 32,32); - tilemap_set_transparent_pen(atarigen_playfield_tilemap, 0); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 32,32); + tilemap_set_transparent_pen(state->atarigen.playfield_tilemap, 0); /* adjust the playfield for the 8 pixel offset */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, -8); - playfield_flip = 0; - state_save_register_global(machine, playfield_flip); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, -8); + state_save_register_global(machine, state->playfield_flip); /* compute the color output resistor weights */ compute_resistor_weights(0, 255, -1.0, - 3, &resistances[0], rweights, 0, 0, - 3, &resistances[0], gweights, 0, 0, - 2, &resistances[1], bweights, 0, 0); + 3, &resistances[0], state->rweights, 0, 0, + 3, &resistances[0], state->gweights, 0, 0, + 2, &resistances[1], state->bweights, 0, 0); } @@ -65,12 +60,12 @@ VIDEO_START( foodf ) * *************************************/ -void foodf_set_flip(int flip) +void foodf_set_flip(foodf_state *state, int flip) { - if (flip != playfield_flip) + if (flip != state->playfield_flip) { - playfield_flip = flip; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_flip = flip; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } } @@ -84,6 +79,7 @@ void foodf_set_flip(int flip) WRITE16_HANDLER( foodf_paletteram_w ) { + foodf_state *state = (foodf_state *)space->machine->driver_data; int newword, r, g, b, bit0, bit1, bit2; COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]); @@ -94,18 +90,18 @@ WRITE16_HANDLER( foodf_paletteram_w ) bit0 = (newword >> 0) & 0x01; bit1 = (newword >> 1) & 0x01; bit2 = (newword >> 2) & 0x01; - r = combine_3_weights(rweights, bit0, bit1, bit2); + r = combine_3_weights(state->rweights, bit0, bit1, bit2); /* green component */ bit0 = (newword >> 3) & 0x01; bit1 = (newword >> 4) & 0x01; bit2 = (newword >> 5) & 0x01; - g = combine_3_weights(gweights, bit0, bit1, bit2); + g = combine_3_weights(state->gweights, bit0, bit1, bit2); /* blue component */ bit0 = (newword >> 6) & 0x01; bit1 = (newword >> 7) & 0x01; - b = combine_2_weights(bweights, bit0, bit1); + b = combine_2_weights(state->bweights, bit0, bit1); palette_set_color(space->machine, offset, MAKE_RGB(r, g, b)); } @@ -120,17 +116,18 @@ WRITE16_HANDLER( foodf_paletteram_w ) VIDEO_UPDATE( foodf ) { + foodf_state *state = (foodf_state *)screen->machine->driver_data; int offs; const gfx_element *gfx = screen->machine->gfx[1]; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; UINT16 *spriteram16 = screen->machine->generic.spriteram.u16; /* first draw the playfield opaquely */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, TILEMAP_DRAW_OPAQUE, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, TILEMAP_DRAW_OPAQUE, 0); /* then draw the non-transparent parts with a priority of 1 */ bitmap_fill(priority_bitmap, 0, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 1); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 1); /* draw the motion objects front-to-back */ for (offs = 0x80-2; offs >= 0x20; offs -= 2) diff --git a/src/mame/video/gauntlet.c b/src/mame/video/gauntlet.c index 97c4a9bb641..ab83bad37e7 100644 --- a/src/mame/video/gauntlet.c +++ b/src/mame/video/gauntlet.c @@ -12,34 +12,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT8 vindctr2_screen_refresh; - - - -/************************************* - * - * Statics - * - *************************************/ - -static UINT8 playfield_tile_bank; -static UINT8 playfield_color_bank; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + gauntlet_state *state = (gauntlet_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = ((data >> 10) & 0x0f) | ((data >> 9) & 0x20); int opaque = data & 0x8000; @@ -49,9 +29,10 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = ((playfield_tile_bank * 0x1000) + (data & 0xfff)) ^ 0x800; - int color = 0x10 + (playfield_color_bank * 8) + ((data >> 12) & 7); + gauntlet_state *state = (gauntlet_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = ((state->playfield_tile_bank * 0x1000) + (data & 0xfff)) ^ 0x800; + int color = 0x10 + (state->playfield_color_bank * 8) + ((data >> 12) & 7); SET_TILE_INFO(0, code, color, (data >> 15) & 1); } @@ -102,18 +83,19 @@ VIDEO_START( gauntlet ) 0 /* callback routine for special entries */ }; + gauntlet_state *state = (gauntlet_state *)machine->driver_data; UINT16 *codelookup; int i, size; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* modify the motion object code lookup table to account for the code XOR */ codelookup = atarimo_get_code_lookup(0, &size); @@ -121,7 +103,7 @@ VIDEO_START( gauntlet ) codelookup[i] ^= 0x800; /* set up the base color for the playfield */ - playfield_color_bank = vindctr2_screen_refresh ? 0 : 1; + state->playfield_color_bank = state->vindctr2_screen_refresh ? 0 : 1; } @@ -134,17 +116,18 @@ VIDEO_START( gauntlet ) WRITE16_HANDLER( gauntlet_xscroll_w ) { - UINT16 oldxscroll = *atarigen_xscroll; - COMBINE_DATA(atarigen_xscroll); + gauntlet_state *state = (gauntlet_state *)space->machine->driver_data; + UINT16 oldxscroll = *state->atarigen.xscroll; + COMBINE_DATA(state->atarigen.xscroll); /* if something changed, force a partial update */ - if (*atarigen_xscroll != oldxscroll) + if (*state->atarigen.xscroll != oldxscroll) { video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* adjust the scrolls */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, *atarigen_xscroll); - atarimo_set_xscroll(0, *atarigen_xscroll & 0x1ff); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, *state->atarigen.xscroll); + atarimo_set_xscroll(0, *state->atarigen.xscroll & 0x1ff); } } @@ -158,24 +141,25 @@ WRITE16_HANDLER( gauntlet_xscroll_w ) WRITE16_HANDLER( gauntlet_yscroll_w ) { - UINT16 oldyscroll = *atarigen_yscroll; - COMBINE_DATA(atarigen_yscroll); + gauntlet_state *state = (gauntlet_state *)space->machine->driver_data; + UINT16 oldyscroll = *state->atarigen.yscroll; + COMBINE_DATA(state->atarigen.yscroll); /* if something changed, force a partial update */ - if (*atarigen_yscroll != oldyscroll) + if (*state->atarigen.yscroll != oldyscroll) { video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* if the bank changed, mark all tiles dirty */ - if (playfield_tile_bank != (*atarigen_yscroll & 3)) + if (state->playfield_tile_bank != (*state->atarigen.yscroll & 3)) { - playfield_tile_bank = *atarigen_yscroll & 3; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank = *state->atarigen.yscroll & 3; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } /* adjust the scrolls */ - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, *atarigen_yscroll >> 7); - atarimo_set_yscroll(0, (*atarigen_yscroll >> 7) & 0x1ff); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, *state->atarigen.yscroll >> 7); + atarimo_set_yscroll(0, (*state->atarigen.yscroll >> 7) & 0x1ff); } } @@ -189,12 +173,13 @@ WRITE16_HANDLER( gauntlet_yscroll_w ) VIDEO_UPDATE( gauntlet ) { + gauntlet_state *state = (gauntlet_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -213,7 +198,7 @@ VIDEO_UPDATE( gauntlet ) if ((mo[x] & 0x0f) == 1) { /* Vindicators Part II has extra logic here for the bases */ - if (!vindctr2_screen_refresh || (mo[x] & 0xf0) != 0) + if (!state->vindctr2_screen_refresh || (mo[x] & 0xf0) != 0) pf[x] ^= 0x80; } else @@ -225,6 +210,6 @@ VIDEO_UPDATE( gauntlet ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/harddriv.c b/src/mame/video/harddriv.c index e56cd753fe7..9fdc4b55e7c 100644 --- a/src/mame/video/harddriv.c +++ b/src/mame/video/harddriv.c @@ -24,66 +24,20 @@ /************************************* * - * External definitions - * - *************************************/ - -/* externally accessible */ -UINT8 hdgsp_multisync; -UINT8 *hdgsp_vram; -UINT16 *hdgsp_control_lo; -UINT16 *hdgsp_control_hi; -UINT16 *hdgsp_paletteram_lo; -UINT16 *hdgsp_paletteram_hi; -size_t hdgsp_vram_size; - - - -/************************************* - * - * Static globals - * - *************************************/ - -static offs_t vram_mask; - -static UINT8 shiftreg_enable; - -static UINT32 *mask_table; -static UINT8 *gsp_shiftreg_source; - -static offs_t gfx_offset; -static offs_t gfx_rowbytes; -static INT8 gfx_finescroll; -static UINT8 gfx_palettebank; - - - -/************************************* - * * Start/stop routines * *************************************/ VIDEO_START( harddriv ) { + harddriv_state *state = (harddriv_state *)machine->driver_data; UINT32 *destmask, mask; int i; - shiftreg_enable = 0; - - gfx_offset = 0; - gfx_rowbytes = 0; - gfx_finescroll = 0; - gfx_palettebank = 0; - - /* allocate the mask table */ - mask_table = auto_alloc_array(machine, UINT32, 4 * 65536); - /* fill in the mask table */ - destmask = mask_table; + destmask = state->mask_table; for (i = 0; i < 65536; i++) - if (hdgsp_multisync) + if (state->gsp_multisync) { mask = 0; if (i & 0x0001) mask |= MASK(0); @@ -131,7 +85,7 @@ VIDEO_START( harddriv ) } /* init VRAM pointers */ - vram_mask = hdgsp_vram_size - 1; + state->vram_mask = state->gsp_vram_size - 1; } @@ -144,14 +98,16 @@ VIDEO_START( harddriv ) void hdgsp_write_to_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* access to the 1bpp/2bpp area */ if (address >= 0x02000000 && address <= 0x020fffff) { address -= 0x02000000; - address >>= hdgsp_multisync; - address &= vram_mask; - address &= ~((512*8 >> hdgsp_multisync) - 1); - gsp_shiftreg_source = &hdgsp_vram[address]; + address >>= state->gsp_multisync; + address &= state->vram_mask; + address &= ~((512*8 >> state->gsp_multisync) - 1); + state->gsp_shiftreg_source = &state->gsp_vram[address]; } /* access to normal VRAM area */ @@ -159,9 +115,9 @@ void hdgsp_write_to_shiftreg(const address_space *space, UINT32 address, UINT16 { address -= 0xff800000; address /= 8; - address &= vram_mask; + address &= state->vram_mask; address &= ~511; - gsp_shiftreg_source = &hdgsp_vram[address]; + state->gsp_shiftreg_source = &state->gsp_vram[address]; } else logerror("Unknown shiftreg write %08X\n", address); @@ -170,17 +126,19 @@ void hdgsp_write_to_shiftreg(const address_space *space, UINT32 address, UINT16 void hdgsp_read_from_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg) { - if (!shiftreg_enable) + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + + if (!state->shiftreg_enable) return; /* access to the 1bpp/2bpp area */ if (address >= 0x02000000 && address <= 0x020fffff) { address -= 0x02000000; - address >>= hdgsp_multisync; - address &= vram_mask; - address &= ~((512*8 >> hdgsp_multisync) - 1); - memmove(&hdgsp_vram[address], gsp_shiftreg_source, 512*8 >> hdgsp_multisync); + address >>= state->gsp_multisync; + address &= state->vram_mask; + address &= ~((512*8 >> state->gsp_multisync) - 1); + memmove(&state->gsp_vram[address], state->gsp_shiftreg_source, 512*8 >> state->gsp_multisync); } /* access to normal VRAM area */ @@ -188,9 +146,9 @@ void hdgsp_read_from_shiftreg(const address_space *space, UINT32 address, UINT16 { address -= 0xff800000; address /= 8; - address &= vram_mask; + address &= state->vram_mask; address &= ~511; - memmove(&hdgsp_vram[address], gsp_shiftreg_source, 512); + memmove(&state->gsp_vram[address], state->gsp_shiftreg_source, 512); } else logerror("Unknown shiftreg read %08X\n", address); @@ -206,8 +164,9 @@ void hdgsp_read_from_shiftreg(const address_space *space, UINT32 address, UINT16 static void update_palette_bank(running_machine *machine, int newbank) { + harddriv_state *state = (harddriv_state *)machine->driver_data; video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); - gfx_palettebank = newbank; + state->gfx_palettebank = newbank; } @@ -220,20 +179,22 @@ static void update_palette_bank(running_machine *machine, int newbank) READ16_HANDLER( hdgsp_control_lo_r ) { - return hdgsp_control_lo[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->gsp_control_lo[offset]; } WRITE16_HANDLER( hdgsp_control_lo_w ) { - int oldword = hdgsp_control_lo[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + int oldword = state->gsp_control_lo[offset]; int newword; - COMBINE_DATA(&hdgsp_control_lo[offset]); - newword = hdgsp_control_lo[offset]; + COMBINE_DATA(&state->gsp_control_lo[offset]); + newword = state->gsp_control_lo[offset]; if (oldword != newword && offset != 0) - logerror("GSP:hdgsp_control_lo(%X)=%04X\n", offset, newword); + logerror("GSP:gsp_control_lo(%X)=%04X\n", offset, newword); } @@ -246,43 +207,45 @@ WRITE16_HANDLER( hdgsp_control_lo_w ) READ16_HANDLER( hdgsp_control_hi_r ) { - return hdgsp_control_hi[offset]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + return state->gsp_control_hi[offset]; } WRITE16_HANDLER( hdgsp_control_hi_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; int val = (offset >> 3) & 1; - int oldword = hdgsp_control_hi[offset]; + int oldword = state->gsp_control_hi[offset]; int newword; - COMBINE_DATA(&hdgsp_control_hi[offset]); - newword = hdgsp_control_hi[offset]; + COMBINE_DATA(&state->gsp_control_hi[offset]); + newword = state->gsp_control_hi[offset]; switch (offset & 7) { case 0x00: - shiftreg_enable = val; + state->shiftreg_enable = val; break; case 0x01: - data = data & (15 >> hdgsp_multisync); + data = data & (15 >> state->gsp_multisync); video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1); - gfx_finescroll = data; + state->gfx_finescroll = data; break; case 0x02: - update_palette_bank(space->machine, (gfx_palettebank & ~1) | val); + update_palette_bank(space->machine, (state->gfx_palettebank & ~1) | val); break; case 0x03: - update_palette_bank(space->machine, (gfx_palettebank & ~2) | (val << 1)); + update_palette_bank(space->machine, (state->gfx_palettebank & ~2) | (val << 1)); break; case 0x04: if (space->machine->config->total_colors >= 256 * 8) - update_palette_bank(space->machine, (gfx_palettebank & ~4) | (val << 2)); + update_palette_bank(space->machine, (state->gfx_palettebank & ~4) | (val << 2)); break; case 0x07: @@ -291,7 +254,7 @@ WRITE16_HANDLER( hdgsp_control_hi_w ) default: if (oldword != newword) - logerror("GSP:hdgsp_control_hi_w(%X)=%04X\n", offset, newword); + logerror("GSP:gsp_control_hi_w(%X)=%04X\n", offset, newword); break; } } @@ -312,9 +275,10 @@ READ16_HANDLER( hdgsp_vram_2bpp_r ) WRITE16_HANDLER( hdgsp_vram_1bpp_w ) { - UINT32 *dest = (UINT32 *)&hdgsp_vram[offset * 16]; - UINT32 *mask = &mask_table[data * 4]; - UINT32 color = hdgsp_control_lo[0] & 0xff; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 *dest = (UINT32 *)&state->gsp_vram[offset * 16]; + UINT32 *mask = &state->mask_table[data * 4]; + UINT32 color = state->gsp_control_lo[0] & 0xff; UINT32 curmask; color |= color << 8; @@ -340,9 +304,10 @@ WRITE16_HANDLER( hdgsp_vram_1bpp_w ) WRITE16_HANDLER( hdgsp_vram_2bpp_w ) { - UINT32 *dest = (UINT32 *)&hdgsp_vram[offset * 8]; - UINT32 *mask = &mask_table[data * 2]; - UINT32 color = hdgsp_control_lo[0]; + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + UINT32 *dest = (UINT32 *)&state->gsp_vram[offset * 8]; + UINT32 *mask = &state->mask_table[data * 2]; + UINT32 color = state->gsp_control_lo[0]; UINT32 curmask; color |= color << 16; @@ -366,30 +331,35 @@ WRITE16_HANDLER( hdgsp_vram_2bpp_w ) INLINE void gsp_palette_change(running_machine *machine, int offset) { - int red = (hdgsp_paletteram_lo[offset] >> 8) & 0xff; - int green = hdgsp_paletteram_lo[offset] & 0xff; - int blue = hdgsp_paletteram_hi[offset] & 0xff; + harddriv_state *state = (harddriv_state *)machine->driver_data; + int red = (state->gsp_paletteram_lo[offset] >> 8) & 0xff; + int green = state->gsp_paletteram_lo[offset] & 0xff; + int blue = state->gsp_paletteram_hi[offset] & 0xff; palette_set_color(machine, offset, MAKE_RGB(red, green, blue)); } READ16_HANDLER( hdgsp_paletteram_lo_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* note that the palette is only accessed via the first 256 entries */ /* others are selected via the palette bank */ - offset = gfx_palettebank * 0x100 + (offset & 0xff); + offset = state->gfx_palettebank * 0x100 + (offset & 0xff); - return hdgsp_paletteram_lo[offset]; + return state->gsp_paletteram_lo[offset]; } WRITE16_HANDLER( hdgsp_paletteram_lo_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* note that the palette is only accessed via the first 256 entries */ /* others are selected via the palette bank */ - offset = gfx_palettebank * 0x100 + (offset & 0xff); + offset = state->gfx_palettebank * 0x100 + (offset & 0xff); - COMBINE_DATA(&hdgsp_paletteram_lo[offset]); + COMBINE_DATA(&state->gsp_paletteram_lo[offset]); gsp_palette_change(space->machine, offset); } @@ -403,21 +373,25 @@ WRITE16_HANDLER( hdgsp_paletteram_lo_w ) READ16_HANDLER( hdgsp_paletteram_hi_r ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* note that the palette is only accessed via the first 256 entries */ /* others are selected via the palette bank */ - offset = gfx_palettebank * 0x100 + (offset & 0xff); + offset = state->gfx_palettebank * 0x100 + (offset & 0xff); - return hdgsp_paletteram_hi[offset]; + return state->gsp_paletteram_hi[offset]; } WRITE16_HANDLER( hdgsp_paletteram_hi_w ) { + harddriv_state *state = (harddriv_state *)space->machine->driver_data; + /* note that the palette is only accessed via the first 256 entries */ /* others are selected via the palette bank */ - offset = gfx_palettebank * 0x100 + (offset & 0xff); + offset = state->gfx_palettebank * 0x100 + (offset & 0xff); - COMBINE_DATA(&hdgsp_paletteram_hi[offset]); + COMBINE_DATA(&state->gsp_paletteram_hi[offset]); gsp_palette_change(space->machine, offset); } @@ -451,13 +425,14 @@ static void display_speedups(void) void harddriv_scanline_driver(const device_config *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - UINT8 *vram_base = &hdgsp_vram[(params->rowaddr << 12) & vram_mask]; + harddriv_state *state = (harddriv_state *)screen->machine->driver_data; + UINT8 *vram_base = &state->gsp_vram[(params->rowaddr << 12) & state->vram_mask]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); - int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 4) - 15 + (gfx_finescroll & 0x0f); + int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 4) - 15 + (state->gfx_finescroll & 0x0f); int x; for (x = params->heblnk; x < params->hsblnk; x++) - dest[x] = gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0xfff)]; + dest[x] = state->gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0xfff)]; if (scanline == video_screen_get_visible_area(screen)->max_y) display_speedups(); @@ -466,13 +441,14 @@ void harddriv_scanline_driver(const device_config *screen, bitmap_t *bitmap, int void harddriv_scanline_multisync(const device_config *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - UINT8 *vram_base = &hdgsp_vram[(params->rowaddr << 11) & vram_mask]; + harddriv_state *state = (harddriv_state *)screen->machine->driver_data; + UINT8 *vram_base = &state->gsp_vram[(params->rowaddr << 11) & state->vram_mask]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); - int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 3) - 7 + (gfx_finescroll & 0x07); + int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 3) - 7 + (state->gfx_finescroll & 0x07); int x; for (x = params->heblnk; x < params->hsblnk; x++) - dest[x] = gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0x7ff)]; + dest[x] = state->gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0x7ff)]; if (scanline == video_screen_get_visible_area(screen)->max_y) display_speedups(); diff --git a/src/mame/video/klax.c b/src/mame/video/klax.c index 8bf8beeb651..56c373a5912 100644 --- a/src/mame/video/klax.c +++ b/src/mame/video/klax.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "klax.h" @@ -18,8 +17,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + klax_state *state = (klax_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x1fff; int color = data2 & 0x0f; SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -71,9 +71,10 @@ VIDEO_START( klax ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + klax_state *state = (klax_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,32); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,32); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -101,12 +102,13 @@ WRITE16_HANDLER( klax_latch_w ) VIDEO_UPDATE( klax ) { + klax_state *state = (klax_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); diff --git a/src/mame/video/offtwall.c b/src/mame/video/offtwall.c index 158a457586d..94aa175c1c8 100644 --- a/src/mame/video/offtwall.c +++ b/src/mame/video/offtwall.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "offtwall.h" @@ -18,8 +17,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + offtwall_state *state = (offtwall_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = 0x10 + (data2 & 0x0f); SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -71,9 +71,10 @@ VIDEO_START( offtwall ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + offtwall_state *state = (offtwall_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -89,12 +90,13 @@ VIDEO_START( offtwall ) VIDEO_UPDATE( offtwall ) { + offtwall_state *state = (offtwall_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); diff --git a/src/mame/video/rampart.c b/src/mame/video/rampart.c index dd2324b726f..6ba9d1fbc7c 100644 --- a/src/mame/video/rampart.c +++ b/src/mame/video/rampart.c @@ -12,16 +12,6 @@ /************************************* * - * Globals we own - * - *************************************/ - -UINT16 *rampart_bitmap; - - - -/************************************* - * * Video system start * *************************************/ @@ -119,12 +109,13 @@ VIDEO_UPDATE( rampart ) void rampart_bitmap_render(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { + rampart_state *state = (rampart_state *)machine->driver_data; int x, y; /* update any dirty scanlines */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) { - const UINT16 *src = &rampart_bitmap[256 * y]; + const UINT16 *src = &state->bitmap[256 * y]; UINT16 *dst = BITMAP_ADDR16(bitmap, y, 0); /* regenerate the line */ diff --git a/src/mame/video/relief.c b/src/mame/video/relief.c index 56b9b0ff12b..ae9057ac306 100644 --- a/src/mame/video/relief.c +++ b/src/mame/video/relief.c @@ -18,8 +18,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] & 0xff; + relief_state *state = (relief_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] & 0xff; int code = data1 & 0x7fff; int color = 0x20 + (data2 & 0x0f); SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -28,8 +29,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) static TILE_GET_INFO( get_playfield2_tile_info ) { - UINT16 data1 = atarigen_playfield2[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + relief_state *state = (relief_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield2[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = data2 & 0x0f; SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -81,16 +83,17 @@ VIDEO_START( relief ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + relief_state *state = (relief_state *)machine->driver_data; /* MOs are 5bpp but with a 4-bit color granularity */ machine->gfx[1]->color_granularity = 16; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the second playfield */ - atarigen_playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); - tilemap_set_transparent_pen(atarigen_playfield2_tilemap, 0); + state->atarigen.playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); + tilemap_set_transparent_pen(state->atarigen.playfield2_tilemap, 0); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -106,6 +109,7 @@ VIDEO_START( relief ) VIDEO_UPDATE( relief ) { + relief_state *state = (relief_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; atarimo_rect_list rectlist; bitmap_t *mobitmap; @@ -113,8 +117,8 @@ VIDEO_UPDATE( relief ) /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 0, 1); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 0, 1); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); diff --git a/src/mame/video/shuuz.c b/src/mame/video/shuuz.c index d40aa6c54f9..196763be96c 100644 --- a/src/mame/video/shuuz.c +++ b/src/mame/video/shuuz.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "shuuz.h" @@ -18,8 +17,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + shuuz_state *state = (shuuz_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x3fff; int color = data2 & 0x0f; SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -71,9 +71,10 @@ VIDEO_START( shuuz ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + shuuz_state *state = (shuuz_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); @@ -89,12 +90,13 @@ VIDEO_START( shuuz ) VIDEO_UPDATE( shuuz ) { + shuuz_state *state = (shuuz_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); diff --git a/src/mame/video/skullxbo.c b/src/mame/video/skullxbo.c index 8bec85fc24d..383b756a964 100644 --- a/src/mame/video/skullxbo.c +++ b/src/mame/video/skullxbo.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "includes/skullxbo.h" @@ -18,7 +17,8 @@ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + skullxbo_state *state = (skullxbo_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = (data ^ 0x400) & 0x7ff; int color = (data >> 11) & 0x0f; int opaque = data & 0x8000; @@ -28,8 +28,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] & 0xff; + skullxbo_state *state = (skullxbo_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] & 0xff; int code = data1 & 0x7fff; int color = data2 & 0x0f; SET_TILE_INFO(1, code, color, (data1 >> 15) & 1); @@ -81,16 +82,17 @@ VIDEO_START( skullxbo ) 0, /* resulting value to indicate "special" */ 0, /* callback routine for special entries */ }; + skullxbo_state *state = (skullxbo_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 16,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 16,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 16,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 16,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -103,8 +105,10 @@ VIDEO_START( skullxbo ) WRITE16_HANDLER( skullxbo_xscroll_w ) { + skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; + /* combine data */ - UINT16 oldscroll = *atarigen_xscroll; + UINT16 oldscroll = *state->atarigen.xscroll; UINT16 newscroll = oldscroll; COMBINE_DATA(&newscroll); @@ -113,19 +117,21 @@ WRITE16_HANDLER( skullxbo_xscroll_w ) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* adjust the actual scrolls */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, 2 * (newscroll >> 7)); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, 2 * (newscroll >> 7)); atarimo_set_xscroll(0, 2 * (newscroll >> 7)); /* update the data */ - *atarigen_xscroll = newscroll; + *state->atarigen.xscroll = newscroll; } WRITE16_HANDLER( skullxbo_yscroll_w ) { + skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; + /* combine data */ int scanline = video_screen_get_vpos(space->machine->primary_screen); - UINT16 oldscroll = *atarigen_yscroll; + UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; UINT16 effscroll; COMBINE_DATA(&newscroll); @@ -140,11 +146,11 @@ WRITE16_HANDLER( skullxbo_yscroll_w ) effscroll = (newscroll >> 7) - scanline; /* adjust the actual scrolls */ - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, effscroll); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, effscroll); atarimo_set_yscroll(0, effscroll & 0x1ff); /* update the data */ - *atarigen_yscroll = newscroll; + *state->atarigen.yscroll = newscroll; } @@ -171,7 +177,8 @@ WRITE16_HANDLER( skullxbo_mobmsb_w ) WRITE16_HANDLER( skullxbo_playfieldlatch_w ) { - atarigen_set_playfield_latch(data); + skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; + atarigen_set_playfield_latch(&state->atarigen, data); } @@ -184,18 +191,19 @@ WRITE16_HANDLER( skullxbo_playfieldlatch_w ) void skullxbo_scanline_update(running_machine *machine, int scanline) { - UINT16 *base = &atarigen_alpha[(scanline / 8) * 64 + 42]; + skullxbo_state *state = (skullxbo_state *)machine->driver_data; + UINT16 *base = &state->atarigen.alpha[(scanline / 8) * 64 + 42]; int x; /* keep in range */ - if (base >= &atarigen_alpha[0x7c0]) + if (base >= &state->atarigen.alpha[0x7c0]) return; /* special case: scanline 0 should re-latch the previous raw scroll */ if (scanline == 0) { - int newscroll = (*atarigen_yscroll >> 7) & 0x1ff; - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); + int newscroll = (*state->atarigen.yscroll >> 7) & 0x1ff; + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); atarimo_set_yscroll(0, newscroll); } @@ -216,12 +224,12 @@ void skullxbo_scanline_update(running_machine *machine, int scanline) video_screen_update_partial(machine->primary_screen, scanline - 1); /* update the new scroll */ - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); atarimo_set_yscroll(0, newscroll); /* make sure we change this value so that writes to the scroll register */ /* know whether or not they are a different scroll */ - *atarigen_yscroll = data; + *state->atarigen.yscroll = data; } } } @@ -236,12 +244,13 @@ void skullxbo_scanline_update(running_machine *machine, int scanline) VIDEO_UPDATE( skullxbo ) { + skullxbo_state *state = (skullxbo_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -305,6 +314,6 @@ VIDEO_UPDATE( skullxbo ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/thunderj.c b/src/mame/video/thunderj.c index 2ec97613160..632a6b101e0 100644 --- a/src/mame/video/thunderj.c +++ b/src/mame/video/thunderj.c @@ -12,24 +12,15 @@ /************************************* * - * Globals - * - *************************************/ - -UINT8 thunderj_alpha_tile_bank; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; - int code = ((data & 0x200) ? (thunderj_alpha_tile_bank * 0x200) : 0) + (data & 0x1ff); + thunderj_state *state = (thunderj_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; + int code = ((data & 0x200) ? (state->alpha_tile_bank * 0x200) : 0) + (data & 0x1ff); int color = ((data >> 10) & 0x0f) | ((data >> 9) & 0x20); int opaque = data & 0x8000; SET_TILE_INFO(2, code, color, opaque ? TILE_FORCE_LAYER0 : 0); @@ -38,8 +29,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] & 0xff; + thunderj_state *state = (thunderj_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] & 0xff; int code = data1 & 0x7fff; int color = 0x10 + (data2 & 0x0f); SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -49,8 +41,9 @@ static TILE_GET_INFO( get_playfield_tile_info ) static TILE_GET_INFO( get_playfield2_tile_info ) { - UINT16 data1 = atarigen_playfield2[tile_index]; - UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8; + thunderj_state *state = (thunderj_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield2[tile_index]; + UINT16 data2 = state->atarigen.playfield_upper[tile_index] >> 8; int code = data1 & 0x7fff; int color = data2 & 0x0f; SET_TILE_INFO(0, code, color, (data1 >> 15) & 1); @@ -103,20 +96,21 @@ VIDEO_START( thunderj ) 0, /* resulting value to indicate "special" */ NULL /* callback routine for special entries */ }; + thunderj_state *state = (thunderj_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the second playfield */ - atarigen_playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); - tilemap_set_transparent_pen(atarigen_playfield2_tilemap, 0); + state->atarigen.playfield2_tilemap = tilemap_create(machine, get_playfield2_tile_info, tilemap_scan_cols, 8,8, 64,64); + tilemap_set_transparent_pen(state->atarigen.playfield2_tilemap, 0); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -154,6 +148,7 @@ void thunderj_mark_high_palette(bitmap_t *bitmap, UINT16 *pf, UINT16 *mo, int x, VIDEO_UPDATE( thunderj ) { + thunderj_state *state = (thunderj_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; atarimo_rect_list rectlist; bitmap_t *mobitmap; @@ -161,14 +156,14 @@ VIDEO_UPDATE( thunderj ) /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0x00); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 1, 0x01); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 2, 0x02); - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 3, 0x03); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 0, 0x80); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 1, 0x84); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 2, 0x88); - tilemap_draw(bitmap, cliprect, atarigen_playfield2_tilemap, 3, 0x8c); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0x00); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 1, 0x01); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 2, 0x02); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 3, 0x03); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 0, 0x80); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 1, 0x84); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 2, 0x88); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield2_tilemap, 3, 0x8c); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -267,7 +262,7 @@ VIDEO_UPDATE( thunderj ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* now go back and process the upper bit of MO priority */ rectlist.rect -= rectlist.numrects; diff --git a/src/mame/video/toobin.c b/src/mame/video/toobin.c index bd0b95d4f39..32d43543f4d 100644 --- a/src/mame/video/toobin.c +++ b/src/mame/video/toobin.c @@ -12,24 +12,14 @@ /************************************* * - * Globals we own - * - *************************************/ - -static double brightness; -static bitmap_t *pfbitmap; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + toobin_state *state = (toobin_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = (data >> 12) & 0x0f; SET_TILE_INFO(2, code, color, (data >> 10) & 1); @@ -38,8 +28,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data1 = atarigen_playfield[tile_index * 2]; - UINT16 data2 = atarigen_playfield[tile_index * 2 + 1]; + toobin_state *state = (toobin_state *)machine->driver_data; + UINT16 data1 = state->atarigen.playfield[tile_index * 2]; + UINT16 data2 = state->atarigen.playfield[tile_index * 2 + 1]; int code = data2 & 0x3fff; int color = data1 & 0x0f; SET_TILE_INFO(0, code, color, TILE_FLIPYX(data2 >> 14)); @@ -92,19 +83,20 @@ VIDEO_START( toobin ) 0, /* resulting value to indicate "special" */ 0 /* callback routine for special entries */ }; + toobin_state *state = (toobin_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 128,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 128,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,48); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,48); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* allocate a playfield bitmap for rendering */ - pfbitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16); + state->pfbitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16); } @@ -117,6 +109,7 @@ VIDEO_START( toobin ) WRITE16_HANDLER( toobin_paletteram_w ) { + toobin_state *state = (toobin_state *)space->machine->driver_data; int newword; COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]); @@ -133,7 +126,7 @@ WRITE16_HANDLER( toobin_paletteram_w ) palette_set_color(space->machine, offset & 0x3ff, MAKE_RGB(red, green, blue)); if (!(newword & 0x8000)) - palette_set_pen_contrast(space->machine, offset & 0x3ff, brightness); + palette_set_pen_contrast(space->machine, offset & 0x3ff, state->brightness); else palette_set_pen_contrast(space->machine, offset & 0x3ff, 1.0); } @@ -142,15 +135,16 @@ WRITE16_HANDLER( toobin_paletteram_w ) WRITE16_HANDLER( toobin_intensity_w ) { + toobin_state *state = (toobin_state *)space->machine->driver_data; int i; if (ACCESSING_BITS_0_7) { - brightness = (double)(~data & 0x1f) / 31.0; + state->brightness = (double)(~data & 0x1f) / 31.0; for (i = 0; i < 0x400; i++) if (!(space->machine->generic.paletteram.u16[i] & 0x8000)) - palette_set_pen_contrast(space->machine, i, brightness); + palette_set_pen_contrast(space->machine, i, state->brightness); } } @@ -164,7 +158,8 @@ WRITE16_HANDLER( toobin_intensity_w ) WRITE16_HANDLER( toobin_xscroll_w ) { - UINT16 oldscroll = *atarigen_xscroll; + toobin_state *state = (toobin_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.xscroll; UINT16 newscroll = oldscroll; COMBINE_DATA(&newscroll); @@ -173,17 +168,18 @@ WRITE16_HANDLER( toobin_xscroll_w ) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* update the playfield scrolling - hscroll is clocked on the following scanline */ - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, newscroll >> 6); + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll >> 6); atarimo_set_xscroll(0, newscroll >> 6); /* update the data */ - *atarigen_xscroll = newscroll; + *state->atarigen.xscroll = newscroll; } WRITE16_HANDLER( toobin_yscroll_w ) { - UINT16 oldscroll = *atarigen_yscroll; + toobin_state *state = (toobin_state *)space->machine->driver_data; + UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; COMBINE_DATA(&newscroll); @@ -192,11 +188,11 @@ WRITE16_HANDLER( toobin_yscroll_w ) video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); /* if bit 4 is zero, the scroll value is clocked in right away */ - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, newscroll >> 6); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll >> 6); atarimo_set_yscroll(0, (newscroll >> 6) & 0x1ff); /* update the data */ - *atarigen_yscroll = newscroll; + *state->atarigen.yscroll = newscroll; } @@ -231,6 +227,7 @@ WRITE16_HANDLER( toobin_slip_w ) VIDEO_UPDATE( toobin ) { + toobin_state *state = (toobin_state *)screen->machine->driver_data; bitmap_t *priority_bitmap = screen->machine->priority_bitmap; const rgb_t *palette = palette_entry_list_adjusted(screen->machine->palette); atarimo_rect_list rectlist; @@ -239,10 +236,10 @@ VIDEO_UPDATE( toobin ) /* draw the playfield */ bitmap_fill(priority_bitmap, cliprect, 0); - tilemap_draw(pfbitmap, cliprect, atarigen_playfield_tilemap, 0, 0); - tilemap_draw(pfbitmap, cliprect, atarigen_playfield_tilemap, 1, 1); - tilemap_draw(pfbitmap, cliprect, atarigen_playfield_tilemap, 2, 2); - tilemap_draw(pfbitmap, cliprect, atarigen_playfield_tilemap, 3, 3); + tilemap_draw(state->pfbitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); + tilemap_draw(state->pfbitmap, cliprect, state->atarigen.playfield_tilemap, 1, 1); + tilemap_draw(state->pfbitmap, cliprect, state->atarigen.playfield_tilemap, 2, 2); + tilemap_draw(state->pfbitmap, cliprect, state->atarigen.playfield_tilemap, 3, 3); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -250,7 +247,7 @@ VIDEO_UPDATE( toobin ) { UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0); UINT16 *mo = BITMAP_ADDR16(mobitmap, y, 0); - UINT16 *pf = BITMAP_ADDR16(pfbitmap, y, 0); + UINT16 *pf = BITMAP_ADDR16(state->pfbitmap, y, 0); UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0); for (x = cliprect->min_x; x <= cliprect->max_x; x++) { @@ -275,6 +272,6 @@ VIDEO_UPDATE( toobin ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/vindictr.c b/src/mame/video/vindictr.c index 86d6a59d6b2..412f4a9a89d 100644 --- a/src/mame/video/vindictr.c +++ b/src/mame/video/vindictr.c @@ -5,7 +5,6 @@ ****************************************************************************/ #include "driver.h" -#include "machine/atarigen.h" #include "vindictr.h" #include "thunderj.h" @@ -13,25 +12,14 @@ /************************************* * - * Statics - * - *************************************/ - -static UINT8 playfield_tile_bank; -static UINT16 playfield_xscroll; -static UINT16 playfield_yscroll; - - - -/************************************* - * * Tilemap callbacks * *************************************/ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + vindictr_state *state = (vindictr_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = ((data >> 10) & 0x0f) | ((data >> 9) & 0x20); int opaque = data & 0x8000; @@ -41,8 +29,9 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; - int code = (playfield_tile_bank * 0x1000) + (data & 0xfff); + vindictr_state *state = (vindictr_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; + int code = (state->playfield_tile_bank * 0x1000) + (data & 0xfff); int color = 0x10 + 2 * ((data >> 12) & 7); SET_TILE_INFO(0, code, color, (data >> 15) & 1); } @@ -93,16 +82,17 @@ VIDEO_START( vindictr ) 0, /* resulting value to indicate "special" */ NULL /* callback routine for special entries */ }; + vindictr_state *state = (vindictr_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -145,13 +135,14 @@ WRITE16_HANDLER( vindictr_paletteram_w ) void vindictr_scanline_update(const device_config *screen, int scanline) { - UINT16 *base = &atarigen_alpha[((scanline - 8) / 8) * 64 + 42]; + vindictr_state *state = (vindictr_state *)screen->machine->driver_data; + UINT16 *base = &state->atarigen.alpha[((scanline - 8) / 8) * 64 + 42]; int x; /* keep in range */ - if (base < atarigen_alpha) + if (base < state->atarigen.alpha) base += 0x7c0; - else if (base >= &atarigen_alpha[0x7c0]) + else if (base >= &state->atarigen.alpha[0x7c0]) return; /* update the current parameters */ @@ -162,20 +153,20 @@ void vindictr_scanline_update(const device_config *screen, int scanline) switch ((data >> 9) & 7) { case 2: /* /PFB */ - if (playfield_tile_bank != (data & 7)) + if (state->playfield_tile_bank != (data & 7)) { video_screen_update_partial(screen, scanline - 1); - playfield_tile_bank = data & 7; - tilemap_mark_all_tiles_dirty(atarigen_playfield_tilemap); + state->playfield_tile_bank = data & 7; + tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } break; case 3: /* /PFHSLD */ - if (playfield_xscroll != (data & 0x1ff)) + if (state->playfield_xscroll != (data & 0x1ff)) { video_screen_update_partial(screen, scanline - 1); - tilemap_set_scrollx(atarigen_playfield_tilemap, 0, data); - playfield_xscroll = data & 0x1ff; + tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, data); + state->playfield_xscroll = data & 0x1ff; } break; @@ -202,10 +193,10 @@ void vindictr_scanline_update(const device_config *screen, int scanline) if (offset > visible_area->max_y) offset -= visible_area->max_y + 1; - if (playfield_yscroll != ((data - offset) & 0x1ff)) + if (state->playfield_yscroll != ((data - offset) & 0x1ff)) { video_screen_update_partial(screen, scanline - 1); - tilemap_set_scrolly(atarigen_playfield_tilemap, 0, data - offset); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, data - offset); atarimo_set_yscroll(0, (data - offset) & 0x1ff); } break; @@ -224,12 +215,13 @@ void vindictr_scanline_update(const device_config *screen, int scanline) VIDEO_UPDATE( vindictr ) { + vindictr_state *state = (vindictr_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -270,7 +262,7 @@ VIDEO_UPDATE( vindictr ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); /* now go back and process the upper bit of MO priority */ rectlist.rect -= rectlist.numrects; diff --git a/src/mame/video/xybots.c b/src/mame/video/xybots.c index 11f9bb76434..28d916beede 100644 --- a/src/mame/video/xybots.c +++ b/src/mame/video/xybots.c @@ -18,7 +18,8 @@ static TILE_GET_INFO( get_alpha_tile_info ) { - UINT16 data = atarigen_alpha[tile_index]; + xybots_state *state = (xybots_state *)machine->driver_data; + UINT16 data = state->atarigen.alpha[tile_index]; int code = data & 0x3ff; int color = (data >> 12) & 7; int opaque = data & 0x8000; @@ -28,7 +29,8 @@ static TILE_GET_INFO( get_alpha_tile_info ) static TILE_GET_INFO( get_playfield_tile_info ) { - UINT16 data = atarigen_playfield[tile_index]; + xybots_state *state = (xybots_state *)machine->driver_data; + UINT16 data = state->atarigen.playfield[tile_index]; int code = data & 0x1fff; int color = (data >> 11) & 0x0f; SET_TILE_INFO(0, code, color, (data >> 15) & 1); @@ -80,16 +82,17 @@ VIDEO_START( xybots ) 0, /* resulting value to indicate "special" */ NULL /* callback routine for special entries */ }; + xybots_state *state = (xybots_state *)machine->driver_data; /* initialize the playfield */ - atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,32); + state->atarigen.playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows, 8,8, 64,32); /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); /* initialize the alphanumerics */ - atarigen_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); - tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0); + state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); + tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); } @@ -102,12 +105,13 @@ VIDEO_START( xybots ) VIDEO_UPDATE( xybots ) { + xybots_state *state = (xybots_state *)screen->machine->driver_data; atarimo_rect_list rectlist; bitmap_t *mobitmap; int x, y, r; /* draw the playfield */ - tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.playfield_tilemap, 0, 0); /* draw and merge the MO */ mobitmap = atarimo_render(0, cliprect, &rectlist); @@ -161,6 +165,6 @@ VIDEO_UPDATE( xybots ) } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, atarigen_alpha_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->atarigen.alpha_tilemap, 0, 0); return 0; } |
