Replace 8 and 16 bit custom types by stdint.h types

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2017-12-31 13:46:52 +01:00
parent c24cab6d1d
commit 13c0684497
20 changed files with 75 additions and 59 deletions

View File

@@ -1,18 +1,20 @@
#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];
};
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

View File

@@ -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 YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size);
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);

View File

@@ -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 {
struct Section *pNext;
struct Patch *pPatches;
struct Charmap *charmap;
UBYTE *tData;
uint8_t *tData;
};
void out_PrepPass2(void);

View File

@@ -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_HIGH(struct Expression * expr, struct Expression * src);
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);

View File

@@ -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 @@ struct sSymbol {
* 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);

View File

@@ -5,6 +5,8 @@
#define _MAX_PATH 512
#endif
#include <stdint.h>
#include "types.h"
extern SLONG options;
@@ -64,12 +66,12 @@ struct sSection {
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 @@ struct sPatch {
SLONG nOffset;
enum ePatchType Type;
SLONG nRPNSize;
UBYTE *pRPN;
uint8_t *pRPN;
struct sPatch *pNext;
BBOOL oRelocPatch;
uint8_t oRelocPatch;
};
extern struct sSection *pSections;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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 @@ ULONG str2int( char *s )
while( *s )
{
r<<=8;
r|=(UBYTE)(*s++);
r|=(uint8_t)(*s++);
}
return( r );
}
@@ -116,7 +117,7 @@ ULONG str2int2( char *s, int length )
while(i < length)
{
r<<=8;
r|=(UBYTE)(s[i]);
r|=(uint8_t)(s[i]);
i++;
}
return( r );

View File

@@ -105,7 +105,7 @@ readUTF8Char(char *dest, char *src)
}
int
charmap_Add(char *input, UBYTE output)
charmap_Add(char *input, uint8_t output)
{
int i;
size_t input_length;

View File

@@ -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 @@ fstk_RunMacroArg(SLONG s)
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

View File

@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@@ -152,7 +153,7 @@ yy_create_buffer(FILE * f)
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 @@ lex_FloatAlloc(struct sLexFloat *token)
* 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 @@ lex_CheckCharacterRange(UWORD start, UWORD end)
}
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 @@ lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end)
}
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 @@ lex_FloatAddRange(ULONG id, UWORD start, UWORD end)
}
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 @@ lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end)
}
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 @@ lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end)
}
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 @@ lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end)
}
void
lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end)
lex_FloatAddSecondRange(ULONG id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);

View File

@@ -4,6 +4,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -24,9 +25,9 @@ struct Patch {
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 @@ void
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;

View File

@@ -2,6 +2,7 @@
* Controls RPN expressions for objectfiles
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -46,7 +47,7 @@ rpn_Reset(struct Expression * expr)
/*
* Returns the next rpn byte in expression
*/
UWORD
uint16_t
rpn_PopByte(struct Expression * expr)
{
if (expr->nRPNOut == expr->nRPNLength) {

View File

@@ -3,6 +3,7 @@
*/
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -814,7 +815,7 @@ sym_AddMacro(char *tzSym)
/*
* Set whether to export all relocable symbols by default
*/
void sym_SetExportAll(BBOOL set) {
void sym_SetExportAll(uint8_t set) {
exportall = set;
}

View File

@@ -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 @@ symboldefined(char *name)
return (0);
}
static BBOOL
static uint8_t
addmodulecontaining(char *name)
{
struct sSection **ppLSect;

View File

@@ -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 @@ readlong(FILE * f)
return (r);
}
UWORD
uint16_t
readword(FILE * f)
{
UWORD r;
uint16_t r;
r = fgetc(f);
r |= fgetc(f) << 8;
@@ -228,7 +229,7 @@ obj_ReadRGBSection(FILE * f)
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 @@ obj_ReadRGBSection(FILE * f)
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.");
}

View File

@@ -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 @@ writehome(FILE * f, FILE * f_overlay)
}
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 @@ out_SetOverlayname(char *tzOverlayfile)
void
Output(void)
{
SLONG i;
int32_t i;
FILE *f;
FILE *f_overlay = NULL;

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -86,7 +87,7 @@ SLONG
calcrpn(struct sPatch * pPatch)
{
SLONG t, size;
UBYTE *rpn;
uint8_t *rpn;
rpnp = 0;
@@ -232,7 +233,7 @@ Patch(void)
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",