PROGRAMMER'S GUIDEBackup Library User's Manual
Back | ■
Backup Library User's Manual / Reference

Detailed specifications


■ Data specifications

 List
 Title

Data specifications

 Data

Storage device connection information

 Data Name

BupConfig

 No

1

typedef struct BupConfig {
  Uint16 unit_id; / * Unit ID * /
  Uint16 partition; / * Number of partitions * /
} BupConfig;

* If unit_id is 0, it means that there is no connection.

 Device type
 unit_id
 partition
 Built-in memory
 1
 1
 External cartridge
 2
 1 


 List
 Title

Data specifications

 Data

Status information

 Data Name

BupStat

 No

2

typedef struct BupStat {
  Uint32 totalsize; / * Total capacity () * /
  Uint32 totalblock; / * number of blocks * /
  Uint32 blocksize; / * 1 block size () * /
  Uint32 freesize; / * Free space * /
  Uint32 freeblock; / * Number of free blocks * /
  Uint32 datanum; / * Number of writable items * /
} BupStat;

In datanum, the value for the size for which datasize is specified by BUP_Stat () is stored.


 List
 Title

Data specifications

 Data

Date time

 Data Name

BupDate

 No

3

typedef struct BupDate {
  Uint8 year; / * year (1980 minus the year) * /
  Uint8 month; / * Month (1-12) * /
  Uint8 day; / * days (1-31) * /
  Uint8 time; / * hours (0-23) * /
  Uint8 min; / * minutes (0-59) * /
  Uint8 week; / * Sunday (Sunday 0-Sat 6) * /
} BupDate;

 List
 Title

Data specifications

 Data

Directory information

 Data Name

BupDir

 No

Four

typedef struct BupDir {
  Uint8 filename [12]; / * filename * /
                        / * (11 ASCII characters + 12 bytes in total of NUL) * /
  Uint8 comment [11]; / * Comment * /
                        / * (10 ASCII characters + 11 bytes in total) * /
  Uint8 language; / * Comment language type * /
                        / * Japanese: BUP_JAPANESE * /
                        / * English: BUP_ENGLISH * /
                        / * French: BUP_FRANCAIS * /
                        / * German: BUP_DEUTSCH * /
                        / * Spanish: BUP_ESPANOL * /
                        / * Italian: BUP_ITALIANO * /
  Uint32 date; / * Date time data * /
  Uint32 datasize; / * Data size (unit: bytes) * /
  Uint16 blocksize; / * Data size (unit: block) * /
} BupDir;

■ Function specifications


 List
 Title

Function specifications

 Func

Backup library initialization

 Function

BUP_Init

 No

1

Form
void BUP_Init (Uint32 * libaddr, Uint32 * workbuff, BupConfig conf [3])
input
libaddr: Specify the address to load the library The size of the library is 16K bytes.
workbuff: Library work area pointer The size of the work area must be 8192 bytes. Be sure to secure it with Uint32 as it may be accessed for a long word.
output
conf: Get information about the connected storage device.
function
Reads the backup library onto the specified memory area and performs preprocessing for use. Information on the connected storage device can be obtained. Each of the three tables corresponds to the following device numbers.

 Device number
 Device type
 0
 Built-in memory cartridge
 1
 Memory cartridge or parallel interface
 2
 Serial interface

remarks
Be sure to prepare three storage device connection information tables.
example
#define BUP_START_ADDR 0x6 ??????
#include "sega_bup.h"
Uint32 workmemory [2048 + 30];

  void sample ()
  {
    BupConfig conf [3];

    BUP_Init (BUP_START_ADDR, workmemory, conf);
    ...............
  }

 List
 Title

Function specifications

 Func

Partition selection

 Function

BUP_SelPart

 No

2

Form
Sint32 BUP_SelPart (Uint32 device, Uint16 num)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
num: partition number
0- (number of partitions-1)
output
none
Function value
0: Success
Other: Failure
function
Select the partition. In the initial state, partition 0 is selected.

 List
 Title

Function specifications

 Func

Formatting

 Function

BUP_Format

 No

3

Form
Sint32 BUP_Format (Uint32 device)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
output
none
Function value
0: Success
BUP_WRITE_PROTECT: With write protection
Other: Failure
function
Initializes the backup storage device.
For partitioned backup storage, format only for the current partition.

 List
 Title

Function specifications

 Func

Get status

 Function

BUP_Stat

 No

Four

Form
Sint32 BUP_Stat (Uint32 device, Uint32 datasize, BupStat * stat)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
datasize: Specify the size of the data you want to write in units
output
stat: status information
Function value
Returns the state of the device
0: Success
BUP_NON: Not connected
BUP_UNFORMAT: unformatted
function
Get status information.

 List
 Title

Function specifications

 Func

Writing data

 Function

BUP_Write

 No

Five

Form
Sint32 BUP_Write (Uint32 device, BupDir * dir, Uint8 * data, Uint8 owsw)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
dir: File management information (input other than dir.blocksize)
data: Pointer of write data owsw: Overwrite check mode ON: Do not write if a file with the same name exists.
OFF: If a file with the same name exists, it will be overwritten.
output
none
Function value
 Function value
 meaning
 0
 success
 BUP_NON
 disconnected
 BUP_UNFORMAT
 Unformatted
 BUP_WRITE_PROTECT
 With write protection
 BUP_FOUND
 A file with the same name exists.
 other
 Failure
function
Write data to backup storage

 List
 Title

Function specifications

 Func

Read data

 Function

BUP_Read

 No

6

Form
Sint32 BUP_Read (Uint32 device, Uint8 * fname, Uint8 * data)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
fname: Specify the file name (11 characters are required for ASCII)
output
data: Pointer to the read buffer
Function value
 Function value
 meaning
 0
 success
 BUP_NON
 disconnected
 BUP_UNFORMAT
 Unformatted
 BUP_NOT_FOUND
 File not found
 BUP_BROKEN
 The file is broken
 other
 Failure
function
Read data from backup storage.

 List
 Title

Function specifications

 Func

Delete data

 Function

BUP_Delete

 No

7

Form
Sint32 BUP_Delete (Uint32 device, Uint8 * fname)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
fname: File name (must be ASCII with 11 characters)
output
none
Function value
 Function value
 meaning
 0
 success
 BUP_NON
 disconnected
 BUP_UNFORMAT
 Unformatted
 BUP_NOT_FOUND
 File not found
 BUP_WRITE_PROTECT
 With write protection
 other
 Failure
function
Delete the data on the backup storage device.

 List
 Title

Function specifications

 Func

Get directory information

 Function

BUP_Dir

 No

8

Form
Sint32 BUP_Dir (Uint32 device, Uint8 * fname, Uint16 dirsize, BupDir * dir)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
fname: Specify the file name (up to 11 characters in ASCII)
dirsize: Specify the number of reserved directory information
output
dir: Directory information is stored
Function value
The number of hits in the directory information.
function
Search the file name by prefix match and store the directory information in the table.
The number of directory information hit by the search is returned as a function value.
If it is negative, it means that the table size is insufficient, and the number of cases can be confirmed by reversing the sign.
(If tbsize is set to 10 and the search result is 11, -11 is returned)

 List
 Title

Function specifications

 Func

Data collation

 Function

BUP_Verify

 No

9

Form
Sint32 BUP_Verify (Uint32 device, Uint8 * filename, Uint8 * data)
input
device: device number
 Device number
Storage device
 0
 Built-in memory
 1
 Memory cartridge or parallel interface
 2
 Serial interface
filename: File name (must be ASCII 11 characters)
data: Pointer for collation data
output
none
Function value
 Function value
 meaning
 0
 success
 BUP_NON
 disconnected
 BUP_UNFORMAT
 Unformatted
 BUP_NO_MATCH
 Data do not match
 BUP_NOT_FOUND
 File not found
 BUP_BROKEN
 The file is broken
function
Collate the data written to the backup file.

 List
 Title

Function specifications

 Func

Expansion of date and time data

 Function

BUP_GetDate

 No

Ten

Form
void BUP_GetDate (Uint32 pdate, BupDate * date)
input
pdate: Date time data of directory information
date: date time table
output
none
Function value
none
function
Expand the date / time data in the directory information table.

 List
 Title

Function specifications

 Func

Date-time data compression

 Function

BUP_SetDate

 No

11

Form
Uint32 BUP_SetDate (BupDate * date)
input
date: date time
output
none
Function value
Data in date-time data format in the directory information table
function
Compress the date / time data in the directory information table.

Back | ■
PROGRAMMER'S GUIDEBackup Library User's Manual
Copyright SEGA ENTERPRISES, LTD., 1997