KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
vmu_pkg.h
Go to the documentation of this file.
1 /* KallistiOS 2.0.0
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