src/mess/machine/c64.c
| r11474 | r11475 | |
| 1304 | 1304 | |
| 1305 | 1305 | static void load_vizawrite_cartridge(device_image_interface &image) |
| 1306 | 1306 | { |
| 1307 | | #define DECRYPT_ADDRESS(_offset) \ |
| 1307 | #define VW64_DECRYPT_ADDRESS(_offset) \ |
| 1308 | 1308 | BITSWAP16(_offset,15,14,13,12,7,8,6,9,5,11,4,3,2,10,1,0) |
| 1309 | 1309 | |
| 1310 | | #define DECRYPT_DATA(_data) \ |
| 1310 | #define VW64_DECRYPT_DATA(_data) \ |
| 1311 | 1311 | BITSWAP8(_data,7,6,0,5,1,4,2,3) |
| 1312 | 1312 | |
| 1313 | 1313 | c64_state *state = image.device().machine().driver_data<c64_state>(); |
| r11474 | r11475 | |
| 1319 | 1319 | // decrypt ROMs |
| 1320 | 1320 | for (offs_t offset = 0; offset < 0x2000; offset++) |
| 1321 | 1321 | { |
| 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]); |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | // map cartridge ROMs |
| r11474 | r11475 | |
| 1334 | 1334 | state->m_cartridge_timer->adjust(attotime::from_msec(1184), 0); |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | static 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 | |
| 1362 | static 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 | |
| 1337 | 1390 | static void c64_software_list_cartridge_load(device_image_interface &image) |
| 1338 | 1391 | { |
| 1339 | 1392 | c64_state *state = image.device().machine().driver_data<c64_state>(); |
| r11474 | r11475 | |
| 1361 | 1414 | { |
| 1362 | 1415 | if (!strcmp(cart_type, "vizawrite")) |
| 1363 | 1416 | load_vizawrite_cartridge(image); |
| 1417 | |
| 1418 | if (!strcmp(cart_type, "hugo")) |
| 1419 | load_hugo_cartridge(image); |
| 1364 | 1420 | } |
| 1365 | 1421 | } |
| 1366 | 1422 | |