KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
vmu_pkg.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  dc/vmu_pkg.h
4  Copyright (C) 2002 Dan Potter
5 
6 */
7 
8 /** \file dc/vmu_pkg.h
9  \brief VMU Packaging functionality.
10 
11  This file provides declarations for managing the headers that must be
12  attached to VMU files for the BIOS to pay attention to them. This does not
13  handle reading/writing files directly.
14 
15  \author Dan Potter
16  \see dc/fs_vmu.h
17 */
18 
19 #ifndef __DC_VMU_PKG_H
20 #define __DC_VMU_PKG_H
21 
22 #include <sys/cdefs.h>
23 __BEGIN_DECLS
24 
25 #include <arch/types.h>
26 
27 /** \brief VMU Package type.
28 
29  Anyone wanting to package a VMU file should create one of these somewhere;
30  eventually it will be turned into a flat file that you can save using
31  fs_vmu.
32 
33  \headerfile dc/vmu_pkg.h
34 */
35 typedef struct vmu_pkg {
36  char desc_short[20]; /**< \brief Short file description */
37  char desc_long[36]; /**< \brief Long file description */
38  char app_id[20]; /**< \brief Application ID */
39  int icon_cnt; /**< \brief Number of icons */
40  int icon_anim_speed; /**< \brief Icon animation speed */
41  int eyecatch_type; /**< \brief "Eyecatch" type */
42  int data_len; /**< \brief Number of data (payload) bytes */
43  uint16 icon_pal[16]; /**< \brief Icon palette (ARGB4444) */
44  const uint8 *icon_data; /**< \brief 512*n bytes of icon data */
45  const uint8 *eyecatch_data; /**< \brief Eyecatch data */
46  const uint8 *data; /**< \brief Payload data */
47 } vmu_pkg_t;
48 
49 /** \brief Final VMU package type.
50 
51  This structure will be written into the file itself, not vmu_pkg_t.
52 
53  \headerfile dc/vmu_pkg.h
54 */
55 typedef struct vmu_hdr {
56  char desc_short[16]; /**< \brief Space-padded short description */
57  char desc_long[32]; /**< \brief Space-padded long description*/
58  char app_id[16]; /**< \brief Null-padded application ID */
59  uint16 icon_cnt; /**< \brief Number of icons */
60  uint16 icon_anim_speed; /**< \brief Icon animation speed */
61  uint16 eyecatch_type; /**< \brief Eyecatch type */
62  uint16 crc; /**< \brief CRC of the file */
63  uint32 data_len; /**< \brief Payload size */
64  uint8 reserved[20]; /**< \brief Reserved (all zero) */
65  uint16 icon_pal[16]; /**< \brief Icon palette (ARGB4444) */
66  /* 512*n Icon Bitmaps */
67  /* Eyecatch palette + bitmap */
68 } vmu_hdr_t;
69 
70 /** \defgroup vmu_ectype Eyecatch types.
71 
72  All eyecatches are 72x56, but the pixel format is variable. Note that in all
73  of the cases which use a palette, the palette entries are in ARGB4444 format
74  and come directly before the pixel data itself.
75 
76  @{
77 */
78 #define VMUPKG_EC_NONE 0 /**< \brief No eyecatch */
79 #define VMUPKG_EC_16BIT 1 /**< \brief 16-bit ARGB4444 */
80 #define VMUPKG_EC_256COL 2 /**< \brief 256-color palette */
81 #define VMUPKG_EC_16COL 3 /**< \brief 16-color palette */
82 /** @} */
83 
84 /** \brief Convert a vmu_pkg_t into an array of uint8s.
85 
86  This function converts a vmu_pkg_t structure into an array of uint8's which
87  may be written to a VMU file via fs_vmu, or whatever.
88 
89  \param src The vmu_pkg_t to convert.
90  \param dst The buffer (will be allocated for you).
91  \param dst_size The size of the output.
92  \return 0 on success, <0 on failure.
93 */
94 int vmu_pkg_build(vmu_pkg_t *src, uint8 ** dst, int * dst_size);
95 
96 /** \brief Parse an array of uint8s into a vmu_pkg_t.
97 
98  This function does the opposite of vmu_pkg_build and is used to parse VMU
99  files read in.
100 
101  \param data The buffer to parse.
102  \param pkg Where to store the vmu_pkg_t.
103  \retval -1 On invalid CRC in the data.
104  \retval 0 On success.
105 */
106 int vmu_pkg_parse(uint8 *data, vmu_pkg_t *pkg);
107 
108 
109 __END_DECLS
110 
111 #endif /* __DC_VMU_PKG_H */
112 
Common integer types.
char app_id[16]
Null-padded application ID.
Definition: vmu_pkg.h:58
const uint8 * data
Payload data.
Definition: vmu_pkg.h:46
int icon_cnt
Number of icons.
Definition: vmu_pkg.h:39
char desc_short[16]
Space-padded short description.
Definition: vmu_pkg.h:56
char desc_long[36]
Long file description.
Definition: vmu_pkg.h:37
uint32 data_len
Payload size.
Definition: vmu_pkg.h:63
char desc_short[20]
Short file description.
Definition: vmu_pkg.h:36
uint16 crc
CRC of the file.
Definition: vmu_pkg.h:62
int icon_anim_speed
Icon animation speed.
Definition: vmu_pkg.h:40
char desc_long[32]
Space-padded long description.
Definition: vmu_pkg.h:57
uint16 eyecatch_type
Eyecatch type.
Definition: vmu_pkg.h:61
int data_len
Number of data (payload) bytes.
Definition: vmu_pkg.h:42
unsigned short uint16
16-bit unsigned integer
Definition: types.h:29
struct vmu_pkg vmu_pkg_t
VMU Package type.
const uint8 * eyecatch_data
Eyecatch data.
Definition: vmu_pkg.h:45
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
char app_id[20]
Application ID.
Definition: vmu_pkg.h:38
int vmu_pkg_parse(uint8 *data, vmu_pkg_t *pkg)
Parse an array of uint8s into a vmu_pkg_t.
const uint8 * icon_data
512*n bytes of icon data
Definition: vmu_pkg.h:44
unsigned char uint8
8-bit unsigned integer
Definition: types.h:30
uint8 reserved[20]
Reserved (all zero)
Definition: vmu_pkg.h:64
VMU Package type.
Definition: vmu_pkg.h:35
int eyecatch_type
"Eyecatch" type
Definition: vmu_pkg.h:41
uint16 icon_pal[16]
Icon palette (ARGB4444)
Definition: vmu_pkg.h:43
Final VMU package type.
Definition: vmu_pkg.h:55
uint16 icon_pal[16]
Icon palette (ARGB4444)
Definition: vmu_pkg.h:65
uint16 icon_cnt
Number of icons.
Definition: vmu_pkg.h:59
int vmu_pkg_build(vmu_pkg_t *src, uint8 **dst, int *dst_size)
Convert a vmu_pkg_t into an array of uint8s.
struct vmu_hdr vmu_hdr_t
Final VMU package type.
uint16 icon_anim_speed
Icon animation speed.
Definition: vmu_pkg.h:60