trunk/src/mame/drivers/destroyr.c
| r248387 | r248388 | |
| 29 | 29 | |
| 30 | 30 | destroyr_state(const machine_config &mconfig, device_type type, const char *tag) |
| 31 | 31 | : driver_device(mconfig, type, tag), |
| 32 | | m_alpha_num_ram(*this, "alpha_nuram"), |
| 33 | | m_major_obj_ram(*this, "major_obj_ram"), |
| 34 | | m_minor_obj_ram(*this, "minor_obj_ram"), |
| 35 | 32 | m_maincpu(*this, "maincpu"), |
| 36 | 33 | m_gfxdecode(*this, "gfxdecode"), |
| 37 | 34 | m_screen(*this, "screen"), |
| 38 | | m_palette(*this, "palette") { } |
| 35 | m_palette(*this, "palette"), |
| 36 | m_alpha_num_ram(*this, "alpha_nuram"), |
| 37 | m_major_obj_ram(*this, "major_obj_ram"), |
| 38 | m_minor_obj_ram(*this, "minor_obj_ram") { } |
| 39 | 39 | |
| 40 | /* devices */ |
| 41 | required_device<cpu_device> m_maincpu; |
| 42 | required_device<gfxdecode_device> m_gfxdecode; |
| 43 | required_device<screen_device> m_screen; |
| 44 | required_device<palette_device> m_palette; |
| 45 | |
| 40 | 46 | /* memory pointers */ |
| 41 | 47 | required_shared_ptr<UINT8> m_alpha_num_ram; |
| 42 | 48 | required_shared_ptr<UINT8> m_major_obj_ram; |
| r248387 | r248388 | |
| 52 | 58 | int m_attract; |
| 53 | 59 | int m_motor_speed; |
| 54 | 60 | int m_noise; |
| 61 | emu_timer *m_dial_timer; |
| 62 | emu_timer *m_frame_timer; |
| 55 | 63 | |
| 56 | | /* devices */ |
| 57 | | required_device<cpu_device> m_maincpu; |
| 58 | | required_device<gfxdecode_device> m_gfxdecode; |
| 59 | | required_device<screen_device> m_screen; |
| 60 | | required_device<palette_device> m_palette; |
| 64 | DECLARE_WRITE8_MEMBER(misc_w); |
| 65 | DECLARE_WRITE8_MEMBER(cursor_load_w); |
| 66 | DECLARE_WRITE8_MEMBER(interrupt_ack_w); |
| 67 | DECLARE_WRITE8_MEMBER(output_w); |
| 68 | DECLARE_READ8_MEMBER(input_r); |
| 69 | DECLARE_READ8_MEMBER(scanline_r); |
| 61 | 70 | |
| 62 | | DECLARE_WRITE8_MEMBER(destroyr_misc_w); |
| 63 | | DECLARE_WRITE8_MEMBER(destroyr_cursor_load_w); |
| 64 | | DECLARE_WRITE8_MEMBER(destroyr_interrupt_ack_w); |
| 65 | | DECLARE_WRITE8_MEMBER(destroyr_output_w); |
| 66 | | DECLARE_READ8_MEMBER(destroyr_input_r); |
| 67 | | DECLARE_READ8_MEMBER(destroyr_scanline_r); |
| 68 | 71 | virtual void machine_start(); |
| 69 | 72 | virtual void machine_reset(); |
| 70 | 73 | DECLARE_PALETTE_INIT(destroyr); |
| 71 | | UINT32 screen_update_destroyr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 72 | | TIMER_CALLBACK_MEMBER(destroyr_dial_callback); |
| 73 | | TIMER_CALLBACK_MEMBER(destroyr_frame_callback); |
| 74 | 74 | |
| 75 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 76 | |
| 77 | TIMER_CALLBACK_MEMBER(dial_callback); |
| 78 | TIMER_CALLBACK_MEMBER(frame_callback); |
| 79 | |
| 75 | 80 | protected: |
| 76 | 81 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 77 | 82 | }; |
| 78 | 83 | |
| 79 | 84 | |
| 80 | | UINT32 destroyr_state::screen_update_destroyr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 85 | UINT32 destroyr_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 81 | 86 | { |
| 82 | 87 | int i, j; |
| 83 | 88 | |
| r248387 | r248388 | |
| 149 | 154 | switch (id) |
| 150 | 155 | { |
| 151 | 156 | case TIMER_DESTROYR_DIAL: |
| 152 | | destroyr_dial_callback(ptr, param); |
| 157 | dial_callback(ptr, param); |
| 153 | 158 | break; |
| 154 | 159 | case TIMER_DESTROYR_FRAME: |
| 155 | | destroyr_frame_callback(ptr, param); |
| 160 | frame_callback(ptr, param); |
| 156 | 161 | break; |
| 157 | 162 | default: |
| 158 | 163 | assert_always(FALSE, "Unknown id in destroyr_state::device_timer"); |
| r248387 | r248388 | |
| 160 | 165 | } |
| 161 | 166 | |
| 162 | 167 | |
| 163 | | TIMER_CALLBACK_MEMBER(destroyr_state::destroyr_dial_callback) |
| 168 | TIMER_CALLBACK_MEMBER(destroyr_state::dial_callback) |
| 164 | 169 | { |
| 165 | 170 | int dial = param; |
| 166 | 171 | |
| r248387 | r248388 | |
| 180 | 185 | } |
| 181 | 186 | |
| 182 | 187 | |
| 183 | | TIMER_CALLBACK_MEMBER(destroyr_state::destroyr_frame_callback) |
| 188 | TIMER_CALLBACK_MEMBER(destroyr_state::frame_callback) |
| 184 | 189 | { |
| 185 | 190 | m_potsense[0] = 0; |
| 186 | 191 | m_potsense[1] = 0; |
| 187 | 192 | |
| 188 | 193 | /* PCB supports two dials, but cab has only got one */ |
| 189 | | timer_set(m_screen->time_until_pos(ioport("PADDLE")->read()), TIMER_DESTROYR_DIAL); |
| 190 | | timer_set(m_screen->time_until_pos(0), TIMER_DESTROYR_FRAME); |
| 194 | m_dial_timer->adjust(m_screen->time_until_pos(ioport("PADDLE")->read())); |
| 195 | m_frame_timer->adjust(m_screen->time_until_pos(0)); |
| 191 | 196 | } |
| 192 | 197 | |
| 193 | 198 | |
| r248387 | r248388 | |
| 207 | 212 | } |
| 208 | 213 | |
| 209 | 214 | |
| 210 | | WRITE8_MEMBER(destroyr_state::destroyr_misc_w) |
| 215 | WRITE8_MEMBER(destroyr_state::misc_w) |
| 211 | 216 | { |
| 212 | 217 | /* bits 0 to 2 connect to the sound circuits */ |
| 213 | 218 | m_attract = data & 0x01; |
| r248387 | r248388 | |
| 222 | 227 | } |
| 223 | 228 | |
| 224 | 229 | |
| 225 | | WRITE8_MEMBER(destroyr_state::destroyr_cursor_load_w) |
| 230 | WRITE8_MEMBER(destroyr_state::cursor_load_w) |
| 226 | 231 | { |
| 227 | 232 | m_cursor = data; |
| 228 | 233 | watchdog_reset_w(space, offset, data); |
| 229 | 234 | } |
| 230 | 235 | |
| 231 | 236 | |
| 232 | | WRITE8_MEMBER(destroyr_state::destroyr_interrupt_ack_w) |
| 237 | WRITE8_MEMBER(destroyr_state::interrupt_ack_w) |
| 233 | 238 | { |
| 234 | 239 | m_maincpu->set_input_line(0, CLEAR_LINE); |
| 235 | 240 | } |
| 236 | 241 | |
| 237 | 242 | |
| 238 | | WRITE8_MEMBER(destroyr_state::destroyr_output_w) |
| 243 | WRITE8_MEMBER(destroyr_state::output_w) |
| 239 | 244 | { |
| 240 | | if (offset & 8) destroyr_misc_w(space, 8, data); |
| 245 | if (offset & 8) misc_w(space, 8, data); |
| 241 | 246 | |
| 242 | 247 | else switch (offset & 7) |
| 243 | 248 | { |
| r248387 | r248388 | |
| 269 | 274 | } |
| 270 | 275 | |
| 271 | 276 | |
| 272 | | READ8_MEMBER(destroyr_state::destroyr_input_r) |
| 277 | READ8_MEMBER(destroyr_state::input_r) |
| 273 | 278 | { |
| 274 | 279 | if (offset & 1) |
| 275 | 280 | { |
| r248387 | r248388 | |
| 290 | 295 | } |
| 291 | 296 | |
| 292 | 297 | |
| 293 | | READ8_MEMBER(destroyr_state::destroyr_scanline_r) |
| 298 | READ8_MEMBER(destroyr_state::scanline_r) |
| 294 | 299 | { |
| 295 | 300 | return m_screen->vpos(); |
| 296 | 301 | } |
| r248387 | r248388 | |
| 299 | 304 | static ADDRESS_MAP_START( destroyr_map, AS_PROGRAM, 8, destroyr_state ) |
| 300 | 305 | ADDRESS_MAP_GLOBAL_MASK(0x7fff) |
| 301 | 306 | AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0xf00) AM_RAM |
| 302 | | AM_RANGE(0x1000, 0x1fff) AM_READWRITE(destroyr_input_r, destroyr_output_w) |
| 307 | AM_RANGE(0x1000, 0x1fff) AM_READWRITE(input_r, output_w) |
| 303 | 308 | AM_RANGE(0x2000, 0x2fff) AM_READ_PORT("IN2") |
| 304 | 309 | AM_RANGE(0x3000, 0x30ff) AM_MIRROR(0xf00) AM_WRITEONLY AM_SHARE("alpha_nuram") |
| 305 | 310 | AM_RANGE(0x4000, 0x401f) AM_MIRROR(0xfe0) AM_WRITEONLY AM_SHARE("major_obj_ram") |
| 306 | | AM_RANGE(0x5000, 0x5000) AM_MIRROR(0xff8) AM_WRITE(destroyr_cursor_load_w) |
| 307 | | AM_RANGE(0x5001, 0x5001) AM_MIRROR(0xff8) AM_WRITE(destroyr_interrupt_ack_w) |
| 311 | AM_RANGE(0x5000, 0x5000) AM_MIRROR(0xff8) AM_WRITE(cursor_load_w) |
| 312 | AM_RANGE(0x5001, 0x5001) AM_MIRROR(0xff8) AM_WRITE(interrupt_ack_w) |
| 308 | 313 | AM_RANGE(0x5002, 0x5007) AM_MIRROR(0xff8) AM_WRITEONLY AM_SHARE("minor_obj_ram") |
| 309 | | AM_RANGE(0x6000, 0x6fff) AM_READ(destroyr_scanline_r) |
| 314 | AM_RANGE(0x6000, 0x6fff) AM_READ(scanline_r) |
| 310 | 315 | AM_RANGE(0x7000, 0x7fff) AM_ROM |
| 311 | 316 | ADDRESS_MAP_END |
| 312 | 317 | |
| r248387 | r248388 | |
| 469 | 474 | |
| 470 | 475 | void destroyr_state::machine_start() |
| 471 | 476 | { |
| 477 | m_dial_timer = timer_alloc(TIMER_DESTROYR_DIAL); |
| 478 | m_frame_timer = timer_alloc(TIMER_DESTROYR_FRAME); |
| 479 | |
| 472 | 480 | save_item(NAME(m_cursor)); |
| 473 | 481 | save_item(NAME(m_wavemod)); |
| 474 | 482 | save_item(NAME(m_attract)); |
| r248387 | r248388 | |
| 491 | 499 | MCFG_SCREEN_REFRESH_RATE(60) |
| 492 | 500 | MCFG_SCREEN_SIZE(256, 262) |
| 493 | 501 | MCFG_SCREEN_VISIBLE_AREA(0, 255, 0, 239) |
| 494 | | MCFG_SCREEN_UPDATE_DRIVER(destroyr_state, screen_update_destroyr) |
| 502 | MCFG_SCREEN_UPDATE_DRIVER(destroyr_state, screen_update) |
| 495 | 503 | MCFG_SCREEN_PALETTE("palette") |
| 496 | 504 | |
| 497 | 505 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", destroyr) |
| r248387 | r248388 | |
| 552 | 560 | ROM_END |
| 553 | 561 | |
| 554 | 562 | |
| 555 | | GAMEL( 1977, destroyr, 0, destroyr, destroyr, driver_device, 0, ORIENTATION_FLIP_X, "Atari", "Destroyer (version O2)", GAME_NO_SOUND, layout_destroyr ) |
| 556 | | GAMEL( 1977, destroyr1, destroyr, destroyr, destroyr, driver_device, 0, ORIENTATION_FLIP_X, "Atari", "Destroyer (version O1)", GAME_NO_SOUND, layout_destroyr ) |
| 563 | GAMEL( 1977, destroyr, 0, destroyr, destroyr, driver_device, 0, ORIENTATION_FLIP_X, "Atari", "Destroyer (version O2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE, layout_destroyr ) |
| 564 | GAMEL( 1977, destroyr1, destroyr, destroyr, destroyr, driver_device, 0, ORIENTATION_FLIP_X, "Atari", "Destroyer (version O1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE, layout_destroyr ) |