trunk/src/mame/drivers/peplus.c
r241520 | r241521 | |
203 | 203 | { |
204 | 204 | TIMER_ASSERT_LP |
205 | 205 | }; |
206 | | |
207 | | peplus_state(const machine_config &mconfig, device_type type, const char *tag)
|
208 | | : driver_device(mconfig, type, tag),
|
209 | | m_maincpu(*this, "maincpu"),
|
210 | | m_crtc(*this, "crtc"),
|
211 | | m_i2cmem(*this, "i2cmem"),
|
212 | | m_screen(*this, "screen"),
|
213 | | m_gfxdecode(*this, "gfxdecode"),
|
214 | | m_palette(*this, "palette"),
|
215 | | m_cmos_ram(*this, "cmos"),
|
216 | | m_program_ram(*this, "prograram"),
|
217 | | m_s3000_ram(*this, "s3000_ram"),
|
218 | | m_s5000_ram(*this, "s5000_ram"),
|
| 206 | |
| 207 | peplus_state(const machine_config &mconfig, device_type type, const char *tag) |
| 208 | : driver_device(mconfig, type, tag), |
| 209 | m_maincpu(*this, "maincpu"), |
| 210 | m_crtc(*this, "crtc"), |
| 211 | m_i2cmem(*this, "i2cmem"), |
| 212 | m_screen(*this, "screen"), |
| 213 | m_gfxdecode(*this, "gfxdecode"), |
| 214 | m_palette(*this, "palette"), |
| 215 | m_cmos_ram(*this, "cmos"), |
| 216 | m_program_ram(*this, "prograram"), |
| 217 | m_s3000_ram(*this, "s3000_ram"), |
| 218 | m_s5000_ram(*this, "s5000_ram"), |
219 | 219 | m_videoram(*this, "videoram"), |
220 | 220 | m_s7000_ram(*this, "s7000_ram"), |
221 | | m_sb000_ram(*this, "sb000_ram"),
|
222 | | m_sd000_ram(*this, "sd000_ram"),
|
223 | | m_sf000_ram(*this, "sf000_ram"),
|
224 | | m_io_port(*this, "io_port")
|
225 | | {
|
226 | | }
|
227 | | |
228 | | required_device<cpu_device> m_maincpu;
|
229 | | required_device<r6545_1_device> m_crtc;
|
230 | | required_device<i2cmem_device> m_i2cmem;
|
231 | | required_device<screen_device> m_screen;
|
232 | | required_device<gfxdecode_device> m_gfxdecode;
|
233 | | required_device<palette_device> m_palette;
|
234 | |
|
235 | | required_shared_ptr<UINT8> m_cmos_ram;
|
236 | | required_shared_ptr<UINT8> m_program_ram;
|
237 | | required_shared_ptr<UINT8> m_s3000_ram;
|
| 221 | m_sb000_ram(*this, "sb000_ram"), |
| 222 | m_sd000_ram(*this, "sd000_ram"), |
| 223 | m_sf000_ram(*this, "sf000_ram"), |
| 224 | m_io_port(*this, "io_port") |
| 225 | { |
| 226 | } |
| 227 | |
| 228 | required_device<cpu_device> m_maincpu; |
| 229 | required_device<r6545_1_device> m_crtc; |
| 230 | required_device<i2cmem_device> m_i2cmem; |
| 231 | required_device<screen_device> m_screen; |
| 232 | required_device<gfxdecode_device> m_gfxdecode; |
| 233 | required_device<palette_device> m_palette; |
| 234 | |
| 235 | required_shared_ptr<UINT8> m_cmos_ram; |
| 236 | required_shared_ptr<UINT8> m_program_ram; |
| 237 | required_shared_ptr<UINT8> m_s3000_ram; |
238 | 238 | required_shared_ptr<UINT8> m_s5000_ram; |
239 | 239 | required_shared_ptr<UINT8> m_videoram; |
240 | 240 | required_shared_ptr<UINT8> m_s7000_ram; |
241 | 241 | required_shared_ptr<UINT8> m_sb000_ram; |
242 | | required_shared_ptr<UINT8> m_sd000_ram;
|
243 | | required_shared_ptr<UINT8> m_sf000_ram;
|
244 | | required_shared_ptr<UINT8> m_io_port;
|
245 | |
|
246 | | tilemap_t *m_bg_tilemap;
|
247 | | UINT8 m_wingboard;
|
248 | | UINT8 m_doorcycle;
|
| 242 | required_shared_ptr<UINT8> m_sd000_ram; |
| 243 | required_shared_ptr<UINT8> m_sf000_ram; |
| 244 | required_shared_ptr<UINT8> m_io_port; |
| 245 | |
| 246 | tilemap_t *m_bg_tilemap; |
| 247 | UINT8 m_wingboard; |
| 248 | UINT8 m_doorcycle; |
249 | 249 | UINT16 door_wait; |
250 | 250 | UINT8 m_jumper_e16_e17; |
251 | 251 | UINT16 m_vid_address; |
r241520 | r241521 | |
267 | 267 | UINT8 m_bv_last_enable_state; |
268 | 268 | UINT8 m_bv_enable_state; |
269 | 269 | UINT8 m_bv_enable_count; |
270 | | UINT8 m_bv_data_bit;
|
271 | | UINT8 m_bv_loop_count;
|
272 | | UINT16 id023_data;
|
273 | |
|
274 | | DECLARE_WRITE8_MEMBER(peplus_bgcolor_w);
|
275 | | DECLARE_WRITE8_MEMBER(peplus_crtc_display_w);
|
276 | | DECLARE_WRITE8_MEMBER(peplus_duart_w);
|
277 | | DECLARE_WRITE8_MEMBER(peplus_cmos_w);
|
278 | | DECLARE_WRITE8_MEMBER(peplus_output_bank_a_w);
|
279 | | DECLARE_WRITE8_MEMBER(peplus_output_bank_b_w);
|
280 | | DECLARE_WRITE8_MEMBER(peplus_output_bank_c_w);
|
281 | | DECLARE_READ8_MEMBER(peplus_duart_r);
|
282 | | DECLARE_READ8_MEMBER(peplus_bgcolor_r);
|
283 | | DECLARE_READ8_MEMBER(peplus_dropdoor_r);
|
284 | | DECLARE_READ8_MEMBER(peplus_watchdog_r);
|
| 270 | UINT8 m_bv_data_bit; |
| 271 | UINT8 m_bv_loop_count; |
| 272 | UINT16 id023_data; |
| 273 | |
| 274 | DECLARE_WRITE8_MEMBER(peplus_bgcolor_w); |
| 275 | DECLARE_WRITE8_MEMBER(peplus_crtc_display_w); |
| 276 | DECLARE_WRITE8_MEMBER(peplus_duart_w); |
| 277 | DECLARE_WRITE8_MEMBER(peplus_cmos_w); |
| 278 | DECLARE_WRITE8_MEMBER(peplus_output_bank_a_w); |
| 279 | DECLARE_WRITE8_MEMBER(peplus_output_bank_b_w); |
| 280 | DECLARE_WRITE8_MEMBER(peplus_output_bank_c_w); |
| 281 | DECLARE_READ8_MEMBER(peplus_duart_r); |
| 282 | DECLARE_READ8_MEMBER(peplus_bgcolor_r); |
| 283 | DECLARE_READ8_MEMBER(peplus_dropdoor_r); |
| 284 | DECLARE_READ8_MEMBER(peplus_watchdog_r); |
285 | 285 | DECLARE_CUSTOM_INPUT_MEMBER(peplus_input_r); |
286 | 286 | DECLARE_WRITE8_MEMBER(peplus_crtc_mode_w); |
287 | 287 | DECLARE_WRITE_LINE_MEMBER(crtc_vsync); |
r241520 | r241521 | |
296 | 296 | MC6845_ON_UPDATE_ADDR_CHANGED(crtc_addr); |
297 | 297 | virtual void machine_reset(); |
298 | 298 | virtual void video_start(); |
299 | | UINT32 screen_update_peplus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
300 | | void peplus_load_superdata(const char *bank_name);
|
301 | | DECLARE_PALETTE_INIT(peplus);
|
302 | | void handle_lightpen();
|
303 | | |
304 | | protected:
|
305 | | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
| 299 | UINT32 screen_update_peplus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 300 | void peplus_load_superdata(const char *bank_name); |
| 301 | DECLARE_PALETTE_INIT(peplus); |
| 302 | void handle_lightpen(); |
| 303 | |
| 304 | protected: |
| 305 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
306 | 306 | }; |
307 | 307 | |
308 | 308 | static const UINT8 id_022[8] = { 0x00, 0x01, 0x04, 0x09, 0x13, 0x16, 0x18, 0x00 }; |
r241520 | r241521 | |
382 | 382 | |
383 | 383 | void peplus_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
384 | 384 | { |
385 | | switch (id)
|
386 | | {
|
387 | | case TIMER_ASSERT_LP:
|
388 | | m_crtc->assert_light_pen_input();
|
389 | | break;
|
390 | | default:
|
391 | | assert_always(FALSE, "Unknown id in peplus_state::device_timer");
|
| 385 | switch (id) |
| 386 | { |
| 387 | case TIMER_ASSERT_LP: |
| 388 | m_crtc->assert_light_pen_input(); |
| 389 | break; |
| 390 | default: |
| 391 | assert_always(FALSE, "Unknown id in peplus_state::device_timer"); |
392 | 392 | } |
393 | | }
|
394 | | |
395 | | |
396 | | void peplus_state::handle_lightpen()
|
397 | | {
|
398 | | int x_val = ioport("TOUCH_X")->read_safe(0x00);
|
399 | | int y_val = ioport("TOUCH_Y")->read_safe(0x00);
|
400 | | const rectangle &vis_area = m_screen->visible_area();
|
401 | | int xt, yt;
|
402 | | |
403 | | xt = x_val * vis_area.width() / 1024 + vis_area.min_x;
|
404 | | yt = y_val * vis_area.height() / 1024 + vis_area.min_y;
|
405 | | |
406 | | timer_set(m_screen->time_until_pos(yt, xt), TIMER_ASSERT_LP, 0);
|
407 | | }
|
408 | | |
409 | | WRITE_LINE_MEMBER(peplus_state::crtc_vsync)
|
410 | | {
|
411 | | m_maincpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
|
412 | | handle_lightpen();
|
413 | | }
|
414 | | |
415 | | WRITE8_MEMBER(peplus_state::peplus_crtc_display_w)
|
| 393 | } |
| 394 | |
| 395 | |
| 396 | void peplus_state::handle_lightpen() |
416 | 397 | { |
| 398 | int x_val = ioport("TOUCH_X")->read_safe(0x00); |
| 399 | int y_val = ioport("TOUCH_Y")->read_safe(0x00); |
| 400 | const rectangle &vis_area = m_screen->visible_area(); |
| 401 | int xt, yt; |
| 402 | |
| 403 | xt = x_val * vis_area.width() / 1024 + vis_area.min_x; |
| 404 | yt = y_val * vis_area.height() / 1024 + vis_area.min_y; |
| 405 | |
| 406 | timer_set(m_screen->time_until_pos(yt, xt), TIMER_ASSERT_LP, 0); |
| 407 | } |
| 408 | |
| 409 | WRITE_LINE_MEMBER(peplus_state::crtc_vsync) |
| 410 | { |
| 411 | m_maincpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); |
| 412 | handle_lightpen(); |
| 413 | } |
| 414 | |
| 415 | WRITE8_MEMBER(peplus_state::peplus_crtc_display_w) |
| 416 | { |
417 | 417 | UINT8 *videoram = m_videoram; |
418 | 418 | videoram[m_vid_address] = data; |
419 | 419 | m_palette_ram[m_vid_address] = m_io_port[1]; |
420 | 420 | m_palette_ram2[m_vid_address] = m_io_port[3]; |
421 | 421 | |
422 | | m_bg_tilemap->mark_tile_dirty(m_vid_address);
|
423 | | |
424 | | /* An access here triggers a device read !*/
|
425 | | m_crtc->register_r(space, 0);
|
426 | | }
|
427 | | |
428 | | WRITE8_MEMBER(peplus_state::peplus_duart_w)
|
| 422 | m_bg_tilemap->mark_tile_dirty(m_vid_address); |
| 423 | |
| 424 | /* An access here triggers a device read !*/ |
| 425 | m_crtc->register_r(space, 0); |
| 426 | } |
| 427 | |
| 428 | WRITE8_MEMBER(peplus_state::peplus_duart_w) |
429 | 429 | { |
430 | 430 | // Used for Slot Accounting System Communication |
431 | 431 | } |
r241520 | r241521 | |
441 | 441 | peplus_load_superdata(bank_name); |
442 | 442 | } |
443 | 443 | |
444 | | m_cmos_ram[offset] = data;
|
445 | | }
|
446 | | |
447 | | WRITE8_MEMBER(peplus_state::peplus_output_bank_a_w)
|
448 | | {
|
449 | | output_set_value("pe_bnka0",(data >> 0) & 1); /* Coin Lockout */
|
| 444 | m_cmos_ram[offset] = data; |
| 445 | } |
| 446 | |
| 447 | WRITE8_MEMBER(peplus_state::peplus_output_bank_a_w) |
| 448 | { |
| 449 | output_set_value("pe_bnka0",(data >> 0) & 1); /* Coin Lockout */ |
450 | 450 | output_set_value("pe_bnka1",(data >> 1) & 1); /* Diverter */ |
451 | 451 | output_set_value("pe_bnka2",(data >> 2) & 1); /* Bell */ |
452 | 452 | output_set_value("pe_bnka3",(data >> 3) & 1); /* N/A */ |
r241520 | r241521 | |
495 | 495 | |
496 | 496 | |
497 | 497 | /**************** |
498 | | * Read Handlers *
|
499 | | ****************/
|
500 | | |
501 | | READ8_MEMBER(peplus_state::peplus_duart_r)
|
502 | | {
|
503 | | // Used for Slot Accounting System Communication
|
504 | | return 0x00;
|
505 | | }
|
506 | | |
507 | | /* Last Color in Every Palette is bgcolor */
|
508 | | READ8_MEMBER(peplus_state::peplus_bgcolor_r)
|
509 | | {
|
| 498 | * Read Handlers * |
| 499 | ****************/ |
| 500 | |
| 501 | READ8_MEMBER(peplus_state::peplus_duart_r) |
| 502 | { |
| 503 | // Used for Slot Accounting System Communication |
| 504 | return 0x00; |
| 505 | } |
| 506 | |
| 507 | /* Last Color in Every Palette is bgcolor */ |
| 508 | READ8_MEMBER(peplus_state::peplus_bgcolor_r) |
| 509 | { |
510 | 510 | return m_palette->pen_color(15); // Return bgcolor from First Palette |
511 | 511 | } |
512 | 512 | |
r241520 | r241521 | |
969 | 969 | static ADDRESS_MAP_START( peplus_map, AS_PROGRAM, 8, peplus_state ) |
970 | 970 | AM_RANGE(0x0000, 0xffff) AM_ROM AM_SHARE("prograram") |
971 | 971 | ADDRESS_MAP_END |
972 | | |
973 | | static ADDRESS_MAP_START( peplus_iomap, AS_IO, 8, peplus_state )
|
974 | | // Battery-backed RAM (0x1000-0x01fff Extended RAM for Superboards Only)
|
975 | | AM_RANGE(0x0000, 0x1fff) AM_RAM_WRITE(peplus_cmos_w) AM_SHARE("cmos")
|
976 | | |
977 | | // CRT Controller
|
978 | | AM_RANGE(0x2008, 0x2008) AM_WRITE(peplus_crtc_mode_w)
|
| 972 | |
| 973 | static ADDRESS_MAP_START( peplus_iomap, AS_IO, 8, peplus_state ) |
| 974 | // Battery-backed RAM (0x1000-0x01fff Extended RAM for Superboards Only) |
| 975 | AM_RANGE(0x0000, 0x1fff) AM_RAM_WRITE(peplus_cmos_w) AM_SHARE("cmos") |
| 976 | |
| 977 | // CRT Controller |
| 978 | AM_RANGE(0x2008, 0x2008) AM_WRITE(peplus_crtc_mode_w) |
979 | 979 | AM_RANGE(0x2080, 0x2080) AM_DEVREADWRITE("crtc", mc6845_device, status_r, address_w) |
980 | 980 | AM_RANGE(0x2081, 0x2081) AM_DEVREADWRITE("crtc", mc6845_device, register_r, register_w) |
981 | | AM_RANGE(0x2083, 0x2083) AM_DEVREAD("crtc", mc6845_device, register_r) AM_WRITE(peplus_crtc_display_w)
|
982 | | |
983 | | // Superboard Data
|
984 | | AM_RANGE(0x3000, 0x3fff) AM_RAM AM_SHARE("s3000_ram")
|
985 | | |
986 | | // Sound and Dipswitches
|
987 | | AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("aysnd", ay8910_device, address_w)
|
988 | | AM_RANGE(0x4004, 0x4004) AM_READ_PORT("SW1")/* likely ay8910 input port, not direct */ AM_DEVWRITE("aysnd", ay8910_device, data_w)
|
989 | | |
990 | | // Superboard Data
|
991 | | AM_RANGE(0x5000, 0x5fff) AM_RAM AM_SHARE("s5000_ram")
|
992 | | |
993 | | // Background Color Latch
|
994 | | AM_RANGE(0x6000, 0x6000) AM_READ(peplus_bgcolor_r) AM_WRITE(peplus_bgcolor_w)
|
| 981 | AM_RANGE(0x2083, 0x2083) AM_DEVREAD("crtc", mc6845_device, register_r) AM_WRITE(peplus_crtc_display_w) |
995 | 982 | |
| 983 | // Superboard Data |
| 984 | AM_RANGE(0x3000, 0x3fff) AM_RAM AM_SHARE("s3000_ram") |
| 985 | |
| 986 | // Sound and Dipswitches |
| 987 | AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("aysnd", ay8910_device, address_w) |
| 988 | AM_RANGE(0x4004, 0x4004) AM_READ_PORT("SW1")/* likely ay8910 input port, not direct */ AM_DEVWRITE("aysnd", ay8910_device, data_w) |
| 989 | |
| 990 | // Superboard Data |
| 991 | AM_RANGE(0x5000, 0x5fff) AM_RAM AM_SHARE("s5000_ram") |
| 992 | |
| 993 | // Background Color Latch |
| 994 | AM_RANGE(0x6000, 0x6000) AM_READ(peplus_bgcolor_r) AM_WRITE(peplus_bgcolor_w) |
| 995 | |
996 | 996 | // Bogus Location for Video RAM |
997 | | AM_RANGE(0x06001, 0x06400) AM_RAM AM_SHARE("videoram")
|
998 | | |
999 | | // Superboard Data
|
1000 | | AM_RANGE(0x7000, 0x7fff) AM_RAM AM_SHARE("s7000_ram")
|
1001 | | |
1002 | | // Input Bank A, Output Bank C
|
1003 | | AM_RANGE(0x8000, 0x8000) AM_READ(peplus_input_bank_a_r) AM_WRITE(peplus_output_bank_c_w)
|
| 997 | AM_RANGE(0x06001, 0x06400) AM_RAM AM_SHARE("videoram") |
1004 | 998 | |
| 999 | // Superboard Data |
| 1000 | AM_RANGE(0x7000, 0x7fff) AM_RAM AM_SHARE("s7000_ram") |
| 1001 | |
| 1002 | // Input Bank A, Output Bank C |
| 1003 | AM_RANGE(0x8000, 0x8000) AM_READ(peplus_input_bank_a_r) AM_WRITE(peplus_output_bank_c_w) |
| 1004 | |
1005 | 1005 | // Drop Door, I2C EEPROM Writes |
1006 | 1006 | AM_RANGE(0x9000, 0x9000) AM_READ(peplus_dropdoor_r) AM_WRITE(i2c_nvram_w) |
1007 | 1007 | |
1008 | 1008 | // Input Banks B & C, Output Bank B |
1009 | | AM_RANGE(0xa000, 0xa000) AM_READ(peplus_input0_r) AM_WRITE(peplus_output_bank_b_w)
|
1010 | | |
1011 | | // Superboard Data
|
1012 | | AM_RANGE(0xb000, 0xbfff) AM_RAM AM_SHARE("sb000_ram")
|
1013 | | |
1014 | | // Output Bank A
|
1015 | | AM_RANGE(0xc000, 0xc000) AM_READ(peplus_watchdog_r) AM_WRITE(peplus_output_bank_a_w)
|
1016 | | |
1017 | | // Superboard Data
|
1018 | | AM_RANGE(0xd000, 0xdfff) AM_RAM AM_SHARE("sd000_ram")
|
1019 | | |
1020 | | // DUART
|
1021 | | AM_RANGE(0xe000, 0xe00f) AM_READWRITE(peplus_duart_r, peplus_duart_w)
|
1022 | | |
1023 | | // Superboard Data
|
1024 | | AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("sf000_ram")
|
1025 | | |
1026 | | /* Ports start here */
|
1027 | | AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_RAM AM_SHARE("io_port")
|
1028 | | ADDRESS_MAP_END
|
1029 | | |
1030 | | |
| 1009 | AM_RANGE(0xa000, 0xa000) AM_READ(peplus_input0_r) AM_WRITE(peplus_output_bank_b_w) |
| 1010 | |
| 1011 | // Superboard Data |
| 1012 | AM_RANGE(0xb000, 0xbfff) AM_RAM AM_SHARE("sb000_ram") |
| 1013 | |
| 1014 | // Output Bank A |
| 1015 | AM_RANGE(0xc000, 0xc000) AM_READ(peplus_watchdog_r) AM_WRITE(peplus_output_bank_a_w) |
| 1016 | |
| 1017 | // Superboard Data |
| 1018 | AM_RANGE(0xd000, 0xdfff) AM_RAM AM_SHARE("sd000_ram") |
| 1019 | |
| 1020 | // DUART |
| 1021 | AM_RANGE(0xe000, 0xe00f) AM_READWRITE(peplus_duart_r, peplus_duart_w) |
| 1022 | |
| 1023 | // Superboard Data |
| 1024 | AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("sf000_ram") |
| 1025 | |
| 1026 | /* Ports start here */ |
| 1027 | AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_RAM AM_SHARE("io_port") |
| 1028 | ADDRESS_MAP_END |
| 1029 | |
| 1030 | |
1031 | 1031 | /************************* |
1032 | 1032 | * Input ports * |
1033 | 1033 | *************************/ |