hh2: provide metadata macros and a non-metadata marker by default

If none of the HH2_*() macros are used, the binary will show up as its
own filename instead of random garbage.

If HH2_NAME() is used the metadata will be read, and the binary format
requires that all fields by specified. Using only a subset of the macros
is invalid, but not reported.
This commit is contained in:
Lephe 2024-08-17 18:04:16 +02:00
parent 979873288a
commit aba6c280b6
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
3 changed files with 34 additions and 1 deletions

View file

@ -43,7 +43,10 @@ SECTIONS
- All text from .text and .text.* (including user code) */
.hh2 : {
KEEP(*(.hh2.header))
KEEP(*(.hh2.info))
KEEP(*(.hh2.info.name))
KEEP(*(.hh2.info.description))
KEEP(*(.hh2.info.author))
KEEP(*(.hh2.info.version))
KEEP(*(.hh2.stage2))
. = ALIGN(16);
} > eram AT> bin

View file

@ -80,4 +80,26 @@
#define GINT_RENDER_MONO (GINT_HW_FX || GINT_FX9860G_G3A)
#define GINT_RENDER_RGB ((GINT_HW_CG || GINT_HW_CP) && !GINT_FX9860G_G3A)
/* Macros for specifying HH2 binary metadata fields. Here because this header
is guaranteed to be included with every gint header. */
#if GINT_HW_CP
#define HH2_NAME(STR) \
GSECTION(".hh2.info.name") GVISIBLE \
char _hh2info_name[] = (STR);
#define HH2_DESCRIPTION(STR) \
GSECTION(".hh2.info.description") GVISIBLE \
char _hh2info_description[] = (STR);
#define HH2_AUTHOR(STR) \
GSECTION(".hh2.info.author") GVISIBLE \
char _hh2info_author[] = (STR);
#define HH2_VERSION(STR) \
GSECTION(".hh2.info.version") GVISIBLE \
char _hh2info_version[] = (STR);
#else
#define HH2_NAME(STR)
#define HH2_DESCRIPTION(STR)
#define HH2_AUTHOR(STR)
#define HH2_VERSION(STR)
#endif
#endif /* GINT_CONFIG */

View file

@ -122,4 +122,12 @@ _stage2:
it's overriding the correct location. */
.long 1, 2, 3, 4, 5, 6, 7, 8
/* Also provide default values for metadata fields. */
.section .hh2.info.name
.global __hh2info_name
.weak __hh2info_name
/* Zero byte will skip specifiying any of the data */
__hh2info_name: .byte 0x00
#endif /* GINT_OS_CP */