Previous 15994 Revisions Next

r14507 Saturday 18th February, 2012 at 09:04:07 UTC by Curt Coder
[C64] Added support for .CRT cartridge image files. Only standard cartridges (8/16KB) are supported for the moment, soon all will be assimilated. [Curt Coder]
[hash]c64_cart.xml vic1001_cart.xml
[src/mess/formats]cbm_crt.h
[src/mess/machine]c64_std.c c64exp.c

hash/vic1001_cart.xml
r14506r14507
66   Missing stuff:
77
88   - Behr Bonz multicart
9   - Mega-Cart
109   - Ultra Vic-20 Cart
11   - Vic Flash Plugin
12   - Final Expansion 3
1310   - Speech Synthesizer (SP-0256-AL2)
14   -
1511
1612   http://sleepingelephant.com/denial/wiki/index.php?title=Cartridges
1713   http://www.digitpress.com/the_digs/vic20/texts/vic-rare.htm
r14506r14507
13271323      </part>
13281324   </software>
13291325
1326   <software name="fe3">
1327      <description>Final Expansion 3</description>
1328      <year>2011</year>
1329      <publisher>Denial</publisher>
1330      <info name="serial" value="VIC-2011" />
1331      <sharedfeat name="compatibility" value="NTSC,PAL"/>
1332      <part name="cart" interface="vic1001_cart">
1333         <feature name="slot" value="fe" />
1334         <dataarea name="rom" size="0x80000">
1335            <rom name="fe3vice-r020.bin" size="0x80000" crc="c12d844a" sha1="3946b6595f4ac0469a9fd97e4cd156618e868deb" offset="0x0000" />
1336         </dataarea>
1337         <dataarea name="ram" size="0x80000">
1338      </part>
1339   </software>
1340
13301341   <software name="finalorb">
13311342      <description>Final Orbit + Bumper Bash (NTSC)</description>
13321343      <year>1983</year>
r14506r14507
19011912      </part>
19021913   </software>
19031914
1915   <software name="megacart">
1916      <description>Mega-Cart</description>
1917      <year>2008</year>
1918      <publisher>Denial</publisher>
1919      <info name="serial" value="MC-2008" />
1920      <sharedfeat name="compatibility" value="NTSC,PAL"/>
1921      <part name="cart" interface="vic1001_cart">
1922         <feature name="slot" value="megacart" />
1923         <dataarea name="rom" size="0x200000">
1924            <rom name="megacart.rom" size="0x200000" crc="787551d4" sha1="c4854de023c25dc827af3bebed76d2ff86eaf0ce" offset="0x0000" />
1925         </dataarea>
1926         <dataarea name="ram" size="0x8000">
1927      </part>
1928   </software>
1929
19041930   <software name="meteorun">
19051931      <description>Meteor Run (PAL)</description>
19061932      <year>1982</year>
r14506r14507
34703496      </part>
34713497   </software>
34723498
3499   <software name="fp">
3500      <description>Vic Flash Plugin</description>
3501      <year>2008</year>
3502      <publisher>Marko Mäkelä</publisher>
3503      <sharedfeat name="compatibility" value="NTSC,PAL"/>
3504      <part name="cart" interface="vic1001_cart">
3505         <feature name="slot" value="fp" />
3506         <dataarea name="rom" size="0x400000">
3507            <rom name="menu-s.bin" size="0x400000" crc="de4f023b" sha1="164666798dfcee7d6b86a39548af4a97d72c0852" offset="0x0000" />
3508         </dataarea>
3509      </part>
3510   </software>
3511
34733512   <software name="forth11">
34743513      <description>VIC Forth v1.1</description>
34753514      <year>1982</year>
hash/c64_cart.xml
r14506r14507
13991399         </dataarea>
14001400      </part>
14011401   </software>
1402
1403   <software name="mmcr">
1404      <description>MMC Replay v0.55</description>
1405      <year>2008</year>
1406      <publisher>Protovision</publisher>
1407      <part name="cart" interface="c64_cart">
1408         <feature name="slot" value="mmc_replay" />
1409         <feature name="exrom" value="0" />
1410         <feature name="game" value="0" />
1411         <dataarea name="roml" size="0x10000">
1412            <rom name="mmcrbios.bin" size="0x10000" crc="63E35CA8" sha1="165934CEE24FE6BCDDEFD370288B58E01AC985D8" offset="0x0000" />
1413         </dataarea>
1414      </part>
1415   </software>
1416
1417   <software name="mmc64">
1418      <description>MMC64 v1.10</description>
1419      <year>2007</year>
1420      <publisher>Protovision</publisher>
1421      <part name="cart" interface="c64_cart">
1422         <feature name="slot" value="mmc64" />
1423         <feature name="exrom" value="0" />
1424         <feature name="game" value="0" />
1425         <dataarea name="roml" size="0x2000">
1426            <rom name="mmc64v1b.bin" size="0x2000" crc="c6255ad9" sha1="0fc4516ae9fc24da1a4e008ccdb876e765aaf640" offset="0x0000" />
1427         </dataarea>
1428      </part>
1429   </software>   
14021430   
1431   <software name="rr">
1432      <description>Retro Replay v3.8P</description>
1433      <year>2006</year>
1434      <publisher>CyberpunX</publisher>
1435      <sharedfeat name="compatibility" value="PAL"/>
1436      <part name="cart" interface="c64_cart">
1437         <feature name="slot" value="retro_replay" />
1438         <feature name="exrom" value="0" />
1439         <feature name="game" value="0" />
1440         <dataarea name="roml" size="0x10000">
1441            <rom name="rr38ppal.bin" size="0x10000" crc="fa52afac" sha1="48381d924a20978319ead8de7c904c91f270cc65" offset="0x0000" />
1442         </dataarea>
1443      </part>
1444   </software>   
1445
14031446   <!-- Games Added by k1w1 -->
14041447
14051448   <software name="advcrtor">
src/mess/machine/c64_std.c
r14506r14507
2828//-------------------------------------------------
2929
3030c64_standard_cartridge_device::c64_standard_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
31   device_t(mconfig, C64_STD, "Standard cartridge", tag, owner, clock),
31   device_t(mconfig, C64_STD, "C64 standard cartridge", tag, owner, clock),
3232   device_c64_expansion_card_interface(mconfig, *this)
3333{
3434}
r14506r14507
5151{
5252   UINT8 data = 0;
5353
54   if (!roml && m_roml)
54   if (!roml)
5555   {
5656      data = m_roml[offset & 0x1fff];
5757   }
58   else if (!romh && m_romh)
58   else if (!romh)
5959   {
60      data = m_romh[offset & 0x1fff];
60      if (m_romh_mask)
61      {
62         data = m_romh[offset & 0x1fff];
63      }
64      else if (m_roml_mask == 0x3fff)
65      {
66         data = m_roml[offset & 0x3fff];
67      }
6168   }
6269
6370   return data;
src/mess/machine/c64exp.c
r14506r14507
1111#include "emuopts.h"
1212#include "machine/c64exp.h"
1313#include "formats/cbm_crt.h"
14#include "formats/imageutl.h"
1415
1516
1617
1718//**************************************************************************
19//  MACROS/CONSTANTS
20//**************************************************************************
21
22#define LOG 0
23
24
25
26//**************************************************************************
1827//  DEVICE DEFINITIONS
1928//**************************************************************************
2029
r14506r14507
200209         }
201210         else if (!mame_stricmp(filetype(), "a0"))
202211         {
203            fread(m_cart->c64_romh_pointer(machine(), 0x2000), size);
212            fread(m_cart->c64_romh_pointer(machine(), 0x2000), 0x2000);
204213
214            m_cart->c64_exrom_w(0);
205215            m_cart->c64_game_w(0);
206            m_cart->c64_exrom_w(0);
207216         }
208217         else if (!mame_stricmp(filetype(), "e0"))
209218         {
210            fread(m_cart->c64_romh_pointer(machine(), 0x2000), size);
219            fread(m_cart->c64_romh_pointer(machine(), 0x2000), 0x2000);
211220
212221            m_cart->c64_game_w(0);
213222         }
214      }
215      else
216      {
217         if (get_feature("slot") == NULL)
223         else if (!mame_stricmp(filetype(), "crt"))
218224         {
219            size = get_software_region_length("roml");
225            // read the header
226            cbm_crt_header header;
227            fread(&header, CRT_HEADER_LENGTH);
228           
229            if (memcmp(header.signature, CRT_SIGNATURE, 16) != 0)
230               return IMAGE_INIT_FAIL;
231           
232            UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
233           
234            // TODO support other cartridge hardware
235            if (hardware != CRT_C64_STANDARD)
236               return IMAGE_INIT_FAIL;
237           
238            if (LOG)
239            {
240               logerror("Name: %s\n", header.name);
241               logerror("Hardware: %04x\n", hardware);
242               logerror("Slot device: %s\n", CRT_C64_SLOT_NAMES[hardware]);
243               logerror("EXROM: %u\n", header.exrom);
244               logerror("GAME: %u\n", header.game);
245            }
246         
247            // determine ROM region lengths
248            size_t roml_size = 0;
249            size_t romh_size = 0;
250           
251            while (!image_feof())
252            {
253               cbm_crt_chip chip;
254               fread(&chip, CRT_CHIP_LENGTH);
255               
256               UINT16 address = pick_integer_be(chip.start_address, 0, 2);
257               UINT16 size = pick_integer_be(chip.image_size, 0, 2);
258               UINT16 type = pick_integer_be(chip.chip_type, 0, 2);
259               
260               if (LOG)
261               {
262                  logerror("CHIP Address: %04x\n", address);
263                  logerror("CHIP Size: %04x\n", size);
264                  logerror("CHIP Type: %04x\n", type);
265               }
266               
267               switch (address)
268               {
269               case 0x8000: roml_size += size; break;
270               case 0xa000: romh_size += size; break;
271               case 0xe000: romh_size += size; break;
272               default: logerror("Invalid CHIP loading address!\n"); break;
273               }
274               
275               fseek(size, SEEK_CUR);
276            }
220277
221            switch (size)
278            // allocate cartridge memory
279            UINT8 *roml = NULL;
280            UINT8 *romh = NULL;
281           
282            if (roml_size) roml = m_cart->c64_roml_pointer(machine(), roml_size);
283            if (romh_size) romh = m_cart->c64_romh_pointer(machine(), romh_size);
284           
285            // read the data
286            offs_t roml_offset = 0;
287            offs_t romh_offset = 0;
288           
289            fseek(CRT_HEADER_LENGTH, SEEK_SET);
290           
291            while (!image_feof())
222292            {
223            case 0x2000:
224               memcpy(m_cart->c64_roml_pointer(machine(), 0x2000), get_software_region("roml"), size);
293               cbm_crt_chip chip;
294               fread(&chip, CRT_CHIP_LENGTH);
295               
296               UINT16 address = pick_integer_be(chip.start_address, 0, 2);
297               UINT16 size = pick_integer_be(chip.image_size, 0, 2);
225298
226               size = get_software_region_length("romh");
227               if (size) memcpy(m_cart->c64_romh_pointer(machine(), 0x2000), get_software_region("romh"), size);
228               break;
229
230            case 0x4000:
231               memcpy(m_cart->c64_roml_pointer(machine(), 0x2000), get_software_region("roml"), 0x2000);
232               memcpy(m_cart->c64_romh_pointer(machine(), 0x2000), get_software_region("roml") + 0x2000, 0x2000);
233               break;
234
235            default:
236               memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
237               break;
299               switch (address)
300               {
301               case 0x8000: fread(roml + roml_offset, size); roml_offset += size; break;
302               case 0xa000: fread(romh + romh_offset, size); romh_offset += size; break;
303               case 0xe000: fread(romh + romh_offset, size); romh_offset += size; break;
304               }
238305            }
239         }
240         else
241         {
242            size = get_software_region_length("roml");
243            if (size) memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
244306           
245            size = get_software_region_length("romh");
246            if (size) memcpy(m_cart->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
247
248            size = get_software_region_length("ram");
249            if (size) memset(m_cart->c64_ram_pointer(machine(), size), 0, size);
307            m_cart->c64_exrom_w(header.exrom);
308            m_cart->c64_game_w(header.game);
250309         }
310      }
311      else
312      {
313         size = get_software_region_length("roml");
314         if (size) memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
315         
316         size = get_software_region_length("romh");
317         if (size) memcpy(m_cart->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
251318
319         size = get_software_region_length("ram");
320         if (size) memset(m_cart->c64_ram_pointer(machine(), size), 0, size);
321
322         m_cart->c64_exrom_w(atol(get_feature("exrom")));
252323         m_cart->c64_game_w(atol(get_feature("game")));
253         m_cart->c64_exrom_w(atol(get_feature("exrom")));
254324      }
255325   }
256326
src/mess/formats/cbm_crt.h
r14506r14507
1919//  MACROS/CONSTANTS
2020//**************************************************************************
2121 
22#define CRT_SIGNATURE      "C64 CARTRIDGE   "
23 
2224#define CRT_HEADER_LENGTH   0x40
2325#define CRT_CHIP_LENGTH      0x10
2426 
r14506r14507
148150};
149151 
150152 
153// chip types
154enum
155{
156   CRT_CHIP_TYPE_ROM = 0,
157   CRT_CHIP_TYPE_RAM,
158   CRT_CHIP_TYPE_FLASH_ROM
159};
151160 
161 
162 
152163//**************************************************************************
153164//  TYPE DEFINITIONS
154165//**************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team