diff --git a/.gitattributes b/.gitattributes index e8d56f08ef9..4acb8724c8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3824,6 +3824,8 @@ src/mame/video/ddribble.c svneol=native#text/plain src/mame/video/deadang.c svneol=native#text/plain src/mame/video/dec0.c svneol=native#text/plain src/mame/video/dec8.c svneol=native#text/plain +src/mame/video/decbac06.c svneol=native#text/plain +src/mame/video/decbac06.h svneol=native#text/plain src/mame/video/deco16ic.c svneol=native#text/plain src/mame/video/deco16ic.h svneol=native#text/plain src/mame/video/deco32.c svneol=native#text/plain diff --git a/src/mame/drivers/dec0.c b/src/mame/drivers/dec0.c index 0243acf11f4..946d6f4da46 100644 --- a/src/mame/drivers/dec0.c +++ b/src/mame/drivers/dec0.c @@ -39,6 +39,7 @@ Original Service Manuals and Service Mode (when available). ToDo: Hook up the 68705 in Midnight Resistance (bootleg) + (it might not be used, leftover from the Fighting Fantasy bootleg on the same PCB?) PCB Layouts @@ -160,7 +161,7 @@ Notes: #include "sound/3812intf.h" #include "sound/okim6295.h" #include "sound/msm5205.h" - +#include "video/decbac06.h" @@ -275,22 +276,25 @@ static WRITE16_HANDLER( midres_sound_w ) static ADDRESS_MAP_START( dec0_map, AS_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM - AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf1_control_0_w) /* text layer */ - AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_colscroll) - AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_rowscroll) + AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w) /* text layer */ + AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w) + AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) AM_RANGE(0x242800, 0x243fff) AM_RAM /* Robocop only */ - AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) - AM_RANGE(0x246000, 0x246007) AM_WRITE(dec0_pf2_control_0_w) /* first tile layer */ - AM_RANGE(0x246010, 0x246017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_colscroll) - AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_rowscroll) - AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) - AM_RANGE(0x24c000, 0x24c007) AM_WRITE(dec0_pf3_control_0_w) /* second tile layer */ - AM_RANGE(0x24c010, 0x24c017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) - AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) - AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) + AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + + AM_RANGE(0x246000, 0x246007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w) /* first tile layer */ + AM_RANGE(0x246010, 0x246017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w) + AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x24a000, 0x24a7ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + + AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w) /* second tile layer */ + AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w) + AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r) AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r) AM_RANGE(0x30c010, 0x30c01f) AM_WRITE(dec0_control_w) /* Priority, sound, etc. */ @@ -310,42 +314,190 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( hippodrm_sub_map, AS_PROGRAM, 8 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x180000, 0x1800ff) AM_READWRITE(hippodrm_shared_r, hippodrm_shared_w) - AM_RANGE(0x1a0000, 0x1a001f) AM_WRITE(dec0_pf3_control_8bit_w) - AM_RANGE(0x1a1000, 0x1a17ff) AM_READWRITE(dec0_pf3_data_8bit_r, dec0_pf3_data_8bit_w) + AM_RANGE(0x1a0000, 0x1a001f) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_8bit_w) + AM_RANGE(0x1a1000, 0x1a17ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_8bit_r, deco_bac06_pf_data_8bit_w) AM_RANGE(0x1d0000, 0x1d00ff) AM_READWRITE(hippodrm_prot_r, hippodrm_prot_w) AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8") /* Main ram */ AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w) AM_RANGE(0x1ff402, 0x1ff403) AM_READ_PORT("VBLANK") ADDRESS_MAP_END + + +READ16_HANDLER( slyspy_controls_r ) +{ + switch (offset<<1) + { + case 0: /* Dip Switches */ + return input_port_read(space->machine, "DSW"); + + case 2: /* Player 1 & Player 2 joysticks & fire buttons */ + return input_port_read(space->machine, "INPUTS"); + + case 4: /* Credits */ + return input_port_read(space->machine, "SYSTEM"); + } + + logerror("Unknown control read at 30c000 %d\n", offset); + return ~0; +} + +READ16_HANDLER( slyspy_protection_r ) +{ + /* These values are for Boulderdash, I have no idea what they do in Slyspy */ + switch (offset<<1) { + case 0: return 0; + case 2: return 0x13; + case 4: return 0; + case 6: return 0x2; + } + + logerror("%04x, Unknown protection read at 30c000 %d\n", cpu_get_pc(space->cpu), offset); + return 0; +} + + +/* + The memory map in Sly Spy can change between 4 states according to the protection! + + Default state (called by Traps 1, 3, 4, 7, C) + + 240000 - 24001f = control (Playfield 2 area) + 242000 - 24207f = colscroll + 242400 - 2425ff = rowscroll + 246000 - 2467ff = data + + 248000 - 24801f = control (Playfield 1 area) + 24c000 - 24c07f = colscroll + 24c400 - 24c4ff = rowscroll + 24e000 - 24e7ff = data + + State 1 (Called by Trap 9) uses this memory map: + + 248000 = pf1 data + 24c000 = pf2 data + + State 2 (Called by Trap A) uses this memory map: + + 240000 = pf2 data + 242000 = pf1 data + 24e000 = pf1 data + + State 3 (Called by Trap B) uses this memory map: + + 240000 = pf1 data + 248000 = pf2 data + +*/ + +static WRITE16_HANDLER( unmapped_w ) +{ + // fall through for unmapped protection areas + dec0_state *state = space->machine->driver_data(); + logerror("unmapped memory write to %04x = %04x in mode %d\n", 0x240000+offset*2, data, state->slyspy_state); +} + +void slyspy_set_protection_map(running_machine* machine, int type); + +WRITE16_HANDLER( slyspy_state_w ) +{ + dec0_state *state = space->machine->driver_data(); + state->slyspy_state=0; + slyspy_set_protection_map(space->machine, state->slyspy_state); +} + +READ16_HANDLER( slyspy_state_r ) +{ + dec0_state *state = space->machine->driver_data(); + state->slyspy_state++; + state->slyspy_state=state->slyspy_state%4; + slyspy_set_protection_map(space->machine, state->slyspy_state); + + return 0; /* Value doesn't mater */ +} + +void slyspy_set_protection_map(running_machine* machine, int type) +{ + address_space* space = machine->device("maincpu")->memory().space(AS_PROGRAM); + + deco_bac06_device *tilegen1 = (deco_bac06_device*)space->machine->device("tilegen1"); + deco_bac06_device *tilegen2 = (deco_bac06_device*)space->machine->device("tilegen2"); + + memory_install_write16_handler( space, 0x240000, 0x24ffff, 0, 0, unmapped_w); + + memory_install_write16_handler( space, 0x24a000, 0x24a001, 0, 0, slyspy_state_w); + memory_install_read16_handler( space, 0x244000, 0x244001, 0, 0, slyspy_state_r); + + switch (type) + { + + case 0: + memory_install_write16_device_handler( space, tilegen2, 0x240000, 0x240007, 0, 0, deco_bac06_pf_control_0_w); + memory_install_write16_device_handler( space, tilegen2, 0x240010, 0x240017, 0, 0, deco_bac06_pf_control_1_w); + + memory_install_write16_device_handler( space, tilegen2, 0x242000, 0x24207f, 0, 0, deco_bac06_pf_colscroll_w); + memory_install_write16_device_handler( space, tilegen2, 0x242400, 0x2427ff, 0, 0, deco_bac06_pf_rowscroll_w); + + memory_install_write16_device_handler( space, tilegen2, 0x246000, 0x247fff, 0, 0, deco_bac06_pf_data_w); + + memory_install_write16_device_handler( space, tilegen1, 0x248000, 0x280007, 0, 0, deco_bac06_pf_control_0_w); + memory_install_write16_device_handler( space, tilegen1, 0x248010, 0x280017, 0, 0, deco_bac06_pf_control_1_w); + + memory_install_write16_device_handler( space, tilegen1, 0x24c000, 0x24c07f, 0, 0, deco_bac06_pf_colscroll_w); + memory_install_write16_device_handler( space, tilegen1, 0x24c400, 0x24c7ff, 0, 0, deco_bac06_pf_rowscroll_w); + + memory_install_write16_device_handler( space, tilegen1, 0x24e000, 0x24ffff, 0, 0, deco_bac06_pf_data_w); + + break; + + case 1: + // 0x240000 - 0x241fff not mapped + // 0x242000 - 0x243fff not mapped + // 0x246000 - 0x247fff not mapped + memory_install_write16_device_handler( space, tilegen1, 0x248000, 0x249fff, 0, 0, deco_bac06_pf_data_w); + memory_install_write16_device_handler( space, tilegen2, 0x24c000, 0x24dfff, 0, 0, deco_bac06_pf_data_w); + // 0x24e000 - 0x24ffff not mapped + break; + + case 2: + memory_install_write16_device_handler( space, tilegen2, 0x240000, 0x241fff, 0, 0, deco_bac06_pf_data_w); + memory_install_write16_device_handler( space, tilegen1, 0x242000, 0x243fff, 0, 0, deco_bac06_pf_data_w); + // 0x242000 - 0x243fff not mapped + // 0x246000 - 0x247fff not mapped + // 0x248000 - 0x249fff not mapped + // 0x24c000 - 0x24dfff not mapped + memory_install_write16_device_handler( space, tilegen1, 0x24e000, 0x24ffff, 0, 0, deco_bac06_pf_data_w); + break; + + case 3: + memory_install_write16_device_handler( space, tilegen1, 0x240000, 0x241fff, 0, 0, deco_bac06_pf_data_w); + // 0x242000 - 0x243fff not mapped + // 0x246000 - 0x247fff not mapped + memory_install_write16_device_handler( space, tilegen2, 0x248000, 0x249fff, 0, 0, deco_bac06_pf_data_w); + // 0x24c000 - 0x24dfff not mapped + // 0x24e000 - 0x24ffff not mapped + break; + } + +} + + + + + + + static ADDRESS_MAP_START( slyspy_map, AS_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM - /* These locations aren't real! They are just there so memory is allocated */ - AM_RANGE(0x200000, 0x2007ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_data) - AM_RANGE(0x202000, 0x203fff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_data) - AM_RANGE(0x232000, 0x23207f) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_colscroll) - AM_RANGE(0x232400, 0x2327ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_rowscroll) - AM_RANGE(0x23c000, 0x23c07f) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_colscroll) - AM_RANGE(0x23c400, 0x23c7ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_rowscroll) - - AM_RANGE(0x244000, 0x244001) AM_READ(slyspy_state_r) AM_WRITENOP /* protection */ - - /* The location of p1 & pf2 can change between these according to protection */ - AM_RANGE(0x240000, 0x241fff) AM_WRITE(slyspy_240000_w) - AM_RANGE(0x242000, 0x243fff) AM_WRITE(slyspy_242000_w) - AM_RANGE(0x246000, 0x247fff) AM_WRITE(slyspy_246000_w) - AM_RANGE(0x248000, 0x249fff) AM_WRITE(slyspy_248000_w) - AM_RANGE(0x24a000, 0x24a001) AM_WRITE(slyspy_state_w) /* Protection */ - AM_RANGE(0x24c000, 0x24dfff) AM_WRITE(slyspy_24c000_w) - AM_RANGE(0x24e000, 0x24ffff) AM_WRITE(slyspy_24e000_w) - + /* The location of p1 & pf2 can change in the 240000 - 24ffff region according to protection */ + /* Pf3 is unaffected by protection */ - AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf3_control_0_w) - AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x300800, 0x30087f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_colscroll) - AM_RANGE(0x300c00, 0x300fff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) - AM_RANGE(0x301000, 0x3017ff) AM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) + AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w) + AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w) + AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w) AM_RANGE(0x304000, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Sly spy main ram */ AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_BASE_MEMBER(dec0_state, spriteram) /* Sprites */ @@ -355,6 +507,7 @@ static ADDRESS_MAP_START( slyspy_map, AS_PROGRAM, 16 ) AM_RANGE(0x31c000, 0x31c00f) AM_READ(slyspy_protection_r) AM_WRITENOP ADDRESS_MAP_END + static ADDRESS_MAP_START( midres_map, AS_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) @@ -365,24 +518,24 @@ static ADDRESS_MAP_START( midres_map, AS_PROGRAM, 16 ) AM_RANGE(0x180008, 0x18000f) AM_WRITENOP /* ?? watchdog ?? */ AM_RANGE(0x1a0000, 0x1a0001) AM_WRITE(midres_sound_w) - AM_RANGE(0x200000, 0x200007) AM_WRITE(dec0_pf2_control_0_w) - AM_RANGE(0x200010, 0x200017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x220000, 0x2207ff) AM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) - AM_RANGE(0x220800, 0x220fff) AM_WRITE(dec0_pf2_data_w) /* mirror address used in end sequence */ - AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_colscroll) - AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_rowscroll) + AM_RANGE(0x200000, 0x200007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w) + AM_RANGE(0x200010, 0x200017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w) + AM_RANGE(0x220000, 0x2207ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + AM_RANGE(0x220800, 0x220fff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w) /* mirror address used in end sequence */ + AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) - AM_RANGE(0x280000, 0x280007) AM_WRITE(dec0_pf3_control_0_w) - AM_RANGE(0x280010, 0x280017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x2a0000, 0x2a07ff) AM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) - AM_RANGE(0x2c0000, 0x2c007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) - AM_RANGE(0x2c0400, 0x2c07ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_rowscroll) + AM_RANGE(0x280000, 0x280007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w) + AM_RANGE(0x280010, 0x280017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w) + AM_RANGE(0x2a0000, 0x2a07ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + AM_RANGE(0x2c0000, 0x2c007f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x2c0400, 0x2c07ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) - AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf1_control_0_w) - AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x320000, 0x321fff) AM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) - AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_colscroll) - AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_rowscroll) + AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w) + AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w) + AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) AM_RANGE(0x320000, 0x321fff) AM_RAM ADDRESS_MAP_END @@ -421,55 +574,59 @@ static ADDRESS_MAP_START( midres_s_map, AS_PROGRAM, 8 ) ADDRESS_MAP_END + + + static ADDRESS_MAP_START( secretab_map, AS_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM - AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf2_control_0_w) - AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x246000, 0x247fff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) -// AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_colscroll) -// AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_rowscroll) + AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w) + AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w) + AM_RANGE(0x246000, 0x247fff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w) +// AM_RANGE(0x240000, 0x24007f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) +// AM_RANGE(0x240400, 0x2407ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) -// AM_RANGE(0x200000, 0x300007) AM_WRITE(dec0_pf1_control_0_w) -// AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x24e000, 0x24ffff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) -// AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_colscroll) -// AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_rowscroll) +// AM_RANGE(0x200000, 0x300007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w) +// AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w) + AM_RANGE(0x24e000, 0x24ffff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w) +// AM_RANGE(0x340000, 0x34007f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) +// AM_RANGE(0x340400, 0x3407ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) AM_RANGE(0x314008, 0x31400f) AM_READ(slyspy_controls_r) // AM_RANGE(0x314000, 0x314003) AM_WRITE(slyspy_control_w) - AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf3_control_0_w) - AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x300800, 0x30087f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) - AM_RANGE(0x300c00, 0x300fff) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_rowscroll) - AM_RANGE(0x301000, 0x3017ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) + AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w) + AM_RANGE(0x300010, 0x300017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w) + AM_RANGE(0x300800, 0x30087f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x300c00, 0x300fff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x301000, 0x3017ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w) AM_RANGE(0x301800, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Sly spy main ram */ AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xb08000, 0xb087ff) AM_RAM AM_BASE_MEMBER(dec0_state, spriteram) /* Sprites */ ADDRESS_MAP_END + static ADDRESS_MAP_START( automat_map, AS_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM - AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf1_control_0_w) /* text layer */ - AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_colscroll) - AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_rowscroll) - + AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w) /* text layer */ + AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w) + AM_RANGE(0x242000, 0x24207f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x242400, 0x2427ff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) AM_RANGE(0x242800, 0x243fff) AM_RAM /* Robocop only */ - AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) + AM_RANGE(0x244000, 0x245fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w) - AM_RANGE(0x246000, 0x246007) AM_WRITE(dec0_pf2_control_0_w) /* first tile layer */ - AM_RANGE(0x246010, 0x246017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_colscroll) - AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_rowscroll) + AM_RANGE(0x246000, 0x246007) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_0_w) /* first tile layer */ + AM_RANGE(0x246010, 0x246017) AM_DEVWRITE("tilegen2", deco_bac06_pf_control_1_w) + AM_RANGE(0x248000, 0x24807f) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x248400, 0x2487ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x24a000, 0x24a7ff) AM_DEVREADWRITE("tilegen2", deco_bac06_pf_data_r, deco_bac06_pf_data_w) + + AM_RANGE(0x24c000, 0x24c007) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_0_w) /* second tile layer */ + AM_RANGE(0x24c010, 0x24c017) AM_DEVWRITE("tilegen3", deco_bac06_pf_control_1_w) + AM_RANGE(0x24c800, 0x24c87f) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_colscroll_r, deco_bac06_pf_colscroll_w) + AM_RANGE(0x24cc00, 0x24cfff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_rowscroll_r, deco_bac06_pf_rowscroll_w) + AM_RANGE(0x24d000, 0x24d7ff) AM_DEVREADWRITE("tilegen3", deco_bac06_pf_data_r, deco_bac06_pf_data_w) - AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) - AM_RANGE(0x24c000, 0x24c007) AM_WRITE(dec0_pf3_control_0_w) /* second tile layer */ - AM_RANGE(0x24c010, 0x24c017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) - AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) - AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r) AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r) AM_RANGE(0x30c000, 0x30c01f) AM_WRITE(automat_control_w) /* Priority, sound, etc. */ @@ -1140,7 +1297,40 @@ static const msm5205_interface msm5205_config = }; -static MACHINE_CONFIG_START( automat, dec0_state ) +static MACHINE_CONFIG_START( dec0_base, dec0_state ) + MCFG_GFXDECODE(dec0) + MCFG_PALETTE_LENGTH(1024) + + MCFG_DEVICE_ADD("tilegen1", deco_bac06_, 0) + deco_bac06_device_config::set_gfx_region(device, 0,0); + MCFG_DEVICE_ADD("tilegen2", deco_bac06_, 0) + deco_bac06_device_config::set_gfx_region(device, 0,1); + MCFG_DEVICE_ADD("tilegen3", deco_bac06_, 0) + deco_bac06_device_config::set_gfx_region(device, 0,2); + + MCFG_VIDEO_START(dec0) +MACHINE_CONFIG_END + +static MACHINE_CONFIG_DERIVED( dec0_base_sound, dec0_base ) + /* sound hardware */ + MCFG_SPEAKER_STANDARD_MONO("mono") + + MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) + MCFG_SOUND_ROUTE(0, "mono", 0.90) + MCFG_SOUND_ROUTE(1, "mono", 0.90) + MCFG_SOUND_ROUTE(2, "mono", 0.90) + MCFG_SOUND_ROUTE(3, "mono", 0.35) + + MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) + MCFG_SOUND_CONFIG(ym3812_config) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) + + MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) +MACHINE_CONFIG_END + + +static MACHINE_CONFIG_DERIVED( automat, dec0_base ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 10000000) @@ -1160,12 +1350,10 @@ static MACHINE_CONFIG_START( automat, dec0_state ) MCFG_SCREEN_UPDATE(robocop) MCFG_GFXDECODE(automat) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") + MCFG_SOUND_ADD("ym1", YM2203, 1500000) MCFG_SOUND_ROUTE(0, "mono", 0.90) MCFG_SOUND_ROUTE(1, "mono", 0.90) @@ -1184,7 +1372,7 @@ static MACHINE_CONFIG_START( automat, dec0_state ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( hbarrel, dec0_state ) +static MACHINE_CONFIG_DERIVED( hbarrel, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1205,30 +1393,9 @@ static MACHINE_CONFIG_START( hbarrel, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(hbarrel) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( baddudes, dec0_state ) +static MACHINE_CONFIG_DERIVED( baddudes, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1246,30 +1413,9 @@ static MACHINE_CONFIG_START( baddudes, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(baddudes) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( birdtry, dec0_state ) +static MACHINE_CONFIG_DERIVED( birdtry, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1287,30 +1433,9 @@ static MACHINE_CONFIG_START( birdtry, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(birdtry) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( robocop, dec0_state ) +static MACHINE_CONFIG_DERIVED( robocop, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1333,30 +1458,9 @@ static MACHINE_CONFIG_START( robocop, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(robocop) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( robocopb, dec0_state ) +static MACHINE_CONFIG_DERIVED( robocopb, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 10000000) @@ -1374,30 +1478,9 @@ static MACHINE_CONFIG_START( robocopb, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(robocop) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, 1500000) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, 3000000) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( hippodrm, dec0_state ) +static MACHINE_CONFIG_DERIVED( hippodrm, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1420,30 +1503,15 @@ static MACHINE_CONFIG_START( hippodrm, dec0_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(hippodrm) - - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - - MCFG_VIDEO_START(dec0) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz / 4) - MCFG_SOUND_CONFIG(ym3812_config) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( slyspy, dec0_state ) +static MACHINE_RESET( slyspy ) +{ + // set initial memory map + slyspy_set_protection_map(machine, 0); +} + +static MACHINE_CONFIG_DERIVED( slyspy, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ @@ -1462,29 +1530,14 @@ static MACHINE_CONFIG_START( slyspy, dec0_state ) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_UPDATE(slyspy) - MCFG_GFXDECODE(dec0) - MCFG_PALETTE_LENGTH(1024) - MCFG_VIDEO_START(dec0_nodma) - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz/8) /* verified on pcb */ - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz/4) /* verified on pcb */ - MCFG_SOUND_CONFIG(ym3812b_interface) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) + MCFG_MACHINE_RESET(slyspy) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( secretab, dec0_state ) + + +static MACHINE_CONFIG_DERIVED( secretab, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ @@ -1505,28 +1558,10 @@ static MACHINE_CONFIG_START( secretab, dec0_state ) MCFG_SCREEN_UPDATE(robocop) MCFG_GFXDECODE(secretab) - MCFG_PALETTE_LENGTH(1024) - MCFG_VIDEO_START(dec0_nodma) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz/8) /* verified on pcb */ - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz/4) /* verified on pcb */ - MCFG_SOUND_CONFIG(ym3812b_interface) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( midres, dec0_state ) +static MACHINE_CONFIG_DERIVED( midres, dec0_base_sound ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ @@ -1546,25 +1581,7 @@ static MACHINE_CONFIG_START( midres, dec0_state ) MCFG_SCREEN_UPDATE(midres) MCFG_GFXDECODE(midres) - MCFG_PALETTE_LENGTH(1024) - MCFG_VIDEO_START(dec0_nodma) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("ym1", YM2203, XTAL_24MHz/16) /* verified on pcb */ - MCFG_SOUND_ROUTE(0, "mono", 0.90) - MCFG_SOUND_ROUTE(1, "mono", 0.90) - MCFG_SOUND_ROUTE(2, "mono", 0.90) - MCFG_SOUND_ROUTE(3, "mono", 0.35) - - MCFG_SOUND_ADD("ym2", YM3812, XTAL_24MHz/8) /* verified on pcb */ - MCFG_SOUND_CONFIG(ym3812b_interface) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - - MCFG_OKIM6295_ADD("oki", XTAL_1MHz, OKIM6295_PIN7_HIGH) /* verified on pcb (1mhz crystal) */ - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.40) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( midresb, midres ) diff --git a/src/mame/includes/darkseal.h b/src/mame/includes/darkseal.h index 2d3c1087133..f0d6422b373 100644 --- a/src/mame/includes/darkseal.h +++ b/src/mame/includes/darkseal.h @@ -5,26 +5,19 @@ class darkseal_state : public driver_device public: darkseal_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config), - deco_tilegen1(*this, "tilegen1"), + deco_tilegen1(*this, "tilegen1"), deco_tilegen2(*this, "tilegen2") { } UINT16 *ram; - UINT16 *pf12_row; - UINT16 *pf34_row; - UINT16 *pf1_data; - UINT16 *pf2_data; - UINT16 *pf3_data; - UINT16 control_0[8]; - UINT16 control_1[8]; - tilemap_t *pf1_tilemap; - tilemap_t *pf2_tilemap; - tilemap_t *pf3_tilemap; UINT16 *pf1_rowscroll; + //UINT16 *pf2_rowscroll; UINT16 *pf3_rowscroll; - int flipscreen; - + //UINT16 *pf4_rowscroll; + required_device deco_tilegen1; required_device deco_tilegen2; + + int flipscreen; }; @@ -33,11 +26,5 @@ public: VIDEO_START( darkseal ); SCREEN_UPDATE( darkseal ); -WRITE16_HANDLER( darkseal_pf1_data_w ); -WRITE16_HANDLER( darkseal_pf2_data_w ); -WRITE16_HANDLER( darkseal_pf3_data_w ); -WRITE16_HANDLER( darkseal_pf3b_data_w ); -WRITE16_HANDLER( darkseal_control_0_w ); -WRITE16_HANDLER( darkseal_control_1_w ); WRITE16_HANDLER( darkseal_palette_24bit_rg_w ); WRITE16_HANDLER( darkseal_palette_24bit_b_w ); diff --git a/src/mame/includes/dec0.h b/src/mame/includes/dec0.h index df515e52ca7..c6314930620 100644 --- a/src/mame/includes/dec0.h +++ b/src/mame/includes/dec0.h @@ -8,15 +8,7 @@ public: int automat_msm5205_vclk_toggle; UINT16 *ram; UINT8 *robocop_shared_ram; - UINT16 *pf1_rowscroll; - UINT16 *pf2_rowscroll; - UINT16 *pf3_rowscroll; - UINT16 *pf1_colscroll; - UINT16 *pf2_colscroll; - UINT16 *pf3_colscroll; - UINT16 *pf1_data; - UINT16 *pf2_data; - UINT16 *pf3_data; + int GAME; int i8751_return; int i8751_command; @@ -25,25 +17,10 @@ public: int hippodrm_msb; int hippodrm_lsb; UINT8 i8751_ports[4]; - tilemap_t *pf1_tilemap_0; - tilemap_t *pf1_tilemap_1; - tilemap_t *pf1_tilemap_2; - tilemap_t *pf2_tilemap_0; - tilemap_t *pf2_tilemap_1; - tilemap_t *pf2_tilemap_2; - tilemap_t *pf3_tilemap_0; - tilemap_t *pf3_tilemap_1; - tilemap_t *pf3_tilemap_2; - UINT16 pf1_control_0[4]; - UINT16 pf1_control_1[4]; - UINT16 pf2_control_0[4]; - UINT16 pf2_control_1[4]; - UINT16 pf3_control_0[4]; - UINT16 pf3_control_1[4]; + UINT16 *spriteram; UINT16 *buffered_spriteram; UINT16 pri; - int buffer[0x20]; }; @@ -60,16 +37,6 @@ SCREEN_UPDATE( hippodrm ); SCREEN_UPDATE( slyspy ); SCREEN_UPDATE( midres ); - -WRITE16_HANDLER( dec0_pf1_control_0_w ); -WRITE16_HANDLER( dec0_pf1_control_1_w ); -WRITE16_HANDLER( dec0_pf1_data_w ); -WRITE16_HANDLER( dec0_pf2_control_0_w ); -WRITE16_HANDLER( dec0_pf2_control_1_w ); -WRITE16_HANDLER( dec0_pf2_data_w ); -WRITE16_HANDLER( dec0_pf3_control_0_w ); -WRITE16_HANDLER( dec0_pf3_control_1_w ); -WRITE16_HANDLER( dec0_pf3_data_w ); WRITE16_HANDLER( dec0_priority_w ); WRITE16_HANDLER( dec0_update_sprites_w ); @@ -86,15 +53,6 @@ READ16_HANDLER( dec0_controls_r ); READ16_HANDLER( dec0_rotary_r ); READ16_HANDLER( midres_controls_r ); READ16_HANDLER( slyspy_controls_r ); -READ16_HANDLER( slyspy_protection_r ); -WRITE16_HANDLER( slyspy_state_w ); -READ16_HANDLER( slyspy_state_r ); -WRITE16_HANDLER( slyspy_240000_w ); -WRITE16_HANDLER( slyspy_242000_w ); -WRITE16_HANDLER( slyspy_246000_w ); -WRITE16_HANDLER( slyspy_248000_w ); -WRITE16_HANDLER( slyspy_24c000_w ); -WRITE16_HANDLER( slyspy_24e000_w ); DRIVER_INIT( slyspy ); DRIVER_INIT( hippodrm ); diff --git a/src/mame/includes/sshangha.h b/src/mame/includes/sshangha.h index c84c7582134..a871de0f751 100644 --- a/src/mame/includes/sshangha.h +++ b/src/mame/includes/sshangha.h @@ -10,20 +10,11 @@ public: UINT16 *prot_data; UINT16 *sound_shared_ram; - UINT16 *pf1_data; - UINT16 *pf2_data; - UINT16 *pf1_rowscroll; - UINT16 *pf2_rowscroll; - UINT16 control_0[8]; - tilemap_t *pf1_8x8_tilemap; - tilemap_t *pf1_16x16_tilemap; - tilemap_t *pf2_tilemap; - int pf1_bank; - int pf2_bank; int video_control; - int last_pf1_bank; - int last_pf2_bank; + UINT16* pf1_rowscroll; + UINT16* pf2_rowscroll; + UINT16* sprite_paletteram; UINT16* sprite_paletteram2; UINT16* tile_paletteram1; diff --git a/src/mame/machine/dec0.c b/src/mame/machine/dec0.c index 8124c97111e..d9b091e0f40 100644 --- a/src/mame/machine/dec0.c +++ b/src/mame/machine/dec0.c @@ -87,174 +87,6 @@ READ16_HANDLER( midres_controls_r ) /******************************************************************************/ -READ16_HANDLER( slyspy_controls_r ) -{ - switch (offset<<1) - { - case 0: /* Dip Switches */ - return input_port_read(space->machine, "DSW"); - - case 2: /* Player 1 & Player 2 joysticks & fire buttons */ - return input_port_read(space->machine, "INPUTS"); - - case 4: /* Credits */ - return input_port_read(space->machine, "SYSTEM"); - } - - logerror("Unknown control read at 30c000 %d\n", offset); - return ~0; -} - -READ16_HANDLER( slyspy_protection_r ) -{ - /* These values are for Boulderdash, I have no idea what they do in Slyspy */ - switch (offset<<1) { - case 0: return 0; - case 2: return 0x13; - case 4: return 0; - case 6: return 0x2; - } - - logerror("%04x, Unknown protection read at 30c000 %d\n", cpu_get_pc(space->cpu), offset); - return 0; -} - -/* - The memory map in Sly Spy can change between 4 states according to the protection! - - Default state (called by Traps 1, 3, 4, 7, C) - - 240000 - 24001f = control (Playfield 2 area) - 242000 - 24207f = colscroll - 242400 - 2425ff = rowscroll - 246000 - 2467ff = data - - 248000 - 24801f = control (Playfield 1 area) - 24c000 - 24c07f = colscroll - 24c400 - 24c4ff = rowscroll - 24e000 - 24e7ff = data - - State 1 (Called by Trap 9) uses this memory map: - - 248000 = pf1 data - 24c000 = pf2 data - - State 2 (Called by Trap A) uses this memory map: - - 240000 = pf2 data - 242000 = pf1 data - 24e000 = pf1 data - - State 3 (Called by Trap B) uses this memory map: - - 240000 = pf1 data - 248000 = pf2 data - -*/ - -WRITE16_HANDLER( slyspy_state_w ) -{ - dec0_state *state = space->machine->driver_data(); - state->slyspy_state=0; -} - -READ16_HANDLER( slyspy_state_r ) -{ - dec0_state *state = space->machine->driver_data(); - state->slyspy_state++; - state->slyspy_state=state->slyspy_state%4; - return 0; /* Value doesn't mater */ -} - -WRITE16_HANDLER( slyspy_240000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x3: - dec0_pf1_data_w(space,offset,data,mem_mask); - return; - case 0x2: - dec0_pf2_data_w(space,offset,data,mem_mask); - return; - case 0x0: - if (offset<0x8) dec0_pf2_control_0_w(space,offset,data,mem_mask); - else if (offset<0x10) dec0_pf2_control_1_w(space,offset-0x8,data,mem_mask); - return; - } - logerror("Wrote to 240000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - -WRITE16_HANDLER( slyspy_242000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x2: /* Trap A */ - dec0_pf1_data_w(space,offset,data,mem_mask); - return; - case 0x0: /* Trap C */ - if (offset<0x40) COMBINE_DATA(&state->pf2_colscroll[offset]); - else if (offset<0x300) COMBINE_DATA(&state->pf2_rowscroll[offset-0x200]); - return; - } - logerror("Wrote to 242000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - -WRITE16_HANDLER( slyspy_246000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x0: - dec0_pf2_data_w(space,offset,data,mem_mask); - return; - } - logerror("Wrote to 246000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - -WRITE16_HANDLER( slyspy_248000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x1: - dec0_pf1_data_w(space,offset,data,mem_mask); - return; - case 0x3: - dec0_pf2_data_w(space,offset,data,mem_mask); - return; - case 0x0: - if (offset<0x8) dec0_pf1_control_0_w(space,offset,data,mem_mask); - else if (offset<0x10) dec0_pf1_control_1_w(space,offset-0x8,data,mem_mask); - return; - } - logerror("Wrote to 248000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - -WRITE16_HANDLER( slyspy_24c000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x1: /* Trap 9 */ - dec0_pf2_data_w(space,offset,data,mem_mask); - return; - case 0x0: /* Trap C */ - if (offset<0x40) COMBINE_DATA(&state->pf1_colscroll[offset]); - else if (offset<0x300) COMBINE_DATA(&state->pf1_rowscroll[offset-0x200]); - return; - } - logerror("Wrote to 24c000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - -WRITE16_HANDLER( slyspy_24e000_w ) -{ - dec0_state *state = space->machine->driver_data(); - switch (state->slyspy_state) { - case 0x2: - case 0x0: - dec0_pf1_data_w(space,offset,data,mem_mask); - return; - } - logerror("Wrote to 24e000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); -} - /******************************************************************************/ diff --git a/src/mame/video/dec0.c b/src/mame/video/dec0.c index b1b88ec9529..6900907863a 100644 --- a/src/mame/video/dec0.c +++ b/src/mame/video/dec0.c @@ -39,53 +39,6 @@ Bad Dudes, Robocop, Heavy Barrel, Hippodrome - 24 bit rgb Sly Spy, Midnight Resistance - 12 bit rgb - Tile data - - 4 bit palette select, 12 bit tile select - -********************************************************************** - - All games contain three BAC06 background generator chips, usual (software) -configuration is 2 chips of 16*16 tiles, 1 of 8*8. - - Playfield control registers: - bank 0: - 0: - bit 0 (0x1) set = 8*8 tiles, else 16*16 tiles - Bit 1 (0x2) unknown - bit 2 (0x4) set enables rowscroll - bit 3 (0x8) set enables colscroll - bit 7 (0x80) set in playfield 1 is reverse screen (set via dip-switch) - bit 7 (0x80) in other playfields unknown - 2: unknown (00 in bg, 03 in fg+text - maybe controls pf transparency?) - 4: unknown (always 00) [Used to access 2nd bank of tiles in Stadium Hero) - 6: playfield shape: 00 = 4x1, 01 = 2x2, 02 = 1x4 (low 4 bits only) - - bank 1: - 0: horizontal scroll - 2: vertical scroll - 4: colscroll shifter (low 4 bits, top 4 bits do nothing) - 6: rowscroll shifter (low 4 bits, top 4 bits do nothing) - - Row & column scroll can be applied simultaneously or by themselves. - The shift register controls the granularity of the scroll offsets - (more details given later). - -Playfield priority (Bad Dudes, etc): - In the bottommost playfield, pens 8-15 can have priority over the next playfield. - In that next playfield, pens 8-15 can have priority over sprites. - -Bit 0: Playfield inversion -Bit 1: Enable playfield mixing (for palettes 8-15 only) -Bit 2: Enable playfield/sprite mixing (for palettes 8-15 only) - -Priority word (Midres): - Bit 0 set = Playfield 3 drawn over Playfield 2 - ~ = Playfield 2 drawn over Playfield 3 - Bit 1 set = Sprites are drawn inbetween playfields - ~ = Sprites are on top of playfields - Bit 2 - Bit 3 set = ... Todo: Implement multi-width sprites (used by Birdtry). @@ -96,7 +49,7 @@ Todo: #include "emu.h" #include "includes/dec0.h" - +#include "video/decbac06.h" /******************************************************************************/ @@ -201,157 +154,21 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan } } -/******************************************************************************/ - -static void custom_tilemap_draw(running_machine *machine, - bitmap_t *bitmap, - const rectangle *cliprect, - tilemap_t *tilemap_ptr, - const UINT16 *rowscroll_ptr, - const UINT16 *colscroll_ptr, - const UINT16 *control0, - const UINT16 *control1, - int flags) -{ - const bitmap_t *src_bitmap = tilemap_get_pixmap(tilemap_ptr); - int x, y, p; - int column_offset=0, src_x=0, src_y=0; - UINT32 scrollx=control1[0]; - UINT32 scrolly=control1[1]; - int width_mask; - int height_mask; - int row_scroll_enabled = (rowscroll_ptr && (control0[0]&0x4)); - int col_scroll_enabled = (colscroll_ptr && (control0[0]&0x8)); - - if (!src_bitmap) - return; - - width_mask = src_bitmap->width - 1; - height_mask = src_bitmap->height - 1; - - /* Column scroll & row scroll may per applied per pixel, there are - shift registers for each which control the granularity of the row/col - offset (down to per line level for row, and per 8 lines for column). - - Nb: The row & col selectors are _not_ affected by the shape of the - playfield (ie, 256*1024, 512*512 or 1024*256). So even if the tilemap - width is only 256, 'src_x' should not wrap at 256 in the code below (to - do so would mean the top half of row RAM would never be accessed which - is incorrect). - - Nb2: Real hardware exhibits a strange bug with column scroll on 'mode 2' - (256*1024) - the first column has a strange additional offset, but - curiously the first 'wrap' (at scroll offset 256) does not have this offset, - it is displayed as expected. The bug is confimed to only affect this mode, - the other two modes work as expected. This bug is not emulated, as it - doesn't affect any games. - */ - - if (flip_screen_get(machine)) - src_y = (src_bitmap->height - 256) - scrolly; - else - src_y = scrolly; - - for (y=0; y<=cliprect->max_y; y++) { - if (row_scroll_enabled) - src_x=scrollx + rowscroll_ptr[(src_y >> (control1[3]&0xf))&(0x1ff>>(control1[3]&0xf))]; - else - src_x=scrollx; - - if (flip_screen_get(machine)) - src_x=(src_bitmap->width - 256) - src_x; - - for (x=0; x<=cliprect->max_x; x++) { - if (col_scroll_enabled) - column_offset=colscroll_ptr[((src_x >> 3) >> (control1[2]&0xf))&(0x3f>>(control1[2]&0xf))]; - - p = *BITMAP_ADDR16(src_bitmap, (src_y + column_offset)&height_mask, src_x&width_mask); - - src_x++; - if ((flags&TILEMAP_DRAW_OPAQUE) || (p&0xf)) - { - if( flags & TILEMAP_DRAW_LAYER0 ) - { - /* Top 8 pens of top 8 palettes only */ - if ((p&0x88)==0x88) - *BITMAP_ADDR16(bitmap, y, x) = p; - } - else - *BITMAP_ADDR16(bitmap, y, x) = p; - } - } - src_y++; - } -} - -/******************************************************************************/ - -static void dec0_pf1_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) -{ - dec0_state *state = machine->driver_data(); - switch (state->pf1_control_0[3]&0x3) { - case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_0,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); - break; - case 1: /* 2x2 */ - default: - custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_1,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); - break; - case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_2,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); - break; - }; -} - -static void dec0_pf2_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) -{ - dec0_state *state = machine->driver_data(); - switch (state->pf2_control_0[3]&0x3) { - case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_0,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); - break; - case 1: /* 2x2 */ - default: - custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_1,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); - break; - case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_2,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); - break; - }; -} - -static void dec0_pf3_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) -{ - dec0_state *state = machine->driver_data(); - switch (state->pf3_control_0[3]&0x3) { - case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_0,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); - break; - case 1: /* 2x2 */ - default: - custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_1,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); - break; - case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_2,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); - break; - }; -} /******************************************************************************/ SCREEN_UPDATE( hbarrel ) { - dec0_state *state = screen->machine->driver_data(); - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); draw_sprites(screen->machine,bitmap,cliprect,0x08,0x08); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); /* HB always keeps pf2 on top of pf3, no need explicitly support priority register */ draw_sprites(screen->machine,bitmap,cliprect,0x08,0x00); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -360,37 +177,37 @@ SCREEN_UPDATE( hbarrel ) SCREEN_UPDATE( baddudes ) { dec0_state *state = screen->machine->driver_data(); - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); /* WARNING: inverted wrt Midnight Resistance */ if ((state->pri & 0x01) == 0) { - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - dec0_pf3_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); if (state->pri & 2) - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); if (state->pri & 4) - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ } else { - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); if (state->pri & 2) - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); if (state->pri & 4) - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ } - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -401,7 +218,7 @@ SCREEN_UPDATE( robocop ) dec0_state *state = screen->machine->driver_data(); int trans; - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); if (state->pri & 0x04) trans = 0x08; @@ -414,21 +231,21 @@ SCREEN_UPDATE( robocop ) /* Robocop uses it only for the title screen, so this might be just */ /* completely wrong. The top 8 bits of the register might mean */ /* something (they are 0x80 in midres, 0x00 here) */ - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER1|TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER1|TILEMAP_DRAW_OPAQUE); if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); - dec0_pf3_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } else { - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } if (state->pri & 0x02) @@ -436,7 +253,7 @@ SCREEN_UPDATE( robocop ) else draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -444,15 +261,14 @@ SCREEN_UPDATE( robocop ) SCREEN_UPDATE( birdtry ) { - dec0_state *state = screen->machine->driver_data(); - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); /* This game doesn't have the extra playfield chip on the game board, but the palette does show through. */ bitmap_fill(bitmap,cliprect,screen->machine->pens[768]); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -461,21 +277,21 @@ SCREEN_UPDATE( birdtry ) SCREEN_UPDATE( hippodrm ) { dec0_state *state = screen->machine->driver_data(); - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); if (state->pri & 0x01) { - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - dec0_pf3_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } else { - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -484,18 +300,18 @@ SCREEN_UPDATE( hippodrm ) SCREEN_UPDATE( slyspy ) { dec0_state *state = screen->machine->driver_data(); - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); /* Redraw top 8 pens of top 8 palettes over sprites */ if (state->pri&0x80) - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } @@ -506,7 +322,7 @@ SCREEN_UPDATE( midres ) dec0_state *state = screen->machine->driver_data(); int trans; - flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, screen->machine->device("tilegen1")->get_flip_state()); if (state->pri & 0x04) trans = 0x00; @@ -514,21 +330,21 @@ SCREEN_UPDATE( midres ) if (state->pri & 0x01) { - dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); - dec0_pf3_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } else { - dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); + screen->machine->device("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); - dec0_pf2_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); } if (state->pri & 0x02) @@ -536,74 +352,10 @@ SCREEN_UPDATE( midres ) else draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - dec0_pf1_draw(screen->machine,bitmap,cliprect,0); + screen->machine->device("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0); return 0; } -/******************************************************************************/ - -WRITE16_HANDLER( dec0_pf1_control_0_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf1_control_0[offset]); -} - -WRITE16_HANDLER( dec0_pf1_control_1_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf1_control_1[offset]); -} - -WRITE16_HANDLER( dec0_pf1_data_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf1_data[offset]); - tilemap_mark_tile_dirty(state->pf1_tilemap_0,offset); - tilemap_mark_tile_dirty(state->pf1_tilemap_1,offset); - tilemap_mark_tile_dirty(state->pf1_tilemap_2,offset); -} - -WRITE16_HANDLER( dec0_pf2_control_0_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf2_control_0[offset]); -} - -WRITE16_HANDLER( dec0_pf2_control_1_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf2_control_1[offset]); -} - -WRITE16_HANDLER( dec0_pf2_data_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf2_data[offset]); - tilemap_mark_tile_dirty(state->pf2_tilemap_0,offset); - tilemap_mark_tile_dirty(state->pf2_tilemap_1,offset); - tilemap_mark_tile_dirty(state->pf2_tilemap_2,offset); -} - -WRITE16_HANDLER( dec0_pf3_control_0_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf3_control_0[offset]); -} - -WRITE16_HANDLER( dec0_pf3_control_1_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf3_control_1[offset]); -} - -WRITE16_HANDLER( dec0_pf3_data_w ) -{ - dec0_state *state = space->machine->driver_data(); - COMBINE_DATA(&state->pf3_data[offset]); - tilemap_mark_tile_dirty(state->pf3_tilemap_0,offset); - tilemap_mark_tile_dirty(state->pf3_tilemap_1,offset); - tilemap_mark_tile_dirty(state->pf3_tilemap_2,offset); -} WRITE16_HANDLER( dec0_priority_w ) { @@ -611,118 +363,9 @@ WRITE16_HANDLER( dec0_priority_w ) COMBINE_DATA(&state->pri); } -WRITE8_HANDLER( dec0_pf3_control_8bit_w ) -{ - dec0_state *state = space->machine->driver_data(); - UINT16 myword; - - state->buffer[offset]=data; - - /* Rearrange little endian bytes from H6280 into big endian words for 68k */ - offset&=0xffe; - myword=state->buffer[offset] + (state->buffer[offset+1]<<8); - - if (offset<0x10) dec0_pf3_control_0_w(space,offset/2,myword,0xffff); - else dec0_pf3_control_1_w(space,(offset-0x10)/2,myword,0xffff); -} - -WRITE8_HANDLER( dec0_pf3_data_8bit_w ) -{ - dec0_state *state = space->machine->driver_data(); - if (offset&1) { /* MSB has changed */ - UINT16 lsb=state->pf3_data[offset>>1]; - UINT16 newword=(lsb&0xff) | (data<<8); - state->pf3_data[offset>>1]=newword; - } - else { /* LSB has changed */ - UINT16 msb=state->pf3_data[offset>>1]; - UINT16 newword=(msb&0xff00) | data; - state->pf3_data[offset>>1]=newword; - } - tilemap_mark_tile_dirty(state->pf3_tilemap_0,offset>>1); - tilemap_mark_tile_dirty(state->pf3_tilemap_1,offset>>1); - tilemap_mark_tile_dirty(state->pf3_tilemap_2,offset>>1); -} - -READ8_HANDLER( dec0_pf3_data_8bit_r ) -{ - dec0_state *state = space->machine->driver_data(); - if (offset&1) /* MSB */ - return state->pf3_data[offset>>1]>>8; - - return state->pf3_data[offset>>1]&0xff; -} - -/******************************************************************************/ - -static TILEMAP_MAPPER( tile_shape0_scan ) -{ - return (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x30) << 4); -} - -static TILEMAP_MAPPER( tile_shape1_scan ) -{ - return (col & 0xf) + ((row & 0xf) << 4) + ((row & 0x10) << 4) + ((col & 0x10) << 5); -} - -static TILEMAP_MAPPER( tile_shape2_scan ) -{ - return (col & 0xf) + ((row & 0x3f) << 4); -} - -static TILEMAP_MAPPER( tile_shape0_8x8_scan ) -{ - return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5); -} - -static TILEMAP_MAPPER( tile_shape1_8x8_scan ) -{ - return (col & 0x1f) + ((row & 0x1f) << 5) + ((row & 0x20) << 5) + ((col & 0x20) << 6); -} - -static TILEMAP_MAPPER( tile_shape2_8x8_scan ) -{ - return (col & 0x1f) + ((row & 0x7f) << 5); -} - -static TILE_GET_INFO( get_pf1_tile_info ) -{ - dec0_state *state = machine->driver_data(); - int tile=state->pf1_data[tile_index]; - SET_TILE_INFO(0,tile&0xfff,tile>>12,0); -} - -static TILE_GET_INFO( get_pf2_tile_info ) -{ - dec0_state *state = machine->driver_data(); - int tile=state->pf2_data[tile_index]; - int pri=((tile>>12)>7); - SET_TILE_INFO(1,tile&0xfff,tile>>12,0); - tileinfo->group = pri; -} - -static TILE_GET_INFO( get_pf3_tile_info ) -{ - dec0_state *state = machine->driver_data(); - int tile=state->pf3_data[tile_index]; - int pri=((tile>>12)>7); - SET_TILE_INFO(2,tile&0xfff,tile>>12,0); - tileinfo->group = pri; -} - VIDEO_START( dec0_nodma ) { dec0_state *state = machine->driver_data(); - state->pf1_tilemap_0 = tilemap_create(machine, get_pf1_tile_info,tile_shape0_8x8_scan, 8, 8,128, 32); - state->pf1_tilemap_1 = tilemap_create(machine, get_pf1_tile_info,tile_shape1_8x8_scan, 8, 8, 64, 64); - state->pf1_tilemap_2 = tilemap_create(machine, get_pf1_tile_info,tile_shape2_8x8_scan, 8, 8, 32,128); - state->pf2_tilemap_0 = tilemap_create(machine, get_pf2_tile_info,tile_shape0_scan, 16,16, 64, 16); - state->pf2_tilemap_1 = tilemap_create(machine, get_pf2_tile_info,tile_shape1_scan, 16,16, 32, 32); - state->pf2_tilemap_2 = tilemap_create(machine, get_pf2_tile_info,tile_shape2_scan, 16,16, 16, 64); - state->pf3_tilemap_0 = tilemap_create(machine, get_pf3_tile_info,tile_shape0_scan, 16,16, 64, 16); - state->pf3_tilemap_1 = tilemap_create(machine, get_pf3_tile_info,tile_shape1_scan, 16,16, 32, 32); - state->pf3_tilemap_2 = tilemap_create(machine, get_pf3_tile_info,tile_shape2_scan, 16,16, 16, 64); - state->buffered_spriteram = state->spriteram; } diff --git a/src/mame/video/decbac06.c b/src/mame/video/decbac06.c new file mode 100644 index 00000000000..a5f07e89c1f --- /dev/null +++ b/src/mame/video/decbac06.c @@ -0,0 +1,385 @@ +/* + Deco BAC06 tilemap generator: + + this a direct relative of the later chip implemented in deco16ic.c + we could implement this as either an 8-bit or a 16-bit chip, for now + I'm using the 16-bit implementation from dec0.c + + + + Notes (from dec0.c) + + All games contain three BAC06 background generator chips, usual (software) +configuration is 2 chips of 16*16 tiles, 1 of 8*8. + + Playfield control registers: + bank 0: + 0: + bit 0 (0x1) set = 8*8 tiles, else 16*16 tiles + Bit 1 (0x2) unknown + bit 2 (0x4) set enables rowscroll + bit 3 (0x8) set enables colscroll + bit 7 (0x80) set in playfield 1 is reverse screen (set via dip-switch) + bit 7 (0x80) in other playfields unknown + 2: unknown (00 in bg, 03 in fg+text - maybe controls pf transparency?) + 4: unknown (always 00) [Used to access 2nd bank of tiles in Stadium Hero) + 6: playfield shape: 00 = 4x1, 01 = 2x2, 02 = 1x4 (low 4 bits only) + + bank 1: + 0: horizontal scroll + 2: vertical scroll + 4: colscroll shifter (low 4 bits, top 4 bits do nothing) + 6: rowscroll shifter (low 4 bits, top 4 bits do nothing) + + Row & column scroll can be applied simultaneously or by themselves. + The shift register controls the granularity of the scroll offsets + (more details given later). + +Playfield priority (Bad Dudes, etc): + In the bottommost playfield, pens 8-15 can have priority over the next playfield. + In that next playfield, pens 8-15 can have priority over sprites. + +Bit 0: Playfield inversion +Bit 1: Enable playfield mixing (for palettes 8-15 only) +Bit 2: Enable playfield/sprite mixing (for palettes 8-15 only) + +Priority word (Midres): + Bit 0 set = Playfield 3 drawn over Playfield 2 + ~ = Playfield 2 drawn over Playfield 3 + Bit 1 set = Sprites are drawn inbetween playfields + ~ = Sprites are on top of playfields + Bit 2 + Bit 3 set = ... + +*/ + +#include "emu.h" +#include "decbac06.h" + +deco_bac06_device_config::deco_bac06_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "decbac06_device", tag, owner, clock) +{ + m_gfxregion8x8 = m_gfxregion16x16 = 0; +} + +device_config *deco_bac06_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(deco_bac06_device_config(mconfig, tag, owner, clock)); +} + +device_t *deco_bac06_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, deco_bac06_device(machine, *this)); +} + +void deco_bac06_device_config::set_gfx_region(device_config *device, int region8x8, int region16x16) +{ + deco_bac06_device_config *dev = downcast(device); + dev->m_gfxregion8x8 = region8x8; + dev->m_gfxregion16x16 = region16x16; +} + + +deco_bac06_device::deco_bac06_device(running_machine &_machine, const deco_bac06_device_config &config) + : device_t(_machine, config), + m_config(config), + m_gfxregion8x8(m_config.m_gfxregion8x8), + m_gfxregion16x16(m_config.m_gfxregion16x16) +{ +} + + + +static TILEMAP_MAPPER( tile_shape0_scan ) +{ + return (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x30) << 4); +} + +static TILEMAP_MAPPER( tile_shape1_scan ) +{ + return (col & 0xf) + ((row & 0xf) << 4) + ((row & 0x10) << 4) + ((col & 0x10) << 5); +} + +static TILEMAP_MAPPER( tile_shape2_scan ) +{ + return (col & 0xf) + ((row & 0x3f) << 4); +} + +static TILEMAP_MAPPER( tile_shape0_8x8_scan ) +{ + return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5); +} + +static TILEMAP_MAPPER( tile_shape1_8x8_scan ) +{ + return (col & 0x1f) + ((row & 0x1f) << 5) + ((row & 0x20) << 5) + ((col & 0x20) << 6); +} + +static TILEMAP_MAPPER( tile_shape2_8x8_scan ) +{ + return (col & 0x1f) + ((row & 0x7f) << 5); +} + +static TILE_GET_INFO_DEVICE( get_pf8x8_tile_info ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + int tile=dev->pf_data[tile_index]; + SET_TILE_INFO_DEVICE(dev->tile_region,tile&0xfff,tile>>12,0); +} + +static TILE_GET_INFO_DEVICE( get_pf16x16_tile_info ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + int tile=dev->pf_data[tile_index]; + int pri=((tile>>12)>7); + SET_TILE_INFO_DEVICE(dev->tile_region,tile&0xfff,tile>>12,0); + tileinfo->group = pri; +} + + +void deco_bac06_device::create_tilemaps(int region8x8, int region16x16) +{ + tile_region = region8x8; + + pf8x8_tilemap[0] = tilemap_create_device(this, get_pf8x8_tile_info,tile_shape0_8x8_scan, 8, 8,128, 32); + pf8x8_tilemap[1] = tilemap_create_device(this, get_pf8x8_tile_info,tile_shape1_8x8_scan, 8, 8, 64, 64); + pf8x8_tilemap[2] = tilemap_create_device(this, get_pf8x8_tile_info,tile_shape2_8x8_scan, 8, 8, 32,128); + + tile_region = region16x16; + + pf16x16_tilemap[0] = tilemap_create_device(this, get_pf16x16_tile_info,tile_shape0_scan, 16,16, 64, 16); + pf16x16_tilemap[1] = tilemap_create_device(this, get_pf16x16_tile_info,tile_shape1_scan, 16,16, 32, 32); + pf16x16_tilemap[2] = tilemap_create_device(this, get_pf16x16_tile_info,tile_shape2_scan, 16,16, 16, 64); +} + +void deco_bac06_device::device_start() +{ + pf_data = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2); // 0x2000 is the maximum needed, some games / chip setups map less and mirror + pf_rowscroll = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2); + pf_colscroll = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2); + + create_tilemaps(m_gfxregion8x8, m_gfxregion16x16); +} + +void deco_bac06_device::device_reset() +{ + +} + + +static void custom_tilemap_draw(running_machine *machine, + bitmap_t *bitmap, + const rectangle *cliprect, + tilemap_t *tilemap_ptr, + const UINT16 *rowscroll_ptr, + const UINT16 *colscroll_ptr, + const UINT16 *control0, + const UINT16 *control1, + int flags) +{ + const bitmap_t *src_bitmap = tilemap_get_pixmap(tilemap_ptr); + int x, y, p; + int column_offset=0, src_x=0, src_y=0; + UINT32 scrollx=control1[0]; + UINT32 scrolly=control1[1]; + int width_mask; + int height_mask; + int row_scroll_enabled = (rowscroll_ptr && (control0[0]&0x4)); + int col_scroll_enabled = (colscroll_ptr && (control0[0]&0x8)); + + if (!src_bitmap) + return; + + width_mask = src_bitmap->width - 1; + height_mask = src_bitmap->height - 1; + + /* Column scroll & row scroll may per applied per pixel, there are + shift registers for each which control the granularity of the row/col + offset (down to per line level for row, and per 8 lines for column). + + Nb: The row & col selectors are _not_ affected by the shape of the + playfield (ie, 256*1024, 512*512 or 1024*256). So even if the tilemap + width is only 256, 'src_x' should not wrap at 256 in the code below (to + do so would mean the top half of row RAM would never be accessed which + is incorrect). + + Nb2: Real hardware exhibits a strange bug with column scroll on 'mode 2' + (256*1024) - the first column has a strange additional offset, but + curiously the first 'wrap' (at scroll offset 256) does not have this offset, + it is displayed as expected. The bug is confimed to only affect this mode, + the other two modes work as expected. This bug is not emulated, as it + doesn't affect any games. + */ + + if (flip_screen_get(machine)) + src_y = (src_bitmap->height - 256) - scrolly; + else + src_y = scrolly; + + for (y=0; y<=cliprect->max_y; y++) { + if (row_scroll_enabled) + src_x=scrollx + rowscroll_ptr[(src_y >> (control1[3]&0xf))&(0x1ff>>(control1[3]&0xf))]; + else + src_x=scrollx; + + if (flip_screen_get(machine)) + src_x=(src_bitmap->width - 256) - src_x; + + for (x=0; x<=cliprect->max_x; x++) { + if (col_scroll_enabled) + column_offset=colscroll_ptr[((src_x >> 3) >> (control1[2]&0xf))&(0x3f>>(control1[2]&0xf))]; + + p = *BITMAP_ADDR16(src_bitmap, (src_y + column_offset)&height_mask, src_x&width_mask); + + src_x++; + if ((flags&TILEMAP_DRAW_OPAQUE) || (p&0xf)) + { + if( flags & TILEMAP_DRAW_LAYER0 ) + { + /* Top 8 pens of top 8 palettes only */ + if ((p&0x88)==0x88) + *BITMAP_ADDR16(bitmap, y, x) = p; + } + else + *BITMAP_ADDR16(bitmap, y, x) = p; + } + } + src_y++; + } +} + + +void deco_bac06_device::deco_bac06_pf_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) +{ + tilemap_t* tm = 0; + + switch (pf_control_0[3]&0x3) { + case 0: /* 4x1 */ + if (pf_control_0[0]&0x1) + tm = pf8x8_tilemap[0]; + else + tm = pf16x16_tilemap[0]; + break; + + case 1: /* 2x2 */ + default: + if (pf_control_0[0]&0x1) + tm = pf8x8_tilemap[1]; + else + tm = pf16x16_tilemap[1]; + break; + + case 2: /* 1x4 */ + if (pf_control_0[0]&0x1) + tm = pf8x8_tilemap[2]; + else + tm = pf16x16_tilemap[2]; + break; + }; + + if (tm) + custom_tilemap_draw(machine,bitmap,cliprect,tm,pf_rowscroll,pf_colscroll,pf_control_0,pf_control_1,flags); + +} + + + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_0_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + COMBINE_DATA(&dev->pf_control_0[offset]); +} + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_1_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + COMBINE_DATA(&dev->pf_control_1[offset]); +} + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_data_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + COMBINE_DATA(&dev->pf_data[offset]); + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[0],offset); + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[1],offset); + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[2],offset); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[0],offset); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[1],offset); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[2],offset); +} + +READ16_DEVICE_HANDLER( deco_bac06_pf_data_r ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + return dev->pf_data[offset]; +} + +WRITE8_DEVICE_HANDLER( deco_bac06_pf_control_8bit_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + UINT16 myword; + + dev->buffer[offset]=data; + + /* Rearrange little endian bytes from H6280 into big endian words for 68k */ + offset&=0xffe; + myword=dev->buffer[offset] + (dev->buffer[offset+1]<<8); + + if (offset<0x10) deco_bac06_pf_control_0_w(device,offset/2,myword,0xffff); + else deco_bac06_pf_control_1_w(device,(offset-0x10)/2,myword,0xffff); +} + +WRITE8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + if (offset&1) { /* MSB has changed */ + UINT16 lsb=dev->pf_data[offset>>1]; + UINT16 newword=(lsb&0xff) | (data<<8); + dev->pf_data[offset>>1]=newword; + } + else { /* LSB has changed */ + UINT16 msb=dev->pf_data[offset>>1]; + UINT16 newword=(msb&0xff00) | data; + dev->pf_data[offset>>1]=newword; + } + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[0],offset>>1); + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[1],offset>>1); + tilemap_mark_tile_dirty(dev->pf8x8_tilemap[2],offset>>1); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[0],offset>>1); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[1],offset>>1); + tilemap_mark_tile_dirty(dev->pf16x16_tilemap[2],offset>>1); +} + +READ8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_r ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + if (offset&1) /* MSB */ + return dev->pf_data[offset>>1]>>8; + + return dev->pf_data[offset>>1]&0xff; +} + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_rowscroll_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + COMBINE_DATA(&dev->pf_rowscroll[offset]); +} + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_colscroll_w ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + COMBINE_DATA(&dev->pf_colscroll[offset]); +} + +READ16_DEVICE_HANDLER( deco_bac06_pf_rowscroll_r ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + return dev->pf_rowscroll[offset]; +} + +READ16_DEVICE_HANDLER( deco_bac06_pf_colscroll_r ) +{ + deco_bac06_device *dev = (deco_bac06_device*)device; + return dev->pf_colscroll[offset]; +} + diff --git a/src/mame/video/decbac06.h b/src/mame/video/decbac06.h new file mode 100644 index 00000000000..620daa7b9be --- /dev/null +++ b/src/mame/video/decbac06.h @@ -0,0 +1,71 @@ +/* BAC06 */ + + +class deco_bac06_device_config : public device_config +{ + friend class deco_bac06_device; + deco_bac06_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); +public: + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + static void set_gfx_region(device_config *device, int region8x8, int region16x16); + +protected: + UINT8 m_gfxregion8x8; + UINT8 m_gfxregion16x16; +}; + +class deco_bac06_device : public device_t +{ + friend class deco_bac06_device_config; + deco_bac06_device(running_machine &_machine, const deco_bac06_device_config &config); +public: + void set_gfxregion(int region8x8, int region16x16) { m_gfxregion8x8 = region8x8; m_gfxregion16x16 = region16x16; }; + + + UINT16* pf_data; + UINT16* pf_rowscroll, *pf_colscroll; + + tilemap_t* pf8x8_tilemap[3]; + tilemap_t* pf16x16_tilemap[3]; + int tile_region; + void create_tilemaps(int region8x8,int region16x16); + UINT16 pf_control_0[4]; + UINT16 pf_control_1[4]; + + void deco_bac06_pf_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags); + UINT8 get_flip_state(void) { return pf_control_0[0]&0x80; }; + int buffer[0x20]; + +protected: + virtual void device_start(); + virtual void device_reset(); + const deco_bac06_device_config &m_config; + + UINT8 m_gfxregion8x8; + UINT8 m_gfxregion16x16; + + +private: + + +}; + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_0_w ); +WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_1_w ); + +WRITE16_DEVICE_HANDLER( deco_bac06_pf_data_w ); +READ16_DEVICE_HANDLER( deco_bac06_pf_data_r ); +WRITE16_DEVICE_HANDLER( deco_bac06_pf_rowscroll_w ); +READ16_DEVICE_HANDLER( deco_bac06_pf_rowscroll_r ); +WRITE16_DEVICE_HANDLER( deco_bac06_pf_colscroll_w ); +READ16_DEVICE_HANDLER( deco_bac06_pf_colscroll_r ); + +READ8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_r ); +WRITE8_DEVICE_HANDLER( deco_bac06_pf_control_8bit_w ); +WRITE8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_w ); + + +const device_type deco_bac06_ = deco_bac06_device_config::static_alloc_device_config; + + diff --git a/src/mame/video/simpl156.c b/src/mame/video/simpl156.c index b430a319af4..fe4a9563be0 100644 --- a/src/mame/video/simpl156.c +++ b/src/mame/video/simpl156.c @@ -13,10 +13,10 @@ VIDEO_START( simpl156 ) simpl156_state *state = machine->driver_data(); /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */ - state->pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2); - state->pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2); - state->spriteram = auto_alloc_array(machine, UINT16, 0x2000/2); - machine->generic.paletteram.u16 = auto_alloc_array(machine, UINT16, 0x1000/2); + state->pf1_rowscroll = auto_alloc_array_clear(machine, UINT16, 0x800/2); + state->pf2_rowscroll = auto_alloc_array_clear(machine, UINT16, 0x800/2); + state->spriteram = auto_alloc_array_clear(machine, UINT16, 0x2000/2); + machine->generic.paletteram.u16 = auto_alloc_array_clear(machine, UINT16, 0x1000/2); /* and register the allocated ram so that save states still work */ state->save_pointer(NAME(state->pf1_rowscroll), 0x800/2);