-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbup_header.h
142 lines (119 loc) · 3.67 KB
/
bup_header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* bup_header.h - structure definition for the .BUP file header used
* by various Sega Saturn tools.
*
* Format developed by Cafe-Alpha (https://segaxtreme.net/threads/save-game-metadata-questions.24625/post-178534)
*
* Date conversion functions taken from Cafe-Alpha's Pseudo Saturn Kai
*
*/
#pragma once
/** .BUP extension is required to work wih PS Kai */
#define BUP_EXTENSION ".BUP"
/** The BUP header structure (sizeof(vmem_bup_header_t)) is exactly 64 bytes */
#define BUP_HEADER_SIZE 64
/** BUP header magic */
#define VMEM_MAGIC_STRING_LEN 4
#define VMEM_MAGIC_STRING "Vmem"
/** Max backup filename length */
#define JO_BACKUP_MAX_FILENAME_LENGTH (12)
/** Max backup file comment length */
#define JO_BACKUP_MAX_COMMENT_LENGTH (10)
/*
* Language of backup save in jo_backup_file
* taken from Jo Engine backup.c
*/
enum jo_backup_language
{
backup_japanese = 0,
backup_english = 1,
backup_french = 2,
backup_deutsch = 3,
backup_espanol = 4,
backup_italiano = 5,
};
/**
* Backup file metadata information. Taken from Jo Engine.
**/
typedef struct _jo_backup_file
{
unsigned char filename[JO_BACKUP_MAX_FILENAME_LENGTH];
unsigned char comment[JO_BACKUP_MAX_COMMENT_LENGTH + 1];
unsigned char language; // jo_backup_language
unsigned int date;
unsigned int datasize;
unsigned short blocksize;
unsigned short padding;
} jo_backup_file;
typedef struct _jo_backup_date {
unsigned char year; // year - 1980
unsigned char month;
unsigned char day;
unsigned char time;
unsigned char min;
unsigned char week;
} jo_backup_date;
#if defined( __GNUC__ )
#pragma pack(1)
#else
#pragma pack(push,1)
#endif
/**
* Vmem usage statistics structure.
* Statistics are reset on each vmem session, ie when Saturn is reset,
* or when game calls BUP_Init function.
**/
typedef struct _vmem_bup_stats_t
{
/* Number of times BUP_Dir function is called. */
unsigned char dir_cnt;
/* Number of times BUP_Read function is called. */
unsigned char read_cnt;
/* Number of times BUP_Write function is called. */
unsigned char write_cnt;
/* Number of times BUP_Verify function is called. */
unsigned char verify_cnt;
} vmem_bup_stats_t;
/**
* Backup data header. Multibyte values are stored as big-endian.
**/
typedef struct _vmem_bup_header_t
{
/* Magic string.
* Used in order to verify that file is in vmem format.
*/
char magic[VMEM_MAGIC_STRING_LEN];
/* Save ID.
* "Unique" ID for each save data file, the higher, the most recent.
*/
unsigned int save_id;
/* Vmem usage statistics. */
vmem_bup_stats_t stats;
/* Unused, kept for future use. */
char unused1[8 - sizeof(vmem_bup_stats_t)];
/* Backup Data Informations Record (34 bytes + 2 padding bytes). */
jo_backup_file dir;
/* Date stamp, in Saturn's BUP library format.
* Used in order to verify which save data is the most
* recent one when rebuilding index data.
* Note #1 : this information is already present in BupDir structure,
* but games are setting it, so it may be incorrect (typically, set
* to zero).
* Note #2 : this date information is the date when Pseudo Saturn Kai
* last started, not the time the save was saved, so if information in
* dir structure is available, it is more accurate.
*/
unsigned int date;
/* Unused, kept for future use. */
char unused2[8];
} vmem_bup_header_t, BUP_HEADER, *PBUP_HEADER;
#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif
//
// Functions for converting dates
//
void bup_getdate(unsigned int date, jo_backup_date *tb);
unsigned int bup_setdate(jo_backup_date *tb);