libElysianVMU 1.6.0
Full-featured, accurate, cross-platform library emulating the Dreamcast's Visual Memory Unit
Loading...
Searching...
No Matches
evmu_icondata.h
Go to the documentation of this file.
1/*! \file
2 * \brief EvmuIconData: Header for the ICONDATA_VMS reserved file
3 * \ingroup file_formats
4 *
5 * ICONDATA_VMS is a reserved filename on the VMU filesystem that
6 * is treated differently by the Dreamcast's BIOS menu. Rather
7 * than having the regular EvmuVms header structure, it has
8 * a structure given by EvmuIconData.
9 *
10 * An ICONDATA_VMS file provides the following:
11 * - Custom VMU icon which is drawn to the VMU in the DC BIOS
12 * - Custom DC icon which is drawn to the screen in the DC BIOS
13 * - Optional byte sequence for unlocking the secret 3D DC BIOS
14 *
15 * The VMU icon is a simple monochrome bitmap of exactly the
16 * resolution of the VMU screen while the Dreamcast icon is a
17 * 32x32 icon with a 16-bit, 16-entry color palette.
18 *
19 * \note
20 * In order to unlock the secret 3D Dreamcast BIOS, a particular
21 * byte sequence must appear within the ICONDATA_VMS file.
22 * This sequence must appear starting at byte offset 0x2c0 with the
23 * following 16 byte values:
24 * |Byte|Value|Byte|Value|
25 * |----|-----|----|-----|
26 * |0 |0xda |8 |0x18 |
27 * |1 |0x69 |9 |0x92 |
28 * |2 |0xd0 |10 |0x79 |
29 * |3 |0xda |11 |0x68 |
30 * |4 |0xc7 |12 |0x2d |
31 * |5 |0x4e |13 |0xb5 |
32 * |6 |0xf8 |14 |0x30 |
33 * |7 |0x36 |15 |0x86 |
34 *
35 * \todo
36 * - Set icondata icon if there is no game
37 * - data present instead of the ES logo/screensaver
38 * - good description of what IconData is
39 *
40 * \bug
41 * - Loading VMU image with both a game and an icondata
42 * just shows icon instead of starting game
43 *
44 * \author 2023 Falco Girgis
45 * \copyright MIT License
46 */
47#ifndef EVMU_ICONDATA_H
48#define EVMU_ICONDATA_H
49
50#include "evmu_fat.h"
51#include <gimbal/utils/gimbal_byte_array.h>
52
53//! Reserved EvmuDirEntry::fileName value for EvmuIconData files
54#define EVMU_ICONDATA_VMS_FILE_NAME "ICONDATA_VMS"
55
56/*! \name Field Sizes
57 * \brief Sizes and dimensions for icons
58 * @{
59 */
60#define EVMU_ICONDATA_DESCRIPTION_SIZE 16 //!< Number of bytes in the EvmuIconData::description string
61#define EVMU_ICONDATA_ICON_WIDTH 32 //!< Width of the DC icon in pixels
62#define EVMU_ICONDATA_ICON_HEIGHT 32 //!< Height of the DC icon in pixels
63#define EVMU_ICONDATA_VMU_ICON_BYTES 128 //!< Total number of bytes for the VMU icon
64#define EVMU_ICONDATA_DC_PALETTE_SIZE 16 //!< Number of entries in the DC icon color palette
65#define EVMU_ICONDATA_DC_PALETTE_BYTES 32 //!< Total number of bytes for the DC icon color palette
66#define EVMU_ICONDATA_DC_ICON_BYTES 512 //!< Total number of bytes for the DC icon
67//! @}
68
69/*! \name Secret Bios
70 * \brief Definitions for secret BIOS information
71 * @{
72 */
73#define EVMU_ICONDATA_BIOS_SECRET_OFFSET 0x2c0 //!< Offset of the secret BIOS byte sequence
74#define EVMU_ICONDATA_BIOS_SECRET_BYTE_COUNT 16 //!< Number of bytes in the secret BIOS byte sequence
75//! @}
76
77/*! \name Palette Colors
78 * \brief Extracting and packet palette colors
79 * @{
80 */
81#define EVMU_ICONDATA_PALETTE_ENTRY_A(c) ((c >> 12) & 0xf) //!< Extracts the alpha channel from DC icon a palette entry
82#define EVMU_ICONDATA_PALETTE_ENTRY_R(c) ((c >> 8 ) & 0xf) //!< Extracts the red channel from a DC icon palette entry
83#define EVMU_ICONDATA_PALETTE_ENTRY_G(c) ((c >> 4 ) & 0xf) //!< Extracts the green channel from a DC icon palette entry
84#define EVMU_ICONDATA_PALETTE_ENTRY_B(c) ((c ) & 0xf) //!< Extracts the blue channel from a DC icon palette entry
85//! Packs the channels given by \p a, \p r, \p g, \p b, into a single 16-bit palette entry color
86#define EVMU_ICONDATA_PALETTE_ENTRY(a, r, g, b)
87 ((uint16_t)(((a & 0xf) << 12) | ((r & 0xf) << 8) | ((g & 0xf) << 4) | ((b & 0xf))))
88//! @}
89
90#define GBL_SELF_TYPE EvmuIconData
91
92GBL_DECLS_BEGIN
93
94/*! Header structure for the ICONDATA_VMS special VMU file
95 * \ingroup file_formats
96 *
97 * EvmuIconData is the VMS file payload for the special
98 * ICONDATA_VMS reserved file. It doesn't have all of the
99 * regular VMS header fields and is treated differently
100 * from regular VMS headers.
101 */
102typedef struct EvmuIconData {
103 //! VMU filesystem description of file
105 uint32_t vmuIconOffset; //!< Byte offset of the VMU icon from the header
106 uint32_t dcIconOffset; //!< Byte offset of the DC icon from the header
107} EvmuIconData;
108
109//! Returns the 16-byte ICONDATA sequence for unlocking the secret Dreamcast BIOS
110EVMU_EXPORT const uint8_t* EvmuIconData_unlockSecretBiosBytes (void) GBL_NOEXCEPT;
111
112/*! \name Read Accessors
113 * \brief Methods for fetching data
114 * \relatesalso EvmuIconData
115 * @{
116 */
117//! Fills the given GblStringBuffer with the EvmuIconData::description field, returning its C string
119 GblStringBuffer* pBuff) GBL_NOEXCEPT;
120//! Returns GBL_TRUE if the secret 3D Dreamcast BIOS has been unlocked, GBL_FALSE otherwise
122//! Returns a raw data pointer to the VMU icon, which is a monochrome bitmap
123EVMU_EXPORT const void* EvmuIconData_vmuIcon (GBL_CSELF) GBL_NOEXCEPT;
124//! Returns a raw data pointer to the DC icon, which is a 4-bit paletted image where each color is 16-bit
125EVMU_EXPORT const void* EvmuIconData_dcIcon (GBL_CSELF) GBL_NOEXCEPT;
126//! Returns the 16-bit color palette entry at index \p idx for the DC icon
127EVMU_EXPORT uint16_t EvmuIconData_dcPaletteEntry (GBL_CSELF, size_t idx) GBL_NOEXCEPT;
128//! Returns a pointer to the beginning of the byte sequence for unlocking the secret DC BIOS
129EVMU_EXPORT const uint8_t* EvmuIconData_secretBiosBytes (GBL_CSELF) GBL_NOEXCEPT;
130//! Returns the total size of the EvmuIconData file on the filesystem in bytes
131EVMU_EXPORT size_t EvmuIconData_totalBytes (GBL_CSELF) GBL_NOEXCEPT;
132//! @}
133
134/*! \name Write Accessors
135 * \brief Methods for storing data
136 * \relatesalso EvmuIconData
137 * @{
138 */
139//! Sets the EvmuIconData::description field to the string given by \p pString, returning the number of bytes copied
141 const char* pString) GBL_NOEXCEPT;
142//! Locks or unlocks the secret 3D additional Dreamcast BIOS by writing a secret bit sequence
144 GblBool unlock) GBL_NOEXCEPT;
145//! Sets the 16-byte sequence for unlocking the secret BIOS to the data pointed to by \p pBytes
147 const uint8_t* pBytes) GBL_NOEXCEPT;
148//! @}
149
150/*! \name Utilities
151 * \brief Miscellaneous methods
152 * \relatesalso EvmuIconData
153 * @{
154 */
155//! Creates and returns a GblByteArray containing an ARGB4444 16-bit format texture for the VMU icon
156EVMU_EXPORT GblByteArray* EvmuIconData_createVmuIconArgb4444 (GBL_CSELF) GBL_NOEXCEPT;
157//! Creats and returns a GblByteArray containing an ARGB4444 16-bit format texture for the DC icon
158EVMU_EXPORT GblByteArray* EvmuIconData_createDcIconArgb4444 (GBL_CSELF) GBL_NOEXCEPT;
159//! Dumps all attribute and field information for EvmuIconData to the libGimbal log system
160EVMU_EXPORT EVMU_RESULT EvmuIconData_log (GBL_CSELF) GBL_NOEXCEPT;
161//! @}
162
163GBL_DECLS_END
164
165#undef GBL_SELF_TYPE
166
167#endif
#define EVMU_EXPORT
Define used for adding attributes to export public symbols.
Definition evmu_api.h:18
const uint8_t * EvmuIconData_unlockSecretBiosBytes(void)
Returns the 16-byte ICONDATA sequence for unlocking the secret Dreamcast BIOS.
#define EVMU_ICONDATA_DESCRIPTION_SIZE
Number of bytes in the EvmuIconData::description string.
uint8_t GblBool
Header structure for the ICONDATA_VMS special VMU file.
uint32_t vmuIconOffset
Byte offset of the VMU icon from the header.
const char * EvmuIconData_description(const EvmuIconData *pSelf, GblStringBuffer *pBuff)
Fills the given GblStringBuffer with the EvmuIconData::description field, returning its C string.
const void * EvmuIconData_dcIcon(const EvmuIconData *pSelf)
Returns a raw data pointer to the DC icon, which is a 4-bit paletted image where each color is 16-bit...
size_t EvmuIconData_setDescription(EvmuIconData *pSelf, const char *pString)
Sets the EvmuIconData::description field to the string given by pString, returning the number of byte...
const uint8_t * EvmuIconData_secretBiosBytes(const EvmuIconData *pSelf)
Returns a pointer to the beginning of the byte sequence for unlocking the secret DC BIOS.
GblBool EvmuIconData_secretBiosUnlocked(const EvmuIconData *pSelf)
Returns GBL_TRUE if the secret 3D Dreamcast BIOS has been unlocked, GBL_FALSE otherwise.
uint16_t EvmuIconData_dcPaletteEntry(const EvmuIconData *pSelf, size_t idx)
Returns the 16-bit color palette entry at index idx for the DC icon.
uint32_t dcIconOffset
Byte offset of the DC icon from the header.
void EvmuIconData_setSecretBiosBytes(EvmuIconData *pSelf, const uint8_t *pBytes)
Sets the 16-byte sequence for unlocking the secret BIOS to the data pointed to by pBytes.
const void * EvmuIconData_vmuIcon(const EvmuIconData *pSelf)
Returns a raw data pointer to the VMU icon, which is a monochrome bitmap.
GblByteArray * EvmuIconData_createDcIconArgb4444(const EvmuIconData *pSelf)
Creats and returns a GblByteArray containing an ARGB4444 16-bit format texture for the DC icon.
void EvmuIconData_unlockSecretBios(EvmuIconData *pSelf, GblBool unlock)
Locks or unlocks the secret 3D additional Dreamcast BIOS by writing a secret bit sequence.
size_t EvmuIconData_totalBytes(const EvmuIconData *pSelf)
Returns the total size of the EvmuIconData file on the filesystem in bytes.
char description[16]
VMU filesystem description of file.
GblByteArray * EvmuIconData_createVmuIconArgb4444(const EvmuIconData *pSelf)
Creates and returns a GblByteArray containing an ARGB4444 16-bit format texture for the VMU icon.
EVMU_RESULT EvmuIconData_log(const EvmuIconData *pSelf)
Dumps all attribute and field information for EvmuIconData to the libGimbal log system.