trunk/src/mame/drivers/flyball.c
| r32180 | r32181 | |
| 9 | 9 | MADE IN USA |
| 10 | 10 | PAT NO 3793483 |
| 11 | 11 | |
| 12 | |
| 13 | TODO: |
| 14 | - discrete sound |
| 15 | - accurate video timing |
| 16 | |
| 12 | 17 | ***************************************************************************/ |
| 13 | 18 | |
| 14 | 19 | #include "emu.h" |
| 15 | 20 | #include "cpu/m6502/m6502.h" |
| 16 | 21 | |
| 17 | | #define MASTER_CLOCK ( XTAL_12_096MHz ) |
| 22 | #define MASTER_CLOCK XTAL_12_096MHz |
| 23 | #define PIXEL_CLOCK (MASTER_CLOCK / 2) |
| 18 | 24 | |
| 19 | 25 | |
| 20 | | |
| 21 | 26 | class flyball_state : public driver_device |
| 22 | 27 | { |
| 23 | 28 | public: |
| 24 | 29 | enum |
| 25 | 30 | { |
| 26 | | TIMER_FLYBALL_JOYSTICK, |
| 31 | TIMER_FLYBALL_POT_ASSERT, |
| 32 | TIMER_FLYBALL_POT_CLEAR, |
| 27 | 33 | TIMER_FLYBALL_QUARTER |
| 28 | 34 | }; |
| 29 | 35 | |
| r32180 | r32181 | |
| 105 | 111 | int code = data & 63; |
| 106 | 112 | |
| 107 | 113 | if ((flags & TILE_FLIPX) && (flags & TILE_FLIPY)) |
| 108 | | { |
| 109 | 114 | code += 64; |
| 110 | | } |
| 111 | 115 | |
| 112 | 116 | SET_TILE_INFO_MEMBER(0, code, 0, flags); |
| 113 | 117 | } |
| r32180 | r32181 | |
| 127 | 131 | int ballx = m_ball_horz - 1; |
| 128 | 132 | int bally = m_ball_vert - 17; |
| 129 | 133 | |
| 130 | | int x; |
| 131 | | int y; |
| 132 | | |
| 133 | 134 | m_tmap->mark_all_dirty(); |
| 134 | 135 | |
| 135 | 136 | /* draw playfield */ |
| r32180 | r32181 | |
| 139 | 140 | m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, m_pitcher_pic ^ 0xf, 0, 1, 0, pitcherx, pitchery, 1); |
| 140 | 141 | |
| 141 | 142 | /* draw ball */ |
| 142 | | |
| 143 | | for (y = bally; y < bally + 2; y++) |
| 144 | | for (x = ballx; x < ballx + 2; x++) |
| 143 | for (int y = bally; y < bally + 2; y++) |
| 144 | for (int x = ballx; x < ballx + 2; x++) |
| 145 | 145 | if (cliprect.contains(x, y)) |
| 146 | 146 | bitmap.pix16(y, x) = 1; |
| 147 | |
| 147 | 148 | return 0; |
| 148 | 149 | } |
| 149 | 150 | |
| r32180 | r32181 | |
| 152 | 153 | { |
| 153 | 154 | switch (id) |
| 154 | 155 | { |
| 155 | | case TIMER_FLYBALL_JOYSTICK: |
| 156 | case TIMER_FLYBALL_POT_ASSERT: |
| 156 | 157 | flyball_joystick_callback(ptr, param); |
| 157 | 158 | break; |
| 159 | case TIMER_FLYBALL_POT_CLEAR: |
| 160 | m_maincpu->set_input_line(0, CLEAR_LINE); |
| 161 | break; |
| 158 | 162 | case TIMER_FLYBALL_QUARTER: |
| 159 | 163 | flyball_quarter_callback(ptr, param); |
| 160 | 164 | break; |
| 165 | |
| 161 | 166 | default: |
| 162 | 167 | assert_always(FALSE, "Unknown id in flyball_state::device_timer"); |
| 163 | 168 | } |
| r32180 | r32181 | |
| 169 | 174 | int potsense = param; |
| 170 | 175 | |
| 171 | 176 | if (potsense & ~m_potmask) |
| 172 | | generic_pulse_irq_line(*m_maincpu, 0, 1); |
| 177 | { |
| 178 | // pot irq is active at hsync |
| 179 | m_maincpu->set_input_line(0, ASSERT_LINE); |
| 180 | timer_set(attotime::from_ticks(32, PIXEL_CLOCK), TIMER_FLYBALL_POT_CLEAR, 0); |
| 181 | } |
| 173 | 182 | |
| 174 | 183 | m_potsense |= potsense; |
| 175 | 184 | } |
| r32180 | r32181 | |
| 189 | 198 | |
| 190 | 199 | for (i = 0; i < 64; i++) |
| 191 | 200 | if (potsense[i] != 0) |
| 192 | | timer_set(m_screen->time_until_pos(scanline + i), TIMER_FLYBALL_JOYSTICK, potsense[i]); |
| 201 | timer_set(m_screen->time_until_pos(scanline + i), TIMER_FLYBALL_POT_ASSERT, potsense[i]); |
| 193 | 202 | |
| 194 | 203 | scanline += 0x40; |
| 195 | 204 | scanline &= 0xff; |
| r32180 | r32181 | |
| 418 | 427 | |
| 419 | 428 | void flyball_state::machine_reset() |
| 420 | 429 | { |
| 421 | | int i; |
| 422 | | |
| 423 | 430 | /* address bits 0 through 8 are inverted */ |
| 424 | 431 | UINT8* ROM = memregion("maincpu")->base() + 0x2000; |
| 425 | 432 | |
| 426 | | for (i = 0; i < 0x1000; i++) |
| 433 | for (int i = 0; i < 0x1000; i++) |
| 427 | 434 | m_rombase[i] = ROM[i ^ 0x1ff]; |
| 428 | 435 | |
| 429 | 436 | m_maincpu->reset(); |
| r32180 | r32181 | |
| 445 | 452 | /* basic machine hardware */ |
| 446 | 453 | MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK/16) |
| 447 | 454 | MCFG_CPU_PROGRAM_MAP(flyball_map) |
| 448 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", flyball_state, nmi_line_pulse) |
| 455 | MCFG_CPU_VBLANK_INT_DRIVER("screen", flyball_state, nmi_line_pulse) |
| 449 | 456 | |
| 450 | | |
| 451 | 457 | /* video hardware */ |
| 452 | 458 | MCFG_SCREEN_ADD("screen", RASTER) |
| 453 | 459 | MCFG_SCREEN_REFRESH_RATE(60) |