void fidelz80_state::update_display() { // data for the 4x 7seg leds, bits are 0bxABCDEFG UINT8 out_digit = BITSWAP8( m_digit_data,7,0,1,2,3,4,5,6 ) & 0x7f; if (m_led_selected&0x04) { output_set_digit_value(0, out_digit); output_set_led_value(1, m_led_data & 0x01); } if (m_led_selected&0x08) { output_set_digit_value(1, out_digit); output_set_led_value(0, m_led_data & 0x01); } if (m_led_selected&0x10) { output_set_digit_value(2, out_digit); } if (m_led_selected&0x20) { output_set_digit_value(3, out_digit); } }
ROM_END static DRIVER_INIT( wink ) { unsigned int i; UINT8 *ROM = memory_region(REGION_CPU1); UINT8 *buffer = malloc(0x8000); // protection module reverse engineered by HIGHWAYMAN if (buffer) { memcpy(buffer,ROM,0x8000); for (i = 0x0000; i <= 0x1fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; for (i = 0x2000; i <= 0x3fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 10, 7,12, 9, 8,11, 6, 3, 1, 5, 2, 4, 0)]; for (i = 0x4000; i <= 0x5fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 7,10,11, 9, 8,12, 6, 1, 3, 4, 2, 5, 0)]; for (i = 0x6000; i <= 0x7fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; free(buffer); } for (i = 0; i < 0x8000; i++) ROM[i] += BITSWAP8(i & 0xff, 7,5,3,1,6,4,2,0); }
static DRIVER_INIT( togenkyo ) { #if 0 UINT8 *prot = machine.region("protdata")->base(); int i; /* this is one possible way to rearrange the protection ROM data to get the expected 0x5ece checksum. It's probably completely wrong! But since the game doesn't do anything else with that ROM, this is more than enough. I could just fill this are with fake data, the only thing that matters is the checksum. */ for (i = 0;i < 0x20000;i++) { prot[i] = BITSWAP8(prot[i],2,7,3,5,0,6,4,1); } #else unsigned char *ROM = machine.region("maincpu")->base(); // Protection ROM check skip ROM[0x010b] = 0x00; ROM[0x010c] = 0x00; ROM[0x010d] = 0x00; // Program ROM SUM check skip // ROM[0x025c] = 0x00; // ROM[0x025d] = 0x00; #endif nb1413m3_type = NB1413M3_TOGENKYO; //S init_nb1413m3(machine); }
MACHINE_CONFIG_END DRIVER_INIT_MEMBER(forte2_state,pesadelo) { int i; UINT8 *mem = memregion("maincpu")->base(); int memsize = memregion("maincpu")->bytes(); UINT8 *buf; // data swap for ( i = 0; i < memsize; i++ ) { mem[i] = BITSWAP8(mem[i],3,5,6,7,0,4,2,1); } // address line swap buf = auto_alloc_array(machine(), UINT8, memsize); memcpy(buf, mem, memsize); for ( i = 0; i < memsize; i++ ) { mem[BITSWAP16(i,11,9,8,13,14,15,12,7,6,5,4,3,2,1,0,10)] = buf[i]; } auto_free(machine(), buf); }
UINT8 deco_cpu6_device::mi_decrypt::read_decrypted(UINT16 adr) { if (adr&1) return BITSWAP8(direct->read_raw_byte(adr),6,4,7,5,3,2,1,0); else return direct->read_raw_byte(adr); }
ROM_END DRIVER_INIT_MEMBER(wink_state,wink) { UINT32 i; UINT8 *ROM = memregion("maincpu")->base(); dynamic_buffer buffer(0x8000); // protection module reverse engineered by HIGHWAYMAN memcpy(&buffer[0],ROM,0x8000); for (i = 0x0000; i <= 0x1fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; for (i = 0x2000; i <= 0x3fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 10, 7,12, 9, 8,11, 6, 3, 1, 5, 2, 4, 0)]; for (i = 0x4000; i <= 0x5fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 7,10,11, 9, 8,12, 6, 1, 3, 4, 2, 5, 0)]; for (i = 0x6000; i <= 0x7fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; for (i = 0; i < 0x8000; i++) ROM[i] += BITSWAP8(i & 0xff, 7,5,3,1,6,4,2,0); }
ROM_END static DRIVER_INIT( hnfubuki ) { UINT8 *rom = memory_region(REGION_GFX1); int len = memory_region_length(REGION_GFX1); int i,j; /* interestingly, the blitter data has a slight encryption */ /* swap address bits 4 and 5 */ for (i = 0;i < len;i += 0x40) { for (j = 0;j < 0x10;j++) { UINT8 t = rom[i + j + 0x10]; rom[i + j + 0x10] = rom[i + j + 0x20]; rom[i + j + 0x20] = t; } } /* swap data bits 0 and 1 */ for (i = 0;i < len;i++) { rom[i] = BITSWAP8(rom[i],7,6,5,4,3,2,0,1); } }
ROM_END static DRIVER_INIT( wink ) { UINT32 i; UINT8 *ROM = memory_region(machine, "maincpu"); UINT8 *buffer = auto_alloc_array(machine, UINT8, 0x8000); // protection module reverse engineered by HIGHWAYMAN memcpy(buffer,ROM,0x8000); for (i = 0x0000; i <= 0x1fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; for (i = 0x2000; i <= 0x3fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 10, 7,12, 9, 8,11, 6, 3, 1, 5, 2, 4, 0)]; for (i = 0x4000; i <= 0x5fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 7,10,11, 9, 8,12, 6, 1, 3, 4, 2, 5, 0)]; for (i = 0x6000; i <= 0x7fff; i++) ROM[i] = buffer[BITSWAP16(i,15,14,13, 11,12, 7, 9, 8,10, 6, 4, 5, 1, 2, 3, 0)]; auto_free(machine, buffer); for (i = 0; i < 0x8000; i++) ROM[i] += BITSWAP8(i & 0xff, 7,5,3,1,6,4,2,0); }
void elwro800_state::elwro800jr_mmu_w(UINT8 data) { UINT8 *prom = memregion("proms")->base() + 0x200; UINT8 *messram = m_ram->pointer(); UINT8 cs; UINT8 ls175; ls175 = BITSWAP8(data, 7, 6, 5, 4, 4, 5, 7, 6) & 0x0f; cs = prom[((0x0000 >> 10) | (ls175 << 6)) & 0x1ff]; if (!BIT(cs,0)) { // rom BAS0 membank("bank1")->set_base(memregion("maincpu")->base() + 0x0000); /* BAS0 ROM */ m_maincpu->space(AS_PROGRAM).nop_write(0x0000, 0x1fff); m_ram_at_0000 = 0; } else if (!BIT(cs,4)) { // rom BOOT membank("bank1")->set_base(memregion("maincpu")->base() + 0x4000); /* BOOT ROM */ m_maincpu->space(AS_PROGRAM).nop_write(0x0000, 0x1fff); m_ram_at_0000 = 0; } else { // RAM membank("bank1")->set_base(messram); m_maincpu->space(AS_PROGRAM).install_write_bank(0x0000, 0x1fff, "bank1"); m_ram_at_0000 = 1; } cs = prom[((0x2000 >> 10) | (ls175 << 6)) & 0x1ff]; if (!BIT(cs,1)) { membank("bank2")->set_base(memregion("maincpu")->base() + 0x2000); /* BAS1 ROM */ m_maincpu->space(AS_PROGRAM).nop_write(0x2000, 0x3fff); } else { membank("bank2")->set_base(messram + 0x2000); /* RAM */ m_maincpu->space(AS_PROGRAM).install_write_bank(0x2000, 0x3fff, "bank2"); } if (BIT(ls175,2)) { // relok m_screen_location = messram + 0xe000; } else { m_screen_location = messram + 0x4000; } m_NR = BIT(ls175,3); if (BIT(ls175,3)) { logerror("Reading network number\n"); } }
ROM_END DRIVER_INIT_MEMBER(hnayayoi_state,hnfubuki) { UINT8 *rom = machine().root_device().memregion("gfx1")->base(); int len = machine().root_device().memregion("gfx1")->bytes(); int i, j; /* interestingly, the blitter data has a slight encryption */ /* swap address bits 4 and 5 */ for (i = 0; i < len; i += 0x40) { for (j = 0; j < 0x10; j++) { UINT8 t = rom[i + j + 0x10]; rom[i + j + 0x10] = rom[i + j + 0x20]; rom[i + j + 0x20] = t; } } /* swap data bits 0 and 1 */ for (i = 0; i < len; i++) { rom[i] = BITSWAP8(rom[i],7,6,5,4,3,2,0,1); } }
ROM_END /************************************** * Driver Init * **************************************/ /* This reflect how was connected the bus to the EPROM inside the epoxy CPU block. They used ultra-thin wires, just to melt down with the epoxy in case someone try to use a heat gun for epoxy removal purposes... Bus / Eprom D0-> D5 D1-> D6 D2-> D0 D3-> D7 D4-> D2 D5-> D4 D6-> D3 D7-> D1 A00-> A10 A01-> A08 A02-> A01 A03-> A11 A04-> A05 A05-> A13 A06-> A12 A07-> A04 A08-> A02 A09-> A07 A10-> A03 A11-> A00 A12-> A09 A13-> A06 A14-> A14 */ DRIVER_INIT_MEMBER(kas89_state,kas89) { int i; uint8_t *mem = memregion("maincpu")->base(); int memsize = memregion("maincpu")->bytes(); /* Unscrambling data lines */ for ( i = 0; i < memsize; i++ ) { mem[i] = BITSWAP8(mem[i], 3, 1, 0, 5, 6, 4, 7, 2); } /* Unscrambling address lines */ std::vector<uint8_t> buf(memsize); memcpy(&buf[0], mem, memsize); for ( i = 0; i < memsize; i++ ) { mem[BITSWAP16(i, 15, 14, 5, 6, 3, 0, 12, 1, 9, 13, 4, 7, 10, 8, 2, 11)] = buf[i]; } }
// this should be correct, the areas of the ROM that differ to the original // after this decode look like intentional changes static DRIVER_INIT( mk3mdb ) { UINT8 *rom = machine->region("maincpu")->base(); for (int x = 0x000001; x < 0x100001; x += 2) { if (x & 0x80000) { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 0,3,2,5,4,6,7,1); } else { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 4,0,7,1,3,6,2,5); } } for (int x = 0x100001; x < 0x400000; x += 2) { if (x & 0x80000) { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 2,7,5,4,1,0,3,6); } else { rom[x] = BITSWAP8(rom[x], 6,1,4,2,7,0,3,5); } } // boot vectors don't seem to be valid, so they are patched... rom[0x01] = 0x01; rom[0x00] = 0x00; rom[0x03] = 0x00; rom[0x02] = 0x00; rom[0x05] = 0x00; rom[0x04] = 0x00; rom[0x07] = 0x02; rom[0x06] = 0x10; memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770075, 0, 0, mk3mdb_dsw_r ); megadrive_6buttons_pad = 1; DRIVER_INIT_CALL(megadriv); }
static void decrypt_snd(running_machine *machine) { int i; UINT8 *ROM = memory_region(machine, "t5182"); for(i=0x8000;i<0x10000;i++) ROM[i] = BITSWAP8(ROM[i], 7,1,2,3,4,5,6,0); }
static void decrypt_snd(running_machine &machine) { int i; UINT8 *ROM = machine.region("t5182")->base(); for(i=0x8000;i<0x10000;i++) ROM[i] = BITSWAP8(ROM[i], 7,1,2,3,4,5,6,0); }
void fidel68k_state::eag_prepare_display() { // Excel 68000: 4*7seg leds, 8*8 chessboard leds // EAG: 8*7seg leds(2 panels), (8+1)*8 chessboard leds uint8_t seg_data = BITSWAP8(m_7seg_data,0,1,3,2,7,5,6,4); set_display_segmask(0x1ff, 0x7f); display_matrix(16, 9, m_led_data << 8 | seg_data, m_inp_mux); }
ROM_END static DRIVER_INIT(mv4in1) { int i; for(i=0;i<0x10000;i++) memory_region(REGION_CPU1)[i]=BITSWAP8(memory_region(REGION_CPU1)[i],7,6,5,4,3,1,2,0); }
void darkmist_state::decrypt_snd() { int i; UINT8 *ROM = memregion("t5182_z80")->base(); for(i=0x0000;i<0x2000;i++) ROM[i] = BITSWAP8(ROM[i], 7,1,2,3,4,5,6,0); }
// this should be correct, the areas of the ROM that differ to the original // after this decode look like intentional changes DRIVER_INIT_MEMBER(md_boot_state,mk3mdb) { UINT8 *rom = machine().root_device().memregion("maincpu")->base(); for (int x = 0x000001; x < 0x100001; x += 2) { if (x & 0x80000) { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 0,3,2,5,4,6,7,1); } else { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 4,0,7,1,3,6,2,5); } } for (int x = 0x100001; x < 0x400000; x += 2) { if (x & 0x80000) { rom[x] = rom[x] ^ 0xff; rom[x] = BITSWAP8(rom[x], 2,7,5,4,1,0,3,6); } else { rom[x] = BITSWAP8(rom[x], 6,1,4,2,7,0,3,5); } } // boot vectors don't seem to be valid, so they are patched... rom[0x01] = 0x01; rom[0x00] = 0x00; rom[0x03] = 0x00; rom[0x02] = 0x00; rom[0x05] = 0x00; rom[0x04] = 0x00; rom[0x07] = 0x02; rom[0x06] = 0x10; machine().device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770070, 0x770075, FUNC(mk3mdb_dsw_r) ); megadrive_6buttons_pad = 1; DRIVER_INIT_CALL(megadriv); }
ROM_END static DRIVER_INIT(mv4in1) { int i; UINT8 *rom = machine.root_device().memregion("maincpu")->base(); for(i=0;i<0x10000;i++) rom[i]=BITSWAP8(rom[i],7,6,5,4,3,1,2,0); }
static UINT8 decrypt_opcode(int a,int src) { if ( BIT(a,9) & BIT(a,8)) src ^= 0x80; if ( BIT(a,11) & BIT(a,4) & BIT(a,1)) src ^= 0x40; if (~BIT(a,13) & BIT(a,12)) src ^= 0x20; if (~BIT(a,6) & BIT(a,1)) src ^= 0x10; if (~BIT(a,12) & BIT(a,2)) src ^= 0x08; if ( BIT(a,11) & ~BIT(a,8) & BIT(a,1)) src ^= 0x04; if ( BIT(a,13) & ~BIT(a,6) & BIT(a,4)) src ^= 0x02; if (~BIT(a,11) & BIT(a,9) & BIT(a,2)) src ^= 0x01; if (BIT(a,13) & BIT(a,4)) src = BITSWAP8(src,7,6,5,4,3,2,0,1); if (BIT(a, 8) & BIT(a,4)) src = BITSWAP8(src,7,6,5,4,2,3,1,0); if (BIT(a,12) & BIT(a,9)) src = BITSWAP8(src,7,6,4,5,3,2,1,0); if (BIT(a,11) & ~BIT(a,6)) src = BITSWAP8(src,6,7,5,4,3,2,1,0); return src; }
ADDRESS_MAP_END /*********************************************************************/ READ8_MEMBER(cabal_state::cabalbl_snd2_r) { return BITSWAP8(m_sound_command2, 7,2,4,5,3,6,1,0); }
static DRIVER_INIT( shtridra ) { int A; UINT8 *rom = memory_region(REGION_CPU1); /* D3/D4 and D5/D6 swapped */ for (A = 0; A < 0x2000; A++) rom[A] = BITSWAP8(rom[A],7,5,6,3,4,2,1,0); }
DRIVER_INIT_MEMBER(travrusa_state,shtridra) { int A; UINT8 *rom = memregion("maincpu")->base(); /* D3/D4 and D5/D6 swapped */ for (A = 0; A < 0x2000; A++) rom[A] = BITSWAP8(rom[A],7,5,6,3,4,2,1,0); }
ROM_END DRIVER_INIT_MEMBER(ltcasino_state,mv4in1) { int i; UINT8 *rom = memregion("maincpu")->base(); for(i=0;i<0x10000;i++) rom[i]=BITSWAP8(rom[i],7,6,5,4,3,1,2,0); }
static DRIVER_INIT( shtridra ) { int A; UINT8 *rom = machine.region("maincpu")->base(); /* D3/D4 and D5/D6 swapped */ for (A = 0; A < 0x2000; A++) rom[A] = BITSWAP8(rom[A],7,5,6,3,4,2,1,0); }
void victor21_bitswaps(UINT8 *decrypt, int i) { if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,4,7,2,5,0 ); if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 ); if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 3,6,5,0,7,2,1,4 ); if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,4,3,2,1,0 ); if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 ); }
uint8_t deco_cpu7_device::mi_decrypt::read_sync(uint16_t adr) { uint8_t res = direct->read_byte(adr); if(had_written) { had_written = false; if((adr & 0x0104) == 0x0104) res = BITSWAP8(res, 6,5,3,4,2,7,1,0); } return res; }
void nmk16_state::nmk16_draw_sprites_swap_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl) { int i; for ( i = 0; i < 0x100; i++ ) { int spr = BITSWAP8(i, bittbl[0], bittbl[1], bittbl[2], bittbl[3], bittbl[4], bittbl[5], bittbl[6], bittbl[7]); nmk16_draw_sprite_flipsupported(bitmap, cliprect, m_spriteram_old2.get() + (spr * 16/2)); } }
void seibu_adpcm_device::decrypt(const char *region) { UINT8 *ROM = machine().root_device().memregion(region)->base(); int len = machine().root_device().memregion(region)->bytes(); for (int i = 0; i < len; i++) { ROM[i] = BITSWAP8(ROM[i], 7, 5, 3, 1, 6, 4, 2, 0); } }
UINT8 deco_cpu7_device::mi_decrypt::read_decrypted(UINT16 adr) { UINT8 res = direct->read_raw_byte(adr); if(had_written) { had_written = false; if((adr & 0x0104) == 0x0104) res = BITSWAP8(res, 6,5,3,4,2,7,1,0); } return res; }