trunk/src/mame/drivers/exprraid.c
| r25356 | r25357 | |
| 213 | 213 | |
| 214 | 214 | |
| 215 | 215 | /*****************************************************************************************/ |
| 216 | | /* Emulate Protection ( only for original express raider, code is cracked on the bootleg */ |
| 216 | /* Emulate DECO 291 protection (for original express raider, code is cracked on the bootleg)*/ |
| 217 | 217 | /*****************************************************************************************/ |
| 218 | 218 | |
| 219 | | READ8_MEMBER(exprraid_state::exprraid_protection_r) |
| 219 | READ8_MEMBER(exprraid_state::exprraid_prot_data_r) |
| 220 | 220 | { |
| 221 | | switch (offset) |
| 221 | return m_prot_value; |
| 222 | } |
| 223 | |
| 224 | READ8_MEMBER(exprraid_state::exprraid_prot_status_r) |
| 225 | { |
| 226 | /* |
| 227 | 76543210 |
| 228 | .......x ? |
| 229 | ......x. Device data available |
| 230 | .....x.. CPU data available (cleared by device) |
| 231 | */ |
| 232 | |
| 233 | return 0x02; |
| 234 | } |
| 235 | |
| 236 | WRITE8_MEMBER(exprraid_state::exprraid_prot_data_w) |
| 237 | { |
| 238 | switch (data) |
| 222 | 239 | { |
| 223 | | case 0: |
| 224 | | return m_main_ram[0x02a9]; |
| 225 | | case 1: |
| 226 | | return 0x02; |
| 240 | case 0x20: |
| 241 | // Written when CPU times out waiting for status |
| 242 | break; |
| 243 | |
| 244 | case 0x60: |
| 245 | // ? |
| 246 | break; |
| 247 | |
| 248 | case 0x80: |
| 249 | ++m_prot_value; |
| 250 | break; |
| 251 | |
| 252 | case 0x90: |
| 253 | m_prot_value = 0; |
| 254 | break; |
| 255 | |
| 256 | default: |
| 257 | logerror("Unknown protection write: %x at PC:%x\n", data, space.device().safe_pc()); |
| 227 | 258 | } |
| 259 | } |
| 228 | 260 | |
| 229 | | return 0; |
| 261 | READ8_MEMBER(exprraid_state::sound_cpu_command_r) |
| 262 | { |
| 263 | m_slave->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); |
| 264 | return soundlatch_byte_r(space, 0); |
| 230 | 265 | } |
| 231 | 266 | |
| 232 | 267 | WRITE8_MEMBER(exprraid_state::sound_cpu_command_w) |
| 233 | 268 | { |
| 234 | 269 | soundlatch_byte_w(space, 0, data); |
| 235 | | m_slave->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 270 | m_slave->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); |
| 236 | 271 | } |
| 237 | 272 | |
| 273 | WRITE8_MEMBER(exprraid_state::exprraid_int_clear_w) |
| 274 | { |
| 275 | m_maincpu->set_input_line(DECO16_IRQ_LINE, CLEAR_LINE); |
| 276 | } |
| 277 | |
| 238 | 278 | READ8_MEMBER(exprraid_state::vblank_r) |
| 239 | 279 | { |
| 240 | 280 | return ioport("IN0")->read(); |
| 241 | 281 | } |
| 242 | 282 | |
| 283 | |
| 243 | 284 | static ADDRESS_MAP_START( master_map, AS_PROGRAM, 8, exprraid_state ) |
| 244 | 285 | AM_RANGE(0x0000, 0x05ff) AM_RAM AM_SHARE("main_ram") |
| 245 | 286 | AM_RANGE(0x0600, 0x07ff) AM_RAM AM_SHARE("spriteram") |
| 246 | 287 | AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(exprraid_videoram_w) AM_SHARE("videoram") |
| 247 | 288 | AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(exprraid_colorram_w) AM_SHARE("colorram") |
| 248 | | AM_RANGE(0x1317, 0x1317) AM_READNOP // ??? |
| 249 | | AM_RANGE(0x1700, 0x1700) AM_READNOP // ??? |
| 250 | 289 | AM_RANGE(0x1800, 0x1800) AM_READ_PORT("DSW0") /* DSW 0 */ |
| 251 | 290 | AM_RANGE(0x1801, 0x1801) AM_READ_PORT("IN1") /* Controls */ |
| 252 | 291 | AM_RANGE(0x1802, 0x1802) AM_READ_PORT("IN2") /* Coins */ |
| 253 | 292 | AM_RANGE(0x1803, 0x1803) AM_READ_PORT("DSW1") /* DSW 1 */ |
| 254 | | AM_RANGE(0x2000, 0x2000) AM_WRITENOP // ??? |
| 293 | AM_RANGE(0x2000, 0x2000) AM_WRITE(exprraid_int_clear_w) |
| 255 | 294 | AM_RANGE(0x2001, 0x2001) AM_WRITE(sound_cpu_command_w) |
| 256 | 295 | AM_RANGE(0x2002, 0x2002) AM_WRITE(exprraid_flipscreen_w) |
| 257 | | AM_RANGE(0x2003, 0x2003) AM_WRITENOP // ??? |
| 258 | | AM_RANGE(0x2800, 0x2801) AM_READ(exprraid_protection_r) |
| 296 | AM_RANGE(0x2003, 0x2003) AM_WRITENOP // DMA SWAP - Allow writes to video and sprite RAM |
| 297 | AM_RANGE(0x2800, 0x2800) AM_READ(exprraid_prot_data_r) |
| 298 | AM_RANGE(0x2801, 0x2801) AM_READ(exprraid_prot_status_r) |
| 259 | 299 | AM_RANGE(0x2800, 0x2803) AM_WRITE(exprraid_bgselect_w) |
| 260 | 300 | AM_RANGE(0x2804, 0x2804) AM_WRITE(exprraid_scrolly_w) |
| 261 | 301 | AM_RANGE(0x2805, 0x2806) AM_WRITE(exprraid_scrollx_w) |
| 262 | | AM_RANGE(0x2807, 0x2807) AM_WRITENOP // Scroll related ? |
| 302 | AM_RANGE(0x2807, 0x2807) AM_WRITE(exprraid_prot_data_w) |
| 263 | 303 | AM_RANGE(0x4000, 0xffff) AM_ROM |
| 264 | 304 | ADDRESS_MAP_END |
| 265 | 305 | |
| r25356 | r25357 | |
| 271 | 311 | AM_RANGE(0x0000, 0x1fff) AM_RAM |
| 272 | 312 | AM_RANGE(0x2000, 0x2001) AM_DEVREADWRITE("ym1", ym2203_device, read, write) |
| 273 | 313 | AM_RANGE(0x4000, 0x4001) AM_DEVREADWRITE("ym2", ym3526_device, read, write) |
| 274 | | AM_RANGE(0x6000, 0x6000) AM_READ(soundlatch_byte_r) |
| 314 | AM_RANGE(0x6000, 0x6000) AM_READ(sound_cpu_command_r) |
| 275 | 315 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 276 | 316 | ADDRESS_MAP_END |
| 277 | 317 | |
| 318 | |
| 278 | 319 | INPUT_CHANGED_MEMBER(exprraid_state::coin_inserted_deco16) |
| 279 | 320 | { |
| 280 | | m_maincpu->set_input_line(DECO16_IRQ_LINE, oldval ? ASSERT_LINE : CLEAR_LINE); |
| 321 | if (oldval && !newval) |
| 322 | m_maincpu->set_input_line(DECO16_IRQ_LINE, ASSERT_LINE); |
| 281 | 323 | } |
| 282 | 324 | |
| 283 | 325 | INPUT_CHANGED_MEMBER(exprraid_state::coin_inserted_nmi) |
| r25356 | r25357 | |
| 336 | 378 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL |
| 337 | 379 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 338 | 380 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL |
| 339 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_deco16, 0) |
| 340 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_deco16, 0) |
| 381 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_deco16, 0) |
| 382 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_deco16, 0) |
| 341 | 383 | |
| 342 | 384 | PORT_START("DSW1") /* 0x1803 */ |
| 343 | 385 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:1,2") |
| r25356 | r25357 | |
| 356 | 398 | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:6") /* see notes */ |
| 357 | 399 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 358 | 400 | PORT_DIPSETTING( 0x20, DEF_STR( On ) ) |
| 359 | | PORT_DIPNAME( 0x40, 0x40, "Force Coinage = 1C/1C" ) PORT_DIPLOCATION("SW2:7") /* see notes */ |
| 360 | | PORT_DIPSETTING( 0x40, DEF_STR( No ) ) |
| 361 | | PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) |
| 401 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_deco16, 0) |
| 362 | 402 | PORT_DIPUNUSED_DIPLOC( 0x80, IP_ACTIVE_LOW, "SW1:8" ) |
| 363 | 403 | INPUT_PORTS_END |
| 364 | 404 | |
| r25356 | r25357 | |
| 369 | 409 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, exprraid_state, coin_inserted_nmi, 0) |
| 370 | 410 | INPUT_PORTS_END |
| 371 | 411 | |
| 412 | |
| 372 | 413 | static const gfx_layout charlayout = |
| 373 | 414 | { |
| 374 | 415 | 8,8, /* 8*8 characters */ |
| r25356 | r25357 | |
| 432 | 473 | GFXDECODE_END |
| 433 | 474 | |
| 434 | 475 | |
| 435 | | |
| 436 | 476 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 437 | 477 | WRITE_LINE_MEMBER(exprraid_state::irqhandler) |
| 438 | 478 | { |
| 439 | 479 | m_slave->set_input_line_and_vector(0, state, 0xff); |
| 440 | 480 | } |
| 441 | 481 | |
| 442 | | #if 0 |
| 443 | | INTERRUPT_GEN_MEMBER(exprraid_state::exprraid_interrupt) |
| 444 | | { |
| 445 | | if ((~ioport("IN2")->read()) & 0xc0) |
| 446 | | { |
| 447 | | if (m_coin == 0) |
| 448 | | { |
| 449 | | m_coin = 1; |
| 450 | | //device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 451 | | device.execute().set_input_line(DECO16_IRQ_LINE, ASSERT_LINE); |
| 452 | | } |
| 453 | | } |
| 454 | | else |
| 455 | | { |
| 456 | | device.execute().set_input_line(DECO16_IRQ_LINE, CLEAR_LINE); |
| 457 | | m_coin = 0; |
| 458 | | } |
| 459 | | } |
| 460 | | #endif |
| 461 | | |
| 462 | | |
| 463 | 482 | void exprraid_state::machine_start() |
| 464 | 483 | { |
| 484 | save_item(NAME(m_prot_value)); |
| 465 | 485 | save_item(NAME(m_bg_index)); |
| 466 | 486 | } |
| 467 | 487 | |
| r25356 | r25357 | |
| 473 | 493 | m_bg_index[3] = 0; |
| 474 | 494 | } |
| 475 | 495 | |
| 496 | |
| 476 | 497 | static MACHINE_CONFIG_START( exprraid, exprraid_state ) |
| 477 | 498 | |
| 478 | 499 | /* basic machine hardware */ |
| 479 | | MCFG_CPU_ADD("maincpu", DECO16, 4000000) /* 4 MHz ??? */ |
| 500 | MCFG_CPU_ADD("maincpu", DECO16, XTAL_12MHz / 8) |
| 480 | 501 | MCFG_CPU_PROGRAM_MAP(master_map) |
| 481 | 502 | MCFG_CPU_IO_MAP(master_io_map) |
| 482 | 503 | |
| 483 | | MCFG_CPU_ADD("slave", M6809, 2000000) /* 2 MHz ??? */ |
| 504 | MCFG_CPU_ADD("slave", M6809, XTAL_12MHz / 8) |
| 484 | 505 | MCFG_CPU_PROGRAM_MAP(slave_map) |
| 485 | | /* IRQs are caused by the YM3526 */ |
| 506 | /* IRQs are caused by the YM3526 */ |
| 486 | 507 | |
| 508 | MCFG_QUANTUM_TIME(attotime::from_hz(12000)) |
| 509 | |
| 487 | 510 | /* video hardware */ |
| 488 | 511 | MCFG_SCREEN_ADD("screen", RASTER) |
| 489 | 512 | MCFG_SCREEN_REFRESH_RATE(60) |
| r25356 | r25357 | |
| 500 | 523 | /* sound hardware */ |
| 501 | 524 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 502 | 525 | |
| 503 | | MCFG_SOUND_ADD("ym1", YM2203, 1500000) |
| 526 | MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8) |
| 504 | 527 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) |
| 505 | 528 | |
| 506 | | MCFG_SOUND_ADD("ym2", YM3526, 3600000) |
| 529 | MCFG_SOUND_ADD("ym2", YM3526, XTAL_12MHz / 4) |
| 507 | 530 | MCFG_YM3526_IRQ_HANDLER(WRITELINE(exprraid_state, irqhandler)) |
| 508 | 531 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) |
| 509 | 532 | MACHINE_CONFIG_END |
| 510 | 533 | |
| 511 | 534 | static MACHINE_CONFIG_DERIVED( exprboot, exprraid ) |
| 512 | 535 | |
| 513 | | MCFG_CPU_REPLACE("maincpu", M6502, 4000000) /* 4 MHz ??? */ |
| 536 | MCFG_CPU_REPLACE("maincpu", M6502, 1500000) /* 1.5 MHz ??? */ |
| 514 | 537 | MCFG_CPU_PROGRAM_MAP(master_map) |
| 515 | 538 | MACHINE_CONFIG_END |
| 516 | 539 | |
trunk/src/mame/includes/exprraid.h
| r25356 | r25357 | |
| 10 | 10 | public: |
| 11 | 11 | exprraid_state(const machine_config &mconfig, device_type type, const char *tag) |
| 12 | 12 | : driver_device(mconfig, type, tag), |
| 13 | m_maincpu(*this, "maincpu"), |
| 14 | m_slave(*this, "slave"), |
| 13 | 15 | m_main_ram(*this, "main_ram"), |
| 14 | 16 | m_spriteram(*this, "spriteram"), |
| 15 | 17 | m_videoram(*this, "videoram"), |
| 16 | | m_colorram(*this, "colorram"), |
| 17 | | m_maincpu(*this, "maincpu"), |
| 18 | | m_slave(*this, "slave"){ } |
| 18 | m_colorram(*this, "colorram") { } |
| 19 | 19 | |
| 20 | /* devices */ |
| 21 | required_device<cpu_device> m_maincpu; |
| 22 | required_device<cpu_device> m_slave; |
| 23 | |
| 20 | 24 | /* memory pointers */ |
| 21 | 25 | required_shared_ptr<UINT8> m_main_ram; |
| 22 | 26 | required_shared_ptr<UINT8> m_spriteram; |
| 23 | 27 | required_shared_ptr<UINT8> m_videoram; |
| 24 | 28 | required_shared_ptr<UINT8> m_colorram; |
| 25 | 29 | |
| 30 | /* protection */ |
| 31 | UINT8 m_prot_value; |
| 32 | |
| 26 | 33 | /* video-related */ |
| 27 | | tilemap_t *m_bg_tilemap; |
| 28 | | tilemap_t *m_fg_tilemap; |
| 29 | | int m_bg_index[4]; |
| 34 | tilemap_t *m_bg_tilemap; |
| 35 | tilemap_t *m_fg_tilemap; |
| 36 | int m_bg_index[4]; |
| 30 | 37 | |
| 31 | | /* misc */ |
| 32 | | //int m_coin; // used in the commented out INTERRUPT_GEN - can this be removed? |
| 38 | virtual void machine_start(); |
| 39 | virtual void machine_reset(); |
| 40 | virtual void video_start(); |
| 33 | 41 | |
| 34 | | /* devices */ |
| 35 | | required_device<cpu_device> m_maincpu; |
| 36 | | required_device<cpu_device> m_slave; |
| 37 | | DECLARE_READ8_MEMBER(exprraid_protection_r); |
| 42 | DECLARE_WRITE8_MEMBER(exprraid_int_clear_w); |
| 43 | DECLARE_READ8_MEMBER(exprraid_prot_status_r); |
| 44 | DECLARE_READ8_MEMBER(exprraid_prot_data_r); |
| 45 | DECLARE_WRITE8_MEMBER(exprraid_prot_data_w); |
| 38 | 46 | DECLARE_WRITE8_MEMBER(sound_cpu_command_w); |
| 39 | 47 | DECLARE_READ8_MEMBER(vblank_r); |
| 40 | 48 | DECLARE_WRITE8_MEMBER(exprraid_videoram_w); |
| r25356 | r25357 | |
| 45 | 53 | DECLARE_WRITE8_MEMBER(exprraid_scrolly_w); |
| 46 | 54 | DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_deco16); |
| 47 | 55 | DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_nmi); |
| 56 | |
| 57 | DECLARE_READ8_MEMBER(sound_cpu_command_r); |
| 58 | |
| 48 | 59 | DECLARE_WRITE_LINE_MEMBER(irqhandler); |
| 49 | 60 | DECLARE_DRIVER_INIT(exprraid); |
| 50 | 61 | DECLARE_DRIVER_INIT(wexpressb); |
| r25356 | r25357 | |
| 52 | 63 | DECLARE_DRIVER_INIT(wexpressb3); |
| 53 | 64 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 54 | 65 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 55 | | virtual void machine_start(); |
| 56 | | virtual void machine_reset(); |
| 57 | | virtual void video_start(); |
| 66 | |
| 58 | 67 | UINT32 screen_update_exprraid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 59 | 68 | INTERRUPT_GEN_MEMBER(exprraid_interrupt); |
| 60 | 69 | void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); |