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