DRIVER_INIT_MEMBER(darkmist_state,darkmist) { int i, len; uint8_t *ROM = memregion("maincpu")->base(); std::vector<uint8_t> buffer(0x10000); decrypt_gfx(); decrypt_snd(); for(i=0;i<0x8000;i++) { uint8_t p, d; p = d = ROM[i]; if(((i & 0x20) == 0x00) && ((i & 0x8) != 0)) p ^= 0x20; if(((i & 0x20) == 0x00) && ((i & 0xa) != 0)) d ^= 0x20; if(((i & 0x200) == 0x200) && ((i & 0x408) != 0)) p ^= 0x10; if((i & 0x220) != 0x200) { p = BITSWAP8(p, 7,6,5,2,3,4,1,0); d = BITSWAP8(d, 7,6,5,2,3,4,1,0); } ROM[i] = d; m_decrypted_opcodes[i] = p; } membank("bank1")->set_base(&ROM[0x010000]); /* adr line swaps */ ROM = memregion("bg_map")->base(); len = memregion("bg_map")->bytes(); memcpy( &buffer[0], ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,7,6,5,4,3,15,14,13,12,9,8,2,1,11,10, 0)]; } ROM = memregion("fg_map")->base(); len = memregion("fg_map")->bytes(); memcpy( &buffer[0], ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15 ,6,5,4,3,12,11,10,9,14,13,2,1,8,7 ,0 )]; } }
void darkmist_state::init_darkmist() { uint8_t *ROM = memregion("maincpu")->base(); std::vector<uint8_t> buffer(0x10000); decrypt_gfx(); decrypt_snd(); for (int i = 0; i < 0x8000; i++) { uint8_t p = ROM[i]; uint8_t d = p; if(((i & 0x20) == 0x00) && ((i & 0x8) != 0)) p ^= 0x20; if(((i & 0x20) == 0x00) && ((i & 0xa) != 0)) d ^= 0x20; if(((i & 0x200) == 0x200) && ((i & 0x408) != 0)) p ^= 0x10; if((i & 0x220) != 0x200) { p = bitswap<8>(p, 7,6,5,2,3,4,1,0); d = bitswap<8>(d, 7,6,5,2,3,4,1,0); } ROM[i] = d; m_decrypted_opcodes[i] = p; } membank("bank1")->set_base(&ROM[0x010000]); /* adr line swaps */ ROM = memregion("bg_map")->base(); int len = memregion("bg_map")->bytes(); memcpy( &buffer[0], ROM, len ); for (int i = 0; i < len; i++) { ROM[i]=buffer[bitswap<24>(i,23,22,21,20,19,18,17,16,7,6,5,4,3,15,14,13,12,9,8,2,1,11,10, 0)]; } ROM = memregion("fg_map")->base(); len = memregion("fg_map")->bytes(); memcpy( &buffer[0], ROM, len ); for (int i = 0; i < len; i++) { ROM[i]=buffer[bitswap<24>(i,23,22,21,20,19,18,17,16,15 ,6,5,4,3,12,11,10,9,14,13,2,1,8,7 ,0 )]; } }
static INT32 DrvInit() { BurnSetRefreshRate(60.00); AllMem = NULL; MemIndex(); INT32 nLen = MemEnd - (UINT8 *)0; if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(AllMem, 0, nLen); MemIndex(); { if (BurnLoadRom(DrvZ80ROM + 0x00000, 0, 1)) return 1; if (BurnLoadRom(DrvZ80ROM + 0x10000, 1, 1)) return 1; if (BurnLoadRom(t5182ROM + 0x00000, 2, 1)) return 1; if (BurnLoadRom(t5182ROM + 0x08000, 3, 1)) return 1; if (BurnLoadRom(DrvGfxROM0 + 0x00000, 4, 1)) return 1; if (BurnLoadRom(DrvGfxROM0 + 0x02000, 5, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x10000, 6, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x00000, 7, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x30000, 8, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x20000, 9, 1)) return 1; if (BurnLoadRom(DrvGfxROM2 + 0x00000, 10, 1)) return 1; if (BurnLoadRom(DrvGfxROM2 + 0x10000, 11, 1)) return 1; if (BurnLoadRom(DrvGfxROM2 + 0x20000, 12, 1)) return 1; if (BurnLoadRom(DrvGfxROM2 + 0x30000, 13, 1)) return 1; if (BurnLoadRom(DrvGfxROM3 + 0x00000, 14, 1)) return 1; if (BurnLoadRom(DrvGfxROM3 + 0x08000, 15, 1)) return 1; if (BurnLoadRom(DrvGfxROM4 + 0x00000, 16, 1)) return 1; if (BurnLoadRom(DrvGfxROM4 + 0x04000, 17, 1)) return 1; if (BurnLoadRom(DrvColPROM + 0x00000, 18, 1)) return 1; if (BurnLoadRom(DrvColPROM + 0x00100, 19, 1)) return 1; if (BurnLoadRom(DrvColPROM + 0x00200, 20, 1)) return 1; if (BurnLoadRom(DrvColPROM + 0x00300, 21, 1)) return 1; decrypt_prg(); decrypt_gfx(); decrypt_snd(); DrvGfxDecode(); DrvPaletteInit(); } ZetInit(0); ZetOpen(0); ZetMapMemory(DrvZ80ROM, 0x0000, 0x7fff, MAP_ROM); ZetMapMemory(DrvZ80ROMDec, 0x0000, 0x7fff, MAP_FETCHOP); ZetMapMemory(DrvPalRAM, 0xd000, 0xd3ff, MAP_ROM); ZetMapMemory(DrvScrollRAM, 0xd400, 0xd4ff, MAP_RAM); ZetMapMemory(DrvVidRAM, 0xd800, 0xdfff, MAP_RAM); ZetMapMemory(DrvZ80RAM, 0xe000, 0xefff, MAP_RAM); ZetMapMemory(DrvSprRAM, 0xf000, 0xffff, MAP_RAM); ZetSetWriteHandler(darkmist_main_write); ZetSetReadHandler(darkmist_main_read); ZetClose(); t5182Init(1, 14318180/4); GenericTilesInit(); DrvDoReset(); return 0; }
DRIVER_INIT_MEMBER(darkmist_state,darkmist) { address_space &space = m_maincpu->space(AS_PROGRAM); int i, len; UINT8 *ROM = memregion("maincpu")->base(); dynamic_buffer buffer(0x10000); UINT8 *decrypt = auto_alloc_array(machine(), UINT8, 0x8000); decrypt_gfx(); decrypt_snd(); for(i=0;i<0x8000;i++) { UINT8 p, d; p = d = ROM[i]; if(((i & 0x20) == 0x00) && ((i & 0x8) != 0)) p ^= 0x20; if(((i & 0x20) == 0x00) && ((i & 0xa) != 0)) d ^= 0x20; if(((i & 0x200) == 0x200) && ((i & 0x408) != 0)) p ^= 0x10; if((i & 0x220) != 0x200) { p = BITSWAP8(p, 7,6,5,2,3,4,1,0); d = BITSWAP8(d, 7,6,5,2,3,4,1,0); } ROM[i] = d; decrypt[i] = p; } space.set_decrypted_region(0x0000, 0x7fff, decrypt); membank("bank1")->set_base(&ROM[0x010000]); /* adr line swaps */ ROM = memregion("user1")->base(); len = memregion("user1")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memregion("user2")->base(); len = memregion("user2")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memregion("user3")->base(); len = memregion("user3")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } ROM = memregion("user4")->base(); len = memregion("user4")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } }
static DRIVER_INIT(darkmist) { address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM); int i, len; UINT8 *ROM = machine.region("maincpu")->base(); UINT8 *buffer = auto_alloc_array(machine, UINT8, 0x10000); UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x8000); decrypt_gfx(machine); decrypt_snd(machine); for(i=0;i<0x8000;i++) { UINT8 p, d; p = d = ROM[i]; if(((i & 0x20) == 0x00) && ((i & 0x8) != 0)) p ^= 0x20; if(((i & 0x20) == 0x00) && ((i & 0xa) != 0)) d ^= 0x20; if(((i & 0x200) == 0x200) && ((i & 0x408) != 0)) p ^= 0x10; if((i & 0x220) != 0x200) { p = BITSWAP8(p, 7,6,5,2,3,4,1,0); d = BITSWAP8(d, 7,6,5,2,3,4,1,0); } ROM[i] = d; decrypt[i] = p; } space->set_decrypted_region(0x0000, 0x7fff, decrypt); memory_set_bankptr(space->machine(), "bank1",&ROM[0x010000]); /* adr line swaps */ ROM = machine.region("user1")->base(); len = machine.region("user1")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = machine.region("user2")->base(); len = machine.region("user2")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = machine.region("user3")->base(); len = machine.region("user3")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } ROM = machine.region("user4")->base(); len = machine.region("user4")->bytes(); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } auto_free(machine, buffer); }
static DRIVER_INIT(darkmist) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); int i, len; UINT8 *ROM = memory_region(machine, "maincpu"); UINT8 *buffer = alloc_array_or_die(UINT8, 0x10000); UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x8000); decrypt_gfx(machine); decrypt_snd(machine); for(i=0;i<0x8000;i++) { UINT8 p, d; p = d = ROM[i]; if(((i & 0x20) == 0x00) && ((i & 0x8) != 0)) p ^= 0x20; if(((i & 0x20) == 0x00) && ((i & 0xa) != 0)) d ^= 0x20; if(((i & 0x200) == 0x200) && ((i & 0x408) != 0)) p ^= 0x10; if((i & 0x220) != 0x200) { p = BITSWAP8(p, 7,6,5,2,3,4,1,0); d = BITSWAP8(d, 7,6,5,2,3,4,1,0); } ROM[i] = d; decrypt[i] = p; } memory_set_decrypted_region(space, 0x0000, 0x7fff, decrypt); memory_set_bankptr(space->machine, 1,&ROM[0x010000]); /* adr line swaps */ ROM = memory_region(machine, "user1"); len = memory_region_length(machine, "user1"); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memory_region(machine, "user2"); len = memory_region_length(machine, "user2"); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memory_region(machine, "user3"); len = memory_region_length(machine, "user3"); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } ROM = memory_region(machine, "user4"); len = memory_region_length(machine, "user4"); memcpy( buffer, ROM, len ); for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } free(buffer); }