Previous 199869 Revisions Next

r21511 Friday 1st March, 2013 at 10:51:56 UTC by Fabio Priuli
(MESS) gameboy: added emulation of Rockman 8 pirate cart by Yong Yong. [Fabio Priuli]

(MESS) gameboy: added correct handling of Echo RAM, needed by Rockman 8. [Fabio Priuli]

(MESS) gbcolor: added proper type to Stone Age / Shi Qi Shi Dai, making it working on gbpocket
(it freezes on gb/gbc due to unemulated interaction with the bios). nw.

also backing up some wip code which I'm not sure when I will have time to improve...
[hash]gameboy.xml gbcolor.xml
[src/mess/drivers]gb.c
[src/mess/includes]gb.h
[src/mess/machine]gb_mbc.c gb_mbc.h gb_slot.c gb_slot.h

trunk/hash/gbcolor.xml
r21510r21511
2328023280      </part>
2328123281   </software>
2328223282
23283   <software name="3gokum2a" cloneof="3gokum2">
23284      <description>Zhen San Guo Wu Shuang 2 - Shin Sangokumusou 2 (Chi, Pirate)</description>
23285      <year>200?</year>
23286      <publisher>&lt;pirate&gt;</publisher>
23287      <info name="alt_title" value="真三國無雙2"/>
23288      <part name="cart" interface="gameboy_cart">
23289         <feature name="slot" value="rom_mbc5" />
23290         <!-- cartridge ram -->
23291         <dataarea name="rom" size="2097152">
23292            <rom name="shin san guo shi 2 (unl).bin" size="2097152" crc="33f56c90" sha1="a5111c11cf70c65341b373f484650caae3c4d29f" offset="000000" />
23293         </dataarea>
23294         <dataarea name="nvram" size="8192">
23295         </dataarea>
23296      </part>
23297   </software>
23298
2328323299   <software name="zzx3">
2328423300   <!-- 4MB rom with crc 66442e7d is taizou's cracked version running on base MBC5 -->
2328523301      <description>Zhi Zhu Xia III (Chi)</description>
r21510r21511
2393123947      </part>
2393223948   </software>
2393323949
23934   <software name="sqsd" supported="no">
23950<!-- works on gbpocket -->
23951   <software name="sqsd">
2393523952      <!-- Alt. Title: 石器時代 精靈王誕生 (Stone Age - Birth of the Goblin King) -->
2393623953      <description>Shi Qi Shi Dai - Jing Ling Wang Dan Sheng (Chi)</description>
2393723954      <year>20??</year>
2393823955      <publisher>GOWIN</publisher>
2393923956      <part name="cart" interface="gameboy_cart">
23940         <feature name="slot" value="rom_mbc5" />
23957         <feature name="slot" value="rom_yong" />
2394123958         <!-- cartridge ram -->
2394223959         <dataarea name="rom" size="4194304">
2394323960            <rom name="stone age (unl).bin" size="4194304" crc="e7d9d377" sha1="f88f605960c1573aa8bc5fafab19014b0d987729" offset="000000" />
r21510r21511
2394723964      </part>
2394823965   </software>
2394923966
23950   <software name="sqsdh" cloneof="sqsd" supported="partial">
23967<!-- works on gbpocket -->
23968   <software name="sqsdh" cloneof="sqsd">
2395123969      <!-- Alt. Title: 石器時代 精靈王誕生 (Stone Age - Birth of the Goblin King) -->
2395223970      <description>Shi Qi Shi Dai - Jing Ling Wang Dan Sheng (Chi, Hacked?)</description>
2395323971      <year>20??</year>
2395423972      <publisher>GOWIN</publisher>
2395523973      <part name="cart" interface="gameboy_cart">
23956         <feature name="slot" value="rom_mbc5" />
23974         <feature name="slot" value="rom_yong" />
2395723975         <!-- cartridge ram -->
2395823976         <dataarea name="rom" size="4194304">
2395923977            <rom name="stone age (unl)(hacked).bin" size="4194304" crc="2ffe697c" sha1="b992f280b5dd2095c8f430282c5dba69c6a10eb4" offset="000000" />
r21510r21511
2396323981      </part>
2396423982   </software>
2396523983
23966   <software name="ssangws2">
23967      <description>Shin Sangoku Musou 2 - Zhen San Guo Wu Shuang 2 (Chi)</description>
23968      <year>20??</year>
23969      <publisher>&lt;unknown&gt;</publisher>
23970      <info name="alt_title" value="真三國無雙2"/>
23971      <part name="cart" interface="gameboy_cart">
23972         <feature name="slot" value="rom_mbc5" />
23973         <!-- cartridge ram -->
23974         <dataarea name="rom" size="2097152">
23975            <rom name="shin san guo shi 2 (unl).bin" size="2097152" crc="33f56c90" sha1="a5111c11cf70c65341b373f484650caae3c4d29f" offset="000000" />
23976         </dataarea>
23977         <dataarea name="nvram" size="8192">
23978         </dataarea>
23979      </part>
23980   </software>
23981
2398223984   <software name="dquest4">
2398323985      <description>Dragon Quest 4 - Yongzhe Dou E Long 4 (Chi)</description>
2398423986      <year>20??</year>
r21510r21511
2409424096      </part>
2409524097   </software>
2409624098
24099<!--
24100There are various dumps of this:
241012MB version (CRC 18fd445d) which contains 4 copies of the rom used here
24102256KB version (CRC 791f8c86) which contains the first half of the rom used here
24103
24104taizou dumped the game also from a multicart and got a 1MB dump containing the rom
24105used here repeated twice. we need to redump the standalone cart to confirm the size
24106but the 256KB version is definitely underdumped and misses sprite data
24107-->
2409724108   <software name="sm3sp" supported="no">
24098      <description>Super Mario 3 Special (Chi, Bad? Protected?)</description>
24099      <year>200?</year>
24109      <description>Super Mario 3 Special (Chi)</description>
24110      <year>2000</year>
2410024111      <publisher>Yong Yong</publisher>
2410124112      <part name="cart" interface="gameboy_cart">
24102         <feature name="slot" value="rom_mbc1" />
24103         <dataarea name="rom" size="262144">
24104            <rom name="super mario 3 special (unl).bin" size="262144" crc="791f8c86" sha1="c5632ea968398d3a342f2639aad7e11122d561ef" offset="000000" />
24113         <feature name="slot" value="rom_sm3sp" />
24114         <dataarea name="rom" size="524288">
24115            <rom name="super mario 3 special (unl).bin" size="524288" crc="5e4266a7" sha1="f493da9f707ad84c4d720687ec1ca3f635dc35c6" offset="000000" />
2410524116         </dataarea>
2410624117      </part>
2410724118   </software>
r21510r21511
2411224123      <year>20??</year>
2411324124      <publisher>Yong Yong</publisher>
2411424125      <part name="cart" interface="gameboy_cart">
24115         <feature name="slot" value="rom_mbc5" />
24126         <feature name="slot" value="rom_digimon" />
2411624127         <dataarea name="rom" size="1048576">
2411724128            <rom name="digimon 2 (unl).bin" size="1048576" crc="aabbec08" sha1="b88393318c35fcd63b9bbe8ccd0ce89d971b6163" offset="000000" />
2411824129         </dataarea>
r21510r21511
2415724168      <year>20??</year>
2415824169      <publisher>Yong Yong</publisher>
2415924170      <part name="cart" interface="gameboy_cart">
24160         <feature name="slot" value="rom_mbc5" />
24171         <feature name="slot" value="rom_digimon" />
2416124172         <dataarea name="rom" size="1048576">
2416224173            <rom name="digimon 4 (unl).bin" size="1048576" crc="2ee18ab2" sha1="839f0880749735ba2113e437f8efede171b7474d" offset="000000" />
2416324174         </dataarea>
trunk/hash/gameboy.xml
r21510r21511
2350023500
2350123501<!-- Other Asian pirate carts -->
2350223502
23503   <software name="rockman8">
23504      <description>Rockman 8 (Chi)</description>
23505      <year>1999</year>
23506      <publisher>Yong Yong</publisher>
23507      <part name="cart" interface="gameboy_cart">
23508         <feature name="slot" value="rom_rock8" />
23509         <dataarea name="rom" size="262144">
23510            <rom name="rockman 8 (hong kong) [p1].bin" size="262144" crc="cc131a94" sha1="496575adfb1296f2f99c00e06e5ca5ee4daf1a12" offset="000000" />
23511         </dataarea>
23512         <dataarea name="ram" size="8192">
23513         </dataarea>
23514      </part>
23515   </software>
23516
2350323517   <software name="sml4" cloneof="crayon4">
2350423518      <description>Super Mario Land 4 (Chi)</description>
2350523519      <year>1997?</year>
r21510r21511
2361023624      </part>
2361123625   </software>
2361223626
23613   <software name="lasama" supported="no">
23627   <software name="lasama">
2361423628      <description>La Sa Ma Chuan Qi - Story of Lasama (Tw)</description>
2361523629      <year>19??</year>
2361623630      <publisher>GOWIN</publisher>
r21510r21511
2362523639      </part>
2362623640   </software>
2362723641
23628   <software name="lasamah" cloneof="lasama" supported="no">
23629      <description>La Sa Ma Chuan Qi - Story of Lasama (Tw, Hacked)</description>
23630      <year>19??</year>
23631      <publisher>GOWIN</publisher>
23632      <info name="serial" value="GS-04"/>
23633      <part name="cart" interface="gameboy_cart">
23634         <feature name="slot" value="rom_mbc1" />
23635         <dataarea name="rom" size="65536">
23636            <rom name="la sa ma chuan qi - story of lasama (unlicensed) [fixed].bin" size="65536" crc="985fcc24" sha1="de0fed7673c525bbcdcc484067dddebba7684462" offset="000000" />
23637         </dataarea>
23638      </part>
23639   </software>
23640
2364123642   <software name="magicbal">
2364223643      <description>Magic Ball (Tw)</description>
2364323644      <year>19??</year>
trunk/src/mess/drivers/gb.c
r21510r21511
522522      m_cartslot->m_cart->write_ram(space, offset, data);
523523}
524524
525READ8_MEMBER(gb_state::gb_echo_r)
526{
527   return space.read_byte(0xc000 + offset);
528}
529
530WRITE8_MEMBER(gb_state::gb_echo_w)
531{
532   return space.write_byte(0xc000 + offset, data);
533}
534
525535READ8_MEMBER(megaduck_state::cart_r)
526536{
527537   if (m_cartslot && m_cartslot->m_cart)
r21510r21511
546556static ADDRESS_MAP_START(gameboy_map, AS_PROGRAM, 8, gb_state )
547557   ADDRESS_MAP_UNMAP_HIGH
548558   AM_RANGE(0x0000, 0x7fff) AM_READWRITE(gb_cart_r, gb_bank_w)
549   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(gb_vram_r, gb_vram_w ) /* 8k VRAM */
550   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(gb_ram_r, gb_ram_w )   /* 8k switched RAM bank (cartridge) */
551   AM_RANGE(0xc000, 0xfdff) AM_RAM                     /* 8k low RAM, echo RAM */
552   AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w )  /* OAM RAM */
553   AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, gb_io_w )        /* I/O */
559   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(gb_vram_r, gb_vram_w )  /* 8k VRAM */
560   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(gb_ram_r, gb_ram_w )    /* 8k switched RAM bank (cartridge) */
561   AM_RANGE(0xc000, 0xdfff) AM_RAM                               /* 8k low RAM */
562   AM_RANGE(0xe000, 0xfdff) AM_READWRITE(gb_echo_r, gb_echo_w )  /* echo RAM */
563   AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w )    /* OAM RAM */
564   AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, gb_io_w )      /* I/O */
554565   AM_RANGE(0xff10, 0xff26) AM_DEVREADWRITE_LEGACY("custom", gb_sound_r, gb_sound_w )      /* sound registers */
555566   AM_RANGE(0xff27, 0xff2f) AM_NOP                     /* unused */
556567   AM_RANGE(0xff30, 0xff3f) AM_DEVREADWRITE_LEGACY("custom", gb_wave_r, gb_wave_w )        /* Wave ram */
r21510r21511
562573static ADDRESS_MAP_START(sgb_map, AS_PROGRAM, 8, gb_state )
563574   ADDRESS_MAP_UNMAP_HIGH
564575   AM_RANGE(0x0000, 0x7fff) AM_READWRITE(gb_cart_r, gb_bank_w)
565   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(gb_vram_r, gb_vram_w ) /* 8k VRAM */
566   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(gb_ram_r, gb_ram_w )   /* 8k switched RAM bank (cartridge) */
567   AM_RANGE(0xc000, 0xfdff) AM_RAM                     /* 8k low RAM, echo RAM */
568   AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w )  /* OAM RAM */
569   AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, sgb_io_w )       /* I/O */
576   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(gb_vram_r, gb_vram_w )  /* 8k VRAM */
577   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(gb_ram_r, gb_ram_w )    /* 8k switched RAM bank (cartridge) */
578   AM_RANGE(0xc000, 0xdfff) AM_RAM                               /* 8k low RAM */
579   AM_RANGE(0xe000, 0xfdff) AM_READWRITE(gb_echo_r, gb_echo_w )  /* echo RAM */
580   AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w )    /* OAM RAM */
581   AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, sgb_io_w )     /* I/O */
570582   AM_RANGE(0xff10, 0xff26) AM_DEVREADWRITE_LEGACY("custom", gb_sound_r, gb_sound_w )      /* sound registers */
571583   AM_RANGE(0xff27, 0xff2f) AM_NOP                     /* unused */
572584   AM_RANGE(0xff30, 0xff3f) AM_DEVREADWRITE_LEGACY("custom", gb_wave_r, gb_wave_w )        /* Wave RAM */
r21510r21511
582594   AM_RANGE(0xa000, 0xbfff) AM_READWRITE(gb_ram_r, gb_ram_w )   /* 8k switched RAM bank (cartridge) */
583595   AM_RANGE(0xc000, 0xcfff) AM_RAM                     /* 4k fixed RAM bank */
584596   AM_RANGE(0xd000, 0xdfff) AM_RAMBANK("cgb_ram")                    /* 4k switched RAM bank */
585   AM_RANGE(0xe000, 0xfdff) AM_RAM                     /* echo RAM */
597   AM_RANGE(0xe000, 0xfdff) AM_READWRITE(gb_echo_r, gb_echo_w )  /* echo RAM */
586598   AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(gb_oam_r, gb_oam_w )  /* OAM RAM */
587599   AM_RANGE(0xff00, 0xff0f) AM_READWRITE(gb_io_r, gb_io_w )        /* I/O */
588600   AM_RANGE(0xff10, 0xff26) AM_DEVREADWRITE_LEGACY("custom", gb_sound_r, gb_sound_w )      /* sound controller */
r21510r21511
647659   SLOT_INTERFACE_INTERNAL("rom_camera",  GB_STD_ROM)
648660   SLOT_INTERFACE_INTERNAL("rom_sintax",  GB_ROM_SINTAX)
649661   SLOT_INTERFACE_INTERNAL("rom_chong",  GB_ROM_CHONGWU)
662   SLOT_INTERFACE_INTERNAL("rom_digimon",  GB_ROM_DIGIMON)
663   SLOT_INTERFACE_INTERNAL("rom_rock8",  GB_ROM_ROCKMAN8)
664   SLOT_INTERFACE_INTERNAL("rom_sm3sp",  GB_ROM_SM3SP)
650665SLOT_INTERFACE_END
651666
652667static SLOT_INTERFACE_START(megaduck_cart)
trunk/src/mess/machine/gb_mbc.c
r21510r21511
2626const device_type GB_ROM_MMM01 = &device_creator<gb_rom_mmm01_device>;
2727const device_type GB_ROM_SINTAX = &device_creator<gb_rom_sintax_device>;
2828const device_type GB_ROM_CHONGWU = &device_creator<gb_rom_chongwu_device>;
29const device_type GB_ROM_DIGIMON = &device_creator<gb_rom_digimon_device>;
30const device_type GB_ROM_ROCKMAN8 = &device_creator<gb_rom_rockman8_device>;
31const device_type GB_ROM_SM3SP = &device_creator<gb_rom_sm3sp_device>;
2932
3033
3134gb_rom_mbc_device::gb_rom_mbc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
r21510r21511
8992{
9093}
9194
95gb_rom_digimon_device::gb_rom_digimon_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
96               : gb_rom_mbc5_device(mconfig, GB_ROM_DIGIMON, "GB Digimon", tag, owner, clock)
97{
98}
9299
100gb_rom_rockman8_device::gb_rom_rockman8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
101               : gb_rom_mbc_device(mconfig, GB_ROM_ROCKMAN8, "GB MBC1 Rockman 8", tag, owner, clock)
102{
103}
104
105gb_rom_sm3sp_device::gb_rom_sm3sp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
106               : gb_rom_mbc_device(mconfig, GB_ROM_SM3SP, "GB MBC1 Super Mario 3 Special", tag, owner, clock)
107{
108}
109
110
93111void gb_rom_mbc_device::device_start()
94112{
95113   has_timer = FALSE;
r21510r21511
305323   save_item(NAME(m_protection_checked));
306324}
307325
326void gb_rom_digimon_device::device_start()
327{
328   has_timer = FALSE;
329   has_rumble = FALSE;
330   
331   m_latch_bank = 0;
332   m_latch_bank2 = 1;
333   m_ram_bank = 0;
334   m_ram_enable = 0;
335   m_mode = 0;
336   save_item(NAME(m_latch_bank));
337   save_item(NAME(m_latch_bank2));
338   save_item(NAME(m_ram_bank));
339   save_item(NAME(m_ram_enable));
340   save_item(NAME(m_mode));
341}
308342
343void gb_rom_rockman8_device::device_start()
344{
345   has_timer = FALSE;
346   has_rumble = FALSE;
347   
348   m_latch_bank = 0;
349   m_latch_bank2 = 1;
350   m_ram_bank = 0;
351   m_ram_enable = 0;
352   m_mode = 0;
353   save_item(NAME(m_latch_bank));
354   save_item(NAME(m_latch_bank2));
355   save_item(NAME(m_ram_bank));
356   save_item(NAME(m_ram_enable));
357   save_item(NAME(m_mode));
358}
359
360void gb_rom_sm3sp_device::device_start()
361{
362   has_timer = FALSE;
363   has_rumble = FALSE;
364   
365   m_latch_bank = 0;
366   m_latch_bank2 = 1;
367   m_ram_bank = 0;
368   m_ram_enable = 0;
369   m_mode = 0;
370   save_item(NAME(m_latch_bank));
371   save_item(NAME(m_latch_bank2));
372   save_item(NAME(m_ram_bank));
373   save_item(NAME(m_ram_enable));
374   save_item(NAME(m_mode));
375}
376
377
309378/*-------------------------------------------------
310379 mapper specific handlers
311380 -------------------------------------------------*/
r21510r21511
573642{
574643   if (offset < 0x2000)
575644      m_ram_enable = ((data & 0x0f) == 0x0a) ? 1 : 0;
645   else if (offset < 0x3000)
646   {
647      // MBC5 has a 9 bit bank select
648      // Writing into 2000-2fff sets the lower 8 bits
649      m_latch_bank2 = (m_latch_bank2 & 0x100) | data;
650   }
576651   else if (offset < 0x4000)
577652   {
578653      // MBC5 has a 9 bit bank select
579      // Writing into 2000-2fff sets the lower 8 bits
580654      // Writing into 3000-3fff sets the 9th bit
581      if (offset & 0x1000)
582         m_latch_bank2 = (m_latch_bank2 & 0xff) | ((data & 0x01) << 8);
583      else
584         m_latch_bank2 = (m_latch_bank2 & 0x100) | data;
655      m_latch_bank2 = (m_latch_bank2 & 0xff) | ((data & 0x01) << 8);
585656   }
586657   else if (offset < 0x6000)
587658   {
r21510r21511
897968      m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data;
898969}
899970
971/*
972 
973 Further MBC5 variants to emulate:
974 
975 Digimon 2 & Digimon 4 (Yong Yong)
976 
977 Digimon 2 writes at $2000 to select latch2 (data must be divided by 2, and 0 becomes 1),
978 then writes to $2400 a series of values that the patched version does not write...
979 Digimon 4 seems to share part of the $2000 behavior, but does not write to $2400...
980 
981 */
982
983// MBC5 variant used by Digimon 2 (and maybe 4?)
984
985READ8_MEMBER(gb_rom_digimon_device::read_rom)
986{
987   if (offset < 0x4000)
988      return m_rom[rom_bank_map[m_latch_bank] * 0x4000 + (offset & 0x3fff)];
989   else
990      return m_rom[rom_bank_map[m_latch_bank2] * 0x4000 + (offset & 0x3fff)];
991}
992
993WRITE8_MEMBER(gb_rom_digimon_device::write_bank)
994{
995   if (offset < 0x2000)
996      m_ram_enable = ((data & 0x0f) == 0x0a) ? 1 : 0;
997   else if (offset == 0x2000)
998   {
999//      printf("written $02 %X at %X\n", data, offset);
1000      if (!data)
1001         data++;
1002      m_latch_bank2 = data/2;
1003   }
1004   else if (offset < 0x3000)
1005   {
1006//      printf("written $03 %X at %X\n", data, offset);
1007   }
1008   else if (offset < 0x4000)
1009   {
1010//      printf("written $04 %X at %X\n", data, offset);
1011   }
1012   else if (offset < 0x6000)
1013   {
1014//      printf("written $05-$06 %X at %X\n", data, offset);
1015      data &= 0x0f;
1016      if (has_rumble)
1017         data &= 0x7;
1018      m_ram_bank = data;
1019   }
1020//   else
1021//      printf("written $07 %X at %X\n", data, offset);
1022}
1023
1024READ8_MEMBER(gb_rom_digimon_device::read_ram)
1025{
1026   if (m_ram && m_ram_enable)
1027      return m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)];
1028   else
1029      return 0xff;
1030}
1031
1032WRITE8_MEMBER(gb_rom_digimon_device::write_ram)
1033{
1034   if (m_ram && m_ram_enable)
1035      m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data;
1036}
1037
1038
1039// MBC1 variant used by Yong Yong for Rockman 8
1040
1041READ8_MEMBER(gb_rom_rockman8_device::read_rom)
1042{
1043   if (offset < 0x4000)
1044      return m_rom[m_latch_bank * 0x4000 + (offset & 0x3fff)];
1045   else
1046      return m_rom[m_latch_bank2 * 0x4000 + (offset & 0x3fff)];
1047}
1048
1049WRITE8_MEMBER(gb_rom_rockman8_device::write_bank)
1050{
1051   if (offset < 0x2000)
1052      return;
1053   else if (offset < 0x4000)
1054   {
1055      // 5bits only
1056      data &= 0x1f;
1057      if (data == 0)
1058         data = 1;
1059      if (data > 0xf)
1060         data -= 8;
1061     
1062      m_latch_bank2 = data;
1063   }
1064}
1065
1066READ8_MEMBER(gb_rom_rockman8_device::read_ram)
1067{
1068   if (m_ram)
1069      return m_ram[offset];
1070   else
1071      return 0xff;
1072}
1073
1074WRITE8_MEMBER(gb_rom_rockman8_device::write_ram)
1075{
1076   if (m_ram)
1077      m_ram[offset] = data;
1078}
1079
1080// MBC1 variant used by Yong Yong for Super Mario 3 Special
1081
1082// Mario special seems to be 512k image (mirrored up to 1m or 2m [redump needed to establish this])
1083// it consists of 13 unique 16k chunks layed out as follows
1084// unique chunk --> bank in bin
1085// 1st to 7th   --> 0x00 to 0x06
1086// 8th          --> 0x08
1087// 9th          --> 0x0b
1088// 10th         --> 0x0c
1089// 11th         --> 0x0d
1090// 12th         --> 0x0f   
1091// 13th         --> 0x13
1092
1093// writing data to 0x2000-0x2fff switches bank according to the table below
1094// (the value values corresponding to table[0x0f] is not confirmed, choices
1095// 0,1,2,3,8,c,f freeze the game, while 4,5,6,7,b,d,0x13 work with glitches)
1096static UINT8 smb3_table1[0x20] =
1097{
1098   0x00,0x04,0x01,0x05, 0x02,0x06,0x03,0x05, 0x08,0x0c,0x03,0x0d, 0x03,0x0b,0x0b,0x08 /* original doc here put 0x0f (i.e. 11th unique bank) */, 
1099   0x05,0x06,0x0b,0x0d, 0x08,0x06,0x13,0x0b, 0x08,0x05,0x05,0x08, 0x0b,0x0d,0x06,0x05
1100};
1101
1102// according to old doc from Brian Provinciano, writing bit5 in 0x5000-0x5fff should
1103// change the bank layout, in the sense that writing to bankswitch acts like if
1104// the original rom has a different layout (as if unique chunks were under permutations
1105// (24), (365) and (8a9) with 0,1,7,b,c fixed) and the same table above is used
1106// however, no such a write ever happen (only bit4 is written, but changing mode with
1107// bit4 breaks the gfx...)
1108
1109READ8_MEMBER(gb_rom_sm3sp_device::read_rom)
1110{
1111   if (offset < 0x4000)
1112      return m_rom[rom_bank_map[0] * 0x4000 + (offset & 0x3fff)];
1113   else
1114      return m_rom[m_latch_bank2 * 0x4000 + (offset & 0x3fff)];
1115}
1116
1117WRITE8_MEMBER(gb_rom_sm3sp_device::write_bank)
1118{
1119//   printf("write 0x%x at %x\n", data, offset);
1120   if (offset < 0x2000)
1121      return;
1122   else if (offset < 0x3000)
1123   {
1124      // Table 1 confirmed...
1125      // 0->0, 4->2, 6->3
1126      // 1e -> 6 (level 1 bg gfx)
1127      // 19 -> 5 (level 2 bg gfx)
1128      // 1b -> 8 (level 3 bg gfx)
1129      // 1d -> D (level 4 bg gfx)
1130      // 1c -> B (bonus house bg gfx)
1131      // 1 (9 maybe, or 3)? f (5 maybe)? 2->1?
1132      // 16 -> 4-8? b?
1133
1134      // 5bits only
1135      data &= 0x1f;
1136     
1137      m_latch_bank2 = smb3_table1[data];
1138      if (m_mode)
1139      {
1140         switch (m_latch_bank2)
1141         {
1142            case 0x02:   m_latch_bank2 = 4;   break;
1143            case 0x03:   m_latch_bank2 = 6;   break;
1144            case 0x04:   m_latch_bank2 = 2;   break;
1145            case 0x05:   m_latch_bank2 = 3;   break;
1146            case 0x06:   m_latch_bank2 = 5;   break;
1147            case 0x0b:   m_latch_bank2 = 0xd;   break;
1148            case 0x0c:   m_latch_bank2 = 0xb;   break;
1149            case 0x0d:   m_latch_bank2 = 0xc;   break;
1150
1151            case 0x00:
1152            case 0x01:
1153            case 0x08:
1154            case 0x0f:
1155            case 0x13:
1156            default:
1157               break;
1158         }
1159      }
1160   }
1161   else if (offset < 0x5000)
1162   {
1163//      printf("write $5 %x\n", data);
1164      //maybe rumble??
1165   }
1166   else if (offset < 0x6000)
1167   {
1168//      printf("write mode %x\n", data);
1169      m_mode = BIT(data, 5);
1170//      write_bank(space, 0x2000, 1);
1171   }
1172}
1173
1174READ8_MEMBER(gb_rom_sm3sp_device::read_ram)
1175{
1176   if (m_ram)
1177      return m_ram[offset];
1178   else
1179      return 0xff;
1180}
1181
1182WRITE8_MEMBER(gb_rom_sm3sp_device::write_ram)
1183{
1184   if (m_ram)
1185      m_ram[offset] = data;
1186}
trunk/src/mess/machine/gb_mbc.h
r21510r21511
189189   UINT8 m_protection_checked;
190190};
191191
192// ======================> gb_rom_digimon_device
193
194class gb_rom_digimon_device : public gb_rom_mbc5_device
195{
196public:
197   // construction/destruction
198   gb_rom_digimon_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
199   
200   // device-level overrides
201   virtual void device_start();
202   virtual void device_config_complete() { m_shortname = "gb_rom_digimon"; }
203   
204   virtual DECLARE_READ8_MEMBER(read_rom);
205   virtual DECLARE_WRITE8_MEMBER(write_bank);
206   virtual DECLARE_READ8_MEMBER(read_ram);
207   virtual DECLARE_WRITE8_MEMBER(write_ram);
208};
209
192210// ======================> gb_rom_sintax_device
193211class gb_rom_sintax_device : public gb_rom_mbc_device
194212{
r21510r21511
211229   UINT8 m_currentxor, m_xor2, m_xor3, m_xor4, m_xor5, m_sintax_mode;
212230};
213231
232// ======================> gb_rom_rockman8_device
233class gb_rom_rockman8_device : public gb_rom_mbc_device
234{
235public:
236   // construction/destruction
237   gb_rom_rockman8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
238   
239   // device-level overrides
240   virtual void device_start();
241   virtual void device_config_complete() { m_shortname = "gb_rom_rockman8"; }
242   
243   // reading and writing
244   virtual DECLARE_READ8_MEMBER(read_rom);
245   virtual DECLARE_WRITE8_MEMBER(write_bank);
246   virtual DECLARE_READ8_MEMBER(read_ram);
247   virtual DECLARE_WRITE8_MEMBER(write_ram);
248   UINT8 m_bank_mask, m_bank, m_reg;
249};
214250
251// ======================> gb_rom_sm3sp_device
252class gb_rom_sm3sp_device : public gb_rom_mbc_device
253{
254public:
255   // construction/destruction
256   gb_rom_sm3sp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
257   
258   // device-level overrides
259   virtual void device_start();
260   virtual void device_config_complete() { m_shortname = "gb_rom_sm3sp"; }
261   
262   // reading and writing
263   virtual DECLARE_READ8_MEMBER(read_rom);
264   virtual DECLARE_WRITE8_MEMBER(write_bank);
265   virtual DECLARE_READ8_MEMBER(read_ram);
266   virtual DECLARE_WRITE8_MEMBER(write_ram);
267   UINT8 m_bank_mask, m_bank, m_reg;
268};
215269
270
271
216272// device type definition
217273extern const device_type GB_ROM_MBC1;
218274extern const device_type GB_ROM_MBC1_COL;
r21510r21511
225281extern const device_type GB_ROM_MMM01;
226282extern const device_type GB_ROM_SINTAX;
227283extern const device_type GB_ROM_CHONGWU;
284extern const device_type GB_ROM_DIGIMON;
285extern const device_type GB_ROM_ROCKMAN8;
286extern const device_type GB_ROM_SM3SP;
228287
229288#endif
trunk/src/mess/machine/gb_slot.c
r21510r21511
216216   { GB_MBC_ATVRACIN, "rom_atvrac" },
217217   { GB_MBC_SINTAX, "rom_sintax" },
218218   { GB_MBC_CHONGWU, "rom_chong" },
219   { GB_MBC_DIGIMON, "rom_digimon" },
220   { GB_MBC_ROCKMAN8, "rom_rock8" },
221   { GB_MBC_SM3SP, "rom_sm3sp" },
219222   { GB_MBC_CAMERA, "rom_camera" }
220223};
221224
trunk/src/mess/machine/gb_slot.h
r21510r21511
2929   GB_MBC_CAMERA,
3030   GB_MBC_SINTAX,
3131   GB_MBC_CHONGWU,
32   GB_MBC_DIGIMON,
33   GB_MBC_ROCKMAN8,
34   GB_MBC_SM3SP,
3235   GB_MBC_MEGADUCK,     /* MEGADUCK style banking                        */
3336   GB_MBC_UNKNOWN       /* Unknown mapper                                */
3437};
trunk/src/mess/includes/gb.h
r21510r21511
205205   DECLARE_WRITE8_MEMBER(gb_bank_w);
206206   DECLARE_READ8_MEMBER(gb_ram_r);
207207   DECLARE_WRITE8_MEMBER(gb_ram_w);
208   DECLARE_READ8_MEMBER(gb_echo_r);
209   DECLARE_WRITE8_MEMBER(gb_echo_w);
208210   optional_device<gb_cart_slot_device> m_cartslot;
209211
210212protected:

Previous 199869 Revisions Next


© 1997-2024 The MAME Team