Пример #1
0
void convert_tiles(u8 *chr,cache_t *cache,int num,int hflip)
{
	int n;

	for(n=0;n<num;n++) {
		if(hflip != 0)
			convert_tile_hflip(chr,cache);
		else
			convert_tile(chr,cache);
		chr += 16;
		cache += CACHE_TILE_SIZE;
	}
}
Пример #2
0
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;
}