KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
vmu_pkg.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/vmu_pkg.h
4 Copyright (C) 2002 Megan Potter
5
6*/
7
8/** \file dc/vmu_pkg.h
9 \brief VMU Packaging functionality.
10 \ingroup vmu_package
11
12 This file provides declarations for managing the headers that must be
13 attached to VMU files for the BIOS to pay attention to them. This does not
14 handle reading/writing files directly.
15
16 \author Megan Potter
17 \see dc/fs_vmu.h
18*/
19
20#ifndef __DC_VMU_PKG_H
21#define __DC_VMU_PKG_H
22
23#include <sys/cdefs.h>
24__BEGIN_DECLS
25
26#include <stdint.h>
27
28/** \defgroup vmu_package Header Package
29 \brief API for Managing VMU File Headers
30 \ingroup vmu
31
32 This API is provided as a utility for easy management of VMS file headers.
33 These headers must be present on every file saved within the VMU's
34 filesystem for both the Dreamcast and VMU's BIOS to detect them properly.
35*/
36
37/** \brief VMU Package type.
38 \ingroup vmu_package
39
40 Anyone wanting to package a VMU file should create one of these somewhere;
41 eventually it will be turned into a flat file that you can save using
42 fs_vmu.
43
44 \headerfile dc/vmu_pkg.h
45*/
46typedef struct vmu_pkg {
47 char desc_short[20]; /**< \brief Short file description */
48 char desc_long[36]; /**< \brief Long file description */
49 char app_id[20]; /**< \brief Application ID */
50 int icon_cnt; /**< \brief Number of icons */
51 int icon_anim_speed; /**< \brief Icon animation speed */
52 int eyecatch_type; /**< \brief "Eyecatch" type */
53 int data_len; /**< \brief Number of data (payload) bytes */
54 uint16_t icon_pal[16]; /**< \brief Icon palette (ARGB4444) */
55 uint8_t *icon_data; /**< \brief 512*n bytes of icon data */
56 const uint8_t *eyecatch_data; /**< \brief Eyecatch data */
57 const uint8_t *data; /**< \brief Payload data */
58} vmu_pkg_t;
59
60/** \brief Final VMU package type.
61 \ingroup vmu_package
62
63 This structure will be written into the file itself, not vmu_pkg_t.
64
65 \headerfile dc/vmu_pkg.h
66*/
67typedef struct vmu_hdr {
68 char desc_short[16]; /**< \brief Space-padded short description */
69 char desc_long[32]; /**< \brief Space-padded long description*/
70 char app_id[16]; /**< \brief Null-padded application ID */
71 uint16_t icon_cnt; /**< \brief Number of icons */
72 uint16_t icon_anim_speed; /**< \brief Icon animation speed */
73 uint16_t eyecatch_type; /**< \brief Eyecatch type */
74 uint16_t crc; /**< \brief CRC of the file */
75 uint32_t data_len; /**< \brief Payload size */
76 uint8_t reserved[20]; /**< \brief Reserved (all zero) */
77 uint16_t icon_pal[16]; /**< \brief Icon palette (ARGB4444) */
78 /* 512*n Icon Bitmaps */
79 /* Eyecatch palette + bitmap */
80} vmu_hdr_t;
81
82/** \defgroup vmu_ectype Eyecatch Types
83 \brief Values for various VMU eyecatch formats
84 \ingroup vmu_package
85
86 All eyecatches are 72x56, but the pixel format is variable. Note that in all
87 of the cases which use a palette, the palette entries are in ARGB4444 format
88 and come directly before the pixel data itself.
89
90 @{
91*/
92#define VMUPKG_EC_NONE 0 /**< \brief No eyecatch */
93#define VMUPKG_EC_16BIT 1 /**< \brief 16-bit ARGB4444 */
94#define VMUPKG_EC_256COL 2 /**< \brief 256-color palette */
95#define VMUPKG_EC_16COL 3 /**< \brief 16-color palette */
96/** @} */
97
98/** \brief Convert a vmu_pkg_t into an array of uint8s.
99 \ingroup vmu_package
100
101 This function converts a vmu_pkg_t structure into an array of uint8's which
102 may be written to a VMU file via fs_vmu, or whatever.
103
104 \param src The vmu_pkg_t to convert.
105 \param dst The buffer (will be allocated for you).
106 \param dst_size The size of the output.
107 \return 0 on success, <0 on failure.
108*/
109int vmu_pkg_build(vmu_pkg_t *src, uint8_t ** dst, int * dst_size);
110
111/** \brief Parse an array of uint8s into a vmu_pkg_t.
112 \ingroup vmu_package
113
114 This function does the opposite of vmu_pkg_build and is used to parse VMU
115 files read in.
116
117 \param data The buffer to parse.
118 \param pkg Where to store the vmu_pkg_t.
119 \retval -1 On invalid CRC in the data.
120 \retval 0 On success.
121*/
122int vmu_pkg_parse(uint8_t *data, vmu_pkg_t *pkg);
123
124/** \brief Load a .ico file to use as a VMU file's icon.
125 \ingroup vmu_package
126
127 Icon files must be in the ICO file format, be 32x32 in size, contain a
128 bitmap (no PNG or compressed BMP), and use paletted 4bpp.
129 They can contain more than one frame, and they can use up to 16 colors
130 if transparency is not used, or 15 colors otherwise. Finally, all frames
131 must use the same palette.
132
133 This function assumes that the vmu_pkg_t has been properly initialized;
134 in particular, the .icon_cnt must be set, and the .icon_data must point to
135 a valid buffer (of 512 bytes per frame).
136
137 If the .ico file contains more frames than requested, only the first ones
138 are loaded. If it contains less frames than requested, the .icon_cnt field
139 will be updated to the new frame count.
140
141 \param pkg A pointer a pre-initialized vmu_pkg_t
142 \param icon_fn The file path to the .ico file
143 \retval -1 If the .ico file cannot be loaded.
144 \retval 0 On success.
145*/
146int vmu_pkg_load_icon(vmu_pkg_t *pkg, const char *icon_fn);
147
148__END_DECLS
149
150#endif /* __DC_VMU_PKG_H */
int vmu_pkg_load_icon(vmu_pkg_t *pkg, const char *icon_fn)
Load a .ico file to use as a VMU file's icon.
int vmu_pkg_build(vmu_pkg_t *src, uint8_t **dst, int *dst_size)
Convert a vmu_pkg_t into an array of uint8s.
int vmu_pkg_parse(uint8_t *data, vmu_pkg_t *pkg)
Parse an array of uint8s into a vmu_pkg_t.
Final VMU package type.
Definition vmu_pkg.h:67
uint16_t icon_anim_speed
Icon animation speed.
Definition vmu_pkg.h:72
uint32_t data_len
Payload size.
Definition vmu_pkg.h:75
uint16_t icon_cnt
Number of icons.
Definition vmu_pkg.h:71
uint16_t eyecatch_type
Eyecatch type.
Definition vmu_pkg.h:73
uint16_t crc
CRC of the file.
Definition vmu_pkg.h:74
VMU Package type.
Definition vmu_pkg.h:46
int eyecatch_type
"Eyecatch" type
Definition vmu_pkg.h:52
int icon_cnt
Number of icons.
Definition vmu_pkg.h:50
uint8_t * icon_data
512*n bytes of icon data
Definition vmu_pkg.h:55
const uint8_t * data
Payload data.
Definition vmu_pkg.h:57
int data_len
Number of data (payload) bytes.
Definition vmu_pkg.h:53
int icon_anim_speed
Icon animation speed.
Definition vmu_pkg.h:51
const uint8_t * eyecatch_data
Eyecatch data.
Definition vmu_pkg.h:56