Shinobi Library - ペリフェラル・記録デバイス関数

buMakeBackupFileImage

ファイルイメージの取得

書式

Sint32 buMakeBackupFileImage( buf, hdr )
void *buf
const BUS_BACKUPFILEHEADER *hdr

引数

buf   メモリーカードファイル形式イメージ作成アドレス(4バイト境界)
hdr   メモリーカードファイルヘッダアドレス

戻り値

正   メモリーカードファイルの使用ブロック数
BUD_ERR_INVALID_PARAM   ヘッダ不正

解説

メモリ上にメモリーカードファイル形式イメージを作成します。

用例

/* Game name (sort item) */
extern Uint8 game_name[];
/* Icon palette data */
extern Uint16 icon_palette[];
/* Icon pixel data */
extern Uint8 icon_data[];
/* Visual data */
extern Uint8 visual_data[];
/* Application save data */
extern Uint8 save_data[];
Sint32 nblock1, nblock2;
void* buf;
/* Memory card file header */
BUS_BACKUPFILEHEADER hdr;
memset(&hdr, 0, sizeof(hdr));
/* VM comment setting */
strcpy(hdr.vms_comment, "VMS_COMMENT");
/* BOOT ROM comment setting */
strcpy(hdr.btr_comment, "BOOT ROM full-character comment");
/* Game name (sort item) setting */
memcpy(hdr.game_name,   game_name, 16);
/* Icon palette data setting */
hdr.icon_palette = icon_palette;
/* Icon pixel data setting */
hdr.icon_data    = icon_data;
/* Number of icons setting */
hdr.icon_num     = 1;
/* Icon speed setting */
hdr.icon_speed   = 1;
/* Visual comment setting */
hdr.visual_data  = visual_data;
/* Visual type setting */
hdr.visual_type  = BUD_VISUALTYPE_C;
/* Application save data */
hdr.save_data    = save_data;
/* Application save data size */
hdr.save_size    = 0x400;
nblock = buCalcBackupFileSize(hdr.icon_num,
	hdr.visual_type, hdr.save_size);
/* Allocates (the number of blocks to be used x 512 bytes) */
buf = syMalloc(nblock * 512);
if (buf == NULL) {
	/* Memory cannot be allocated */
	return NG;
}
nblock = buMakeBackupFileImage(buf, &hdr);
if (nblock < 0) {
	/* Structure includes an invalid parameter */
	return NG;
}

buMakeBackupFileImage
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998-2000