trunk/src/mame/drivers/pipedrm.c
| r20980 | r20981 | |
| 167 | 167 | #include "includes/fromance.h" |
| 168 | 168 | |
| 169 | 169 | |
| 170 | class pipedrm_state : public fromance_state |
| 171 | { |
| 172 | public: |
| 173 | pipedrm_state(const machine_config &mconfig, device_type type, const char *tag) |
| 174 | : fromance_state(mconfig, type, tag) |
| 175 | { } |
| 176 | |
| 177 | DECLARE_MACHINE_START(pipedrm); |
| 178 | DECLARE_MACHINE_RESET(pipedrm); |
| 179 | DECLARE_DRIVER_INIT(pipedrm); |
| 180 | DECLARE_DRIVER_INIT(hatris); |
| 181 | DECLARE_WRITE8_MEMBER( pipedrm_bankswitch_w ); |
| 182 | DECLARE_WRITE8_MEMBER( sound_bankswitch_w ); |
| 183 | TIMER_CALLBACK_MEMBER( delayed_command_w ); |
| 184 | DECLARE_WRITE8_MEMBER( sound_command_w ); |
| 185 | DECLARE_WRITE8_MEMBER( sound_command_nonmi_w ); |
| 186 | DECLARE_WRITE8_MEMBER( pending_command_clear_w ); |
| 187 | DECLARE_READ8_MEMBER( pending_command_r ); |
| 188 | DECLARE_READ8_MEMBER( sound_command_r ); |
| 189 | }; |
| 190 | |
| 191 | |
| 170 | 192 | /************************************* |
| 171 | 193 | * |
| 172 | 194 | * Bankswitching |
| 173 | 195 | * |
| 174 | 196 | *************************************/ |
| 175 | 197 | |
| 176 | | static WRITE8_HANDLER( pipedrm_bankswitch_w ) |
| 198 | WRITE8_MEMBER(pipedrm_state::pipedrm_bankswitch_w ) |
| 177 | 199 | { |
| 178 | | fromance_state *state = space.machine().driver_data<fromance_state>(); |
| 179 | 200 | /* |
| 180 | 201 | Bit layout: |
| 181 | 202 | |
| r20980 | r20981 | |
| 188 | 209 | */ |
| 189 | 210 | |
| 190 | 211 | /* set the memory bank on the Z80 using the low 3 bits */ |
| 191 | | state->membank("bank1")->set_entry(data & 0x7); |
| 212 | membank("bank1")->set_entry(data & 0x7); |
| 192 | 213 | |
| 193 | 214 | /* map to the fromance gfx register */ |
| 194 | | state->fromance_gfxreg_w(space, offset, ((data >> 6) & 0x01) | /* flipscreen */ |
| 215 | fromance_gfxreg_w(space, offset, ((data >> 6) & 0x01) | /* flipscreen */ |
| 195 | 216 | ((~data >> 2) & 0x02)); /* videoram select */ |
| 196 | 217 | } |
| 197 | 218 | |
| 198 | 219 | |
| 199 | | static WRITE8_HANDLER( sound_bankswitch_w ) |
| 220 | WRITE8_MEMBER(pipedrm_state::sound_bankswitch_w ) |
| 200 | 221 | { |
| 201 | 222 | space.machine().root_device().membank("bank2")->set_entry(data & 0x01); |
| 202 | 223 | } |
| r20980 | r20981 | |
| 209 | 230 | * |
| 210 | 231 | *************************************/ |
| 211 | 232 | |
| 212 | | static TIMER_CALLBACK( delayed_command_w ) |
| 233 | TIMER_CALLBACK_MEMBER(pipedrm_state::delayed_command_w) |
| 213 | 234 | { |
| 214 | | fromance_state *state = machine.driver_data<fromance_state>(); |
| 215 | | state->m_sound_command = param & 0xff; |
| 216 | | state->m_pending_command = 1; |
| 235 | m_sound_command = param & 0xff; |
| 236 | m_pending_command = 1; |
| 217 | 237 | |
| 218 | 238 | /* Hatris polls commands *and* listens to the NMI; this causes it to miss */ |
| 219 | 239 | /* sound commands. It's possible the NMI isn't really hooked up on the YM2608 */ |
| 220 | 240 | /* sound board. */ |
| 221 | 241 | if (param & 0x100) |
| 222 | | state->m_subcpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); |
| 242 | m_subcpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); |
| 223 | 243 | } |
| 224 | 244 | |
| 225 | 245 | |
| 226 | | static WRITE8_HANDLER( sound_command_w ) |
| 246 | WRITE8_MEMBER(pipedrm_state::sound_command_w ) |
| 227 | 247 | { |
| 228 | | space.machine().scheduler().synchronize(FUNC(delayed_command_w), data | 0x100); |
| 248 | machine().scheduler().synchronize(timer_expired_delegate(FUNC(pipedrm_state::delayed_command_w),this), data | 0x100); |
| 229 | 249 | } |
| 230 | 250 | |
| 231 | 251 | |
| 232 | | static WRITE8_HANDLER( sound_command_nonmi_w ) |
| 252 | WRITE8_MEMBER(pipedrm_state::sound_command_nonmi_w ) |
| 233 | 253 | { |
| 234 | | space.machine().scheduler().synchronize(FUNC(delayed_command_w), data); |
| 254 | machine().scheduler().synchronize(timer_expired_delegate(FUNC(pipedrm_state::delayed_command_w),this), data); |
| 235 | 255 | } |
| 236 | 256 | |
| 237 | 257 | |
| 238 | | static WRITE8_HANDLER( pending_command_clear_w ) |
| 258 | WRITE8_MEMBER(pipedrm_state::pending_command_clear_w ) |
| 239 | 259 | { |
| 240 | | fromance_state *state = space.machine().driver_data<fromance_state>(); |
| 241 | | state->m_pending_command = 0; |
| 242 | | state->m_subcpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); |
| 260 | m_pending_command = 0; |
| 261 | m_subcpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); |
| 243 | 262 | } |
| 244 | 263 | |
| 245 | 264 | |
| 246 | | static READ8_HANDLER( pending_command_r ) |
| 265 | READ8_MEMBER(pipedrm_state::pending_command_r ) |
| 247 | 266 | { |
| 248 | | fromance_state *state = space.machine().driver_data<fromance_state>(); |
| 249 | | return state->m_pending_command; |
| 267 | return m_pending_command; |
| 250 | 268 | } |
| 251 | 269 | |
| 252 | 270 | |
| 253 | | static READ8_HANDLER( sound_command_r ) |
| 271 | READ8_MEMBER(pipedrm_state::sound_command_r ) |
| 254 | 272 | { |
| 255 | | fromance_state *state = space.machine().driver_data<fromance_state>(); |
| 256 | | return state->m_sound_command; |
| 273 | return m_sound_command; |
| 257 | 274 | } |
| 258 | 275 | |
| 259 | 276 | |
| r20980 | r20981 | |
| 264 | 281 | * |
| 265 | 282 | *************************************/ |
| 266 | 283 | |
| 267 | | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, fromance_state ) |
| 284 | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, pipedrm_state ) |
| 268 | 285 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 269 | 286 | AM_RANGE(0x8000, 0x9fff) AM_RAM |
| 270 | 287 | AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1") |
| r20980 | r20981 | |
| 273 | 290 | ADDRESS_MAP_END |
| 274 | 291 | |
| 275 | 292 | |
| 276 | | static ADDRESS_MAP_START( main_portmap, AS_IO, 8, fromance_state ) |
| 293 | static ADDRESS_MAP_START( main_portmap, AS_IO, 8, pipedrm_state ) |
| 277 | 294 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 278 | 295 | AM_RANGE(0x10, 0x10) AM_WRITE(fromance_crtc_data_w) |
| 279 | 296 | AM_RANGE(0x11, 0x11) AM_WRITE(fromance_crtc_register_w) |
| 280 | | AM_RANGE(0x20, 0x20) AM_READ_PORT("P1") AM_WRITE_LEGACY(sound_command_w) |
| 281 | | AM_RANGE(0x21, 0x21) AM_READ_PORT("P2") AM_WRITE_LEGACY(pipedrm_bankswitch_w) |
| 297 | AM_RANGE(0x20, 0x20) AM_READ_PORT("P1") AM_WRITE(sound_command_w) |
| 298 | AM_RANGE(0x21, 0x21) AM_READ_PORT("P2") AM_WRITE(pipedrm_bankswitch_w) |
| 282 | 299 | AM_RANGE(0x22, 0x25) AM_WRITE(fromance_scroll_w) |
| 283 | 300 | AM_RANGE(0x22, 0x22) AM_READ_PORT("DSW1") |
| 284 | 301 | AM_RANGE(0x23, 0x23) AM_READ_PORT("DSW2") |
| 285 | 302 | AM_RANGE(0x24, 0x24) AM_READ_PORT("SYSTEM") |
| 286 | | AM_RANGE(0x25, 0x25) AM_READ_LEGACY(pending_command_r) |
| 303 | AM_RANGE(0x25, 0x25) AM_READ(pending_command_r) |
| 287 | 304 | ADDRESS_MAP_END |
| 288 | 305 | |
| 289 | 306 | |
| r20980 | r20981 | |
| 294 | 311 | * |
| 295 | 312 | *************************************/ |
| 296 | 313 | |
| 297 | | static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, fromance_state ) |
| 314 | static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, pipedrm_state ) |
| 298 | 315 | AM_RANGE(0x0000, 0x77ff) AM_ROM |
| 299 | 316 | AM_RANGE(0x7800, 0x7fff) AM_RAM |
| 300 | 317 | AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank2") |
| 301 | 318 | ADDRESS_MAP_END |
| 302 | 319 | |
| 303 | 320 | |
| 304 | | static ADDRESS_MAP_START( sound_portmap, AS_IO, 8, fromance_state ) |
| 321 | static ADDRESS_MAP_START( sound_portmap, AS_IO, 8, pipedrm_state ) |
| 305 | 322 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 306 | | AM_RANGE(0x04, 0x04) AM_WRITE_LEGACY(sound_bankswitch_w) |
| 307 | | AM_RANGE(0x16, 0x16) AM_READ_LEGACY(sound_command_r) |
| 308 | | AM_RANGE(0x17, 0x17) AM_WRITE_LEGACY(pending_command_clear_w) |
| 323 | AM_RANGE(0x04, 0x04) AM_WRITE(sound_bankswitch_w) |
| 324 | AM_RANGE(0x16, 0x16) AM_READ(sound_command_r) |
| 325 | AM_RANGE(0x17, 0x17) AM_WRITE(pending_command_clear_w) |
| 309 | 326 | AM_RANGE(0x18, 0x1b) AM_DEVREADWRITE_LEGACY("ymsnd", ym2610_r, ym2610_w) |
| 310 | 327 | ADDRESS_MAP_END |
| 311 | 328 | |
| 312 | 329 | |
| 313 | | static ADDRESS_MAP_START( hatris_sound_portmap, AS_IO, 8, fromance_state ) |
| 330 | static ADDRESS_MAP_START( hatris_sound_portmap, AS_IO, 8, pipedrm_state ) |
| 314 | 331 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 315 | 332 | AM_RANGE(0x00, 0x03) AM_MIRROR(0x08) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w) |
| 316 | | AM_RANGE(0x04, 0x04) AM_READ_LEGACY(sound_command_r) |
| 317 | | AM_RANGE(0x05, 0x05) AM_READWRITE_LEGACY(pending_command_r, pending_command_clear_w) |
| 333 | AM_RANGE(0x04, 0x04) AM_READ(sound_command_r) |
| 334 | AM_RANGE(0x05, 0x05) AM_READWRITE(pending_command_r, pending_command_clear_w) |
| 318 | 335 | ADDRESS_MAP_END |
| 319 | 336 | |
| 320 | 337 | |
| r20980 | r20981 | |
| 557 | 574 | * |
| 558 | 575 | *************************************/ |
| 559 | 576 | |
| 560 | | static void irqhandler( device_t *device, int irq ) |
| 577 | static void irqhandler(device_t *device, int irq ) |
| 561 | 578 | { |
| 562 | | fromance_state *state = device->machine().driver_data<fromance_state>(); |
| 579 | pipedrm_state *state = device->machine().driver_data<pipedrm_state>(); |
| 563 | 580 | state->m_subcpu->set_input_line(0, irq ? ASSERT_LINE : CLEAR_LINE); |
| 564 | 581 | } |
| 565 | 582 | |
| r20980 | r20981 | |
| 588 | 605 | * |
| 589 | 606 | *************************************/ |
| 590 | 607 | |
| 591 | | MACHINE_START_MEMBER(fromance_state,pipedrm) |
| 608 | MACHINE_START_MEMBER(pipedrm_state,pipedrm) |
| 592 | 609 | { |
| 593 | 610 | m_subcpu = machine().device<cpu_device>("sub"); |
| 594 | 611 | |
| r20980 | r20981 | |
| 607 | 624 | /* video-related elements are saved in VIDEO_START */ |
| 608 | 625 | } |
| 609 | 626 | |
| 610 | | MACHINE_RESET_MEMBER(fromance_state,pipedrm) |
| 627 | MACHINE_RESET_MEMBER(pipedrm_state,pipedrm) |
| 611 | 628 | { |
| 612 | 629 | int i; |
| 613 | 630 | |
| r20980 | r20981 | |
| 631 | 648 | m_crtc_data[i] = 0; |
| 632 | 649 | } |
| 633 | 650 | |
| 634 | | static MACHINE_CONFIG_START( pipedrm, fromance_state ) |
| 651 | static MACHINE_CONFIG_START( pipedrm, pipedrm_state ) |
| 635 | 652 | |
| 636 | 653 | /* basic machine hardware */ |
| 637 | 654 | MCFG_CPU_ADD("maincpu", Z80,12000000/2) |
| 638 | 655 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 639 | 656 | MCFG_CPU_IO_MAP(main_portmap) |
| 640 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", fromance_state, irq0_line_hold) |
| 657 | MCFG_CPU_VBLANK_INT_DRIVER("screen", pipedrm_state, irq0_line_hold) |
| 641 | 658 | |
| 642 | 659 | MCFG_CPU_ADD("sub", Z80,14318000/4) |
| 643 | 660 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 644 | 661 | MCFG_CPU_IO_MAP(sound_portmap) |
| 645 | 662 | |
| 646 | | MCFG_MACHINE_START_OVERRIDE(fromance_state,pipedrm) |
| 647 | | MCFG_MACHINE_RESET_OVERRIDE(fromance_state,pipedrm) |
| 663 | MCFG_MACHINE_START_OVERRIDE(pipedrm_state,pipedrm) |
| 664 | MCFG_MACHINE_RESET_OVERRIDE(pipedrm_state,pipedrm) |
| 648 | 665 | |
| 649 | 666 | /* video hardware */ |
| 650 | 667 | MCFG_SCREEN_ADD("screen", RASTER) |
| r20980 | r20981 | |
| 652 | 669 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 653 | 670 | MCFG_SCREEN_SIZE(44*8, 30*8) |
| 654 | 671 | MCFG_SCREEN_VISIBLE_AREA(0*8, 44*8-1, 0*8, 30*8-1) |
| 655 | | MCFG_SCREEN_UPDATE_DRIVER(fromance_state, screen_update_pipedrm) |
| 672 | MCFG_SCREEN_UPDATE_DRIVER(pipedrm_state, screen_update_pipedrm) |
| 656 | 673 | |
| 657 | 674 | MCFG_GFXDECODE(pipedrm) |
| 658 | 675 | MCFG_PALETTE_LENGTH(2048) |
| r20980 | r20981 | |
| 662 | 679 | MCFG_VSYSTEM_SPR2_SET_OFFSETS(-13, -6) |
| 663 | 680 | MCFG_VSYSTEM_SPR2_SET_PRITYPE(3) |
| 664 | 681 | |
| 665 | | MCFG_VIDEO_START_OVERRIDE(fromance_state,pipedrm) |
| 682 | MCFG_VIDEO_START_OVERRIDE(pipedrm_state,pipedrm) |
| 666 | 683 | |
| 667 | 684 | /* sound hardware */ |
| 668 | 685 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| r20980 | r20981 | |
| 675 | 692 | MACHINE_CONFIG_END |
| 676 | 693 | |
| 677 | 694 | |
| 678 | | static MACHINE_CONFIG_START( hatris, fromance_state ) |
| 695 | static MACHINE_CONFIG_START( hatris, pipedrm_state ) |
| 679 | 696 | |
| 680 | 697 | /* basic machine hardware */ |
| 681 | 698 | MCFG_CPU_ADD("maincpu", Z80,12000000/2) |
| 682 | 699 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 683 | 700 | MCFG_CPU_IO_MAP(main_portmap) |
| 684 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", fromance_state, irq0_line_hold) |
| 701 | MCFG_CPU_VBLANK_INT_DRIVER("screen", pipedrm_state, irq0_line_hold) |
| 685 | 702 | |
| 686 | 703 | MCFG_CPU_ADD("sub", Z80,14318000/4) |
| 687 | 704 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 688 | 705 | MCFG_CPU_IO_MAP(hatris_sound_portmap) |
| 689 | 706 | |
| 690 | | MCFG_MACHINE_START_OVERRIDE(fromance_state,pipedrm) |
| 691 | | MCFG_MACHINE_RESET_OVERRIDE(fromance_state,pipedrm) |
| 707 | MCFG_MACHINE_START_OVERRIDE(pipedrm_state,pipedrm) |
| 708 | MCFG_MACHINE_RESET_OVERRIDE(pipedrm_state,pipedrm) |
| 692 | 709 | |
| 693 | 710 | /* video hardware */ |
| 694 | 711 | MCFG_SCREEN_ADD("screen", RASTER) |
| r20980 | r20981 | |
| 696 | 713 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 697 | 714 | MCFG_SCREEN_SIZE(44*8, 30*8) |
| 698 | 715 | MCFG_SCREEN_VISIBLE_AREA(0*8, 44*8-1, 0*8, 30*8-1) |
| 699 | | MCFG_SCREEN_UPDATE_DRIVER(fromance_state, screen_update_fromance) |
| 716 | MCFG_SCREEN_UPDATE_DRIVER(pipedrm_state, screen_update_fromance) |
| 700 | 717 | |
| 701 | 718 | MCFG_GFXDECODE(hatris) |
| 702 | 719 | MCFG_PALETTE_LENGTH(2048) |
| 703 | 720 | |
| 704 | | MCFG_VIDEO_START_OVERRIDE(fromance_state,hatris) |
| 721 | MCFG_VIDEO_START_OVERRIDE(pipedrm_state,hatris) |
| 705 | 722 | |
| 706 | 723 | /* sound hardware */ |
| 707 | 724 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| r20980 | r20981 | |
| 876 | 893 | * |
| 877 | 894 | *************************************/ |
| 878 | 895 | |
| 879 | | DRIVER_INIT_MEMBER(fromance_state,pipedrm) |
| 896 | DRIVER_INIT_MEMBER(pipedrm_state,pipedrm) |
| 880 | 897 | { |
| 881 | 898 | /* sprite RAM lives at the end of palette RAM */ |
| 882 | 899 | m_spriteram.set_target(&m_generic_paletteram_8[0xc00], 0x400); |
| r20980 | r20981 | |
| 884 | 901 | } |
| 885 | 902 | |
| 886 | 903 | |
| 887 | | DRIVER_INIT_MEMBER(fromance_state,hatris) |
| 904 | DRIVER_INIT_MEMBER(pipedrm_state,hatris) |
| 888 | 905 | { |
| 889 | | machine().device("maincpu")->memory().space(AS_IO).install_legacy_write_handler(0x20, 0x20, FUNC(sound_command_nonmi_w)); |
| 890 | | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x21, 0x21, write8_delegate(FUNC(fromance_state::fromance_gfxreg_w),this)); |
| 906 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x20, 0x20, write8_delegate(FUNC(pipedrm_state::sound_command_nonmi_w),this)); |
| 907 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x21, 0x21, write8_delegate(FUNC(pipedrm_state::fromance_gfxreg_w),this)); |
| 891 | 908 | } |
| 892 | 909 | |
| 893 | 910 | |
| r20980 | r20981 | |
| 898 | 915 | * |
| 899 | 916 | *************************************/ |
| 900 | 917 | |
| 901 | | GAME( 1990, pipedrm, 0, pipedrm, pipedrm, fromance_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (World)", GAME_SUPPORTS_SAVE ) |
| 902 | | GAME( 1990, pipedrmu, pipedrm, pipedrm, pipedrm, fromance_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (US)", GAME_SUPPORTS_SAVE ) |
| 903 | | GAME( 1990, pipedrmj, pipedrm, pipedrm, pipedrm, fromance_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (Japan)", GAME_SUPPORTS_SAVE ) |
| 904 | | GAME( 1990, hatris, 0, hatris, hatris, fromance_state, hatris, ROT0, "Video System Co.", "Hatris (US)", GAME_SUPPORTS_SAVE ) |
| 905 | | GAME( 1990, hatrisj, hatris, hatris, hatris, fromance_state, hatris, ROT0, "Video System Co.", "Hatris (Japan)", GAME_SUPPORTS_SAVE ) |
| 918 | GAME( 1990, pipedrm, 0, pipedrm, pipedrm, pipedrm_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (World)", GAME_SUPPORTS_SAVE ) |
| 919 | GAME( 1990, pipedrmu, pipedrm, pipedrm, pipedrm, pipedrm_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (US)", GAME_SUPPORTS_SAVE ) |
| 920 | GAME( 1990, pipedrmj, pipedrm, pipedrm, pipedrm, pipedrm_state, pipedrm, ROT0, "Video System Co.", "Pipe Dream (Japan)", GAME_SUPPORTS_SAVE ) |
| 921 | GAME( 1990, hatris, 0, hatris, hatris, pipedrm_state, hatris, ROT0, "Video System Co.", "Hatris (US)", GAME_SUPPORTS_SAVE ) |
| 922 | GAME( 1990, hatrisj, hatris, hatris, hatris, pipedrm_state, hatris, ROT0, "Video System Co.", "Hatris (Japan)", GAME_SUPPORTS_SAVE ) |