mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Remove commented-out C-only macro features
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
|
||||
#include "asm/section.hpp"
|
||||
|
||||
#include "platform.hpp" // MIN_NB_ELMS
|
||||
|
||||
#define MAXSYMLEN 255
|
||||
|
||||
enum SymbolType {
|
||||
@@ -72,7 +70,7 @@ void sym_SetExportAll(bool set);
|
||||
Symbol *sym_AddLocalLabel(char const *symName);
|
||||
Symbol *sym_AddLabel(char const *symName);
|
||||
Symbol *sym_AddAnonLabel();
|
||||
void sym_WriteAnonLabelName(char buf[MIN_NB_ELMS(MAXSYMLEN + 1)], uint32_t ofs, bool neg);
|
||||
void sym_WriteAnonLabelName(char buf[/* MAXSYMLEN + 1 */], uint32_t ofs, bool neg);
|
||||
void sym_Export(char const *symName);
|
||||
Symbol *sym_AddEqu(char const *symName, int32_t value);
|
||||
Symbol *sym_RedefEqu(char const *symName, int32_t value);
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
void warn(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
void warnx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
void warn(char const *fmt ...) format_(printf, 1, 2);
|
||||
void warnx(char const *fmt, ...) format_(printf, 1, 2);
|
||||
|
||||
[[noreturn]] void err(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void errx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void err(char const *fmt, ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void errx(char const *fmt, ...) format_(printf, 1, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
// C++ doesn't support `[static N]` for array arguments from C99 or C11
|
||||
#define MIN_NB_ELMS(N) // static (N)
|
||||
#define ARR_QUALS(...) // __VA_ARGS__
|
||||
#define NONNULL(ptr) *ptr // ptr[static 1]
|
||||
#define restrict
|
||||
|
||||
// MSVC uses a different name for O_RDWR, and needs an additional _O_BINARY flag
|
||||
#ifdef _MSC_VER
|
||||
# include <fcntl.h>
|
||||
|
||||
@@ -498,7 +498,7 @@ Symbol *sym_AddAnonLabel()
|
||||
}
|
||||
|
||||
// Write an anonymous label's name to a buffer
|
||||
void sym_WriteAnonLabelName(char buf[MIN_NB_ELMS(MAXSYMLEN + 1)], uint32_t ofs, bool neg)
|
||||
void sym_WriteAnonLabelName(char buf[/* MAXSYMLEN + 1 */], uint32_t ofs, bool neg)
|
||||
{
|
||||
uint32_t id = 0;
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "error.hpp"
|
||||
#include "platform.hpp"
|
||||
|
||||
static void vwarn(char const NONNULL(fmt), va_list ap)
|
||||
static void vwarn(char const *fmt, va_list ap)
|
||||
{
|
||||
const char *error = strerror(errno);
|
||||
|
||||
@@ -18,14 +17,14 @@ static void vwarn(char const NONNULL(fmt), va_list ap)
|
||||
fprintf(stderr, ": %s\n", error);
|
||||
}
|
||||
|
||||
static void vwarnx(char const NONNULL(fmt), va_list ap)
|
||||
static void vwarnx(char const *fmt, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "warning: ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
[[noreturn]] static void verr(char const NONNULL(fmt), va_list ap)
|
||||
[[noreturn]] static void verr(char const *fmt, va_list ap)
|
||||
{
|
||||
const char *error = strerror(errno);
|
||||
|
||||
@@ -36,7 +35,7 @@ static void vwarnx(char const NONNULL(fmt), va_list ap)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
[[noreturn]] static void verrx(char const NONNULL(fmt), va_list ap)
|
||||
[[noreturn]] static void verrx(char const *fmt, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "error: ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
@@ -45,7 +44,7 @@ static void vwarnx(char const NONNULL(fmt), va_list ap)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void warn(char const NONNULL(fmt), ...)
|
||||
void warn(char const *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -54,7 +53,7 @@ void warn(char const NONNULL(fmt), ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void warnx(char const NONNULL(fmt), ...)
|
||||
void warnx(char const *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -63,7 +62,7 @@ void warnx(char const NONNULL(fmt), ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
[[noreturn]] void err(char const NONNULL(fmt), ...)
|
||||
[[noreturn]] void err(char const *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -71,7 +70,7 @@ void warnx(char const NONNULL(fmt), ...)
|
||||
verr(fmt, ap);
|
||||
}
|
||||
|
||||
[[noreturn]] void errx(char const NONNULL(fmt), ...)
|
||||
[[noreturn]] void errx(char const *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "error.hpp"
|
||||
#include "itertools.hpp"
|
||||
#include "linkdefs.hpp"
|
||||
#include "platform.hpp" // For `MIN_NB_ELMS` and `AT`
|
||||
|
||||
#define BANK_SIZE 0x4000
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t readNumber(char const *restrict str, char const **endptr, enum NumberType base) {
|
||||
static uint32_t readNumber(char const *str, char const **endptr, enum NumberType base) {
|
||||
uint32_t res = 0;
|
||||
|
||||
for (;;) {
|
||||
@@ -88,7 +88,7 @@ static uint32_t readNumber(char const *restrict str, char const **endptr, enum N
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t parseNumber(FileStackNode const *where, uint32_t lineNo, char const *restrict str, enum NumberType base) {
|
||||
static uint32_t parseNumber(FileStackNode const *where, uint32_t lineNo, char const *str, enum NumberType base) {
|
||||
if (str[0] == '\0')
|
||||
fatal(where, lineNo, "Expected number, got empty string");
|
||||
|
||||
@@ -100,7 +100,7 @@ static uint32_t parseNumber(FileStackNode const *where, uint32_t lineNo, char co
|
||||
return res;
|
||||
}
|
||||
|
||||
static uint8_t parseByte(FileStackNode const *where, uint32_t lineNo, char const *restrict str, enum NumberType base) {
|
||||
static uint8_t parseByte(FileStackNode const *where, uint32_t lineNo, char const *str, enum NumberType base) {
|
||||
uint32_t num = parseNumber(where, lineNo, str, base);
|
||||
|
||||
if (num > UINT8_MAX)
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
#include "platform.hpp"
|
||||
|
||||
struct Attributes {
|
||||
unsigned char palette;
|
||||
unsigned char nbColors;
|
||||
@@ -48,7 +46,7 @@ static unsigned long long getRandomBits(unsigned count) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static void generate_tile_attributes(Attributes * restrict attributes) {
|
||||
static void generate_tile_attributes(Attributes *attributes) {
|
||||
/*
|
||||
* Images have ten colors, grouped into two groups of 5 colors. The palette index indicates two
|
||||
* things: which one of those groups will be used, and which colors out of those 5 will be used
|
||||
@@ -77,8 +75,7 @@ static void generate_tile_attributes(Attributes * restrict attributes) {
|
||||
attributes->nbColors = popcount[pal];
|
||||
}
|
||||
|
||||
static void generate_tile_data(unsigned char tiledata[ARR_QUALS(restrict) MIN_NB_ELMS(8)][8],
|
||||
unsigned colorcount) {
|
||||
static void generate_tile_data(unsigned char tiledata[/* 8 */][8], unsigned colorcount) {
|
||||
switch (colorcount) {
|
||||
case 2: // 1bpp
|
||||
for (uint8_t y = 0; y < 8; y++) {
|
||||
@@ -109,8 +106,7 @@ static void generate_tile_data(unsigned char tiledata[ARR_QUALS(restrict) MIN_NB
|
||||
|
||||
// Can't mark as `const`, as the array type is otherwise not compatible (augh)
|
||||
static void
|
||||
copy_tile_data(unsigned char destination[ARR_QUALS(restrict) MIN_NB_ELMS(8)][8],
|
||||
unsigned char /* const */ source[ARR_QUALS(restrict) MIN_NB_ELMS(8)][8]) {
|
||||
copy_tile_data(unsigned char destination[/* 8 */][8], unsigned char /* const */ source[/* 8 */][8]) {
|
||||
// Apply a random rotation to the copy
|
||||
// coord ^ 7 = inverted coordinate; coord ^ 0 = regular coordinate
|
||||
unsigned xmask = getRandomBits(1) * 7;
|
||||
@@ -122,7 +118,7 @@ static void
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_palettes(uint16_t palettes[ARR_QUALS(restrict) MIN_NB_ELMS(60)][4]) {
|
||||
static void generate_palettes(uint16_t palettes[/* 60 */][4]) {
|
||||
uint16_t colors[10];
|
||||
// Generate 10 random colors (two groups of 5 colors)
|
||||
for (unsigned p = 0; p < 10; p++) {
|
||||
@@ -153,7 +149,7 @@ static uint8_t _5to8(uint8_t five) {
|
||||
}
|
||||
|
||||
// Can't mark as `const`, as the array type is otherwise not compatible (augh)
|
||||
static void write_image(char const *filename, uint16_t /* const */ palettes[MIN_NB_ELMS(60)][4],
|
||||
static void write_image(char const *filename, uint16_t /* const */ palettes[/* 60 */][4],
|
||||
unsigned char /* const */ (*tileData)[8][8], Attributes const *attributes,
|
||||
uint8_t width, uint8_t height) {
|
||||
uint8_t const nbTiles = width * height;
|
||||
|
||||
Reference in New Issue
Block a user