mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Rewrite charmap system
Avoid allocating a *ton* of data per charmap Stop relying on uninitialized data in charmap nodes Only initialize charmap nodes lazily
This commit is contained in:
@@ -11,38 +11,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "asm/symbol.h"
|
||||
|
||||
#define MAXCHARMAPS 512
|
||||
#define CHARMAPLENGTH 16
|
||||
#define MAXCHARNODES (MAXCHARMAPS * CHARMAPLENGTH + 1)
|
||||
|
||||
/*
|
||||
* A node for trie structure.
|
||||
*/
|
||||
struct Charnode {
|
||||
uint8_t code; /* the value in a key-value pair. */
|
||||
uint8_t isCode; /* has 1 if it's a code node, not just a bridge node. */
|
||||
struct Charnode *next[256]; /* each index representing the next possible
|
||||
* character from its current state.
|
||||
*/
|
||||
};
|
||||
|
||||
struct Charmap {
|
||||
char name[MAXSYMLEN + 1];
|
||||
int32_t charCount; /* user-side count. */
|
||||
int32_t nodeCount; /* node-side count. */
|
||||
struct Charnode nodes[MAXCHARNODES]; /* first node is reserved for the
|
||||
* root node in charmap.
|
||||
*/
|
||||
};
|
||||
|
||||
void charmap_InitMain(void);
|
||||
struct Charmap *charmap_New(const char *name, const char *baseName);
|
||||
void charmap_Delete(struct Charmap *charmap);
|
||||
void charmap_Set(const char *name);
|
||||
void charmap_Push(void);
|
||||
void charmap_Pop(void);
|
||||
int32_t charmap_Add(char *input, uint8_t output);
|
||||
int32_t charmap_Convert(char **input);
|
||||
void charmap_Add(char *mapping, uint8_t value);
|
||||
size_t charmap_Convert(char const *input, uint8_t *output);
|
||||
|
||||
#endif /* RGBDS_ASM_CHARMAP_H */
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t calchash(const char *s);
|
||||
int32_t readUTF8Char(char *dest, char *src);
|
||||
size_t readUTF8Char(uint8_t *dest, char const *src);
|
||||
|
||||
#endif /* RGBDS_UTIL_H */
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
extern unsigned int nbErrors;
|
||||
|
||||
enum WarningID {
|
||||
WARNING_ASSERT, /* Assertions */
|
||||
WARNING_BUILTIN_ARG, /* Invalid args to builtins */
|
||||
WARNING_DIV, /* Division undefined behavior */
|
||||
WARNING_EMPTY_DATA_DIRECTIVE,
|
||||
/* `db`, `dw` or `dl` with no directive in ROM */
|
||||
WARNING_EMPTY_ENTRY, /* Empty entry in `db`, `dw` or `dl` */
|
||||
WARNING_LARGE_CONSTANT, /* Constants too large */
|
||||
WARNING_LONG_STR, /* String too long for internal buffers */
|
||||
WARNING_OBSOLETE, /* Obsolete things */
|
||||
WARNING_SHIFT, /* Shifting undefined behavior */
|
||||
WARNING_SHIFT_AMOUNT, /* Strange shift amount */
|
||||
WARNING_TRUNCATION, /* Implicit truncation loses some bits */
|
||||
WARNING_USER, /* User warnings */
|
||||
WARNING_ASSERT, /* Assertions */
|
||||
WARNING_BUILTIN_ARG, /* Invalid args to builtins */
|
||||
WARNING_CHARMAP_REDEF, /* Charmap entry re-definition */
|
||||
WARNING_DIV, /* Division undefined behavior */
|
||||
WARNING_EMPTY_DATA_DIRECTIVE, /* `db`, `dw` or `dl` with no directive in ROM */
|
||||
WARNING_EMPTY_ENTRY, /* Empty entry in `db`, `dw` or `dl` */
|
||||
WARNING_LARGE_CONSTANT, /* Constants too large */
|
||||
WARNING_LONG_STR, /* String too long for internal buffers */
|
||||
WARNING_OBSOLETE, /* Obsolete things */
|
||||
WARNING_SHIFT, /* Shifting undefined behavior */
|
||||
WARNING_SHIFT_AMOUNT, /* Strange shift amount */
|
||||
WARNING_TRUNCATION, /* Implicit truncation loses some bits */
|
||||
WARNING_USER, /* User warnings */
|
||||
|
||||
NB_WARNINGS,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user