Previous 199869 Revisions Next

r21444 Tuesday 26th February, 2013 at 09:39:14 UTC by Fabio Priuli
(MESS) megadriv.c: emulated protection in pirate Super Mario World 64, based on research by Eke and andlabs [Fabio Priuli]
[hash]megadriv.xml
[src/mess/drivers]megadriv.c
[src/mess/machine]md_rom.c md_rom.h md_slot.c md_slot.h

trunk/hash/megadriv.xml
r21443r21444
2611926119      </part>
2612026120   </software>
2612126121
26122   <software name="xinqig1" cloneof="xinqig">
26122   <software name="beggarp">
26123      <description>Beggar Prince (USA)</description>
26124      <year>2005</year>
26125      <publisher>Super Fighter Team</publisher>
26126      <part name="cart" interface="megadriv_cart">
26127         <feature name="slot" value="rom_beggar" />
26128         <dataarea name="rom" size="4194304">
26129            <rom name="beggar prince (unl).bin" size="4194304" crc="f3af46cd" sha1="f481b970756c482d8f408c4bab8902172837e7d8" offset="000000" loadflag="load16_word_swap" />
26130         </dataarea>
26131      </part>
26132   </software>
26133
26134   <software name="xinqig1" cloneof="beggarp">
2612326135      <description>Xin Qi Gai Wang Zi (Chi, Alt)</description>
2612426136      <year>1996</year>
2612526137      <publisher>C&amp;E</publisher>
r21443r21444
2613126143      </part>
2613226144   </software>
2613326145
26134   <software name="xinqig">
26146   <software name="xinqig" cloneof="beggarp">
2613526147      <description>Xin Qi Gai Wang Zi (Chi)</description>
2613626148      <year>1996</year>
2613726149      <publisher>C&amp;E</publisher>
r21443r21444
2686326875      </part>
2686426876   </software>
2686526877
26878   <software name="smw64">
26879      <description>Super Mario World 64</description>
26880      <year>199?</year>
26881      <publisher>&lt;unknown&gt;</publisher>
26882      <part name="cart" interface="megadriv_cart">
26883         <feature name="slot" value="rom_smw64" />
26884         <dataarea name="rom" size="1048576">
26885            <rom name="super mario world 64 (unl).bin" size="1048576" crc="e7ac4161" sha1="2ccf970fffd173f1984e69617c330a8f297f3481" offset="000000" loadflag="load16_word_swap" />
26886         </dataarea>
26887      </part>
26888   </software>
26889
2686626890   <software name="redcliff">
2686726891      <description>The Battle of Red Cliffs - Romance of the Three Kingdoms</description>
2686826892      <year>199?</year>
r21443r21444
2730027324      </part>
2730127325   </software>
2730227326
27327   <software name="chipndal">
27328      <description>Chip 'n Dale Rescue Rangers (Rus)</description>
27329      <year>199?</year>
27330      <publisher>&lt;unknown&gt;</publisher>
27331      <part name="cart" interface="megadriv_cart">
27332         <dataarea name="rom" size="468616">
27333            <rom name="chip and dale rescue rangers (unl).bin" size="468616" crc="09614862" sha1="d58c3b171ce88638d15df681670a8eb5725210a4" offset="000000" loadflag="load16_word_swap" />
27334         </dataarea>
27335      </part>
27336   </software>
27337
27338   <software name="chipndl2">
27339      <description>Chip 'n Dale Rescue Rangers 2 (Rus)</description>
27340      <year>199?</year>
27341      <publisher>&lt;unknown&gt;</publisher>
27342      <part name="cart" interface="megadriv_cart">
27343         <dataarea name="rom" size="616952">
27344            <rom name="chip and dale rescue rangers 2 (unl).bin" size="616952" crc="51eebddc" sha1="21d62ac2307147d733141e22399bb04616f977df" offset="000000" loadflag="load16_word_swap" />
27345         </dataarea>
27346      </part>
27347   </software>
27348
2730327349   <software name="commconq">
2730427350      <description>Command &amp; Conquer (Prototype)</description>
2730527351      <year>199?</year>
r21443r21444
2734427390      </part>
2734527391   </software>
2734627392
27393   <software name="darkwing">
27394      <description>Darkwing Duck (Rus)</description>
27395      <year>199?</year>
27396      <publisher>&lt;unknown&gt;</publisher>
27397      <part name="cart" interface="megadriv_cart">
27398         <dataarea name="rom" size="644592">
27399            <rom name="darkwing duck (unl).bin" size="644592" crc="922d49ff" sha1="ae238741113de481147ab20baee74d9c723453b5" offset="000000" loadflag="load16_word_swap" />
27400         </dataarea>
27401      </part>
27402   </software>
27403
2734727404   <software name="deathcal">
2734827405      <description>Death Caliber (Rus)</description>
2734927406      <year>199?</year>
r21443r21444
2739027447      </part>
2739127448   </software>
2739227449
27450   <software name="dbfb">
27451      <description>Dragon Ball Final Bout (Chi?)</description>
27452      <year>1998</year>
27453      <publisher>&lt;unknown&gt;</publisher>
27454      <part name="cart" interface="megadriv_cart">
27455         <dataarea name="rom" size="2097152">
27456            <rom name="dragon ball final bout (unl).bin" size="2097152" crc="63847005" sha1="6014cbf37fbabc51df581f7a93a1f8df09a66665" offset="000000" loadflag="load16_word_swap" />
27457         </dataarea>
27458      </part>
27459   </software>
27460
27461   <software name="felix">
27462      <description>Felix the Cat (Rus)</description>
27463      <year>199?</year>
27464      <publisher>&lt;unknown&gt;</publisher>
27465      <part name="cart" interface="megadriv_cart">
27466         <dataarea name="rom" size="737528">
27467            <rom name="felix the cat (unl).bin" size="737528" crc="90c4655c" sha1="6954e0c76a3585d74c7394b574d8e01cf4edb577" offset="000000" loadflag="load16_word_swap" />
27468         </dataarea>
27469      </part>
27470   </software>
27471
2739327472   <software name="fifa2k2" cloneof="wcs2">
2739427473      <description>FIFA World Cup 2002 (Rus)</description>
2739527474      <year>199?</year>
r21443r21444
2768427763      <info name="alt_title" value="Mario 3 Вокруг света"/>
2768527764      <part name="cart" interface="megadriv_cart">
2768627765         <dataarea name="rom" size="2097152">
27687            <rom name="mario 3 (unl).bin" size="2097152" crc="69f5b02f" sha1="7c2ebe7c88503bc719d5bcecae183619a7be503c" offset="000000" loadflag="load16_word_swap" />
27766            <rom name="mario 3 (unl)[a1].bin" size="2097152" crc="6f630ebd" sha1="167f17f3a9d24f5d3ed1fbf7d7310fae53015258" offset="000000" loadflag="load16_word_swap" />
2768827767         </dataarea>
2768927768      </part>
2769027769   </software>
2769127770
27692   <software name="mario4">
27693      <description>Mario 4 - Kosmicheskaya Odissyeya (Rus)</description>
27771   <software name="mario3d" cloneof="mario3">
27772      <description>Mario 3 - Vokrug Sveta (Rus, Demo?)</description>
2769427773      <year>199?</year>
2769527774      <publisher>&lt;unknown&gt;</publisher>
27696      <info name="alt_title" value="Mario 4 Космическая одиссея"/>
27775      <info name="alt_title" value="Mario 3 Вокруг света"/>
2769727776      <part name="cart" interface="megadriv_cart">
2769827777         <dataarea name="rom" size="2097152">
27699            <rom name="mario 4 (unl).bin" size="2097152" crc="96b0ecd9" sha1="6c9444268413b76d698ea432cbceb4cdc9a6cfaf" offset="000000" loadflag="load16_word_swap" />
27778            <rom name="mario 3 (unl).bin" size="2097152" crc="69f5b02f" sha1="7c2ebe7c88503bc719d5bcecae183619a7be503c" offset="000000" loadflag="load16_word_swap" />
2770027779         </dataarea>
2770127780      </part>
2770227781   </software>
2770327782
27704<!-- Needs emulation of the protection. -->
27705   <software name="smario64" supported="no">
27706      <description>Super Mario World 64</description>
27783   <software name="mario4">
27784      <description>Mario 4 - Kosmicheskaya Odissyeya (Rus)</description>
2770727785      <year>199?</year>
2770827786      <publisher>&lt;unknown&gt;</publisher>
27787      <info name="alt_title" value="Mario 4 Космическая одиссея"/>
2770927788      <part name="cart" interface="megadriv_cart">
27710         <dataarea name="rom" size="1048576">
27711            <rom name="super mario world 64 (unl).bin" size="1048576" crc="e7ac4161" sha1="2ccf970fffd173f1984e69617c330a8f297f3481" offset="000000" loadflag="load16_word_swap" />
27789         <dataarea name="rom" size="2097152">
27790            <rom name="mario 4 (unl).bin" size="2097152" crc="96b0ecd9" sha1="6c9444268413b76d698ea432cbceb4cdc9a6cfaf" offset="000000" loadflag="load16_word_swap" />
2771227791         </dataarea>
2771327792      </part>
2771427793   </software>
2771527794
27716<!-- This can be removed when protected version is emulated correctly -->
27717   <software name="smario64h" cloneof="smario64">
27718      <description>Super Mario World 64 (Hacked Protection)</description>
27719      <year>199?</year>
27720      <publisher>&lt;unknown&gt;</publisher>
27721      <part name="cart" interface="megadriv_cart">
27722         <dataarea name="rom" size="1048576">
27723            <rom name="super mario world 64 (hacked).bin" size="1048576" crc="a20f98aa" sha1="47fd007173419906ecdc7b0efc7d49f42de70c91" offset="000000" loadflag="load16_word_swap" />
27724         </dataarea>
27725      </part>
27726   </software>
27727
2772827795   <software name="mgs" cloneof="crkdown">
2772927796      <description>Metal Gear Solid (Rus)</description>
2773027797      <year>199?</year>
r21443r21444
2788027947      </part>
2788127948   </software>
2788227949
27950   <software name="samspir2" cloneof="samsho">
27951      <description>Samurai Spirits II (Pirate)</description>
27952      <year>199?</year>
27953      <publisher>&lt;unknown&gt;</publisher>
27954      <part name="cart" interface="megadriv_cart">
27955         <dataarea name="rom" size="2097152">
27956            <rom name="samurai spirits ii (unl).bin" size="2097152" crc="2942f180" sha1="fe5a6a28542a313f142ba938956fd43187834805" offset="000000" loadflag="load16_word_swap" />
27957         </dataarea>
27958      </part>
27959   </software>
27960
2788327961   <software name="shrek" cloneof="yogibear">
2788427962      <description>Shrek (Rus)</description>
2788527963      <year>199?</year>
trunk/src/mess/drivers/megadriv.c
r21443r21444
341341   SLOT_INTERFACE_INTERNAL("rom_sbubl",  MD_ROM_SBUBL)
342342   SLOT_INTERFACE_INTERNAL("rom_smb",  MD_ROM_SMB)
343343   SLOT_INTERFACE_INTERNAL("rom_smb2",  MD_ROM_SMB2)
344   SLOT_INTERFACE_INTERNAL("rom_smw64",  MD_ROM_SMW64)
344345   SLOT_INTERFACE_INTERNAL("rom_smouse",  MD_ROM_SMOUSE)
345346   SLOT_INTERFACE_INTERNAL("rom_soulb",  MD_ROM_SOULB)
346347   SLOT_INTERFACE_INTERNAL("rom_squir",  MD_ROM_SQUIR)
trunk/src/mess/machine/md_rom.c
r21443r21444
2727const device_type MD_ROM_SSF2 = &device_creator<md_rom_ssf2_device>;
2828const device_type MD_ROM_BUGSLIFE = &device_creator<md_rom_bugslife_device>;
2929const device_type MD_ROM_SMOUSE = &device_creator<md_rom_smouse_device>;
30const device_type MD_ROM_SMW64 = &device_creator<md_rom_smw64_device>;
3031const device_type MD_ROM_SMB = &device_creator<md_rom_smb_device>;
3132const device_type MD_ROM_SMB2 = &device_creator<md_rom_smb2_device>;
3233const device_type MD_ROM_SBUBL = &device_creator<md_rom_sbubl_device>;
r21443r21444
101102{
102103}
103104
105md_rom_smw64_device::md_rom_smw64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
106               : md_std_rom_device(mconfig, MD_ROM_SMW64, "MD Super Mario World 64", tag, owner, clock)
107{
108}
109
104110md_rom_sbubl_device::md_rom_sbubl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
105111               : md_std_rom_device(mconfig, MD_ROM_SBUBL, "MD Super Bubble Bobble", tag, owner, clock)
106112{
r21443r21444
253259   save_item(NAME(m_latch));
254260}
255261
262void md_rom_smw64_device::device_start()
263{
264   m_latch0 = 0xf;
265   m_latch1 = 0xf;
266   memset(m_reg, 0, sizeof(m_reg));
267   memset(m_ctrl, 0, sizeof(m_ctrl));
268
269   save_item(NAME(m_latch0));
270   save_item(NAME(m_latch1));
271   save_item(NAME(m_reg));
272   save_item(NAME(m_ctrl));
273}
274
256275void md_rom_topf_device::device_start()
257276{
258277   m_latch = 0;
r21443r21444
818837}
819838
820839/*-------------------------------------------------
840 SUPER MARIO WORLD 64
841 -------------------------------------------------*/
842
843READ16_MEMBER(md_rom_smw64_device::read)
844{
845   // 0x000000-0x0fffff: lower 512KB ROM (up to 0x07ffff) + mirror
846   // 0x600000-0x6fffff: internal hardware (up to 0x67ffff) + mirror
847   // Namely,
848   //  * 60xxx = bank1 of the upper 512KB ROM
849   //  * 61xxx = bank2 of the upper 512KB ROM
850   //  * 62xxx = alternate 4KB chunks of 0x0000 ~ 0xffff
851   //  * 63xxx = same as 62xxx
852   //  * 64xxx = returns 0x0000
853   //  * 65xxx = same as 64xxx
854   //  * 66xxx = CTRL/DATA
855   //  * 67xxx = CTRL/DATA
856   if (offset < 0x100000/2)
857      return m_rom[offset & 0x3ffff];
858
859   if ((offset >= 0x600000/2) && (offset < 0x610000/2))
860      return m_rom[(m_latch0 * 0x10000)/2 + (offset & 0x7fff)];
861   if ((offset >= 0x610000/2) && (offset < 0x620000/2))
862      return m_rom[(m_latch1 * 0x10000)/2 + (offset & 0x7fff)];
863
864   if ((offset >= 0x620000/2) && (offset < 0x640000/2))
865      return (offset & 0x1000/2) ? 0x0000 : 0xffff;
866   if ((offset >= 0x640000/2) && (offset < 0x660000/2))
867      return 0x0000;
868
869   if ((offset >= 0x660000/2) && (offset < 0x670000/2))
870   {
871      offset &= 7;
872      switch (offset)
873      {
874         case 0x0:
875         case 0x2:
876         case 0x4:
877            return m_reg[offset/2];   // DATA1, DATA2, DATA3
878         case 0x1:
879         case 0x3:
880         case 0x5:
881            return m_reg[offset/2] + 1;   // DATA1+1, DATA2+1, DATA3+1
882         case 0x6:
883            return m_reg[2] + 2;   // DATA3+2
884         case 0x7:
885            return m_reg[2] + 3;   // DATA3+3
886      }
887   }
888   if ((offset >= 0x670000/2) && (offset < 0x680000/2))
889   {
890      UINT16 data = (m_ctrl[1] & 0x80) ? ((m_ctrl[2] & 0x40) ? (m_reg[4] & m_reg[5]) : (m_reg[4] ^ 0xff)) : 0x0000;
891      if (offset & 0x1)   // odd offset, return lower 7 bits of the above
892         return data & 0x7f;
893      else   // even offset, return whole data above, but also update the regs if CTRL3 has 0x80 set
894      {
895         if (m_ctrl[2] & 0x80)   // update regs if CTRL3 has bit7 set
896         {
897            if (m_ctrl[2] & 0x20)
898               m_reg[2] = (m_reg[5] << 2) & 0xfc;   // DATA3
899            else
900               m_reg[0] = ((m_reg[4] << 1) ^ m_reg[3]) & 0xfe;   // DATA1
901         }
902         return data;
903      }
904   }
905   
906   return 0xffff;
907}
908
909WRITE16_MEMBER(md_rom_smw64_device::write)
910{
911   // 0x600000-0x6fffff: internal hardware (up to 0x67ffff) + mirror
912   // Namely,
913   //  * 62xxx/63xxx = unknown/unmapped
914   //  * 65xxx/66xxx = unknown/unmapped
915   //  * remaining ranges = CTRL/DATA
916   if ((offset >= 0x600000/2) && (offset < 0x610000/2))
917   {
918      if (offset & 1)
919      {
920         if ((m_ctrl[0] & 7) == 0)
921            m_reg[0] = ((m_reg[0] ^ m_reg[3]) ^ data) & 0xfe;   // DATA1
922         if ((m_ctrl[0] & 7) == 1)
923            m_reg[1] = data & 0xfe;   // DATA2
924         if ((m_ctrl[0] & 7) == 7)
925            m_latch1 = 8 + ((data & 0x1c) >> 2);   // ROM BANKSWITCH $61
926         m_reg[3] = data;   // DATA4
927      }
928      else
929         m_ctrl[0] = data;   // CTRL1
930   }
931   if ((offset >= 0x610000/2) && (offset < 0x620000/2))
932   {
933      if (offset & 1)
934         m_ctrl[1] = data;   // CTRL2
935   }
936   if ((offset >= 0x640000/2) && (offset < 0x650000/2))
937   {
938      if (offset & 1)
939         m_reg[5] = data;   // DATA6
940      else
941         m_reg[4] = data;   // DATA5
942   }
943   if ((offset >= 0x670000/2) && (offset < 0x680000/2))
944   {
945      if (!(offset & 1))
946      {
947         m_ctrl[2] = data;   // CTRL3
948         if (m_ctrl[1] & 0x80)
949            m_latch0 = 8 + ((data & 0x1c) >> 2);   // ROM BANKSWITCH $60
950      }
951   }
952}
953
954/*-------------------------------------------------
821955 TOP FIGHTER
822956 -------------------------------------------------*/
823957
trunk/src/mess/machine/md_rom.h
r21443r21444
369369   virtual DECLARE_READ16_MEMBER(read_a13);
370370};
371371
372// ======================> md_rom_smw64_device
373
374class md_rom_smw64_device : public md_std_rom_device
375{
376public:
377   // construction/destruction
378   md_rom_smw64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
379   
380   // device-level overrides
381   virtual void device_start();
382   virtual void device_config_complete() { m_shortname = "md_rom_smw64"; }
383   
384   // reading and writing
385   virtual DECLARE_READ16_MEMBER(read);
386   virtual DECLARE_WRITE16_MEMBER(write);
387   
388private:
389   UINT32 m_latch0, m_latch1;
390   UINT16 m_reg[6];
391   UINT16 m_ctrl[3];
392};
393
372394// ======================> md_rom_smouse_device
373395
374396class md_rom_smouse_device : public md_std_rom_device
r21443r21444
484506extern const device_type MD_ROM_SBUBL;
485507extern const device_type MD_ROM_SMB;
486508extern const device_type MD_ROM_SMB2;
509extern const device_type MD_ROM_SMW64;
487510extern const device_type MD_ROM_SMOUSE;
488511extern const device_type MD_ROM_SOULB;
489512extern const device_type MD_ROM_SSF2;
r21443r21444
491514extern const device_type MD_ROM_TOPF;
492515extern const device_type MD_ROM_RADICA;
493516
494// this are currently unused... protection is directly patched out!
495extern const device_type MD_ROM_MULAN;
496extern const device_type MD_ROM_POKE2;
497
498517#endif
trunk/src/mess/machine/md_slot.c
r21443r21444
277277   { SBUBBOB, "rom_sbubl" },
278278   { SMB, "rom_smb" },
279279   { SMB2, "rom_smb2" },
280   { SMW64, "rom_smw64" },
280281   { SMOUSE, "rom_smouse" },
281282   { SOULBLAD, "rom_soulblad" },
282283   { SQUIRRELK, "rom_squir" },
trunk/src/mess/machine/md_slot.h
r21443r21444
2121   // Cart + NVRAM
2222   SEGA_SRAM, SEGA_FRAM,
2323   HARDBALL95,                  /* Hardball 95 uses different sram start address */
24   BEGGAR,                      /* Xin Qigai Wangzi uses different sram start address and has no valid header */
24   BEGGAR,                      /* Beggar Prince / Xin Qigai Wangzi uses different sram start address and has no valid header */
2525
2626   // EEPROM
2727   SEGA_EEPROM,                 /* Wonder Boy V / Evander Holyfield's Boxing / Greatest Heavyweights of the Ring / Sports Talk Baseball / Megaman */
r21443r21444
6060   SBUBBOB,                     /* Super Bubble Bobble */
6161   SMB,                         /* Super Mario Bros. */
6262   SMB2,                        /* Super Mario Bros. 2 */
63   SMW64,                       /* Super Mario World 64 */
6364   SMOUSE,                      /* Smart Mouse */
6465   SOULBLAD,                    /* Soul Blade */
6566   SQUIRRELK,                   /* Squirrel King */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team