From 19723cecd0f57cd21431baacc27186f3fbd6a1a8 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Mon, 1 Mar 2010 09:10:49 +0000 Subject: [PATCH] Added driver_data class and save states to the following drivers: oneshot.c, onetwo.c, orbit.c, othello.c and othldrby.c Added driver_data class to the following drivers: nemesis.c and nyny.c --- .gitattributes | 1 + src/mame/drivers/nemesis.c | 557 ++++++++++++++++++++--------------- src/mame/drivers/nyny.c | 252 +++++++++------- src/mame/drivers/oneshot.c | 118 +++++--- src/mame/drivers/onetwo.c | 178 ++++++++--- src/mame/drivers/orbit.c | 81 ++--- src/mame/drivers/othello.c | 222 +++++++++----- src/mame/drivers/othldrby.c | 66 +++-- src/mame/includes/nemesis.h | 76 +++-- src/mame/includes/oneshot.h | 33 ++- src/mame/includes/orbit.h | 40 ++- src/mame/includes/othldrby.h | 41 +++ src/mame/video/nemesis.c | 343 +++++++++++---------- src/mame/video/oneshot.c | 198 +++++++------ src/mame/video/orbit.c | 39 ++- src/mame/video/othldrby.c | 173 ++++++----- 16 files changed, 1456 insertions(+), 962 deletions(-) create mode 100644 src/mame/includes/othldrby.h diff --git a/.gitattributes b/.gitattributes index a313f09c9e0..0f78a4d19ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2705,6 +2705,7 @@ src/mame/includes/ojankohs.h svneol=native#text/plain src/mame/includes/oneshot.h svneol=native#text/plain src/mame/includes/opwolf.h svneol=native#text/plain src/mame/includes/orbit.h svneol=native#text/plain +src/mame/includes/othldrby.h svneol=native#text/plain src/mame/includes/othunder.h svneol=native#text/plain src/mame/includes/overdriv.h svneol=native#text/plain src/mame/includes/pacman.h svneol=native#text/plain diff --git a/src/mame/drivers/nemesis.c b/src/mame/drivers/nemesis.c index ca67ce7b223..23b1c8376d4 100644 --- a/src/mame/drivers/nemesis.c +++ b/src/mame/drivers/nemesis.c @@ -52,78 +52,77 @@ So this is the correct behavior of real hardware, not an emulation bug. #include "includes/nemesis.h" #include "includes/konamipt.h" -int nemesis_irq_on = 0; -int nemesis_irq2_on = 0; -static int nemesis_irq1_on = 0; -static int nemesis_irq4_on = 0; -static int gx400_irq1_cnt; -static UINT8 frame_counter; - - -static MACHINE_RESET( nemesis ) -{ - nemesis_irq_on = 0; - nemesis_irq1_on = 0; - nemesis_irq2_on = 0; - nemesis_irq4_on = 0; - gx400_irq1_cnt = 0; - frame_counter = 1; -} - static INTERRUPT_GEN( nemesis_interrupt ) { - if (nemesis_irq_on) + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + + if (state->irq_on) cpu_set_input_line(device, 1, HOLD_LINE); } static INTERRUPT_GEN( konamigt_interrupt ) { + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + if (cpu_getiloops(device) == 0) { - if ( (nemesis_irq_on) && (gx400_irq1_cnt++ & 1) ) cpu_set_input_line(device, 1, HOLD_LINE); + if ((state->irq_on) && (state->gx400_irq1_cnt++ & 1)) + cpu_set_input_line(device, 1, HOLD_LINE); } else { - if (nemesis_irq2_on) cpu_set_input_line(device, 2, HOLD_LINE); + if (state->irq2_on) + cpu_set_input_line(device, 2, HOLD_LINE); } } static INTERRUPT_GEN( gx400_interrupt ) { + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + switch (cpu_getiloops(device)) { case 0: - if (nemesis_irq2_on) cpu_set_input_line(device, 2, HOLD_LINE); + if (state->irq2_on) + cpu_set_input_line(device, 2, HOLD_LINE); break; case 1: - if ( (nemesis_irq1_on) && (gx400_irq1_cnt++ & 1) ) cpu_set_input_line(device, 1, HOLD_LINE); + if ((state->irq1_on) && (state->gx400_irq1_cnt++ & 1)) + cpu_set_input_line(device, 1, HOLD_LINE); break; case 2: - if (nemesis_irq4_on) cpu_set_input_line(device, 4, HOLD_LINE); + if (state->irq4_on) + cpu_set_input_line(device, 4, HOLD_LINE); break; } } static INTERRUPT_GEN( salamand_interrupt ) { - if (nemesis_irq_on) + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + + if (state->irq_on) cpu_set_input_line(device, 1, HOLD_LINE); } static INTERRUPT_GEN( blkpnthr_interrupt ) { - if (nemesis_irq_on) + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + + if (state->irq_on) cpu_set_input_line(device, 2, HOLD_LINE); } static WRITE16_HANDLER( gx400_irq1_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - nemesis_irq1_on = data & 0x0001; + state->irq1_on = data & 0x0001; if (ACCESSING_BITS_8_15) coin_lockout_w(space->machine, 1, data & 0x0100); @@ -131,8 +130,10 @@ static WRITE16_HANDLER( gx400_irq1_enable_word_w ) static WRITE16_HANDLER( gx400_irq2_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - nemesis_irq2_on = data & 0x0001; + state->irq2_on = data & 0x0001; if (ACCESSING_BITS_8_15) coin_lockout_w(space->machine, 0, data & 0x0100); @@ -140,14 +141,18 @@ static WRITE16_HANDLER( gx400_irq2_enable_word_w ) static WRITE16_HANDLER( gx400_irq4_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_8_15) - nemesis_irq4_on = data & 0x0100; + state->irq4_on = data & 0x0100; } static WRITE16_HANDLER( nemesis_irq_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - nemesis_irq_on = data & 0xff; + state->irq_on = data & 0xff; if (ACCESSING_BITS_8_15) coin_lockout_global_w(space->machine, data & 0x0100); @@ -155,8 +160,10 @@ static WRITE16_HANDLER( nemesis_irq_enable_word_w ) static WRITE16_HANDLER( konamigt_irq_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - nemesis_irq_on = data & 0xff; + state->irq_on = data & 0xff; if (ACCESSING_BITS_8_15) coin_lockout_w(space->machine, 1, data & 0x0100); @@ -164,25 +171,28 @@ static WRITE16_HANDLER( konamigt_irq_enable_word_w ) static WRITE16_HANDLER( konamigt_irq2_enable_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - nemesis_irq2_on = data & 0xff; + state->irq2_on = data & 0xff; if (ACCESSING_BITS_8_15) coin_lockout_w(space->machine, 0, data & 0x0100); } -static UINT8 *gx400_shared_ram; - static READ16_HANDLER( gx400_sharedram_word_r ) { - return gx400_shared_ram[offset]; + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + return state->gx400_shared_ram[offset]; } static WRITE16_HANDLER( gx400_sharedram_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) - gx400_shared_ram[offset] = data; + state->gx400_shared_ram[offset] = data; } @@ -195,33 +205,37 @@ static READ16_HANDLER( konamigt_input_word_r ) bit 12-15: accel */ - int data=input_port_read(space->machine, "IN3"); - int data2=input_port_read(space->machine, "PADDLE"); + int data = input_port_read(space->machine, "IN3"); + int data2 = input_port_read(space->machine, "PADDLE"); int ret=0x0000; -// if(data&0x10) ret|=0x0800; // turbo/gear? -// if(data&0x80) ret|=0x0400; // turbo? - if(data&0x20) ret|=0x0300; // brake (0-3) +// if (BIT(data, 4)) ret |= 0x0800; // turbo/gear? +// if (BIT(data, 7)) ret |= 0x0400; // turbo? + if (BIT(data, 5)) + ret |= 0x0300; // brake (0-3) - if(data&0x40) ret|=0xf000; // accel (0-f) + if (BIT(data, 6)) + ret |= 0xf000; // accel (0-f) - ret|=data2&0x7f; // steering wheel, not exactly sure if DIAL works ok. + ret |= data2 & 0x7f; // steering wheel, not exactly sure if DIAL works ok. return ret; } -/* Copied from WEC Le Mans 24 driver, explicity needed for Hyper Crash */ -UINT16 hcrash_selected_ip; - static WRITE16_HANDLER( selected_ip_word_w ) { - if (ACCESSING_BITS_0_7) hcrash_selected_ip = data & 0xff; // latch the value + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + if (ACCESSING_BITS_0_7) + state->selected_ip = data & 0xff; // latch the value } static READ16_HANDLER( selected_ip_word_r ) { - switch (hcrash_selected_ip & 0xf) + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + switch (state->selected_ip & 0xf) { // From WEC Le Mans Schems: case 0xc: return input_port_read(space->machine, "ACCEL"); // Accel - Schems: Accelevr case 0: return input_port_read(space->machine, "ACCEL"); @@ -236,13 +250,15 @@ static READ16_HANDLER( selected_ip_word_r ) static WRITE16_HANDLER( nemesis_soundlatch_word_w ) { if (ACCESSING_BITS_0_7) - soundlatch_w(space,offset,data & 0xff); + soundlatch_w(space, offset, data & 0xff); } static WRITE8_DEVICE_HANDLER( gx400_speech_start_w ) { + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + /* the voice data is not in a rom but in sound RAM at $8000 */ - vlm5030_set_rom(device, gx400_shared_ram + 0x4000); + vlm5030_set_rom(device, state->gx400_shared_ram + 0x4000); vlm5030_st(device, 1); vlm5030_st(device, 0); } @@ -261,13 +277,12 @@ static READ8_DEVICE_HANDLER( nemesis_portA_r ) bit 5: vlm5030 busy bit 7: unused by this software version. Bubble Memory version uses this bit. */ - - running_device *vlm = devtag_get_device(device->machine, "vlm"); - int res = (cputag_get_total_cycles(device->machine, "audiocpu") / 1024) & 0x2f; // this should be 0x0f, but it doesn't work + nemesis_state *state = (nemesis_state *)device->machine->driver_data; + int res = (cpu_get_total_cycles(state->audiocpu) / 1024) & 0x2f; // this should be 0x0f, but it doesn't work res |= 0xd0; - if (vlm != NULL && vlm5030_bsy(vlm)) + if (state->vlm != NULL && vlm5030_bsy(state->vlm)) res |= 0x20; return res; @@ -275,26 +290,26 @@ static READ8_DEVICE_HANDLER( nemesis_portA_r ) static WRITE8_DEVICE_HANDLER( city_sound_bank_w ) { - int bank_A=(data&0x3); - int bank_B=((data>>2)&0x3); - k007232_set_bank( device, bank_A, bank_B ); + int bank_A = (data & 0x03); + int bank_B = ((data >> 2) & 0x03); + k007232_set_bank(device, bank_A, bank_B); } static ADDRESS_MAP_START( nemesis_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) + AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) AM_RANGE(0x050000, 0x051fff) AM_RAM - AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) + AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x05c400, 0x05c401) AM_READ_PORT("DSW0") AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW1") @@ -316,19 +331,19 @@ static ADDRESS_MAP_START( gx400_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM /* ROM BIOS */ AM_RANGE(0x010000, 0x01ffff) AM_RAM AM_RANGE(0x020000, 0x0287ff) AM_READWRITE(gx400_sharedram_word_r, gx400_sharedram_word_w) - AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) + AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) AM_RANGE(0x050000, 0x051fff) AM_RAM - AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) AM_RANGE(0x057000, 0x057fff) AM_RAM /* needed for twinbee */ - AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW0") AM_RANGE(0x05c404, 0x05c405) AM_READ_PORT("DSW1") @@ -349,18 +364,18 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( konamigt_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) + AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) AM_RANGE(0x050000, 0x051fff) AM_RAM - AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) + AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x05c400, 0x05c401) AM_READ_PORT("DSW0") AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW1") @@ -383,18 +398,18 @@ static ADDRESS_MAP_START( rf2_gx400_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM /* ROM BIOS */ AM_RANGE(0x010000, 0x01ffff) AM_RAM AM_RANGE(0x020000, 0x0287ff) AM_READWRITE(gx400_sharedram_word_r, gx400_sharedram_word_w) - AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) + AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) AM_RANGE(0x050000, 0x051fff) AM_RAM - AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) + AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW0") AM_RANGE(0x05c404, 0x05c405) AM_READ_PORT("DSW1") @@ -418,11 +433,11 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x4000, 0x47ff) AM_RAM - AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("konami", k005289_pitch_A_w) - AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("konami", k005289_pitch_B_w) + AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("k007232", k005289_pitch_A_w) + AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("k007232", k005289_pitch_B_w) AM_RANGE(0xe001, 0xe001) AM_READ(soundlatch_r) - AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("konami", k005289_keylatch_A_w) - AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("konami", k005289_keylatch_B_w) + AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("k007232", k005289_keylatch_A_w) + AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("k007232", k005289_keylatch_B_w) AM_RANGE(0xe005, 0xe005) AM_DEVWRITE("ay2", ay8910_address_w) AM_RANGE(0xe006, 0xe006) AM_DEVWRITE("ay1", ay8910_address_w) AM_RANGE(0xe086, 0xe086) AM_DEVREAD("ay1", ay8910_r) @@ -433,13 +448,13 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( gx400_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM - AM_RANGE(0x4000, 0x87ff) AM_RAM AM_BASE(&gx400_shared_ram) - AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("konami", k005289_pitch_A_w) - AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("konami", k005289_pitch_B_w) + AM_RANGE(0x4000, 0x87ff) AM_RAM AM_BASE_MEMBER(nemesis_state, gx400_shared_ram) + AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("k007232", k005289_pitch_A_w) + AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("k007232", k005289_pitch_B_w) AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("vlm", vlm5030_data_w) AM_RANGE(0xe001, 0xe001) AM_READ(soundlatch_r) - AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("konami", k005289_keylatch_A_w) - AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("konami", k005289_keylatch_B_w) + AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("k007232", k005289_keylatch_A_w) + AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("k007232", k005289_keylatch_B_w) AM_RANGE(0xe005, 0xe005) AM_DEVWRITE("ay2", ay8910_address_w) AM_RANGE(0xe006, 0xe006) AM_DEVWRITE("ay1", ay8910_address_w) AM_RANGE(0xe030, 0xe030) AM_DEVWRITE("vlm", gx400_speech_start_w) @@ -454,7 +469,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( salamand_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x080000, 0x087fff) AM_RAM - AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(salamand_control_port_word_w) /* irq enable, flipscreen, etc. */ AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("DSW0") @@ -463,22 +478,22 @@ static ADDRESS_MAP_START( salamand_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0c2002, 0x0c2003) AM_READ_PORT("IN1") AM_RANGE(0x0c2004, 0x0c2005) AM_READ_PORT("IN2") AM_RANGE(0x0c2006, 0x0c2007) AM_READ_PORT("DSW1") - AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) /* VRAM */ - AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) - AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) - AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* more sprite ram ??? */ + AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) /* VRAM */ + AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) + AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) + AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) /* more sprite ram ??? */ AM_RANGE(0x190000, 0x191fff) AM_RAM - AM_RANGE(0x190000, 0x1903ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x190400, 0x1907ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x190f00, 0x190f7f) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x190f80, 0x190fff) AM_BASE(&nemesis_yscroll2) + AM_RANGE(0x190000, 0x1903ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x190400, 0x1907ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x190f00, 0x190f7f) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x190f80, 0x190fff) AM_BASE_MEMBER(nemesis_state, yscroll2) ADDRESS_MAP_END static ADDRESS_MAP_START( blkpnthr_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x080000, 0x081fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x080000, 0x081fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x090000, 0x097fff) AM_RAM AM_RANGE(0x0a0000, 0x0a0001) AM_RAM_WRITE(salamand_control_port_word_w) /* irq enable, flipscreen, etc. */ AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w) @@ -488,23 +503,23 @@ static ADDRESS_MAP_START( blkpnthr_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0c2002, 0x0c2003) AM_READ_PORT("IN1") AM_RANGE(0x0c2004, 0x0c2005) AM_READ_PORT("IN2") AM_RANGE(0x0c2006, 0x0c2007) AM_READ_PORT("DSW1") - AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) AM_MIRROR(0x4000) /* VRAM */ - AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) AM_MIRROR(0x4000) - AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) - AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) + AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) AM_MIRROR(0x4000) /* VRAM */ + AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) AM_MIRROR(0x4000) + AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) + AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) AM_RANGE(0x180000, 0x181fff) AM_RAM - AM_RANGE(0x180000, 0x1803ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x180400, 0x1807ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x180f00, 0x180f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x180f80, 0x180fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x190000, 0x190fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* more sprite ram ??? */ + AM_RANGE(0x180000, 0x1803ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x180400, 0x1807ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x180f00, 0x180f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x180f80, 0x180fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x190000, 0x190fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) /* more sprite ram ??? */ ADDRESS_MAP_END static ADDRESS_MAP_START( citybomb_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_RANGE(0x080000, 0x087fff) AM_RAM - AM_RANGE(0x0e0000, 0x0e1fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x0e0000, 0x0e1fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x0f0000, 0x0f0001) AM_READ_PORT("DSW1") AM_RANGE(0x0f0002, 0x0f0003) AM_READ_PORT("IN2") AM_RANGE(0x0f0004, 0x0f0005) AM_READ_PORT("IN1") @@ -515,23 +530,23 @@ static ADDRESS_MAP_START( citybomb_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0f0020, 0x0f0021) AM_READ(selected_ip_word_r) AM_WRITENOP /* WEC Le Mans 24 control? */ AM_RANGE(0x0f8000, 0x0f8001) AM_WRITE(salamand_control_port_word_w) /* irq enable, flipscreen, etc. */ AM_RANGE(0x100000, 0x1bffff) AM_ROM - AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) - AM_RANGE(0x210000, 0x210fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x211000, 0x211fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x212000, 0x212fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x213000, 0x213fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) + AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) + AM_RANGE(0x210000, 0x210fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x211000, 0x211fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x212000, 0x212fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x213000, 0x213fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) AM_RANGE(0x300000, 0x301fff) AM_RAM - AM_RANGE(0x300000, 0x3003ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x300400, 0x3007ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x300f00, 0x300f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x300f80, 0x300fff) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x310000, 0x310fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* more sprite ram ??? */ + AM_RANGE(0x300000, 0x3003ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x300400, 0x3007ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x300f00, 0x300f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x300f80, 0x300fff) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x310000, 0x310fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) /* more sprite ram ??? */ ADDRESS_MAP_END static ADDRESS_MAP_START( nyanpani_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_RANGE(0x040000, 0x047fff) AM_RAM - AM_RANGE(0x060000, 0x061fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x060000, 0x061fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x100000, 0x13ffff) AM_ROM AM_RANGE(0x070000, 0x070001) AM_READ_PORT("DSW1") AM_RANGE(0x070002, 0x070003) AM_READ_PORT("IN2") @@ -541,30 +556,31 @@ static ADDRESS_MAP_START( nyanpani_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x070010, 0x070011) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x070018, 0x070019) AM_WRITE(watchdog_reset16_w) /* probably */ AM_RANGE(0x078000, 0x078001) AM_WRITE(salamand_control_port_word_w) /* irq enable, flipscreen, etc. */ - AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) /* VRAM */ - AM_RANGE(0x201000, 0x201fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) - AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x203000, 0x203fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x210000, 0x21ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) - AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* more sprite ram ??? */ + AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) /* VRAM */ + AM_RANGE(0x201000, 0x201fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) + AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x203000, 0x203fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x210000, 0x21ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) + AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) /* more sprite ram ??? */ AM_RANGE(0x310000, 0x311fff) AM_RAM - AM_RANGE(0x310000, 0x3103ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x310400, 0x3107ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x310f00, 0x310f7f) AM_BASE(&nemesis_yscroll2) - AM_RANGE(0x310f80, 0x310fff) AM_BASE(&nemesis_yscroll1) + AM_RANGE(0x310000, 0x3103ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x310400, 0x3107ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x310f00, 0x310f7f) AM_BASE_MEMBER(nemesis_state, yscroll2) + AM_RANGE(0x310f80, 0x310fff) AM_BASE_MEMBER(nemesis_state, yscroll1) ADDRESS_MAP_END static READ8_HANDLER( wd_r ) { - frame_counter^= 1; - return frame_counter; + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + state->frame_counter ^= 1; + return state->frame_counter; } static ADDRESS_MAP_START( sal_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r) - AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w) + AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w) AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) AM_RANGE(0xd000, 0xd000) AM_DEVWRITE("vlm", vlm5030_data_w) AM_RANGE(0xe000, 0xe000) AM_READ(wd_r) /* watchdog?? */ @@ -575,7 +591,7 @@ static ADDRESS_MAP_START( blkpnthr_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r) - AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w) + AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w) AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) AM_RANGE(0xe000, 0xe000) AM_READ(wd_r) /* watchdog?? */ ADDRESS_MAP_END @@ -583,13 +599,13 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( city_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM - AM_RANGE(0x9800, 0x987f) AM_DEVWRITE("konami2", k051649_waveform_w) - AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("konami2", k051649_frequency_w) - AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("konami2", k051649_volume_w) - AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("konami2", k051649_keyonoff_w) + AM_RANGE(0x9800, 0x987f) AM_DEVWRITE("k051649", k051649_waveform_w) + AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("k051649", k051649_frequency_w) + AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("k051649", k051649_volume_w) + AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("k051649", k051649_keyonoff_w) AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ymsnd", ym3812_r, ym3812_w) - AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w) - AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("konami", city_sound_bank_w) /* 7232 bankswitch */ + AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w) + AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("k007232", city_sound_bank_w) /* 7232 bankswitch */ AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r) ADDRESS_MAP_END @@ -599,7 +615,7 @@ static ADDRESS_MAP_START( hcrash_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x040000, 0x05ffff) AM_ROM AM_RANGE(0x080000, 0x083fff) AM_RAM - AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram) + AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram) AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(salamand_control_port_word_w) /* irq enable, flipscreen, etc. */ AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w) AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("DSW0") @@ -613,17 +629,17 @@ static ADDRESS_MAP_START( hcrash_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0c2804, 0x0c2805) AM_WRITENOP AM_RANGE(0x0c4000, 0x0c4001) AM_READ_PORT("IN1") AM_WRITE(selected_ip_word_w) AM_RANGE(0x0c4002, 0x0c4003) AM_READ(selected_ip_word_r) AM_WRITENOP /* WEC Le Mans 24 control. latches the value read previously */ - AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2) /* VRAM */ - AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1) - AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) - AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) - AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size) - AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2) /* VRAM */ + AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1) + AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) + AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) + AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size) + AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size) AM_RANGE(0x190000, 0x191fff) AM_RAM - AM_RANGE(0x190000, 0x1903ff) AM_BASE(&nemesis_xscroll2) - AM_RANGE(0x190400, 0x1907ff) AM_BASE(&nemesis_xscroll1) - AM_RANGE(0x190f00, 0x190f7f) AM_BASE(&nemesis_yscroll1) - AM_RANGE(0x190f80, 0x190fff) AM_BASE(&nemesis_yscroll2) + AM_RANGE(0x190000, 0x1903ff) AM_BASE_MEMBER(nemesis_state, xscroll2) + AM_RANGE(0x190400, 0x1907ff) AM_BASE_MEMBER(nemesis_state, xscroll1) + AM_RANGE(0x190f00, 0x190f7f) AM_BASE_MEMBER(nemesis_state, yscroll1) + AM_RANGE(0x190f80, 0x190fff) AM_BASE_MEMBER(nemesis_state, yscroll2) ADDRESS_MAP_END /******************************************************************************/ @@ -1594,14 +1610,15 @@ static const ay8910_interface ay8910_interface_2 = AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, - DEVCB_DEVICE_HANDLER("konami", k005289_control_A_w), - DEVCB_DEVICE_HANDLER("konami", k005289_control_B_w) + DEVCB_DEVICE_HANDLER("k007232", k005289_control_A_w), + DEVCB_DEVICE_HANDLER("k007232", k005289_control_B_w) }; static void sound_irq(running_device *device, int state) { /* Interrupts _are_ generated, I wonder where they go.. */ -/*cputag_set_input_line(device->machine, "audiocpu", 0, HOLD_LINE);*/ +// nemesis_state *driver_state = (nemesis_state *)device->machine->driver_data; +// cpu_set_input_line(driver_state->audiocpu, 0, HOLD_LINE); } static const ym2151_interface ym2151_config = @@ -1616,8 +1633,8 @@ static const ym3812_interface ym3812_config = static void volume_callback(running_device *device, int v) { - k007232_set_volume(device,0,(v >> 4) * 0x11,0); - k007232_set_volume(device,1,0,(v & 0x0f) * 0x11); + k007232_set_volume(device, 0, (v >> 4) * 0x11, 0); + k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11); } static const k007232_interface k007232_config = @@ -1627,8 +1644,49 @@ static const k007232_interface k007232_config = /******************************************************************************/ +static MACHINE_START( nemesis ) +{ + nemesis_state *state = (nemesis_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->vlm = devtag_get_device(machine, "vlm"); + + state_save_register_global(machine, state->irq_on); + state_save_register_global(machine, state->irq1_on); + state_save_register_global(machine, state->irq2_on); + state_save_register_global(machine, state->irq4_on); + state_save_register_global(machine, state->frame_counter); + state_save_register_global(machine, state->gx400_irq1_cnt); + state_save_register_global(machine, state->selected_ip); + + state_save_register_global(machine, state->tilemap_flip); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->irq_port_last); +} + +static MACHINE_RESET( nemesis ) +{ + nemesis_state *state = (nemesis_state *)machine->driver_data; + + state->irq_on = 0; + state->irq1_on = 0; + state->irq2_on = 0; + state->irq4_on = 0; + state->gx400_irq1_cnt = 0; + state->frame_counter = 1; + state->selected_ip = 0; + + state->flipscreen = 0; + state->tilemap_flip = 0; + state->irq_port_last = 0; +} + static MACHINE_DRIVER_START( nemesis ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216 MHz? */ // 14318180/2, /* From schematics, should be accurate */ @@ -1638,6 +1696,7 @@ static MACHINE_DRIVER_START( nemesis ) MDRV_CPU_ADD("audiocpu", Z80,14318180/4) /* From schematics, should be accurate */ MDRV_CPU_PROGRAM_MAP(sound_map) /* fixed */ + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1665,7 +1724,7 @@ static MACHINE_DRIVER_START( nemesis ) MDRV_SOUND_CONFIG(ay8910_interface_2) /* fixed */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) /* verified with OST */ - MDRV_SOUND_ADD("konami", K005289, 3579545/2) + MDRV_SOUND_ADD("k007232", K005289, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.35) /* verified with OST */ MDRV_SOUND_ADD("vlm", VLM5030, 3579545) @@ -1675,6 +1734,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( gx400 ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216MHz */ MDRV_CPU_PROGRAM_MAP(gx400_map) @@ -1684,6 +1746,7 @@ static MACHINE_DRIVER_START( gx400 ) MDRV_CPU_PROGRAM_MAP(gx400_sound_map) MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) /* interrupts are triggered by the main CPU */ + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1711,7 +1774,7 @@ static MACHINE_DRIVER_START( gx400 ) MDRV_SOUND_CONFIG(ay8910_interface_2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) /* verified with OST */ - MDRV_SOUND_ADD("konami", K005289, 3579545/2) + MDRV_SOUND_ADD("k007232", K005289, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.35) /* verified with OST */ MDRV_SOUND_ADD("vlm", VLM5030, 3579545) @@ -1721,6 +1784,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( konamigt ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216 MHz? */ MDRV_CPU_PROGRAM_MAP(konamigt_map) @@ -1729,6 +1795,7 @@ static MACHINE_DRIVER_START( konamigt ) MDRV_CPU_ADD("audiocpu", Z80,14318180/4) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1756,13 +1823,16 @@ static MACHINE_DRIVER_START( konamigt ) MDRV_SOUND_CONFIG(ay8910_interface_2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("konami", K005289, 3579545/2) + MDRV_SOUND_ADD("k007232", K005289, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END static MACHINE_DRIVER_START( rf2_gx400 ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216MHz */ MDRV_CPU_PROGRAM_MAP(rf2_gx400_map) @@ -1772,6 +1842,7 @@ static MACHINE_DRIVER_START( rf2_gx400 ) MDRV_CPU_PROGRAM_MAP(gx400_sound_map) MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) /* interrupts are triggered by the main CPU */ + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1799,7 +1870,7 @@ static MACHINE_DRIVER_START( rf2_gx400 ) MDRV_SOUND_CONFIG(ay8910_interface_2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("konami", K005289, 3579545/2) + MDRV_SOUND_ADD("k007232", K005289, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MDRV_SOUND_ADD("vlm", VLM5030, 3579545) @@ -1809,6 +1880,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( salamand ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216MHz */ MDRV_CPU_PROGRAM_MAP(salamand_map) @@ -1817,6 +1891,7 @@ static MACHINE_DRIVER_START( salamand ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(sal_sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1842,7 +1917,7 @@ static MACHINE_DRIVER_START( salamand ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) - MDRV_SOUND_ADD("konami", K007232, 3579545) + MDRV_SOUND_ADD("k007232", K007232, 3579545) MDRV_SOUND_CONFIG(k007232_config) MDRV_SOUND_ROUTE(0, "lspeaker", 0.10) MDRV_SOUND_ROUTE(0, "rspeaker", 0.10) @@ -1858,6 +1933,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( blkpnthr ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216 MHz? */ MDRV_CPU_PROGRAM_MAP(blkpnthr_map) @@ -1866,6 +1944,7 @@ static MACHINE_DRIVER_START( blkpnthr ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(blkpnthr_sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1887,7 +1966,7 @@ static MACHINE_DRIVER_START( blkpnthr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("konami", K007232, 3579545) + MDRV_SOUND_ADD("k007232", K007232, 3579545) MDRV_SOUND_CONFIG(k007232_config) MDRV_SOUND_ROUTE(0, "lspeaker", 0.10) MDRV_SOUND_ROUTE(0, "rspeaker", 0.10) @@ -1903,6 +1982,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( citybomb ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216 MHz? */ MDRV_CPU_PROGRAM_MAP(citybomb_map) @@ -1911,6 +1993,7 @@ static MACHINE_DRIVER_START( citybomb ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(city_sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1932,7 +2015,7 @@ static MACHINE_DRIVER_START( citybomb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("konami", K007232, 3579545) + MDRV_SOUND_ADD("k007232", K007232, 3579545) MDRV_SOUND_CONFIG(k007232_config) MDRV_SOUND_ROUTE(0, "lspeaker", 0.30) MDRV_SOUND_ROUTE(0, "rspeaker", 0.30) @@ -1944,7 +2027,7 @@ static MACHINE_DRIVER_START( citybomb ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("konami2", K051649, 3579545/2) + MDRV_SOUND_ADD("k051649", K051649, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38) MACHINE_DRIVER_END @@ -1952,6 +2035,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( nyanpani ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/2) /* 9.216 MHz? */ MDRV_CPU_PROGRAM_MAP(nyanpani_map) @@ -1960,6 +2046,7 @@ static MACHINE_DRIVER_START( nyanpani ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(city_sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -1981,7 +2068,7 @@ static MACHINE_DRIVER_START( nyanpani ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("konami", K007232, 3579545) + MDRV_SOUND_ADD("k007232", K007232, 3579545) MDRV_SOUND_CONFIG(k007232_config) MDRV_SOUND_ROUTE(0, "lspeaker", 0.30) MDRV_SOUND_ROUTE(0, "rspeaker", 0.30) @@ -1993,7 +2080,7 @@ static MACHINE_DRIVER_START( nyanpani ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("konami2", K051649, 3579545/2) + MDRV_SOUND_ADD("k051649", K051649, 3579545/2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38) MACHINE_DRIVER_END @@ -2001,6 +2088,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( hcrash ) + /* driver data */ + MDRV_DRIVER_DATA(nemesis_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,18432000/3) /* 6.144MHz */ MDRV_CPU_PROGRAM_MAP(hcrash_map) @@ -2009,6 +2099,7 @@ static MACHINE_DRIVER_START( hcrash ) MDRV_CPU_ADD("audiocpu", Z80,14318180/4) /* 3.579545 MHz */ MDRV_CPU_PROGRAM_MAP(sal_sound_map) + MDRV_MACHINE_START(nemesis) MDRV_MACHINE_RESET(nemesis) /* video hardware */ @@ -2032,7 +2123,7 @@ static MACHINE_DRIVER_START( hcrash ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) - MDRV_SOUND_ADD("konami", K007232, 3579545) + MDRV_SOUND_ADD("k007232", K007232, 3579545) MDRV_SOUND_CONFIG(k007232_config) MDRV_SOUND_ROUTE(0, "lspeaker", 0.10) MDRV_SOUND_ROUTE(0, "rspeaker", 0.10) @@ -2065,7 +2156,7 @@ ROM_START( nemesis ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "456-d09.9c", 0x00000, 0x4000, CRC(26bf9636) SHA1(009dcbf18ea6230fc75a72232bd4fc29ad28dbf0) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2084,7 +2175,7 @@ ROM_START( nemesisuk ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "456-d09.9c", 0x00000, 0x4000, CRC(26bf9636) SHA1(009dcbf18ea6230fc75a72232bd4fc29ad28dbf0) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2103,7 +2194,7 @@ ROM_START( konamigt ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "561-b09.9c", 0x00000, 0x4000, CRC(539d0c49) SHA1(4c16b07fbd876b6445fc0ec49c3ad5ab1a92cbf6) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2118,7 +2209,7 @@ ROM_START( rf2 ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "400-e03.5l", 0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2133,7 +2224,7 @@ ROM_START( twinbee ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "400-e03.5l", 0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2148,7 +2239,7 @@ ROM_START( gradius ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "400-e03.5l", 0x00000, 0x2000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2163,7 +2254,7 @@ ROM_START( gwarrior ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "400-e03.5l", 0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) ) - ROM_REGION( 0x0200, "konami", 0 ) /* 2x 256 byte for 0005289 wavetable data */ + ROM_REGION( 0x0200, "k007232", 0 ) /* 2x 256 byte for 0005289 wavetable data */ ROM_LOAD( "400-a01.fse", 0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) ) ROM_LOAD( "400-a02.fse", 0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) ) ROM_END @@ -2181,7 +2272,7 @@ ROM_START( salamand ) ROM_REGION( 0x04000, "vlm", 0 ) /* VLM5030 data? */ ROM_LOAD( "587-d08.8g", 0x00000, 0x04000, CRC(f9ac6b82) SHA1(3370fc3a7f82e922e19d54afb3bca7b07fa4aa9a) ) - ROM_REGION( 0x20000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x20000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "587-c01.10a", 0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */ ROM_END @@ -2198,7 +2289,7 @@ ROM_START( salamandj ) ROM_REGION( 0x04000, "vlm", 0 ) /* VLM5030 data? */ ROM_LOAD( "587-d08.8g", 0x00000, 0x04000, CRC(f9ac6b82) SHA1(3370fc3a7f82e922e19d54afb3bca7b07fa4aa9a) ) - ROM_REGION( 0x20000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x20000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "587-c01.10a", 0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */ ROM_END @@ -2215,7 +2306,7 @@ ROM_START( lifefrce ) ROM_REGION( 0x04000, "vlm", 0 ) /* VLM5030 data? */ ROM_LOAD( "587-k08.8g", 0x00000, 0x04000, CRC(7f0e9b41) SHA1(c9fc2723fac55691dfbb4cf9b3c472a42efa97c9) ) - ROM_REGION( 0x20000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x20000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "587-c01.10a", 0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */ ROM_END @@ -2232,7 +2323,7 @@ ROM_START( lifefrcej ) ROM_REGION( 0x04000, "vlm", 0 ) /* VLM5030 data? */ ROM_LOAD( "587-k08.8g", 0x00000, 0x04000, CRC(7f0e9b41) SHA1(c9fc2723fac55691dfbb4cf9b3c472a42efa97c9) ) - ROM_REGION( 0x20000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x20000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "587-c01.10a", 0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */ ROM_END @@ -2246,7 +2337,7 @@ ROM_START( blkpnthr ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "604-a08.11j", 0x00000, 0x08000, CRC(aff88a2b) SHA1(7080add63deab5755606759a218dea9105df4819) ) - ROM_REGION( 0x20000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x20000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "604-a01.10a", 0x00000, 0x20000, CRC(eceb64a6) SHA1(028157d336770fe4ca17c24476d62a790255898a) ) ROM_END @@ -2264,7 +2355,7 @@ ROM_START( citybomb ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "787-e02.4h", 0x00000, 0x08000, CRC(f4591e46) SHA1(c17c1a24bf1866fbba388521a4b7ea0975bda587) ) - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "787-e01.1k", 0x00000, 0x80000, CRC(edc34d01) SHA1(b1465d1a7364a7cebc14b96cd01dc78e57975972) ) ROM_END @@ -2282,7 +2373,7 @@ ROM_START( citybombj ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "787-e02.4h", 0x00000, 0x08000, CRC(f4591e46) SHA1(c17c1a24bf1866fbba388521a4b7ea0975bda587) ) - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "787-e01.1k", 0x00000, 0x80000, CRC(edc34d01) SHA1(b1465d1a7364a7cebc14b96cd01dc78e57975972) ) ROM_END @@ -2296,7 +2387,7 @@ ROM_START( kittenk ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "712-e02.4h", 0x00000, 0x08000, CRC(ba76f310) SHA1(cc2164a9617493d1b3b8ac67430f9eb26fd987d2) ) - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "712-b01.1k", 0x00000, 0x80000, CRC(f65b5d95) SHA1(12701be68629844720cd16af857ce38ef06af61c) ) ROM_END @@ -2310,7 +2401,7 @@ ROM_START( nyanpani ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for sound */ ROM_LOAD( "712-e02.4h", 0x00000, 0x08000, CRC(ba76f310) SHA1(cc2164a9617493d1b3b8ac67430f9eb26fd987d2) ) - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "712-b01.1k", 0x00000, 0x80000, CRC(f65b5d95) SHA1(12701be68629844720cd16af857ce38ef06af61c) ) ROM_END @@ -2434,7 +2525,7 @@ ROM_START( hcrash ) ROM_LOAD( "790-c08.j4", 0x04000, 0x04000, CRC(cfb844bc) SHA1(43b7adb6093e707212204118087ef4f79b0dbc1f) ) ROM_CONTINUE( 0x00000, 0x04000 ) /* Board is wired for 27C128, top half of EPROM is blank */ - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "790-c01.m10", 0x00000, 0x20000, CRC(07976bc3) SHA1(9341ac6084fbbe17c4e7bbefade9a3f1dec3f132) ) ROM_END @@ -2452,39 +2543,27 @@ ROM_START( hcrashc ) ROM_LOAD( "790-c08.j4", 0x04000, 0x04000, CRC(cfb844bc) SHA1(43b7adb6093e707212204118087ef4f79b0dbc1f) ) ROM_CONTINUE( 0x00000, 0x04000 ) /* Board is wired for 27C128, top half of EPROM is blank */ - ROM_REGION( 0x80000, "konami", 0 ) /* 007232 data */ + ROM_REGION( 0x80000, "k007232", 0 ) /* 007232 data */ ROM_LOAD( "790-c01.m10", 0x00000, 0x20000, CRC(07976bc3) SHA1(9341ac6084fbbe17c4e7bbefade9a3f1dec3f132) ) ROM_END -static DRIVER_INIT( nemesis ) -{ - /* Set up save state */ - state_save_register_global(machine, nemesis_irq_on); - state_save_register_global(machine, nemesis_irq1_on); - state_save_register_global(machine, nemesis_irq2_on); - state_save_register_global(machine, nemesis_irq4_on); - state_save_register_global(machine, frame_counter); - state_save_register_global(machine, gx400_irq1_cnt); - state_save_register_global(machine, hcrash_selected_ip); -} - -GAME( 1985, nemesis, 0, nemesis, nemesis, nemesis, ROT0, "Konami", "Nemesis", GAME_SUPPORTS_SAVE ) -GAME( 1985, nemesisuk, nemesis, nemesis, nemesuk, nemesis, ROT0, "Konami", "Nemesis (World?)", GAME_SUPPORTS_SAVE ) -GAME( 1985, konamigt, 0, konamigt, konamigt, nemesis, ROT0, "Konami", "Konami GT", GAME_SUPPORTS_SAVE ) -GAME( 1985, rf2, konamigt, rf2_gx400, rf2, nemesis, ROT0, "Konami", "Konami RF2 - Red Fighter", GAME_SUPPORTS_SAVE ) -GAME( 1985, twinbee, 0, gx400, twinbee, nemesis, ROT90, "Konami", "TwinBee", GAME_SUPPORTS_SAVE ) -GAME( 1985, gradius, nemesis, gx400, gradius, nemesis, ROT0, "Konami", "Gradius", GAME_SUPPORTS_SAVE ) -GAME( 1985, gwarrior, 0, gx400, gwarrior, nemesis, ROT0, "Konami", "Galactic Warriors", GAME_SUPPORTS_SAVE ) -GAME( 1986, salamand, 0, salamand, salamand, nemesis, ROT0, "Konami", "Salamander (version D)", GAME_SUPPORTS_SAVE ) -GAME( 1986, salamandj, salamand, salamand, salamand, nemesis, ROT0, "Konami", "Salamander (version J)", GAME_SUPPORTS_SAVE ) -GAME( 1986, lifefrce, salamand, salamand, salamand, nemesis, ROT0, "Konami", "Lifeforce (US)", GAME_SUPPORTS_SAVE ) -GAME( 1987, lifefrcej, salamand, salamand, lifefrcj, nemesis, ROT0, "Konami", "Lifeforce (Japan)", GAME_SUPPORTS_SAVE ) -GAME( 1987, blkpnthr, 0, blkpnthr, blkpnthr, nemesis, ROT0, "Konami", "Black Panther", GAME_SUPPORTS_SAVE ) -GAME( 1987, citybomb, 0, citybomb, citybomb, nemesis, ROT270, "Konami", "City Bomber (World)", GAME_SUPPORTS_SAVE ) -GAME( 1987, citybombj, citybomb, citybomb, citybomb, nemesis, ROT270, "Konami", "City Bomber (Japan)", GAME_SUPPORTS_SAVE ) -GAME( 1987, hcrash, 0, hcrash, hcrash, nemesis, ROT0, "Konami", "Hyper Crash (version D)", GAME_SUPPORTS_SAVE ) -GAME( 1987, hcrashc, hcrash, hcrash, hcrash, nemesis, ROT0, "Konami", "Hyper Crash (version C)", GAME_SUPPORTS_SAVE ) -GAME( 1988, kittenk, 0, nyanpani, nyanpani, nemesis, ROT0, "Konami", "Kitten Kaboodle", GAME_SUPPORTS_SAVE ) -GAME( 1988, nyanpani, kittenk, nyanpani, nyanpani, nemesis, ROT0, "Konami", "Nyan Nyan Panic (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1985, nemesis, 0, nemesis, nemesis, 0, ROT0, "Konami", "Nemesis", GAME_SUPPORTS_SAVE ) +GAME( 1985, nemesisuk, nemesis, nemesis, nemesuk, 0, ROT0, "Konami", "Nemesis (World?)", GAME_SUPPORTS_SAVE ) +GAME( 1985, konamigt, 0, konamigt, konamigt, 0, ROT0, "Konami", "Konami GT", GAME_SUPPORTS_SAVE ) +GAME( 1985, rf2, konamigt, rf2_gx400, rf2, 0, ROT0, "Konami", "Konami RF2 - Red Fighter", GAME_SUPPORTS_SAVE ) +GAME( 1985, twinbee, 0, gx400, twinbee, 0, ROT90, "Konami", "TwinBee", GAME_SUPPORTS_SAVE ) +GAME( 1985, gradius, nemesis, gx400, gradius, 0, ROT0, "Konami", "Gradius", GAME_SUPPORTS_SAVE ) +GAME( 1985, gwarrior, 0, gx400, gwarrior, 0, ROT0, "Konami", "Galactic Warriors", GAME_SUPPORTS_SAVE ) +GAME( 1986, salamand, 0, salamand, salamand, 0, ROT0, "Konami", "Salamander (version D)", GAME_SUPPORTS_SAVE ) +GAME( 1986, salamandj, salamand, salamand, salamand, 0, ROT0, "Konami", "Salamander (version J)", GAME_SUPPORTS_SAVE ) +GAME( 1986, lifefrce, salamand, salamand, salamand, 0, ROT0, "Konami", "Lifeforce (US)", GAME_SUPPORTS_SAVE ) +GAME( 1987, lifefrcej, salamand, salamand, lifefrcj, 0, ROT0, "Konami", "Lifeforce (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1987, blkpnthr, 0, blkpnthr, blkpnthr, 0, ROT0, "Konami", "Black Panther", GAME_SUPPORTS_SAVE ) +GAME( 1987, citybomb, 0, citybomb, citybomb, 0, ROT270, "Konami", "City Bomber (World)", GAME_SUPPORTS_SAVE ) +GAME( 1987, citybombj, citybomb, citybomb, citybomb, 0, ROT270, "Konami", "City Bomber (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1987, hcrash, 0, hcrash, hcrash, 0, ROT0, "Konami", "Hyper Crash (version D)", GAME_SUPPORTS_SAVE ) +GAME( 1987, hcrashc, hcrash, hcrash, hcrash, 0, ROT0, "Konami", "Hyper Crash (version C)", GAME_SUPPORTS_SAVE ) +GAME( 1988, kittenk, 0, nyanpani, nyanpani, 0, ROT0, "Konami", "Kitten Kaboodle", GAME_SUPPORTS_SAVE ) +GAME( 1988, nyanpani, kittenk, nyanpani, nyanpani, 0, ROT0, "Konami", "Nyan Nyan Panic (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/nyny.c b/src/mame/drivers/nyny.c index 2c446264987..29eca6b9cc0 100644 --- a/src/mame/drivers/nyny.c +++ b/src/mame/drivers/nyny.c @@ -72,26 +72,43 @@ #include "sound/dac.h" - -#define MAIN_CPU_MASTER_CLOCK (XTAL_11_2MHz) -#define PIXEL_CLOCK (MAIN_CPU_MASTER_CLOCK / 2) -#define CRTC_CLOCK (MAIN_CPU_MASTER_CLOCK / 16) -#define AUDIO_1_MASTER_CLOCK (XTAL_4MHz) -#define AUDIO_CPU_1_CLOCK (AUDIO_1_MASTER_CLOCK) -#define AUDIO_2_MASTER_CLOCK (XTAL_4MHz) -#define AUDIO_CPU_2_CLOCK (AUDIO_2_MASTER_CLOCK) +#define MAIN_CPU_MASTER_CLOCK XTAL_11_2MHz +#define PIXEL_CLOCK (MAIN_CPU_MASTER_CLOCK / 2) +#define CRTC_CLOCK (MAIN_CPU_MASTER_CLOCK / 16) +#define AUDIO_1_MASTER_CLOCK XTAL_4MHz +#define AUDIO_CPU_1_CLOCK AUDIO_1_MASTER_CLOCK +#define AUDIO_2_MASTER_CLOCK XTAL_4MHz +#define AUDIO_CPU_2_CLOCK AUDIO_2_MASTER_CLOCK -static UINT8 *nyny_videoram_1; -static UINT8 *nyny_videoram_2; -static UINT8 *nyny_colorram_1; -static UINT8 *nyny_colorram_2; -static UINT8 flipscreen; +class nyny_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nyny_state(machine)); } -static UINT8 star_enable; -static UINT16 star_delay_counter; -static UINT16 star_shift_reg; + nyny_state(running_machine &machine) { } + + /* memory pointers */ + UINT8 * videoram1; + UINT8 * videoram2; + UINT8 * colorram1; + UINT8 * colorram2; + /* video-related */ + int flipscreen; + UINT8 star_enable; + UINT16 star_delay_counter; + UINT16 star_shift_reg; + + /* devices */ + running_device *maincpu; + running_device *audiocpu; + running_device *audiocpu2; + running_device *ic48_1; + running_device *mc6845; + running_device *pia1; + running_device *pia2; +}; /************************************* @@ -104,7 +121,6 @@ static WRITE_LINE_DEVICE_HANDLER( flipscreen_w ); static WRITE8_HANDLER( audio_2_command_w ); - /************************************* * * Interrupt generation @@ -113,17 +129,17 @@ static WRITE8_HANDLER( audio_2_command_w ); static WRITE_LINE_DEVICE_HANDLER( main_cpu_irq ) { - running_device *pia1 = devtag_get_device(device->machine, "pia1"); - running_device *pia2 = devtag_get_device(device->machine, "pia2"); - int combined_state = pia6821_get_irq_a(pia1) | pia6821_get_irq_b(pia1) | pia6821_get_irq_b(pia2); + nyny_state *driver_state = (nyny_state *)device->machine->driver_data; + int combined_state = pia6821_get_irq_a(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia2); - cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(driver_state->maincpu, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } static WRITE_LINE_DEVICE_HANDLER( main_cpu_firq ) { - cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); + nyny_state *driver_state = (nyny_state *)device->machine->driver_data; + cpu_set_input_line(driver_state->maincpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); } @@ -136,17 +152,18 @@ static WRITE_LINE_DEVICE_HANDLER( main_cpu_firq ) static INTERRUPT_GEN( update_pia_1 ) { - running_device *pia1 = devtag_get_device(device->machine, "pia1"); + nyny_state *state = (nyny_state *)device->machine->driver_data; + /* update the different PIA pins from the input ports */ /* CA1 - copy of PA0 (COIN1) */ - pia6821_ca1_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x01); + pia6821_ca1_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x01); /* CA2 - copy of PA1 (SERVICE1) */ - pia6821_ca2_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x02); + pia6821_ca2_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x02); /* CB1 - (crosshatch) */ - pia6821_cb1_w(pia1, 0, input_port_read(device->machine, "CROSS")); + pia6821_cb1_w(state->pia1, 0, input_port_read(device->machine, "CROSS")); /* CB2 - NOT CONNECTED */ } @@ -178,20 +195,23 @@ static const pia6821_interface pia_1_intf = static WRITE8_DEVICE_HANDLER( pia_2_port_a_w ) { - star_delay_counter = (star_delay_counter & 0x0f00) | data; + nyny_state *state = (nyny_state *)device->machine->driver_data; + state->star_delay_counter = (state->star_delay_counter & 0x0f00) | data; } static WRITE8_DEVICE_HANDLER( pia_2_port_b_w ) { + nyny_state *state = (nyny_state *)device->machine->driver_data; + /* bits 0-3 go to bits 8-11 of the star delay counter */ - star_delay_counter = (star_delay_counter & 0x00ff) | ((data & 0x0f) << 8); + state->star_delay_counter = (state->star_delay_counter & 0x00ff) | ((data & 0x0f) << 8); /* bit 4 is star field enable */ - star_enable = data & 0x10; + state->star_enable = data & 0x10; /* bits 5-7 go to the music board connector */ - audio_2_command_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, data & 0xe0); + audio_2_command_w(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0, data & 0xe0); } @@ -225,10 +245,10 @@ static const pia6821_interface pia_2_intf = * *************************************/ -static WRITE8_DEVICE_HANDLER(ic48_1_74123_output_changed) +static WRITE8_DEVICE_HANDLER( ic48_1_74123_output_changed ) { - running_device *pia2 = devtag_get_device(device->machine, "pia2"); - pia6821_ca1_w(pia2, 0, data); + nyny_state *state = (nyny_state *)device->machine->driver_data; + pia6821_ca1_w(state->pia2, 0, data); } @@ -245,35 +265,19 @@ static const ttl74123_config ic48_1_config = -/************************************* - * - * Machine start - * - *************************************/ - -static MACHINE_START( nyny ) -{ - /* setup for save states */ - state_save_register_global(machine, flipscreen); - state_save_register_global(machine, star_enable); - state_save_register_global(machine, star_delay_counter); - state_save_register_global(machine, star_shift_reg); -} - - - /************************************* * * Video system * *************************************/ -#define NUM_PENS (8) +#define NUM_PENS 8 static WRITE_LINE_DEVICE_HANDLER( flipscreen_w ) { - flipscreen = state ? 0 : 1; + nyny_state *driver_state = (nyny_state *)device->machine->driver_data; + driver_state->flipscreen = state ? 0 : 1; } @@ -294,8 +298,8 @@ static MC6845_BEGIN_UPDATE( begin_update ) static MC6845_UPDATE_ROW( update_row ) { + nyny_state *state = (nyny_state *)device->machine->driver_data; UINT8 cx; - pen_t *pens = (pen_t *)param; UINT8 x = 0; @@ -310,30 +314,30 @@ static MC6845_UPDATE_ROW( update_row ) ((ra << 5) & 0x00e0) | ((ma << 0) & 0x001f); - if (flipscreen) + if (state->flipscreen) offs = offs ^ 0x9fff; - data1 = nyny_videoram_1[offs]; - data2 = nyny_videoram_2[offs]; - color1 = nyny_colorram_1[offs] & 0x07; - color2 = nyny_colorram_2[offs] & 0x07; + data1 = state->videoram1[offs]; + data2 = state->videoram2[offs]; + color1 = state->colorram1[offs] & 0x07; + color2 = state->colorram2[offs] & 0x07; for (i = 0; i < 8; i++) { UINT8 bit1, bit2, color; - if (flipscreen) + if (state->flipscreen) { - bit1 = data1 & 0x80; - bit2 = data2 & 0x80; + bit1 = BIT(data1, 7); + bit2 = BIT(data2, 7); data1 = data1 << 1; data2 = data2 << 1; } else { - bit1 = data1 & 0x01; - bit2 = data2 & 0x01; + bit1 = BIT(data1, 0); + bit2 = BIT(data2, 0); data1 = data1 >> 1; data2 = data2 >> 1; @@ -347,27 +351,30 @@ static MC6845_UPDATE_ROW( update_row ) *BITMAP_ADDR32(bitmap, y, x) = pens[color]; - x = x + 1; + x += 1; } - ma = ma + 1; + ma += 1; } } -INLINE void shift_star_generator(void) +INLINE void shift_star_generator( running_machine *machine ) { - star_shift_reg = (star_shift_reg << 1) | (((~star_shift_reg >> 15) & 0x01) ^ ((star_shift_reg >> 2) & 0x01)); + nyny_state *state = (nyny_state *)machine->driver_data; + state->star_shift_reg = (state->star_shift_reg << 1) | (((~state->star_shift_reg >> 15) & 0x01) ^ ((state->star_shift_reg >> 2) & 0x01)); } static MC6845_END_UPDATE( end_update ) { + nyny_state *state = (nyny_state *)device->machine->driver_data; + /* draw the star field into the bitmap */ int y; pen_t *pens = (pen_t *)param; - UINT16 delay_counter = star_delay_counter; + UINT16 delay_counter = state->star_delay_counter; for (y = cliprect->min_y; y <= cliprect->max_y; y++) { @@ -376,20 +383,20 @@ static MC6845_END_UPDATE( end_update ) for (x = cliprect->min_x; x <= cliprect->max_x; x++) { /* check if the star status */ - if (star_enable && + if (state->star_enable && (*BITMAP_ADDR32(bitmap, y, x) == 0) && - ((star_shift_reg & 0x80ff) == 0x00ff) && - (((y & 0x01) ^ flipscreen) ^ (((x & 0x08) >> 3) ^ flipscreen))) + ((state->star_shift_reg & 0x80ff) == 0x00ff) && + (((y & 0x01) ^ state->flipscreen) ^ (((x & 0x08) >> 3) ^ state->flipscreen))) { - UINT8 color = ((star_shift_reg & 0x0100) >> 8) | /* R */ - ((star_shift_reg & 0x0400) >> 9) | /* G */ - ((star_shift_reg & 0x1000) >> 10); /* B */ + UINT8 color = ((state->star_shift_reg & 0x0100) >> 8) | /* R */ + ((state->star_shift_reg & 0x0400) >> 9) | /* G */ + ((state->star_shift_reg & 0x1000) >> 10); /* B */ *BITMAP_ADDR32(bitmap, y, x) = pens[color]; } if (delay_counter == 0) - shift_star_generator(); + shift_star_generator(device->machine); else delay_counter = delay_counter - 1; } @@ -399,7 +406,8 @@ static MC6845_END_UPDATE( end_update ) static WRITE_LINE_DEVICE_HANDLER( display_enable_changed ) { - ttl74123_a_w(devtag_get_device(device->machine, "ic48_1"), 0, state); + nyny_state *driver_state = (nyny_state *)device->machine->driver_data; + ttl74123_a_w(driver_state->ic48_1, 0, state); } @@ -420,8 +428,9 @@ static const mc6845_interface mc6845_intf = static VIDEO_UPDATE( nyny ) { - running_device *mc6845 = devtag_get_device(screen->machine, "crtc"); - mc6845_update(mc6845, bitmap, cliprect); + nyny_state *state = (nyny_state *)screen->machine->driver_data; + + mc6845_update(state->mc6845, bitmap, cliprect); return 0; } @@ -436,15 +445,19 @@ static VIDEO_UPDATE( nyny ) static WRITE8_HANDLER( audio_1_command_w ) { + nyny_state *state = (nyny_state *)space->machine->driver_data; + soundlatch_w(space, 0, data); - cputag_set_input_line(space->machine, "audiocpu", M6800_IRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->audiocpu, M6800_IRQ_LINE, HOLD_LINE); } static WRITE8_HANDLER( audio_1_answer_w ) { + nyny_state *state = (nyny_state *)space->machine->driver_data; + soundlatch3_w(space, 0, data); - cputag_set_input_line(space->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->maincpu, M6809_IRQ_LINE, HOLD_LINE); } @@ -487,8 +500,10 @@ static const ay8910_interface ay8910_64_interface = static WRITE8_HANDLER( audio_2_command_w ) { + nyny_state *state = (nyny_state *)space->machine->driver_data; + soundlatch2_w(space, 0, (data & 0x60) >> 5); - cputag_set_input_line(space->machine, "audio2", M6800_IRQ_LINE, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE); + cpu_set_input_line(state->audiocpu2, M6800_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE); } @@ -501,13 +516,12 @@ static WRITE8_HANDLER( audio_2_command_w ) static READ8_HANDLER( nyny_pia_1_2_r ) { - running_device *pia1 = devtag_get_device(space->machine, "pia1"); - running_device *pia2 = devtag_get_device(space->machine, "pia2"); + nyny_state *state = (nyny_state *)space->machine->driver_data; UINT8 ret = 0; /* the address bits are directly connected to the chip selects */ - if (offset & 0x04) ret = pia6821_r(pia1, offset & 0x03); - if (offset & 0x08) ret = pia6821_alt_r(pia2, offset & 0x03); + if (BIT(offset, 2)) ret = pia6821_r(state->pia1, offset & 0x03); + if (BIT(offset, 3)) ret = pia6821_alt_r(state->pia2, offset & 0x03); return ret; } @@ -515,20 +529,19 @@ static READ8_HANDLER( nyny_pia_1_2_r ) static WRITE8_HANDLER( nyny_pia_1_2_w ) { - running_device *pia1 = devtag_get_device(space->machine, "pia1"); - running_device *pia2 = devtag_get_device(space->machine, "pia2"); + nyny_state *state = (nyny_state *)space->machine->driver_data; /* the address bits are directly connected to the chip selects */ - if (offset & 0x04) pia6821_w(pia1, offset & 0x03, data); - if (offset & 0x08) pia6821_alt_w(pia2, offset & 0x03, data); + if (BIT(offset, 2)) pia6821_w(state->pia1, offset & 0x03, data); + if (BIT(offset, 3)) pia6821_alt_w(state->pia2, offset & 0x03, data); } static ADDRESS_MAP_START( nyny_main_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&nyny_videoram_1) - AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&nyny_colorram_1) - AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&nyny_videoram_2) - AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&nyny_colorram_2) + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram1) + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram1) + AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram2) + AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram2) AM_RANGE(0x8000, 0x9fff) AM_RAM AM_RANGE(0xa000, 0xa0ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) /* SRAM (coin counter, shown when holding F2) */ AM_RANGE(0xa100, 0xa100) AM_MIRROR(0x00fe) AM_DEVWRITE("crtc", mc6845_address_w) @@ -587,16 +600,16 @@ static INPUT_PORTS_START( nyny ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL /* PIA0 PA4 */ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 ) /* PIA0 PA5 */ PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) /* PIA0 PA6 */ - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("IN1") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB0 */ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB1 */ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY /* PIA0 PB2 */ PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY /* PIA0 PB3 */ - PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_START("SW1") /* port 2 */ + PORT_START("SW1") PORT_DIPNAME( 0x03, 0x03, "Bombs from UFO (Screens 3+)" ) PORT_DIPLOCATION("SW1:1,2") PORT_DIPSETTING( 0x01, "3" ) PORT_DIPSETTING( 0x00, "6" ) @@ -609,7 +622,7 @@ static INPUT_PORTS_START( nyny ) PORT_DIPSETTING( 0x00, DEF_STR( Low ) ) PORT_DIPSETTING( 0x80, DEF_STR( High ) ) - PORT_START("SW2") /* port 3 */ + PORT_START("SW2") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW2:1,2") PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) @@ -627,7 +640,7 @@ static INPUT_PORTS_START( nyny ) PORT_DIPSETTING( 0x00, DEF_STR( No ) ) PORT_DIPSETTING( 0x80, DEF_STR( Yes ) ) - PORT_START("SW3") /* port 4 */ + PORT_START("SW3") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:1") PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) @@ -651,13 +664,48 @@ static INPUT_PORTS_START( nyny ) PORT_DIPSETTING( 0x40, "+2" ) PORT_DIPSETTING( 0x20, "+3" ) - PORT_START("CROSS") /* connected to PIA1 CB1 input */ - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1) + PORT_START("CROSS") /* connected to PIA1 CB1 input */ + PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1) INPUT_PORTS_END +/************************************* + * + * Machine start & reset + * + *************************************/ + +static MACHINE_START( nyny ) +{ + nyny_state *state = (nyny_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->audiocpu2 = devtag_get_device(machine, "audio2"); + state->ic48_1 = devtag_get_device(machine, "ic48_1"); + state->mc6845 = devtag_get_device(machine, "crtc"); + state->pia1 = devtag_get_device(machine, "pia1"); + state->pia2 = devtag_get_device(machine, "pia2"); + + /* setup for save states */ + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->star_enable); + state_save_register_global(machine, state->star_delay_counter); + state_save_register_global(machine, state->star_shift_reg); +} + +static MACHINE_RESET( nyny ) +{ + nyny_state *state = (nyny_state *)machine->driver_data; + + state->flipscreen = 0; + state->star_enable = 0; + state->star_delay_counter = 0; + state->star_shift_reg = 0; +} + /************************************* * * Machine driver @@ -666,6 +714,9 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( nyny ) + /* driver data */ + MDRV_DRIVER_DATA(nyny_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6809, 1400000) /* 1.40 MHz? The clock signal is generated by analog chips */ MDRV_CPU_PROGRAM_MAP(nyny_main_map) @@ -678,6 +729,7 @@ static MACHINE_DRIVER_START( nyny ) MDRV_CPU_PROGRAM_MAP(nyny_audio_2_map) MDRV_MACHINE_START(nyny) + MDRV_MACHINE_RESET(nyny) MDRV_NVRAM_HANDLER(generic_0fill) /* video hardware */ diff --git a/src/mame/drivers/oneshot.c b/src/mame/drivers/oneshot.c index cb8d5a8274b..80da17e313e 100644 --- a/src/mame/drivers/oneshot.c +++ b/src/mame/drivers/oneshot.c @@ -32,37 +32,28 @@ TO DO : #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" +#include "includes/oneshot.h" #include "sound/okim6295.h" #include "sound/3812intf.h" -#include "includes/oneshot.h" - - -UINT16 *oneshot_sprites; -UINT16 *oneshot_bg_videoram; -UINT16 *oneshot_mid_videoram; -UINT16 *oneshot_fg_videoram; -UINT16 *oneshot_scroll; - -int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2; -int gun_x_shift; static READ16_HANDLER( oneshot_in0_word_r ) { + oneshot_state *state = (oneshot_state *)space->machine->driver_data; int data = input_port_read(space->machine, "DSW1"); switch (data & 0x0c) { case 0x00 : - gun_x_shift = 35; + state->gun_x_shift = 35; break; case 0x04 : - gun_x_shift = 30; + state->gun_x_shift = 30; break; case 0x08 : - gun_x_shift = 40; + state->gun_x_shift = 40; break; case 0x0c : - gun_x_shift = 50; + state->gun_x_shift = 50; break; } @@ -71,30 +62,34 @@ static READ16_HANDLER( oneshot_in0_word_r ) static READ16_HANDLER( oneshot_gun_x_p1_r ) { - /* shots must be in a different location to register */ - static int wobble = 0; - wobble ^= 1; + oneshot_state *state = (oneshot_state *)space->machine->driver_data; - return gun_x_p1 ^ wobble; + /* shots must be in a different location to register */ + state->p1_wobble ^= 1; + + return state->gun_x_p1 ^ state->p1_wobble; } static READ16_HANDLER( oneshot_gun_y_p1_r ) { - return gun_y_p1; + oneshot_state *state = (oneshot_state *)space->machine->driver_data; + return state->gun_y_p1; } static READ16_HANDLER( oneshot_gun_x_p2_r ) { - /* shots must be in a different location to register */ - static int wobble = 0; - wobble ^= 1; + oneshot_state *state = (oneshot_state *)space->machine->driver_data; - return gun_x_p2 ^ wobble; + /* shots must be in a different location to register */ + state->p2_wobble ^= 1; + + return state->gun_x_p2 ^ state->p2_wobble; } static READ16_HANDLER( oneshot_gun_y_p2_r ) { - return gun_y_p2; + oneshot_state *state = (oneshot_state *)space->machine->driver_data; + return state->gun_y_p2; } static WRITE16_DEVICE_HANDLER( soundbank_w ) @@ -111,11 +106,11 @@ static ADDRESS_MAP_START( oneshot_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x080000, 0x087fff) AM_RAM AM_RANGE(0x0c0000, 0x0c07ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE(&oneshot_sprites) - AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE(&oneshot_mid_videoram) // some people , girl etc. - AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE(&oneshot_fg_videoram) // credits etc. - AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE(&oneshot_bg_videoram) // credits etc. - AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE(&oneshot_scroll) // scroll registers + AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE_MEMBER(oneshot_state, sprites) + AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE_MEMBER(oneshot_state, mid_videoram) // some people , girl etc. + AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE_MEMBER(oneshot_state, fg_videoram) // credits etc. + AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE_MEMBER(oneshot_state, bg_videoram) // credits etc. + AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE_MEMBER(oneshot_state, scroll) // scroll registers AM_RANGE(0x190002, 0x190003) AM_READ(soundlatch_word_r) AM_RANGE(0x190010, 0x190011) AM_WRITE(soundlatch_word_w) AM_RANGE(0x190018, 0x190019) AM_DEVWRITE("oki", soundbank_w) @@ -140,7 +135,7 @@ ADDRESS_MAP_END static INPUT_PORTS_START( oneshot ) - PORT_START("DSW1") /* DSW 1 (0x19c020.l -> 0x08006c.l) */ + PORT_START("DSW1") /* 0x19c020.l -> 0x08006c.l */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) // 0x080084.l : credits (00-09) PORT_DIPSETTING( 0x03, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) @@ -162,7 +157,7 @@ static INPUT_PORTS_START( oneshot ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) - PORT_START("DSW2") /* DSW 2 (0x19c024.l -> 0x08006e.l) */ + PORT_START("DSW2") /* 0x19c024.l -> 0x08006e.l */ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) // 0x082500.l PORT_DIPSETTING( 0x01, "1" ) PORT_DIPSETTING( 0x02, "2" ) @@ -182,7 +177,7 @@ static INPUT_PORTS_START( oneshot ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) - PORT_START("CREDITS") /* Credits (0x19c02c.l -> 0x08007a.l) */ + PORT_START("CREDITS") /* 0x19c02c.l -> 0x08007a.l */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN ) @@ -227,7 +222,7 @@ static INPUT_PORTS_START( oneshot ) INPUT_PORTS_END static INPUT_PORTS_START( maddonna ) - PORT_START("DSW1") /* DSW A */ + PORT_START("DSW1") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) @@ -250,7 +245,7 @@ static INPUT_PORTS_START( maddonna ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_SERVICE( 0x80, IP_ACTIVE_HIGH ) - PORT_START("DSW2") /* DSW B */ + PORT_START("DSW2") PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) // 2 Monsters at start, but "dumber"?? PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) // 2 Monsters at start @@ -273,7 +268,7 @@ static INPUT_PORTS_START( maddonna ) PORT_DIPSETTING( 0x80, "On - 01" ) PORT_DIPSETTING( 0xc0, "On - 11" ) - PORT_START("CREDITS") /* Credits */ + PORT_START("CREDITS") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN ) @@ -283,7 +278,7 @@ static INPUT_PORTS_START( maddonna ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_START("P1") /* Player 1 */ + PORT_START("P1") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) @@ -293,7 +288,7 @@ static INPUT_PORTS_START( maddonna ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_START("P2") /* Player 1 */ + PORT_START("P2") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) @@ -337,7 +332,8 @@ GFXDECODE_END static void irq_handler(running_device *device, int irq) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + oneshot_state *state = (oneshot_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym3812_interface ym3812_config = @@ -345,8 +341,40 @@ static const ym3812_interface ym3812_config = irq_handler }; +static MACHINE_START( oneshot ) +{ + oneshot_state *state = (oneshot_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + + state_save_register_global(machine, state->gun_x_p1); + state_save_register_global(machine, state->gun_y_p1); + state_save_register_global(machine, state->gun_x_p2); + state_save_register_global(machine, state->gun_y_p2); + state_save_register_global(machine, state->gun_x_shift); + state_save_register_global(machine, state->p1_wobble); + state_save_register_global(machine, state->p2_wobble); +} + +static MACHINE_RESET( oneshot ) +{ + oneshot_state *state = (oneshot_state *)machine->driver_data; + + state->gun_x_p1 = 0; + state->gun_y_p1 = 0; + state->gun_x_p2 = 0; + state->gun_y_p2 = 0; + state->gun_x_shift = 0; + state->p1_wobble = 0; + state->p2_wobble = 0; +} + static MACHINE_DRIVER_START( oneshot ) + /* driver data */ + MDRV_DRIVER_DATA(oneshot_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 12000000) MDRV_CPU_PROGRAM_MAP(oneshot_map) @@ -355,7 +383,8 @@ static MACHINE_DRIVER_START( oneshot ) MDRV_CPU_ADD("audiocpu", Z80, 5000000) MDRV_CPU_PROGRAM_MAP(oneshot_sound_map) - MDRV_GFXDECODE(oneshot) + MDRV_MACHINE_START(oneshot) + MDRV_MACHINE_RESET(oneshot) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -365,6 +394,7 @@ static MACHINE_DRIVER_START( oneshot ) MDRV_SCREEN_SIZE(32*16, 32*16) MDRV_SCREEN_VISIBLE_AREA(0*16, 20*16-1, 0*16, 15*16-1) + MDRV_GFXDECODE(oneshot) MDRV_PALETTE_LENGTH(0x400) MDRV_VIDEO_START(oneshot) @@ -470,8 +500,6 @@ ROM_END - - -GAME( 199?, oneshot, 0, oneshot, oneshot , 0, ROT0, "", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS ) -GAME( 1995, maddonna, 0, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 1)", 0 ) -GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 2)", GAME_NOT_WORKING ) +GAME( 199?, oneshot, 0, oneshot, oneshot , 0, ROT0, "", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) +GAME( 1995, maddonna, 0, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 1)", GAME_SUPPORTS_SAVE ) +GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 2)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/onetwo.c b/src/mame/drivers/onetwo.c index 0f3bab1d845..d34d939c812 100644 --- a/src/mame/drivers/onetwo.c +++ b/src/mame/drivers/onetwo.c @@ -44,76 +44,129 @@ Note: this is quite clearly a 'Korean bootleg' of Shisensho - Joshiryo-Hen / Mat #include "sound/okim6295.h" #include "sound/3812intf.h" -static tilemap_t *fg_tilemap; -static UINT8 *fgram; +#define MASTER_CLOCK XTAL_4MHz -#define MASTER_CLOCK (XTAL_4MHz) +class onetwo_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, onetwo_state(machine)); } + + onetwo_state(running_machine &machine) { } + + /* memory pointers */ + UINT8 * fgram; + UINT8 * paletteram; + UINT8 * paletteram2; + + /* video-related */ + tilemap_t *fg_tilemap; + + /* devices */ + running_device *maincpu; + running_device *audiocpu; +}; + + + +/************************************* + * + * Video emulation + * + *************************************/ static TILE_GET_INFO( get_fg_tile_info ) { - int code = (fgram[tile_index*2+1]<<8) | fgram[tile_index*2]; - int color = (fgram[tile_index*2+1] & 0x80) >> 7; + onetwo_state *state = (onetwo_state *)machine->driver_data; + int code = (state->fgram[tile_index * 2 + 1] << 8) | state->fgram[tile_index * 2]; + int color = (state->fgram[tile_index * 2 + 1] & 0x80) >> 7; code &= 0x7fff; SET_TILE_INFO(0, code, color, 0); } +static VIDEO_START( onetwo ) +{ + onetwo_state *state = (onetwo_state *)machine->driver_data; + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); +} + +static VIDEO_UPDATE( onetwo ) +{ + onetwo_state *state = (onetwo_state *)screen->machine->driver_data; + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); + return 0; +} + +/************************************* + * + * Memory handlers + * + *************************************/ + static WRITE8_HANDLER( onetwo_fgram_w ) { - fgram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap, offset / 2); + onetwo_state *state = (onetwo_state *)space->machine->driver_data; + state->fgram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2); } static WRITE8_HANDLER( onetwo_cpubank_w ) { - UINT8 *RAM = memory_region(space->machine, "maincpu") + 0x10000; - - memory_set_bankptr(space->machine, "bank1", &RAM[data * 0x4000]); + memory_set_bank(space->machine, "bank1", data); } static WRITE8_HANDLER( onetwo_coin_counters_w ) { watchdog_reset(space->machine); - coin_counter_w(space->machine, 0, data & 0x02); - coin_counter_w(space->machine, 1, data & 0x04); + coin_counter_w(space->machine, 0, BIT(data, 1)); + coin_counter_w(space->machine, 1, BIT(data, 2)); } static WRITE8_HANDLER( onetwo_soundlatch_w ) { + onetwo_state *state = (onetwo_state *)space->machine->driver_data; soundlatch_w(space, 0, data); - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE); } -static void setColor(running_machine *machine, int offset) +static void set_color(running_machine *machine, int offset) { - int r, g, b; - r = machine->generic.paletteram.u8[offset] & 0x1f; - g = machine->generic.paletteram2.u8[offset] & 0x1f; - b = ((machine->generic.paletteram.u8[offset] & 0x60) >> 2) | ((machine->generic.paletteram2.u8[offset] & 0xe0) >> 5); - palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b)); + onetwo_state *state = (onetwo_state *)machine->driver_data; + int r, g, b; + + r = state->paletteram[offset] & 0x1f; + g = state->paletteram2[offset] & 0x1f; + b = ((state->paletteram[offset] & 0x60) >> 2) | ((state->paletteram2[offset] & 0xe0) >> 5); + palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b)); } static WRITE8_HANDLER(palette1_w) { - space->machine->generic.paletteram.u8[offset] = data; - setColor(space->machine, offset); + onetwo_state *state = (onetwo_state *)space->machine->driver_data; + state->paletteram[offset] = data; + set_color(space->machine, offset); } static WRITE8_HANDLER(palette2_w) { - space->machine->generic.paletteram2.u8[offset] = data; - setColor(space->machine, offset); + onetwo_state *state = (onetwo_state *)space->machine->driver_data; + state->paletteram2[offset] = data; + set_color(space->machine, offset); } -/* Main CPU */ +/************************************* + * + * Address maps + * + *************************************/ static ADDRESS_MAP_START( main_cpu, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION("maincpu", 0x10000) AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") - AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_GENERIC(paletteram2) - AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE(&fgram) + AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_MEMBER(onetwo_state, paletteram) + AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_MEMBER(onetwo_state, paletteram2) + AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE_MEMBER(onetwo_state, fgram) AM_RANGE(0xe000, 0xffff) AM_RAM ADDRESS_MAP_END @@ -126,8 +179,6 @@ static ADDRESS_MAP_START( main_cpu_io, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x04, 0x04) AM_READ_PORT("SYSTEM") ADDRESS_MAP_END -/* Sound CPU */ - static ADDRESS_MAP_START( sound_cpu, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0xf000, 0xf7ff) AM_RAM @@ -142,6 +193,12 @@ static ADDRESS_MAP_START( sound_cpu_io, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0xc0, 0xc0) AM_WRITE(soundlatch_clear_w) ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( onetwo ) PORT_START("DSW1") PORT_DIPNAME( 0x03, 0x03, "Timer" ) PORT_DIPLOCATION("SW1:1,2") @@ -240,6 +297,12 @@ static INPUT_PORTS_START( onetwo ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout tiles8x8x6_layout = { 8,8, @@ -255,20 +318,16 @@ static GFXDECODE_START( onetwo ) GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x6_layout, 0, 2 ) GFXDECODE_END -static VIDEO_START( onetwo ) -{ - fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); -} - -static VIDEO_UPDATE( onetwo ) -{ - tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0); - return 0; -} +/************************************* + * + * Sound interface + * + *************************************/ static void irqhandler(running_device *device, int linestate) { - cputag_set_input_line(device->machine, "audiocpu", 0, linestate); + onetwo_state *state = (onetwo_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, linestate); } static const ym3812_interface ym3812_config = @@ -276,7 +335,28 @@ static const ym3812_interface ym3812_config = irqhandler /* IRQ Line */ }; +/************************************* + * + * Machine driver + * + *************************************/ + +static MACHINE_START( onetwo ) +{ + onetwo_state *state = (onetwo_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); +} + static MACHINE_DRIVER_START( onetwo ) + + /* driver data */ + MDRV_DRIVER_DATA(onetwo_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK) /* 4 MHz */ MDRV_CPU_PROGRAM_MAP(main_cpu) @@ -287,6 +367,8 @@ static MACHINE_DRIVER_START( onetwo ) MDRV_CPU_PROGRAM_MAP(sound_cpu) MDRV_CPU_IO_MAP(sound_cpu_io) + MDRV_MACHINE_START(onetwo) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -313,6 +395,12 @@ static MACHINE_DRIVER_START( onetwo ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END +/************************************* + * + * ROM definition(s) + * + *************************************/ + ROM_START( onetwo ) ROM_REGION( 0x30000, "maincpu", 0 ) /* main z80 */ ROM_LOAD( "maincpu", 0x10000, 0x20000, CRC(83431e6e) SHA1(61ab386a1d0af050f091f5df28c55ad5ad1a0d4b) ) @@ -345,5 +433,11 @@ ROM_START( onetwoe ) ROM_LOAD( "sample", 0x000000, 0x40000, CRC(b10d3132) SHA1(42613e17b6a1300063b8355596a2dc7bcd903777) ) ROM_END -GAME( 1997, onetwo, 0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", 0 ) -GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", 0 ) +/************************************* + * + * Game driver(s) + * + *************************************/ + +GAME( 1997, onetwo, 0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", GAME_SUPPORTS_SAVE ) +GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/orbit.c b/src/mame/drivers/orbit.c index 426759d8df3..3ae149cda64 100644 --- a/src/mame/drivers/orbit.c +++ b/src/mame/drivers/orbit.c @@ -25,11 +25,6 @@ Atari Orbit Driver #define MASTER_CLOCK XTAL_12_096MHz - -static UINT8 orbit_misc_flags; - - - /************************************* * * Interrupts and timing @@ -38,15 +33,17 @@ static UINT8 orbit_misc_flags; static TIMER_DEVICE_CALLBACK( nmi_32v ) { + orbit_state *state = (orbit_state *)timer->machine->driver_data; int scanline = param; - int nmistate = (scanline & 32) && (orbit_misc_flags & 4); - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE); + int nmistate = (scanline & 32) && (state->misc_flags & 4); + cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE); } static TIMER_CALLBACK( irq_off ) { - cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); + orbit_state *state = (orbit_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 0, CLEAR_LINE); } @@ -66,9 +63,9 @@ static INTERRUPT_GEN( orbit_interrupt ) static void update_misc_flags(running_machine *machine, UINT8 val) { - running_device *discrete = devtag_get_device(machine, "discrete"); + orbit_state *state = (orbit_state *)machine->driver_data; - orbit_misc_flags = val; + state->misc_flags = val; /* BIT0 => UNUSED */ /* BIT1 => LOCKOUT */ @@ -79,37 +76,25 @@ static void update_misc_flags(running_machine *machine, UINT8 val) /* BIT6 => HYPER LED */ /* BIT7 => WARNING SND */ - discrete_sound_w(discrete, ORBIT_WARNING_EN, orbit_misc_flags & 0x80); + discrete_sound_w(state->discrete, ORBIT_WARNING_EN, BIT(state->misc_flags, 7)); - set_led_status(machine, 0, orbit_misc_flags & 0x08); - set_led_status(machine, 1, orbit_misc_flags & 0x40); + set_led_status(machine, 0, BIT(state->misc_flags, 3)); + set_led_status(machine, 1, BIT(state->misc_flags, 6)); - coin_lockout_w(machine, 0, !(orbit_misc_flags & 0x02)); - coin_lockout_w(machine, 1, !(orbit_misc_flags & 0x02)); + coin_lockout_w(machine, 0, !BIT(state->misc_flags, 1)); + coin_lockout_w(machine, 1, !BIT(state->misc_flags, 1)); } static WRITE8_HANDLER( orbit_misc_w ) { + orbit_state *state = (orbit_state *)space->machine->driver_data; UINT8 bit = offset >> 1; if (offset & 1) - update_misc_flags(space->machine, orbit_misc_flags | (1 << bit)); + update_misc_flags(space->machine, state->misc_flags | (1 << bit)); else - update_misc_flags(space->machine, orbit_misc_flags & ~(1 << bit)); -} - - - -/************************************* - * - * Machine setup - * - *************************************/ - -static MACHINE_RESET( orbit ) -{ - update_misc_flags(machine, 0); + update_misc_flags(space->machine, state->misc_flags & ~(1 << bit)); } @@ -128,8 +113,8 @@ static ADDRESS_MAP_START( orbit_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x1800, 0x1800) AM_MIRROR(0x07ff) AM_READ_PORT("DSW1") AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x07ff) AM_READ_PORT("DSW2") AM_RANGE(0x2800, 0x2800) AM_MIRROR(0x07ff) AM_READ_PORT("BUTTONS") - AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE(&orbit_playfield_ram) - AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&orbit_sprite_ram) + AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE_MEMBER(orbit_state, playfield_ram) + AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(orbit_state, sprite_ram) AM_RANGE(0x3800, 0x3800) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_w) AM_RANGE(0x3900, 0x3900) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_noise_amp_w) AM_RANGE(0x3a00, 0x3a00) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_amp_w) @@ -281,6 +266,32 @@ GFXDECODE_END +/************************************* + * + * Machine setup + * + *************************************/ + +static MACHINE_START( orbit ) +{ + orbit_state *state = (orbit_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->discrete = devtag_get_device(machine, "discrete"); + + state_save_register_global(machine, state->misc_flags); + state_save_register_global(machine, state->flip_screen); +} + +static MACHINE_RESET( orbit ) +{ + orbit_state *state = (orbit_state *)machine->driver_data; + + update_misc_flags(machine, 0); + state->flip_screen = 0; +} + + /************************************* * * Machine drivers @@ -289,6 +300,9 @@ GFXDECODE_END static MACHINE_DRIVER_START( orbit ) + /* driver data */ + MDRV_DRIVER_DATA(orbit_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6800, MASTER_CLOCK / 16) MDRV_CPU_PROGRAM_MAP(orbit_map) @@ -296,6 +310,7 @@ static MACHINE_DRIVER_START( orbit ) MDRV_TIMER_ADD_SCANLINE("32v", nmi_32v, "screen", 0, 32) + MDRV_MACHINE_START(orbit) MDRV_MACHINE_RESET(orbit) /* video hardware */ @@ -362,4 +377,4 @@ ROM_END * *************************************/ -GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", 0 ) +GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/othello.c b/src/mame/drivers/othello.c index 24811126b4b..9da793b9525 100644 --- a/src/mame/drivers/othello.c +++ b/src/mame/drivers/othello.c @@ -37,42 +37,64 @@ Limit for help/undo (matta): #include "emu.h" #include "cpu/z80/z80.h" +#include "cpu/mcs48/mcs48.h" +#include "machine/i8243.h" +#include "sound/dac.h" #include "sound/ay8910.h" #include "video/mc6845.h" -#include "machine/i8243.h" -#include "cpu/mcs48/mcs48.h" -#include "sound/dac.h" -static int ay_select=0; -static int ack_data=0; - -static UINT8 n7751_command; -//static UINT32 n7751_rom_address; - -static int tile_bank=0; - -static int sound_addr; -static int n7751_busy; #define TILE_WIDTH 6 + +class othello_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othello_state(machine)); } + + othello_state(running_machine &machine) { } + + /* memory pointers */ + UINT8 * videoram; + + /* video-related */ + int tile_bank; + + /* misc */ + int ay_select; + int ack_data; + UINT8 n7751_command; +// UINT32 n7751_rom_address; + int sound_addr; + int n7751_busy; + + /* devices */ + running_device *maincpu; + running_device *mc6845; + running_device *n7751; + running_device *ay1; + running_device *ay2; +}; + + static MC6845_UPDATE_ROW( update_row ) { - int cx,x; + othello_state *state = (othello_state *)device->machine->driver_data; + int cx, x; UINT32 data_address; UINT32 tmp; const UINT8 *gfx = memory_region(device->machine, "gfx"); - for(cx=0;cxmachine->generic.videoram.u8[ma+cx]+tile_bank)<<4)|ra; - tmp=gfx[data_address]|(gfx[data_address+0x2000]<<8)|(gfx[data_address+0x4000]<<16); + data_address = ((state->videoram[ma + cx] + state->tile_bank) << 4) | ra; + tmp = gfx[data_address] | (gfx[data_address + 0x2000] << 8) | (gfx[data_address + 0x4000] << 16); - for(x=0;x>=4; + *BITMAP_ADDR16(bitmap, y, (cx * TILE_WIDTH + x) ^ 1) = tmp & 0x0f; + tmp >>= 4; } } } @@ -80,32 +102,33 @@ static MC6845_UPDATE_ROW( update_row ) static PALETTE_INIT( othello ) { int i; - for (i = 0;i < machine->config->total_colors;i++) - { - palette_set_color(machine,i,MAKE_RGB(0xff,0x00,0xff)); - } + for (i = 0; i < machine->config->total_colors; i++) + { + palette_set_color(machine, i, MAKE_RGB(0xff, 0x00, 0xff)); + } - /* only colors 2,3,7,9,c,d,f are used */ - palette_set_color(machine,0x02,MAKE_RGB(0x00,0xff,0x00)); - palette_set_color(machine,0x03,MAKE_RGB(0xff,0x7f,0x00)); - palette_set_color(machine,0x07,MAKE_RGB(0x00,0x00,0x00)); - palette_set_color(machine,0x09,MAKE_RGB(0xff,0x00,0x00)); - palette_set_color(machine,0x0c,MAKE_RGB(0x00,0x00,0xff)); - palette_set_color(machine,0x0d,MAKE_RGB(0x7f,0x7f,0x00)); - palette_set_color(machine,0x0f,MAKE_RGB(0xff,0xff,0xff)); + /* only colors 2,3,7,9,c,d,f are used */ + palette_set_color(machine, 0x02, MAKE_RGB(0x00, 0xff, 0x00)); + palette_set_color(machine, 0x03, MAKE_RGB(0xff, 0x7f, 0x00)); + palette_set_color(machine, 0x07, MAKE_RGB(0x00, 0x00, 0x00)); + palette_set_color(machine, 0x09, MAKE_RGB(0xff, 0x00, 0x00)); + palette_set_color(machine, 0x0c, MAKE_RGB(0x00, 0x00, 0xff)); + palette_set_color(machine, 0x0d, MAKE_RGB(0x7f, 0x7f, 0x00)); + palette_set_color(machine, 0x0f, MAKE_RGB(0xff, 0xff, 0xff)); } static VIDEO_UPDATE( othello ) { - running_device *mc6845 = devtag_get_device(screen->machine, "crtc"); - mc6845_update(mc6845, bitmap, cliprect); + othello_state *state = (othello_state *)screen->machine->driver_data; + + mc6845_update(state->mc6845, bitmap, cliprect); return 0; } static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_ROM AM_RANGE(0x8000, 0x97ff) AM_NOP /* not populated */ - AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_GENERIC(videoram) + AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_MEMBER(othello_state, videoram) AM_RANGE(0xf000, 0xffff) AM_RAM ADDRESS_MAP_END @@ -115,21 +138,23 @@ static READ8_HANDLER( unk_87_r ) return mame_rand(space->machine); } -static WRITE8_HANDLER(unk_8a_w) +static WRITE8_HANDLER( unk_8a_w ) { /* - n7751_command = (data & 0x07); - cputag_set_input_line(space->machine, "n7751", 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE); - //cputag_set_input_line(device->machine, "n7751", 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE); + othello_state *state = (othello_state *)space->machine->driver_data; + + state->n7751_command = (data & 0x07); + cpu_set_input_line(state->n7751, 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE); + //cpu_set_input_line(state->n7751, 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE); cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(100)); */ - logerror("8a -> %x\n",data); + logerror("8a -> %x\n", data); } -static WRITE8_HANDLER(unk_8c_w) +static WRITE8_HANDLER( unk_8c_w ) { - logerror("8c -> %x\n",data); + logerror("8c -> %x\n", data); } static READ8_HANDLER( unk_8c_r ) @@ -137,20 +162,22 @@ static READ8_HANDLER( unk_8c_r ) return mame_rand(space->machine); } -static READ8_HANDLER(sound_ack_r) +static READ8_HANDLER( sound_ack_r ) { - return ack_data; + othello_state *state = (othello_state *)space->machine->driver_data; + return state->ack_data; } -static WRITE8_HANDLER(unk_8f_w) +static WRITE8_HANDLER( unk_8f_w ) { - logerror("8f -> %x\n",data); + logerror("8f -> %x\n", data); } -static WRITE8_HANDLER(tilebank_w) +static WRITE8_HANDLER( tilebank_w ) { - tile_bank=data==0x0f?0x100:0x00; - logerror("tilebank -> %x\n",data); + othello_state *state = (othello_state *)space->machine->driver_data; + state->tile_bank = (data == 0x0f) ? 0x100 : 0x00; + logerror("tilebank -> %x\n", data); } static ADDRESS_MAP_START( main_portmap, ADDRESS_SPACE_IO, 8 ) @@ -168,34 +195,39 @@ static ADDRESS_MAP_START( main_portmap, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x8f, 0x8f) AM_WRITE(unk_8f_w) ADDRESS_MAP_END -static READ8_HANDLER(latch_r) +static READ8_HANDLER( latch_r ) { - int retval=soundlatch_r(space,0); - soundlatch_clear_w(space,0,0); + int retval = soundlatch_r(space, 0); + soundlatch_clear_w(space, 0, 0); return retval; } -static WRITE8_HANDLER(ay_select_w) +static WRITE8_HANDLER( ay_select_w ) { - ay_select=data; + othello_state *state = (othello_state *)space->machine->driver_data; + state->ay_select = data; } -static WRITE8_HANDLER(ack_w) +static WRITE8_HANDLER( ack_w ) { - ack_data=data; + othello_state *state = (othello_state *)space->machine->driver_data; + state->ack_data = data; } -static WRITE8_HANDLER(ay_address_w) +static WRITE8_HANDLER( ay_address_w ) { - if(ay_select&1) ay8910_address_w(devtag_get_device(space->machine, "ay1"),0,data); - if(ay_select&2) ay8910_address_w(devtag_get_device(space->machine, "ay2"),0,data); + othello_state *state = (othello_state *)space->machine->driver_data; + + if (state->ay_select & 1) ay8910_address_w(state->ay1, 0, data); + if (state->ay_select & 2) ay8910_address_w(state->ay2, 0, data); } -static WRITE8_HANDLER(ay_data_w) +static WRITE8_HANDLER( ay_data_w ) { - if(ay_select&1) ay8910_data_w(devtag_get_device(space->machine, "ay1"),0,data); - if(ay_select&2) ay8910_data_w(devtag_get_device(space->machine, "ay2"),0,data); + othello_state *state = (othello_state *)space->machine->driver_data; + if (state->ay_select & 1) ay8910_data_w(state->ay1, 0, data); + if (state->ay_select & 2) ay8910_data_w(state->ay2, 0, data); } static ADDRESS_MAP_START( audio_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -214,6 +246,8 @@ ADDRESS_MAP_END static WRITE8_DEVICE_HANDLER( n7751_rom_control_w ) { + othello_state *state = (othello_state *)device->machine->driver_data; + /* P4 - address lines 0-3 */ /* P5 - address lines 4-7 */ /* P6 - address lines 8-11 */ @@ -221,25 +255,25 @@ static WRITE8_DEVICE_HANDLER( n7751_rom_control_w ) switch (offset) { case 0: - sound_addr = (sound_addr & ~0x00f) | ((data & 0x0f) << 0); + state->sound_addr = (state->sound_addr & ~0x00f) | ((data & 0x0f) << 0); break; case 1: - sound_addr = (sound_addr & ~0x0f0) | ((data & 0x0f) << 4); + state->sound_addr = (state->sound_addr & ~0x0f0) | ((data & 0x0f) << 4); break; case 2: - sound_addr = (sound_addr & ~0xf00) | ((data & 0x0f) << 8); + state->sound_addr = (state->sound_addr & ~0xf00) | ((data & 0x0f) << 8); break; case 3: - sound_addr &= 0xfff; + state->sound_addr &= 0xfff; { - if (!(data & 0x01) ) sound_addr |= 0x0000; - if (!(data & 0x02) ) sound_addr |= 0x1000; - if (!(data & 0x04) ) sound_addr |= 0x2000; - if (!(data & 0x08) ) sound_addr |= 0x3000; + if (!BIT(data, 0)) state->sound_addr |= 0x0000; + if (!BIT(data, 1)) state->sound_addr |= 0x1000; + if (!BIT(data, 2)) state->sound_addr |= 0x2000; + if (!BIT(data, 3)) state->sound_addr |= 0x3000; } break; } @@ -247,22 +281,26 @@ static WRITE8_DEVICE_HANDLER( n7751_rom_control_w ) static READ8_HANDLER( n7751_rom_r ) { - return memory_region(space->machine, "n7751data")[sound_addr]; + othello_state *state = (othello_state *)space->machine->driver_data; + return memory_region(space->machine, "n7751data")[state->sound_addr]; } static READ8_HANDLER( n7751_command_r ) { - return 0x80 | ((n7751_command & 0x07) << 4); + othello_state *state = (othello_state *)space->machine->driver_data; + return 0x80 | ((state->n7751_command & 0x07) << 4); } static WRITE8_DEVICE_HANDLER( n7751_p2_w ) { + othello_state *state = (othello_state *)device->machine->driver_data; + /* write to P2; low 4 bits go to 8243 */ i8243_p2_w(device, offset, data & 0x0f); /* output of bit $80 indicates we are ready (1) or busy (0) */ /* no other outputs are used */ - n7751_busy = data; + state->n7751_busy = data; } static READ8_HANDLER( n7751_t1_r ) @@ -340,8 +378,42 @@ static const mc6845_interface h46505_intf = NULL /* update address callback */ }; + +static MACHINE_START( othello ) +{ + othello_state *state = (othello_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->mc6845 = devtag_get_device(machine, "crtc"); + state->n7751 = devtag_get_device(machine, "n7751"); + state->ay1 = devtag_get_device(machine, "ay1"); + state->ay2 = devtag_get_device(machine, "ay2"); + + state_save_register_global(machine, state->tile_bank); + state_save_register_global(machine, state->ay_select); + state_save_register_global(machine, state->ack_data); + state_save_register_global(machine, state->n7751_command); + state_save_register_global(machine, state->sound_addr); + state_save_register_global(machine, state->n7751_busy); +} + +static MACHINE_RESET( othello ) +{ + othello_state *state = (othello_state *)machine->driver_data; + + state->tile_bank = 0; + state->ay_select = 0; + state->ack_data = 0; + state->n7751_command = 0; + state->sound_addr = 0; + state->n7751_busy = 0; +} + static MACHINE_DRIVER_START( othello ) + /* driver data */ + MDRV_DRIVER_DATA(othello_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu",Z80,XTAL_8MHz/2) MDRV_CPU_PROGRAM_MAP(main_map) @@ -357,6 +429,8 @@ static MACHINE_DRIVER_START( othello ) MDRV_I8243_ADD("n7751_8243", NULL, n7751_rom_control_w) + MDRV_MACHINE_START(othello) + MDRV_MACHINE_RESET(othello) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -406,4 +480,4 @@ ROM_START( othello ) ROM_LOAD( "7.ic42", 0x4000, 0x2000, CRC(a76705f7) SHA1(b7d2a65d65d065732ddd0b3b738749369b382b48)) ROM_END -GAME( 1984, othello, 0, othello, othello, 0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND ) +GAME( 1984, othello, 0, othello, othello, 0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/othldrby.c b/src/mame/drivers/othldrby.c index a619da9dd5c..e60c6b87776 100644 --- a/src/mame/drivers/othldrby.c +++ b/src/mame/drivers/othldrby.c @@ -17,24 +17,13 @@ Notes: #include "emu.h" #include "cpu/m68000/m68000.h" #include "sound/okim6295.h" - - -WRITE16_HANDLER( othldrby_videoram_addr_w ); -READ16_HANDLER( othldrby_videoram_r ); -WRITE16_HANDLER( othldrby_videoram_w ); -WRITE16_HANDLER( othldrby_vreg_addr_w ); -WRITE16_HANDLER( othldrby_vreg_w ); - -VIDEO_START( othldrby ); -VIDEO_EOF( othldrby ); -VIDEO_UPDATE( othldrby ); - -static int toggle; +#include "includes/othldrby.h" static READ16_HANDLER( pip ) { - return toggle ^= 1; + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + return state->toggle ^= 1; } static READ16_HANDLER( pap ) @@ -53,10 +42,10 @@ static WRITE16_HANDLER( coinctrl_w ) { if (ACCESSING_BITS_0_7) { - coin_counter_w(space->machine, 0,data & 1); - coin_counter_w(space->machine, 1,data & 2); - coin_lockout_w(space->machine, 0,~data & 4); - coin_lockout_w(space->machine, 1,~data & 8); + coin_counter_w(space->machine, 0, data & 1); + coin_counter_w(space->machine, 1, data & 2); + coin_lockout_w(space->machine, 0, ~data & 4); + coin_lockout_w(space->machine, 1, ~data & 8); } } @@ -93,18 +82,17 @@ static READ16_HANDLER( calendar_r ) } - static ADDRESS_MAP_START( othldrby_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x100000, 0x10ffff) AM_RAM - AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r,calendar_w) + AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r, calendar_w) AM_RANGE(0x300000, 0x300001) AM_WRITE(othldrby_videoram_addr_w) - AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r,othldrby_videoram_w) + AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r, othldrby_videoram_w) AM_RANGE(0x300008, 0x300009) AM_WRITE(othldrby_vreg_addr_w) AM_RANGE(0x30000c, 0x30000d) AM_READ(pip) // vblank? AM_RANGE(0x30000c, 0x30000f) AM_WRITE(othldrby_vreg_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r,okim6295_w, 0x00ff) + AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x700000, 0x700001) AM_READ(pap) // scanline??? AM_RANGE(0x700004, 0x700005) AM_READ_PORT("DSW1") AM_RANGE(0x700008, 0x700009) AM_READ_PORT("DSW2") @@ -228,13 +216,40 @@ GFXDECODE_END +static MACHINE_START( othldrby ) +{ + othldrby_state *state = (othldrby_state *)machine->driver_data; + + state_save_register_global(machine, state->toggle); + state_save_register_global(machine, state->vram_addr); + state_save_register_global(machine, state->vreg_addr); + state_save_register_global_array(machine, state->vreg); +} + +static MACHINE_RESET( othldrby ) +{ + othldrby_state *state = (othldrby_state *)machine->driver_data; + + state->toggle = 0xff; + state->vram_addr = 0; + state->vreg_addr = 0; + + memset(state->vreg, 0, ARRAY_LENGTH(state->vreg)); +} + static MACHINE_DRIVER_START( othldrby ) + /* driver data */ + MDRV_DRIVER_DATA(othldrby_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 16000000) MDRV_CPU_PROGRAM_MAP(othldrby_map) MDRV_CPU_VBLANK_INT("screen", irq4_line_hold) + MDRV_MACHINE_START(othldrby) + MDRV_MACHINE_RESET(othldrby) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -278,9 +293,4 @@ ROM_START( othldrby ) ROM_LOAD( "db0.4", 0x00000, 0x80000, CRC(a9701868) SHA1(9ee89556666d358e8d3915622573b3ba660048b8) ) ROM_END -static DRIVER_INIT( othldrby ) -{ - toggle = 0xff; -} - -GAME( 1995, othldrby, 0, othldrby, othldrby, othldrby, ROT0, "Sunwise", "Othello Derby (Japan)", 0 ) +GAME( 1995, othldrby, 0, othldrby, othldrby, 0, ROT0, "Sunwise", "Othello Derby (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/nemesis.h b/src/mame/includes/nemesis.h index b0feddfbf4f..f5e792172a0 100644 --- a/src/mame/includes/nemesis.h +++ b/src/mame/includes/nemesis.h @@ -1,30 +1,64 @@ -/*----------- defined in drivers/nemesis.c -----------*/ +class nemesis_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nemesis_state(machine)); } + + nemesis_state(running_machine &machine) { } + + /* memory pointers */ + UINT16 * videoram1; + UINT16 * videoram2; + UINT16 * colorram1; + UINT16 * colorram2; + UINT16 * charram; + UINT16 * spriteram; + UINT16 * paletteram; + UINT16 * xscroll1; + UINT16 * xscroll2; + UINT16 * yscroll1; + UINT16 * yscroll2; + UINT8 * gx400_shared_ram; + + size_t charram_size; + size_t spriteram_size; + + /* video-related */ + tilemap_t *background, *foreground; + int spriteram_words; + int tilemap_flip; + int flipscreen; + UINT8 irq_port_last; + UINT8 blank_tile[8*8]; + + /* misc */ + int irq_on; + int irq1_on; + int irq2_on; + int irq4_on; + UINT16 selected_ip; /* Copied from WEC Le Mans 24 driver, explicity needed for Hyper Crash */ + int gx400_irq1_cnt; + UINT8 frame_counter; + + /* devices */ + running_device *maincpu; + running_device *audiocpu; + running_device *vlm; +}; -extern int nemesis_irq_on; -extern int nemesis_irq2_on; -extern UINT16 hcrash_selected_ip; /*----------- defined in video/nemesis.c -----------*/ -extern UINT16 *nemesis_videoram1; -extern UINT16 *nemesis_videoram2; -extern UINT16 *nemesis_colorram1; -extern UINT16 *nemesis_colorram2; -extern UINT16 *nemesis_characterram; -extern size_t nemesis_characterram_size; -extern UINT16 *nemesis_xscroll1, *nemesis_xscroll2; -extern UINT16 *nemesis_yscroll1, *nemesis_yscroll2; - -WRITE16_HANDLER( nemesis_videoram1_word_w ); -WRITE16_HANDLER( nemesis_videoram2_word_w ); -WRITE16_HANDLER( nemesis_colorram1_word_w ); -WRITE16_HANDLER( nemesis_colorram2_word_w ); -WRITE16_HANDLER( nemesis_characterram_word_w ); -VIDEO_START( nemesis ); -VIDEO_UPDATE( nemesis ); - WRITE16_HANDLER( nemesis_gfx_flipx_word_w ); WRITE16_HANDLER( nemesis_gfx_flipy_word_w ); WRITE16_HANDLER( salamand_control_port_word_w ); WRITE16_HANDLER( salamander_palette_word_w ); WRITE16_HANDLER( nemesis_palette_word_w ); + +WRITE16_HANDLER( nemesis_videoram1_word_w ); +WRITE16_HANDLER( nemesis_videoram2_word_w ); +WRITE16_HANDLER( nemesis_colorram1_word_w ); +WRITE16_HANDLER( nemesis_colorram2_word_w ); +WRITE16_HANDLER( nemesis_charram_word_w ); + +VIDEO_START( nemesis ); +VIDEO_UPDATE( nemesis ); diff --git a/src/mame/includes/oneshot.h b/src/mame/includes/oneshot.h index b780785b2fa..5e199c52575 100644 --- a/src/mame/includes/oneshot.h +++ b/src/mame/includes/oneshot.h @@ -1,20 +1,37 @@ -/*----------- defined in drivers/oneshot.c -----------*/ -extern UINT16 *oneshot_sprites; -extern UINT16 *oneshot_bg_videoram; -extern UINT16 *oneshot_mid_videoram; -extern UINT16 *oneshot_fg_videoram; -extern UINT16 *oneshot_scroll; +class oneshot_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, oneshot_state(machine)); } -extern int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2; -extern int gun_x_shift; + oneshot_state(running_machine &machine) { } + + /* memory pointers */ + UINT16 * sprites; + UINT16 * bg_videoram; + UINT16 * mid_videoram; + UINT16 * fg_videoram; + UINT16 * scroll; + /* video-related */ + tilemap_t *bg_tilemap, *mid_tilemap, *fg_tilemap; + + /* misc */ + int gun_x_p1, gun_y_p1, gun_x_p2, gun_y_p2; + int gun_x_shift; + int p1_wobble, p2_wobble; + + /* devices */ + running_device *maincpu; + running_device *audiocpu; +}; /*----------- defined in video/oneshot.c -----------*/ WRITE16_HANDLER( oneshot_bg_videoram_w ); WRITE16_HANDLER( oneshot_mid_videoram_w ); WRITE16_HANDLER( oneshot_fg_videoram_w ); + VIDEO_START( oneshot ); VIDEO_UPDATE( oneshot ); VIDEO_UPDATE( maddonna ); diff --git a/src/mame/includes/orbit.h b/src/mame/includes/orbit.h index 615b8aba2be..89e46775884 100644 --- a/src/mame/includes/orbit.h +++ b/src/mame/includes/orbit.h @@ -7,13 +7,36 @@ #include "sound/discrete.h" /* Discrete Sound Input Nodes */ -#define ORBIT_NOTE_FREQ NODE_01 -#define ORBIT_ANOTE1_AMP NODE_02 -#define ORBIT_ANOTE2_AMP NODE_03 -#define ORBIT_NOISE1_AMP NODE_04 -#define ORBIT_NOISE2_AMP NODE_05 -#define ORBIT_WARNING_EN NODE_06 -#define ORBIT_NOISE_EN NODE_07 +#define ORBIT_NOTE_FREQ NODE_01 +#define ORBIT_ANOTE1_AMP NODE_02 +#define ORBIT_ANOTE2_AMP NODE_03 +#define ORBIT_NOISE1_AMP NODE_04 +#define ORBIT_NOISE2_AMP NODE_05 +#define ORBIT_WARNING_EN NODE_06 +#define ORBIT_NOISE_EN NODE_07 + +class orbit_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, orbit_state(machine)); } + + orbit_state(running_machine &machine) { } + + /* memory pointers */ + UINT8 * playfield_ram; + UINT8 * sprite_ram; + + /* video-related */ + tilemap_t *bg_tilemap; + int flip_screen; + + /* misc */ + UINT8 misc_flags; + + /* devices */ + running_device *maincpu; + running_device *discrete; +}; /*----------- defined in audio/orbit.c -----------*/ @@ -30,7 +53,4 @@ DISCRETE_SOUND_EXTERN( orbit ); VIDEO_START( orbit ); VIDEO_UPDATE( orbit ); -extern UINT8* orbit_playfield_ram; -extern UINT8* orbit_sprite_ram; - extern WRITE8_HANDLER( orbit_playfield_w ); diff --git a/src/mame/includes/othldrby.h b/src/mame/includes/othldrby.h new file mode 100644 index 00000000000..1e802f6e133 --- /dev/null +++ b/src/mame/includes/othldrby.h @@ -0,0 +1,41 @@ +/************************************************************************* + + Othello Derby + +*************************************************************************/ + +#define OTHLDRBY_VREG_SIZE 18 + +class othldrby_state +{ +public: + static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othldrby_state(machine)); } + + othldrby_state(running_machine &machine) { } + + /* memory pointers */ + UINT16 * vram; + UINT16 * buf_spriteram; + UINT16 * buf_spriteram2; + + /* video-related */ + tilemap_t *bg_tilemap[3]; + UINT16 vreg[OTHLDRBY_VREG_SIZE]; + UINT32 vram_addr, vreg_addr; + + /* misc */ + int toggle; +}; + + +/*----------- defined in video/othldrby.c -----------*/ + +WRITE16_HANDLER( othldrby_videoram_addr_w ); +READ16_HANDLER( othldrby_videoram_r ); +WRITE16_HANDLER( othldrby_videoram_w ); +WRITE16_HANDLER( othldrby_vreg_addr_w ); +WRITE16_HANDLER( othldrby_vreg_w ); + +VIDEO_START( othldrby ); +VIDEO_EOF( othldrby ); +VIDEO_UPDATE( othldrby ); diff --git a/src/mame/video/nemesis.c b/src/mame/video/nemesis.c index d99aa5864f3..a795fd99c7b 100644 --- a/src/mame/video/nemesis.c +++ b/src/mame/video/nemesis.c @@ -8,22 +8,6 @@ #include "includes/nemesis.h" -UINT16 *nemesis_videoram1; -UINT16 *nemesis_videoram2; -UINT16 *nemesis_colorram1; -UINT16 *nemesis_colorram2; -UINT16 *nemesis_characterram; -size_t nemesis_characterram_size; -UINT16 *nemesis_xscroll1, *nemesis_xscroll2; -UINT16 *nemesis_yscroll1, *nemesis_yscroll2; - -static int spriteram_words; -static int tilemap_flip; -static int flipscreen; -static UINT8 irq_port_last; - -static tilemap_t *background, *foreground; - static const struct { UINT8 width; @@ -36,26 +20,33 @@ sprite_data[8] = { 8, 8, 0 }, { 16, 8, 6 }, { 8, 16, 3 }, { 16, 16, 1 } }; -static UINT8 blank_tile[8*8]; - static TILE_GET_INFO( get_bg_tile_info ) { - int code,color,flags,mask,layer; + nemesis_state *state = (nemesis_state *)machine->driver_data; + int code, color, flags, mask, layer; - code = nemesis_videoram2[tile_index]; - color = nemesis_colorram2[tile_index]; + code = state->videoram2[tile_index]; + color = state->colorram2[tile_index]; flags = 0; - if (color & 0x80) flags |= TILE_FLIPX; - if (code & 0x0800) flags |= TILE_FLIPY; + if (color & 0x80) + flags |= TILE_FLIPX; + + if (code & 0x0800) + flags |= TILE_FLIPY; + if ((~code & 0x2000) || ((code & 0xc000) == 0x4000)) flags |= TILE_FORCE_LAYER0; /* no transparency */ - if (code & 0xf800) { + + if (code & 0xf800) + { SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags ); - } else { + } + else + { SET_TILE_INFO( 0, 0, 0x00, 0 ); - tileinfo->pen_data = blank_tile; + tileinfo->pen_data = state->blank_tile; } mask = (code & 0x1000) >> 12; @@ -68,21 +59,30 @@ static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_fg_tile_info ) { - int code,color,flags,mask,layer; + nemesis_state *state = (nemesis_state *)machine->driver_data; + int code, color, flags, mask, layer; - code = nemesis_videoram1[tile_index]; - color = nemesis_colorram1[tile_index]; + code = state->videoram1[tile_index]; + color = state->colorram1[tile_index]; flags = 0; - if (color & 0x80) flags |= TILE_FLIPX; - if (code & 0x0800) flags |= TILE_FLIPY; + if (color & 0x80) + flags |= TILE_FLIPX; + + if (code & 0x0800) + flags |= TILE_FLIPY; + if ((~code & 0x2000) || ((code & 0xc000) == 0x4000)) flags |= TILE_FORCE_LAYER0; /* no transparency */ - if (code & 0xf800) { + + if (code & 0xf800) + { SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags ); - } else { + } + else + { SET_TILE_INFO( 0, 0, 0x00, 0 ); - tileinfo->pen_data = blank_tile; + tileinfo->pen_data = state->blank_tile; } mask = (code & 0x1000) >> 12; @@ -96,63 +96,69 @@ static TILE_GET_INFO( get_fg_tile_info ) WRITE16_HANDLER( nemesis_gfx_flipx_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - flipscreen = data & 0x01; + state->flipscreen = data & 0x01; if (data & 0x01) - tilemap_flip |= TILEMAP_FLIPX; + state->tilemap_flip |= TILEMAP_FLIPX; else - tilemap_flip &= ~TILEMAP_FLIPX; + state->tilemap_flip &= ~TILEMAP_FLIPX; - tilemap_set_flip_all(space->machine, tilemap_flip); + tilemap_set_flip_all(space->machine, state->tilemap_flip); } if (ACCESSING_BITS_8_15) { if (data & 0x0100) - cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); + cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff); } } WRITE16_HANDLER( nemesis_gfx_flipy_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { if (data & 0x01) - tilemap_flip |= TILEMAP_FLIPY; + state->tilemap_flip |= TILEMAP_FLIPY; else - tilemap_flip &= ~TILEMAP_FLIPY; + state->tilemap_flip &= ~TILEMAP_FLIPY; - tilemap_set_flip_all(space->machine, tilemap_flip); + tilemap_set_flip_all(space->machine, state->tilemap_flip); } } WRITE16_HANDLER( salamand_control_port_word_w ) { + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - UINT8 accessing_bits = data ^ irq_port_last; + UINT8 accessing_bits = data ^ state->irq_port_last; - nemesis_irq_on = data & 0x01; - nemesis_irq2_on = data & 0x02; - flipscreen = data & 0x04; + state->irq_on = data & 0x01; + state->irq2_on = data & 0x02; + state->flipscreen = data & 0x04; if (data & 0x04) - tilemap_flip |= TILEMAP_FLIPX; + state->tilemap_flip |= TILEMAP_FLIPX; else - tilemap_flip &= ~TILEMAP_FLIPX; + state->tilemap_flip &= ~TILEMAP_FLIPX; if (data & 0x08) - tilemap_flip |= TILEMAP_FLIPY; + state->tilemap_flip |= TILEMAP_FLIPY; else - tilemap_flip &= ~TILEMAP_FLIPY; + state->tilemap_flip &= ~TILEMAP_FLIPY; if (accessing_bits & 0x0c) - tilemap_set_flip_all(space->machine, tilemap_flip); + tilemap_set_flip_all(space->machine, state->tilemap_flip); - irq_port_last = data; + state->irq_port_last = data; } if (ACCESSING_BITS_8_15) @@ -161,19 +167,20 @@ WRITE16_HANDLER( salamand_control_port_word_w ) coin_lockout_w(space->machine, 1, data & 0x0400); if (data & 0x0800) - cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); + cpu_set_input_line(state->audiocpu, 0, HOLD_LINE); - hcrash_selected_ip = (~data & 0x1000) >> 12; /* citybomb steering & accel */ + state->selected_ip = (~data & 0x1000) >> 12; /* citybomb steering & accel */ } } WRITE16_HANDLER( nemesis_palette_word_w ) { - int r,g,b,bit1,bit2,bit3,bit4,bit5; + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + int r, g, b, bit1, bit2, bit3, bit4, bit5; - COMBINE_DATA(space->machine->generic.paletteram.u16 + offset); - data = space->machine->generic.paletteram.u16[offset]; + COMBINE_DATA(state->paletteram + offset); + data = state->paletteram[offset]; /* Mish, 30/11/99 - Schematics show the resistor values are: 300 Ohms @@ -187,77 +194,89 @@ WRITE16_HANDLER( nemesis_palette_word_w ) #define MULTIPLIER 8 * bit1 + 17 * bit2 + 33 * bit3 + 67 * bit4 + 130 * bit5 - bit1=(data >> 0)&1; - bit2=(data >> 1)&1; - bit3=(data >> 2)&1; - bit4=(data >> 3)&1; - bit5=(data >> 4)&1; + bit1 = BIT(data, 0); + bit2 = BIT(data, 1); + bit3 = BIT(data, 2); + bit4 = BIT(data, 3); + bit5 = BIT(data, 4); r = MULTIPLIER; - r = pow (r/255.0, 2)*255; - bit1=(data >> 5)&1; - bit2=(data >> 6)&1; - bit3=(data >> 7)&1; - bit4=(data >> 8)&1; - bit5=(data >> 9)&1; + r = pow(r/255.0, 2)*255; + bit1 = BIT(data, 5); + bit2 = BIT(data, 6); + bit3 = BIT(data, 7); + bit4 = BIT(data, 8); + bit5 = BIT(data, 9); g = MULTIPLIER; - g = pow (g/255.0, 2)*255; - bit1=(data >> 10)&1; - bit2=(data >> 11)&1; - bit3=(data >> 12)&1; - bit4=(data >> 13)&1; - bit5=(data >> 14)&1; + g = pow(g/255.0, 2)*255; + bit1 = BIT(data, 10); + bit2 = BIT(data, 11); + bit3 = BIT(data, 12); + bit4 = BIT(data, 13); + bit5 = BIT(data, 14); b = MULTIPLIER; - b = pow (b/255.0, 2)*255; + b = pow(b/255.0, 2)*255; - palette_set_color(space->machine,offset,MAKE_RGB(r,g,b)); + palette_set_color(space->machine, offset, MAKE_RGB(r, g, b)); } WRITE16_HANDLER( salamander_palette_word_w ) { - COMBINE_DATA(space->machine->generic.paletteram.u16 + offset); + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + COMBINE_DATA(state->paletteram + offset); offset &= ~1; - data = ((space->machine->generic.paletteram.u16[offset] << 8) & 0xff00) | (space->machine->generic.paletteram.u16[offset+1] & 0xff); - palette_set_color_rgb(space->machine,offset / 2,pal5bit(data >> 0),pal5bit(data >> 5),pal5bit(data >> 10)); + data = ((state->paletteram[offset] << 8) & 0xff00) | (state->paletteram[offset + 1] & 0xff); + palette_set_color_rgb(space->machine, offset / 2, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); } WRITE16_HANDLER( nemesis_videoram1_word_w ) { - COMBINE_DATA(nemesis_videoram1 + offset); - tilemap_mark_tile_dirty( foreground, offset ); + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + COMBINE_DATA(state->videoram1 + offset); + tilemap_mark_tile_dirty(state->foreground, offset); } WRITE16_HANDLER( nemesis_videoram2_word_w ) { - COMBINE_DATA(nemesis_videoram2 + offset); - tilemap_mark_tile_dirty( background, offset ); + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + COMBINE_DATA(state->videoram2 + offset); + tilemap_mark_tile_dirty(state->background, offset); } WRITE16_HANDLER( nemesis_colorram1_word_w ) { - COMBINE_DATA(nemesis_colorram1 + offset); - tilemap_mark_tile_dirty( foreground, offset ); + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + COMBINE_DATA(state->colorram1 + offset); + tilemap_mark_tile_dirty(state->foreground, offset); } WRITE16_HANDLER( nemesis_colorram2_word_w ) { - COMBINE_DATA(nemesis_colorram2 + offset); - tilemap_mark_tile_dirty( background, offset ); + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + + COMBINE_DATA(state->colorram2 + offset); + tilemap_mark_tile_dirty(state->background, offset); } /* we have to straighten out the 16-bit word into bytes for gfxdecode() to work */ -WRITE16_HANDLER( nemesis_characterram_word_w ) +WRITE16_HANDLER( nemesis_charram_word_w ) { - UINT16 oldword = nemesis_characterram[offset]; - COMBINE_DATA(nemesis_characterram + offset); - data = nemesis_characterram[offset]; + nemesis_state *state = (nemesis_state *)space->machine->driver_data; + UINT16 oldword = state->charram[offset]; + + COMBINE_DATA(state->charram + offset); + data = state->charram[offset]; if (oldword != data) { int i; - for (i=0; i<8; i++) + for (i = 0; i < 8; i++) { int w = sprite_data[i].width; int h = sprite_data[i].height; @@ -269,63 +288,56 @@ WRITE16_HANDLER( nemesis_characterram_word_w ) static STATE_POSTLOAD( nemesis_postload ) { - int i,offs; + nemesis_state *state = (nemesis_state *)machine->driver_data; + int i, offs; - for (offs=0; offscharram_size; offs++) { - for (i=0; i<8; i++) + for (i = 0; i < 8; i++) { int w = sprite_data[i].width; int h = sprite_data[i].height; gfx_element_mark_dirty(machine->gfx[sprite_data[i].char_type], offs * 4 / (w * h)); } } - tilemap_mark_all_tiles_dirty(background); - tilemap_mark_all_tiles_dirty(foreground); + tilemap_mark_all_tiles_dirty(state->background); + tilemap_mark_all_tiles_dirty(state->foreground); } /* claim a palette dirty array */ VIDEO_START( nemesis ) { - spriteram_words = machine->generic.spriteram_size / 2; + nemesis_state *state = (nemesis_state *)machine->driver_data; - background = tilemap_create(machine, - get_bg_tile_info, tilemap_scan_rows, 8,8, 64,32 ); + state->spriteram_words = state->spriteram_size / 2; - foreground = tilemap_create(machine, - get_fg_tile_info, tilemap_scan_rows, 8,8, 64,32 ); + state->background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + state->foreground = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); - tilemap_set_transparent_pen( background, 0 ); - tilemap_set_transparent_pen( foreground, 0 ); - tilemap_set_scroll_rows( background, 256 ); - tilemap_set_scroll_rows( foreground, 256 ); + tilemap_set_transparent_pen(state->background, 0); + tilemap_set_transparent_pen(state->foreground, 0); + tilemap_set_scroll_rows(state->background, 256); + tilemap_set_scroll_rows(state->foreground, 256); - memset(nemesis_characterram, 0, nemesis_characterram_size); + memset(state->charram, 0, state->charram_size); + memset(state->blank_tile, 0, ARRAY_LENGTH(state->blank_tile)); - gfx_element_set_source(machine->gfx[0], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[1], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[2], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[3], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[4], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[5], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[6], (UINT8 *)nemesis_characterram); - gfx_element_set_source(machine->gfx[7], (UINT8 *)nemesis_characterram); - - flipscreen = 0; - tilemap_flip = 0; - irq_port_last = 0; + gfx_element_set_source(machine->gfx[0], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[1], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[2], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[3], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[4], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[5], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[6], (UINT8 *)state->charram); + gfx_element_set_source(machine->gfx[7], (UINT8 *)state->charram); /* Set up save state */ - state_save_register_global(machine, spriteram_words); - state_save_register_global(machine, tilemap_flip); - state_save_register_global(machine, flipscreen); - state_save_register_global(machine, irq_port_last); state_save_register_postload(machine, nemesis_postload, NULL); } -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { /* * 16 bytes per sprite, in memory from 56000-56fff @@ -342,7 +354,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta * byte E : not used. */ - UINT16 *spriteram16 = machine->generic.spriteram.u16; + nemesis_state *state = (nemesis_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; int adress; /* start of sprite in spriteram */ int sx; /* sprite X-pos */ int sy; /* sprite Y-pos */ @@ -356,30 +369,32 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta int w,h; int idx; - for (priority=256-1; priority>=0; priority--) + for (priority = 256 - 1; priority >= 0; priority--) { - for (adress = spriteram_words-8; adress >= 0; adress -= 8) + for (adress = state->spriteram_words - 8; adress >= 0; adress -= 8) { - if((spriteram16[adress] & 0xff)!=priority) continue; + if((spriteram[adress] & 0xff) != priority) + continue; - zoom = spriteram16[adress+2] & 0xff; - if (!(spriteram16[adress+2] & 0xff00) && ((spriteram16[adress+3] & 0xff00) != 0xff00)) - code = spriteram16[adress+3] + ((spriteram16[adress+4] & 0xc0) << 2); + zoom = spriteram[adress + 2] & 0xff; + if (!(spriteram[adress + 2] & 0xff00) && ((spriteram[adress + 3] & 0xff00) != 0xff00)) + code = spriteram[adress + 3] + ((spriteram[adress + 4] & 0xc0) << 2); else - code = (spriteram16[adress+3] & 0xff) + ((spriteram16[adress+4] & 0xc0) << 2); + code = (spriteram[adress + 3] & 0xff) + ((spriteram[adress + 4] & 0xc0) << 2); - if (zoom != 0xFF || code!=0) + if (zoom != 0xff || code != 0) { - size = spriteram16[adress+1]; + size = spriteram[adress + 1]; zoom += (size & 0xc0) << 2; - sx = spriteram16[adress+5] & 0xff; - sy = spriteram16[adress+6] & 0xff; - if (spriteram16[adress+4] & 0x01) + sx = spriteram[adress + 5] & 0xff; + sy = spriteram[adress + 6] & 0xff; + if (spriteram[adress + 4] & 0x01) sx-=0x100; /* fixes left side clip */ - color = (spriteram16[adress+4] & 0x1e) >> 1; - flipx = spriteram16[adress+1] & 0x01; - flipy = spriteram16[adress+4] & 0x20; + + color = (spriteram[adress + 4] & 0x1e) >> 1; + flipx = spriteram[adress + 1] & 0x01; + flipy = spriteram[adress + 4] & 0x20; idx = (size >> 3) & 7; w = sprite_data[idx].width; @@ -387,16 +402,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta code = code * 8 * 16 / (w * h); char_type = sprite_data[idx].char_type; - if( zoom ) + if (zoom) { - zoom = ((1<<16) * 0x80 / zoom) + 0x02ab; - if (flipscreen) + zoom = ((1 << 16) * 0x80 / zoom) + 0x02ab; + if (state->flipscreen) { sx = 256 - ((zoom * w) >> 16) - sx; sy = 256 - ((zoom * h) >> 16) - sy; flipx = !flipx; flipy = !flipy; } + pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[char_type], code, color, @@ -405,38 +421,39 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta zoom,zoom, machine->priority_bitmap,0xffcc,0 ); } - } /* if sprite */ - } /* for loop */ - } /* priority */ + } + } + } } /******************************************************************************/ VIDEO_UPDATE( nemesis ) { + nemesis_state *state = (nemesis_state *)screen->machine->driver_data; int offs; rectangle clip; - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - bitmap_fill(bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); + bitmap_fill(bitmap, cliprect, 0); clip.min_x = 0; clip.max_x = 255; - tilemap_set_scroll_cols( background, 64 ); - tilemap_set_scroll_cols( foreground, 64 ); - tilemap_set_scroll_rows( background, 1 ); - tilemap_set_scroll_rows( foreground, 1 ); + tilemap_set_scroll_cols(state->background, 64); + tilemap_set_scroll_cols(state->foreground, 64); + tilemap_set_scroll_rows(state->background, 1); + tilemap_set_scroll_rows(state->foreground, 1); for (offs = 0; offs < 64; offs++) { int offset_x = offs; - if (flipscreen) + if (state->flipscreen) offset_x = (offs + 0x20) & 0x3f; - tilemap_set_scrolly( background, offs, nemesis_yscroll2[offset_x] ); - tilemap_set_scrolly( foreground, offs, nemesis_yscroll1[offset_x] ); + tilemap_set_scrolly(state->background, offs, state->yscroll2[offset_x]); + tilemap_set_scrolly(state->foreground, offs, state->yscroll1[offset_x]); } for (offs = cliprect->min_y; offs <= cliprect->max_y; offs++) @@ -447,18 +464,18 @@ VIDEO_UPDATE( nemesis ) clip.min_y = offs; clip.max_y = offs; - if (flipscreen) + if (state->flipscreen) offset_y = 255 - offs; - tilemap_set_scrollx( background, 0, (nemesis_xscroll2[offset_y] & 0xff) + ((nemesis_xscroll2[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) ); - tilemap_set_scrollx( foreground, 0, (nemesis_xscroll1[offset_y] & 0xff) + ((nemesis_xscroll1[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) ); + tilemap_set_scrollx(state->background, 0, (state->xscroll2[offset_y] & 0xff) + ((state->xscroll2[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0)); + tilemap_set_scrollx(state->foreground, 0, (state->xscroll1[offset_y] & 0xff) + ((state->xscroll1[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0)); - for (i=0; i<4; i+=2) + for (i = 0; i < 4; i += 2) { - tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+0), 1); - tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+1), 2); - tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+0), 1); - tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+1), 2); + tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 0), 1); + tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 1), 2); + tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 0), 1); + tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 1), 2); } } diff --git a/src/mame/video/oneshot.c b/src/mame/video/oneshot.c index 536653e0577..04717f6b21f 100644 --- a/src/mame/video/oneshot.c +++ b/src/mame/video/oneshot.c @@ -3,114 +3,117 @@ #include "emu.h" #include "includes/oneshot.h" -static tilemap_t *oneshot_bg_tilemap; -static tilemap_t *oneshot_mid_tilemap; -static tilemap_t *oneshot_fg_tilemap; /* bg tilemap */ static TILE_GET_INFO( get_oneshot_bg_tile_info ) { - int tileno; + oneshot_state *state = (oneshot_state *)machine->driver_data; + int tileno = state->bg_videoram[tile_index * 2 + 1]; - tileno = oneshot_bg_videoram[tile_index*2+1]; - - SET_TILE_INFO(0,tileno,0,0); + SET_TILE_INFO(0, tileno, 0, 0); } WRITE16_HANDLER( oneshot_bg_videoram_w ) { - COMBINE_DATA(&oneshot_bg_videoram[offset]); - tilemap_mark_tile_dirty(oneshot_bg_tilemap,offset/2); + oneshot_state *state = (oneshot_state *)space->machine->driver_data; + COMBINE_DATA(&state->bg_videoram[offset]); + tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2); } /* mid tilemap */ static TILE_GET_INFO( get_oneshot_mid_tile_info ) { - int tileno; + oneshot_state *state = (oneshot_state *)machine->driver_data; + int tileno = state->mid_videoram[tile_index * 2 + 1]; - tileno = oneshot_mid_videoram[tile_index*2+1]; - - SET_TILE_INFO(0,tileno,2,0); + SET_TILE_INFO(0, tileno, 2, 0); } WRITE16_HANDLER( oneshot_mid_videoram_w ) { - COMBINE_DATA(&oneshot_mid_videoram[offset]); - tilemap_mark_tile_dirty(oneshot_mid_tilemap,offset/2); + oneshot_state *state = (oneshot_state *)space->machine->driver_data; + COMBINE_DATA(&state->mid_videoram[offset]); + tilemap_mark_tile_dirty(state->mid_tilemap, offset / 2); } /* fg tilemap */ static TILE_GET_INFO( get_oneshot_fg_tile_info ) { - int tileno; + oneshot_state *state = (oneshot_state *)machine->driver_data; + int tileno = state->fg_videoram[tile_index * 2 + 1]; - tileno = oneshot_fg_videoram[tile_index*2+1]; - - SET_TILE_INFO(0,tileno,3,0); + SET_TILE_INFO(0, tileno, 3, 0); } WRITE16_HANDLER( oneshot_fg_videoram_w ) { - COMBINE_DATA(&oneshot_fg_videoram[offset]); - tilemap_mark_tile_dirty(oneshot_fg_tilemap,offset/2); + oneshot_state *state = (oneshot_state *)space->machine->driver_data; + COMBINE_DATA(&state->fg_videoram[offset]); + tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2); } VIDEO_START( oneshot ) { - oneshot_bg_tilemap = tilemap_create(machine, get_oneshot_bg_tile_info,tilemap_scan_rows, 16, 16,32,32); - oneshot_mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info,tilemap_scan_rows, 16, 16,32,32); - oneshot_fg_tilemap = tilemap_create(machine, get_oneshot_fg_tile_info,tilemap_scan_rows, 16, 16,32,32); + oneshot_state *state = (oneshot_state *)machine->driver_data; - tilemap_set_transparent_pen(oneshot_bg_tilemap,0); - tilemap_set_transparent_pen(oneshot_mid_tilemap,0); - tilemap_set_transparent_pen(oneshot_fg_tilemap,0); + state->bg_tilemap = tilemap_create(machine, get_oneshot_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32); + state->mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info, tilemap_scan_rows, 16, 16, 32, 32); + state->fg_tilemap = tilemap_create(machine, get_oneshot_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32); + + tilemap_set_transparent_pen(state->bg_tilemap, 0); + tilemap_set_transparent_pen(state->mid_tilemap, 0); + tilemap_set_transparent_pen(state->fg_tilemap, 0); } static void draw_crosshairs( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { - int xpos,ypos; - /* get gun raw coordonates (player 1) */ - gun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256; - gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256; - - /* compute the coordonates for drawing (from routine at 0x009ab0) */ - xpos = gun_x_p1; - ypos = gun_y_p1; - - gun_x_p1+=gun_x_shift; - - gun_y_p1 -= 0x0a; - if (gun_y_p1 < 0) - gun_y_p1=0; - - - /* get gun raw coordonates (player 2) */ - gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256; - gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256; - /* compute the coordonates for drawing (from routine at 0x009b6e) */ - xpos = gun_x_p2; - ypos = gun_y_p2; - - gun_x_p2 += gun_x_shift-0x0a; - if (gun_x_p2 < 0) - gun_x_p2=0; -} - -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) -{ - const UINT16 *source = oneshot_sprites; - const UINT16 *finish = source+(0x1000/2); - const gfx_element *gfx = machine->gfx[1]; - + oneshot_state *state = (oneshot_state *)machine->driver_data; int xpos,ypos; - while( sourcegun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256; + state->gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256; + + /* compute the coordinates for drawing (from routine at 0x009ab0) */ + xpos = state->gun_x_p1; + ypos = state->gun_y_p1; + + state->gun_x_p1 += state->gun_x_shift; + + state->gun_y_p1 -= 0x0a; + if (state->gun_y_p1 < 0) + state->gun_y_p1 = 0; + + + /* get gun raw coordinates (player 2) */ + state->gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256; + state->gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256; + + /* compute the coordinates for drawing (from routine at 0x009b6e) */ + xpos = state->gun_x_p2; + ypos = state->gun_y_p2; + + state->gun_x_p2 += state->gun_x_shift - 0x0a; + if (state->gun_x_p2 < 0) + state->gun_x_p2 = 0; +} + +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) +{ + oneshot_state *state = (oneshot_state *)machine->driver_data; + const UINT16 *source = state->sprites; + const UINT16 *finish = source + (0x1000 / 2); + const gfx_element *gfx = machine->gfx[1]; + + int xpos, ypos; + + while (source < finish) { - int blockx,blocky; + int blockx, blocky; int num = source[1] & 0xffff; - int xsize = (source[2] & 0x000f)+1; - int ysize = (source[3] & 0x000f)+1; + int xsize = (source[2] & 0x000f) + 1; + int ysize = (source[3] & 0x000f) + 1; ypos = source[3] & 0xff80; xpos = source[2] & 0xff80; @@ -119,35 +122,33 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta xpos = xpos >> 7; - if (source[0] == 0x0001) break; + if (source[0] == 0x0001) + break; xpos -= 8; ypos -= 6; - - for (blockx = 0; blockxmachine->driver_data; + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - tilemap_set_scrollx(oneshot_mid_tilemap,0, oneshot_scroll[0]-0x1f5); - tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]); + tilemap_set_scrollx(state->mid_tilemap, 0, state->scroll[0] - 0x1f5); + tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]); - tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0); - tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0); - draw_sprites(screen->machine,bitmap,cliprect); - tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0); - draw_crosshairs(screen->machine,bitmap,cliprect); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0); + draw_sprites(screen->machine, bitmap, cliprect); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); + draw_crosshairs(screen->machine, bitmap, cliprect); return 0; } VIDEO_UPDATE( maddonna ) { + oneshot_state *state = (oneshot_state *)screen->machine->driver_data; + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]); // other registers aren't used so we don't know which layers they relate to + tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]); // other registers aren't used so we don't know which layers they relate to - tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0); - tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0); - tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0); - draw_sprites(screen->machine,bitmap,cliprect); -// draw_crosshairs(screen->machine,bitmap,cliprect); // not a gun game + tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); + draw_sprites(screen->machine, bitmap, cliprect); -// popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", oneshot_scroll[0],oneshot_scroll[1],oneshot_scroll[2],oneshot_scroll[3],oneshot_scroll[4],oneshot_scroll[5],oneshot_scroll[6],oneshot_scroll[7]); +// popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", state->scroll[0], state->scroll[1], state->scroll[2], state->scroll[3], state->scroll[4], state->scroll[5], state->scroll[6], state->scroll[7]); return 0; } diff --git a/src/mame/video/orbit.c b/src/mame/video/orbit.c index ff3cda5e65b..e3e0a6a6f7f 100644 --- a/src/mame/video/orbit.c +++ b/src/mame/video/orbit.c @@ -7,30 +7,23 @@ Atari Orbit video emulation #include "emu.h" #include "includes/orbit.h" -UINT8* orbit_playfield_ram; -UINT8* orbit_sprite_ram; - -static tilemap_t* bg_tilemap; - -static int orbit_flip_screen; - - WRITE8_HANDLER( orbit_playfield_w ) { - orbit_playfield_ram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap, offset); + orbit_state *state = (orbit_state *)space->machine->driver_data; + state->playfield_ram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } static TILE_GET_INFO( get_tile_info ) { - UINT8 code = orbit_playfield_ram[tile_index]; - + orbit_state *state = (orbit_state *)machine->driver_data; + UINT8 code = state->playfield_ram[tile_index]; int flags = 0; - if (code & 0x40) + if (BIT(code, 6)) flags |= TILE_FLIPX; - if (orbit_flip_screen) + if (state->flip_screen) flags |= TILE_FLIPY; SET_TILE_INFO(3, code & 0x3f, 0, flags); @@ -39,13 +32,15 @@ static TILE_GET_INFO( get_tile_info ) VIDEO_START( orbit ) { - bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30); + orbit_state *state = (orbit_state *)machine->driver_data; + state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30); } -static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect) +static void draw_sprites( running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect ) { - const UINT8* p = orbit_sprite_ram; + orbit_state *state = (orbit_state *)machine->driver_data; + const UINT8* p = state->sprite_ram; int i; @@ -60,8 +55,8 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta ((flag & 0xc0) == 0x80) ? 1 : ((flag & 0xc0) == 0xc0) ? 2 : 0; - int flip_x = code & 0x40; - int flip_y = code & 0x80; + int flip_x = BIT(code, 6); + int flip_y = BIT(code, 7); int zoom_x = 0x10000; int zoom_y = 0x10000; @@ -86,9 +81,11 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta VIDEO_UPDATE( orbit ) { - orbit_flip_screen = input_port_read(screen->machine, "DSW2") & 8; + orbit_state *state = (orbit_state *)screen->machine->driver_data; - tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); + state->flip_screen = input_port_read(screen->machine, "DSW2") & 8; + + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); draw_sprites(screen->machine, bitmap, cliprect); return 0; diff --git a/src/mame/video/othldrby.c b/src/mame/video/othldrby.c index 15e1f81fb7b..9857694c0a0 100644 --- a/src/mame/video/othldrby.c +++ b/src/mame/video/othldrby.c @@ -1,17 +1,10 @@ #include "emu.h" +#include "includes/othldrby.h" - -#define VIDEORAM_SIZE 0x1c00 -#define SPRITERAM_START 0x1800 -#define SPRITERAM_SIZE (VIDEORAM_SIZE-SPRITERAM_START) - -static UINT16 *vram,*buf_spriteram,*buf_spriteram2; - -#define VREG_SIZE 18 -static UINT16 vreg[VREG_SIZE]; - -static tilemap_t *bg_tilemap[3]; +#define VIDEORAM_SIZE 0x1c00 +#define SPRITERAM_START 0x1800 +#define SPRITERAM_SIZE (VIDEORAM_SIZE - SPRITERAM_START) /*************************************************************************** @@ -20,15 +13,16 @@ static tilemap_t *bg_tilemap[3]; ***************************************************************************/ -INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int plane) +INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int plane ) { + othldrby_state *state = (othldrby_state *)machine->driver_data; UINT16 attr; - tile_index = 2*tile_index + 0x800*plane; - attr = vram[tile_index]; + tile_index = 2 * tile_index + 0x800 * plane; + attr = state->vram[tile_index]; SET_TILE_INFO( 1, - vram[tile_index+1], + state->vram[tile_index + 1], attr & 0x7f, 0); tileinfo->category = (attr & 0x0600) >> 9; @@ -36,17 +30,17 @@ INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_ static TILE_GET_INFO( get_tile_info0 ) { - get_tile_info(machine,tileinfo,tile_index,0); + get_tile_info(machine, tileinfo, tile_index, 0); } static TILE_GET_INFO( get_tile_info1 ) { - get_tile_info(machine,tileinfo,tile_index,1); + get_tile_info(machine, tileinfo, tile_index, 1); } static TILE_GET_INFO( get_tile_info2 ) { - get_tile_info(machine,tileinfo,tile_index,2); + get_tile_info(machine, tileinfo, tile_index, 2); } @@ -59,18 +53,22 @@ static TILE_GET_INFO( get_tile_info2 ) VIDEO_START( othldrby ) { - bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,16,16,32,32); - bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32); - bg_tilemap[2] = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32); + othldrby_state *state = (othldrby_state *)machine->driver_data; - vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE); - buf_spriteram = auto_alloc_array(machine, UINT16, 2*SPRITERAM_SIZE); + state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 16, 16, 32, 32); + state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 16, 32, 32); + state->bg_tilemap[2] = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 16, 32, 32); - buf_spriteram2 = buf_spriteram + SPRITERAM_SIZE; + state->vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE); + state->buf_spriteram = auto_alloc_array(machine, UINT16, 2 * SPRITERAM_SIZE); + state->buf_spriteram2 = state->buf_spriteram + SPRITERAM_SIZE; - tilemap_set_transparent_pen(bg_tilemap[0],0); - tilemap_set_transparent_pen(bg_tilemap[1],0); - tilemap_set_transparent_pen(bg_tilemap[2],0); + tilemap_set_transparent_pen(state->bg_tilemap[0], 0); + tilemap_set_transparent_pen(state->bg_tilemap[1], 0); + tilemap_set_transparent_pen(state->bg_tilemap[2], 0); + + state_save_register_global_pointer(machine, state->vram, VIDEORAM_SIZE); + state_save_register_global_pointer(machine, state->buf_spriteram, 2 * SPRITERAM_SIZE); } @@ -81,47 +79,53 @@ VIDEO_START( othldrby ) ***************************************************************************/ -static UINT32 vram_addr,vreg_addr; - WRITE16_HANDLER( othldrby_videoram_addr_w ) { - vram_addr = data; + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + state->vram_addr = data; } READ16_HANDLER( othldrby_videoram_r ) { - if (vram_addr < VIDEORAM_SIZE) - return vram[vram_addr++]; + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + + if (state->vram_addr < VIDEORAM_SIZE) + return state->vram[state->vram_addr++]; else { - popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr); + popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr); return 0; } } WRITE16_HANDLER( othldrby_videoram_w ) { - if (vram_addr < VIDEORAM_SIZE) + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + + if (state->vram_addr < VIDEORAM_SIZE) { - if (vram_addr < SPRITERAM_START) - tilemap_mark_tile_dirty(bg_tilemap[vram_addr/0x800],(vram_addr&0x7ff)/2); - vram[vram_addr++] = data; + if (state->vram_addr < SPRITERAM_START) + tilemap_mark_tile_dirty(state->bg_tilemap[state->vram_addr / 0x800], (state->vram_addr & 0x7ff) / 2); + state->vram[state->vram_addr++] = data; } else - popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr); + popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr); } WRITE16_HANDLER( othldrby_vreg_addr_w ) { - vreg_addr = data & 0x7f; /* bit 7 is set when screen is flipped */ + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + state->vreg_addr = data & 0x7f; /* bit 7 is set when screen is flipped */ } WRITE16_HANDLER( othldrby_vreg_w ) { - if (vreg_addr < VREG_SIZE) - vreg[vreg_addr++] = data; + othldrby_state *state = (othldrby_state *)space->machine->driver_data; + + if (state->vreg_addr < OTHLDRBY_VREG_SIZE) + state->vreg[state->vreg_addr++] = data; else - popmessage("%06x: VREG OUT OF BOUNDS %04x",cpu_get_pc(space->cpu),vreg_addr); + popmessage("%06x: VREG OUT OF BOUNDS %04x", cpu_get_pc(space->cpu), state->vreg_addr); } @@ -132,26 +136,27 @@ WRITE16_HANDLER( othldrby_vreg_w ) ***************************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int priority) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority ) { + othldrby_state *state = (othldrby_state *)machine->driver_data; int offs; - for (offs = 0;offs < SPRITERAM_SIZE;offs += 4) + for (offs = 0; offs < SPRITERAM_SIZE; offs += 4) { - int x,y,color,code,sx,sy,flipx,flipy,sizex,sizey,pri; + int x, y, color, code, sx, sy, flipx, flipy, sizex, sizey, pri; + pri = (state->buf_spriteram[offs] & 0x0600) >> 9; + if (pri != priority) + continue; - pri = (buf_spriteram[offs] & 0x0600) >> 9; - if (pri != priority) continue; - - flipx = buf_spriteram[offs] & 0x1000; + flipx = state->buf_spriteram[offs] & 0x1000; flipy = 0; - color = (buf_spriteram[offs] & 0x01fc) >> 2; - code = buf_spriteram[offs+1] | ((buf_spriteram[offs] & 0x0003) << 16); - sx = (buf_spriteram[offs+2] >> 7); - sy = (buf_spriteram[offs+3] >> 7); - sizex = (buf_spriteram[offs+2] & 0x000f) + 1; - sizey = (buf_spriteram[offs+3] & 0x000f) + 1; + color = (state->buf_spriteram[offs] & 0x01fc) >> 2; + code = state->buf_spriteram[offs + 1] | ((state->buf_spriteram[offs] & 0x0003) << 16); + sx = (state->buf_spriteram[offs + 2] >> 7); + sy = (state->buf_spriteram[offs + 3] >> 7); + sizex = (state->buf_spriteram[offs + 2] & 0x000f) + 1; + sizey = (state->buf_spriteram[offs + 3] & 0x000f) + 1; if (flip_screen_get(machine)) { @@ -161,15 +166,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan sy = 16 - sy; } - for (y = 0;y < sizey;y++) + for (y = 0; y < sizey; y++) { - for (x = 0;x < sizex;x++) + for (x = 0; x < sizex; x++) { drawgfx_transpen(bitmap,cliprect,machine->gfx[0], code + x + sizex * y, color, flipx,flipy, - (sx + (flipx ? (-8*(x+1)+1) : 8*x) - vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - vreg[7]-9) & 0x1ff,0); + (sx + (flipx ? (-8*(x+1)+1) : 8*x) - state->vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - state->vreg[7]-9) & 0x1ff,0); } } } @@ -177,47 +182,53 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( othldrby ) { + othldrby_state *state = (othldrby_state *)screen->machine->driver_data; int layer; + flip_screen_set(screen->machine, state->vreg[0x0f] & 0x80); - flip_screen_set(screen->machine, vreg[0x0f] & 0x80); - - for (layer = 0;layer < 3;layer++) + for (layer = 0; layer < 3; layer++) { if (flip_screen_get(screen->machine)) { - tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]+59); - tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+248); + tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] + 59); + tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer + 1] + 248); } else { - tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]-58); - tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+9); + tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] - 58); + tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer+1] + 9); } } - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); - bitmap_fill(bitmap,cliprect,0); + bitmap_fill(bitmap, cliprect, 0); + + for (layer = 0; layer < 3; layer++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 0, 0); + draw_sprites(screen->machine, bitmap, cliprect, 0); + + for (layer = 0; layer < 3; layer++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 1, 0); + draw_sprites(screen->machine, bitmap, cliprect, 1); + + for (layer = 0; layer < 3; layer++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 2, 0); + draw_sprites(screen->machine, bitmap, cliprect, 2); + + for (layer = 0; layer < 3; layer++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 3, 0); + draw_sprites(screen->machine, bitmap, cliprect, 3); - for (layer = 0;layer < 3;layer++) - tilemap_draw(bitmap,cliprect,bg_tilemap[layer],0,0); - draw_sprites(screen->machine,bitmap,cliprect,0); - for (layer = 0;layer < 3;layer++) - tilemap_draw(bitmap,cliprect,bg_tilemap[layer],1,0); - draw_sprites(screen->machine,bitmap,cliprect,1); - for (layer = 0;layer < 3;layer++) - tilemap_draw(bitmap,cliprect,bg_tilemap[layer],2,0); - draw_sprites(screen->machine,bitmap,cliprect,2); - for (layer = 0;layer < 3;layer++) - tilemap_draw(bitmap,cliprect,bg_tilemap[layer],3,0); - draw_sprites(screen->machine,bitmap,cliprect,3); return 0; } VIDEO_EOF( othldrby ) { + othldrby_state *state = (othldrby_state *)machine->driver_data; + /* sprites need to be delayed two frames */ - memcpy(buf_spriteram,buf_spriteram2,SPRITERAM_SIZE*sizeof(buf_spriteram[0])); - memcpy(buf_spriteram2,&vram[SPRITERAM_START],SPRITERAM_SIZE*sizeof(buf_spriteram[0])); + memcpy(state->buf_spriteram, state->buf_spriteram2, SPRITERAM_SIZE * sizeof(state->buf_spriteram[0])); + memcpy(state->buf_spriteram2, &state->vram[SPRITERAM_START], SPRITERAM_SIZE * sizeof(state->buf_spriteram[0])); }