Replace SLONG by int32_t

All affected `printf` have been fixed.

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:59:17 +01:00
parent 13c0684497
commit 87c9d819a1
28 changed files with 247 additions and 232 deletions

View File

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

View File

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

View File

@@ -1,13 +1,14 @@
#ifndef RGBDS_MAIN_H
#define RGBDS_MAIN_H
#include <stdint.h>
#include <stdbool.h>
#include "extern/stdnoreturn.h"
struct sOptions {
char gbgfx[4];
char binary[2];
SLONG fillchar;
int32_t fillchar;
bool verbose;
bool haltnop;
bool exportall;
@@ -17,8 +18,8 @@ struct sOptions {
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;

View File

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

View File

@@ -22,8 +22,8 @@ struct Section {
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_PCRelByte(struct Expression * expr);
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);

View File

@@ -4,7 +4,7 @@
#include <stdint.h>
struct Expression {
SLONG nVal;
int32_t nVal;
uint8_t tRPN[256];
ULONG nRPNLength;
ULONG nRPNOut;

View File

@@ -10,14 +10,14 @@
struct sSymbol {
char tzName[MAXSYMLEN + 1];
SLONG nValue;
int32_t nValue;
ULONG nType;
struct sSymbol *pScope;
struct sSymbol *pNext;
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_SaveCurrentMacroArgs(char *save[]);
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);

View File

@@ -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 @@ enum eBankDefine {
#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);

View File

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

View File

@@ -1,11 +1,13 @@
#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

View File

@@ -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 @@ enum eSectionType {
};
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 @@ struct sSymbol {
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 @@ enum ePatchType {
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;

View File

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

View File

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

View File

@@ -6,6 +6,5 @@
#endif
typedef unsigned long ULONG;
typedef signed long SLONG;
#endif

View File

@@ -22,9 +22,9 @@ char *tzNewMacro;
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 @@ ULONG isEndr( char *s )
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 @@ ULONG isEndm( char *s )
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 @@ ULONG isEndc(char *s)
void if_skip_to_else()
{
SLONG level = 1;
int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -367,7 +367,7 @@ void if_skip_to_else()
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_else()
void if_skip_to_endc()
{
SLONG level = 1;
int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -425,7 +425,7 @@ void if_skip_to_endc()
fatalerror("Unterminated IF construct");
}
SLONG len = src - pCurrentBuffer->pBuffer;
int32_t len = src - pCurrentBuffer->pBuffer;
yyskipbytes(len);
yyunput('\n');
@@ -467,7 +467,7 @@ void updateUnion() {
char tzSym[MAXSYMLEN + 1];
char tzString[MAXSTRLEN + 1];
struct Expression sVal;
SLONG nConstValue;
int32_t nConstValue;
}
%type <sVal> relocconst
@@ -922,7 +922,7 @@ printt : T_POP_PRINTT string
printv : T_POP_PRINTV const
{
if( nPass==1 )
printf( "$%lX", $2 );
printf( "$%X", $2 );
}
;

View File

@@ -28,7 +28,7 @@ FILE *pCurrentFile;
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 @@ fstk_Dump(void)
pLastFile = pFileStack;
while (pLastFile) {
fprintf(stderr, "%s(%ld) -> ", pLastFile->tzFileName,
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 @@ fstk_RunMacro(char *s)
* Set up a macroargument for parsing
*/
void
fstk_RunMacroArg(SLONG s)
fstk_RunMacroArg(int32_t s)
{
char *sym;

View File

@@ -8,19 +8,20 @@
#include "asmy.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#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 @@ gbgfx2bin(char ch)
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 @@ binary2bin(char ch)
return (0);
}
SLONG
int32_t
char2bin(char ch)
{
if (ch >= 'a' && ch <= 'f')
@@ -60,13 +61,13 @@ char2bin(char ch)
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 @@ ascii2bin(char *s)
}
if (radix == 4) {
SLONG c;
int32_t c;
while (*s != '\0') {
c = convertfunc(*s++);
@@ -128,7 +129,7 @@ ParseFixedPoint(char *s, ULONG size)
yyunputbytes(size);
yylval.nConstValue = (SLONG) (atof(s) * 65536);
yylval.nConstValue = (int32_t) (atof(s) * 65536);
return (1);
}

View File

@@ -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 @@ int cldefines_size;
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 @@ opt_Parse(char *s)
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'");
}

View File

@@ -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 @@ math_DefinePI(void)
* 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 @@ math_Sin(SLONG i)
/*
* 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 @@ math_Cos(SLONG i)
/*
* 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 @@ math_Tan(SLONG i)
/*
* 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 @@ math_ASin(SLONG i)
/*
* 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 @@ math_ACos(SLONG i)
/*
* 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 @@ math_ATan(SLONG i)
/*
* 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 @@ math_ATan2(SLONG i, SLONG j)
/*
* 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 @@ math_Mul(SLONG i, SLONG j)
/*
* 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 @@ math_Div(SLONG i, SLONG j)
/*
* Round
*/
SLONG
math_Round(SLONG i)
int32_t
math_Round(int32_t i)
{
return double2fix(round(fix2double(i)));
}
@@ -132,8 +133,8 @@ math_Round(SLONG i)
/*
* Ceil
*/
SLONG
math_Ceil(SLONG i)
int32_t
math_Ceil(int32_t i)
{
return double2fix(ceil(fix2double(i)));
}
@@ -141,8 +142,8 @@ math_Ceil(SLONG i)
/*
* Floor
*/
SLONG
math_Floor(SLONG i)
int32_t
math_Floor(int32_t i)
{
return double2fix(floor(fix2double(i)));
}

View File

@@ -253,7 +253,7 @@ writesymbol(struct sSymbol * pSym, FILE * f)
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 @@ out_SetFileName(char *s)
* 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 @@ out_NewSection(char *pzName, ULONG secttype)
* 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 @@ out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank)
* 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 @@ out_RelWord(struct Expression * expr)
* 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 @@ out_AbsLong(SLONG b)
void
out_RelLong(struct Expression * expr)
{
SLONG b;
int32_t b;
checkcodesection();
checksectionoverflow(4);
@@ -854,7 +854,7 @@ out_RelLong(struct Expression * expr)
void
out_PCRelByte(struct Expression * expr)
{
SLONG b = expr->nVal;
int32_t b = expr->nVal;
checkcodesection();
checksectionoverflow(1);
@@ -879,7 +879,7 @@ out_BinaryFile(char *s)
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 @@ out_BinaryFile(char *s)
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 @@ out_BinaryFile(char *s)
}
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 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
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 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
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);

View File

@@ -51,7 +51,7 @@ void helper_RemoveLeadingZeros(char * string){
memmove(string, new_beginning, strlen(new_beginning) + 1);
}
SLONG
int32_t
Callback_NARG(struct sSymbol * sym)
{
ULONG i = 0;
@@ -62,7 +62,7 @@ Callback_NARG(struct sSymbol * sym)
return (i);
}
SLONG
int32_t
Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
{
return (nLineNo);
@@ -71,7 +71,7 @@ Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
/*
* Get the nValue field of a symbol
*/
SLONG
int32_t
getvaluefield(struct sSymbol * sym)
{
if (sym->Callback) {
@@ -145,7 +145,7 @@ struct sSymbol **
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 @@ sym_GetDefinedValue(char *s)
void
sym_ShiftCurrentMacroArgs(void)
{
SLONG i;
int32_t i;
free(currentmacroargs[0]);
for (i = 0; i < MAXMACROARGS - 1; i += 1) {
@@ -421,7 +421,7 @@ sym_ShiftCurrentMacroArgs(void)
}
char *
sym_FindMacroArg(SLONG i)
sym_FindMacroArg(int32_t i)
{
if (i == -1)
i = MAXMACROARGS + 1;
@@ -435,7 +435,7 @@ sym_FindMacroArg(SLONG i)
void
sym_UseNewMacroArgs(void)
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
currentmacroargs[i] = newmacroargs[i];
@@ -446,7 +446,7 @@ sym_UseNewMacroArgs(void)
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 @@ sym_SaveCurrentMacroArgs(char *save[])
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 @@ sym_RestoreCurrentMacroArgs(char *save[])
void
sym_FreeCurrentMacroArgs(void)
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
free(currentmacroargs[i]);
@@ -475,7 +475,7 @@ sym_FreeCurrentMacroArgs(void)
void
sym_AddNewMacroArg(char *s)
{
SLONG i = 0;
int32_t i = 0;
while (i < MAXMACROARGS && newmacroargs[i] != NULL)
i += 1;
@@ -501,7 +501,7 @@ sym_SetMacroArgID(ULONG nMacroCount)
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 @@ sym_FindMacro(char *s)
* 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 @@ sym_isString(char *tzSym)
* 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 @@ sym_PrepPass1(void)
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 @@ sym_PrepPass2(void)
void
sym_Init(void)
{
SLONG i;
int32_t i;
time_t now;
for (i = 0; i < MAXMACROARGS; i += 1) {

View File

@@ -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 @@ ensureSectionTypeIsValid(enum eSectionType type)
}
}
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 @@ area_Avail(SLONG bank)
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 @@ area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
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 @@ area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
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 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
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 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
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 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
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 @@ struct sSection *
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 @@ AssignFloatingBankSections(enum eSectionType type)
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 @@ SetLinkerscriptName(char *tzLinkerscriptFile)
void
AssignSections(void)
{
SLONG i;
int32_t i;
struct sSection *pSection;
MaxBankUsed = 0;
@@ -557,7 +558,7 @@ CreateSymbolTable(void)
pSect = pSections;
while (pSect) {
SLONG i;
int32_t i;
i = pSect->nNumberOfSymbols;

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -21,8 +22,8 @@ enum eBlockType {
BLOCK_OUTPUT
};
SLONG options = 0;
SLONG fillchar = 0;
int32_t options = 0;
int32_t fillchar = 0;
char *smartlinkstartsymbol;
/*

View File

@@ -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,26 +50,26 @@ CloseMapfile(void)
}
void
MapfileInitBank(SLONG bank)
MapfileInitBank(int32_t bank)
{
if (mf) {
currentbank = bank;
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 @@ MapfileInitBank(SLONG bank)
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 @@ MapfileWriteSection(struct sSection * pSect)
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 @@ MapfileWriteSection(struct sSection * pSect)
}
void
MapfileCloseBank(SLONG slack)
MapfileCloseBank(int32_t slack)
{
if (!mf)
return;
@@ -134,5 +135,5 @@ MapfileCloseBank(SLONG slack)
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);
}

View File

@@ -27,10 +27,10 @@ uint8_t oReadLib = 0;
*
*/
SLONG
int32_t
readlong(FILE * f)
{
SLONG r;
int32_t r;
r = fgetc(f);
r |= fgetc(f) << 8;
@@ -55,7 +55,7 @@ readword(FILE * f)
* Read a NULL terminated string from a file
*
*/
SLONG
int32_t
readasciiz(char **dest, FILE *f)
{
size_t r = 0;
@@ -226,7 +226,7 @@ obj_ReadRGBSection(FILE * f)
err(1, NULL);
}
SLONG nNumberOfPatches;
int32_t nNumberOfPatches;
struct sPatch **ppPatch, *pPatch;
if (fread(pSection->pData, sizeof(uint8_t),
@@ -281,7 +281,7 @@ void
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 @@ obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
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 @@ obj_Readfile(char *tzObjectfile)
oReadLib = 0;
}
SLONG
int32_t
file_Length(FILE * f)
{
ULONG r, p;

View File

@@ -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 @@ getsymvalue(SLONG symid)
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 @@ getsymbank(SLONG symid)
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 @@ Patch(void)
pCurrentSection = pSect;
pPatch = pSect->pPatches;
while (pPatch) {
SLONG t;
int32_t t;
nPC = pSect->nOrg + pPatch->nOffset;
t = calcrpn(pPatch);

View File

@@ -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 {
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 @@ calchash(char *s)
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 @@ sym_GetValue(char *tzName)
}
}
SLONG
int32_t
sym_GetBank(char *tzName)
{
struct ISymbol **ppSym;
@@ -78,7 +79,7 @@ sym_GetBank(char *tzName)
}
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)