Shinobi Library - Memory Card Function

buCalcBackupFileSize

Calculates file size

FORMAT

Sint32 buCalcBackupFileSize( inum, vtype, size )
Uint32 inum
Uint32 vtype
Uint32 size

PARAMETER

 inum  Number of icons 
 vtype  Visual type 
 size  Number of bytes of data to be saved for applications 

RETURN

 Positive value  Number of blocks used in the memory card file 
 BUD_ERR_INVALID_PARAM  Invalid parameter   

DESCRIPTION

Calculates the size of a memory card file format image.

EXAMPLE

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

buCalcBackupFileSize
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999