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 #define RGBDS_ASM_ASM_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -22,7 +23,7 @@
#define MAXMACROARGS 256 #define MAXMACROARGS 256
#define MAXINCPATHS 128 #define MAXINCPATHS 128
extern SLONG nLineNo; extern int32_t nLineNo;
extern ULONG nTotalLines; extern ULONG nTotalLines;
extern ULONG nPC; extern ULONG nPC;
extern ULONG nPass; extern ULONG nPass;

View File

@@ -9,6 +9,7 @@
#ifndef RGBDS_ASM_FSTACK_H #ifndef RGBDS_ASM_FSTACK_H
#define RGBDS_ASM_FSTACK_H #define RGBDS_ASM_FSTACK_H
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include "asm/asm.h" #include "asm/asm.h"
@@ -21,7 +22,7 @@ struct sContext {
struct sContext *pNext; struct sContext *pNext;
char tzFileName[_MAX_PATH + 1]; char tzFileName[_MAX_PATH + 1];
char *tzMacroArgs[MAXMACROARGS + 1]; char *tzMacroArgs[MAXMACROARGS + 1];
SLONG nLine; int32_t nLine;
ULONG nStatus; ULONG nStatus;
FILE *pFile; FILE *pFile;
char *pREPTBlock; char *pREPTBlock;
@@ -31,7 +32,7 @@ struct sContext {
void void
fstk_RunInclude(char *); fstk_RunInclude(char *);
extern void fstk_RunMacroArg(SLONG s); extern void fstk_RunMacroArg(int32_t s);
void void
fstk_Init(char *); fstk_Init(char *);
extern void fstk_Dump(void); extern void fstk_Dump(void);

View File

@@ -1,13 +1,14 @@
#ifndef RGBDS_MAIN_H #ifndef RGBDS_MAIN_H
#define RGBDS_MAIN_H #define RGBDS_MAIN_H
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "extern/stdnoreturn.h" #include "extern/stdnoreturn.h"
struct sOptions { struct sOptions {
char gbgfx[4]; char gbgfx[4];
char binary[2]; char binary[2];
SLONG fillchar; int32_t fillchar;
bool verbose; bool verbose;
bool haltnop; bool haltnop;
bool exportall; bool exportall;
@@ -17,8 +18,8 @@ struct sOptions {
extern char *tzNewMacro; extern char *tzNewMacro;
extern ULONG ulNewMacroSize; extern ULONG ulNewMacroSize;
extern SLONG nGBGfxID; extern int32_t nGBGfxID;
extern SLONG nBinaryID; extern int32_t nBinaryID;
extern struct sOptions DefaultOptions; extern struct sOptions DefaultOptions;
extern struct sOptions CurrentOptions; extern struct sOptions CurrentOptions;

View File

@@ -1,21 +1,21 @@
#ifndef RGBDS_ASM_MATH_H #ifndef RGBDS_ASM_MATH_H
#define RGBDS_ASM_MATH_H #define RGBDS_ASM_MATH_H
#include "types.h" #include <stdint.h>
void math_DefinePI(void); void math_DefinePI(void);
void math_Print(SLONG i); void math_Print(int32_t i);
SLONG math_Sin(SLONG i); int32_t math_Sin(int32_t i);
SLONG math_Cos(SLONG i); int32_t math_Cos(int32_t i);
SLONG math_Tan(SLONG i); int32_t math_Tan(int32_t i);
SLONG math_ASin(SLONG i); int32_t math_ASin(int32_t i);
SLONG math_ACos(SLONG i); int32_t math_ACos(int32_t i);
SLONG math_ATan(SLONG i); int32_t math_ATan(int32_t i);
SLONG math_ATan2(SLONG i, SLONG j); int32_t math_ATan2(int32_t i, int32_t j);
SLONG math_Mul(SLONG i, SLONG j); int32_t math_Mul(int32_t i, int32_t j);
SLONG math_Div(SLONG i, SLONG j); int32_t math_Div(int32_t i, int32_t j);
SLONG math_Round(SLONG i); int32_t math_Round(int32_t i);
SLONG math_Ceil(SLONG i); int32_t math_Ceil(int32_t i);
SLONG math_Floor(SLONG i); int32_t math_Floor(int32_t i);
#endif #endif

View File

@@ -22,8 +22,8 @@ struct Section {
void out_PrepPass2(void); void out_PrepPass2(void);
void out_SetFileName(char *s); void out_SetFileName(char *s);
void out_NewSection(char *pzName, ULONG secttype); void out_NewSection(char *pzName, ULONG secttype);
void out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank); void out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank);
void out_NewAlignedSection(char *pzName, ULONG secttype, SLONG alignment, SLONG bank); void out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank);
void out_AbsByte(int b); void out_AbsByte(int b);
void out_AbsByteGroup(char *s, int length); void out_AbsByteGroup(char *s, int length);
void out_RelByte(struct Expression * expr); void out_RelByte(struct Expression * expr);
@@ -32,9 +32,9 @@ void out_PCRelByte(struct Expression * expr);
void out_WriteObject(void); void out_WriteObject(void);
void out_Skip(int skip); void out_Skip(int skip);
void out_BinaryFile(char *s); 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_String(char *s);
void out_AbsLong(SLONG b); void out_AbsLong(int32_t b);
void out_RelLong(struct Expression * expr); void out_RelLong(struct Expression * expr);
void out_PushSection(void); void out_PushSection(void);
void out_PopSection(void); void out_PopSection(void);

View File

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

View File

@@ -10,14 +10,14 @@
struct sSymbol { struct sSymbol {
char tzName[MAXSYMLEN + 1]; char tzName[MAXSYMLEN + 1];
SLONG nValue; int32_t nValue;
ULONG nType; ULONG nType;
struct sSymbol *pScope; struct sSymbol *pScope;
struct sSymbol *pNext; struct sSymbol *pNext;
struct Section *pSection; struct Section *pSection;
ULONG ulMacroSize; ULONG ulMacroSize;
char *pMacro; char *pMacro;
SLONG(*Callback) (struct sSymbol *); int32_t(*Callback) (struct sSymbol *);
char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */ char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
ULONG nFileLine; /* Line 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_RestoreCurrentMacroArgs(char *save[]);
void sym_UseNewMacroArgs(void); void sym_UseNewMacroArgs(void);
void sym_FreeCurrentMacroArgs(void); void sym_FreeCurrentMacroArgs(void);
void sym_AddEqu(char *tzSym, SLONG value); void sym_AddEqu(char *tzSym, int32_t value);
void sym_AddSet(char *tzSym, SLONG value); void sym_AddSet(char *tzSym, int32_t value);
void sym_Init(void); void sym_Init(void);
ULONG sym_GetConstantValue(char *s); ULONG sym_GetConstantValue(char *s);
ULONG sym_isConstant(char *s); ULONG sym_isConstant(char *s);
struct sSymbol *sym_FindSymbol(char *tzName); struct sSymbol *sym_FindSymbol(char *tzName);
void sym_Global(char *tzSym); void sym_Global(char *tzSym);
char *sym_FindMacroArg(SLONG i); char *sym_FindMacroArg(int32_t i);
char *sym_GetStringValue(char *tzSym); char *sym_GetStringValue(char *tzSym);
void sym_UseCurrentMacroArgs(void); void sym_UseCurrentMacroArgs(void);
void sym_SetMacroArgID(ULONG nMacroCount); void sym_SetMacroArgID(ULONG nMacroCount);

View File

@@ -1,6 +1,8 @@
#ifndef RGBDS_LINK_ASSIGN_H #ifndef RGBDS_LINK_ASSIGN_H
#define RGBDS_LINK_ASSIGN_H #define RGBDS_LINK_ASSIGN_H
#include <stdint.h>
#include "mylink.h" #include "mylink.h"
#include "types.h" #include "types.h"
@@ -29,11 +31,11 @@ enum eBankDefine {
#define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \ #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) + 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 AssignSections(void);
extern void CreateSymbolTable(void); extern void CreateSymbolTable(void);
extern SLONG MaxBankUsed; extern int32_t MaxBankUsed;
extern SLONG MaxAvail[MAXBANKS]; extern int32_t MaxAvail[MAXBANKS];
int int
IsSectionNameInUse(const char *name); IsSectionNameInUse(const char *name);

View File

@@ -1,9 +1,9 @@
#ifndef RGBDS_LINK_MAIN_H #ifndef RGBDS_LINK_MAIN_H
#define 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; extern char *smartlinkstartsymbol;
#endif #endif

View File

@@ -1,11 +1,13 @@
#ifndef RGBDS_LINK_MAPFILE_H #ifndef RGBDS_LINK_MAPFILE_H
#define RGBDS_LINK_MAPFILE_H #define RGBDS_LINK_MAPFILE_H
#include <stdint.h>
extern void SetMapfileName(char *name); extern void SetMapfileName(char *name);
extern void SetSymfileName(char *name); extern void SetSymfileName(char *name);
extern void CloseMapfile(void); extern void CloseMapfile(void);
extern void MapfileWriteSection(struct sSection * pSect); extern void MapfileWriteSection(struct sSection * pSect);
extern void MapfileInitBank(SLONG bank); extern void MapfileInitBank(int32_t bank);
extern void MapfileCloseBank(SLONG slack); extern void MapfileCloseBank(int32_t slack);
#endif #endif

View File

@@ -9,7 +9,7 @@
#include "types.h" #include "types.h"
extern SLONG options; extern int32_t options;
#define OPT_TINY 0x01 #define OPT_TINY 0x01
#define OPT_SMART_C_LINK 0x02 #define OPT_SMART_C_LINK 0x02
#define OPT_OVERLAY 0x04 #define OPT_OVERLAY 0x04
@@ -63,16 +63,16 @@ enum eSectionType {
}; };
struct sSection { struct sSection {
SLONG nBank; int32_t nBank;
SLONG nOrg; int32_t nOrg;
SLONG nAlign; int32_t nAlign;
uint8_t oAssigned; uint8_t oAssigned;
char *pzName; char *pzName;
SLONG nByteSize; int32_t nByteSize;
enum eSectionType Type; enum eSectionType Type;
uint8_t *pData; uint8_t *pData;
SLONG nNumberOfSymbols; int32_t nNumberOfSymbols;
struct sSymbol **tSymbols; struct sSymbol **tSymbols;
struct sPatch *pPatches; struct sPatch *pPatches;
struct sSection *pNext; struct sSection *pNext;
@@ -88,9 +88,9 @@ struct sSymbol {
char *pzName; char *pzName;
enum eSymbolType Type; enum eSymbolType Type;
/* the following 3 items only valid when Type!=SYM_IMPORT */ /* 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; struct sSection *pSection;
SLONG nOffset; int32_t nOffset;
char *pzObjFileName; /* Object file where the symbol is located. */ char *pzObjFileName; /* Object file where the symbol is located. */
char *pzFileName; /* Source file where the symbol was defined. */ char *pzFileName; /* Source file where the symbol was defined. */
ULONG nFileLine; /* Line where the symbol was defined. */ ULONG nFileLine; /* Line where the symbol was defined. */
@@ -104,10 +104,10 @@ enum ePatchType {
struct sPatch { struct sPatch {
char *pzFilename; char *pzFilename;
SLONG nLineNo; int32_t nLineNo;
SLONG nOffset; int32_t nOffset;
enum ePatchType Type; enum ePatchType Type;
SLONG nRPNSize; int32_t nRPNSize;
uint8_t *pRPN; uint8_t *pRPN;
struct sPatch *pNext; struct sPatch *pNext;
uint8_t oRelocPatch; uint8_t oRelocPatch;

View File

@@ -1,9 +1,9 @@
#ifndef RGBDS_LINK_PATCH_H #ifndef RGBDS_LINK_PATCH_H
#define RGBDS_LINK_PATCH_H #define RGBDS_LINK_PATCH_H
#include "types.h" #include <stdint.h>
void Patch(void); void Patch(void);
extern SLONG nPC; extern int32_t nPC;
#endif #endif

View File

@@ -1,12 +1,14 @@
#ifndef RGBDS_LINK_SYMBOL_H #ifndef RGBDS_LINK_SYMBOL_H
#define RGBDS_LINK_SYMBOL_H #define RGBDS_LINK_SYMBOL_H
#include <stdint.h>
#include "types.h" #include "types.h"
void sym_Init(void); 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); char *tzObjFileName, char *tzFileName, ULONG nFileLine);
SLONG sym_GetValue(char *tzName); int32_t sym_GetValue(char *tzName);
SLONG sym_GetBank(char *tzName); int32_t sym_GetBank(char *tzName);
#endif #endif

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ FILE *pCurrentFile;
ULONG nCurrentStatus; ULONG nCurrentStatus;
char tzCurrentFileName[_MAX_PATH + 1]; char tzCurrentFileName[_MAX_PATH + 1];
char IncludePaths[MAXINCPATHS][_MAX_PATH + 1]; char IncludePaths[MAXINCPATHS][_MAX_PATH + 1];
SLONG NextIncPath = 0; int32_t NextIncPath = 0;
ULONG nMacroCount; ULONG nMacroCount;
char *pCurrentREPTBlock; char *pCurrentREPTBlock;
@@ -200,12 +200,12 @@ fstk_Dump(void)
pLastFile = pFileStack; pLastFile = pFileStack;
while (pLastFile) { while (pLastFile) {
fprintf(stderr, "%s(%ld) -> ", pLastFile->tzFileName, fprintf(stderr, "%s(%d) -> ", pLastFile->tzFileName,
pLastFile->nLine); pLastFile->nLine);
pLastFile = pLastFile->pNext; 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 * Set up a macroargument for parsing
*/ */
void void
fstk_RunMacroArg(SLONG s) fstk_RunMacroArg(int32_t s)
{ {
char *sym; char *sym;

View File

@@ -8,19 +8,20 @@
#include "asmy.h" #include "asmy.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
bool oDontExpandStrings = false; bool oDontExpandStrings = false;
SLONG nGBGfxID = -1; int32_t nGBGfxID = -1;
SLONG nBinaryID = -1; int32_t nBinaryID = -1;
SLONG int32_t
gbgfx2bin(char ch) gbgfx2bin(char ch)
{ {
SLONG i; int32_t i;
for (i = 0; i <= 3; i += 1) { for (i = 0; i <= 3; i += 1) {
if (CurrentOptions.gbgfx[i] == ch) { if (CurrentOptions.gbgfx[i] == ch) {
@@ -31,10 +32,10 @@ gbgfx2bin(char ch)
return (0); return (0);
} }
SLONG int32_t
binary2bin(char ch) binary2bin(char ch)
{ {
SLONG i; int32_t i;
for (i = 0; i <= 1; i += 1) { for (i = 0; i <= 1; i += 1) {
if (CurrentOptions.binary[i] == ch) { if (CurrentOptions.binary[i] == ch) {
@@ -45,7 +46,7 @@ binary2bin(char ch)
return (0); return (0);
} }
SLONG int32_t
char2bin(char ch) char2bin(char ch)
{ {
if (ch >= 'a' && ch <= 'f') if (ch >= 'a' && ch <= 'f')
@@ -60,13 +61,13 @@ char2bin(char ch)
return (0); return (0);
} }
typedef SLONG(*x2bin) (char ch); typedef int32_t(*x2bin) (char ch);
SLONG int32_t
ascii2bin(char *s) ascii2bin(char *s)
{ {
SLONG radix = 10; int32_t radix = 10;
SLONG result = 0; int32_t result = 0;
x2bin convertfunc = char2bin; x2bin convertfunc = char2bin;
switch (*s) { switch (*s) {
@@ -93,7 +94,7 @@ ascii2bin(char *s)
} }
if (radix == 4) { if (radix == 4) {
SLONG c; int32_t c;
while (*s != '\0') { while (*s != '\0') {
c = convertfunc(*s++); c = convertfunc(*s++);
@@ -128,7 +129,7 @@ ParseFixedPoint(char *s, ULONG size)
yyunputbytes(size); yyunputbytes(size);
yylval.nConstValue = (SLONG) (atof(s) * 65536); yylval.nConstValue = (int32_t) (atof(s) * 65536);
return (1); return (1);
} }

View File

@@ -1,6 +1,7 @@
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@@ -22,7 +23,7 @@ int cldefines_size;
char **cldefines; char **cldefines;
clock_t nStartClock, nEndClock; clock_t nStartClock, nEndClock;
SLONG nLineNo; int32_t nLineNo;
ULONG nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors; ULONG nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors;
bool skipElif; bool skipElif;
ULONG unionStart[128], unionSize[128]; ULONG unionStart[128], unionSize[128];
@@ -141,7 +142,7 @@ opt_Parse(char *s)
if (strlen(&s[1]) <= 2) { if (strlen(&s[1]) <= 2) {
int result; int result;
result = sscanf(&s[1], "%lx", &newopt.fillchar); result = sscanf(&s[1], "%x", &newopt.fillchar);
if (!((result == EOF) || (result == 1))) { if (!((result == EOF) || (result == 1))) {
errx(1, "Invalid argument for option 'z'"); errx(1, "Invalid argument for option 'z'");
} }

View File

@@ -3,6 +3,7 @@
*/ */
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include "types.h" #include "types.h"
@@ -10,7 +11,7 @@
#include "asm/symbol.h" #include "asm/symbol.h"
#define fix2double(i) ((double)(i/65536.0)) #define fix2double(i) ((double)(i/65536.0))
#define double2fix(d) ((SLONG)(d*65536.0)) #define double2fix(d) ((int32_t)(d*65536.0))
#ifndef PI #ifndef PI
#define PI (acos(-1)) #define PI (acos(-1))
#endif #endif
@@ -28,21 +29,21 @@ math_DefinePI(void)
* Print a fixed point value * Print a fixed point value
*/ */
void void
math_Print(SLONG i) math_Print(int32_t i)
{ {
if (i >= 0) if (i >= 0)
printf("%ld.%05ld", i >> 16, printf("%d.%05d", i >> 16,
((SLONG) (fix2double(i) * 100000 + 0.5)) % 100000); ((int32_t) (fix2double(i) * 100000 + 0.5)) % 100000);
else else
printf("-%ld.%05ld", (-i) >> 16, printf("-%d.%05d", (-i) >> 16,
((SLONG) (fix2double(-i) * 100000 + 0.5)) % 100000); ((int32_t) (fix2double(-i) * 100000 + 0.5)) % 100000);
} }
/* /*
* Calculate sine * Calculate sine
*/ */
SLONG int32_t
math_Sin(SLONG i) math_Sin(int32_t i)
{ {
return (double2fix(sin(fix2double(i) * 2 * PI / 65536))); return (double2fix(sin(fix2double(i) * 2 * PI / 65536)));
} }
@@ -50,8 +51,8 @@ math_Sin(SLONG i)
/* /*
* Calculate cosine * Calculate cosine
*/ */
SLONG int32_t
math_Cos(SLONG i) math_Cos(int32_t i)
{ {
return (double2fix(cos(fix2double(i) * 2 * PI / 65536))); return (double2fix(cos(fix2double(i) * 2 * PI / 65536)));
} }
@@ -59,8 +60,8 @@ math_Cos(SLONG i)
/* /*
* Calculate tangent * Calculate tangent
*/ */
SLONG int32_t
math_Tan(SLONG i) math_Tan(int32_t i)
{ {
return (double2fix(tan(fix2double(i) * 2 * PI / 65536))); return (double2fix(tan(fix2double(i) * 2 * PI / 65536)));
} }
@@ -68,8 +69,8 @@ math_Tan(SLONG i)
/* /*
* Calculate arcsine * Calculate arcsine
*/ */
SLONG int32_t
math_ASin(SLONG i) math_ASin(int32_t i)
{ {
return (double2fix(asin(fix2double(i)) / 2 / PI * 65536)); return (double2fix(asin(fix2double(i)) / 2 / PI * 65536));
} }
@@ -77,8 +78,8 @@ math_ASin(SLONG i)
/* /*
* Calculate arccosine * Calculate arccosine
*/ */
SLONG int32_t
math_ACos(SLONG i) math_ACos(int32_t i)
{ {
return (double2fix(acos(fix2double(i)) / 2 / PI * 65536)); return (double2fix(acos(fix2double(i)) / 2 / PI * 65536));
} }
@@ -86,8 +87,8 @@ math_ACos(SLONG i)
/* /*
* Calculate arctangent * Calculate arctangent
*/ */
SLONG int32_t
math_ATan(SLONG i) math_ATan(int32_t i)
{ {
return (double2fix(atan(fix2double(i)) / 2 / PI * 65536)); return (double2fix(atan(fix2double(i)) / 2 / PI * 65536));
} }
@@ -95,8 +96,8 @@ math_ATan(SLONG i)
/* /*
* Calculate atan2 * Calculate atan2
*/ */
SLONG int32_t
math_ATan2(SLONG i, SLONG j) math_ATan2(int32_t i, int32_t j)
{ {
return (double2fix return (double2fix
(atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536)); (atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536));
@@ -105,8 +106,8 @@ math_ATan2(SLONG i, SLONG j)
/* /*
* Multiplication * Multiplication
*/ */
SLONG int32_t
math_Mul(SLONG i, SLONG j) math_Mul(int32_t i, int32_t j)
{ {
return (double2fix(fix2double(i) * fix2double(j))); return (double2fix(fix2double(i) * fix2double(j)));
} }
@@ -114,8 +115,8 @@ math_Mul(SLONG i, SLONG j)
/* /*
* Division * Division
*/ */
SLONG int32_t
math_Div(SLONG i, SLONG j) math_Div(int32_t i, int32_t j)
{ {
return (double2fix(fix2double(i) / fix2double(j))); return (double2fix(fix2double(i) / fix2double(j)));
} }
@@ -123,8 +124,8 @@ math_Div(SLONG i, SLONG j)
/* /*
* Round * Round
*/ */
SLONG int32_t
math_Round(SLONG i) math_Round(int32_t i)
{ {
return double2fix(round(fix2double(i))); return double2fix(round(fix2double(i)));
} }
@@ -132,8 +133,8 @@ math_Round(SLONG i)
/* /*
* Ceil * Ceil
*/ */
SLONG int32_t
math_Ceil(SLONG i) math_Ceil(int32_t i)
{ {
return double2fix(ceil(fix2double(i))); return double2fix(ceil(fix2double(i)));
} }
@@ -141,8 +142,8 @@ math_Ceil(SLONG i)
/* /*
* Floor * Floor
*/ */
SLONG int32_t
math_Floor(SLONG i) math_Floor(int32_t i)
{ {
return double2fix(floor(fix2double(i))); return double2fix(floor(fix2double(i)));
} }

View File

@@ -253,7 +253,7 @@ writesymbol(struct sSymbol * pSym, FILE * f)
char symname[MAXSYMLEN * 2 + 1]; char symname[MAXSYMLEN * 2 + 1];
ULONG type; ULONG type;
ULONG offset; ULONG offset;
SLONG sectid; int32_t sectid;
if (pSym->nType & SYMF_IMPORT) { if (pSym->nType & SYMF_IMPORT) {
/* Symbol should be imported */ /* 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 * Find a section by name and type. If it doesn't exist, create it
*/ */
struct Section * 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; struct Section *pSect, **ppSect;
@@ -646,7 +646,7 @@ out_NewSection(char *pzName, ULONG secttype)
* Set the current section by name and type * Set the current section by name and type
*/ */
void 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)); 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 * Set the current section by name and type, using a given byte alignment
*/ */
void 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) { if (alignment < 0 || alignment > 16) {
yyerror("Alignment must be between 0-16 bits."); yyerror("Alignment must be between 0-16 bits.");
@@ -805,10 +805,10 @@ out_RelWord(struct Expression * expr)
* Output an absolute longword * Output an absolute longword
*/ */
void void
out_AbsLong(SLONG b) out_AbsLong(int32_t b)
{ {
checkcodesection(); checkcodesection();
checksectionoverflow(sizeof(SLONG)); checksectionoverflow(sizeof(int32_t));
if (nPass == 2) { if (nPass == 2) {
pCurrentSection->tData[nPC] = b & 0xFF; pCurrentSection->tData[nPC] = b & 0xFF;
pCurrentSection->tData[nPC + 1] = b >> 8; pCurrentSection->tData[nPC + 1] = b >> 8;
@@ -827,7 +827,7 @@ out_AbsLong(SLONG b)
void void
out_RelLong(struct Expression * expr) out_RelLong(struct Expression * expr)
{ {
SLONG b; int32_t b;
checkcodesection(); checkcodesection();
checksectionoverflow(4); checksectionoverflow(4);
@@ -854,7 +854,7 @@ out_RelLong(struct Expression * expr)
void void
out_PCRelByte(struct Expression * expr) out_PCRelByte(struct Expression * expr)
{ {
SLONG b = expr->nVal; int32_t b = expr->nVal;
checkcodesection(); checkcodesection();
checksectionoverflow(1); checksectionoverflow(1);
@@ -879,7 +879,7 @@ out_BinaryFile(char *s)
err(1, "Unable to open incbin file '%s'", s); err(1, "Unable to open incbin file '%s'", s);
} }
SLONG fsize; int32_t fsize;
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
fsize = ftell(f); fsize = ftell(f);
@@ -889,8 +889,8 @@ out_BinaryFile(char *s)
checksectionoverflow(fsize); checksectionoverflow(fsize);
if (nPass == 2) { if (nPass == 2) {
SLONG dest = nPC; int32_t dest = nPC;
SLONG todo = fsize; int32_t todo = fsize;
while (todo--) while (todo--)
pCurrentSection->tData[dest++] = fgetc(f); pCurrentSection->tData[dest++] = fgetc(f);
@@ -902,7 +902,7 @@ out_BinaryFile(char *s)
} }
void void
out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length) out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length)
{ {
FILE *f; FILE *f;
@@ -917,7 +917,7 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
err(1, "Unable to open included file '%s'", s); err(1, "Unable to open included file '%s'", s);
} }
SLONG fsize; int32_t fsize;
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
fsize = ftell(f); fsize = ftell(f);
@@ -934,8 +934,8 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
checksectionoverflow(length); checksectionoverflow(length);
if (nPass == 2) { if (nPass == 2) {
SLONG dest = nPC; int32_t dest = nPC;
SLONG todo = length; int32_t todo = length;
while (todo--) while (todo--)
pCurrentSection->tData[dest++] = fgetc(f); pCurrentSection->tData[dest++] = fgetc(f);

View File

@@ -51,7 +51,7 @@ void helper_RemoveLeadingZeros(char * string){
memmove(string, new_beginning, strlen(new_beginning) + 1); memmove(string, new_beginning, strlen(new_beginning) + 1);
} }
SLONG int32_t
Callback_NARG(struct sSymbol * sym) Callback_NARG(struct sSymbol * sym)
{ {
ULONG i = 0; ULONG i = 0;
@@ -62,7 +62,7 @@ Callback_NARG(struct sSymbol * sym)
return (i); return (i);
} }
SLONG int32_t
Callback__LINE__(struct sSymbol __attribute__((unused)) * sym) Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
{ {
return (nLineNo); return (nLineNo);
@@ -71,7 +71,7 @@ Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
/* /*
* Get the nValue field of a symbol * Get the nValue field of a symbol
*/ */
SLONG int32_t
getvaluefield(struct sSymbol * sym) getvaluefield(struct sSymbol * sym)
{ {
if (sym->Callback) { if (sym->Callback) {
@@ -145,7 +145,7 @@ struct sSymbol **
findpsymbol(char *s, struct sSymbol * scope) findpsymbol(char *s, struct sSymbol * scope)
{ {
struct sSymbol **ppsym; struct sSymbol **ppsym;
SLONG hash; int32_t hash;
char fullname[MAXSYMLEN + 1]; char fullname[MAXSYMLEN + 1];
if (s[0] == '.' && scope) { if (s[0] == '.' && scope) {
@@ -411,7 +411,7 @@ sym_GetDefinedValue(char *s)
void void
sym_ShiftCurrentMacroArgs(void) sym_ShiftCurrentMacroArgs(void)
{ {
SLONG i; int32_t i;
free(currentmacroargs[0]); free(currentmacroargs[0]);
for (i = 0; i < MAXMACROARGS - 1; i += 1) { for (i = 0; i < MAXMACROARGS - 1; i += 1) {
@@ -421,7 +421,7 @@ sym_ShiftCurrentMacroArgs(void)
} }
char * char *
sym_FindMacroArg(SLONG i) sym_FindMacroArg(int32_t i)
{ {
if (i == -1) if (i == -1)
i = MAXMACROARGS + 1; i = MAXMACROARGS + 1;
@@ -435,7 +435,7 @@ sym_FindMacroArg(SLONG i)
void void
sym_UseNewMacroArgs(void) sym_UseNewMacroArgs(void)
{ {
SLONG i; int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) { for (i = 0; i <= MAXMACROARGS; i += 1) {
currentmacroargs[i] = newmacroargs[i]; currentmacroargs[i] = newmacroargs[i];
@@ -446,7 +446,7 @@ sym_UseNewMacroArgs(void)
void void
sym_SaveCurrentMacroArgs(char *save[]) sym_SaveCurrentMacroArgs(char *save[])
{ {
SLONG i; int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) for (i = 0; i <= MAXMACROARGS; i += 1)
save[i] = currentmacroargs[i]; save[i] = currentmacroargs[i];
@@ -455,7 +455,7 @@ sym_SaveCurrentMacroArgs(char *save[])
void void
sym_RestoreCurrentMacroArgs(char *save[]) sym_RestoreCurrentMacroArgs(char *save[])
{ {
SLONG i; int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) for (i = 0; i <= MAXMACROARGS; i += 1)
currentmacroargs[i] = save[i]; currentmacroargs[i] = save[i];
@@ -464,7 +464,7 @@ sym_RestoreCurrentMacroArgs(char *save[])
void void
sym_FreeCurrentMacroArgs(void) sym_FreeCurrentMacroArgs(void)
{ {
SLONG i; int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) { for (i = 0; i <= MAXMACROARGS; i += 1) {
free(currentmacroargs[i]); free(currentmacroargs[i]);
@@ -475,7 +475,7 @@ sym_FreeCurrentMacroArgs(void)
void void
sym_AddNewMacroArg(char *s) sym_AddNewMacroArg(char *s)
{ {
SLONG i = 0; int32_t i = 0;
while (i < MAXMACROARGS && newmacroargs[i] != NULL) while (i < MAXMACROARGS && newmacroargs[i] != NULL)
i += 1; i += 1;
@@ -501,7 +501,7 @@ sym_SetMacroArgID(ULONG nMacroCount)
void void
sym_UseCurrentMacroArgs(void) sym_UseCurrentMacroArgs(void)
{ {
SLONG i; int32_t i;
for (i = 1; i <= MAXMACROARGS; i += 1) for (i = 1; i <= MAXMACROARGS; i += 1)
sym_AddNewMacroArg(sym_FindMacroArg(i)); sym_AddNewMacroArg(sym_FindMacroArg(i));
@@ -520,7 +520,7 @@ sym_FindMacro(char *s)
* Add an equated symbol * Add an equated symbol
*/ */
void void
sym_AddEqu(char *tzSym, SLONG value) sym_AddEqu(char *tzSym, int32_t value)
{ {
if ((nPass == 1) if ((nPass == 1)
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) { || ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
@@ -598,7 +598,7 @@ sym_isString(char *tzSym)
* Alter a SET symbols value * Alter a SET symbols value
*/ */
void void
sym_AddSet(char *tzSym, SLONG value) sym_AddSet(char *tzSym, int32_t value)
{ {
struct sSymbol *nsym; struct sSymbol *nsym;
@@ -834,7 +834,7 @@ sym_PrepPass1(void)
void void
sym_PrepPass2(void) sym_PrepPass2(void)
{ {
SLONG i; int32_t i;
for (i = 0; i < HASHSIZE; i += 1) { for (i = 0; i < HASHSIZE; i += 1) {
struct sSymbol **ppSym = &(tHashedSymbols[i]); struct sSymbol **ppSym = &(tHashedSymbols[i]);
@@ -885,7 +885,7 @@ sym_PrepPass2(void)
void void
sym_Init(void) sym_Init(void)
{ {
SLONG i; int32_t i;
time_t now; time_t now;
for (i = 0; i < MAXMACROARGS; i += 1) { for (i = 0; i < MAXMACROARGS; i += 1) {

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
@@ -11,25 +12,25 @@
#include "link/symbol.h" #include "link/symbol.h"
struct sFreeArea { struct sFreeArea {
SLONG nOrg; int32_t nOrg;
SLONG nSize; int32_t nSize;
struct sFreeArea *pPrev, *pNext; struct sFreeArea *pPrev, *pNext;
}; };
struct sSectionAttributes { struct sSectionAttributes {
const char *name; const char *name;
SLONG bank; int32_t bank;
SLONG offset; // bank + offset = bank originally stored in a section struct int32_t offset; // bank + offset = bank originally stored in a section struct
SLONG minBank; int32_t minBank;
SLONG bankCount; int32_t bankCount;
}; };
struct sFreeArea *BankFree[MAXBANKS]; struct sFreeArea *BankFree[MAXBANKS];
SLONG MaxAvail[MAXBANKS]; int32_t MaxAvail[MAXBANKS];
SLONG MaxBankUsed; int32_t MaxBankUsed;
SLONG MaxWBankUsed; int32_t MaxWBankUsed;
SLONG MaxSBankUsed; int32_t MaxSBankUsed;
SLONG MaxVBankUsed; int32_t MaxVBankUsed;
const enum eSectionType SECT_MIN = SECT_WRAM0; const enum eSectionType SECT_MIN = SECT_WRAM0;
const enum eSectionType SECT_MAX = SECT_OAM; const enum eSectionType SECT_MAX = SECT_OAM;
@@ -63,10 +64,10 @@ ensureSectionTypeIsValid(enum eSectionType type)
} }
} }
SLONG int32_t
area_Avail(SLONG bank) area_Avail(int32_t bank)
{ {
SLONG r; int32_t r;
struct sFreeArea *pArea; struct sFreeArea *pArea;
r = 0; r = 0;
@@ -80,8 +81,8 @@ area_Avail(SLONG bank)
return (r); return (r);
} }
SLONG int32_t
area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size) 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 && (org + size) <= (pArea->nOrg + pArea->nSize)) {
if (org == pArea->nOrg) { if (org == pArea->nOrg) {
@@ -114,14 +115,14 @@ area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
return -1; return -1;
} }
SLONG int32_t
area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size) area_AllocAbs(struct sFreeArea ** ppArea, int32_t org, int32_t size)
{ {
struct sFreeArea *pArea; struct sFreeArea *pArea;
pArea = *ppArea; pArea = *ppArea;
while (pArea) { while (pArea) {
SLONG result = area_doAlloc(pArea, org, size); int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) { if (result != -1) {
return result; return result;
} }
@@ -133,13 +134,13 @@ area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
return -1; return -1;
} }
SLONG int32_t
area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type) area_AllocAbsAnyBank(int32_t org, int32_t size, enum eSectionType type)
{ {
ensureSectionTypeIsValid(type); ensureSectionTypeIsValid(type);
SLONG startBank = SECT_ATTRIBUTES[type].bank; int32_t startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount; int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { for (int i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) { if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
@@ -150,8 +151,8 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
return -1; return -1;
} }
SLONG int32_t
area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) { area_Alloc(struct sFreeArea ** ppArea, int32_t size, int32_t alignment) {
struct sFreeArea *pArea; struct sFreeArea *pArea;
if (alignment < 1) { if (alignment < 1) {
alignment = 1; alignment = 1;
@@ -159,13 +160,13 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
pArea = *ppArea; pArea = *ppArea;
while (pArea) { while (pArea) {
SLONG org = pArea->nOrg; int32_t org = pArea->nOrg;
if (org % alignment) { if (org % alignment) {
org += alignment; org += alignment;
} }
org -= org % alignment; org -= org % alignment;
SLONG result = area_doAlloc(pArea, org, size); int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) { if (result != -1) {
return result; return result;
} }
@@ -177,15 +178,15 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
return -1; return -1;
} }
SLONG int32_t
area_AllocAnyBank(SLONG size, SLONG alignment, enum eSectionType type) { area_AllocAnyBank(int32_t size, int32_t alignment, enum eSectionType type) {
ensureSectionTypeIsValid(type); ensureSectionTypeIsValid(type);
SLONG startBank = SECT_ATTRIBUTES[type].bank; int32_t startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount; int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { 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) { if (org != -1) {
return ((startBank + i) << 16) | org; return ((startBank + i) << 16) | org;
} }
@@ -198,8 +199,8 @@ struct sSection *
FindLargestSection(enum eSectionType type, bool bankFixed) FindLargestSection(enum eSectionType type, bool bankFixed)
{ {
struct sSection *pSection, *r = NULL; struct sSection *pSection, *r = NULL;
SLONG nLargest = 0; int32_t nLargest = 0;
SLONG nLargestAlignment = 0; int32_t nLargestAlignment = 0;
pSection = pSections; pSection = pSections;
while (pSection) { while (pSection) {
@@ -332,7 +333,7 @@ AssignFloatingBankSections(enum eSectionType type)
struct sSection *pSection; struct sSection *pSection;
while ((pSection = FindLargestSection(type, false))) { while ((pSection = FindLargestSection(type, false))) {
SLONG org; int32_t org;
if ((org = area_AllocAnyBank(pSection->nByteSize, pSection->nAlign, type)) != -1) { if ((org = area_AllocAnyBank(pSection->nByteSize, pSection->nAlign, type)) != -1) {
if (options & OPT_OVERLAY) { if (options & OPT_OVERLAY) {
@@ -370,7 +371,7 @@ SetLinkerscriptName(char *tzLinkerscriptFile)
void void
AssignSections(void) AssignSections(void)
{ {
SLONG i; int32_t i;
struct sSection *pSection; struct sSection *pSection;
MaxBankUsed = 0; MaxBankUsed = 0;
@@ -557,7 +558,7 @@ CreateSymbolTable(void)
pSect = pSections; pSect = pSections;
while (pSect) { while (pSect) {
SLONG i; int32_t i;
i = pSect->nNumberOfSymbols; i = pSect->nNumberOfSymbols;

View File

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

View File

@@ -1,4 +1,5 @@
#include <errno.h> #include <errno.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -10,8 +11,8 @@
FILE *mf = NULL; FILE *mf = NULL;
FILE *sf = NULL; FILE *sf = NULL;
SLONG currentbank = 0; int32_t currentbank = 0;
SLONG sfbank; int32_t sfbank;
void void
SetMapfileName(char *name) SetMapfileName(char *name)
@@ -49,26 +50,26 @@ CloseMapfile(void)
} }
void void
MapfileInitBank(SLONG bank) MapfileInitBank(int32_t bank)
{ {
if (mf) { if (mf) {
currentbank = bank; currentbank = bank;
if (bank == BANK_ROM0) if (bank == BANK_ROM0)
fprintf(mf, "ROM Bank #0 (HOME):\n"); fprintf(mf, "ROM Bank #0 (HOME):\n");
else if (bank < BANK_WRAM0) else if (bank < BANK_WRAM0)
fprintf(mf, "ROM Bank #%ld:\n", bank); fprintf(mf, "ROM Bank #%d:\n", bank);
else if (bank == BANK_WRAM0) else if (bank == BANK_WRAM0)
fprintf(mf, "WRAM Bank #0:\n"); fprintf(mf, "WRAM Bank #0:\n");
else if (bank < BANK_VRAM) 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) else if (bank == BANK_HRAM)
fprintf(mf, "HRAM:\n"); fprintf(mf, "HRAM:\n");
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1) 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) else if (bank == BANK_OAM)
fprintf(mf, "OAM:\n"); fprintf(mf, "OAM:\n");
else if (bank < MAXBANKS) 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 (sf) {
if (bank < BANK_WRAM0) if (bank < BANK_WRAM0)
@@ -93,15 +94,15 @@ MapfileInitBank(SLONG bank)
void void
MapfileWriteSection(struct sSection * pSect) MapfileWriteSection(struct sSection * pSect)
{ {
SLONG i; int32_t i;
if (mf) { if (mf) {
if (pSect->nByteSize > 0) { 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->nOrg, pSect->nOrg + pSect->nByteSize - 1,
pSect->nByteSize, pSect->pzName); pSect->nByteSize, pSect->pzName);
} else { } else {
fprintf(mf, " SECTION: $%04lX ($0 bytes) [\"%s\"]\n", fprintf(mf, " SECTION: $%04X ($0 bytes) [\"%s\"]\n",
pSect->nOrg, pSect->pzName); pSect->nOrg, pSect->pzName);
} }
} }
@@ -112,12 +113,12 @@ MapfileWriteSection(struct sSection * pSect)
if ((pSym->pSection == pSect) if ((pSym->pSection == pSect)
&& (pSym->Type != SYM_IMPORT)) { && (pSym->Type != SYM_IMPORT)) {
if (mf) { if (mf) {
fprintf(mf, " $%04lX = %s\n", fprintf(mf, " $%04X = %s\n",
pSym->nOffset + pSect->nOrg, pSym->nOffset + pSect->nOrg,
pSym->pzName); pSym->pzName);
} }
if (sf) { if (sf) {
fprintf(sf, "%02lX:%04lX %s\n", sfbank, fprintf(sf, "%02X:%04X %s\n", sfbank,
pSym->nOffset + pSect->nOrg, pSym->nOffset + pSect->nOrg,
pSym->pzName); pSym->pzName);
} }
@@ -126,7 +127,7 @@ MapfileWriteSection(struct sSection * pSect)
} }
void void
MapfileCloseBank(SLONG slack) MapfileCloseBank(int32_t slack)
{ {
if (!mf) if (!mf)
return; return;
@@ -134,5 +135,5 @@ MapfileCloseBank(SLONG slack)
if (slack == MaxAvail[currentbank]) if (slack == MaxAvail[currentbank])
fprintf(mf, " EMPTY\n\n"); fprintf(mf, " EMPTY\n\n");
else 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) readlong(FILE * f)
{ {
SLONG r; int32_t r;
r = fgetc(f); r = fgetc(f);
r |= fgetc(f) << 8; r |= fgetc(f) << 8;
@@ -55,7 +55,7 @@ readword(FILE * f)
* Read a NULL terminated string from a file * Read a NULL terminated string from a file
* *
*/ */
SLONG int32_t
readasciiz(char **dest, FILE *f) readasciiz(char **dest, FILE *f)
{ {
size_t r = 0; size_t r = 0;
@@ -226,7 +226,7 @@ obj_ReadRGBSection(FILE * f)
err(1, NULL); err(1, NULL);
} }
SLONG nNumberOfPatches; int32_t nNumberOfPatches;
struct sPatch **ppPatch, *pPatch; struct sPatch **ppPatch, *pPatch;
if (fread(pSection->pData, sizeof(uint8_t), if (fread(pSection->pData, sizeof(uint8_t),
@@ -281,7 +281,7 @@ void
obj_ReadRGB(FILE * pObjfile, char *tzObjectfile) obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
{ {
struct sSection *pFirstSection; struct sSection *pFirstSection;
SLONG nNumberOfSymbols, nNumberOfSections, i; int32_t nNumberOfSymbols, nNumberOfSections, i;
nNumberOfSymbols = readlong(pObjfile); nNumberOfSymbols = readlong(pObjfile);
nNumberOfSections = readlong(pObjfile); nNumberOfSections = readlong(pObjfile);
@@ -322,7 +322,7 @@ obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
if (tSymbols[i]->Type != SYM_IMPORT if (tSymbols[i]->Type != SYM_IMPORT
&& tSymbols[i]->nSectionID != -1) { && tSymbols[i]->nSectionID != -1) {
SLONG j = 0; int32_t j = 0;
while (j != tSymbols[i]->nSectionID) { while (j != tSymbols[i]->nSectionID) {
j += 1; j += 1;
pConvSect = pConvSect->pNext; pConvSect = pConvSect->pNext;
@@ -381,7 +381,7 @@ obj_Readfile(char *tzObjectfile)
oReadLib = 0; oReadLib = 0;
} }
SLONG int32_t
file_Length(FILE * f) file_Length(FILE * f)
{ {
ULONG r, p; ULONG r, p;

View File

@@ -10,24 +10,24 @@
#include "link/main.h" #include "link/main.h"
struct sSection *pCurrentSection; struct sSection *pCurrentSection;
SLONG rpnstack[256]; int32_t rpnstack[256];
SLONG rpnp; int32_t rpnp;
SLONG nPC; int32_t nPC;
void void
rpnpush(SLONG i) rpnpush(int32_t i)
{ {
rpnstack[rpnp++] = i; rpnstack[rpnp++] = i;
} }
SLONG int32_t
rpnpop(void) rpnpop(void)
{ {
return (rpnstack[--rpnp]); return (rpnstack[--rpnp]);
} }
SLONG int32_t
getsymvalue(SLONG symid) getsymvalue(int32_t symid)
{ {
switch (pCurrentSection->tSymbols[symid]->Type) { switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT: case SYM_IMPORT:
@@ -52,10 +52,10 @@ getsymvalue(SLONG symid)
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE"); errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
} }
SLONG int32_t
getsymbank(SLONG symid) getsymbank(int32_t symid)
{ {
SLONG nBank; int32_t nBank;
switch (pCurrentSection->tSymbols[symid]->Type) { switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT: case SYM_IMPORT:
@@ -83,10 +83,10 @@ getsymbank(SLONG symid)
return nBank; return nBank;
} }
SLONG int32_t
calcrpn(struct sPatch * pPatch) calcrpn(struct sPatch * pPatch)
{ {
SLONG t, size; int32_t t, size;
uint8_t *rpn; uint8_t *rpn;
rpnp = 0; rpnp = 0;
@@ -224,7 +224,7 @@ Patch(void)
pCurrentSection = pSect; pCurrentSection = pSect;
pPatch = pSect->pPatches; pPatch = pSect->pPatches;
while (pPatch) { while (pPatch) {
SLONG t; int32_t t;
nPC = pSect->nOrg + pPatch->nOffset; nPC = pSect->nOrg + pPatch->nOffset;
t = calcrpn(pPatch); t = calcrpn(pPatch);

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -11,8 +12,8 @@
struct ISymbol { struct ISymbol {
char *pzName; char *pzName;
SLONG nValue; int32_t nValue;
SLONG nBank; /* -1 = constant */ int32_t nBank; /* -1 = constant */
char tzObjFileName[_MAX_PATH + 1]; /* Object file where the symbol was defined. */ char tzObjFileName[_MAX_PATH + 1]; /* Object file where the symbol was defined. */
char tzFileName[_MAX_PATH + 1]; /* Source 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. */ ULONG nFileLine; /* Line where the symbol was defined. */
@@ -21,10 +22,10 @@ struct ISymbol {
struct ISymbol *tHash[HASHSIZE]; struct ISymbol *tHash[HASHSIZE];
SLONG int32_t
calchash(char *s) calchash(char *s)
{ {
SLONG r = 0; int32_t r = 0;
while (*s) while (*s)
r += *s++; r += *s++;
@@ -34,12 +35,12 @@ calchash(char *s)
void void
sym_Init(void) sym_Init(void)
{ {
SLONG i; int32_t i;
for (i = 0; i < HASHSIZE; i += 1) for (i = 0; i < HASHSIZE; i += 1)
tHash[i] = NULL; tHash[i] = NULL;
} }
SLONG int32_t
sym_GetValue(char *tzName) sym_GetValue(char *tzName)
{ {
if (strcmp(tzName, "@") == 0) { if (strcmp(tzName, "@") == 0) {
@@ -60,7 +61,7 @@ sym_GetValue(char *tzName)
} }
} }
SLONG int32_t
sym_GetBank(char *tzName) sym_GetBank(char *tzName)
{ {
struct ISymbol **ppSym; struct ISymbol **ppSym;
@@ -78,7 +79,7 @@ sym_GetBank(char *tzName)
} }
void 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) char *tzFileName, ULONG nFileLine)
{ {
if (strcmp(tzName, "@") == 0) if (strcmp(tzName, "@") == 0)