Previous 199869 Revisions Next

r17472 Saturday 25th August, 2012 at 19:14:08 UTC by Angelo Salese
Hooked up the protection chip, fails for unknown reasons
[src/mame/drivers]nss.c

trunk/src/mame/drivers/nss.c
r17471r17472
297297#include "cpu/z80/z80.h"
298298#include "machine/eeprom.h"
299299#include "machine/s3520cf.h"
300#include "machine/rp5h01.h"
300301#include "video/m50458.h"
301302#include "includes/snes.h"
302303#include "rendlay.h"
r17471r17472
308309   nss_state(const machine_config &mconfig, device_type type, const char *tag)
309310      : snes_state(mconfig, type, tag),
310311      m_m50458(*this,"m50458"),
311      m_s3520cf(*this, "s3520cf")
312      m_s3520cf(*this, "s3520cf"),
313      m_rp5h01(*this,"rp5h01")
312314      { }
313315
314316   required_device<m50458_device> m_m50458;
315317   required_device<s3520cf_device> m_s3520cf;
318   required_device<rp5h01_device> m_rp5h01;
316319   UINT8 m_wram_wp_flag;
317320   UINT8 *m_wram;
318321   UINT8 m_nmi_enable;
322   UINT8 m_cart_sel;
319323   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
320324
321325   DECLARE_READ8_MEMBER(spc_ram_100_r);
r17471r17472
325329   DECLARE_READ8_MEMBER(ram_wp_r);
326330   DECLARE_WRITE8_MEMBER(ram_wp_w);
327331   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);
328335   DECLARE_WRITE8_MEMBER(eeprom_w);
329336};
330337
r17471r17472
384391bp 6f8d check the EEPROM2 results
385392870d EEPROM2 result of checksum
386393
387bp 6dce onward looks bogus, but it's probably the way it's intended to be
394New notes:
388395
389M50458 charset is checked at 1382, a word checksum is provided at offsets 0xffe-0xfff of the given ROM
3960x3a7 is the protection check
390397
3980x8000 work RAM is for cart 1
3990x8100 work RAM is for cart 2
4000x8200 work RAM is for cart 3
401
391402*/
392403/*
393404Nocash info: http://nocash.emubase.de/fullsnes.htm
r17471r17472
470481      m_wram[offset] = data;
471482}
472483
484
485READ8_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
499WRITE8_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
473513WRITE8_MEMBER(nss_state::eeprom_w)
474514{
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*/
483515   ioport("EEPROMOUT")->write(data, 0xff);
484516}
485517
r17471r17472
490522   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("EEPROMIN")
491523   AM_RANGE(0xc000, 0xdfff) AM_ROM AM_REGION("ibios_rom", 0x6000 )
492524   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)
493527ADDRESS_MAP_END
494528
495529READ8_MEMBER(nss_state::port_00_r)
r17471r17472
506540*/
507541   UINT8 res;
508542
509   res = (machine().primary_screen->vblank() & 1) << 6;
543   res = 0 << 7;
544   res|= (machine().primary_screen->vblank() & 1) << 6;
510545   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x80) >> 7) << 5);
511546   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x80) >> 7) << 4);
512547   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x08) >> 3) << 3);
r17471r17472
547582   ioport("RTC_OSD")->write(data, 0xff);
548583}
549584
585WRITE8_MEMBER(nss_state::port_01_w)
586{
587   m_cart_sel = (data & 0xc) >> 2;
588}
589
550590static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state )
551591   /* TODO: I think that this actually masks to 0x7? */
552592   ADDRESS_MAP_GLOBAL_MASK(0xff)
r17471r17472
557597
558598   AM_RANGE(0x72, 0x72) AM_WRITE(rtc_osd_w)
559599   AM_RANGE(0x80, 0x80) AM_WRITE(port_00_w)
600   AM_RANGE(0x81, 0x81) AM_WRITE(port_01_w)
560601   AM_RANGE(0x82, 0x82) AM_WRITE(rtc_osd_w)
561602   AM_RANGE(0xea, 0xea) AM_WRITE(rtc_osd_w)
562603ADDRESS_MAP_END
r17471r17472
785826
786827   MCFG_M50458_ADD("m50458",4000000) /* TODO: clock */
787828   MCFG_S3520CF_ADD("s3520cf") /* RTC */
829   MCFG_RP5H01_ADD("rp5h01")
788830
789831   /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs for now */
790832   MCFG_DEFAULT_LAYOUT(layout_dualhsxs)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team