mirror of
https://github.com/gbdev/rgbds.git
synced 2026-01-11 02:51:51 +00:00
reran indent (whitespace changes)
Merging lai's source with this one is very irritating because they have different indentation styles. I couldn't find what profile vegard used for his version, so I used these flags (which should bring the source close to KNF): -bap -br -ce -ci4 -cli0 -d0 -di0 -i8 -ip -l79 -nbc -ncdb -ndj -ei -nfc1 -nlp -npcs -psl -sc -sob
This commit is contained in:
110
src/asm/alloca.c
110
src/asm/alloca.c
@@ -104,9 +104,11 @@ extern pointer malloc ();
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
#define STACK_DIR stack_dir
|
||||
|
||||
static void find_stack_direction()
|
||||
static void
|
||||
find_stack_direction()
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
static char *addr = NULL; /* Address of first `dummy', once
|
||||
* known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL) { /* Initial entry. */
|
||||
@@ -121,7 +123,6 @@ static void find_stack_direction()
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
@@ -152,7 +153,8 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
pointer alloca(size)
|
||||
pointer
|
||||
alloca(size)
|
||||
unsigned size;
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
@@ -163,8 +165,8 @@ unsigned size;
|
||||
find_stack_direction();
|
||||
#endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
/* Reclaim garbage, defined as all alloca'd storage that was allocated
|
||||
* from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
@@ -210,7 +212,6 @@ unsigned size;
|
||||
return (pointer) ((char *) new + sizeof(header));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
@@ -227,7 +228,6 @@ struct stack_control_header {
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
@@ -241,11 +241,11 @@ struct stack_segment_linkage {
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
* segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
* microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
@@ -268,15 +268,14 @@ struct stack_segment_linkage {
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
#else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat {
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long maxc; /* Amount of contiguous space which would be
|
||||
* required to satisfy the maximum stack
|
||||
* demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
@@ -289,25 +288,24 @@ struct stk_stat {
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long current_size; /* Current stack segment size. This number is
|
||||
* actually corrupted by STKSTAT to include
|
||||
* the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer {
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long this_size; /* Size of this block (does not include this
|
||||
* trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
* segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
@@ -319,7 +317,6 @@ struct stk_trailer {
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
#endif /* CRAY2 */
|
||||
#endif /* not CRAY_STACK */
|
||||
|
||||
@@ -327,17 +324,18 @@ struct stk_trailer {
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long i00afunc(long *address)
|
||||
static long
|
||||
i00afunc(long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
/* We want to iterate through all of the segments. The first step is
|
||||
* to get the stack status structure. We could do this more quickly
|
||||
* and more directly, perhaps, by referencing the $LM00 common block,
|
||||
* but I know that this works. */
|
||||
|
||||
STKSTAT(&status);
|
||||
|
||||
@@ -346,8 +344,8 @@ static long i00afunc(long *address)
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size - 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
/* There must be at least one stack segment. Therefore it is a fatal
|
||||
* error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort();
|
||||
@@ -364,15 +362,14 @@ static long i00afunc(long *address)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
/* Set the result to the offset in this segment and add the sizes of
|
||||
* all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
do {
|
||||
if (trailer->this_size <= 0)
|
||||
abort();
|
||||
@@ -381,14 +378,13 @@ static long i00afunc(long *address)
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
/* We are done. Note that if you present a bogus address (one not in
|
||||
* any segment), you will get a different number back, formed from
|
||||
* subtracting the address of the first block. This is probably not
|
||||
* what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
@@ -396,7 +392,8 @@ static long i00afunc(long *address)
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long i00afunc(long address)
|
||||
static long
|
||||
i00afunc(long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
@@ -405,31 +402,30 @@ static long i00afunc(long address)
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
/* Register B67 contains the address of the end of the current stack
|
||||
* segment. If you (as a subprogram) store your registers on the
|
||||
* stack and find that you are past the contents of B67, you have
|
||||
* overflowed the segment.
|
||||
*
|
||||
* B67 also points to the stack segment linkage control area, which is
|
||||
* what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
/* If one subtracts 'size' from the end of the segment, one has the
|
||||
* address of the first word of the segment.
|
||||
*
|
||||
* If this is not the first segment, 'pseg' will be nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
/* It is possible that calling this routine itself caused a stack
|
||||
* overflow. Discard stack segments which do not contain the target
|
||||
* address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl)) {
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
@@ -447,10 +443,9 @@ static long i00afunc(long address)
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
/* If you subtract pseg from the current end of the stack, you get the
|
||||
* address of the previous stack segment's end. This seems a little
|
||||
* convoluted to me, but I'll bet you save a cycle somewhere. */
|
||||
|
||||
while (pseg != 0) {
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
@@ -464,7 +459,6 @@ static long i00afunc(long address)
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endif /* not CRAY2 */
|
||||
#endif /* CRAY */
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ ULONG ulMacroReturnValue;
|
||||
#define STAT_isMacroArg 2
|
||||
#define STAT_isREPTBlock 3
|
||||
|
||||
ULONG filesize(char *s)
|
||||
ULONG
|
||||
filesize(char *s)
|
||||
{
|
||||
FILE *f;
|
||||
ULONG size = 0;
|
||||
@@ -58,7 +59,6 @@ ULONG filesize(char *s)
|
||||
}
|
||||
return (size);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -66,7 +66,8 @@ ULONG filesize(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void pushcontext(void)
|
||||
void
|
||||
pushcontext(void)
|
||||
{
|
||||
struct sContext **ppFileStack;
|
||||
|
||||
@@ -103,7 +104,8 @@ void pushcontext(void)
|
||||
fatalerror("No memory for context");
|
||||
}
|
||||
|
||||
int popcontext(void)
|
||||
int
|
||||
popcontext(void)
|
||||
{
|
||||
struct sContext *pLastFile, **ppLastFile;
|
||||
|
||||
@@ -120,7 +122,6 @@ int popcontext(void)
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
if ((pLastFile = pFileStack) != NULL) {
|
||||
ppLastFile = &pFileStack;
|
||||
while (pLastFile->pNext) {
|
||||
@@ -167,11 +168,11 @@ int popcontext(void)
|
||||
return (1);
|
||||
}
|
||||
|
||||
int yywrap(void)
|
||||
int
|
||||
yywrap(void)
|
||||
{
|
||||
return (popcontext());
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -179,7 +180,8 @@ int yywrap(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void fstk_Dump(void)
|
||||
void
|
||||
fstk_Dump(void)
|
||||
{
|
||||
struct sContext *pLastFile;
|
||||
|
||||
@@ -192,7 +194,6 @@ void fstk_Dump(void)
|
||||
|
||||
printf("%s(%ld)", tzCurrentFileName, nLineNo);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -200,12 +201,14 @@ void fstk_Dump(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void fstk_AddIncludePath(char *s)
|
||||
void
|
||||
fstk_AddIncludePath(char *s)
|
||||
{
|
||||
strcpy(IncludePaths[NextIncPath++], s);
|
||||
}
|
||||
|
||||
void fstk_FindFile(char *s)
|
||||
void
|
||||
fstk_FindFile(char *s)
|
||||
{
|
||||
char t[_MAX_PATH + 1];
|
||||
SLONG i = -1;
|
||||
@@ -227,7 +230,6 @@ void fstk_FindFile(char *s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -235,7 +237,8 @@ void fstk_FindFile(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG fstk_RunInclude(char *s)
|
||||
ULONG
|
||||
fstk_RunInclude(char *s)
|
||||
{
|
||||
FILE *f;
|
||||
char tzFileName[_MAX_PATH + 1];
|
||||
@@ -264,7 +267,6 @@ ULONG fstk_RunInclude(char *s)
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -272,7 +274,8 @@ ULONG fstk_RunInclude(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG fstk_RunMacro(char *s)
|
||||
ULONG
|
||||
fstk_RunMacro(char *s)
|
||||
{
|
||||
struct sSymbol *sym;
|
||||
|
||||
@@ -292,7 +295,6 @@ ULONG fstk_RunMacro(char *s)
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -300,7 +302,8 @@ ULONG fstk_RunMacro(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void fstk_RunMacroArg(SLONG s)
|
||||
void
|
||||
fstk_RunMacroArg(SLONG s)
|
||||
{
|
||||
char *sym;
|
||||
|
||||
@@ -318,7 +321,6 @@ void fstk_RunMacroArg(SLONG s)
|
||||
} else
|
||||
fatalerror("No such macroargument");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -326,7 +328,8 @@ void fstk_RunMacroArg(SLONG s)
|
||||
*
|
||||
*/
|
||||
|
||||
void fstk_RunString(char *s)
|
||||
void
|
||||
fstk_RunString(char *s)
|
||||
{
|
||||
struct sSymbol *pSym;
|
||||
|
||||
@@ -340,7 +343,6 @@ void fstk_RunString(char *s)
|
||||
} else
|
||||
yyerror("No such string symbol");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -348,7 +350,8 @@ void fstk_RunString(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void fstk_RunRept(ULONG count)
|
||||
void
|
||||
fstk_RunRept(ULONG count)
|
||||
{
|
||||
if (count) {
|
||||
pushcontext();
|
||||
@@ -364,7 +367,6 @@ void fstk_RunRept(ULONG count)
|
||||
yy_switch_to_buffer(CurrentFlexHandle);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
*
|
||||
@@ -372,7 +374,8 @@ void fstk_RunRept(ULONG count)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG fstk_Init(char *s)
|
||||
ULONG
|
||||
fstk_Init(char *s)
|
||||
{
|
||||
char tzFileName[_MAX_PATH + 1];
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ UBYTE oDontExpandStrings = 0;
|
||||
SLONG nGBGfxID = -1;
|
||||
SLONG nBinaryID = -1;
|
||||
|
||||
SLONG gbgfx2bin(char ch)
|
||||
SLONG
|
||||
gbgfx2bin(char ch)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -29,7 +30,8 @@ SLONG gbgfx2bin(char ch)
|
||||
return (0);
|
||||
}
|
||||
|
||||
SLONG binary2bin(char ch)
|
||||
SLONG
|
||||
binary2bin(char ch)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -37,13 +39,13 @@ SLONG binary2bin(char ch)
|
||||
if (CurrentOptions.binary[i] == ch) {
|
||||
return (i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
SLONG char2bin(char ch)
|
||||
SLONG
|
||||
char2bin(char ch)
|
||||
{
|
||||
if (ch >= 'a' && ch <= 'f')
|
||||
return (ch - 'a' + 10);
|
||||
@@ -59,7 +61,8 @@ SLONG char2bin(char ch)
|
||||
|
||||
typedef SLONG(*x2bin) (char ch);
|
||||
|
||||
SLONG ascii2bin(char *s)
|
||||
SLONG
|
||||
ascii2bin(char *s)
|
||||
{
|
||||
SLONG radix = 10;
|
||||
SLONG result = 0;
|
||||
@@ -103,7 +106,8 @@ SLONG ascii2bin(char *s)
|
||||
return (result);
|
||||
}
|
||||
|
||||
ULONG ParseFixedPoint(char *s, ULONG size)
|
||||
ULONG
|
||||
ParseFixedPoint(char *s, ULONG size)
|
||||
{
|
||||
char dest[256];
|
||||
ULONG i = 0, dot = 0;
|
||||
@@ -128,7 +132,8 @@ ULONG ParseFixedPoint(char *s, ULONG size)
|
||||
return (1);
|
||||
}
|
||||
|
||||
ULONG ParseNumber(char *s, ULONG size)
|
||||
ULONG
|
||||
ParseNumber(char *s, ULONG size)
|
||||
{
|
||||
char dest[256];
|
||||
|
||||
@@ -139,7 +144,8 @@ ULONG ParseNumber(char *s, ULONG size)
|
||||
return (1);
|
||||
}
|
||||
|
||||
ULONG ParseSymbol(char *src, ULONG size)
|
||||
ULONG
|
||||
ParseSymbol(char *src, ULONG size)
|
||||
{
|
||||
char dest[MAXSYMLEN + 1];
|
||||
int copied = 0, size_backup = size;
|
||||
@@ -196,7 +202,8 @@ ULONG ParseSymbol(char *src, ULONG size)
|
||||
}
|
||||
}
|
||||
|
||||
ULONG PutMacroArg(char *src, ULONG size)
|
||||
ULONG
|
||||
PutMacroArg(char *src, ULONG size)
|
||||
{
|
||||
char *s;
|
||||
|
||||
@@ -209,7 +216,8 @@ ULONG PutMacroArg(char *src, ULONG size)
|
||||
return (0);
|
||||
}
|
||||
|
||||
ULONG PutUniqueArg(char *src, ULONG size)
|
||||
ULONG
|
||||
PutUniqueArg(char *src, ULONG size)
|
||||
{
|
||||
src = src;
|
||||
yyskipbytes(size);
|
||||
@@ -365,7 +373,8 @@ struct sLexFloat tMacroUniqueToken = {
|
||||
T_LEX_MACROUNIQUE
|
||||
};
|
||||
|
||||
void setuplex(void)
|
||||
void
|
||||
setuplex(void)
|
||||
{
|
||||
ULONG id;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ struct sLexString {
|
||||
ULONG nNameLength;
|
||||
struct sLexString *pNext;
|
||||
};
|
||||
|
||||
#define pLexBuffer (pCurrentBuffer->pBuffer)
|
||||
#define nLexBufferLeng (pCurrentBuffer->nBufferSize)
|
||||
|
||||
@@ -41,7 +40,8 @@ enum eLexerState lexerstate = LEX_STATE_NORMAL;
|
||||
#define AtLineStart pCurrentBuffer->oAtLineStart
|
||||
|
||||
#ifdef __GNUC__
|
||||
void strupr(char *s)
|
||||
void
|
||||
strupr(char *s)
|
||||
{
|
||||
while (*s) {
|
||||
*s = toupper(*s);
|
||||
@@ -49,31 +49,35 @@ void strupr(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
void strlwr(char *s)
|
||||
void
|
||||
strlwr(char *s)
|
||||
{
|
||||
while (*s) {
|
||||
*s = tolower(*s);
|
||||
s += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
void yyskipbytes(ULONG count)
|
||||
void
|
||||
yyskipbytes(ULONG count)
|
||||
{
|
||||
pLexBuffer += count;
|
||||
}
|
||||
|
||||
void yyunputbytes(ULONG count)
|
||||
void
|
||||
yyunputbytes(ULONG count)
|
||||
{
|
||||
pLexBuffer -= count;
|
||||
}
|
||||
|
||||
void yyunput(char c)
|
||||
void
|
||||
yyunput(char c)
|
||||
{
|
||||
*(--pLexBuffer) = c;
|
||||
}
|
||||
|
||||
void yyunputstr(char *s)
|
||||
void
|
||||
yyunputstr(char *s)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -83,23 +87,27 @@ void yyunputstr(char *s)
|
||||
yyunput(s[i--]);
|
||||
}
|
||||
|
||||
void yy_switch_to_buffer(YY_BUFFER_STATE buf)
|
||||
void
|
||||
yy_switch_to_buffer(YY_BUFFER_STATE buf)
|
||||
{
|
||||
pCurrentBuffer = buf;
|
||||
}
|
||||
|
||||
void yy_set_state(enum eLexerState i)
|
||||
void
|
||||
yy_set_state(enum eLexerState i)
|
||||
{
|
||||
lexerstate = i;
|
||||
}
|
||||
|
||||
void yy_delete_buffer(YY_BUFFER_STATE buf)
|
||||
void
|
||||
yy_delete_buffer(YY_BUFFER_STATE buf)
|
||||
{
|
||||
free(buf->pBufferStart - SAFETYMARGIN);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size)
|
||||
YY_BUFFER_STATE
|
||||
yy_scan_bytes(char *mem, ULONG size)
|
||||
{
|
||||
YY_BUFFER_STATE pBuffer;
|
||||
|
||||
@@ -117,12 +125,12 @@ YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size)
|
||||
return (pBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
fatalerror("Out of memory!");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
YY_BUFFER_STATE yy_create_buffer(FILE * f)
|
||||
YY_BUFFER_STATE
|
||||
yy_create_buffer(FILE * f)
|
||||
{
|
||||
YY_BUFFER_STATE pBuffer;
|
||||
|
||||
@@ -187,19 +195,20 @@ YY_BUFFER_STATE yy_create_buffer(FILE * f)
|
||||
return (pBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
fatalerror("Out of memory!");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ULONG lex_FloatAlloc(struct sLexFloat * tok)
|
||||
ULONG
|
||||
lex_FloatAlloc(struct sLexFloat * tok)
|
||||
{
|
||||
tLexFloat[nFloating] = (*tok);
|
||||
|
||||
return (1 << (nFloating++));
|
||||
}
|
||||
|
||||
void lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingChars[start] &= ~id;
|
||||
@@ -207,7 +216,8 @@ void lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
void lex_FloatAddRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatAddRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingChars[start] |= id;
|
||||
@@ -215,7 +225,8 @@ void lex_FloatAddRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
void lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingFirstChar[start] &= ~id;
|
||||
@@ -223,7 +234,8 @@ void lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
void lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingFirstChar[start] |= id;
|
||||
@@ -231,7 +243,8 @@ void lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
void lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingSecondChar[start] &= ~id;
|
||||
@@ -239,7 +252,8 @@ void lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
void lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
void
|
||||
lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
{
|
||||
while (start <= end) {
|
||||
tFloatingSecondChar[start] |= id;
|
||||
@@ -247,7 +261,8 @@ void lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end)
|
||||
}
|
||||
}
|
||||
|
||||
struct sLexFloat *lexgetfloat(ULONG id)
|
||||
struct sLexFloat *
|
||||
lexgetfloat(ULONG id)
|
||||
{
|
||||
ULONG r = 0, mask = 1;
|
||||
|
||||
@@ -262,7 +277,8 @@ struct sLexFloat *lexgetfloat(ULONG id)
|
||||
return (&tLexFloat[r]);
|
||||
}
|
||||
|
||||
ULONG lexcalchash(char *s)
|
||||
ULONG
|
||||
lexcalchash(char *s)
|
||||
{
|
||||
ULONG r = 0;
|
||||
|
||||
@@ -274,7 +290,8 @@ ULONG lexcalchash(char *s)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void lex_Init(void)
|
||||
void
|
||||
lex_Init(void)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
@@ -292,7 +309,8 @@ void lex_Init(void)
|
||||
nFloating = 0;
|
||||
}
|
||||
|
||||
void lex_AddStrings(struct sLexInitString *lex)
|
||||
void
|
||||
lex_AddStrings(struct sLexInitString * lex)
|
||||
{
|
||||
while (lex->tzName) {
|
||||
struct sLexString **ppHash;
|
||||
@@ -327,7 +345,8 @@ void lex_AddStrings(struct sLexInitString *lex)
|
||||
}
|
||||
}
|
||||
|
||||
ULONG yylex(void)
|
||||
ULONG
|
||||
yylex(void)
|
||||
{
|
||||
ULONG hash, maxlen;
|
||||
char *s;
|
||||
@@ -353,7 +372,6 @@ ULONG yylex(void)
|
||||
goto scanagain;
|
||||
}
|
||||
}
|
||||
|
||||
s = pLexBuffer;
|
||||
nOldFloatMask = nFloatLen = 0;
|
||||
nFloatMask = tFloatingFirstChar[(int) *s++];
|
||||
@@ -392,7 +410,6 @@ ULONG yylex(void)
|
||||
lex = lex->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nFloatLen == 0 && pLongestFixed == NULL) {
|
||||
@@ -462,8 +479,7 @@ ULONG yylex(void)
|
||||
*pLexBuffer++) ==
|
||||
'\\') {
|
||||
switch (ch =
|
||||
(*pLexBuffer++))
|
||||
{
|
||||
(*pLexBuffer++)) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
@@ -506,7 +522,6 @@ ULONG yylex(void)
|
||||
yyerror("Missing }");
|
||||
ch = 0;
|
||||
}
|
||||
|
||||
if (ch)
|
||||
yylval.tzString[index++] = ch;
|
||||
}
|
||||
@@ -582,13 +597,11 @@ ULONG yylex(void)
|
||||
return (*pLexBuffer++);
|
||||
}
|
||||
}
|
||||
|
||||
if (nFloatLen == 0) {
|
||||
yyleng = pLongestFixed->nNameLength;
|
||||
pLexBuffer += yyleng;
|
||||
return (pLongestFixed->nToken);
|
||||
}
|
||||
|
||||
if (pLongestFixed == NULL) {
|
||||
struct sLexFloat *tok;
|
||||
|
||||
@@ -598,7 +611,6 @@ ULONG yylex(void)
|
||||
if (tok->Callback(pLexBuffer, yyleng) == 0)
|
||||
goto scanagain;
|
||||
}
|
||||
|
||||
if (tok->nToken == T_ID && linestart) {
|
||||
pLexBuffer += yyleng;
|
||||
return (T_LABEL);
|
||||
@@ -607,7 +619,6 @@ ULONG yylex(void)
|
||||
return (tok->nToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (nFloatLen > pLongestFixed->nNameLength) {
|
||||
struct sLexFloat *tok;
|
||||
|
||||
@@ -617,7 +628,6 @@ ULONG yylex(void)
|
||||
if (tok->Callback(pLexBuffer, yyleng) == 0)
|
||||
goto scanagain;
|
||||
}
|
||||
|
||||
if (tok->nToken == T_ID && linestart) {
|
||||
pLexBuffer += yyleng;
|
||||
return (T_LABEL);
|
||||
@@ -698,8 +708,7 @@ ULONG yylex(void)
|
||||
if ((ch =
|
||||
*pLexBuffer++) == '\\') {
|
||||
switch (ch =
|
||||
(*pLexBuffer++))
|
||||
{
|
||||
(*pLexBuffer++)) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
@@ -747,7 +756,6 @@ ULONG yylex(void)
|
||||
yyerror("Missing }");
|
||||
ch = 0;
|
||||
}
|
||||
|
||||
if (ch)
|
||||
yylval.tzString[index++] = ch;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ struct sOptionStackEntry {
|
||||
|
||||
struct sOptionStackEntry *pOptionStack = NULL;
|
||||
|
||||
void opt_SetCurrentOptions(struct sOptions *pOpt)
|
||||
void
|
||||
opt_SetCurrentOptions(struct sOptions * pOpt)
|
||||
{
|
||||
if (nGBGfxID != -1) {
|
||||
lex_FloatDeleteRange(nGBGfxID, CurrentOptions.gbgfx[0],
|
||||
@@ -76,7 +77,6 @@ void opt_SetCurrentOptions(struct sOptions *pOpt)
|
||||
lex_FloatDeleteSecondRange(nGBGfxID, CurrentOptions.gbgfx[3],
|
||||
CurrentOptions.gbgfx[3]);
|
||||
}
|
||||
|
||||
if (nBinaryID != -1) {
|
||||
lex_FloatDeleteRange(nBinaryID, CurrentOptions.binary[0],
|
||||
CurrentOptions.binary[0]);
|
||||
@@ -87,7 +87,6 @@ void opt_SetCurrentOptions(struct sOptions *pOpt)
|
||||
lex_FloatDeleteSecondRange(nBinaryID, CurrentOptions.binary[1],
|
||||
CurrentOptions.binary[1]);
|
||||
}
|
||||
|
||||
CurrentOptions = *pOpt;
|
||||
|
||||
if (nGBGfxID != -1) {
|
||||
@@ -108,7 +107,6 @@ void opt_SetCurrentOptions(struct sOptions *pOpt)
|
||||
lex_FloatAddSecondRange(nGBGfxID, CurrentOptions.gbgfx[3],
|
||||
CurrentOptions.gbgfx[3]);
|
||||
}
|
||||
|
||||
if (nBinaryID != -1) {
|
||||
lex_FloatAddRange(nBinaryID, CurrentOptions.binary[0],
|
||||
CurrentOptions.binary[0]);
|
||||
@@ -119,10 +117,10 @@ void opt_SetCurrentOptions(struct sOptions *pOpt)
|
||||
lex_FloatAddSecondRange(nBinaryID, CurrentOptions.binary[1],
|
||||
CurrentOptions.binary[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void opt_Parse(char *s)
|
||||
void
|
||||
opt_Parse(char *s)
|
||||
{
|
||||
struct sOptions newopt;
|
||||
|
||||
@@ -197,7 +195,8 @@ void opt_Parse(char *s)
|
||||
opt_SetCurrentOptions(&newopt);
|
||||
}
|
||||
|
||||
void opt_Push(void)
|
||||
void
|
||||
opt_Push(void)
|
||||
{
|
||||
struct sOptionStackEntry *pOpt;
|
||||
|
||||
@@ -211,7 +210,8 @@ void opt_Push(void)
|
||||
fatalerror("No memory for option stack");
|
||||
}
|
||||
|
||||
void opt_Pop(void)
|
||||
void
|
||||
opt_Pop(void)
|
||||
{
|
||||
if (pOptionStack) {
|
||||
struct sOptionStackEntry *pOpt;
|
||||
@@ -223,7 +223,6 @@ void opt_Pop(void)
|
||||
} else
|
||||
fatalerror("No entries in the option stack");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MAIN.C
|
||||
*
|
||||
@@ -231,7 +230,8 @@ void opt_Pop(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void yyerror(char *s)
|
||||
void
|
||||
yyerror(char *s)
|
||||
{
|
||||
printf("*ERROR*\t");
|
||||
fstk_Dump();
|
||||
@@ -239,12 +239,12 @@ void yyerror(char *s)
|
||||
nErrors += 1;
|
||||
}
|
||||
|
||||
void fatalerror(char *s)
|
||||
void
|
||||
fatalerror(char *s)
|
||||
{
|
||||
yyerror(s);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MAIN.C
|
||||
*
|
||||
@@ -252,7 +252,8 @@ void fatalerror(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void PrintUsage(void)
|
||||
void
|
||||
PrintUsage(void)
|
||||
{
|
||||
printf(APPNAME " v" ASM_VERSION " (part of ASMotor " ASMOTOR_VERSION
|
||||
")\n\nUsage: " EXENAME " [options] asmfile\n");
|
||||
@@ -272,7 +273,6 @@ void PrintUsage(void)
|
||||
"\t\t\tdata (default is ? for random)\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MAIN.C
|
||||
*
|
||||
@@ -280,7 +280,8 @@ void PrintUsage(void)
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *tzMainfile;
|
||||
int argn = 1;
|
||||
@@ -299,7 +300,8 @@ int main(int argc, char *argv[])
|
||||
DefaultOptions.gbgfx[3] = '3';
|
||||
DefaultOptions.binary[0] = '0';
|
||||
DefaultOptions.binary[1] = '1';
|
||||
DefaultOptions.fillchar = -1; // fill uninitialised data with random values
|
||||
DefaultOptions.fillchar = -1;
|
||||
//fill uninitialised data with random values
|
||||
opt_SetCurrentOptions(&DefaultOptions);
|
||||
|
||||
while (argv[argn][0] == '-' && argc) {
|
||||
@@ -331,8 +333,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
DefaultOptions = CurrentOptions;
|
||||
|
||||
/*tzMainfile=argv[argn++];
|
||||
* argc-=1; */
|
||||
/* tzMainfile=argv[argn++]; argc-=1; */
|
||||
tzMainfile = argv[argn];
|
||||
|
||||
setuplex();
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void math_DefinePI(void)
|
||||
void
|
||||
math_DefinePI(void)
|
||||
{
|
||||
sym_AddEqu("_PI", double2fix(PI));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -37,7 +37,8 @@ void math_DefinePI(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void math_Print(SLONG i)
|
||||
void
|
||||
math_Print(SLONG i)
|
||||
{
|
||||
if (i >= 0)
|
||||
printf("%ld.%05ld", i >> 16,
|
||||
@@ -46,7 +47,6 @@ void math_Print(SLONG i)
|
||||
printf("-%ld.%05ld", (-i) >> 16,
|
||||
((SLONG) (fix2double(-i) * 100000 + 0.5)) % 100000);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -54,11 +54,11 @@ void math_Print(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_Sin(SLONG i)
|
||||
SLONG
|
||||
math_Sin(SLONG i)
|
||||
{
|
||||
return (double2fix(sin(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -66,11 +66,11 @@ SLONG math_Sin(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_Cos(SLONG i)
|
||||
SLONG
|
||||
math_Cos(SLONG i)
|
||||
{
|
||||
return (double2fix(cos(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -78,11 +78,11 @@ SLONG math_Cos(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_Tan(SLONG i)
|
||||
SLONG
|
||||
math_Tan(SLONG i)
|
||||
{
|
||||
return (double2fix(tan(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -90,11 +90,11 @@ SLONG math_Tan(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_ASin(SLONG i)
|
||||
SLONG
|
||||
math_ASin(SLONG i)
|
||||
{
|
||||
return (double2fix(asin(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -102,11 +102,11 @@ SLONG math_ASin(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_ACos(SLONG i)
|
||||
SLONG
|
||||
math_ACos(SLONG i)
|
||||
{
|
||||
return (double2fix(acos(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -114,11 +114,11 @@ SLONG math_ACos(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_ATan(SLONG i)
|
||||
SLONG
|
||||
math_ATan(SLONG i)
|
||||
{
|
||||
return (double2fix(atan(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -126,12 +126,12 @@ SLONG math_ATan(SLONG i)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_ATan2(SLONG i, SLONG j)
|
||||
SLONG
|
||||
math_ATan2(SLONG i, SLONG j)
|
||||
{
|
||||
return (double2fix
|
||||
(atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -139,11 +139,11 @@ SLONG math_ATan2(SLONG i, SLONG j)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_Mul(SLONG i, SLONG j)
|
||||
SLONG
|
||||
math_Mul(SLONG i, SLONG j)
|
||||
{
|
||||
return (double2fix(fix2double(i) * fix2double(j)));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - MATH.C (Fixedpoint math routines)
|
||||
*
|
||||
@@ -151,7 +151,8 @@ SLONG math_Mul(SLONG i, SLONG j)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG math_Div(SLONG i, SLONG j)
|
||||
SLONG
|
||||
math_Div(SLONG i, SLONG j)
|
||||
{
|
||||
return (double2fix(fix2double(i) / fix2double(j)));
|
||||
}
|
||||
|
||||
156
src/asm/output.c
156
src/asm/output.c
@@ -48,7 +48,6 @@ struct SectionStackEntry {
|
||||
struct Section *pSection;
|
||||
struct SectionStackEntry *pNext;
|
||||
};
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -68,7 +67,8 @@ struct SectionStackEntry *pSectionStack = NULL;
|
||||
*
|
||||
*/
|
||||
|
||||
void out_PushSection(void)
|
||||
void
|
||||
out_PushSection(void)
|
||||
{
|
||||
struct SectionStackEntry *pSect;
|
||||
|
||||
@@ -82,7 +82,8 @@ void out_PushSection(void)
|
||||
fatalerror("No memory for section stack");
|
||||
}
|
||||
|
||||
void out_PopSection(void)
|
||||
void
|
||||
out_PopSection(void)
|
||||
{
|
||||
if (pSectionStack) {
|
||||
struct SectionStackEntry *pSect;
|
||||
@@ -94,7 +95,6 @@ void out_PopSection(void)
|
||||
} else
|
||||
fatalerror("No entries in the section stack");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -102,7 +102,8 @@ void out_PopSection(void)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG countsymbols(void)
|
||||
ULONG
|
||||
countsymbols(void)
|
||||
{
|
||||
struct PatchSymbol *pSym;
|
||||
ULONG count = 0;
|
||||
@@ -116,7 +117,6 @@ ULONG countsymbols(void)
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -124,7 +124,8 @@ ULONG countsymbols(void)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG countsections(void)
|
||||
ULONG
|
||||
countsections(void)
|
||||
{
|
||||
struct Section *pSect;
|
||||
ULONG count = 0;
|
||||
@@ -138,7 +139,6 @@ ULONG countsections(void)
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -146,7 +146,8 @@ ULONG countsections(void)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG countpatches(struct Section * pSect)
|
||||
ULONG
|
||||
countpatches(struct Section * pSect)
|
||||
{
|
||||
struct Patch *pPatch;
|
||||
ULONG r = 0;
|
||||
@@ -159,7 +160,6 @@ ULONG countpatches(struct Section * pSect)
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -167,14 +167,14 @@ ULONG countpatches(struct Section * pSect)
|
||||
*
|
||||
*/
|
||||
|
||||
void fputlong(ULONG i, FILE * f)
|
||||
void
|
||||
fputlong(ULONG i, FILE * f)
|
||||
{
|
||||
fputc(i, f);
|
||||
fputc(i >> 8, f);
|
||||
fputc(i >> 16, f);
|
||||
fputc(i >> 24, f);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -182,13 +182,13 @@ void fputlong(ULONG i, FILE * f)
|
||||
*
|
||||
*/
|
||||
|
||||
void fputstring(char *s, FILE * f)
|
||||
void
|
||||
fputstring(char *s, FILE * f)
|
||||
{
|
||||
while (*s)
|
||||
fputc(*s++, f);
|
||||
fputc(0, f);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -196,7 +196,8 @@ void fputstring(char *s, FILE * f)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG getsectid(struct Section *pSect)
|
||||
ULONG
|
||||
getsectid(struct Section * pSect)
|
||||
{
|
||||
struct Section *sec;
|
||||
ULONG ID = 0;
|
||||
@@ -213,7 +214,6 @@ ULONG getsectid(struct Section *pSect)
|
||||
fatalerror("INTERNAL: Unknown section");
|
||||
return ((ULONG) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -221,7 +221,8 @@ ULONG getsectid(struct Section *pSect)
|
||||
*
|
||||
*/
|
||||
|
||||
void writepatch(struct Patch *pPatch, FILE * f)
|
||||
void
|
||||
writepatch(struct Patch * pPatch, FILE * f)
|
||||
{
|
||||
fputstring(pPatch->tzFilename, f);
|
||||
fputlong(pPatch->nLine, f);
|
||||
@@ -230,7 +231,6 @@ void writepatch(struct Patch *pPatch, FILE * f)
|
||||
fputlong(pPatch->nRPNSize, f);
|
||||
fwrite(pPatch->pRPN, 1, pPatch->nRPNSize, f);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -238,15 +238,18 @@ void writepatch(struct Patch *pPatch, FILE * f)
|
||||
*
|
||||
*/
|
||||
|
||||
void writesection(struct Section *pSect, FILE * f)
|
||||
void
|
||||
writesection(struct Section * pSect, FILE * f)
|
||||
{
|
||||
//printf("SECTION: %s, ID: %d\n", pSect->pzName, getsectid(pSect));
|
||||
|
||||
fputlong(pSect->nPC, f);
|
||||
fputc(pSect->nType, f);
|
||||
fputlong(pSect->nOrg, f); // RGB1 addition
|
||||
fputlong(pSect->nOrg, f);
|
||||
//RGB1 addition
|
||||
|
||||
fputlong(pSect->nBank, f); // RGB1 addition
|
||||
fputlong(pSect->nBank, f);
|
||||
//RGB1 addition
|
||||
|
||||
if ((pSect->nType == SECT_HOME)
|
||||
|| (pSect->nType == SECT_CODE)) {
|
||||
@@ -262,7 +265,6 @@ void writesection(struct Section *pSect, FILE * f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -270,7 +272,8 @@ void writesection(struct Section *pSect, FILE * f)
|
||||
*
|
||||
*/
|
||||
|
||||
void writesymbol(struct sSymbol *pSym, FILE * f)
|
||||
void
|
||||
writesymbol(struct sSymbol * pSym, FILE * f)
|
||||
{
|
||||
char symname[MAXSYMLEN * 2 + 1];
|
||||
ULONG type;
|
||||
@@ -312,7 +315,6 @@ void writesymbol(struct sSymbol *pSym, FILE * f)
|
||||
fputlong(offset, f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -320,7 +322,8 @@ void writesymbol(struct sSymbol *pSym, FILE * f)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG addsymbol(struct sSymbol *pSym)
|
||||
ULONG
|
||||
addsymbol(struct sSymbol * pSym)
|
||||
{
|
||||
struct PatchSymbol *pPSym, **ppPSym;
|
||||
ULONG ID = 0;
|
||||
@@ -348,7 +351,6 @@ ULONG addsymbol(struct sSymbol *pSym)
|
||||
|
||||
return ((ULONG) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -356,7 +358,8 @@ ULONG addsymbol(struct sSymbol *pSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void addexports(void)
|
||||
void
|
||||
addexports(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -371,7 +374,6 @@ void addexports(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -379,7 +381,8 @@ void addexports(void)
|
||||
*
|
||||
*/
|
||||
|
||||
struct Patch *allocpatch(void)
|
||||
struct Patch *
|
||||
allocpatch(void)
|
||||
{
|
||||
struct Patch *pPatch, **ppPatch;
|
||||
|
||||
@@ -401,7 +404,6 @@ struct Patch *allocpatch(void)
|
||||
|
||||
return (pPatch);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -409,7 +411,8 @@ struct Patch *allocpatch(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void createpatch(ULONG type, struct Expression *expr)
|
||||
void
|
||||
createpatch(ULONG type, struct Expression * expr)
|
||||
{
|
||||
struct Patch *pPatch;
|
||||
UWORD rpndata;
|
||||
@@ -473,7 +476,6 @@ void createpatch(ULONG type, struct Expression *expr)
|
||||
pPatch->nRPNSize = rpnptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -481,14 +483,14 @@ void createpatch(ULONG type, struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void checksection(void)
|
||||
void
|
||||
checksection(void)
|
||||
{
|
||||
if (pCurrentSection)
|
||||
return;
|
||||
else
|
||||
fatalerror("Code generation before SECTION directive");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -497,7 +499,8 @@ void checksection(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void checkcodesection(SLONG size)
|
||||
void
|
||||
checkcodesection(SLONG size)
|
||||
{
|
||||
checksection();
|
||||
if ((pCurrentSection->nType == SECT_HOME
|
||||
@@ -522,7 +525,6 @@ void checkcodesection(SLONG size)
|
||||
fatalerror
|
||||
("Section can't contain initialized data or section limit exceeded");
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -530,7 +532,8 @@ void checkcodesection(SLONG size)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_WriteObject(void)
|
||||
void
|
||||
out_WriteObject(void)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -559,7 +562,6 @@ void out_WriteObject(void)
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -567,7 +569,8 @@ void out_WriteObject(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_PrepPass2(void)
|
||||
void
|
||||
out_PrepPass2(void)
|
||||
{
|
||||
struct Section *pSect;
|
||||
|
||||
@@ -579,7 +582,6 @@ void out_PrepPass2(void)
|
||||
pCurrentSection = NULL;
|
||||
pSectionStack = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -587,7 +589,8 @@ void out_PrepPass2(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_SetFileName(char *s)
|
||||
void
|
||||
out_SetFileName(char *s)
|
||||
{
|
||||
strcpy(tzObjectname, s);
|
||||
printf("Output filename %s\n", s);
|
||||
@@ -595,7 +598,6 @@ void out_SetFileName(char *s)
|
||||
pCurrentSection = NULL;
|
||||
pPatchSymbols = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -603,7 +605,8 @@ void out_SetFileName(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
struct Section *out_FindSection(char *pzName, ULONG secttype, SLONG org,
|
||||
struct Section *
|
||||
out_FindSection(char *pzName, ULONG secttype, SLONG org,
|
||||
SLONG bank)
|
||||
{
|
||||
struct Section *pSect, **ppSect;
|
||||
@@ -651,7 +654,6 @@ struct Section *out_FindSection(char *pzName, ULONG secttype, SLONG org,
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -659,7 +661,8 @@ struct Section *out_FindSection(char *pzName, ULONG secttype, SLONG org,
|
||||
*
|
||||
*/
|
||||
|
||||
void out_SetCurrentSection(struct Section *pSect)
|
||||
void
|
||||
out_SetCurrentSection(struct Section * pSect)
|
||||
{
|
||||
pCurrentSection = pSect;
|
||||
nPC = pSect->nPC;
|
||||
@@ -667,7 +670,6 @@ void out_SetCurrentSection(struct Section *pSect)
|
||||
pPCSymbol->nValue = nPC;
|
||||
pPCSymbol->pSection = pCurrentSection;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -675,11 +677,11 @@ void out_SetCurrentSection(struct Section *pSect)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_NewSection(char *pzName, ULONG secttype)
|
||||
void
|
||||
out_NewSection(char *pzName, ULONG secttype)
|
||||
{
|
||||
out_SetCurrentSection(out_FindSection(pzName, secttype, -1, -1));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -687,11 +689,11 @@ 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, SLONG org, SLONG bank)
|
||||
{
|
||||
out_SetCurrentSection(out_FindSection(pzName, secttype, org, bank));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -699,7 +701,8 @@ void out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_AbsByte(int b)
|
||||
void
|
||||
out_AbsByte(int b)
|
||||
{
|
||||
checkcodesection(1);
|
||||
b &= 0xFF;
|
||||
@@ -710,7 +713,6 @@ void out_AbsByte(int b)
|
||||
nPC += 1;
|
||||
pPCSymbol->nValue += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -718,7 +720,8 @@ void out_AbsByte(int b)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_Skip(int skip)
|
||||
void
|
||||
out_Skip(int skip)
|
||||
{
|
||||
checksection();
|
||||
if ((CurrentOptions.fillchar == -1)
|
||||
@@ -733,7 +736,6 @@ void out_Skip(int skip)
|
||||
out_AbsByte(CurrentOptions.fillchar);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -741,13 +743,13 @@ void out_Skip(int skip)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_String(char *s)
|
||||
void
|
||||
out_String(char *s)
|
||||
{
|
||||
checkcodesection(strlen(s));
|
||||
while (*s)
|
||||
out_AbsByte(*s++);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -756,7 +758,8 @@ void out_String(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_RelByte(struct Expression *expr)
|
||||
void
|
||||
out_RelByte(struct Expression * expr)
|
||||
{
|
||||
checkcodesection(1);
|
||||
if (rpn_isReloc(expr)) {
|
||||
@@ -772,7 +775,6 @@ void out_RelByte(struct Expression *expr)
|
||||
|
||||
rpn_Reset(expr);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -780,7 +782,8 @@ void out_RelByte(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_AbsWord(int b)
|
||||
void
|
||||
out_AbsWord(int b)
|
||||
{
|
||||
checkcodesection(2);
|
||||
b &= 0xFFFF;
|
||||
@@ -798,7 +801,6 @@ void out_AbsWord(int b)
|
||||
nPC += 2;
|
||||
pPCSymbol->nValue += 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -807,7 +809,8 @@ void out_AbsWord(int b)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_RelWord(struct Expression *expr)
|
||||
void
|
||||
out_RelWord(struct Expression * expr)
|
||||
{
|
||||
ULONG b;
|
||||
|
||||
@@ -833,7 +836,6 @@ void out_RelWord(struct Expression *expr)
|
||||
out_AbsWord(expr->nVal);
|
||||
rpn_Reset(expr);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -841,7 +843,8 @@ void out_RelWord(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_AbsLong(SLONG b)
|
||||
void
|
||||
out_AbsLong(SLONG b)
|
||||
{
|
||||
checkcodesection(sizeof(SLONG));
|
||||
if (nPass == 2) {
|
||||
@@ -862,7 +865,6 @@ void out_AbsLong(SLONG b)
|
||||
nPC += 4;
|
||||
pPCSymbol->nValue += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -871,7 +873,8 @@ void out_AbsLong(SLONG b)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_RelLong(struct Expression *expr)
|
||||
void
|
||||
out_RelLong(struct Expression * expr)
|
||||
{
|
||||
SLONG b;
|
||||
|
||||
@@ -901,7 +904,6 @@ void out_RelLong(struct Expression *expr)
|
||||
out_AbsLong(expr->nVal);
|
||||
rpn_Reset(expr);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -909,7 +911,8 @@ void out_RelLong(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_PCRelByte(struct Expression *expr)
|
||||
void
|
||||
out_PCRelByte(struct Expression * expr)
|
||||
{
|
||||
SLONG b = expr->nVal;
|
||||
|
||||
@@ -921,7 +924,6 @@ void out_PCRelByte(struct Expression *expr)
|
||||
out_AbsByte(b);
|
||||
rpn_Reset(expr);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - OUTPUT.C - Outputs an objectfile
|
||||
*
|
||||
@@ -929,7 +931,8 @@ void out_PCRelByte(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void out_BinaryFile(char *s)
|
||||
void
|
||||
out_BinaryFile(char *s)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -951,7 +954,6 @@ void out_BinaryFile(char *s)
|
||||
while (todo--)
|
||||
pCurrentSection->tData[dest++] = fgetc(f);
|
||||
}
|
||||
|
||||
pCurrentSection->nPC += fsize;
|
||||
nPC += fsize;
|
||||
pPCSymbol->nValue += fsize;
|
||||
@@ -960,7 +962,8 @@ void out_BinaryFile(char *s)
|
||||
fatalerror("File not found");
|
||||
}
|
||||
|
||||
void out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
|
||||
void
|
||||
out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -972,8 +975,7 @@ void out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
|
||||
|
||||
fstk_FindFile(s);
|
||||
|
||||
if( (f=fopen(s,"rb"))!=NULL )
|
||||
{
|
||||
if ((f = fopen(s, "rb")) != NULL) {
|
||||
SLONG fsize;
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
@@ -989,22 +991,18 @@ void out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
|
||||
|
||||
checkcodesection(length);
|
||||
|
||||
if (nPass == 2)
|
||||
{
|
||||
if (nPass == 2) {
|
||||
SLONG dest = nPC;
|
||||
SLONG todo = length;
|
||||
|
||||
while (todo--)
|
||||
pCurrentSection->tData[dest++] = fgetc(f);
|
||||
}
|
||||
|
||||
pCurrentSection->nPC += length;
|
||||
nPC += length;
|
||||
pPCSymbol->nValue += length;
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
} else
|
||||
fatalerror("File not found");
|
||||
}
|
||||
|
||||
|
||||
106
src/asm/rpn.c
106
src/asm/rpn.c
@@ -15,7 +15,8 @@
|
||||
#include "asm/main.h"
|
||||
#include "asm/rpn.h"
|
||||
|
||||
void mergetwoexpressions(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
mergetwoexpressions(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
*expr = *src1;
|
||||
@@ -25,7 +26,6 @@ void mergetwoexpressions(struct Expression *expr, struct Expression *src1,
|
||||
expr->isReloc |= src2->isReloc;
|
||||
expr->isPCRel |= src2->isPCRel;
|
||||
}
|
||||
|
||||
#define joinexpr() mergetwoexpressions(expr,src1,src2)
|
||||
|
||||
/*
|
||||
@@ -48,11 +48,11 @@ void mergetwoexpressions(struct Expression *expr, struct Expression *src1,
|
||||
*
|
||||
*/
|
||||
|
||||
void pushbyte(struct Expression *expr, int b)
|
||||
void
|
||||
pushbyte(struct Expression * expr, int b)
|
||||
{
|
||||
expr->tRPN[expr->nRPNLength++] = b & 0xFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - RPN.C - Controls RPN expressions for objectfiles
|
||||
*
|
||||
@@ -60,11 +60,11 @@ void pushbyte(struct Expression *expr, int b)
|
||||
*
|
||||
*/
|
||||
|
||||
void rpn_Reset(struct Expression *expr)
|
||||
void
|
||||
rpn_Reset(struct Expression * expr)
|
||||
{
|
||||
expr->nRPNLength = expr->nRPNOut = expr->isReloc = expr->isPCRel = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - RPN.C - Controls RPN expressions for objectfiles
|
||||
*
|
||||
@@ -72,14 +72,14 @@ void rpn_Reset(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
UWORD rpn_PopByte(struct Expression *expr)
|
||||
UWORD
|
||||
rpn_PopByte(struct Expression * expr)
|
||||
{
|
||||
if (expr->nRPNOut == expr->nRPNLength) {
|
||||
return (0xDEAD);
|
||||
} else
|
||||
return (expr->tRPN[expr->nRPNOut++]);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - RPN.C - Controls RPN expressions for objectfiles
|
||||
*
|
||||
@@ -87,11 +87,11 @@ UWORD rpn_PopByte(struct Expression *expr)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG rpn_isReloc(struct Expression * expr)
|
||||
ULONG
|
||||
rpn_isReloc(struct Expression * expr)
|
||||
{
|
||||
return (expr->isReloc);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - RPN.C - Controls RPN expressions for objectfiles
|
||||
*
|
||||
@@ -99,11 +99,11 @@ ULONG rpn_isReloc(struct Expression * expr)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG rpn_isPCRelative(struct Expression * expr)
|
||||
ULONG
|
||||
rpn_isPCRelative(struct Expression * expr)
|
||||
{
|
||||
return (expr->isPCRel);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - RPN.C - Controls RPN expressions for objectfiles
|
||||
*
|
||||
@@ -111,7 +111,8 @@ ULONG rpn_isPCRelative(struct Expression * expr)
|
||||
*
|
||||
*/
|
||||
|
||||
void rpn_Number(struct Expression *expr, ULONG i)
|
||||
void
|
||||
rpn_Number(struct Expression * expr, ULONG i)
|
||||
{
|
||||
rpn_Reset(expr);
|
||||
pushbyte(expr, RPN_CONST);
|
||||
@@ -122,7 +123,8 @@ void rpn_Number(struct Expression *expr, ULONG i)
|
||||
expr->nVal = i;
|
||||
}
|
||||
|
||||
void rpn_Symbol(struct Expression *expr, char *tzSym)
|
||||
void
|
||||
rpn_Symbol(struct Expression * expr, char *tzSym)
|
||||
{
|
||||
if (!sym_isConstant(tzSym)) {
|
||||
struct sSymbol *psym;
|
||||
@@ -143,7 +145,8 @@ void rpn_Symbol(struct Expression *expr, char *tzSym)
|
||||
rpn_Number(expr, sym_GetConstantValue(tzSym));
|
||||
}
|
||||
|
||||
void rpn_Bank(struct Expression *expr, char *tzSym)
|
||||
void
|
||||
rpn_Bank(struct Expression * expr, char *tzSym)
|
||||
{
|
||||
if (!sym_isConstant(tzSym)) {
|
||||
struct sSymbol *psym;
|
||||
@@ -164,7 +167,8 @@ void rpn_Bank(struct Expression *expr, char *tzSym)
|
||||
yyerror("BANK argument must be a relocatable identifier");
|
||||
}
|
||||
|
||||
int rpn_RangeCheck(struct Expression *expr, struct Expression *src, SLONG low,
|
||||
int
|
||||
rpn_RangeCheck(struct Expression * expr, struct Expression * src, SLONG low,
|
||||
SLONG high)
|
||||
{
|
||||
*expr = *src;
|
||||
@@ -184,9 +188,9 @@ int rpn_RangeCheck(struct Expression *expr, struct Expression *src, SLONG low,
|
||||
return (expr->nVal >= low && expr->nVal <= high);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GAMEBOY
|
||||
void rpn_CheckHRAM(struct Expression *expr, struct Expression *src)
|
||||
void
|
||||
rpn_CheckHRAM(struct Expression * expr, struct Expression * src)
|
||||
{
|
||||
*expr = *src;
|
||||
pushbyte(expr, RPN_HRAM);
|
||||
@@ -194,20 +198,23 @@ void rpn_CheckHRAM(struct Expression *expr, struct Expression *src)
|
||||
#endif
|
||||
|
||||
#ifdef PCENGINE
|
||||
void rpn_CheckZP(struct Expression *expr, struct Expression *src)
|
||||
void
|
||||
rpn_CheckZP(struct Expression * expr, struct Expression * src)
|
||||
{
|
||||
*expr = *src;
|
||||
pushbyte(expr, RPN_PCEZP);
|
||||
}
|
||||
#endif
|
||||
|
||||
void rpn_LOGNOT(struct Expression *expr, struct Expression *src)
|
||||
void
|
||||
rpn_LOGNOT(struct Expression * expr, struct Expression * src)
|
||||
{
|
||||
*expr = *src;
|
||||
pushbyte(expr, RPN_LOGUNNOT);
|
||||
}
|
||||
|
||||
void rpn_LOGOR(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGOR(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -215,7 +222,8 @@ void rpn_LOGOR(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGOR);
|
||||
}
|
||||
|
||||
void rpn_LOGAND(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGAND(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -223,7 +231,8 @@ void rpn_LOGAND(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGAND);
|
||||
}
|
||||
|
||||
void rpn_LOGEQU(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGEQU(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -231,7 +240,8 @@ void rpn_LOGEQU(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGEQ);
|
||||
}
|
||||
|
||||
void rpn_LOGGT(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGGT(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -239,7 +249,8 @@ void rpn_LOGGT(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGGT);
|
||||
}
|
||||
|
||||
void rpn_LOGLT(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGLT(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -247,7 +258,8 @@ void rpn_LOGLT(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGLT);
|
||||
}
|
||||
|
||||
void rpn_LOGGE(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGGE(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -255,7 +267,8 @@ void rpn_LOGGE(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGGE);
|
||||
}
|
||||
|
||||
void rpn_LOGLE(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGLE(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -263,7 +276,8 @@ void rpn_LOGLE(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGLE);
|
||||
}
|
||||
|
||||
void rpn_LOGNE(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_LOGNE(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -271,7 +285,8 @@ void rpn_LOGNE(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_LOGNE);
|
||||
}
|
||||
|
||||
void rpn_ADD(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_ADD(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -279,7 +294,8 @@ void rpn_ADD(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_ADD);
|
||||
}
|
||||
|
||||
void rpn_SUB(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_SUB(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -287,7 +303,8 @@ void rpn_SUB(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_SUB);
|
||||
}
|
||||
|
||||
void rpn_XOR(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_XOR(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -295,7 +312,8 @@ void rpn_XOR(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_XOR);
|
||||
}
|
||||
|
||||
void rpn_OR(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_OR(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -303,7 +321,8 @@ void rpn_OR(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_OR);
|
||||
}
|
||||
|
||||
void rpn_AND(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_AND(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -311,7 +330,8 @@ void rpn_AND(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_AND);
|
||||
}
|
||||
|
||||
void rpn_SHL(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_SHL(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -319,7 +339,8 @@ void rpn_SHL(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_SHL);
|
||||
}
|
||||
|
||||
void rpn_SHR(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_SHR(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -327,7 +348,8 @@ void rpn_SHR(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_SHR);
|
||||
}
|
||||
|
||||
void rpn_MUL(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_MUL(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -335,7 +357,8 @@ void rpn_MUL(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_MUL);
|
||||
}
|
||||
|
||||
void rpn_DIV(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_DIV(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -343,7 +366,8 @@ void rpn_DIV(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_DIV);
|
||||
}
|
||||
|
||||
void rpn_MOD(struct Expression *expr, struct Expression *src1,
|
||||
void
|
||||
rpn_MOD(struct Expression * expr, struct Expression * src1,
|
||||
struct Expression * src2)
|
||||
{
|
||||
joinexpr();
|
||||
@@ -351,14 +375,16 @@ void rpn_MOD(struct Expression *expr, struct Expression *src1,
|
||||
pushbyte(expr, RPN_MOD);
|
||||
}
|
||||
|
||||
void rpn_UNNEG(struct Expression *expr, struct Expression *src)
|
||||
void
|
||||
rpn_UNNEG(struct Expression * expr, struct Expression * src)
|
||||
{
|
||||
*expr = *src;
|
||||
expr->nVal = -expr->nVal;
|
||||
pushbyte(expr, RPN_UNSUB);
|
||||
}
|
||||
|
||||
void rpn_UNNOT(struct Expression *expr, struct Expression *src)
|
||||
void
|
||||
rpn_UNNOT(struct Expression * expr, struct Expression * src)
|
||||
{
|
||||
*expr = *src;
|
||||
expr->nVal = expr->nVal ^ 0xFFFFFFFF;
|
||||
|
||||
157
src/asm/symbol.c
157
src/asm/symbol.c
@@ -32,7 +32,8 @@ char *newmacroargs[MAXMACROARGS + 1];
|
||||
char SavedTIME[256];
|
||||
char SavedDATE[256];
|
||||
|
||||
SLONG Callback_NARG(struct sSymbol *sym)
|
||||
SLONG
|
||||
Callback_NARG(struct sSymbol * sym)
|
||||
{
|
||||
ULONG i = 0;
|
||||
|
||||
@@ -43,12 +44,12 @@ SLONG Callback_NARG(struct sSymbol *sym)
|
||||
return (i);
|
||||
}
|
||||
|
||||
SLONG Callback__LINE__(struct sSymbol * sym)
|
||||
SLONG
|
||||
Callback__LINE__(struct sSymbol * sym)
|
||||
{
|
||||
sym = sym;
|
||||
return (nLineNo);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -56,14 +57,14 @@ SLONG Callback__LINE__(struct sSymbol * sym)
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG getvaluefield(struct sSymbol * sym)
|
||||
SLONG
|
||||
getvaluefield(struct sSymbol * sym)
|
||||
{
|
||||
if (sym->Callback) {
|
||||
return (sym->Callback(sym));
|
||||
} else
|
||||
return (sym->nValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -71,7 +72,8 @@ SLONG getvaluefield(struct sSymbol * sym)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG calchash(char *s)
|
||||
ULONG
|
||||
calchash(char *s)
|
||||
{
|
||||
ULONG hash = 0;
|
||||
|
||||
@@ -80,7 +82,6 @@ ULONG calchash(char *s)
|
||||
|
||||
return (hash % HASHSIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -88,7 +89,8 @@ ULONG calchash(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol *createsymbol(char *s)
|
||||
struct sSymbol *
|
||||
createsymbol(char *s)
|
||||
{
|
||||
struct sSymbol **ppsym;
|
||||
ULONG hash;
|
||||
@@ -115,7 +117,6 @@ struct sSymbol *createsymbol(char *s)
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -123,7 +124,8 @@ struct sSymbol *createsymbol(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol *findsymbol(char *s, struct sSymbol *scope)
|
||||
struct sSymbol *
|
||||
findsymbol(char *s, struct sSymbol * scope)
|
||||
{
|
||||
struct sSymbol **ppsym;
|
||||
SLONG hash;
|
||||
@@ -140,7 +142,6 @@ struct sSymbol *findsymbol(char *s, struct sSymbol *scope)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -148,7 +149,8 @@ struct sSymbol *findsymbol(char *s, struct sSymbol *scope)
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol **findpsymbol(char *s, struct sSymbol *scope)
|
||||
struct sSymbol **
|
||||
findpsymbol(char *s, struct sSymbol * scope)
|
||||
{
|
||||
struct sSymbol **ppsym;
|
||||
SLONG hash;
|
||||
@@ -165,7 +167,6 @@ struct sSymbol **findpsymbol(char *s, struct sSymbol *scope)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -173,7 +174,8 @@ struct sSymbol **findpsymbol(char *s, struct sSymbol *scope)
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol *sym_FindSymbol(char *tzName)
|
||||
struct sSymbol *
|
||||
sym_FindSymbol(char *tzName)
|
||||
{
|
||||
struct sSymbol *pscope;
|
||||
|
||||
@@ -184,7 +186,6 @@ struct sSymbol *sym_FindSymbol(char *tzName)
|
||||
|
||||
return (findsymbol(tzName, pscope));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -192,7 +193,8 @@ struct sSymbol *sym_FindSymbol(char *tzName)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_Purge(char *tzName)
|
||||
void
|
||||
sym_Purge(char *tzName)
|
||||
{
|
||||
struct sSymbol **ppSym;
|
||||
struct sSymbol *pscope;
|
||||
@@ -219,7 +221,6 @@ void sym_Purge(char *tzName)
|
||||
yyerror(temptext);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -227,7 +228,8 @@ void sym_Purge(char *tzName)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_isConstDefined(char *tzName)
|
||||
ULONG
|
||||
sym_isConstDefined(char *tzName)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -252,7 +254,8 @@ ULONG sym_isConstDefined(char *tzName)
|
||||
return (0);
|
||||
}
|
||||
|
||||
ULONG sym_isDefined(char *tzName)
|
||||
ULONG
|
||||
sym_isDefined(char *tzName)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -268,7 +271,6 @@ ULONG sym_isDefined(char *tzName)
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -276,7 +278,8 @@ ULONG sym_isDefined(char *tzName)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_isConstant(char *s)
|
||||
ULONG
|
||||
sym_isConstant(char *s)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -289,10 +292,8 @@ ULONG sym_isConstant(char *s)
|
||||
if (psym->nType & SYMF_CONST)
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -300,7 +301,8 @@ ULONG sym_isConstant(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
char *sym_GetStringValue(char *tzSym)
|
||||
char *
|
||||
sym_GetStringValue(char *tzSym)
|
||||
{
|
||||
struct sSymbol *pSym;
|
||||
|
||||
@@ -313,7 +315,6 @@ char *sym_GetStringValue(char *tzSym)
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -321,7 +322,8 @@ char *sym_GetStringValue(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_GetConstantValue(char *s)
|
||||
ULONG
|
||||
sym_GetConstantValue(char *s)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -343,7 +345,6 @@ ULONG sym_GetConstantValue(char *s)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -351,7 +352,8 @@ ULONG sym_GetConstantValue(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_GetValue(char *s)
|
||||
ULONG
|
||||
sym_GetValue(char *s)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -389,7 +391,6 @@ ULONG sym_GetValue(char *s)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -397,7 +398,8 @@ ULONG sym_GetValue(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_GetDefinedValue(char *s)
|
||||
ULONG
|
||||
sym_GetDefinedValue(char *s)
|
||||
{
|
||||
struct sSymbol *psym, *pscope;
|
||||
|
||||
@@ -413,7 +415,6 @@ ULONG sym_GetDefinedValue(char *s)
|
||||
"'%s' is a macro or string symbol", s);
|
||||
yyerror(temptext);
|
||||
}
|
||||
|
||||
return (getvaluefield(psym));
|
||||
} else {
|
||||
sprintf(temptext, "'%s' not defined", s);
|
||||
@@ -426,7 +427,6 @@ ULONG sym_GetDefinedValue(char *s)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -434,7 +434,8 @@ ULONG sym_GetDefinedValue(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_ShiftCurrentMacroArgs(void)
|
||||
void
|
||||
sym_ShiftCurrentMacroArgs(void)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -445,7 +446,8 @@ void sym_ShiftCurrentMacroArgs(void)
|
||||
currentmacroargs[MAXMACROARGS - 1] = NULL;
|
||||
}
|
||||
|
||||
char *sym_FindMacroArg(SLONG i)
|
||||
char *
|
||||
sym_FindMacroArg(SLONG i)
|
||||
{
|
||||
if (i == -1)
|
||||
i = MAXMACROARGS + 1;
|
||||
@@ -453,7 +455,8 @@ char *sym_FindMacroArg(SLONG i)
|
||||
return (currentmacroargs[i - 1]);
|
||||
}
|
||||
|
||||
void sym_UseNewMacroArgs(void)
|
||||
void
|
||||
sym_UseNewMacroArgs(void)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -463,7 +466,8 @@ void sym_UseNewMacroArgs(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sym_SaveCurrentMacroArgs(char *save[])
|
||||
void
|
||||
sym_SaveCurrentMacroArgs(char *save[])
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -471,7 +475,8 @@ void sym_SaveCurrentMacroArgs(char *save[])
|
||||
save[i] = currentmacroargs[i];
|
||||
}
|
||||
|
||||
void sym_RestoreCurrentMacroArgs(char *save[])
|
||||
void
|
||||
sym_RestoreCurrentMacroArgs(char *save[])
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -479,7 +484,8 @@ void sym_RestoreCurrentMacroArgs(char *save[])
|
||||
currentmacroargs[i] = save[i];
|
||||
}
|
||||
|
||||
void sym_FreeCurrentMacroArgs(void)
|
||||
void
|
||||
sym_FreeCurrentMacroArgs(void)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -489,7 +495,8 @@ void sym_FreeCurrentMacroArgs(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sym_AddNewMacroArg(char *s)
|
||||
void
|
||||
sym_AddNewMacroArg(char *s)
|
||||
{
|
||||
SLONG i = 0;
|
||||
|
||||
@@ -505,7 +512,8 @@ void sym_AddNewMacroArg(char *s)
|
||||
yyerror("A maximum of 9 arguments allowed");
|
||||
}
|
||||
|
||||
void sym_SetMacroArgID(ULONG nMacroCount)
|
||||
void
|
||||
sym_SetMacroArgID(ULONG nMacroCount)
|
||||
{
|
||||
char s[256];
|
||||
|
||||
@@ -513,14 +521,14 @@ void sym_SetMacroArgID(ULONG nMacroCount)
|
||||
newmacroargs[MAXMACROARGS] = strdup(s);
|
||||
}
|
||||
|
||||
void sym_UseCurrentMacroArgs(void)
|
||||
void
|
||||
sym_UseCurrentMacroArgs(void)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
for (i = 1; i <= MAXMACROARGS; i += 1)
|
||||
sym_AddNewMacroArg(sym_FindMacroArg(i));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -528,11 +536,11 @@ void sym_UseCurrentMacroArgs(void)
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol *sym_FindMacro(char *s)
|
||||
struct sSymbol *
|
||||
sym_FindMacro(char *s)
|
||||
{
|
||||
return (findsymbol(s, NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -540,7 +548,8 @@ struct sSymbol *sym_FindMacro(char *s)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddEqu(char *tzSym, SLONG value)
|
||||
void
|
||||
sym_AddEqu(char *tzSym, SLONG value)
|
||||
{
|
||||
if ((nPass == 1)
|
||||
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
|
||||
@@ -563,7 +572,6 @@ void sym_AddEqu(char *tzSym, SLONG value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -571,7 +579,8 @@ void sym_AddEqu(char *tzSym, SLONG value)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddString(char *tzSym, char *tzValue)
|
||||
void
|
||||
sym_AddString(char *tzSym, char *tzValue)
|
||||
{
|
||||
struct sSymbol *nsym;
|
||||
|
||||
@@ -594,7 +603,6 @@ void sym_AddString(char *tzSym, char *tzValue)
|
||||
nsym->pScope = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -602,7 +610,8 @@ void sym_AddString(char *tzSym, char *tzValue)
|
||||
*
|
||||
*/
|
||||
|
||||
ULONG sym_isString(char *tzSym)
|
||||
ULONG
|
||||
sym_isString(char *tzSym)
|
||||
{
|
||||
struct sSymbol *pSym;
|
||||
|
||||
@@ -612,7 +621,6 @@ ULONG sym_isString(char *tzSym)
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -620,7 +628,8 @@ ULONG sym_isString(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddSet(char *tzSym, SLONG value)
|
||||
void
|
||||
sym_AddSet(char *tzSym, SLONG value)
|
||||
{
|
||||
struct sSymbol *nsym;
|
||||
|
||||
@@ -634,7 +643,6 @@ void sym_AddSet(char *tzSym, SLONG value)
|
||||
nsym->pScope = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -642,7 +650,8 @@ void sym_AddSet(char *tzSym, SLONG value)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddLocalReloc(char *tzSym)
|
||||
void
|
||||
sym_AddLocalReloc(char *tzSym)
|
||||
{
|
||||
if ((nPass == 1)
|
||||
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
|
||||
@@ -670,7 +679,6 @@ void sym_AddLocalReloc(char *tzSym)
|
||||
fatalerror("Local label in main scope");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -678,7 +686,8 @@ void sym_AddLocalReloc(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddReloc(char *tzSym)
|
||||
void
|
||||
sym_AddReloc(char *tzSym)
|
||||
{
|
||||
if ((nPass == 1)
|
||||
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
|
||||
@@ -704,7 +713,6 @@ void sym_AddReloc(char *tzSym)
|
||||
pScope = findsymbol(tzSym, NULL);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -712,7 +720,8 @@ void sym_AddReloc(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_Export(char *tzSym)
|
||||
void
|
||||
sym_Export(char *tzSym)
|
||||
{
|
||||
if (nPass == 1) {
|
||||
/* only export symbols in pass 1 */
|
||||
@@ -735,7 +744,6 @@ void sym_Export(char *tzSym)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -743,7 +751,8 @@ void sym_Export(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_Import(char *tzSym)
|
||||
void
|
||||
sym_Import(char *tzSym)
|
||||
{
|
||||
if (nPass == 1) {
|
||||
/* only import symbols in pass 1 */
|
||||
@@ -753,12 +762,10 @@ void sym_Import(char *tzSym)
|
||||
sprintf(temptext, "'%s' already defined", tzSym);
|
||||
yyerror(temptext);
|
||||
}
|
||||
|
||||
if ((nsym = createsymbol(tzSym)) != NULL)
|
||||
nsym->nType |= SYMF_IMPORT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -766,7 +773,8 @@ void sym_Import(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_Global(char *tzSym)
|
||||
void
|
||||
sym_Global(char *tzSym)
|
||||
{
|
||||
if (nPass == 2) {
|
||||
/* only globalize symbols in pass 2 */
|
||||
@@ -786,7 +794,6 @@ void sym_Global(char *tzSym)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -794,7 +801,8 @@ void sym_Global(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_AddMacro(char *tzSym)
|
||||
void
|
||||
sym_AddMacro(char *tzSym)
|
||||
{
|
||||
if ((nPass == 1)
|
||||
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
|
||||
@@ -819,7 +827,6 @@ void sym_AddMacro(char *tzSym)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -827,11 +834,11 @@ void sym_AddMacro(char *tzSym)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_PrepPass1(void)
|
||||
void
|
||||
sym_PrepPass1(void)
|
||||
{
|
||||
sym_Init();
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -839,7 +846,8 @@ void sym_PrepPass1(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_PrepPass2(void)
|
||||
void
|
||||
sym_PrepPass2(void)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -865,7 +873,6 @@ void sym_PrepPass2(void)
|
||||
sym_AddString("__DATE__", SavedDATE);
|
||||
sym_AddSet("_RS", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -873,7 +880,8 @@ void sym_PrepPass2(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_Init(void)
|
||||
void
|
||||
sym_Init(void)
|
||||
{
|
||||
SLONG i;
|
||||
time_t tod;
|
||||
@@ -907,13 +915,11 @@ void sym_Init(void)
|
||||
sym_AddString("__TIME__", SavedTIME);
|
||||
sym_AddString("__DATE__", SavedDATE);
|
||||
}
|
||||
|
||||
pScope = NULL;
|
||||
|
||||
math_DefinePI();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -921,7 +927,8 @@ void sym_Init(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_PrintSymbolTable(void)
|
||||
void
|
||||
sym_PrintSymbolTable(void)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
@@ -967,7 +974,6 @@ void sym_PrintSymbolTable(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGBAsm - SYMBOL.C - Symboltable stuff
|
||||
*
|
||||
@@ -975,7 +981,8 @@ void sym_PrintSymbolTable(void)
|
||||
*
|
||||
*/
|
||||
|
||||
void sym_DumpMacroArgs(void)
|
||||
void
|
||||
sym_DumpMacroArgs(void)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ unsigned char NintendoChar[48] = {
|
||||
0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC,
|
||||
0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E,
|
||||
};
|
||||
|
||||
/*
|
||||
* Misc. routines
|
||||
*
|
||||
*/
|
||||
|
||||
void PrintUsage(void)
|
||||
void
|
||||
PrintUsage(void)
|
||||
{
|
||||
printf("RGBFix v" RGBFIX_VERSION
|
||||
" (part of ASMotor " ASMOTOR_VERSION ")\n\n");
|
||||
@@ -60,14 +60,16 @@ void PrintUsage(void)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void vFatalError(char *s, va_list ap)
|
||||
void
|
||||
vFatalError(char *s, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "*ERROR* : ");
|
||||
vfprintf(stderr, s, ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void FatalError(char *s, ...)
|
||||
void
|
||||
FatalError(char *s,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
@@ -76,14 +78,16 @@ void FatalError(char *s, ...)
|
||||
exit(5);
|
||||
}
|
||||
|
||||
void vWarning(char *s, va_list ap)
|
||||
void
|
||||
vWarning(char *s, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "*WARNING* : ");
|
||||
vfprintf(stderr, s, ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void Warning(char *s, ...)
|
||||
void
|
||||
Warning(char *s,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
@@ -91,7 +95,8 @@ void Warning(char *s, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
long int FileSize(FILE * f)
|
||||
long int
|
||||
FileSize(FILE * f)
|
||||
{
|
||||
long prevpos;
|
||||
long r;
|
||||
@@ -104,7 +109,8 @@ long int FileSize(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
int FileExists(char *s)
|
||||
int
|
||||
FileExists(char *s)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -114,13 +120,13 @@ int FileExists(char *s)
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Das main
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int argn = 1;
|
||||
char filename[512];
|
||||
@@ -182,7 +188,6 @@ int main(int argc, char *argv[])
|
||||
if ((ulOptions & OPTF_DEBUG) && !(ulOptions & OPTF_QUIET)) {
|
||||
printf("-d (Debug) option enabled...\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* -p (Pad) option code
|
||||
*
|
||||
@@ -200,7 +205,6 @@ int main(int argc, char *argv[])
|
||||
if (!(ulOptions & OPTF_QUIET)) {
|
||||
printf("Padding to %ldkB:\n", padto / 1024);
|
||||
}
|
||||
|
||||
/*
|
||||
if( padto<=0x80000L )
|
||||
{
|
||||
@@ -231,7 +235,6 @@ int main(int argc, char *argv[])
|
||||
FatalError( "Image size exceeds 512kB" );
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* -r (Truncate) option code
|
||||
*
|
||||
@@ -250,7 +253,6 @@ int main(int argc, char *argv[])
|
||||
if (!(ulOptions & OPTF_QUIET)) {
|
||||
printf("Truncating to %ldkB:\n", padto / 1024);
|
||||
}
|
||||
|
||||
mkstemp(tempfile);
|
||||
|
||||
if ((ulOptions & OPTF_DEBUG) == 0) {
|
||||
@@ -267,7 +269,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -t (Set carttitle) option code
|
||||
*
|
||||
@@ -287,7 +288,6 @@ int main(int argc, char *argv[])
|
||||
printf("\tTitle set to %s\n", cartname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -v (Validate header) option code
|
||||
*
|
||||
@@ -339,7 +339,6 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
printf("\tNintendo Character Area is OK\n");
|
||||
}
|
||||
|
||||
/* ROM size */
|
||||
|
||||
fflush(f);
|
||||
@@ -364,11 +363,9 @@ int main(int argc, char *argv[])
|
||||
calcromsize,
|
||||
(0x8000L << calcromsize) / 1024);
|
||||
}
|
||||
} else
|
||||
if(!(ulOptions & OPTF_QUIET)) {
|
||||
} else if (!(ulOptions & OPTF_QUIET)) {
|
||||
printf("\tROM size byte is OK\n");
|
||||
}
|
||||
|
||||
/* Cartridge type */
|
||||
|
||||
fflush(f);
|
||||
@@ -389,8 +386,7 @@ int main(int argc, char *argv[])
|
||||
printf
|
||||
("\tCartridge type byte changed to 0x01\n");
|
||||
}
|
||||
} else
|
||||
if(!(ulOptions & OPTF_QUIET)) {
|
||||
} else if (!(ulOptions & OPTF_QUIET)) {
|
||||
printf("\tCartridge type byte is OK\n");
|
||||
}
|
||||
} else {
|
||||
@@ -466,7 +462,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
} else {
|
||||
FatalError("File '%s' not found", filename);
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
extern void fatalerror(char *s);
|
||||
|
||||
SLONG file_Length(FILE * f)
|
||||
SLONG
|
||||
file_Length(FILE * f)
|
||||
{
|
||||
ULONG r, p;
|
||||
|
||||
@@ -19,7 +20,8 @@ SLONG file_Length(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
SLONG file_ReadASCIIz(char *b, FILE * f)
|
||||
SLONG
|
||||
file_ReadASCIIz(char *b, FILE * f)
|
||||
{
|
||||
SLONG r = 0;
|
||||
|
||||
@@ -29,7 +31,8 @@ SLONG file_ReadASCIIz(char *b, FILE * f)
|
||||
return (r + 1);
|
||||
}
|
||||
|
||||
void file_WriteASCIIz(char *b, FILE * f)
|
||||
void
|
||||
file_WriteASCIIz(char *b, FILE * f)
|
||||
{
|
||||
while (*b)
|
||||
fputc(*b++, f);
|
||||
@@ -37,7 +40,8 @@ void file_WriteASCIIz(char *b, FILE * f)
|
||||
fputc(0, f);
|
||||
}
|
||||
|
||||
UWORD file_ReadWord(FILE * f)
|
||||
UWORD
|
||||
file_ReadWord(FILE * f)
|
||||
{
|
||||
UWORD r;
|
||||
|
||||
@@ -47,13 +51,15 @@ UWORD file_ReadWord(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void file_WriteWord(UWORD w, FILE * f)
|
||||
void
|
||||
file_WriteWord(UWORD w, FILE * f)
|
||||
{
|
||||
fputc(w, f);
|
||||
fputc(w >> 8, f);
|
||||
}
|
||||
|
||||
ULONG file_ReadLong(FILE * f)
|
||||
ULONG
|
||||
file_ReadLong(FILE * f)
|
||||
{
|
||||
ULONG r;
|
||||
|
||||
@@ -65,7 +71,8 @@ ULONG file_ReadLong(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void file_WriteLong(UWORD w, FILE * f)
|
||||
void
|
||||
file_WriteLong(UWORD w, FILE * f)
|
||||
{
|
||||
fputc(w, f);
|
||||
fputc(w >> 8, f);
|
||||
@@ -73,7 +80,8 @@ void file_WriteLong(UWORD w, FILE * f)
|
||||
fputc(w >> 24, f);
|
||||
}
|
||||
|
||||
sLibrary *lib_ReadLib0(FILE * f, SLONG size)
|
||||
sLibrary *
|
||||
lib_ReadLib0(FILE * f, SLONG size)
|
||||
{
|
||||
if (size) {
|
||||
sLibrary *l = NULL, *first = NULL;
|
||||
@@ -111,11 +119,11 @@ sLibrary *lib_ReadLib0(FILE * f, SLONG size)
|
||||
}
|
||||
return (first);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
sLibrary *lib_Read(char *filename)
|
||||
sLibrary *
|
||||
lib_Read(char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -128,7 +136,6 @@ sLibrary *lib_Read(char *filename)
|
||||
fclose(f);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
fread(ID, sizeof(char), 4, f);
|
||||
ID[4] = 0;
|
||||
size -= 4;
|
||||
@@ -153,7 +160,8 @@ sLibrary *lib_Read(char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
BBOOL lib_Write(sLibrary * lib, char *filename)
|
||||
BBOOL
|
||||
lib_Write(sLibrary * lib, char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -172,11 +180,11 @@ BBOOL lib_Write(sLibrary * lib, char *filename)
|
||||
printf("Library '%s' closed\n", filename);
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void TruncateFileName(char *dest, char *src)
|
||||
void
|
||||
TruncateFileName(char *dest, char *src)
|
||||
{
|
||||
SLONG l;
|
||||
|
||||
@@ -187,7 +195,8 @@ void TruncateFileName(char *dest, char *src)
|
||||
strcpy(dest, &src[l + 1]);
|
||||
}
|
||||
|
||||
sLibrary *lib_Find(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_Find(sLibrary * lib, char *filename)
|
||||
{
|
||||
char truncname[MAXNAMELENGTH];
|
||||
|
||||
@@ -203,7 +212,8 @@ sLibrary *lib_Find(sLibrary * lib, char *filename)
|
||||
return (lib);
|
||||
}
|
||||
|
||||
sLibrary *lib_AddReplace(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_AddReplace(sLibrary * lib, char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -237,11 +247,11 @@ sLibrary *lib_AddReplace(sLibrary * lib, char *filename)
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
return (lib);
|
||||
}
|
||||
|
||||
sLibrary *lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
{
|
||||
char truncname[MAXNAMELENGTH];
|
||||
sLibrary **pp, **first;
|
||||
@@ -276,7 +286,8 @@ sLibrary *lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
return (*first);
|
||||
}
|
||||
|
||||
void lib_Free(sLibrary * lib)
|
||||
void
|
||||
lib_Free(sLibrary * lib)
|
||||
{
|
||||
while (lib) {
|
||||
sLibrary *l;
|
||||
|
||||
@@ -18,18 +18,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void fatalerror(char *s)
|
||||
void
|
||||
fatalerror(char *s)
|
||||
{
|
||||
fprintf(stderr, "*ERROR* : %s\n", s);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usagescreen
|
||||
*
|
||||
*/
|
||||
|
||||
void PrintUsage(void)
|
||||
void
|
||||
PrintUsage(void)
|
||||
{
|
||||
printf("xLib v" LIB_VERSION " (part of ASMotor " ASMOTOR_VERSION ")\n\n"
|
||||
"Usage: xlib library command [module1 module2 ... modulen]\n"
|
||||
@@ -39,13 +40,13 @@ void PrintUsage(void)
|
||||
"\tx\tExtract modules from library\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The main routine
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SLONG argn = 0;
|
||||
char *libname;
|
||||
|
||||
@@ -18,7 +18,8 @@ SLONG MaxBankUsed;
|
||||
|
||||
#define DOMAXBANK(x) {if( (x)>MaxBankUsed ) MaxBankUsed=(x);}
|
||||
|
||||
SLONG area_Avail(SLONG bank)
|
||||
SLONG
|
||||
area_Avail(SLONG bank)
|
||||
{
|
||||
SLONG r;
|
||||
struct sFreeArea *pArea;
|
||||
@@ -34,7 +35,8 @@ SLONG area_Avail(SLONG bank)
|
||||
return (r);
|
||||
}
|
||||
|
||||
SLONG area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
|
||||
SLONG
|
||||
area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
|
||||
{
|
||||
struct sFreeArea *pArea;
|
||||
|
||||
@@ -80,7 +82,8 @@ SLONG area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
SLONG area_AllocAbsCODEAnyBank(SLONG org, SLONG size)
|
||||
SLONG
|
||||
area_AllocAbsCODEAnyBank(SLONG org, SLONG size)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -92,7 +95,8 @@ SLONG area_AllocAbsCODEAnyBank(SLONG org, SLONG size)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
SLONG area_Alloc(struct sFreeArea ** ppArea, SLONG size)
|
||||
SLONG
|
||||
area_Alloc(struct sFreeArea ** ppArea, SLONG size)
|
||||
{
|
||||
struct sFreeArea *pArea;
|
||||
|
||||
@@ -114,7 +118,8 @@ SLONG area_Alloc(struct sFreeArea ** ppArea, SLONG size)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
SLONG area_AllocCODEAnyBank(SLONG size)
|
||||
SLONG
|
||||
area_AllocCODEAnyBank(SLONG size)
|
||||
{
|
||||
SLONG i, org;
|
||||
|
||||
@@ -126,7 +131,8 @@ SLONG area_AllocCODEAnyBank(SLONG size)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct sSection *FindLargestCode(void)
|
||||
struct sSection *
|
||||
FindLargestCode(void)
|
||||
{
|
||||
struct sSection *pSection, *r = NULL;
|
||||
SLONG nLargest = 0;
|
||||
@@ -144,7 +150,8 @@ struct sSection *FindLargestCode(void)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void AssignCodeSections(void)
|
||||
void
|
||||
AssignCodeSections(void)
|
||||
{
|
||||
struct sSection *pSection;
|
||||
|
||||
@@ -161,7 +168,8 @@ void AssignCodeSections(void)
|
||||
}
|
||||
}
|
||||
|
||||
void GBROM_AssignSections(void)
|
||||
void
|
||||
GBROM_AssignSections(void)
|
||||
{
|
||||
SLONG i;
|
||||
struct sSection *pSection;
|
||||
@@ -391,7 +399,8 @@ void GBROM_AssignSections(void)
|
||||
if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_CODE
|
||||
&& pSection->nOrg != -1 && pSection->nBank == -1) {
|
||||
/* User wants to have a say... and he's back with a vengeance */
|
||||
/* User wants to have a say... and he's back with a
|
||||
* vengeance */
|
||||
if ((pSection->nBank =
|
||||
area_AllocAbsCODEAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
@@ -466,7 +475,8 @@ void GBROM_AssignSections(void)
|
||||
AssignCodeSections();
|
||||
}
|
||||
|
||||
void PSION2_AssignSections(void)
|
||||
void
|
||||
PSION2_AssignSections(void)
|
||||
{
|
||||
struct sSection *pSection;
|
||||
|
||||
@@ -507,7 +517,8 @@ void PSION2_AssignSections(void)
|
||||
}
|
||||
}
|
||||
|
||||
void AssignSections(void)
|
||||
void
|
||||
AssignSections(void)
|
||||
{
|
||||
switch (outputtype) {
|
||||
case OUTPUT_GBROM:
|
||||
@@ -519,7 +530,8 @@ void AssignSections(void)
|
||||
}
|
||||
}
|
||||
|
||||
void CreateSymbolTable(void)
|
||||
void
|
||||
CreateSymbolTable(void)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include "link/mylink.h"
|
||||
#include "link/main.h"
|
||||
|
||||
static BBOOL symboldefined(char *name)
|
||||
static BBOOL
|
||||
symboldefined(char *name)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
|
||||
@@ -23,14 +24,14 @@ static BBOOL symboldefined(char *name)
|
||||
0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
}
|
||||
pSect = pSect->pNext;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static BBOOL addmodulecontaining(char *name)
|
||||
static BBOOL
|
||||
addmodulecontaining(char *name)
|
||||
{
|
||||
struct sSection **ppLSect;
|
||||
|
||||
@@ -58,14 +59,14 @@ static BBOOL addmodulecontaining(char *name)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ppLSect = &((*ppLSect)->pNext);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void AddNeededModules(void)
|
||||
void
|
||||
AddNeededModules(void)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
|
||||
@@ -88,7 +89,6 @@ void AddNeededModules(void)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (options & OPT_SMART_C_LINK) {
|
||||
if (!addmodulecontaining(smartlinkstartsymbol)) {
|
||||
sprintf(temptext, "Can't find start symbol '%s'",
|
||||
@@ -98,7 +98,6 @@ void AddNeededModules(void)
|
||||
printf("Smart linking with symbol '%s'\n",
|
||||
smartlinkstartsymbol);
|
||||
}
|
||||
|
||||
pSect = pSections;
|
||||
|
||||
while (pSect) {
|
||||
@@ -112,7 +111,6 @@ void AddNeededModules(void)
|
||||
pzName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
pSect = pSect->pNext;
|
||||
}
|
||||
|
||||
@@ -36,18 +36,19 @@ char smartlinkstartsymbol[256];
|
||||
*
|
||||
*/
|
||||
|
||||
void fatalerror(char *s)
|
||||
void
|
||||
fatalerror(char *s)
|
||||
{
|
||||
printf("*ERROR* : %s\n", s);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usagescreen
|
||||
*
|
||||
*/
|
||||
|
||||
void PrintUsage(void)
|
||||
void
|
||||
PrintUsage(void)
|
||||
{
|
||||
printf("xLink v" LINK_VERSION " (part of ASMotor " ASMOTOR_VERSION
|
||||
")\n\n" "Usage: xlink [options] linkfile\n"
|
||||
@@ -62,13 +63,13 @@ void PrintUsage(void)
|
||||
"\t\t-tp\tPsion2 reloc module\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the linkfile and load all the objectfiles
|
||||
*
|
||||
*/
|
||||
|
||||
void ProcessLinkfile(char *tzLinkfile)
|
||||
void
|
||||
ProcessLinkfile(char *tzLinkfile)
|
||||
{
|
||||
FILE *pLinkfile;
|
||||
enum eBlockType CurrentBlock = BLOCK_COMMENT;
|
||||
@@ -78,7 +79,6 @@ void ProcessLinkfile(char *tzLinkfile)
|
||||
sprintf(temptext, "Unable to find linkfile '%s'\n", tzLinkfile);
|
||||
fatalerror(temptext);
|
||||
}
|
||||
|
||||
while (!feof(pLinkfile)) {
|
||||
char tzLine[256];
|
||||
|
||||
@@ -124,13 +124,13 @@ void ProcessLinkfile(char *tzLinkfile)
|
||||
|
||||
fclose(pLinkfile);
|
||||
}
|
||||
|
||||
/*
|
||||
* The main routine
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SLONG argn = 0;
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ FILE *sf = NULL;
|
||||
SLONG currentbank = 0;
|
||||
SLONG sfbank;
|
||||
|
||||
void SetMapfileName(char *name)
|
||||
void
|
||||
SetMapfileName(char *name)
|
||||
{
|
||||
mf = fopen(name, "wt");
|
||||
|
||||
@@ -21,7 +22,8 @@ void SetMapfileName(char *name)
|
||||
fatalerror("Unable to open mapfile for writing");
|
||||
}
|
||||
|
||||
void SetSymfileName(char *name)
|
||||
void
|
||||
SetSymfileName(char *name)
|
||||
{
|
||||
sf = fopen(name, "wt");
|
||||
|
||||
@@ -31,7 +33,8 @@ void SetSymfileName(char *name)
|
||||
fprintf(sf, ";File generated by xLink v" LINK_VERSION "\n\n");
|
||||
}
|
||||
|
||||
void CloseMapfile(void)
|
||||
void
|
||||
CloseMapfile(void)
|
||||
{
|
||||
if (mf) {
|
||||
fclose(mf);
|
||||
@@ -43,7 +46,8 @@ void CloseMapfile(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MapfileInitBank(SLONG bank)
|
||||
void
|
||||
MapfileInitBank(SLONG bank)
|
||||
{
|
||||
if (mf) {
|
||||
currentbank = bank;
|
||||
@@ -58,13 +62,13 @@ void MapfileInitBank(SLONG bank)
|
||||
else if (bank == BANK_VRAM)
|
||||
fprintf(mf, "VRAM:\n");
|
||||
}
|
||||
|
||||
if (sf) {
|
||||
sfbank = (bank >= 1 && bank <= 255) ? bank : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MapfileWriteSection(struct sSection *pSect)
|
||||
void
|
||||
MapfileWriteSection(struct sSection * pSect)
|
||||
{
|
||||
if (!mf && !sf)
|
||||
return;
|
||||
@@ -90,12 +94,12 @@ void MapfileWriteSection(struct sSection *pSect)
|
||||
pSym->nOffset + pSect->nOrg,
|
||||
pSym->pzName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapfileCloseBank(SLONG slack)
|
||||
void
|
||||
MapfileCloseBank(SLONG slack)
|
||||
{
|
||||
if (!mf)
|
||||
return;
|
||||
|
||||
@@ -21,7 +21,8 @@ BBOOL oReadLib = 0;
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG readlong(FILE * f)
|
||||
SLONG
|
||||
readlong(FILE * f)
|
||||
{
|
||||
SLONG r;
|
||||
|
||||
@@ -33,7 +34,8 @@ SLONG readlong(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
UWORD readword(FILE * f)
|
||||
UWORD
|
||||
readword(FILE * f)
|
||||
{
|
||||
UWORD r;
|
||||
|
||||
@@ -42,13 +44,13 @@ UWORD readword(FILE * f)
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a NULL terminated string from a file
|
||||
*
|
||||
*/
|
||||
|
||||
SLONG readasciiz(char *s, FILE * f)
|
||||
SLONG
|
||||
readasciiz(char *s, FILE * f)
|
||||
{
|
||||
SLONG r = 0;
|
||||
|
||||
@@ -57,13 +59,13 @@ SLONG readasciiz(char *s, FILE * f)
|
||||
|
||||
return (r + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new section and link it into the list
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSection *AllocSection(void)
|
||||
struct sSection *
|
||||
AllocSection(void)
|
||||
{
|
||||
struct sSection **ppSections;
|
||||
|
||||
@@ -80,20 +82,19 @@ struct sSection *AllocSection(void)
|
||||
fatalerror("Out of memory!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(*ppSections)->tSymbols = tSymbols;
|
||||
(*ppSections)->pNext = NULL;
|
||||
(*ppSections)->pPatches = NULL;
|
||||
(*ppSections)->oAssigned = 0;
|
||||
return *ppSections;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a symbol from a file
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSymbol *obj_ReadSymbol(FILE * f)
|
||||
struct sSymbol *
|
||||
obj_ReadSymbol(FILE * f)
|
||||
{
|
||||
char s[256];
|
||||
struct sSymbol *pSym;
|
||||
@@ -112,16 +113,15 @@ struct sSymbol *obj_ReadSymbol(FILE * f)
|
||||
pSym->nSectionID = readlong(f);
|
||||
pSym->nOffset = readlong(f);
|
||||
}
|
||||
|
||||
return pSym;
|
||||
}
|
||||
|
||||
/*
|
||||
* RGB0 object reader routines
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSection *obj_ReadRGB0Section(FILE * f)
|
||||
struct sSection *
|
||||
obj_ReadRGB0Section(FILE * f)
|
||||
{
|
||||
struct sSection *pSection;
|
||||
|
||||
@@ -137,7 +137,6 @@ struct sSection *obj_ReadRGB0Section(FILE * f)
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_CODE)) {
|
||||
pSection->Type = SECT_HOME;
|
||||
}
|
||||
|
||||
if ((pSection->Type == SECT_CODE) || (pSection->Type == SECT_HOME)) {
|
||||
/*
|
||||
* These sectiontypes contain data...
|
||||
@@ -202,11 +201,11 @@ struct sSection *obj_ReadRGB0Section(FILE * f)
|
||||
pSection->pData = &dummymem;
|
||||
}
|
||||
}
|
||||
|
||||
return pSection;
|
||||
}
|
||||
|
||||
void obj_ReadRGB0(FILE *pObjfile)
|
||||
void
|
||||
obj_ReadRGB0(FILE * pObjfile)
|
||||
{
|
||||
struct sSection *pFirstSection;
|
||||
SLONG nNumberOfSymbols, nNumberOfSections, i;
|
||||
@@ -259,13 +258,13 @@ void obj_ReadRGB0(FILE *pObjfile)
|
||||
tSymbols[i]->pSection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RGB1 object reader routines
|
||||
*
|
||||
*/
|
||||
|
||||
struct sSection *obj_ReadRGB1Section(FILE *f)
|
||||
struct sSection *
|
||||
obj_ReadRGB1Section(FILE * f)
|
||||
{
|
||||
struct sSection *pSection;
|
||||
|
||||
@@ -286,7 +285,6 @@ struct sSection *obj_ReadRGB1Section(FILE *f)
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_CODE)) {
|
||||
pSection->Type = SECT_HOME;
|
||||
}
|
||||
|
||||
if ((pSection->Type == SECT_CODE) || (pSection->Type == SECT_HOME)) {
|
||||
/*
|
||||
* These sectiontypes contain data...
|
||||
@@ -344,11 +342,11 @@ struct sSection *obj_ReadRGB1Section(FILE *f)
|
||||
pSection->pData = &dummymem;
|
||||
}
|
||||
}
|
||||
|
||||
return pSection;
|
||||
}
|
||||
|
||||
void obj_ReadRGB1(FILE *pObjfile)
|
||||
void
|
||||
obj_ReadRGB1(FILE * pObjfile)
|
||||
{
|
||||
struct sSection *pFirstSection;
|
||||
SLONG nNumberOfSymbols, nNumberOfSections, i;
|
||||
@@ -401,13 +399,13 @@ void obj_ReadRGB1(FILE *pObjfile)
|
||||
tSymbols[i]->pSection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The main objectfileloadroutine (phew)
|
||||
*
|
||||
*/
|
||||
|
||||
void obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
|
||||
void
|
||||
obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
|
||||
{
|
||||
char tzHeader[8];
|
||||
|
||||
@@ -419,7 +417,8 @@ void obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
|
||||
obj_ReadRGB0(pObjfile);
|
||||
break;
|
||||
case '1':
|
||||
case '2': // V2 is really the same but the are new patch types
|
||||
case '2':
|
||||
//V2 is really the same but the are new patch types
|
||||
obj_ReadRGB1(pObjfile);
|
||||
break;
|
||||
default:
|
||||
@@ -434,7 +433,8 @@ void obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
|
||||
}
|
||||
}
|
||||
|
||||
void obj_Readfile(char *tzObjectfile)
|
||||
void
|
||||
obj_Readfile(char *tzObjectfile)
|
||||
{
|
||||
FILE *pObjfile;
|
||||
|
||||
@@ -448,14 +448,14 @@ void obj_Readfile(char *tzObjectfile)
|
||||
sprintf(temptext, "Unable to open '%s'\n", tzObjectfile);
|
||||
fatalerror(temptext);
|
||||
}
|
||||
|
||||
obj_ReadOpenFile(pObjfile, tzObjectfile);
|
||||
fclose(pObjfile);
|
||||
|
||||
oReadLib = 0;
|
||||
}
|
||||
|
||||
SLONG file_Length(FILE * f)
|
||||
SLONG
|
||||
file_Length(FILE * f)
|
||||
{
|
||||
ULONG r, p;
|
||||
|
||||
@@ -467,7 +467,8 @@ SLONG file_Length(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void lib_ReadXLB0(FILE * f)
|
||||
void
|
||||
lib_ReadXLB0(FILE * f)
|
||||
{
|
||||
SLONG size;
|
||||
|
||||
@@ -486,7 +487,8 @@ void lib_ReadXLB0(FILE * f)
|
||||
}
|
||||
}
|
||||
|
||||
void lib_Readfile(char *tzLibfile)
|
||||
void
|
||||
lib_Readfile(char *tzLibfile)
|
||||
{
|
||||
FILE *pObjfile;
|
||||
|
||||
@@ -497,7 +499,6 @@ void lib_Readfile(char *tzLibfile)
|
||||
sprintf(temptext, "Unable to open '%s'\n", tzLibfile);
|
||||
fatalerror(temptext);
|
||||
}
|
||||
|
||||
char tzHeader[5];
|
||||
|
||||
fread(tzHeader, sizeof(char), 4, pObjfile);
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
char tzOutname[_MAX_PATH];
|
||||
BBOOL oOutput = 0;
|
||||
|
||||
void writehome(FILE *f)
|
||||
void
|
||||
writehome(FILE * f)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
UBYTE *mem;
|
||||
@@ -40,7 +41,8 @@ void writehome(FILE *f)
|
||||
free(mem);
|
||||
}
|
||||
|
||||
void writebank(FILE *f, SLONG bank)
|
||||
void
|
||||
writebank(FILE * f, SLONG bank)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
UBYTE *mem;
|
||||
@@ -52,7 +54,6 @@ void writebank(FILE *f, SLONG bank)
|
||||
if (fillchar != -1) {
|
||||
memset(mem, fillchar, MaxAvail[bank]);
|
||||
}
|
||||
|
||||
MapfileInitBank(bank);
|
||||
|
||||
pSect = pSections;
|
||||
@@ -71,13 +72,15 @@ void writebank(FILE *f, SLONG bank)
|
||||
free(mem);
|
||||
}
|
||||
|
||||
void out_Setname(char *tzOutputfile)
|
||||
void
|
||||
out_Setname(char *tzOutputfile)
|
||||
{
|
||||
strcpy(tzOutname, tzOutputfile);
|
||||
oOutput = 1;
|
||||
}
|
||||
|
||||
void GBROM_Output(void)
|
||||
void
|
||||
GBROM_Output(void)
|
||||
{
|
||||
SLONG i;
|
||||
FILE *f;
|
||||
@@ -89,7 +92,6 @@ void GBROM_Output(void)
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
for (i = 256; i < MAXBANKS; i += 1) {
|
||||
struct sSection *pSect;
|
||||
MapfileInitBank(i);
|
||||
@@ -104,7 +106,8 @@ void GBROM_Output(void)
|
||||
}
|
||||
}
|
||||
|
||||
void PSION2_Output(void)
|
||||
void
|
||||
PSION2_Output(void)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -140,7 +143,6 @@ void PSION2_Output(void)
|
||||
fwrite(mem, 1, MaxAvail[0] - area_Avail(0), f);
|
||||
free(mem);
|
||||
}
|
||||
|
||||
relocpatches = 0;
|
||||
pSect = pSections;
|
||||
while (pSect) {
|
||||
@@ -187,7 +189,8 @@ void PSION2_Output(void)
|
||||
}
|
||||
}
|
||||
|
||||
void Output(void)
|
||||
void
|
||||
Output(void)
|
||||
{
|
||||
if (oOutput) {
|
||||
switch (outputtype) {
|
||||
|
||||
@@ -10,17 +10,20 @@ SLONG rpnstack[256];
|
||||
SLONG rpnp;
|
||||
SLONG nPC;
|
||||
|
||||
void rpnpush(SLONG i)
|
||||
void
|
||||
rpnpush(SLONG i)
|
||||
{
|
||||
rpnstack[rpnp++] = i;
|
||||
}
|
||||
|
||||
SLONG rpnpop(void)
|
||||
SLONG
|
||||
rpnpop(void)
|
||||
{
|
||||
return (rpnstack[--rpnp]);
|
||||
}
|
||||
|
||||
SLONG getsymvalue(SLONG symid)
|
||||
SLONG
|
||||
getsymvalue(SLONG symid)
|
||||
{
|
||||
switch (pCurrentSection->tSymbols[symid]->Type) {
|
||||
case SYM_IMPORT:
|
||||
@@ -46,7 +49,8 @@ SLONG getsymvalue(SLONG symid)
|
||||
return (0);
|
||||
}
|
||||
|
||||
SLONG getsymbank(SLONG symid)
|
||||
SLONG
|
||||
getsymbank(SLONG symid)
|
||||
{
|
||||
switch (pCurrentSection->tSymbols[symid]->Type) {
|
||||
case SYM_IMPORT:
|
||||
@@ -63,7 +67,8 @@ SLONG getsymbank(SLONG symid)
|
||||
return (0);
|
||||
}
|
||||
|
||||
SLONG calcrpn(struct sPatch * pPatch)
|
||||
SLONG
|
||||
calcrpn(struct sPatch * pPatch)
|
||||
{
|
||||
SLONG t, size;
|
||||
UBYTE *rpn;
|
||||
@@ -226,7 +231,8 @@ SLONG calcrpn(struct sPatch * pPatch)
|
||||
return (rpnpop());
|
||||
}
|
||||
|
||||
void Patch(void)
|
||||
void
|
||||
Patch(void)
|
||||
{
|
||||
struct sSection *pSect;
|
||||
|
||||
|
||||
@@ -11,13 +11,15 @@
|
||||
struct ISymbol {
|
||||
char *pzName;
|
||||
SLONG nValue;
|
||||
SLONG nBank; // -1=const
|
||||
SLONG nBank;
|
||||
//-1 = const
|
||||
struct ISymbol *pNext;
|
||||
};
|
||||
|
||||
struct ISymbol *tHash[HASHSIZE];
|
||||
|
||||
SLONG calchash(char *s)
|
||||
SLONG
|
||||
calchash(char *s)
|
||||
{
|
||||
SLONG r = 0;
|
||||
while (*s)
|
||||
@@ -26,14 +28,16 @@ SLONG calchash(char *s)
|
||||
return (r % HASHSIZE);
|
||||
}
|
||||
|
||||
void sym_Init(void)
|
||||
void
|
||||
sym_Init(void)
|
||||
{
|
||||
SLONG i;
|
||||
for (i = 0; i < HASHSIZE; i += 1)
|
||||
tHash[i] = NULL;
|
||||
}
|
||||
|
||||
SLONG sym_GetValue(char *tzName)
|
||||
SLONG
|
||||
sym_GetValue(char *tzName)
|
||||
{
|
||||
if (strcmp(tzName, "@") == 0) {
|
||||
return (nPC);
|
||||
@@ -55,7 +59,8 @@ SLONG sym_GetValue(char *tzName)
|
||||
}
|
||||
}
|
||||
|
||||
SLONG sym_GetBank(char *tzName)
|
||||
SLONG
|
||||
sym_GetBank(char *tzName)
|
||||
{
|
||||
struct ISymbol **ppSym;
|
||||
|
||||
@@ -73,7 +78,8 @@ SLONG sym_GetBank(char *tzName)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void sym_CreateSymbol(char *tzName, SLONG nValue, SBYTE nBank)
|
||||
void
|
||||
sym_CreateSymbol(char *tzName, SLONG nValue, SBYTE nBank)
|
||||
{
|
||||
if (strcmp(tzName, "@") == 0)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user