ref: 13c0684497bc45fcea983b176aaaf2809c3066dc
parent: c24cab6d1d1735fc305712a4e95996c10023b45d
author: Antonio Niño Díaz <[email protected]>
date: Sun Dec 31 08:46:52 EST 2017
Replace 8 and 16 bit custom types by stdint.h types Signed-off-by: Antonio Niño Díaz <[email protected]>
--- a/include/asm/charmap.h
+++ b/include/asm/charmap.h
@@ -1,11 +1,13 @@
#ifndef RGBDS_ASM_CHARMAP_H
#define RGBDS_ASM_CHARMAP_H
+#include <stdint.h>
+
#define MAXCHARMAPS 512
#define CHARMAPLENGTH 16
struct Charmap {
- int count;
+ int count;
char input[MAXCHARMAPS][CHARMAPLENGTH + 1];
char output[MAXCHARMAPS];
};
@@ -12,7 +14,7 @@
int readUTF8Char(char *destination, char *source);
void charmap_Sort();
-int charmap_Add(char *input, UBYTE output);
+int charmap_Add(char *input, uint8_t output);
int charmap_Convert(char **input);
#endif
--- a/include/asm/lexer.h
+++ b/include/asm/lexer.h
@@ -1,6 +1,7 @@
#ifndef RGBDS_ASM_LEXER_H
#define RGBDS_ASM_LEXER_H
+#include <stdint.h>
#include <stdio.h>
#include "types.h"
@@ -42,12 +43,12 @@
extern void yy_delete_buffer(YY_BUFFER_STATE);
extern void yy_switch_to_buffer(YY_BUFFER_STATE);
extern ULONG lex_FloatAlloc(struct sLexFloat * tok);
-extern void lex_FloatAddRange(ULONG id, UWORD start, UWORD end);
-extern void lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end);
-extern void lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end);
-extern void lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end);
-extern void lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end);
-extern void lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end);
+extern void lex_FloatAddRange(ULONG id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteRange(ULONG id, uint16_t start, uint16_t end);
+extern void lex_FloatAddFirstRange(ULONG id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteFirstRange(ULONG id, uint16_t start, uint16_t end);
+extern void lex_FloatAddSecondRange(ULONG id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteSecondRange(ULONG id, uint16_t start, uint16_t end);
extern void lex_Init(void);
extern void lex_AddStrings(struct sLexInitString * lex);
extern void lex_SetBuffer(char *buffer, ULONG len);
--- a/include/asm/output.h
+++ b/include/asm/output.h
@@ -1,12 +1,14 @@
#ifndef RGBDS_ASM_OUTPUT_H
#define RGBDS_ASM_OUTPUT_H
+#include <stdint.h>
+
#include "asm/rpn.h"
#include "types.h"
struct Section {
char *pzName;
- UBYTE nType;
+ uint8_t nType;
ULONG nPC;
ULONG nOrg;
ULONG nBank;
@@ -14,7 +16,7 @@
struct Section *pNext;
struct Patch *pPatches;
struct Charmap *charmap;
- UBYTE *tData;
+ uint8_t *tData;
};
void out_PrepPass2(void);
--- a/include/asm/rpn.h
+++ b/include/asm/rpn.h
@@ -1,9 +1,11 @@
#ifndef RGBDS_ASM_RPN_H
#define RGBDS_ASM_RPN_H
+#include <stdint.h>
+
struct Expression {
SLONG nVal;
- UBYTE tRPN[256];
+ uint8_t tRPN[256];
ULONG nRPNLength;
ULONG nRPNOut;
ULONG isReloc;
@@ -73,7 +75,7 @@
void rpn_LOW(struct Expression * expr, struct Expression * src);
void rpn_UNNEG(struct Expression * expr, struct Expression * src);
void rpn_UNNOT(struct Expression * expr, struct Expression * src);
-UWORD rpn_PopByte(struct Expression * expr);
+uint16_t rpn_PopByte(struct Expression * expr);
void rpn_Bank(struct Expression * expr, char *tzSym);
void rpn_Reset(struct Expression * expr);
void rpn_CheckHRAM(struct Expression * expr, struct Expression * src1);
--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -1,6 +1,8 @@
#ifndef RGBDS_SYMBOL_H
#define RGBDS_SYMBOL_H
+#include <stdint.h>
+
#include "types.h"
#define HASHSIZE (1 << 16)
@@ -38,7 +40,7 @@
* not be changed during linking */
ULONG calchash(char *s);
-void sym_SetExportAll(BBOOL set);
+void sym_SetExportAll(uint8_t set);
void sym_PrepPass1(void);
void sym_PrepPass2(void);
void sym_AddLocalReloc(char *tzSym);
--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -5,6 +5,8 @@
#define _MAX_PATH 512
#endif
+#include <stdint.h>
+
#include "types.h"
extern SLONG options;
@@ -64,12 +66,12 @@
SLONG nBank;
SLONG nOrg;
SLONG nAlign;
- BBOOL oAssigned;
+ uint8_t oAssigned;
char *pzName;
SLONG nByteSize;
enum eSectionType Type;
- UBYTE *pData;
+ uint8_t *pData;
SLONG nNumberOfSymbols;
struct sSymbol **tSymbols;
struct sPatch *pPatches;
@@ -106,9 +108,9 @@
SLONG nOffset;
enum ePatchType Type;
SLONG nRPNSize;
- UBYTE *pRPN;
+ uint8_t *pRPN;
struct sPatch *pNext;
- BBOOL oRelocPatch;
+ uint8_t oRelocPatch;
};
extern struct sSection *pSections;
--- a/include/link/object.h
+++ b/include/link/object.h
@@ -1,5 +1,5 @@
-#ifndef RGBDS_LINK_OBJECT_H
-#define RGBDS_LINK_OBJECT_H
+#ifndef RGBDS_LINK_OBJECT_H
+#define RGBDS_LINK_OBJECT_H
extern void obj_Readfile(char *tzObjectfile);
--- a/include/link/output.h
+++ b/include/link/output.h
@@ -1,5 +1,5 @@
-#ifndef RGBDS_LINK_OUTPUT_H
-#define RGBDS_LINK_OUTPUT_H
+#ifndef RGBDS_LINK_OUTPUT_H
+#define RGBDS_LINK_OUTPUT_H
void out_Setname(char *tzOutputfile);
void out_SetOverlayname(char *tzOverlayfile);
--- a/include/types.h
+++ b/include/types.h
@@ -5,12 +5,7 @@
#define _MAX_PATH 512
#endif
-typedef unsigned char UBYTE;
-typedef signed char SBYTE;
-typedef unsigned short UWORD;
-typedef signed short SWORD;
typedef unsigned long ULONG;
typedef signed long SLONG;
-typedef signed char BBOOL;
#endif
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1,6 +1,7 @@
%{
#include <ctype.h>
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -103,7 +104,7 @@
while( *s )
{
r<<=8;
- r|=(UBYTE)(*s++);
+ r|=(uint8_t)(*s++);
}
return( r );
}
@@ -116,7 +117,7 @@
while(i < length)
{
r<<=8;
- r|=(UBYTE)(s[i]);
+ r|=(uint8_t)(s[i]);
i++;
}
return( r );
--- a/src/asm/charmap.c
+++ b/src/asm/charmap.c
@@ -105,7 +105,7 @@
}
int
-charmap_Add(char *input, UBYTE output)
+charmap_Add(char *input, uint8_t output)
{
int i;
size_t input_length;
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -4,6 +4,7 @@
#include <errno.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -331,7 +332,7 @@
if ((sym = sym_FindMacroArg(s)) != NULL) {
pushcontext();
nCurrentStatus = STAT_isMacroArg;
- sprintf(tzCurrentFileName, "%c", (UBYTE) s);
+ sprintf(tzCurrentFileName, "%c", (uint8_t) s);
CurrentFlexHandle = yy_scan_bytes(sym, strlen(sym));
yy_switch_to_buffer(CurrentFlexHandle);
} else
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@@ -152,7 +153,7 @@
pBuffer->pBufferStart = pBuffer->pBufferRealStart + SAFETYMARGIN;
pBuffer->pBuffer = pBuffer->pBufferRealStart + SAFETYMARGIN;
- size = fread(pBuffer->pBuffer, sizeof(UBYTE), size, f);
+ size = fread(pBuffer->pBuffer, sizeof(uint8_t), size, f);
pBuffer->pBuffer[size] = '\n';
pBuffer->pBuffer[size + 1] = 0;
@@ -211,7 +212,7 @@
* start is greater than the end of the range.
*/
void
-lex_CheckCharacterRange(UWORD start, UWORD end)
+lex_CheckCharacterRange(uint16_t start, uint16_t end)
{
if (start > end || start < 1 || end > 127) {
errx(1, "Invalid character range (start: %u, end: %u)",
@@ -220,7 +221,7 @@
}
void
-lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end)
+lex_FloatDeleteRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -231,7 +232,7 @@
}
void
-lex_FloatAddRange(ULONG id, UWORD start, UWORD end)
+lex_FloatAddRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -242,7 +243,7 @@
}
void
-lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end)
+lex_FloatDeleteFirstRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -253,7 +254,7 @@
}
void
-lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end)
+lex_FloatAddFirstRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -264,7 +265,7 @@
}
void
-lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end)
+lex_FloatDeleteSecondRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -275,7 +276,7 @@
}
void
-lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end)
+lex_FloatAddSecondRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -4,6 +4,7 @@
#include <errno.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -24,9 +25,9 @@
char tzFilename[_MAX_PATH + 1];
ULONG nLine;
ULONG nOffset;
- UBYTE nType;
+ uint8_t nType;
ULONG nRPNSize;
- UBYTE *pRPN;
+ uint8_t *pRPN;
struct Patch *pNext;
};
@@ -371,8 +372,8 @@
createpatch(ULONG type, struct Expression * expr)
{
struct Patch *pPatch;
- UWORD rpndata;
- UBYTE rpnexpr[2048];
+ uint16_t rpndata;
+ uint8_t rpnexpr[2048];
char tzSym[512];
ULONG rpnptr = 0, symptr;
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -2,6 +2,7 @@
* Controls RPN expressions for objectfiles
*/
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -46,7 +47,7 @@
/*
* Returns the next rpn byte in expression
*/
-UWORD
+uint16_t
rpn_PopByte(struct Expression * expr)
{
if (expr->nRPNOut == expr->nRPNLength) {
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -3,6 +3,7 @@
*/
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -814,7 +815,7 @@
/*
* Set whether to export all relocable symbols by default
*/
-void sym_SetExportAll(BBOOL set) {
+void sym_SetExportAll(uint8_t set) {
exportall = set;
}
--- a/src/link/library.c
+++ b/src/link/library.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -7,7 +8,7 @@
#include "link/mylink.h"
#include "link/main.h"
-static BBOOL
+static uint8_t
symboldefined(char *name)
{
struct sSection *pSect;
@@ -31,7 +32,7 @@
return (0);
}
-static BBOOL
+static uint8_t
addmodulecontaining(char *name)
{
struct sSection **ppLSect;
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -5,6 +5,7 @@
#include <ctype.h>
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -18,8 +19,8 @@
struct sSymbol **tSymbols;
struct sSection *pSections = NULL;
struct sSection *pLibSections = NULL;
-UBYTE dummymem;
-BBOOL oReadLib = 0;
+uint8_t dummymem;
+uint8_t oReadLib = 0;
/*
* The usual byte order stuff
@@ -39,10 +40,10 @@
return (r);
}
-UWORD
+uint16_t
readword(FILE * f)
{
- UWORD r;
+ uint16_t r;
r = fgetc(f);
r |= fgetc(f) << 8;
@@ -228,7 +229,7 @@
SLONG nNumberOfPatches;
struct sPatch **ppPatch, *pPatch;
- if (fread(pSection->pData, sizeof(UBYTE),
+ if (fread(pSection->pData, sizeof(uint8_t),
pSection->nByteSize, f) != pSection->nByteSize) {
err(1, "Read error.");
}
@@ -257,7 +258,7 @@
err(1, NULL);
}
- if (fread(pPatch->pRPN, sizeof(UBYTE),
+ if (fread(pPatch->pRPN, sizeof(uint8_t),
pPatch->nRPNSize, f) != pPatch->nRPNSize) {
errx(1, "Read error.");
}
--- a/src/link/output.c
+++ b/src/link/output.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -11,13 +12,13 @@
char *tzOutname;
char *tzOverlayname = NULL;
-SLONG MaxOverlayBank;
+int32_t MaxOverlayBank;
void
writehome(FILE * f, FILE * f_overlay)
{
struct sSection *pSect;
- UBYTE *mem;
+ uint8_t *mem;
mem = malloc(MaxAvail[BANK_ROM0]);
if (!mem)
@@ -51,10 +52,10 @@
}
void
-writebank(FILE * f, FILE * f_overlay, SLONG bank)
+writebank(FILE * f, FILE * f_overlay, int32_t bank)
{
struct sSection *pSect;
- UBYTE *mem;
+ uint8_t *mem;
mem = malloc(MaxAvail[bank]);
if (!mem)
@@ -103,7 +104,7 @@
void
Output(void)
{
- SLONG i;
+ int32_t i;
FILE *f;
FILE *f_overlay = NULL;
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -86,7 +87,7 @@
calcrpn(struct sPatch * pPatch)
{
SLONG t, size;
- UBYTE *rpn;
+ uint8_t *rpn;
rpnp = 0;
@@ -232,7 +233,7 @@
if (t >= -128 && t <= 255) {
t &= 0xFF;
pSect->pData[pPatch->nOffset] =
- (UBYTE) t;
+ (uint8_t) t;
} else {
errx(1,
"%s(%ld) : Value must be 8-bit",