Previous 15994 Revisions Next

r11475 Saturday 7th May, 2011 at 15:44:16 UTC by Curt Coder
[C64] Added mapper for the "Skaermtrolden Hugo" cartridge. [Curt Coder]
[hash]c64_cart.xml
[src/mess/machine]c64.c

hash/c64_cart.xml
r11474r11475
408408   </software>
409409
410410   <software name="hugo" supported="no">
411      <description>Skærmtrolden Hugo</description>
411      <description>Skærmtrolden Hugo (Denmark)</description>
412412      <year>1990</year>
413413      <publisher>SilverRock Productions</publisher>
414414      <!--
r11474r11475
439439         <feature name="exrom" value="0" />
440440         <feature name="pcb" value="e9048" />
441441
442         <dataarea name="rom" size="0x20000">
443            <rom name="hugo 2012" size="0x20000" offset="0x0000" status="nodump"/>
442         <dataarea name="roml" size="0x20000">
443            <rom name="hugo 2012" size="0x20000" crc="7059dfc6" sha1="7cc9ac838f1eb02c7e1bab3b3b4da1d791409dea" offset="0x0000"/>
444444         </dataarea>
445445      </part>
446446   </software>
src/mess/machine/c64.c
r11474r11475
13041304
13051305static void load_vizawrite_cartridge(device_image_interface &image)
13061306{
1307   #define DECRYPT_ADDRESS(_offset) \
1307   #define VW64_DECRYPT_ADDRESS(_offset) \
13081308      BITSWAP16(_offset,15,14,13,12,7,8,6,9,5,11,4,3,2,10,1,0)
13091309   
1310   #define DECRYPT_DATA(_data) \
1310   #define VW64_DECRYPT_DATA(_data) \
13111311      BITSWAP8(_data,7,6,0,5,1,4,2,3)
13121312
13131313   c64_state *state = image.device().machine().driver_data<c64_state>();
r11474r11475
13191319   // decrypt ROMs
13201320   for (offs_t offset = 0; offset < 0x2000; offset++)
13211321   {
1322      offs_t address = DECRYPT_ADDRESS(offset);
1323      decrypted[address] = DECRYPT_DATA(roml[offset]);
1324      decrypted[address + 0x2000] = DECRYPT_DATA(roml[offset + 0x2000]);
1325      decrypted[address + 0x4000] = DECRYPT_DATA(romh[offset]);
1322      offs_t address = VW64_DECRYPT_ADDRESS(offset);
1323      decrypted[address] = VW64_DECRYPT_DATA(roml[offset]);
1324      decrypted[address + 0x2000] = VW64_DECRYPT_DATA(roml[offset + 0x2000]);
1325      decrypted[address + 0x4000] = VW64_DECRYPT_DATA(romh[offset]);
13261326   }
13271327
13281328   // map cartridge ROMs
r11474r11475
13341334   state->m_cartridge_timer->adjust(attotime::from_msec(1184), 0);
13351335}
13361336
1337static WRITE8_HANDLER( hugo_bank_w )
1338{
1339   /*
1340
1341      bit      description
1342
1343      0
1344      1
1345      2
1346      3
1347      4      A14
1348      5      A15
1349      6      A16
1350      7      A13
1351
1352   */
1353
1354   c64_state *state = space->machine().driver_data<c64_state>();
1355
1356   int bank = ((data >> 3) & 0x0e) | BIT(data, 7);
1357
1358   UINT8 *decrypted = space->machine().region("user1")->base();
1359   memcpy(state->m_roml, decrypted + (bank * 0x2000), 0x2000);
1360}
1361
1362static void load_hugo_cartridge(device_image_interface &image)
1363{
1364   #define HUGO_DECRYPT_ADDRESS(_offset) \
1365      BITSWAP16(_offset,15,14,13,12,7,6,5,4,3,2,1,0,8,9,11,10)
1366   
1367   #define HUGO_DECRYPT_DATA(_data) \
1368      BITSWAP8(_data,7,6,5,4,0,1,2,3)
1369
1370   c64_state *state = image.device().machine().driver_data<c64_state>();
1371
1372   UINT8 *roml = image.get_software_region("roml");
1373   UINT8 *decrypted = image.device().machine().region("user1")->base();
1374
1375   // decrypt ROMs
1376   for (offs_t offset = 0; offset < 0x20000; offset++)
1377   {
1378      offs_t address = (offset & 0x10000) | HUGO_DECRYPT_ADDRESS(offset);
1379      decrypted[address] = HUGO_DECRYPT_DATA(roml[offset]);
1380   }
1381
1382   // map cartridge ROMs
1383   memcpy(state->m_roml, decrypted, 0x2000);
1384
1385   // install bankswitch handler
1386   address_space *space = image.device().machine().device( "maincpu")->memory().space( AS_PROGRAM );
1387   space->install_legacy_write_handler( 0xde00, 0xdeff, FUNC(hugo_bank_w) );
1388}
1389
13371390static void c64_software_list_cartridge_load(device_image_interface &image)
13381391{
13391392   c64_state *state = image.device().machine().driver_data<c64_state>();
r11474r11475
13611414   {
13621415      if (!strcmp(cart_type, "vizawrite"))
13631416         load_vizawrite_cartridge(image);
1417     
1418      if (!strcmp(cart_type, "hugo"))
1419         load_hugo_cartridge(image);
13641420   }
13651421}
13661422

Previous 15994 Revisions Next


© 1998-2018 The MESS Team