예제 #1
0
void uae4all_flush_disk(int n)
{
	if ((uae4all_disk_writed[n])&&(mainMenu_autosave))
	{
		if (maple_first_vmu())
		{
			if (uae4all_disk_writed_now[n]>6)
			{
				uae4all_disk_real_write(n);
				uae4all_disk_writed[n]=0;
				uae4all_disk_writed_now[n]=0;
			}
			else
				uae4all_disk_writed_now[n]++;
		}
	}
}
예제 #2
0
int loadgame_simple ()
{
	char home[MAX_PATH], path[MAX_PATH];
	int rc = 0;
        printf("here?\n");

#ifdef DREAMCAST
	uint8 addr, port, unit;

	addr = maple_first_vmu();
	if (addr) {
		maple_create_port (addr, &port, &unit);
		sprintf (g_vmu_port, "%c%d", port + 'a', unit);
	} else {
		message_box("No VMU found.");
		return err_OK;
	}

	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
#else	
	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Error loading game.");
		return err_BadFileOpen;
	}

	sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, 0);
#endif

	erase_both();
	stop_sound();
	close_window();

	if ((rc = load_game (path)) == err_OK) {
		message_box ("Game restored.");
		game.exit_all_logics = 1;
		menu_enable_all();
	} else {
		message_box ("Error restoring game.");
	}

	return rc;
}
예제 #3
0
static void uae4all_initsave(unsigned num)
{
#ifndef DREAMCAST
	if (!uae4all_disk_orig[num])
		uae4all_disk_orig[num]=malloc(MAX_DISK_LEN);
#else
	uae4all_disk_orig[num]=(void *)(DC_VRAM+(MAX_DISK_LEN*(num+4)));
#endif
	memcpy(uae4all_disk_orig[num],uae4all_disk_memory[num],MAX_DISK_LEN);
	uae4all_disk_crc[num]=savedisk_get_checksum(uae4all_disk_orig[num],MAX_DISK_LEN);
	if ((!mainMenu_autosave)||(!maple_first_vmu()))
		return;
	FILE *f=fopen(get_namefile(num),"rb");
	if (f)
	{
		void *bc=calloc(1,MAX_COMP_SIZE);
		unsigned long n;
		set_vmu_pad(f);
		fread((void *)&n,1,4,f);
		if (fread(bc,1,n,f)>=n)
		{
			unsigned long sizeuncompressed=MAX_DISK_LEN;
			int retc=uncompress((Bytef *)uae4all_extra_buffer,&sizeuncompressed,(const Bytef *)bc,n);
			if (retc>=0)
			{
				savedisk_apply_changes(uae4all_disk_memory[num],uae4all_extra_buffer,sizeuncompressed);
			}
			else
			{
				fclose(f);
				f=NULL;
				eliminate_file(get_namefile(num));
			}
		}
		free(bc);
		if (f)
			fclose(f);
	}
	uae4all_disk_actual_crc[num]=savedisk_get_checksum(uae4all_disk_memory[num],MAX_DISK_LEN);
}
예제 #4
0
static unsigned getFreeBlocks(void)
{
#ifdef DREAMCAST
	unsigned short buf16[255];
	int free_blocks=0,i=0;
	maple_device_t *dev;
	unsigned char addr=0;
	int p,u;
	uint8 v=maple_first_vmu();
	if (v)
	{
		if (maple_compat_resolve(v,&dev,MAPLE_FUNC_MEMCARD)!=0)
			return 0;
	}
	else
		return 0;

	return vmufs_free_blocks(dev);
#else
	return 0x10000;
#endif
}
예제 #5
0
int savegame_simple ()
{
	char home[MAX_PATH], path[MAX_PATH];

#ifdef DREAMCAST
	uint8 addr, port, unit;

	addr = maple_first_vmu();
	if(addr) {
		maple_create_port(addr, &port, &unit);
		sprintf(g_vmu_port, "%c%d", port + 'a', unit);
	} else {
		message_box("No VMU found.");
		return err_OK;
	}

	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
	fs_unlink(path);
#else
	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Couldn't save game.");
		return err_BadFileOpen;
	}

	sprintf (path, "%s/" DATA_DIR "/", home);
	MKDIR (path, 0755);
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
	MKDIR (path, 0711);
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, 0);
#endif
        printf("here?\n");
	save_game (path, "Default savegame");

	return err_OK;
}
예제 #6
0
int loadgame_dialog ()
{
#ifndef PALMOS
	char home[MAX_PATH], path[MAX_PATH];
	int rc, slot = 0;
	int hm, vm, hp, vp;			/* box margins */
	int w;

	hm = 2; vm = 3;
	hp = hm * CHAR_COLS; vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

#ifdef DREAMCAST
	uint8 addr, port, unit;

	addr = maple_first_vmu();
	if (addr) {
		maple_create_port (addr, &port, &unit);
		sprintf (g_vmu_port, "%c%d", port + 'a', unit);
	} else {
		message_box("No VMU found.");
		return err_OK;
	}
#else
	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Error loading game.");
		return err_BadFileOpen;
	}

# ifdef CIBYL
	sprintf (path, "recordstore://%05X.%s:",
                 game.crc, game.id);
# else
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
# endif
#endif

	erase_both();
	stop_sound();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a game which you wish to\nrestore:",
		0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	print_text ("Press ENTER to select, ESC cancels",
		0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	slot = select_slot (path);

	if (slot < 0) {
		message_box ("Game NOT restored.");
		return err_OK;
	}

#ifdef DREAMCAST
	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
#elif CIBYL
	sprintf (path, "recordstore://%05X.%s:%d",
		game.crc, game.id, slot+1);
        printf("path: %s\n", path);
#else	
	sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);
#endif

	if ((rc = load_game (path)) == err_OK) {
		message_box ("Game restored.");
		game.exit_all_logics = 1;
		menu_enable_all();
	} else {
		message_box ("Error restoring game.");
	}

	return rc;
#endif /* PALMOS */
}
예제 #7
0
int savegame_dialog ()
{
#ifndef PALMOS /* FIXME */
	char home[MAX_PATH], path[MAX_PATH];
	char *desc;
	char *buttons[] = { "Do as I say!", "I regret", NULL }; 
	char dstr[200];
	int rc, slot = 0;
	int hm, vm, hp, vp;			/* box margins */
	int w;

	hm = 2; vm = 3;
	hp = hm * CHAR_COLS; vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

#ifdef DREAMCAST
	uint8 addr, port, unit;

	addr = maple_first_vmu();
	if(addr) {
		maple_create_port(addr, &port, &unit);
		sprintf(g_vmu_port, "%c%d", port + 'a', unit);
	} else {
		message_box("No VMU found.");
		return err_OK;
	}
#else
	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Couldn't save game.");
		return err_BadFileOpen;
	}
# ifdef CIBYL
	sprintf (path, "recordstore://%05X.%s:",
		game.crc, game.id);
# else
	/* DATADIR conflicts with ObjIdl.h in win32 SDK, renamed to DATA_DIR */
	sprintf (path, "%s/" DATA_DIR "/", home);
	MKDIR (path, 0755);
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
	MKDIR (path, 0711);
# endif
#endif

	erase_both ();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a slot in which you wish to save the game:",
		0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	print_text ("Press ENTER to select, ESC cancels",
		0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	slot = select_slot (path);
	if (slot < 0)	/* ESC pressed */
		return err_OK;

	/* Get savegame description */
	draw_window (hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
		GFX_HEIGHT - vp - 9 * CHAR_LINES);
	print_text ("Enter a description for this game:",
		0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	draw_rectangle (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
	flush_block (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES);

	get_string (2, 11, 33, MAX_STRINGS);
	print_character (3, 11, game.cursor_char, MSG_BOX_COLOUR, MSG_BOX_TEXT);
        do { main_cycle (); } while (game.input_mode == INPUT_GETSTRING);
	close_window ();

 	desc = game.strings[MAX_STRINGS];

	sprintf (dstr, "Are you sure you want to save the game "
		"described as:\n\n%s\n\nin slot %d?\n\n\n",
		desc, slot);

	rc = selection_box (dstr, buttons);

	if (rc != 0) {
		message_box ("Game NOT saved.");
		return err_OK;
	}

#ifdef DREAMCAST
	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
	fs_unlink(path);
#elif CIBYL
	sprintf (path, "recordstore://%05X.%s:%d",
		game.crc, game.id, slot+1);
        printf("path: %s\n", path);
#else
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);
#endif
	_D (_D_WARN "file is [%s]", path);
	
	save_game (path, desc);

	message_box ("Game saved.");
#endif /* PALMOS */

	return err_OK;
}