ref: 87c9d819a16186785d4e7460b3ab0458efbcb013
parent: 13c0684497bc45fcea983b176aaaf2809c3066dc
author: Antonio Niño Díaz <[email protected]>
date: Sun Dec 31 08:59:17 EST 2017
Replace SLONG by int32_t All affected `printf` have been fixed. Signed-off-by: Antonio Niño Díaz <[email protected]>
--- a/include/asm/asm.h
+++ b/include/asm/asm.h
@@ -10,6 +10,7 @@
#define RGBDS_ASM_ASM_H
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -22,7 +23,7 @@
#define MAXMACROARGS 256
#define MAXINCPATHS 128
-extern SLONG nLineNo;
+extern int32_t nLineNo;
extern ULONG nTotalLines;
extern ULONG nPC;
extern ULONG nPass;
--- a/include/asm/fstack.h
+++ b/include/asm/fstack.h
@@ -9,6 +9,7 @@
#ifndef RGBDS_ASM_FSTACK_H
#define RGBDS_ASM_FSTACK_H
+#include <stdint.h>
#include <stdio.h>
#include "asm/asm.h"
@@ -21,7 +22,7 @@
struct sContext *pNext;
char tzFileName[_MAX_PATH + 1];
char *tzMacroArgs[MAXMACROARGS + 1];
- SLONG nLine;
+ int32_t nLine;
ULONG nStatus;
FILE *pFile;
char *pREPTBlock;
@@ -31,7 +32,7 @@
void
fstk_RunInclude(char *);
-extern void fstk_RunMacroArg(SLONG s);
+extern void fstk_RunMacroArg(int32_t s);
void
fstk_Init(char *);
extern void fstk_Dump(void);
--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -1,6 +1,7 @@
-#ifndef RGBDS_MAIN_H
-#define RGBDS_MAIN_H
+#ifndef RGBDS_MAIN_H
+#define RGBDS_MAIN_H
+#include <stdint.h>
#include <stdbool.h>
#include "extern/stdnoreturn.h"
@@ -7,7 +8,7 @@
struct sOptions {
char gbgfx[4];
char binary[2];
- SLONG fillchar;
+ int32_t fillchar;
bool verbose;
bool haltnop;
bool exportall;
@@ -17,8 +18,8 @@
extern char *tzNewMacro;
extern ULONG ulNewMacroSize;
-extern SLONG nGBGfxID;
-extern SLONG nBinaryID;
+extern int32_t nGBGfxID;
+extern int32_t nBinaryID;
extern struct sOptions DefaultOptions;
extern struct sOptions CurrentOptions;
--- a/include/asm/mymath.h
+++ b/include/asm/mymath.h
@@ -1,21 +1,21 @@
#ifndef RGBDS_ASM_MATH_H
#define RGBDS_ASM_MATH_H
-#include "types.h"
+#include <stdint.h>
void math_DefinePI(void);
-void math_Print(SLONG i);
-SLONG math_Sin(SLONG i);
-SLONG math_Cos(SLONG i);
-SLONG math_Tan(SLONG i);
-SLONG math_ASin(SLONG i);
-SLONG math_ACos(SLONG i);
-SLONG math_ATan(SLONG i);
-SLONG math_ATan2(SLONG i, SLONG j);
-SLONG math_Mul(SLONG i, SLONG j);
-SLONG math_Div(SLONG i, SLONG j);
-SLONG math_Round(SLONG i);
-SLONG math_Ceil(SLONG i);
-SLONG math_Floor(SLONG i);
+void math_Print(int32_t i);
+int32_t math_Sin(int32_t i);
+int32_t math_Cos(int32_t i);
+int32_t math_Tan(int32_t i);
+int32_t math_ASin(int32_t i);
+int32_t math_ACos(int32_t i);
+int32_t math_ATan(int32_t i);
+int32_t math_ATan2(int32_t i, int32_t j);
+int32_t math_Mul(int32_t i, int32_t j);
+int32_t math_Div(int32_t i, int32_t j);
+int32_t math_Round(int32_t i);
+int32_t math_Ceil(int32_t i);
+int32_t math_Floor(int32_t i);
#endif
--- a/include/asm/output.h
+++ b/include/asm/output.h
@@ -22,8 +22,8 @@
void out_PrepPass2(void);
void out_SetFileName(char *s);
void out_NewSection(char *pzName, ULONG secttype);
-void out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank);
-void out_NewAlignedSection(char *pzName, ULONG secttype, SLONG alignment, SLONG bank);
+void out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank);
+void out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank);
void out_AbsByte(int b);
void out_AbsByteGroup(char *s, int length);
void out_RelByte(struct Expression * expr);
@@ -32,9 +32,9 @@
void out_WriteObject(void);
void out_Skip(int skip);
void out_BinaryFile(char *s);
-void out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length);
+void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length);
void out_String(char *s);
-void out_AbsLong(SLONG b);
+void out_AbsLong(int32_t b);
void out_RelLong(struct Expression * expr);
void out_PushSection(void);
void out_PopSection(void);
--- a/include/asm/rpn.h
+++ b/include/asm/rpn.h
@@ -4,7 +4,7 @@
#include <stdint.h>
struct Expression {
- SLONG nVal;
+ int32_t nVal;
uint8_t tRPN[256];
ULONG nRPNLength;
ULONG nRPNOut;
--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -10,7 +10,7 @@
struct sSymbol {
char tzName[MAXSYMLEN + 1];
- SLONG nValue;
+ int32_t nValue;
ULONG nType;
struct sSymbol *pScope;
struct sSymbol *pNext;
@@ -17,7 +17,7 @@
struct Section *pSection;
ULONG ulMacroSize;
char *pMacro;
- SLONG(*Callback) (struct sSymbol *);
+ int32_t(*Callback) (struct sSymbol *);
char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
ULONG nFileLine; /* Line where the symbol was defined. */
};
@@ -54,14 +54,14 @@
void sym_RestoreCurrentMacroArgs(char *save[]);
void sym_UseNewMacroArgs(void);
void sym_FreeCurrentMacroArgs(void);
-void sym_AddEqu(char *tzSym, SLONG value);
-void sym_AddSet(char *tzSym, SLONG value);
+void sym_AddEqu(char *tzSym, int32_t value);
+void sym_AddSet(char *tzSym, int32_t value);
void sym_Init(void);
ULONG sym_GetConstantValue(char *s);
ULONG sym_isConstant(char *s);
struct sSymbol *sym_FindSymbol(char *tzName);
void sym_Global(char *tzSym);
-char *sym_FindMacroArg(SLONG i);
+char *sym_FindMacroArg(int32_t i);
char *sym_GetStringValue(char *tzSym);
void sym_UseCurrentMacroArgs(void);
void sym_SetMacroArgID(ULONG nMacroCount);
--- a/include/link/assign.h
+++ b/include/link/assign.h
@@ -1,6 +1,8 @@
#ifndef RGBDS_LINK_ASSIGN_H
#define RGBDS_LINK_ASSIGN_H
+#include <stdint.h>
+
#include "mylink.h"
#include "types.h"
@@ -29,11 +31,11 @@
#define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \
+ BANK_COUNT_VRAM + BANK_COUNT_OAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM)
-extern SLONG area_Avail(SLONG bank);
+extern int32_t area_Avail(int32_t bank);
extern void AssignSections(void);
extern void CreateSymbolTable(void);
-extern SLONG MaxBankUsed;
-extern SLONG MaxAvail[MAXBANKS];
+extern int32_t MaxBankUsed;
+extern int32_t MaxAvail[MAXBANKS];
int
IsSectionNameInUse(const char *name);
--- a/include/link/library.h
+++ b/include/link/library.h
@@ -1,5 +1,5 @@
-#ifndef RGBDS_LINK_LIBRARY_H
-#define RGBDS_LINK_LIBRARY_H
+#ifndef RGBDS_LINK_LIBRARY_H
+#define RGBDS_LINK_LIBRARY_H
extern void AddNeededModules(void);
--- a/include/link/main.h
+++ b/include/link/main.h
@@ -1,9 +1,9 @@
#ifndef RGBDS_LINK_MAIN_H
#define RGBDS_LINK_MAIN_H
-#include "types.h"
+#include <stdint.h>
-extern SLONG fillchar;
+extern int32_t fillchar;
extern char *smartlinkstartsymbol;
#endif
--- a/include/link/mapfile.h
+++ b/include/link/mapfile.h
@@ -1,11 +1,13 @@
-#ifndef RGBDS_LINK_MAPFILE_H
-#define RGBDS_LINK_MAPFILE_H
+#ifndef RGBDS_LINK_MAPFILE_H
+#define RGBDS_LINK_MAPFILE_H
+#include <stdint.h>
+
extern void SetMapfileName(char *name);
extern void SetSymfileName(char *name);
extern void CloseMapfile(void);
extern void MapfileWriteSection(struct sSection * pSect);
-extern void MapfileInitBank(SLONG bank);
-extern void MapfileCloseBank(SLONG slack);
+extern void MapfileInitBank(int32_t bank);
+extern void MapfileCloseBank(int32_t slack);
#endif
--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -9,7 +9,7 @@
#include "types.h"
-extern SLONG options;
+extern int32_t options;
#define OPT_TINY 0x01
#define OPT_SMART_C_LINK 0x02
#define OPT_OVERLAY 0x04
@@ -63,16 +63,16 @@
};
struct sSection {
- SLONG nBank;
- SLONG nOrg;
- SLONG nAlign;
+ int32_t nBank;
+ int32_t nOrg;
+ int32_t nAlign;
uint8_t oAssigned;
char *pzName;
- SLONG nByteSize;
+ int32_t nByteSize;
enum eSectionType Type;
uint8_t *pData;
- SLONG nNumberOfSymbols;
+ int32_t nNumberOfSymbols;
struct sSymbol **tSymbols;
struct sPatch *pPatches;
struct sSection *pNext;
@@ -88,9 +88,9 @@
char *pzName;
enum eSymbolType Type;
/* the following 3 items only valid when Type!=SYM_IMPORT */
- SLONG nSectionID; /* internal to object.c */
+ int32_t nSectionID; /* internal to object.c */
struct sSection *pSection;
- SLONG nOffset;
+ int32_t nOffset;
char *pzObjFileName; /* Object file where the symbol is located. */
char *pzFileName; /* Source file where the symbol was defined. */
ULONG nFileLine; /* Line where the symbol was defined. */
@@ -104,10 +104,10 @@
struct sPatch {
char *pzFilename;
- SLONG nLineNo;
- SLONG nOffset;
+ int32_t nLineNo;
+ int32_t nOffset;
enum ePatchType Type;
- SLONG nRPNSize;
+ int32_t nRPNSize;
uint8_t *pRPN;
struct sPatch *pNext;
uint8_t oRelocPatch;
--- a/include/link/patch.h
+++ b/include/link/patch.h
@@ -1,9 +1,9 @@
#ifndef RGBDS_LINK_PATCH_H
#define RGBDS_LINK_PATCH_H
-#include "types.h"
+#include <stdint.h>
void Patch(void);
-extern SLONG nPC;
+extern int32_t nPC;
#endif
--- a/include/link/symbol.h
+++ b/include/link/symbol.h
@@ -1,12 +1,14 @@
#ifndef RGBDS_LINK_SYMBOL_H
#define RGBDS_LINK_SYMBOL_H
+#include <stdint.h>
+
#include "types.h"
void sym_Init(void);
-void sym_CreateSymbol(char *tzName, SLONG nValue, SLONG nBank,
+void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
char *tzObjFileName, char *tzFileName, ULONG nFileLine);
-SLONG sym_GetValue(char *tzName);
-SLONG sym_GetBank(char *tzName);
+int32_t sym_GetValue(char *tzName);
+int32_t sym_GetBank(char *tzName);
#endif
--- a/include/types.h
+++ b/include/types.h
@@ -6,6 +6,5 @@
#endif
typedef unsigned long ULONG;
-typedef signed long SLONG;
#endif
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -22,9 +22,9 @@
ULONG ulNewMacroSize;
void
-bankrangecheck(char *name, ULONG secttype, SLONG org, SLONG bank)
+bankrangecheck(char *name, ULONG secttype, int32_t org, int32_t bank)
{
- SLONG minbank = 0, maxbank = 0;
+ int32_t minbank = 0, maxbank = 0;
char *stype = NULL;
switch (secttype) {
case SECT_ROMX:
@@ -140,7 +140,7 @@
void copyrept( void )
{
- SLONG level=1, len, instring=0;
+ int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
@@ -220,7 +220,7 @@
void copymacro( void )
{
- SLONG level=1, len, instring=0;
+ int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
@@ -312,7 +312,7 @@
void if_skip_to_else()
{
- SLONG level = 1;
+ int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -367,7 +367,7 @@
fatalerror("Unterminated IF construct");
}
- SLONG len = src - pCurrentBuffer->pBuffer;
+ int32_t len = src - pCurrentBuffer->pBuffer;
yyskipbytes(len);
yyunput('\n');
@@ -376,7 +376,7 @@
void if_skip_to_endc()
{
- SLONG level = 1;
+ int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -425,7 +425,7 @@
fatalerror("Unterminated IF construct");
}
- SLONG len = src - pCurrentBuffer->pBuffer;
+ int32_t len = src - pCurrentBuffer->pBuffer;
yyskipbytes(len);
yyunput('\n');
@@ -467,7 +467,7 @@
char tzSym[MAXSYMLEN + 1];
char tzString[MAXSTRLEN + 1];
struct Expression sVal;
- SLONG nConstValue;
+ int32_t nConstValue;
}
%type <sVal> relocconst
@@ -922,7 +922,7 @@
printv : T_POP_PRINTV const
{
if( nPass==1 )
- printf( "$%lX", $2 );
+ printf( "$%X", $2 );
}
;
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -28,7 +28,7 @@
ULONG nCurrentStatus;
char tzCurrentFileName[_MAX_PATH + 1];
char IncludePaths[MAXINCPATHS][_MAX_PATH + 1];
-SLONG NextIncPath = 0;
+int32_t NextIncPath = 0;
ULONG nMacroCount;
char *pCurrentREPTBlock;
@@ -200,12 +200,12 @@
pLastFile = pFileStack;
while (pLastFile) {
- fprintf(stderr, "%s(%ld) -> ", pLastFile->tzFileName,
- pLastFile->nLine);
+ fprintf(stderr, "%s(%d) -> ", pLastFile->tzFileName,
+ pLastFile->nLine);
pLastFile = pLastFile->pNext;
}
- fprintf(stderr, "%s(%ld)", tzCurrentFileName, nLineNo);
+ fprintf(stderr, "%s(%d)", tzCurrentFileName, nLineNo);
}
/*
@@ -320,7 +320,7 @@
* Set up a macroargument for parsing
*/
void
-fstk_RunMacroArg(SLONG s)
+fstk_RunMacroArg(int32_t s)
{
char *sym;
--- a/src/asm/globlex.c
+++ b/src/asm/globlex.c
@@ -8,6 +8,7 @@
#include "asmy.h"
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -14,13 +15,13 @@
#include <string.h>
bool oDontExpandStrings = false;
-SLONG nGBGfxID = -1;
-SLONG nBinaryID = -1;
+int32_t nGBGfxID = -1;
+int32_t nBinaryID = -1;
-SLONG
+int32_t
gbgfx2bin(char ch)
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= 3; i += 1) {
if (CurrentOptions.gbgfx[i] == ch) {
@@ -31,10 +32,10 @@
return (0);
}
-SLONG
+int32_t
binary2bin(char ch)
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= 1; i += 1) {
if (CurrentOptions.binary[i] == ch) {
@@ -45,7 +46,7 @@
return (0);
}
-SLONG
+int32_t
char2bin(char ch)
{
if (ch >= 'a' && ch <= 'f')
@@ -60,13 +61,13 @@
return (0);
}
-typedef SLONG(*x2bin) (char ch);
+typedef int32_t(*x2bin) (char ch);
-SLONG
+int32_t
ascii2bin(char *s)
{
- SLONG radix = 10;
- SLONG result = 0;
+ int32_t radix = 10;
+ int32_t result = 0;
x2bin convertfunc = char2bin;
switch (*s) {
@@ -93,7 +94,7 @@
}
if (radix == 4) {
- SLONG c;
+ int32_t c;
while (*s != '\0') {
c = convertfunc(*s++);
@@ -128,7 +129,7 @@
yyunputbytes(size);
- yylval.nConstValue = (SLONG) (atof(s) * 65536);
+ yylval.nConstValue = (int32_t) (atof(s) * 65536);
return (1);
}
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -1,6 +1,7 @@
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -22,7 +23,7 @@
char **cldefines;
clock_t nStartClock, nEndClock;
-SLONG nLineNo;
+int32_t nLineNo;
ULONG nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors;
bool skipElif;
ULONG unionStart[128], unionSize[128];
@@ -141,7 +142,7 @@
if (strlen(&s[1]) <= 2) {
int result;
- result = sscanf(&s[1], "%lx", &newopt.fillchar);
+ result = sscanf(&s[1], "%x", &newopt.fillchar);
if (!((result == EOF) || (result == 1))) {
errx(1, "Invalid argument for option 'z'");
}
--- a/src/asm/math.c
+++ b/src/asm/math.c
@@ -3,6 +3,7 @@
*/
#include <math.h>
+#include <stdint.h>
#include <stdio.h>
#include "types.h"
@@ -10,7 +11,7 @@
#include "asm/symbol.h"
#define fix2double(i) ((double)(i/65536.0))
-#define double2fix(d) ((SLONG)(d*65536.0))
+#define double2fix(d) ((int32_t)(d*65536.0))
#ifndef PI
#define PI (acos(-1))
#endif
@@ -28,21 +29,21 @@
* Print a fixed point value
*/
void
-math_Print(SLONG i)
+math_Print(int32_t i)
{
if (i >= 0)
- printf("%ld.%05ld", i >> 16,
- ((SLONG) (fix2double(i) * 100000 + 0.5)) % 100000);
+ printf("%d.%05d", i >> 16,
+ ((int32_t) (fix2double(i) * 100000 + 0.5)) % 100000);
else
- printf("-%ld.%05ld", (-i) >> 16,
- ((SLONG) (fix2double(-i) * 100000 + 0.5)) % 100000);
+ printf("-%d.%05d", (-i) >> 16,
+ ((int32_t) (fix2double(-i) * 100000 + 0.5)) % 100000);
}
/*
* Calculate sine
*/
-SLONG
-math_Sin(SLONG i)
+int32_t
+math_Sin(int32_t i)
{
return (double2fix(sin(fix2double(i) * 2 * PI / 65536)));
}
@@ -50,8 +51,8 @@
/*
* Calculate cosine
*/
-SLONG
-math_Cos(SLONG i)
+int32_t
+math_Cos(int32_t i)
{
return (double2fix(cos(fix2double(i) * 2 * PI / 65536)));
}
@@ -59,8 +60,8 @@
/*
* Calculate tangent
*/
-SLONG
-math_Tan(SLONG i)
+int32_t
+math_Tan(int32_t i)
{
return (double2fix(tan(fix2double(i) * 2 * PI / 65536)));
}
@@ -68,8 +69,8 @@
/*
* Calculate arcsine
*/
-SLONG
-math_ASin(SLONG i)
+int32_t
+math_ASin(int32_t i)
{
return (double2fix(asin(fix2double(i)) / 2 / PI * 65536));
}
@@ -77,8 +78,8 @@
/*
* Calculate arccosine
*/
-SLONG
-math_ACos(SLONG i)
+int32_t
+math_ACos(int32_t i)
{
return (double2fix(acos(fix2double(i)) / 2 / PI * 65536));
}
@@ -86,8 +87,8 @@
/*
* Calculate arctangent
*/
-SLONG
-math_ATan(SLONG i)
+int32_t
+math_ATan(int32_t i)
{
return (double2fix(atan(fix2double(i)) / 2 / PI * 65536));
}
@@ -95,8 +96,8 @@
/*
* Calculate atan2
*/
-SLONG
-math_ATan2(SLONG i, SLONG j)
+int32_t
+math_ATan2(int32_t i, int32_t j)
{
return (double2fix
(atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536));
@@ -105,8 +106,8 @@
/*
* Multiplication
*/
-SLONG
-math_Mul(SLONG i, SLONG j)
+int32_t
+math_Mul(int32_t i, int32_t j)
{
return (double2fix(fix2double(i) * fix2double(j)));
}
@@ -114,8 +115,8 @@
/*
* Division
*/
-SLONG
-math_Div(SLONG i, SLONG j)
+int32_t
+math_Div(int32_t i, int32_t j)
{
return (double2fix(fix2double(i) / fix2double(j)));
}
@@ -123,8 +124,8 @@
/*
* Round
*/
-SLONG
-math_Round(SLONG i)
+int32_t
+math_Round(int32_t i)
{
return double2fix(round(fix2double(i)));
}
@@ -132,8 +133,8 @@
/*
* Ceil
*/
-SLONG
-math_Ceil(SLONG i)
+int32_t
+math_Ceil(int32_t i)
{
return double2fix(ceil(fix2double(i)));
}
@@ -141,8 +142,8 @@
/*
* Floor
*/
-SLONG
-math_Floor(SLONG i)
+int32_t
+math_Floor(int32_t i)
{
return double2fix(floor(fix2double(i)));
}
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -253,7 +253,7 @@
char symname[MAXSYMLEN * 2 + 1];
ULONG type;
ULONG offset;
- SLONG sectid;
+ int32_t sectid;
if (pSym->nType & SYMF_IMPORT) {
/* Symbol should be imported */
@@ -564,7 +564,7 @@
* Find a section by name and type. If it doesn't exist, create it
*/
struct Section *
-out_FindSection(char *pzName, ULONG secttype, SLONG org, SLONG bank, SLONG alignment)
+out_FindSection(char *pzName, ULONG secttype, int32_t org, int32_t bank, int32_t alignment)
{
struct Section *pSect, **ppSect;
@@ -646,7 +646,7 @@
* Set the current section by name and type
*/
void
-out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank)
+out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank)
{
out_SetCurrentSection(out_FindSection(pzName, secttype, org, bank, 1));
}
@@ -655,7 +655,7 @@
* Set the current section by name and type, using a given byte alignment
*/
void
-out_NewAlignedSection(char *pzName, ULONG secttype, SLONG alignment, SLONG bank)
+out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank)
{
if (alignment < 0 || alignment > 16) {
yyerror("Alignment must be between 0-16 bits.");
@@ -805,10 +805,10 @@
* Output an absolute longword
*/
void
-out_AbsLong(SLONG b)
+out_AbsLong(int32_t b)
{
checkcodesection();
- checksectionoverflow(sizeof(SLONG));
+ checksectionoverflow(sizeof(int32_t));
if (nPass == 2) {
pCurrentSection->tData[nPC] = b & 0xFF;
pCurrentSection->tData[nPC + 1] = b >> 8;
@@ -827,7 +827,7 @@
void
out_RelLong(struct Expression * expr)
{
- SLONG b;
+ int32_t b;
checkcodesection();
checksectionoverflow(4);
@@ -854,7 +854,7 @@
void
out_PCRelByte(struct Expression * expr)
{
- SLONG b = expr->nVal;
+ int32_t b = expr->nVal;
checkcodesection();
checksectionoverflow(1);
@@ -879,7 +879,7 @@
err(1, "Unable to open incbin file '%s'", s);
}
- SLONG fsize;
+ int32_t fsize;
fseek(f, 0, SEEK_END);
fsize = ftell(f);
@@ -889,8 +889,8 @@
checksectionoverflow(fsize);
if (nPass == 2) {
- SLONG dest = nPC;
- SLONG todo = fsize;
+ int32_t dest = nPC;
+ int32_t todo = fsize;
while (todo--)
pCurrentSection->tData[dest++] = fgetc(f);
@@ -902,7 +902,7 @@
}
void
-out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
+out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length)
{
FILE *f;
@@ -917,7 +917,7 @@
err(1, "Unable to open included file '%s'", s);
}
- SLONG fsize;
+ int32_t fsize;
fseek(f, 0, SEEK_END);
fsize = ftell(f);
@@ -934,8 +934,8 @@
checksectionoverflow(length);
if (nPass == 2) {
- SLONG dest = nPC;
- SLONG todo = length;
+ int32_t dest = nPC;
+ int32_t todo = length;
while (todo--)
pCurrentSection->tData[dest++] = fgetc(f);
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -51,7 +51,7 @@
memmove(string, new_beginning, strlen(new_beginning) + 1);
}
-SLONG
+int32_t
Callback_NARG(struct sSymbol * sym)
{
ULONG i = 0;
@@ -62,7 +62,7 @@
return (i);
}
-SLONG
+int32_t
Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
{
return (nLineNo);
@@ -71,7 +71,7 @@
/*
* Get the nValue field of a symbol
*/
-SLONG
+int32_t
getvaluefield(struct sSymbol * sym)
{
if (sym->Callback) {
@@ -145,7 +145,7 @@
findpsymbol(char *s, struct sSymbol * scope)
{
struct sSymbol **ppsym;
- SLONG hash;
+ int32_t hash;
char fullname[MAXSYMLEN + 1];
if (s[0] == '.' && scope) {
@@ -411,7 +411,7 @@
void
sym_ShiftCurrentMacroArgs(void)
{
- SLONG i;
+ int32_t i;
free(currentmacroargs[0]);
for (i = 0; i < MAXMACROARGS - 1; i += 1) {
@@ -421,7 +421,7 @@
}
char *
-sym_FindMacroArg(SLONG i)
+sym_FindMacroArg(int32_t i)
{
if (i == -1)
i = MAXMACROARGS + 1;
@@ -435,7 +435,7 @@
void
sym_UseNewMacroArgs(void)
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
currentmacroargs[i] = newmacroargs[i];
@@ -446,7 +446,7 @@
void
sym_SaveCurrentMacroArgs(char *save[])
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1)
save[i] = currentmacroargs[i];
@@ -455,7 +455,7 @@
void
sym_RestoreCurrentMacroArgs(char *save[])
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1)
currentmacroargs[i] = save[i];
@@ -464,7 +464,7 @@
void
sym_FreeCurrentMacroArgs(void)
{
- SLONG i;
+ int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
free(currentmacroargs[i]);
@@ -475,7 +475,7 @@
void
sym_AddNewMacroArg(char *s)
{
- SLONG i = 0;
+ int32_t i = 0;
while (i < MAXMACROARGS && newmacroargs[i] != NULL)
i += 1;
@@ -501,7 +501,7 @@
void
sym_UseCurrentMacroArgs(void)
{
- SLONG i;
+ int32_t i;
for (i = 1; i <= MAXMACROARGS; i += 1)
sym_AddNewMacroArg(sym_FindMacroArg(i));
@@ -520,7 +520,7 @@
* Add an equated symbol
*/
void
-sym_AddEqu(char *tzSym, SLONG value)
+sym_AddEqu(char *tzSym, int32_t value)
{
if ((nPass == 1)
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
@@ -598,7 +598,7 @@
* Alter a SET symbols value
*/
void
-sym_AddSet(char *tzSym, SLONG value)
+sym_AddSet(char *tzSym, int32_t value)
{
struct sSymbol *nsym;
@@ -834,7 +834,7 @@
void
sym_PrepPass2(void)
{
- SLONG i;
+ int32_t i;
for (i = 0; i < HASHSIZE; i += 1) {
struct sSymbol **ppSym = &(tHashedSymbols[i]);
@@ -885,7 +885,7 @@
void
sym_Init(void)
{
- SLONG i;
+ int32_t i;
time_t now;
for (i = 0; i < MAXMACROARGS; i += 1) {
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -11,25 +12,25 @@
#include "link/symbol.h"
struct sFreeArea {
- SLONG nOrg;
- SLONG nSize;
+ int32_t nOrg;
+ int32_t nSize;
struct sFreeArea *pPrev, *pNext;
};
struct sSectionAttributes {
const char *name;
- SLONG bank;
- SLONG offset; // bank + offset = bank originally stored in a section struct
- SLONG minBank;
- SLONG bankCount;
+ int32_t bank;
+ int32_t offset; // bank + offset = bank originally stored in a section struct
+ int32_t minBank;
+ int32_t bankCount;
};
struct sFreeArea *BankFree[MAXBANKS];
-SLONG MaxAvail[MAXBANKS];
-SLONG MaxBankUsed;
-SLONG MaxWBankUsed;
-SLONG MaxSBankUsed;
-SLONG MaxVBankUsed;
+int32_t MaxAvail[MAXBANKS];
+int32_t MaxBankUsed;
+int32_t MaxWBankUsed;
+int32_t MaxSBankUsed;
+int32_t MaxVBankUsed;
const enum eSectionType SECT_MIN = SECT_WRAM0;
const enum eSectionType SECT_MAX = SECT_OAM;
@@ -63,10 +64,10 @@
}
}
-SLONG
-area_Avail(SLONG bank)
+int32_t
+area_Avail(int32_t bank)
{
- SLONG r;
+ int32_t r;
struct sFreeArea *pArea;
r = 0;
@@ -80,8 +81,8 @@
return (r);
}
-SLONG
-area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
+int32_t
+area_doAlloc(struct sFreeArea *pArea, int32_t org, int32_t size)
{
if (org >= pArea->nOrg && (org + size) <= (pArea->nOrg + pArea->nSize)) {
if (org == pArea->nOrg) {
@@ -114,14 +115,14 @@
return -1;
}
-SLONG
-area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
+int32_t
+area_AllocAbs(struct sFreeArea ** ppArea, int32_t org, int32_t size)
{
struct sFreeArea *pArea;
pArea = *ppArea;
while (pArea) {
- SLONG result = area_doAlloc(pArea, org, size);
+ int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) {
return result;
}
@@ -133,13 +134,13 @@
return -1;
}
-SLONG
-area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
+int32_t
+area_AllocAbsAnyBank(int32_t org, int32_t size, enum eSectionType type)
{
ensureSectionTypeIsValid(type);
- SLONG startBank = SECT_ATTRIBUTES[type].bank;
- SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
+ int32_t startBank = SECT_ATTRIBUTES[type].bank;
+ int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
@@ -150,8 +151,8 @@
return -1;
}
-SLONG
-area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
+int32_t
+area_Alloc(struct sFreeArea ** ppArea, int32_t size, int32_t alignment) {
struct sFreeArea *pArea;
if (alignment < 1) {
alignment = 1;
@@ -159,13 +160,13 @@
pArea = *ppArea;
while (pArea) {
- SLONG org = pArea->nOrg;
+ int32_t org = pArea->nOrg;
if (org % alignment) {
org += alignment;
}
org -= org % alignment;
- SLONG result = area_doAlloc(pArea, org, size);
+ int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) {
return result;
}
@@ -177,15 +178,15 @@
return -1;
}
-SLONG
-area_AllocAnyBank(SLONG size, SLONG alignment, enum eSectionType type) {
+int32_t
+area_AllocAnyBank(int32_t size, int32_t alignment, enum eSectionType type) {
ensureSectionTypeIsValid(type);
- SLONG startBank = SECT_ATTRIBUTES[type].bank;
- SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
+ int32_t startBank = SECT_ATTRIBUTES[type].bank;
+ int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
- SLONG org = area_Alloc(&BankFree[startBank + i], size, alignment);
+ int32_t org = area_Alloc(&BankFree[startBank + i], size, alignment);
if (org != -1) {
return ((startBank + i) << 16) | org;
}
@@ -198,8 +199,8 @@
FindLargestSection(enum eSectionType type, bool bankFixed)
{
struct sSection *pSection, *r = NULL;
- SLONG nLargest = 0;
- SLONG nLargestAlignment = 0;
+ int32_t nLargest = 0;
+ int32_t nLargestAlignment = 0;
pSection = pSections;
while (pSection) {
@@ -332,7 +333,7 @@
struct sSection *pSection;
while ((pSection = FindLargestSection(type, false))) {
- SLONG org;
+ int32_t org;
if ((org = area_AllocAnyBank(pSection->nByteSize, pSection->nAlign, type)) != -1) {
if (options & OPT_OVERLAY) {
@@ -370,7 +371,7 @@
void
AssignSections(void)
{
- SLONG i;
+ int32_t i;
struct sSection *pSection;
MaxBankUsed = 0;
@@ -557,7 +558,7 @@
pSect = pSections;
while (pSect) {
- SLONG i;
+ int32_t i;
i = pSect->nNumberOfSymbols;
--- a/src/link/main.c
+++ b/src/link/main.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -21,8 +22,8 @@
BLOCK_OUTPUT
};
-SLONG options = 0;
-SLONG fillchar = 0;
+int32_t options = 0;
+int32_t fillchar = 0;
char *smartlinkstartsymbol;
/*
--- a/src/link/mapfile.c
+++ b/src/link/mapfile.c
@@ -1,4 +1,5 @@
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -10,8 +11,8 @@
FILE *mf = NULL;
FILE *sf = NULL;
-SLONG currentbank = 0;
-SLONG sfbank;
+int32_t currentbank = 0;
+int32_t sfbank;
void
SetMapfileName(char *name)
@@ -49,7 +50,7 @@
}
void
-MapfileInitBank(SLONG bank)
+MapfileInitBank(int32_t bank)
{
if (mf) {
currentbank = bank;
@@ -56,19 +57,19 @@
if (bank == BANK_ROM0)
fprintf(mf, "ROM Bank #0 (HOME):\n");
else if (bank < BANK_WRAM0)
- fprintf(mf, "ROM Bank #%ld:\n", bank);
+ fprintf(mf, "ROM Bank #%d:\n", bank);
else if (bank == BANK_WRAM0)
fprintf(mf, "WRAM Bank #0:\n");
else if (bank < BANK_VRAM)
- fprintf(mf, "WRAM Bank #%ld:\n", bank - BANK_WRAMX + 1);
+ fprintf(mf, "WRAM Bank #%d:\n", bank - BANK_WRAMX + 1);
else if (bank == BANK_HRAM)
fprintf(mf, "HRAM:\n");
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
- fprintf(mf, "VRAM Bank #%ld:\n", bank - BANK_VRAM);
+ fprintf(mf, "VRAM Bank #%d:\n", bank - BANK_VRAM);
else if (bank == BANK_OAM)
fprintf(mf, "OAM:\n");
else if (bank < MAXBANKS)
- fprintf(mf, "SRAM Bank #%ld:\n", bank - BANK_SRAM);
+ fprintf(mf, "SRAM Bank #%d:\n", bank - BANK_SRAM);
}
if (sf) {
if (bank < BANK_WRAM0)
@@ -93,15 +94,15 @@
void
MapfileWriteSection(struct sSection * pSect)
{
- SLONG i;
+ int32_t i;
if (mf) {
if (pSect->nByteSize > 0) {
- fprintf(mf, " SECTION: $%04lX-$%04lX ($%04lX bytes) [\"%s\"]\n",
+ fprintf(mf, " SECTION: $%04X-$%04X ($%04X bytes) [\"%s\"]\n",
pSect->nOrg, pSect->nOrg + pSect->nByteSize - 1,
pSect->nByteSize, pSect->pzName);
} else {
- fprintf(mf, " SECTION: $%04lX ($0 bytes) [\"%s\"]\n",
+ fprintf(mf, " SECTION: $%04X ($0 bytes) [\"%s\"]\n",
pSect->nOrg, pSect->pzName);
}
}
@@ -112,12 +113,12 @@
if ((pSym->pSection == pSect)
&& (pSym->Type != SYM_IMPORT)) {
if (mf) {
- fprintf(mf, " $%04lX = %s\n",
+ fprintf(mf, " $%04X = %s\n",
pSym->nOffset + pSect->nOrg,
pSym->pzName);
}
if (sf) {
- fprintf(sf, "%02lX:%04lX %s\n", sfbank,
+ fprintf(sf, "%02X:%04X %s\n", sfbank,
pSym->nOffset + pSect->nOrg,
pSym->pzName);
}
@@ -126,7 +127,7 @@
}
void
-MapfileCloseBank(SLONG slack)
+MapfileCloseBank(int32_t slack)
{
if (!mf)
return;
@@ -134,5 +135,5 @@
if (slack == MaxAvail[currentbank])
fprintf(mf, " EMPTY\n\n");
else
- fprintf(mf, " SLACK: $%04lX bytes\n\n", slack);
+ fprintf(mf, " SLACK: $%04X bytes\n\n", slack);
}
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -27,10 +27,10 @@
*
*/
-SLONG
+int32_t
readlong(FILE * f)
{
- SLONG r;
+ int32_t r;
r = fgetc(f);
r |= fgetc(f) << 8;
@@ -55,7 +55,7 @@
* Read a NULL terminated string from a file
*
*/
-SLONG
+int32_t
readasciiz(char **dest, FILE *f)
{
size_t r = 0;
@@ -226,7 +226,7 @@
err(1, NULL);
}
- SLONG nNumberOfPatches;
+ int32_t nNumberOfPatches;
struct sPatch **ppPatch, *pPatch;
if (fread(pSection->pData, sizeof(uint8_t),
@@ -281,7 +281,7 @@
obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
{
struct sSection *pFirstSection;
- SLONG nNumberOfSymbols, nNumberOfSections, i;
+ int32_t nNumberOfSymbols, nNumberOfSections, i;
nNumberOfSymbols = readlong(pObjfile);
nNumberOfSections = readlong(pObjfile);
@@ -322,7 +322,7 @@
if (tSymbols[i]->Type != SYM_IMPORT
&& tSymbols[i]->nSectionID != -1) {
- SLONG j = 0;
+ int32_t j = 0;
while (j != tSymbols[i]->nSectionID) {
j += 1;
pConvSect = pConvSect->pNext;
@@ -381,7 +381,7 @@
oReadLib = 0;
}
-SLONG
+int32_t
file_Length(FILE * f)
{
ULONG r, p;
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -10,24 +10,24 @@
#include "link/main.h"
struct sSection *pCurrentSection;
-SLONG rpnstack[256];
-SLONG rpnp;
-SLONG nPC;
+int32_t rpnstack[256];
+int32_t rpnp;
+int32_t nPC;
void
-rpnpush(SLONG i)
+rpnpush(int32_t i)
{
rpnstack[rpnp++] = i;
}
-SLONG
+int32_t
rpnpop(void)
{
return (rpnstack[--rpnp]);
}
-SLONG
-getsymvalue(SLONG symid)
+int32_t
+getsymvalue(int32_t symid)
{
switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT:
@@ -52,10 +52,10 @@
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
}
-SLONG
-getsymbank(SLONG symid)
+int32_t
+getsymbank(int32_t symid)
{
- SLONG nBank;
+ int32_t nBank;
switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT:
@@ -83,10 +83,10 @@
return nBank;
}
-SLONG
+int32_t
calcrpn(struct sPatch * pPatch)
{
- SLONG t, size;
+ int32_t t, size;
uint8_t *rpn;
rpnp = 0;
@@ -224,7 +224,7 @@
pCurrentSection = pSect;
pPatch = pSect->pPatches;
while (pPatch) {
- SLONG t;
+ int32_t t;
nPC = pSect->nOrg + pPatch->nOffset;
t = calcrpn(pPatch);
--- a/src/link/symbol.c
+++ b/src/link/symbol.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -11,8 +12,8 @@
struct ISymbol {
char *pzName;
- SLONG nValue;
- SLONG nBank; /* -1 = constant */
+ int32_t nValue;
+ int32_t nBank; /* -1 = constant */
char tzObjFileName[_MAX_PATH + 1]; /* Object file where the symbol was defined. */
char tzFileName[_MAX_PATH + 1]; /* Source file where the symbol was defined. */
ULONG nFileLine; /* Line where the symbol was defined. */
@@ -21,10 +22,10 @@
struct ISymbol *tHash[HASHSIZE];
-SLONG
+int32_t
calchash(char *s)
{
- SLONG r = 0;
+ int32_t r = 0;
while (*s)
r += *s++;
@@ -34,12 +35,12 @@
void
sym_Init(void)
{
- SLONG i;
+ int32_t i;
for (i = 0; i < HASHSIZE; i += 1)
tHash[i] = NULL;
}
-SLONG
+int32_t
sym_GetValue(char *tzName)
{
if (strcmp(tzName, "@") == 0) {
@@ -60,7 +61,7 @@
}
}
-SLONG
+int32_t
sym_GetBank(char *tzName)
{
struct ISymbol **ppSym;
@@ -78,7 +79,7 @@
}
void
-sym_CreateSymbol(char *tzName, SLONG nValue, SLONG nBank, char *tzObjFileName,
+sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank, char *tzObjFileName,
char *tzFileName, ULONG nFileLine)
{
if (strcmp(tzName, "@") == 0)