Exemplo n.º 1
0
// seg000:0C5E
void __pascal far load_opt_sounds(int first,int last) {
	// stub
	dat_type* ibm_dat = NULL;
	dat_type* digi_dat = NULL;
	dat_type* midi_dat = NULL;
	short current;
	ibm_dat = open_dat("IBM_SND2.DAT", 0);
	if (sound_flags & sfDigi) {
		digi_dat = open_dat("DIGISND2.DAT", 0);
	}
	if (sound_flags & sfMidi) {
		midi_dat = open_dat("MIDISND2.DAT", 0);
	}
	for (current = first; current <= last; ++current) {
		//We don't free sounds, so load only once.
		if (sound_pointers[current] != NULL) continue;
		/*if (demo_mode) {
			sound_pointers[current] = decompress_sound((sound_buffer_type*) load_from_opendats_alloc(current + 10000));
		} else*/ {
			//sound_pointers[current] = (sound_buffer_type*) load_from_opendats_alloc(current + 10000, "bin", NULL, NULL);
			//printf("overwriting sound_pointers[%d] = %p\n", current, sound_pointers[current]);
			sound_pointers[current] = load_sound(current);
		}
	}
	if (midi_dat) close_dat(midi_dat);
	if (digi_dat) close_dat(digi_dat);
	close_dat(ibm_dat);
}
Exemplo n.º 2
0
// seg000:22C8
void __pascal far load_title_images(int bgcolor) {
	dat_type* dathandle;
	dathandle = open_dat("TITLE.DAT", 0);
	chtab_title40 = load_sprites_from_file(40, 1<<11, 1);
	chtab_title50 = load_sprites_from_file(50, 1<<12, 1);
	close_dat(dathandle);
	if (graphics_mode == gmMcgaVga) {
		// background of text frame
		SDL_Color color;
		if (bgcolor) {
			// RGB(4,0,18h) = #100060 = dark blue
			set_pal((find_first_pal_row(1<<11) << 4) + 14, 0x04, 0x00, 0x18, 1);
			color.r = 0x10;
			color.g = 0x00;
			color.b = 0x60;
			color.a = 0xFF;
		} else {
			// RGB(20h,0,0) = #800000 = dark red
			set_pal((find_first_pal_row(1<<11) << 4) + 14, 0x20, 0x00, 0x00, 1);
			color.r = 0x80;
			color.g = 0x00;
			color.b = 0x00;
			color.a = 0xFF;
		}
		if (NULL != chtab_title40) {
			SDL_SetPaletteColors(chtab_title40->images[0]->format->palette, &color, 14, 1);
		}
	} else if (graphics_mode == gmEga || graphics_mode == gmTga) {
		// ...
	}
}
Exemplo n.º 3
0
// seg000:136A
void __pascal far load_chtab_from_file(int chtab_id,int resource,const char near *filename,int palette_bits) {
	//printf("Loading chtab %d, id %d from %s\n",chtab_id,resource,filename);
	dat_type* dathandle;
	if (chtab_addrs[chtab_id] != NULL) return;
	dathandle = open_dat(filename, 0);
	chtab_addrs[chtab_id] = load_sprites_from_file(resource, palette_bits, 1);
	close_dat(dathandle);
}
Exemplo n.º 4
0
// seg000:0E6C
void __pascal far load_level() {
	dat_type* dathandle;
	dathandle = open_dat("LEVELS.DAT", 0);
	load_from_opendats_to_area(current_level + 2000, &level, sizeof(level), "bin");
	close_dat(dathandle);

	alter_mods_allrm();
	reset_level_unused_fields(true); // added
}
Exemplo n.º 5
0
/*
 * Place the number of neighbours in the area pointered by nbrNum
 * Return an malloced array of neighbors' nodeID
 * On error, return NULL
 */
int *read_Nbr(int *num) {
	//printf("In read_Nbr\n");

	int myId = topology_getMyNodeID();

	FILE *f = open_dat();

	int nbrNum = 0;
	int nbrArr[MAX_NODE_NUM];
	
	char left_node[NODE_NAME_LEN], right_node[NODE_NAME_LEN];
	int cost = 0;
	fscanf(f, "%s%s%d", left_node, right_node, &cost); // first entry
	while (!feof(f)) {
		int left_nodeId = topology_getNodeIDfromname(left_node);
		int right_nodeId = topology_getNodeIDfromname(right_node);

		int nbrId = -1;
		// check whether there's my neighbor
		if (left_nodeId == myId) 
			nbrId = right_nodeId;
		else if (right_nodeId == myId)
			nbrId = left_nodeId;

		// check whether the neighbor appeared
		int i = 0;
		for(i = 0; i < nbrNum; i ++) {
			if (nbrArr[i] == nbrId)
				break;
		}
		if(i >= nbrNum && nbrId != -1) { // a new neighbor
			nbrArr[nbrNum ++] = nbrId;
		}

		fscanf(f, "%s%s%d", left_node, right_node, &cost); // next entry or EOF
	}

	*num = nbrNum;

	// malloc an array to places the neiboId
	int *arr = (int *)malloc(sizeof(int) * nbrNum);
	if (arr == NULL) {
		printf("malloc error!\n");
		return NULL;
	}
	// move the neiboIds
	int i = 0;
	for(i = 0; i < nbrNum; i ++) {
		arr[i] = nbrArr[i];
	}

	fclose(f);

  	return arr;
}
Exemplo n.º 6
0
// seg000:0D20
void __pascal far load_lev_spr(int level) {
	dat_type* dathandle;
	short guardtype;
	char filename[20];
	dathandle = NULL;
	current_level = next_level = level;
	draw_rect(&screen_rect, 0);
	free_optsnd_chtab();
	snprintf(filename, sizeof(filename), "%s%s.DAT",
		tbl_envir_gr[graphics_mode],
		tbl_envir_ki[tbl_level_type[current_level]]
	);
	load_chtab_from_file(id_chtab_6_environment, 200, filename, 1<<5);
	load_more_opt_graf(filename);
	guardtype = tbl_guard_type[current_level];
	if (guardtype != -1) {
		if (guardtype == 0) {
			dathandle = open_dat(tbl_level_type[current_level] ? "GUARD1.DAT" : "GUARD2.DAT", 0);
		}
		load_chtab_from_file(id_chtab_5_guard, 750, tbl_guard_dat[guardtype], 1<<8);
		if (dathandle) {
			close_dat(dathandle);
		}
	}
	curr_guard_color = 0;
	load_chtab_from_file(id_chtab_7_environmentwall, 360, filename, 1<<6);

	// Level colors (1.3)
	if (graphics_mode == gmMcgaVga && level_var_palettes != NULL) {
		int level_color = tbl_level_color[current_level];
		if (level_color != 0) {
			byte* env_pal = level_var_palettes + 0x30*(level_color-1);
			byte* wall_pal = env_pal + 0x30 * tbl_level_type[current_level];
			set_pal_arr(0x50, 0x10, (rgb_type*)env_pal, 1);
			set_pal_arr(0x60, 0x10, (rgb_type*)wall_pal, 1);
			set_chtab_palette(chtab_addrs[id_chtab_6_environment], env_pal, 0x10);
			set_chtab_palette(chtab_addrs[id_chtab_7_environmentwall], wall_pal, 0x10);
		}
	}

	/*if (comp_skeleton[current_level])*/ {
		load_opt_sounds(44, 44); // skel alive
	}
	/*if (comp_mirror[current_level])*/ {
		load_opt_sounds(45, 45); // mirror
	}
	/*if (comp_chomper[current_level])*/ {
		load_opt_sounds(46, 47); // something chopped, chomper
	}
	/*if (comp_spike[current_level])*/ {
		load_opt_sounds(48, 49); // something spiked, spikes
	}
}
Exemplo n.º 7
0
/*
 * Place the number of all nodes in the area pointered by nbrNum
 * Return an malloced array of all nodes' nodeID
 * On error, return NULL
 */
int *read_Nodes(int *num) {
	FILE *f = open_dat();

	int nodesNum = 0;
	int nodeArr[MAX_NODE_NUM];
	
	char left_node[NODE_NAME_LEN], right_node[NODE_NAME_LEN];
	int cost = 0;
	fscanf(f, "%s%s%d", left_node, right_node, &cost); // first entry
	while (!feof(f)) {
		
		int left_nodeId = topology_getNodeIDfromname(left_node);
		int right_nodeId = topology_getNodeIDfromname(right_node);

		// check whether the left node appeared
		int left_appeared  = 0; // false
		int right_appeared = 0; // false
		int i = 0;
		for(i = 0; i < nodesNum; i ++) {
			if (nodeArr[i] == left_nodeId)
				left_appeared = 1; // true
			if (nodeArr[i] == right_nodeId)
				right_appeared = 1; // true
		}
		if (left_appeared == 0) { // a new node
			nodeArr[nodesNum ++] = left_nodeId;
		}
		if (right_appeared == 0) { // a new node
			nodeArr[nodesNum ++] = right_nodeId;
		}

		fscanf(f, "%s%s%d", left_node, right_node, &cost); // next entry
	}

	*num = nodesNum;

	// malloc an array to places the nodeId
	int *arr = (int *)malloc(sizeof(int) * nodesNum);
	if (arr == NULL) {
		printf("malloc error!\n");
		return NULL;
	}
	// move the nodeIds
	int i = 0;
	for(i = 0; i < nodesNum; i ++) {
		arr[i] = nodeArr[i];
	}

	fclose(f);

  	return arr;
}
Exemplo n.º 8
0
// seg000:0000
void far pop_main() {
	// debug only: check that the sequence table deobfuscation did not mess things up
	#ifdef CHECK_SEQTABLE_MATCHES_ORIGINAL
	check_seqtable_matches_original();
	#endif

	load_options();
	apply_seqtbl_patches();

	char sprintf_temp[100];
	int i;

	dathandle = open_dat("PRINCE.DAT", 0);

	/*video_mode =*/ parse_grmode();

	init_timer(60);
	parse_cmdline_sound();

	set_hc_pal();

	current_target_surface = rect_sthg(onscreen_surface_, &screen_rect);
	show_loading();
	set_joy_mode();
	cheats_enabled = check_param("megahit") != NULL;
#ifdef __DEBUG__
	cheats_enabled = 1; // debug
#endif
	draw_mode = check_param("draw") != NULL && cheats_enabled;
	demo_mode = check_param("demo") != NULL;

	init_copyprot_dialog();
#ifdef USE_REPLAY
	init_record_replay();
#endif

	if (cheats_enabled
		#ifdef USE_REPLAY
		|| recording
        #endif
			) {
		for (i = 14; i >= 0; --i) {
			snprintf(sprintf_temp, sizeof(sprintf_temp), "%d", i);
			if (check_param(sprintf_temp)) {
				start_level = i;
				break;
			}
		}
	}

	init_game_main();
}
Exemplo n.º 9
0
// seg000:0B72
void __pascal far load_sounds(int first,int last) {
	dat_type* ibm_dat = NULL;
	dat_type* digi1_dat = NULL;
//	dat_type* digi2_dat = NULL;
	dat_type* digi3_dat = NULL;
	dat_type* midi_dat = NULL;
	short current;
	ibm_dat = open_dat("IBM_SND1.DAT", 0);
	if (sound_flags & sfDigi) {
		digi1_dat = open_dat("DIGISND1.DAT", 0);
//		digi2_dat = open_dat("DIGISND2.DAT", 0);
		digi3_dat = open_dat("DIGISND3.DAT", 0);
	}
	if (sound_flags & sfMidi) {
		midi_dat = open_dat("MIDISND1.DAT", 0);
	}

	#ifdef USE_MIXER
	load_sound_names();
	#endif

	for (current = first; current <= last; ++current) {
		if (sound_pointers[current] != NULL) continue;
		/*if (demo_mode) {
			sound_pointers[current] = decompress_sound((sound_buffer_type*) load_from_opendats_alloc(current + 10000));
		} else*/ {
			//sound_pointers[current] = (sound_buffer_type*) load_from_opendats_alloc(current + 10000, "bin", NULL, NULL);
			//printf("overwriting sound_pointers[%d] = %p\n", current, sound_pointers[current]);


			sound_pointers[current] = load_sound(current);
		}
	}
	if (midi_dat) close_dat(midi_dat);
	if (digi1_dat) close_dat(digi1_dat);
//	if (digi2_dat) close_dat(digi2_dat);
	if (digi3_dat) close_dat(digi3_dat);
	close_dat(ibm_dat);
}
Exemplo n.º 10
0
// seg000:13FC
void __pascal far load_more_opt_graf(const char *filename) {
	// stub
	dat_type* dathandle;
	dat_shpl_type area;
	short graf_index;
	dathandle = NULL;
	for (graf_index = 0; graf_index < 8; ++graf_index) {
		/*if (...) */ {
			if (dathandle == NULL) {
				dathandle = open_dat(filename, 0);
				load_from_opendats_to_area(200, &area, sizeof(area), "pal");
				area.palette.row_bits = 0x20;
			}
			load_one_optgraf(chtab_addrs[id_chtab_6_environment], &area.palette, 1200, optgraf_min[graf_index] - 1, optgraf_max[graf_index] - 1);
		}
	}
	if (dathandle != NULL) {
		close_dat(dathandle);
	}
}
Exemplo n.º 11
0
//这个函数解析保存在文件topology.dat中的拓扑信息.
//返回指定两个节点之间的直接链路代价. 
//如果指定两个节点之间没有直接链路, 返回INFINITE_COST.
unsigned int topology_getCost(int fromNodeID, int toNodeID)
{
	int ret_cost = INFINITE_COST;
	FILE *f = open_dat();

	char left_node[NODE_NAME_LEN], right_node[NODE_NAME_LEN];
	int cost = 0;
	fscanf(f, "%s%s%d", left_node, right_node, &cost); // first entry
	while (!feof(f)) {
		int left_nodeId = topology_getNodeIDfromname(left_node);
		int right_nodeId = topology_getNodeIDfromname(right_node);

		// check 
		if (left_nodeId == fromNodeID && right_nodeId == toNodeID) {
			ret_cost = cost; 
			break;
		}
		fscanf(f, "%s%s%d", left_node, right_node, &cost); // next entry or EOF
	}
	
	fclose(f);
  	return ret_cost;
}