trunk/src/mame/drivers/sandscrp.c
| r244698 | r244699 | |
| 102 | 102 | UINT8 m_vblank_irq; |
| 103 | 103 | UINT8 m_latch1_full; |
| 104 | 104 | UINT8 m_latch2_full; |
| 105 | | DECLARE_READ16_MEMBER(sandscrp_irq_cause_r); |
| 106 | | DECLARE_WRITE16_MEMBER(sandscrp_irq_cause_w); |
| 107 | | DECLARE_WRITE16_MEMBER(sandscrp_coin_counter_w); |
| 108 | | DECLARE_READ16_MEMBER(sandscrp_latchstatus_word_r); |
| 109 | | DECLARE_WRITE16_MEMBER(sandscrp_latchstatus_word_w); |
| 110 | | DECLARE_READ16_MEMBER(sandscrp_soundlatch_word_r); |
| 111 | | DECLARE_WRITE16_MEMBER(sandscrp_soundlatch_word_w); |
| 112 | | DECLARE_WRITE8_MEMBER(sandscrp_bankswitch_w); |
| 113 | | DECLARE_READ8_MEMBER(sandscrp_latchstatus_r); |
| 114 | | DECLARE_READ8_MEMBER(sandscrp_soundlatch_r); |
| 115 | | DECLARE_WRITE8_MEMBER(sandscrp_soundlatch_w); |
| 116 | | virtual void machine_reset(); |
| 117 | | UINT32 screen_update_sandscrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 118 | | void screen_eof_sandscrp(screen_device &screen, bool state); |
| 119 | | INTERRUPT_GEN_MEMBER(sandscrp_interrupt); |
| 105 | |
| 106 | DECLARE_READ16_MEMBER(irq_cause_r); |
| 107 | DECLARE_WRITE16_MEMBER(irq_cause_w); |
| 108 | DECLARE_WRITE16_MEMBER(coincounter_w); |
| 109 | DECLARE_READ16_MEMBER(latchstatus_word_r); |
| 110 | DECLARE_WRITE16_MEMBER(latchstatus_word_w); |
| 111 | DECLARE_READ16_MEMBER(soundlatch_word_r); |
| 112 | DECLARE_WRITE16_MEMBER(soundlatch_word_w); |
| 113 | DECLARE_WRITE8_MEMBER(bankswitch_w); |
| 114 | DECLARE_READ8_MEMBER(latchstatus_r); |
| 115 | DECLARE_READ8_MEMBER(soundlatch_r); |
| 116 | DECLARE_WRITE8_MEMBER(soundlatch_w); |
| 117 | |
| 118 | virtual void machine_start(); |
| 119 | |
| 120 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 121 | void screen_eof(screen_device &screen, bool state); |
| 122 | |
| 123 | INTERRUPT_GEN_MEMBER(interrupt); |
| 120 | 124 | void update_irq_state(); |
| 121 | | DECLARE_WRITE_LINE_MEMBER(irqhandler); |
| 122 | | DECLARE_DRIVER_INIT(sandscp); |
| 123 | 125 | }; |
| 124 | 126 | |
| 125 | 127 | |
| 126 | 128 | |
| 127 | | UINT32 sandscrp_state::screen_update_sandscrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 129 | UINT32 sandscrp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 128 | 130 | { |
| 129 | 131 | bitmap.fill(0, cliprect); |
| 130 | 132 | |
| 131 | | int i; |
| 132 | | |
| 133 | 133 | screen.priority().fill(0, cliprect); |
| 134 | 134 | |
| 135 | 135 | m_view2_0->kaneko16_prepare(bitmap, cliprect); |
| 136 | 136 | |
| 137 | | for ( i = 0; i < 8; i++ ) |
| 137 | for ( int i = 0; i < 8; i++ ) |
| 138 | 138 | { |
| 139 | 139 | m_view2_0->render_tilemap_chip(screen,bitmap,cliprect,i); |
| 140 | 140 | } |
| r244698 | r244699 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | |
| 150 | | void sandscrp_state::machine_reset() |
| 150 | void sandscrp_state::machine_start() |
| 151 | 151 | { |
| 152 | membank("bank1")->configure_entries(0, 8, memregion("audiocpu")->base(), 0x4000); |
| 153 | |
| 154 | save_item(NAME(m_sprite_irq)); |
| 155 | save_item(NAME(m_unknown_irq)); |
| 156 | save_item(NAME(m_vblank_irq)); |
| 157 | save_item(NAME(m_latch1_full)); |
| 158 | save_item(NAME(m_latch2_full)); |
| 152 | 159 | } |
| 153 | 160 | |
| 154 | | /* Sand Scorpion */ |
| 155 | 161 | |
| 156 | | |
| 157 | | |
| 158 | 162 | /* Update the IRQ state based on all possible causes */ |
| 159 | 163 | void sandscrp_state::update_irq_state() |
| 160 | 164 | { |
| r244698 | r244699 | |
| 167 | 171 | |
| 168 | 172 | |
| 169 | 173 | /* Called once/frame to generate the VBLANK interrupt */ |
| 170 | | INTERRUPT_GEN_MEMBER(sandscrp_state::sandscrp_interrupt) |
| 174 | INTERRUPT_GEN_MEMBER(sandscrp_state::interrupt) |
| 171 | 175 | { |
| 172 | 176 | m_vblank_irq = 1; |
| 173 | 177 | update_irq_state(); |
| 174 | 178 | } |
| 175 | 179 | |
| 176 | 180 | |
| 177 | | void sandscrp_state::screen_eof_sandscrp(screen_device &screen, bool state) |
| 181 | void sandscrp_state::screen_eof(screen_device &screen, bool state) |
| 178 | 182 | { |
| 179 | 183 | // rising edge |
| 180 | 184 | if (state) |
| r244698 | r244699 | |
| 186 | 190 | } |
| 187 | 191 | |
| 188 | 192 | /* Reads the cause of the interrupt */ |
| 189 | | READ16_MEMBER(sandscrp_state::sandscrp_irq_cause_r) |
| 193 | READ16_MEMBER(sandscrp_state::irq_cause_r) |
| 190 | 194 | { |
| 191 | 195 | return ( m_sprite_irq ? 0x08 : 0 ) | |
| 192 | 196 | ( m_unknown_irq ? 0x10 : 0 ) | |
| r244698 | r244699 | |
| 195 | 199 | |
| 196 | 200 | |
| 197 | 201 | /* Clear the cause of the interrupt */ |
| 198 | | WRITE16_MEMBER(sandscrp_state::sandscrp_irq_cause_w) |
| 202 | WRITE16_MEMBER(sandscrp_state::irq_cause_w) |
| 199 | 203 | { |
| 200 | 204 | if (ACCESSING_BITS_0_7) |
| 201 | 205 | { |
| r244698 | r244699 | |
| 216 | 220 | Sand Scorpion |
| 217 | 221 | ***************************************************************************/ |
| 218 | 222 | |
| 219 | | WRITE16_MEMBER(sandscrp_state::sandscrp_coin_counter_w) |
| 223 | WRITE16_MEMBER(sandscrp_state::coincounter_w) |
| 220 | 224 | { |
| 221 | 225 | if (ACCESSING_BITS_0_7) |
| 222 | 226 | { |
| r244698 | r244699 | |
| 226 | 230 | } |
| 227 | 231 | |
| 228 | 232 | |
| 229 | | READ16_MEMBER(sandscrp_state::sandscrp_latchstatus_word_r) |
| 233 | READ16_MEMBER(sandscrp_state::latchstatus_word_r) |
| 230 | 234 | { |
| 231 | 235 | return (m_latch1_full ? 0x80 : 0) | |
| 232 | 236 | (m_latch2_full ? 0x40 : 0) ; |
| 233 | 237 | } |
| 234 | 238 | |
| 235 | | WRITE16_MEMBER(sandscrp_state::sandscrp_latchstatus_word_w) |
| 239 | WRITE16_MEMBER(sandscrp_state::latchstatus_word_w) |
| 236 | 240 | { |
| 237 | 241 | if (ACCESSING_BITS_0_7) |
| 238 | 242 | { |
| r244698 | r244699 | |
| 241 | 245 | } |
| 242 | 246 | } |
| 243 | 247 | |
| 244 | | READ16_MEMBER(sandscrp_state::sandscrp_soundlatch_word_r) |
| 248 | READ16_MEMBER(sandscrp_state::soundlatch_word_r) |
| 245 | 249 | { |
| 246 | 250 | m_latch2_full = 0; |
| 247 | 251 | return soundlatch2_byte_r(space,0); |
| 248 | 252 | } |
| 249 | 253 | |
| 250 | | WRITE16_MEMBER(sandscrp_state::sandscrp_soundlatch_word_w) |
| 254 | WRITE16_MEMBER(sandscrp_state::soundlatch_word_w) |
| 251 | 255 | { |
| 252 | 256 | if (ACCESSING_BITS_0_7) |
| 253 | 257 | { |
| r244698 | r244699 | |
| 260 | 264 | |
| 261 | 265 | static ADDRESS_MAP_START( sandscrp, AS_PROGRAM, 16, sandscrp_state ) |
| 262 | 266 | AM_RANGE(0x000000, 0x07ffff) AM_ROM // ROM |
| 263 | | AM_RANGE(0x100000, 0x100001) AM_WRITE(sandscrp_irq_cause_w) // IRQ Ack |
| 267 | AM_RANGE(0x100000, 0x100001) AM_WRITE(irq_cause_w) // IRQ Ack |
| 264 | 268 | |
| 265 | 269 | AM_RANGE(0x700000, 0x70ffff) AM_RAM // RAM |
| 266 | 270 | AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE("calc1_mcu", kaneko_hit_device, kaneko_hit_r,kaneko_hit_w) |
| r244698 | r244699 | |
| 268 | 272 | AM_RANGE(0x400000, 0x403fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device, kaneko_tmap_vram_r, kaneko_tmap_vram_w ) |
| 269 | 273 | AM_RANGE(0x500000, 0x501fff) AM_DEVREADWRITE("pandora", kaneko_pandora_device, spriteram_LSB_r, spriteram_LSB_w ) // sprites |
| 270 | 274 | AM_RANGE(0x600000, 0x600fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette |
| 271 | | AM_RANGE(0xa00000, 0xa00001) AM_WRITE(sandscrp_coin_counter_w) // Coin Counters (Lockout unused) |
| 275 | AM_RANGE(0xa00000, 0xa00001) AM_WRITE(coincounter_w) // Coin Counters (Lockout unused) |
| 272 | 276 | AM_RANGE(0xb00000, 0xb00001) AM_READ_PORT("P1") |
| 273 | 277 | AM_RANGE(0xb00002, 0xb00003) AM_READ_PORT("P2") |
| 274 | 278 | AM_RANGE(0xb00004, 0xb00005) AM_READ_PORT("SYSTEM") |
| 275 | 279 | AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("UNK") |
| 276 | 280 | AM_RANGE(0xec0000, 0xec0001) AM_READ(watchdog_reset16_r) // |
| 277 | | AM_RANGE(0x800000, 0x800001) AM_READ(sandscrp_irq_cause_r) // IRQ Cause |
| 278 | | AM_RANGE(0xe00000, 0xe00001) AM_READWRITE(sandscrp_soundlatch_word_r, sandscrp_soundlatch_word_w) // From/To Sound CPU |
| 279 | | AM_RANGE(0xe40000, 0xe40001) AM_READWRITE(sandscrp_latchstatus_word_r, sandscrp_latchstatus_word_w) // |
| 281 | AM_RANGE(0x800000, 0x800001) AM_READ(irq_cause_r) // IRQ Cause |
| 282 | AM_RANGE(0xe00000, 0xe00001) AM_READWRITE(soundlatch_word_r, soundlatch_word_w) // From/To Sound CPU |
| 283 | AM_RANGE(0xe40000, 0xe40001) AM_READWRITE(latchstatus_word_r, latchstatus_word_w) // |
| 280 | 284 | ADDRESS_MAP_END |
| 281 | 285 | |
| 282 | 286 | |
| r244698 | r244699 | |
| 285 | 289 | Sand Scorpion |
| 286 | 290 | ***************************************************************************/ |
| 287 | 291 | |
| 288 | | WRITE8_MEMBER(sandscrp_state::sandscrp_bankswitch_w) |
| 292 | WRITE8_MEMBER(sandscrp_state::bankswitch_w) |
| 289 | 293 | { |
| 290 | 294 | membank("bank1")->set_entry(data & 7); |
| 291 | 295 | } |
| 292 | 296 | |
| 293 | | READ8_MEMBER(sandscrp_state::sandscrp_latchstatus_r) |
| 297 | READ8_MEMBER(sandscrp_state::latchstatus_r) |
| 294 | 298 | { |
| 295 | 299 | return (m_latch2_full ? 0x80 : 0) | // swapped!? |
| 296 | 300 | (m_latch1_full ? 0x40 : 0) ; |
| 297 | 301 | } |
| 298 | 302 | |
| 299 | | READ8_MEMBER(sandscrp_state::sandscrp_soundlatch_r) |
| 303 | READ8_MEMBER(sandscrp_state::soundlatch_r) |
| 300 | 304 | { |
| 301 | 305 | m_latch1_full = 0; |
| 302 | 306 | return soundlatch_byte_r(space,0); |
| 303 | 307 | } |
| 304 | 308 | |
| 305 | | WRITE8_MEMBER(sandscrp_state::sandscrp_soundlatch_w) |
| 309 | WRITE8_MEMBER(sandscrp_state::soundlatch_w) |
| 306 | 310 | { |
| 307 | 311 | m_latch2_full = 1; |
| 308 | 312 | soundlatch2_byte_w(space,0,data); |
| r244698 | r244699 | |
| 316 | 320 | |
| 317 | 321 | static ADDRESS_MAP_START( sandscrp_soundport, AS_IO, 8, sandscrp_state ) |
| 318 | 322 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 319 | | AM_RANGE(0x00, 0x00) AM_WRITE(sandscrp_bankswitch_w) // ROM Bank |
| 323 | AM_RANGE(0x00, 0x00) AM_WRITE(bankswitch_w) // ROM Bank |
| 320 | 324 | AM_RANGE(0x02, 0x03) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write) // PORTA/B read |
| 321 | 325 | AM_RANGE(0x04, 0x04) AM_DEVWRITE("oki", okim6295_device, write) // OKIM6295 |
| 322 | | AM_RANGE(0x06, 0x06) AM_WRITE(sandscrp_soundlatch_w) // |
| 323 | | AM_RANGE(0x07, 0x07) AM_READ(sandscrp_soundlatch_r) // |
| 324 | | AM_RANGE(0x08, 0x08) AM_READ(sandscrp_latchstatus_r) // |
| 326 | AM_RANGE(0x06, 0x06) AM_WRITE(soundlatch_w) // |
| 327 | AM_RANGE(0x07, 0x07) AM_READ(soundlatch_r) // |
| 328 | AM_RANGE(0x08, 0x08) AM_READ(latchstatus_r) // |
| 325 | 329 | ADDRESS_MAP_END |
| 326 | 330 | |
| 327 | 331 | |
| r244698 | r244699 | |
| 455 | 459 | Sand Scorpion |
| 456 | 460 | ***************************************************************************/ |
| 457 | 461 | |
| 458 | | /* YM3014B + YM2203C */ |
| 459 | 462 | |
| 460 | | WRITE_LINE_MEMBER(sandscrp_state::irqhandler) |
| 461 | | { |
| 462 | | m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); |
| 463 | | } |
| 464 | | |
| 465 | 463 | static MACHINE_CONFIG_START( sandscrp, sandscrp_state ) |
| 466 | 464 | |
| 467 | 465 | /* basic machine hardware */ |
| 468 | 466 | MCFG_CPU_ADD("maincpu", M68000,12000000) /* TMP68HC000N-12 */ |
| 469 | 467 | MCFG_CPU_PROGRAM_MAP(sandscrp) |
| 470 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", sandscrp_state, sandscrp_interrupt) |
| 468 | MCFG_CPU_VBLANK_INT_DRIVER("screen", sandscrp_state, interrupt) |
| 471 | 469 | |
| 472 | 470 | MCFG_CPU_ADD("audiocpu", Z80,4000000) /* Z8400AB1, Reads the DSWs: it can't be disabled */ |
| 473 | 471 | MCFG_CPU_PROGRAM_MAP(sandscrp_soundmem) |
| r244698 | r244699 | |
| 481 | 479 | MCFG_SCREEN_VBLANK_TIME( ATTOSECONDS_IN_USEC(2500) /* not accurate */ ) |
| 482 | 480 | MCFG_SCREEN_SIZE(256, 256) |
| 483 | 481 | MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0+16, 256-16-1) |
| 484 | | MCFG_SCREEN_UPDATE_DRIVER(sandscrp_state, screen_update_sandscrp) |
| 485 | | MCFG_SCREEN_VBLANK_DRIVER(sandscrp_state, screen_eof_sandscrp) |
| 482 | MCFG_SCREEN_UPDATE_DRIVER(sandscrp_state, screen_update) |
| 483 | MCFG_SCREEN_VBLANK_DRIVER(sandscrp_state, screen_eof) |
| 486 | 484 | MCFG_SCREEN_PALETTE("palette") |
| 487 | 485 | |
| 488 | 486 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", sandscrp) |
| r244698 | r244699 | |
| 508 | 506 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) |
| 509 | 507 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) |
| 510 | 508 | |
| 509 | /* YM3014B + YM2203C */ |
| 511 | 510 | MCFG_SOUND_ADD("ymsnd", YM2203, 4000000) |
| 512 | | MCFG_YM2203_IRQ_HANDLER(WRITELINE(sandscrp_state, irqhandler)) |
| 511 | MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0)) |
| 513 | 512 | MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW1")) |
| 514 | 513 | MCFG_AY8910_PORT_B_READ_CB(IOPORT("DSW2")) |
| 515 | 514 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) |
| r244698 | r244699 | |
| 517 | 516 | MACHINE_CONFIG_END |
| 518 | 517 | |
| 519 | 518 | |
| 520 | | DRIVER_INIT_MEMBER(sandscrp_state, sandscp) |
| 521 | | { |
| 522 | | UINT8 *ROM = memregion("audiocpu")->base(); |
| 523 | | membank("bank1")->configure_entries(0, 8, ROM, 0x4000); |
| 524 | | } |
| 525 | | |
| 526 | 519 | /*************************************************************************** |
| 527 | 520 | |
| 528 | 521 | Sand Scorpion |
| r244698 | r244699 | |
| 590 | 583 | ROM_END |
| 591 | 584 | |
| 592 | 585 | |
| 593 | | GAME( 1992, sandscrp, 0, sandscrp, sandscrp, sandscrp_state, sandscp, ROT90, "Face", "Sand Scorpion", 0 ) |
| 594 | | GAME( 1992, sandscrpa, sandscrp, sandscrp, sandscrp, sandscrp_state, sandscp, ROT90, "Face", "Sand Scorpion (Earlier)", 0 ) |
| 595 | | GAME( 1992, sandscrpb, sandscrp, sandscrp, sandscrp, sandscrp_state, sandscp, ROT90, "Face", "Sand Scorpion (Chinese Title Screen, Revised Hardware)", 0 ) |
| 586 | GAME( 1992, sandscrp, 0, sandscrp, sandscrp, driver_device, 0, ROT90, "Face", "Sand Scorpion", GAME_SUPPORTS_SAVE ) |
| 587 | GAME( 1992, sandscrpa, sandscrp, sandscrp, sandscrp, driver_device, 0, ROT90, "Face", "Sand Scorpion (Earlier)", GAME_SUPPORTS_SAVE ) |
| 588 | GAME( 1992, sandscrpb, sandscrp, sandscrp, sandscrp, driver_device, 0, ROT90, "Face", "Sand Scorpion (Chinese Title Screen, Revised Hardware)", GAME_SUPPORTS_SAVE ) |