trunk/src/mame/drivers/nss.c
r17471 | r17472 | |
297 | 297 | #include "cpu/z80/z80.h" |
298 | 298 | #include "machine/eeprom.h" |
299 | 299 | #include "machine/s3520cf.h" |
| 300 | #include "machine/rp5h01.h" |
300 | 301 | #include "video/m50458.h" |
301 | 302 | #include "includes/snes.h" |
302 | 303 | #include "rendlay.h" |
r17471 | r17472 | |
308 | 309 | nss_state(const machine_config &mconfig, device_type type, const char *tag) |
309 | 310 | : snes_state(mconfig, type, tag), |
310 | 311 | m_m50458(*this,"m50458"), |
311 | | m_s3520cf(*this, "s3520cf") |
| 312 | m_s3520cf(*this, "s3520cf"), |
| 313 | m_rp5h01(*this,"rp5h01") |
312 | 314 | { } |
313 | 315 | |
314 | 316 | required_device<m50458_device> m_m50458; |
315 | 317 | required_device<s3520cf_device> m_s3520cf; |
| 318 | required_device<rp5h01_device> m_rp5h01; |
316 | 319 | UINT8 m_wram_wp_flag; |
317 | 320 | UINT8 *m_wram; |
318 | 321 | UINT8 m_nmi_enable; |
| 322 | UINT8 m_cart_sel; |
319 | 323 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
320 | 324 | |
321 | 325 | DECLARE_READ8_MEMBER(spc_ram_100_r); |
r17471 | r17472 | |
325 | 329 | DECLARE_READ8_MEMBER(ram_wp_r); |
326 | 330 | DECLARE_WRITE8_MEMBER(ram_wp_w); |
327 | 331 | DECLARE_WRITE8_MEMBER(rtc_osd_w); |
| 332 | DECLARE_WRITE8_MEMBER(port_01_w); |
| 333 | DECLARE_READ8_MEMBER(nss_prot_r); |
| 334 | DECLARE_WRITE8_MEMBER(nss_prot_w); |
328 | 335 | DECLARE_WRITE8_MEMBER(eeprom_w); |
329 | 336 | }; |
330 | 337 | |
r17471 | r17472 | |
384 | 391 | bp 6f8d check the EEPROM2 results |
385 | 392 | 870d EEPROM2 result of checksum |
386 | 393 | |
387 | | bp 6dce onward looks bogus, but it's probably the way it's intended to be |
| 394 | New notes: |
388 | 395 | |
389 | | M50458 charset is checked at 1382, a word checksum is provided at offsets 0xffe-0xfff of the given ROM |
| 396 | 0x3a7 is the protection check |
390 | 397 | |
| 398 | 0x8000 work RAM is for cart 1 |
| 399 | 0x8100 work RAM is for cart 2 |
| 400 | 0x8200 work RAM is for cart 3 |
| 401 | |
391 | 402 | */ |
392 | 403 | /* |
393 | 404 | Nocash info: http://nocash.emubase.de/fullsnes.htm |
r17471 | r17472 | |
470 | 481 | m_wram[offset] = data; |
471 | 482 | } |
472 | 483 | |
| 484 | |
| 485 | READ8_MEMBER(nss_state::nss_prot_r) |
| 486 | { |
| 487 | int data = 0xe7; |
| 488 | |
| 489 | if (m_cart_sel == 0) |
| 490 | { |
| 491 | rp5h01_enable_w(m_rp5h01, 0, 0); |
| 492 | data |= ((~rp5h01_counter_r(m_rp5h01, 0)) << 4) & 0x10; /* D4 */ |
| 493 | data |= ((rp5h01_data_r(m_rp5h01, 0)) << 3) & 0x08; /* D3 */ |
| 494 | rp5h01_enable_w(m_rp5h01, 0, 1); |
| 495 | } |
| 496 | return data; |
| 497 | } |
| 498 | |
| 499 | WRITE8_MEMBER(nss_state::nss_prot_w) |
| 500 | { |
| 501 | |
| 502 | if (m_cart_sel == 0) |
| 503 | { |
| 504 | rp5h01_enable_w(m_rp5h01, 0, 0); |
| 505 | rp5h01_test_w(m_rp5h01, 0, data & 0x10); /* D4 */ |
| 506 | rp5h01_clock_w(m_rp5h01, 0, data & 0x08); /* D3 */ |
| 507 | rp5h01_reset_w(m_rp5h01, 0, ~data & 0x01); /* D0, check me */ |
| 508 | rp5h01_enable_w(m_rp5h01, 0, 1); |
| 509 | } |
| 510 | //ioport("EEPROMOUT")->write(data, 0xff); |
| 511 | } |
| 512 | |
473 | 513 | WRITE8_MEMBER(nss_state::eeprom_w) |
474 | 514 | { |
475 | | /* |
476 | | x--- ---- Unknown/set (should be always 1) (EEPROM Reset (active low)?) |
477 | | -xx- ---- Unknown/unused (should be always 0) |
478 | | ---x ---- EEPROM Clock (0=Low=Clock, 1=High=Idle) ;(Data In/Out must be stable |
479 | | ---- x--- EEPROM Data Out (0=Low=Zero, 1=High=One) ;on raising CLK edge) |
480 | | ---- -xx- Unknown/unused (should be always 0) ;(and updated on falling edge) |
481 | | ---- ---x EEPROM Select (0=High=No, 1=Low=Select) |
482 | | */ |
483 | 515 | ioport("EEPROMOUT")->write(data, 0xff); |
484 | 516 | } |
485 | 517 | |
r17471 | r17472 | |
490 | 522 | AM_RANGE(0xa000, 0xa000) AM_READ_PORT("EEPROMIN") |
491 | 523 | AM_RANGE(0xc000, 0xdfff) AM_ROM AM_REGION("ibios_rom", 0x6000 ) |
492 | 524 | AM_RANGE(0xe000, 0xe000) AM_WRITE(eeprom_w) |
| 525 | AM_RANGE(0xe000, 0xffff) AM_READ(nss_prot_r) |
| 526 | AM_RANGE(0xe001, 0xffff) AM_WRITE(nss_prot_w) |
493 | 527 | ADDRESS_MAP_END |
494 | 528 | |
495 | 529 | READ8_MEMBER(nss_state::port_00_r) |
r17471 | r17472 | |
506 | 540 | */ |
507 | 541 | UINT8 res; |
508 | 542 | |
509 | | res = (machine().primary_screen->vblank() & 1) << 6; |
| 543 | res = 0 << 7; |
| 544 | res|= (machine().primary_screen->vblank() & 1) << 6; |
510 | 545 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x80) >> 7) << 5); |
511 | 546 | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x80) >> 7) << 4); |
512 | 547 | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x08) >> 3) << 3); |
r17471 | r17472 | |
547 | 582 | ioport("RTC_OSD")->write(data, 0xff); |
548 | 583 | } |
549 | 584 | |
| 585 | WRITE8_MEMBER(nss_state::port_01_w) |
| 586 | { |
| 587 | m_cart_sel = (data & 0xc) >> 2; |
| 588 | } |
| 589 | |
550 | 590 | static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state ) |
551 | 591 | /* TODO: I think that this actually masks to 0x7? */ |
552 | 592 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
r17471 | r17472 | |
557 | 597 | |
558 | 598 | AM_RANGE(0x72, 0x72) AM_WRITE(rtc_osd_w) |
559 | 599 | AM_RANGE(0x80, 0x80) AM_WRITE(port_00_w) |
| 600 | AM_RANGE(0x81, 0x81) AM_WRITE(port_01_w) |
560 | 601 | AM_RANGE(0x82, 0x82) AM_WRITE(rtc_osd_w) |
561 | 602 | AM_RANGE(0xea, 0xea) AM_WRITE(rtc_osd_w) |
562 | 603 | ADDRESS_MAP_END |
r17471 | r17472 | |
785 | 826 | |
786 | 827 | MCFG_M50458_ADD("m50458",4000000) /* TODO: clock */ |
787 | 828 | MCFG_S3520CF_ADD("s3520cf") /* RTC */ |
| 829 | MCFG_RP5H01_ADD("rp5h01") |
788 | 830 | |
789 | 831 | /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs for now */ |
790 | 832 | MCFG_DEFAULT_LAYOUT(layout_dualhsxs) |