2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* options.c */
|
|
|
|
/* */
|
|
|
|
/* Object file options for the ca65 macroassembler */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2000-08-02 13:23:06 +00:00
|
|
|
/* (C) 1998-2000 Ullrich von Bassewitz */
|
|
|
|
/* Wacholderweg 14 */
|
|
|
|
/* D-70597 Stuttgart */
|
|
|
|
/* EMail: uz@musoftware.de */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-20 15:22:57 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-08-02 13:23:06 +00:00
|
|
|
/* common */
|
|
|
|
#include "optdefs.h"
|
|
|
|
#include "xmalloc.h"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2000-08-02 13:23:06 +00:00
|
|
|
/* ca65 */
|
2000-05-28 13:40:48 +00:00
|
|
|
#include "error.h"
|
|
|
|
#include "objfile.h"
|
|
|
|
#include "options.h"
|
2003-05-25 21:06:57 +00:00
|
|
|
#include "spool.h"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Data */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Option list */
|
|
|
|
static Option* OptRoot = 0;
|
|
|
|
static Option* OptLast = 0;
|
|
|
|
static unsigned OptCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-05-25 21:06:57 +00:00
|
|
|
static Option* NewOption (unsigned char Type, unsigned long Val)
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Create a new option, insert it into the list and return it */
|
|
|
|
{
|
|
|
|
Option* Opt;
|
|
|
|
|
|
|
|
/* Allocate memory */
|
2000-06-14 09:32:22 +00:00
|
|
|
Opt = xmalloc (sizeof (*Opt));
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Initialize fields */
|
|
|
|
Opt->Next = 0;
|
|
|
|
Opt->Type = Type;
|
2003-05-25 21:06:57 +00:00
|
|
|
Opt->Val = Val;
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Insert it into the list */
|
|
|
|
if (OptRoot == 0) {
|
|
|
|
OptRoot = Opt;
|
|
|
|
} else {
|
|
|
|
OptLast->Next = Opt;
|
|
|
|
}
|
|
|
|
OptLast = Opt;
|
|
|
|
|
|
|
|
/* One more option now */
|
|
|
|
++OptCount;
|
|
|
|
|
|
|
|
/* Return the new struct */
|
|
|
|
return Opt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptStr (unsigned char Type, const char* Text)
|
|
|
|
/* Add a string option */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (Type, GetStringId (Text));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptComment (const char* Comment)
|
|
|
|
/* Add a comment */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_COMMENT, GetStringId (Comment));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptAuthor (const char* Author)
|
|
|
|
/* Add an author statement */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_AUTHOR, GetStringId (Author));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptTranslator (const char* Translator)
|
|
|
|
/* Add a translator option */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_TRANSLATOR, GetStringId (Translator));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptCompiler (const char* Compiler)
|
|
|
|
/* Add a compiler option */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_COMPILER, GetStringId (Compiler));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptOS (const char* OS)
|
|
|
|
/* Add an operating system option */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_OS, GetStringId (OS));
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptDateTime (unsigned long DateTime)
|
|
|
|
/* Add a date/time option */
|
|
|
|
{
|
2003-05-25 21:06:57 +00:00
|
|
|
NewOption (OPT_DATETIME, DateTime);
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WriteOptions (void)
|
|
|
|
/* Write the options to the object file */
|
|
|
|
{
|
|
|
|
Option* O;
|
|
|
|
|
|
|
|
/* Tell the object file module that we're about to start the options */
|
|
|
|
ObjStartOptions ();
|
|
|
|
|
|
|
|
/* Write the option count */
|
2000-08-02 13:23:06 +00:00
|
|
|
ObjWriteVar (OptCount);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Walk through the list and write the options */
|
|
|
|
O = OptRoot;
|
|
|
|
while (O) {
|
|
|
|
|
2003-05-25 21:06:57 +00:00
|
|
|
/* Write the type of the option, then the value */
|
2000-05-28 13:40:48 +00:00
|
|
|
ObjWrite8 (O->Type);
|
2003-05-25 21:06:57 +00:00
|
|
|
ObjWriteVar (O->Val);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Next option */
|
|
|
|
O = O->Next;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Done writing options */
|
|
|
|
ObjEndOptions ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|