Exemple #1
0
static int extract_do(void)
{
FILE *fp;

	clear();
	moveto(SM_UPPER_THIRD);
	print("= Extracting Files =");
	
	fp = fileopen(filename, "rb");
	if (!fp)
	{
		moveto(SM_CENTER);
		print("cannot find executable %s", filename);
		print("");
		print("");
		print("Please put it and it's \"data\" directory");
		print("into the same folder as this program.");
		run_until_key();
		return 1;
	}
	
	if (extract_pxt(fp)) return 1;
	if (extract_files(fp)) return 1;
	if (extract_stages(fp)) return 1;
	//findfiles(fp);
	//exit(1);
	
	clearstatus();
	fclose(fp);
	return 0;
}
Exemple #2
0
int conclusion()
{
	moveto(SM_MIDUPPER_Y);
	print("Success!");
	print("");
	print("You can now remove the Doukutsu.exe file");
	print("if you like, as it isn't needed anymore.");
	print("Please leave the \"data\" directory though.");
	print("");
	print("Once you get to the title screen, you may want");
	print("to adjust your resolution by pressing F3.");
	print("");
	print("Press any key to begin");
	
	return run_until_key();
}
Exemple #3
0
int introduction()
{
	clear();
	moveto(SM_UPPER_THIRD);
	
	print("I need to extract some game data");
	print("before I can start up for the first time.");
	print("");
	print("Before beginning, you should have the Aeon Genesis");
	print("English translation of version 1.0.0.6, and drop");
	print("Doukutsu.exe and it's \"data\" directory into the same");
	print("folder as the \"nx\" program you just ran.");
	print("");
	#ifdef __SDLSHIM__
	print("If you haven't done that yet, please press BTN1 now");
	#else
	print("If you haven't done that yet, please press ESCAPE now");
	#endif
	print("and come back in a moment. Otherwise, you can");
	print("press any other key to start the extraction.");
	
	return run_until_key();
}
bool extract_files(FILE *exefp)
{
uint8_t *buffer;
uint8_t *file;
uint32_t length;
uint32_t crc;
bool check_crc = true;
bool first_crc_failure = true;

	buffer = (uint8_t *)malloc(MAX_FILE_SIZE);
	crc_init();
	
	for(int i=0;;i++)
	{
		const char *outfilename = files[i].filename;
		if (!outfilename) break;
		
		status("[ %s ]", outfilename);
		
		// initialize header if any
		file = buffer;
		length = files[i].length;
		
		if (files[i].header)
		{
			memcpy(buffer, files[i].header, HEADER_LEN);
			file += HEADER_LEN;
			length += HEADER_LEN;
		}
		
		// read data from exe
		fseek(exefp, files[i].offset, SEEK_SET);
		fread(file, files[i].length, 1, exefp);
		
		if (check_crc)
		{
			crc = crc_calc(file, files[i].length);
			if (crc != files[i].crc)
			{
				status("File '%s' failed CRC check.", outfilename);
				print("");
				
				#ifndef __SDLSHIM__
					print("[I]gnore");
					print("Ignore [A]ll");
					print("[S]top");
					#define IGNORE_BTN		SDLK_i
					#define IGNORE_ALL_BTN	SDLK_a
					#define STOP_BTN		SDLK_s
				#else
					print("B1 - Ignore");
					print("B2 - Ignore All");
					print("B3 - Stop");
					#define IGNORE_BTN		SDLK_BTN1
					#define IGNORE_ALL_BTN	SDLK_BTN2
					#define STOP_BTN		SDLK_BTN3
				#endif
				
				for(;;)
				{
					switch(run_until_key(first_crc_failure))
					{
						case IGNORE_BTN:
						break;
						
						case IGNORE_ALL_BTN:
							check_crc = false;
						break;
						
						#ifndef __SDLSHIM__
						case SDLK_ESCAPE:
						#endif
						case STOP_BTN:
						{
							free(buffer);
							return 1;
						}
						
						default:
						continue;
					}
					
					break;
				}
				
				first_crc_failure = false;
			}
		}
		
		// write out the file
		createdir(outfilename);
		
		FILE *fp = fileopen(outfilename, "wb");
		if (!fp)
		{
			status("Failed to open '%s' for writing.", outfilename);
			free(buffer);
			return 1;
		}
		
		fwrite(buffer, length, 1, fp);
		fclose(fp);
	}
	
	free(buffer);
	return 0;
}