trunk/src/mame/drivers/gunpey.c
| r21479 | r21480 | |
| 1 | | /* |
| 1 | /******************************************************************************************** |
| 2 | |
| 3 | |
| 4 | ============================================================================================= |
| 5 | |
| 2 | 6 | Gunpey |
| 3 | 7 | Banpresto, 2000 |
| 4 | 8 | |
| r21479 | r21480 | |
| 71 | 75 | Operating frequency: Up to 76MHz |
| 72 | 76 | Release: November 1999 |
| 73 | 77 | |
| 74 | | */ |
| 78 | ********************************************************************************************/ |
| 75 | 79 | |
| 76 | 80 | #include "emu.h" |
| 77 | 81 | #include "cpu/nec/nec.h" |
| r21479 | r21480 | |
| 83 | 87 | { |
| 84 | 88 | public: |
| 85 | 89 | gunpey_state(const machine_config &mconfig, device_type type, const char *tag) |
| 86 | | : driver_device(mconfig, type, tag) { } |
| 90 | : driver_device(mconfig, type, tag), |
| 91 | m_maincpu(*this, "maincpu") |
| 92 | { } |
| 87 | 93 | |
| 94 | required_device<cpu_device> m_maincpu; |
| 95 | |
| 88 | 96 | UINT16 *m_blit_buffer; |
| 89 | 97 | UINT16 m_blit_ram[0x10]; |
| 98 | UINT8 m_irq_cause, m_irq_mask; |
| 90 | 99 | DECLARE_WRITE8_MEMBER(gunpey_status_w); |
| 91 | 100 | DECLARE_READ8_MEMBER(gunpey_status_r); |
| 92 | 101 | DECLARE_READ8_MEMBER(gunpey_inputs_r); |
| r21479 | r21480 | |
| 95 | 104 | virtual void video_start(); |
| 96 | 105 | virtual void palette_init(); |
| 97 | 106 | UINT32 screen_update_gunpey(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 98 | | INTERRUPT_GEN_MEMBER(gunpey_interrupt); |
| 107 | TIMER_DEVICE_CALLBACK_MEMBER(gunpey_scanline); |
| 108 | void gunpey_irq_check(UINT8 irq_type); |
| 99 | 109 | }; |
| 100 | 110 | |
| 101 | 111 | |
| r21479 | r21480 | |
| 127 | 137 | if(cliprect.contains(x, y)) |
| 128 | 138 | bitmap.pix32(y, x) = b | (g<<8) | (r<<16); |
| 129 | 139 | |
| 130 | | |
| 131 | 140 | count++; |
| 132 | 141 | } |
| 133 | 142 | } |
| r21479 | r21480 | |
| 135 | 144 | return 0; |
| 136 | 145 | } |
| 137 | 146 | |
| 147 | void gunpey_state::gunpey_irq_check(UINT8 irq_type) |
| 148 | { |
| 149 | m_irq_cause |= irq_type; |
| 150 | |
| 151 | if(m_irq_cause & m_irq_mask) |
| 152 | m_maincpu->set_input_line_and_vector(0, HOLD_LINE, 0x200/4); |
| 153 | else |
| 154 | m_maincpu->set_input_line_and_vector(0, CLEAR_LINE, 0x200/4); |
| 155 | } |
| 156 | |
| 138 | 157 | WRITE8_MEMBER(gunpey_state::gunpey_status_w) |
| 139 | 158 | { |
| 159 | if(offset == 1) |
| 160 | { |
| 161 | m_irq_cause &= ~data; |
| 162 | gunpey_irq_check(0); |
| 163 | } |
| 164 | |
| 165 | if(offset == 0) |
| 166 | { |
| 167 | m_irq_mask = data; |
| 168 | gunpey_irq_check(0); |
| 169 | } |
| 140 | 170 | } |
| 141 | 171 | |
| 142 | 172 | READ8_MEMBER(gunpey_state::gunpey_status_r) |
| 143 | 173 | { |
| 144 | 174 | if(offset == 1) |
| 145 | | return 0x54; |
| 175 | return m_irq_cause; |
| 146 | 176 | |
| 147 | | return 0x00; |
| 177 | return m_irq_mask; |
| 148 | 178 | } |
| 149 | 179 | |
| 150 | 180 | READ8_MEMBER(gunpey_state::gunpey_inputs_r) |
| r21479 | r21480 | |
| 356 | 386 | |
| 357 | 387 | } |
| 358 | 388 | |
| 359 | | INTERRUPT_GEN_MEMBER(gunpey_state::gunpey_interrupt) |
| 389 | |
| 390 | /* Four irqs: |
| 391 | 0x01 really an irq? |
| 392 | 0x04 |
| 393 | 0x10 |
| 394 | 0x40 almost certainly vblank (reads inputs) |
| 395 | 0x80 |
| 396 | */ |
| 397 | TIMER_DEVICE_CALLBACK_MEMBER(gunpey_state::gunpey_scanline) |
| 360 | 398 | { |
| 361 | | device.execute().set_input_line_and_vector(0,HOLD_LINE,0x200/4); |
| 399 | int scanline = param; |
| 400 | |
| 401 | /* TODO */ |
| 402 | if(scanline == 480) |
| 403 | gunpey_irq_check(0x54); |
| 362 | 404 | } |
| 363 | 405 | |
| 364 | 406 | /***************************************************************************************/ |
| r21479 | r21480 | |
| 368 | 410 | MCFG_CPU_ADD("maincpu", V30, 57242400 / 4) |
| 369 | 411 | MCFG_CPU_PROGRAM_MAP(mem_map) |
| 370 | 412 | MCFG_CPU_IO_MAP(io_map) |
| 371 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", gunpey_state, gunpey_interrupt) |
| 413 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", gunpey_state, gunpey_scanline, "screen", 0, 1) |
| 372 | 414 | |
| 373 | 415 | /* video hardware */ |
| 416 | /* TODO: screen params */ |
| 374 | 417 | MCFG_SCREEN_ADD("screen", RASTER) |
| 375 | 418 | MCFG_SCREEN_REFRESH_RATE(60) |
| 376 | 419 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 377 | | MCFG_SCREEN_SIZE(512, 512) |
| 378 | | MCFG_SCREEN_VISIBLE_AREA(0*8, 512-1, 0*8, 512-1) |
| 420 | MCFG_SCREEN_SIZE(818, 525) |
| 421 | MCFG_SCREEN_VISIBLE_AREA(0*8, 640-1, 0*8, 480-1) |
| 379 | 422 | MCFG_SCREEN_UPDATE_DRIVER(gunpey_state, screen_update_gunpey) |
| 380 | 423 | |
| 381 | 424 | MCFG_PALETTE_LENGTH(0x800) |
| 382 | 425 | |
| 383 | | |
| 384 | 426 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker","rspeaker") |
| 385 | 427 | |
| 386 | 428 | MCFG_OKIM6295_ADD("oki", XTAL_16_9344MHz / 8, OKIM6295_PIN7_LOW) |