// handle protected carts static void install_protection(device_image_interface& image) { neogeo_state *state = image.device().machine().driver_data<neogeo_state>(); const char *crypt_feature = image.get_feature( "crypt" ); if(crypt_feature == NULL) return; if(strcmp(crypt_feature,"fatfury2_prot") == 0) { fatfury2_install_protection(image.device().machine()); logerror("Installed Fatal Fury 2 protection\n"); } if(strcmp(crypt_feature,"kof99_crypt") == 0) { kof99_decrypt_68k(image.device().machine()); state->m_fixed_layer_bank_type = 1; kof99_neogeo_gfx_decrypt(image.device().machine(), 0x00); kof99_install_protection(image.device().machine()); logerror("Decrypted KOF99 code and graphics.\n"); } if(strcmp(crypt_feature,"mslug3_crypt") == 0) { state->m_fixed_layer_bank_type = 1; kof99_neogeo_gfx_decrypt(image.device().machine(), 0xad); logerror("Decrypted Metal Slug 3 graphics\n"); } if(strcmp(crypt_feature,"matrim_crypt") == 0) { matrim_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 1); state->m_fixed_layer_bank_type = 2; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x6a); logerror("Decrypted Matrimelee code, sound and graphics\n"); } if(strcmp(crypt_feature,"svc_crypt") == 0) { svc_px_decrypt(image.device().machine()); neo_pcm2_swap(image.device().machine(), 3); state->m_fixed_layer_bank_type = 2; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x57); install_pvc_protection(image.device().machine()); logerror("Decrypted SvC code, sound and graphics.\n"); } if(strcmp(crypt_feature,"samsho5_crypt") == 0) { samsho5_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 4); state->m_fixed_layer_bank_type = 1; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x0f); logerror("Decrypted Samurai Shodown V code, sound and graphics.\n"); } if(strcmp(crypt_feature,"kof2000_crypt") == 0) { kof2000_decrypt_68k(image.device().machine()); state->m_fixed_layer_bank_type = 2; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x00); kof2000_install_protection(image.device().machine()); logerror("Decrypted KOF2000 code, sound and graphics.\n"); } if(strcmp(crypt_feature,"kof2001_crypt") == 0) { state->m_fixed_layer_bank_type = 1; kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x1e); neogeo_cmc50_m1_decrypt(image.device().machine()); logerror("Decrypted KOF2001 code and graphics.\n"); } if(strcmp(crypt_feature,"kof2002_crypt") == 0) { kof2002_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 0); neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0xec); logerror("Decrypted KOF2002 code, sound and graphics.\n"); } if(strcmp(crypt_feature,"mslug4_crypt") == 0) { state->m_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */ neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x31); neo_pcm2_snk_1999(image.device().machine(), 8); logerror("Decrypted Metal Slug 4 code, sound and graphics.\n"); } if(strcmp(crypt_feature,"mslug5_crypt") == 0) { mslug5_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 2); state->m_fixed_layer_bank_type = 1; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x19); install_pvc_protection(image.device().machine()); logerror("Decrypted Metal Slug 5 code and graphics, and installed protection routines.\n"); } if(strcmp(crypt_feature,"kof2003_crypt") == 0) { kof2003h_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 5); state->m_fixed_layer_bank_type = 2; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x9d); install_pvc_protection(image.device().machine()); logerror("Decrypted KOF2003 code and graphicss, and installed protection routines.\n"); } if(strcmp(crypt_feature,"samsho5s_crypt") == 0) { samsh5sp_decrypt_68k(image.device().machine()); neo_pcm2_swap(image.device().machine(), 6); state->m_fixed_layer_bank_type = 1; neogeo_cmc50_m1_decrypt(image.device().machine()); kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x0d); } }
SDL_bool dr_load_game(DRIVER *dr,char *name) { unzFile *gz; int i; LIST *l; char *zip=get_zip_name(name); gz = unzOpen(zip); free(zip); if (gz==NULL) { return SDL_FALSE; } if (dr->special_bios) { memory.bios=malloc(dr->bios.size); memory.bios_size=dr->bios.size; if (!dr_load_section(gz,dr->bios,memory.bios)) return SDL_FALSE; } for (i=0;i<SEC_MAX;i++) { int s=dr->section[i].size; Uint8 *current_buf=NULL; //if (dr->section[i].item==NULL) continue; if (s==0) continue; // printf("%p %d \n",dr->section[i].item,i); switch (i) { case SEC_CPU: memory.cpu = malloc(s); current_buf = memory.cpu; memory.cpu_size = s; break; case SEC_SFIX: memory.sfix_game = malloc(s); memory.fix_game_usage = malloc(s >> 5); current_buf = memory.sfix_game; memory.sfix_size = s; break; case SEC_SM1: memory.sm1 = malloc(s); current_buf = memory.sm1; memory.sm1_size = s; break; case SEC_SOUND1: memory.sound1 = malloc(s); memory.sound1_size = s; current_buf = memory.sound1; break; case SEC_SOUND2: memory.sound2 = malloc(s); memory.sound2_size = s; current_buf = memory.sound2; break; case SEC_GFX: memory.gfx = malloc(s); //printf("Alloc %x for GFX: %p\n",s,memory.gfx); memory.gfx_size = s; current_buf = memory.gfx; memory.pen_usage = malloc((s >> 7) * sizeof(int)); memset(memory.pen_usage, 0, (s >> 7) * sizeof(int)); memory.nb_of_tiles = s >> 7; break; /* TODO: Crypted rom */ default: break; } if (!dr_load_section(gz,dr->section[i],current_buf)) return SDL_FALSE; } unzClose(gz); /* TODO: Use directly the driver value insteed of recopying them */ conf.game=dr->name; conf.rom_type=dr->rom_type; conf.special_bios=dr->special_bios; conf.extra_xor=dr->xor; set_bankswitchers(dr->banksw_type); for(i=0;i<6;i++) memory.bksw_unscramble[i]=dr->banksw_unscramble[i]; for(i=0;i<64;i++) memory.bksw_offset[i]=dr->banksw_off[i]; if (conf.rom_type == MGD2) { create_progress_bar("Convert MGD2"); convert_mgd2_tiles(memory.gfx, memory.gfx_size); convert_mgd2_tiles(memory.gfx, memory.gfx_size); terminate_progress_bar(); } if (conf.rom_type == MVS_CMC42) { create_progress_bar("Decrypt GFX "); kof99_neogeo_gfx_decrypt(conf.extra_xor); terminate_progress_bar(); } if (conf.rom_type == MVS_CMC50) { create_progress_bar("Decrypt GFX "); kof2000_neogeo_gfx_decrypt(conf.extra_xor); terminate_progress_bar(); } convert_all_char(memory.sfix_game, memory.sfix_size, memory.fix_game_usage); if (CF_BOOL(cf_get_item_by_name("convtile"))) { create_progress_bar("Convert tile"); for (i = 0; i < memory.nb_of_tiles; i++) { convert_tile(i); if (i%100==0) update_progress_bar(i,memory.nb_of_tiles); } terminate_progress_bar(); } if (memory.sound2 == NULL) { memory.sound2 = memory.sound1; memory.sound2_size = memory.sound1_size; } //backup neogeo game vectors memcpy(memory.game_vector,memory.cpu,0x80); printf(" \r"); return SDL_TRUE; }