Removed (pretty inconsistently used) tab chars from source code base.

This commit is contained in:
Oliver Schmidt
2013-05-09 13:56:54 +02:00
parent 44fd1082ae
commit 85885001b1
1773 changed files with 62864 additions and 62868 deletions

View File

@@ -46,7 +46,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -61,7 +61,7 @@ struct AddressSpace {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -101,17 +101,17 @@ static void RemoveCallback (Callback* C)
Callback* N;
Callback** L = &List;
while ((N = *L) != 0) {
if (N == C) {
/* Found, remove it */
if (C->Next) {
/* Adjust the counter of the following callback */
C->Next->Ticks += C->Ticks;
}
*L = C->Next;
return;
} else {
L = &N->Next;
}
if (N == C) {
/* Found, remove it */
if (C->Next) {
/* Adjust the counter of the following callback */
C->Next->Ticks += C->Ticks;
}
*L = C->Next;
return;
} else {
L = &N->Next;
}
}
/* Callback was not found */
@@ -121,7 +121,7 @@ static void RemoveCallback (Callback* C)
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -53,7 +53,7 @@ typedef struct Callback Callback;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* cfgdata.c */
/* cfgdata.c */
/* */
/* Config data structure */
/* Config data structure */
/* */
/* */
/* */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* cfgdata.h */
/* cfgdata.h */
/* */
/* Config data structure */
/* Config data structure */
/* */
/* */
/* */
@@ -53,17 +53,17 @@ typedef struct CfgData CfgData;
struct CfgData {
enum {
CfgDataInvalid,
CfgDataId,
CfgDataNumber,
CfgDataString
} Type; /* Type of the value */
CfgDataId,
CfgDataNumber,
CfgDataString
} Type; /* Type of the value */
union {
char* SVal; /* String or id value */
long IVal; /* Integer value */
long IVal; /* Integer value */
} V;
unsigned Line; /* Line where the attribute was defined */
unsigned Col; /* Column of attribute definition */
char Attr[1]; /* The attribute name */
char Attr[1]; /* The attribute name */
};

View File

@@ -95,8 +95,8 @@ static Collection ChipLibraries = STATIC_COLLECTION_INITIALIZER;
/* SimData instance */
static const SimData Sim65Data = {
1, /* MajorVersion */
1, /* MinorVersion */
1, /* MajorVersion */
1, /* MinorVersion */
xmalloc,
xfree,
Warning,
@@ -158,7 +158,7 @@ static int GetCfgNum (void* CfgInfo, const char* Name, long* Val)
static int CmpChips (void* Data attribute ((unused)),
const void* lhs, const void* rhs)
const void* lhs, const void* rhs)
/* Compare function for CollSort */
{
/* Cast the object pointers */
@@ -181,14 +181,14 @@ static Chip* FindChip (const char* Name)
/* ## We do a linear search for now */
for (I = 0; I < CollCount (&Chips); ++I) {
/* Get the chip at this position */
Chip* C = CollAt (&Chips, I);
/* Get the chip at this position */
Chip* C = CollAt (&Chips, I);
/* Compare the name */
if (strcmp (Name, C->Data->ChipName) == 0) {
/* Found */
return C;
}
/* Compare the name */
if (strcmp (Name, C->Data->ChipName) == 0) {
/* Found */
return C;
}
}
/* Not found */
@@ -198,7 +198,7 @@ static Chip* FindChip (const char* Name)
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -358,7 +358,7 @@ void LoadChipLibrary (const char* LibName)
/* Check the error message */
Msg = dlerror ();
if (Msg) {
/* We had an error */
/* We had an error */
Error ("Cannot find export `GetChipData' in `%s': %s", L->LibName, Msg);
FreeChipLibrary (L);
return;
@@ -395,8 +395,8 @@ void LoadChipLibrary (const char* LibName)
continue;
}
/* Initialize the chip passing the simulator data */
D->InitChip (&Sim65Data);
/* Initialize the chip passing the simulator data */
D->InitChip (&Sim65Data);
/* Generate a new chip */
C = NewChip (L, D);
@@ -407,7 +407,7 @@ void LoadChipLibrary (const char* LibName)
/* Output chip name and version to keep the user happy */
Print (stdout, 1,
" Found %s `%s', version %u.%u in library `%s'\n",
(D->Type == CHIPDATA_TYPE_CHIP)? "chip" : "cpu",
(D->Type == CHIPDATA_TYPE_CHIP)? "chip" : "cpu",
D->ChipName,
D->MajorVersion,
D->MinorVersion,

View File

@@ -87,7 +87,7 @@ struct ChipLibrary {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -65,7 +65,7 @@ struct ChipData {
/* -- Exported functions -- */
int (*InitChip) (const struct SimData* Data);
void* (*CreateInstance) (unsigned Addr, unsigned Range, void* CfgInfo);
void (*DestroyInstance) (void* Data);
void (*DestroyInstance) (void* Data);
void (*WriteCtrl) (void* Data, unsigned Offs, unsigned char Val);
void (*Write) (void* Data, unsigned Offs, unsigned char Val);
unsigned char (*ReadCtrl) (void* Data, unsigned Offs);

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* chipif.h */
/* chipif.h */
/* */
/* Interface header file for chip plugins - unused by sim65 */
/* */

View File

@@ -49,7 +49,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -59,7 +59,7 @@ SearchPath* ChipSearchPath; /* Search paths for chip libs */
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -44,7 +44,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -54,7 +54,7 @@ extern SearchPath* ChipSearchPath; /* Search paths for chip libs */
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -106,7 +106,7 @@ static const struct ChipData CData[] = {
/* -- Exported functions -- */
ScreenInitChip,
ScreenCreateInstance,
ScreenDestroyInstance,
ScreenDestroyInstance,
ScreenWrite,
ScreenWrite,
ScreenRead,
@@ -624,7 +624,7 @@ static void ScreenEventLoop (void)
switch (Event.type) {
case Expose:
/* Calculate the area to redraw, then update the screen */
/* Calculate the area to redraw, then update the screen */
X1 = Event.xexpose.x;
Y1 = Event.xexpose.y;
X2 = Event.xexpose.x + Event.xexpose.width - 1;

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* ram.c */
/* ram.c */
/* */
/* RAM plugin for the sim65 6502 simulator */
/* RAM plugin for the sim65 6502 simulator */
/* */
/* */
/* */
@@ -87,7 +87,7 @@ static const struct ChipData CData[1] = {
/* -- Exported functions -- */
InitChip,
CreateInstance,
DestroyInstance,
DestroyInstance,
WriteCtrl,
Write,
ReadCtrl,
@@ -100,7 +100,7 @@ static const SimData* Sim;
/* Possible RAM attributes */
#define ATTR_INITIALIZED 0x01 /* RAM cell is intialized */
#define ATTR_WPROT 0x02 /* RAM cell is write protected */
#define ATTR_WPROT 0x02 /* RAM cell is write protected */
/* Data for one RAM instance */
typedef struct InstanceData InstanceData;

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* rom.c */
/* rom.c */
/* */
/* ROM plugin for the sim65 6502 simulator */
/* ROM plugin for the sim65 6502 simulator */
/* */
/* */
/* */
@@ -89,7 +89,7 @@ static const struct ChipData CData[1] = {
/* -- Exported functions -- */
InitChip,
CreateInstance,
DestroyInstance,
DestroyInstance,
WriteCtrl,
Write,
ReadCtrl,
@@ -224,7 +224,7 @@ static void Write (void* Data, unsigned Offs, unsigned char Val)
/* Print a warning */
Sim->Break ("Writing to write protected memory at $%04X (value = $%02X)",
D->BaseAddr+Offs, Val);
D->BaseAddr+Offs, Val);
}

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* stdio.c */
/* stdio.c */
/* */
/* STDIO plugin for the sim65 6502 simulator */
/* STDIO plugin for the sim65 6502 simulator */
/* */
/* */
/* */
@@ -94,7 +94,7 @@ static const struct ChipData CData[1] = {
/* -- Exported functions -- */
InitChip,
CreateInstance,
DestroyInstance,
DestroyInstance,
WriteCtrl,
Write,
ReadCtrl,

View File

@@ -2,7 +2,7 @@
/* */
/* vic2.c */
/* */
/* VIC II plugin for the sim65 6502 simulator */
/* VIC II plugin for the sim65 6502 simulator */
/* */
/* */
/* */
@@ -136,7 +136,7 @@ static const struct ChipData CData[] = {
/* -- Exported functions -- */
VicInitChip,
VicCreateInstance,
VicDestroyInstance,
VicDestroyInstance,
VicWrite,
VicWrite,
VicRead,
@@ -151,7 +151,7 @@ static const struct ChipData CData[] = {
/* -- Exported functions -- */
VRamInitChip,
VRamCreateInstance,
VRamDestroyInstance,
VRamDestroyInstance,
VRamWrite,
VRamWrite,
VRamRead,
@@ -166,7 +166,7 @@ static const struct ChipData CData[] = {
/* -- Exported functions -- */
CRamInitChip,
CRamCreateInstance,
CRamDestroyInstance,
CRamDestroyInstance,
CRamWrite,
CRamWrite,
CRamRead,
@@ -176,8 +176,8 @@ static const struct ChipData CData[] = {
/* Defines for the VIC chip */
#define VIC_COLOR_COUNT 16
#define VIC_BLACK 0
#define VIC_WHITE 1
#define VIC_BLACK 0
#define VIC_WHITE 1
/* The application color map. VIC II color values are taken from
* http://www.pepto.de/projects/colorvic/ (Philip "Pepto" Timmermann)
@@ -774,7 +774,7 @@ static void VRamEventLoop (void)
switch (Event.type) {
case Expose:
/* Calculate the area to redraw, then update the screen */
/* Calculate the area to redraw, then update the screen */
X1 = Event.xexpose.x;
Y1 = Event.xexpose.y;
X2 = Event.xexpose.x + Event.xexpose.width - 1;

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* config.c */
/* config.c */
/* */
/* Configuration file parsing for the sim65 6502 simulator */
/* */
@@ -58,7 +58,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -69,7 +69,7 @@ static void FlagAttr (unsigned* Flags, unsigned Mask, const char* Name)
*/
{
if (*Flags & Mask) {
CfgError ("%s is already defined", Name);
CfgError ("%s is already defined", Name);
}
*Flags |= Mask;
}
@@ -80,7 +80,7 @@ static void AttrCheck (unsigned Attr, unsigned Mask, const char* Name)
/* Check that a mandatory attribute was given */
{
if ((Attr & Mask) == 0) {
CfgError ("%s attribute is missing", Name);
CfgError ("%s attribute is missing", Name);
}
}
@@ -195,8 +195,8 @@ static void ParseAddrSpace (void)
CfgData* D = NewCfgData ();
CfgNextTok ();
/* An optional assignment follows */
CfgOptionalAssign ();
/* An optional assignment follows */
CfgOptionalAssign ();
/* Check and assign the attribute value */
switch (CfgTok) {
@@ -223,13 +223,13 @@ static void ParseAddrSpace (void)
/* Add the attribute to the location */
CollAppend (&L->Attributes, D);
/* Skip the attribute value and an optional comma */
CfgNextTok ();
CfgOptionalComma ();
}
/* Skip the attribute value and an optional comma */
CfgNextTok ();
CfgOptionalComma ();
}
/* Skip the semicolon */
CfgConsumeSemi ();
/* Skip the semicolon */
CfgConsumeSemi ();
}
/* Sort all memory locations */
@@ -335,23 +335,23 @@ static void ParseConfig (void)
/* Parse the config file */
{
static const IdentTok BlockNames [] = {
{ "ADDRSPACE", CFGTOK_ADDRSPACE },
{ "CPU", CFGTOK_CPU },
{ "ADDRSPACE", CFGTOK_ADDRSPACE },
{ "CPU", CFGTOK_CPU },
};
cfgtok_t BlockTok;
do {
/* Read the block ident */
CfgSpecialToken (BlockNames, ENTRY_COUNT (BlockNames), "Block identifier");
BlockTok = CfgTok;
CfgNextTok ();
/* Read the block ident */
CfgSpecialToken (BlockNames, ENTRY_COUNT (BlockNames), "Block identifier");
BlockTok = CfgTok;
CfgNextTok ();
/* Expected a curly brace */
CfgConsume (CFGTOK_LCURLY, "`{' expected");
/* Expected a curly brace */
CfgConsume (CFGTOK_LCURLY, "`{' expected");
/* Read the block */
switch (BlockTok) {
/* Read the block */
switch (BlockTok) {
case CFGTOK_ADDRSPACE:
ParseAddrSpace ();
@@ -361,13 +361,13 @@ static void ParseConfig (void)
ParseCPU ();
break;
default:
FAIL ("Unexpected block token");
default:
FAIL ("Unexpected block token");
}
}
/* Skip closing brace */
CfgConsumeRCurly ();
/* Skip closing brace */
CfgConsumeRCurly ();
} while (CfgTok != CFGTOK_EOF);
}

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* config.h */
/* config.h */
/* */
/* Configuration file parsing for the sim65 6502 simulator */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -45,7 +45,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -44,7 +44,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -64,7 +64,7 @@ struct CPUCore {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* cpudata.h */
/* cpudata.h */
/* */
/* CPU data passed from the CPU plugins */
/* */

View File

@@ -84,7 +84,7 @@ static unsigned long GetCycles (void* Data);
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -95,23 +95,23 @@ static const SimData* Sim;
/* 6502 CPU registers */
typedef struct CPURegs CPURegs;
struct CPURegs {
unsigned AC; /* Accumulator */
unsigned XR; /* X register */
unsigned YR; /* Y register */
unsigned AC; /* Accumulator */
unsigned XR; /* X register */
unsigned YR; /* Y register */
unsigned ZR; /* Z register */
unsigned SR; /* Status register */
unsigned SP; /* Stackpointer */
unsigned PC; /* Program counter */
unsigned SR; /* Status register */
unsigned SP; /* Stackpointer */
unsigned PC; /* Program counter */
};
/* Status register bits */
#define CF 0x01 /* Carry flag */
#define ZF 0x02 /* Zero flag */
#define IF 0x04 /* Interrupt flag */
#define DF 0x08 /* Decimal flag */
#define BF 0x10 /* Break flag */
#define OF 0x40 /* Overflow flag */
#define SF 0x80 /* Sign flag */
#define CF 0x01 /* Carry flag */
#define ZF 0x02 /* Zero flag */
#define IF 0x04 /* Interrupt flag */
#define DF 0x08 /* Decimal flag */
#define BF 0x10 /* Break flag */
#define OF 0x40 /* Overflow flag */
#define SF 0x80 /* Sign flag */
/* Type of an opcode handler function */
struct CPUInstance;
@@ -172,7 +172,7 @@ struct CPUInstance {
/*****************************************************************************/
/* Helper functions and macros */
/* Helper functions and macros */
/*****************************************************************************/
@@ -205,8 +205,8 @@ struct CPUInstance {
#define TEST_CF(v) SET_CF (((v) & 0xFF00) != 0)
/* Program counter halves */
#define PCL (D->Regs.PC & 0xFF)
#define PCH ((D->Regs.PC >> 8) & 0xFF)
#define PCL (D->Regs.PC & 0xFF)
#define PCH ((D->Regs.PC >> 8) & 0xFF)
/* Stack operations */
#define PUSH(Val) MemWriteByte (D->StackPage + D->Regs.SP--, Val)
@@ -2909,7 +2909,7 @@ static const OPFunc OP65C02Table[256] = {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -2,7 +2,7 @@
/* */
/* cputype.h */
/* */
/* CPU type definitions */
/* CPU type definitions */
/* */
/* */
/* */
@@ -38,13 +38,13 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* Current CPU */
CPUType CPU = CPU_6502;
CPUType CPU = CPU_6502;

View File

@@ -2,7 +2,7 @@
/* */
/* cputype.h */
/* */
/* CPU type definitions */
/* CPU type definitions */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -51,7 +51,7 @@ typedef enum CPUType {
} CPUType;
/* Current CPU */
extern CPUType CPU;
extern CPUType CPU;

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* error.c */
/* error.c */
/* */
/* Error handling for the sim65 simulator */
/* */
@@ -42,7 +42,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* error.h */
/* error.h */
/* */
/* Error handling for the sim65 simulator */
/* */
@@ -44,7 +44,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* global.c */
/* global.c */
/* */
/* Global variables for the sim65 6502 simulator */
/* */
@@ -38,12 +38,12 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
unsigned char Debug = 0; /* Debug mode */
unsigned char Debug = 0; /* Debug mode */

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* global.h */
/* global.h */
/* */
/* Global variables for the sim65 6502 simulator */
/* */
@@ -39,12 +39,12 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
extern unsigned char Debug; /* Debug mode */
extern unsigned char Debug; /* Debug mode */

View File

@@ -57,7 +57,7 @@ Collection Locations = STATIC_COLLECTION_INITIALIZER;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -82,7 +82,7 @@ Location* NewLocation (unsigned long Start, unsigned long End)
static int CmpLocations (void* Data attribute ((unused)),
const void* lhs, const void* rhs)
const void* lhs, const void* rhs)
/* Compare function for CollSort */
{
/* Cast the object pointers */

View File

@@ -65,7 +65,7 @@ struct Location {
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* main.c */
/* main.c */
/* */
/* sim65 main program */
/* */
@@ -62,7 +62,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -108,17 +108,17 @@ static void OptChipDir (const char* Opt attribute ((unused)), const char* Arg)
/* Read in all files and treat them as libraries */
while ((E = readdir (D)) != 0) {
char* Name;
char* Name;
struct stat S;
/* ### Ignore anything but *.so files */
unsigned NameLen = strlen (E->d_name);
if (NameLen <= 3) {
continue;
}
if (strcmp (E->d_name + NameLen - 3, ".so") != 0) {
continue;
}
/* ### Ignore anything but *.so files */
unsigned NameLen = strlen (E->d_name);
if (NameLen <= 3) {
continue;
}
if (strcmp (E->d_name + NameLen - 3, ".so") != 0) {
continue;
}
/* Create the full file name */
Name = xmalloc (DirLen + 1 + NameLen + 1);
@@ -153,11 +153,11 @@ static void OptCPU (const char* Opt, const char* Arg)
/* Handle the --cpu option */
{
if (strcmp (Arg, "6502") == 0) {
CPU = CPU_6502;
CPU = CPU_6502;
} else if (strcmp (Arg, "65C02") == 0) {
CPU = CPU_65C02;
CPU = CPU_65C02;
} else {
AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
}
}
@@ -167,7 +167,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
/* Define the config file */
{
if (CfgAvail ()) {
Error ("Cannot use -C twice");
Error ("Cannot use -C twice");
}
CfgSetName (Arg);
}
@@ -175,7 +175,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
static void OptDebug (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
const char* Arg attribute ((unused)))
/* Simulator debug mode */
{
Debug = 1;
@@ -184,7 +184,7 @@ static void OptDebug (const char* Opt attribute ((unused)),
static void OptHelp (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
const char* Arg attribute ((unused)))
/* Print usage information and exit */
{
Usage ();
@@ -194,7 +194,7 @@ static void OptHelp (const char* Opt attribute ((unused)),
static void OptVerbose (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
const char* Arg attribute ((unused)))
/* Increase verbosity */
{
++Verbosity;
@@ -203,7 +203,7 @@ static void OptVerbose (const char* Opt attribute ((unused)),
static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
const char* Arg attribute ((unused)))
/* Print the assembler version */
{
fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
@@ -215,13 +215,13 @@ int main (int argc, char* argv[])
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--chipdir", 1, OptChipDir },
{ "--config", 1, OptConfig },
{ "--cpu", 1, OptCPU },
{ "--debug", 0, OptDebug },
{ "--help", 0, OptHelp },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--chipdir", 1, OptChipDir },
{ "--config", 1, OptConfig },
{ "--cpu", 1, OptCPU },
{ "--debug", 0, OptDebug },
{ "--help", 0, OptHelp },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
};
unsigned I;
@@ -239,57 +239,57 @@ int main (int argc, char* argv[])
I = 1;
while (I < ArgCount) {
/* Get the argument */
const char* Arg = ArgVec[I];
/* Get the argument */
const char* Arg = ArgVec[I];
/* Check for an option */
if (Arg [0] == '-') {
/* Check for an option */
if (Arg [0] == '-') {
switch (Arg [1]) {
switch (Arg [1]) {
case '-':
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break;
case '-':
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break;
case 'd':
OptDebug (Arg, 0);
break;
case 'd':
OptDebug (Arg, 0);
break;
case 'h':
case '?':
OptHelp (Arg, 0);
break;
case 'h':
case '?':
OptHelp (Arg, 0);
break;
case 'v':
OptVerbose (Arg, 0);
break;
case 'v':
OptVerbose (Arg, 0);
break;
case 'C':
OptConfig (Arg, GetArg (&I, 2));
break;
case 'C':
OptConfig (Arg, GetArg (&I, 2));
break;
case 'L':
OptChipDir (Arg, GetArg (&I, 2));
break;
case 'L':
OptChipDir (Arg, GetArg (&I, 2));
break;
case 'V':
OptVersion (Arg, 0);
break;
case 'V':
OptVersion (Arg, 0);
break;
default:
UnknownOption (Arg);
break;
}
} else {
if (InputFile) {
fprintf (stderr, "additional file specs ignored\n");
} else {
InputFile = Arg;
}
}
default:
UnknownOption (Arg);
break;
}
} else {
if (InputFile) {
fprintf (stderr, "additional file specs ignored\n");
} else {
InputFile = Arg;
}
}
/* Next argument */
++I;
/* Next argument */
++I;
}
/* Sort the already loaded chips */
@@ -297,7 +297,7 @@ int main (int argc, char* argv[])
/* Check if we have a valid configuration */
if (!CfgAvail ()) {
Error ("Simulator configuration missing");
Error ("Simulator configuration missing");
}
/* Initialize the simulated CPU memory */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* memory.h */
/* memory.h */
/* */
/* Memory subsystem for the 6502 simulator */
/* Memory subsystem for the 6502 simulator */
/* */
/* */
/* */
@@ -50,7 +50,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -62,7 +62,7 @@ unsigned MemSize = 0;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* memory.h */
/* memory.h */
/* */
/* Memory subsystem for the 6502 simulator */
/* Memory subsystem for the 6502 simulator */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -53,7 +53,7 @@ extern unsigned MemSize;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* scanner.c */
/* scanner.c */
/* */
/* Configuration file scanner for the sim65 6502 simulator */
/* */
@@ -50,34 +50,34 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* Current token and attributes */
cfgtok_t CfgTok;
StrBuf CfgSVal = STATIC_STRBUF_INITIALIZER;
cfgtok_t CfgTok;
StrBuf CfgSVal = STATIC_STRBUF_INITIALIZER;
unsigned long CfgIVal;
/* Error location */
unsigned CfgErrorLine;
unsigned CfgErrorCol;
unsigned CfgErrorLine;
unsigned CfgErrorCol;
/* Input sources for the configuration */
static const char* CfgName = 0;
static const char* CfgBuf = 0;
static const char* CfgName = 0;
static const char* CfgBuf = 0;
/* Other input stuff */
static int C = ' ';
static unsigned InputLine = 1;
static unsigned InputCol = 0;
static FILE* InputFile = 0;
static int C = ' ';
static unsigned InputLine = 1;
static unsigned InputCol = 0;
static FILE* InputFile = 0;
/*****************************************************************************/
/* Error handling */
/* Error handling */
/*****************************************************************************/
@@ -113,7 +113,7 @@ void CfgError (const char* Format, ...)
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -122,27 +122,27 @@ static void NextChar (void)
/* Read the next character from the input file */
{
if (CfgBuf) {
/* Read from buffer */
C = (unsigned char)(*CfgBuf);
if (C == 0) {
C = EOF;
} else {
++CfgBuf;
}
/* Read from buffer */
C = (unsigned char)(*CfgBuf);
if (C == 0) {
C = EOF;
} else {
++CfgBuf;
}
} else {
/* Read from the file */
C = getc (InputFile);
/* Read from the file */
C = getc (InputFile);
}
/* Count columns */
if (C != EOF) {
++InputCol;
++InputCol;
}
/* Count lines */
if (C == '\n') {
++InputLine;
InputCol = 0;
++InputLine;
InputCol = 0;
}
}
@@ -152,9 +152,9 @@ static unsigned DigitVal (int C)
/* Return the value for a numeric digit */
{
if (isdigit (C)) {
return C - '0';
return C - '0';
} else {
return toupper (C) - 'A' + 10;
return toupper (C) - 'A' + 10;
}
}
@@ -169,7 +169,7 @@ void CfgNextTok (void)
Again:
/* Skip whitespace */
while (isspace (C)) {
NextChar ();
NextChar ();
}
/* Remember the current position */
@@ -179,122 +179,122 @@ Again:
/* Identifier? */
if (C == '_' || IsAlpha (C)) {
/* Read the identifier */
I = 0;
while (C == '_' || IsAlNum (C)) {
if (I < CFG_MAX_IDENT_LEN) {
CfgSVal [I++] = C;
}
NextChar ();
}
CfgSVal [I] = '\0';
CfgTok = CFGTOK_IDENT;
return;
/* Read the identifier */
I = 0;
while (C == '_' || IsAlNum (C)) {
if (I < CFG_MAX_IDENT_LEN) {
CfgSVal [I++] = C;
}
NextChar ();
}
CfgSVal [I] = '\0';
CfgTok = CFGTOK_IDENT;
return;
}
/* Hex number? */
if (C == '$') {
NextChar ();
if (!isxdigit (C)) {
Error ("%s(%u): Hex digit expected", CfgName, InputLine);
}
CfgIVal = 0;
while (isxdigit (C)) {
CfgIVal = CfgIVal * 16 + DigitVal (C);
NextChar ();
}
CfgTok = CFGTOK_INTCON;
return;
NextChar ();
if (!isxdigit (C)) {
Error ("%s(%u): Hex digit expected", CfgName, InputLine);
}
CfgIVal = 0;
while (isxdigit (C)) {
CfgIVal = CfgIVal * 16 + DigitVal (C);
NextChar ();
}
CfgTok = CFGTOK_INTCON;
return;
}
/* Decimal number? */
if (isdigit (C)) {
CfgIVal = 0;
while (isdigit (C)) {
CfgIVal = CfgIVal * 10 + DigitVal (C);
NextChar ();
}
CfgTok = CFGTOK_INTCON;
return;
CfgIVal = 0;
while (isdigit (C)) {
CfgIVal = CfgIVal * 10 + DigitVal (C);
NextChar ();
}
CfgTok = CFGTOK_INTCON;
return;
}
/* Other characters */
switch (C) {
case '{':
NextChar ();
CfgTok = CFGTOK_LCURLY;
break;
case '{':
NextChar ();
CfgTok = CFGTOK_LCURLY;
break;
case '}':
NextChar ();
CfgTok = CFGTOK_RCURLY;
break;
case '}':
NextChar ();
CfgTok = CFGTOK_RCURLY;
break;
case ';':
NextChar ();
CfgTok = CFGTOK_SEMI;
break;
case ';':
NextChar ();
CfgTok = CFGTOK_SEMI;
break;
case '.':
NextChar ();
case '.':
NextChar ();
if (C == '.') {
NextChar ();
CfgTok = CFGTOK_DOTDOT;
} else {
CfgTok = CFGTOK_DOT;
CfgTok = CFGTOK_DOT;
}
break;
break;
case ',':
NextChar ();
CfgTok = CFGTOK_COMMA;
break;
case ',':
NextChar ();
CfgTok = CFGTOK_COMMA;
break;
case '=':
NextChar ();
CfgTok = CFGTOK_EQ;
break;
case '=':
NextChar ();
CfgTok = CFGTOK_EQ;
break;
case ':':
NextChar ();
CfgTok = CFGTOK_COLON;
break;
NextChar ();
CfgTok = CFGTOK_COLON;
break;
case '\"':
NextChar ();
I = 0;
while (C != '\"') {
if (C == EOF || C == '\n') {
Error ("%s(%u): Unterminated string", CfgName, InputLine);
}
if (I < CFG_MAX_IDENT_LEN) {
CfgSVal [I++] = C;
}
NextChar ();
}
NextChar ();
CfgSVal [I] = '\0';
CfgTok = CFGTOK_STRCON;
break;
NextChar ();
I = 0;
while (C != '\"') {
if (C == EOF || C == '\n') {
Error ("%s(%u): Unterminated string", CfgName, InputLine);
}
if (I < CFG_MAX_IDENT_LEN) {
CfgSVal [I++] = C;
}
NextChar ();
}
NextChar ();
CfgSVal [I] = '\0';
CfgTok = CFGTOK_STRCON;
break;
case '#':
/* Comment */
while (C != '\n' && C != EOF) {
NextChar ();
}
if (C != EOF) {
goto Again;
}
CfgTok = CFGTOK_EOF;
break;
/* Comment */
while (C != '\n' && C != EOF) {
NextChar ();
}
if (C != EOF) {
goto Again;
}
CfgTok = CFGTOK_EOF;
break;
case EOF:
CfgTok = CFGTOK_EOF;
break;
CfgTok = CFGTOK_EOF;
break;
default:
Error ("%s(%u): Invalid character `%c'", CfgName, InputLine, C);
default:
Error ("%s(%u): Invalid character `%c'", CfgName, InputLine, C);
}
}
@@ -305,7 +305,7 @@ void CfgConsume (cfgtok_t T, const char* Msg)
/* Skip a token, print an error message if not found */
{
if (CfgTok != T) {
CfgError ("%s", Msg);
CfgError ("%s", Msg);
}
CfgNextTok ();
}
@@ -340,7 +340,7 @@ void CfgOptionalComma (void)
/* Consume a comma if there is one */
{
if (CfgTok == CFGTOK_COMMA) {
CfgNextTok ();
CfgNextTok ();
}
}
@@ -350,7 +350,7 @@ void CfgOptionalAssign (void)
/* Consume an equal sign if there is one */
{
if (CfgTok == CFGTOK_EQ) {
CfgNextTok ();
CfgNextTok ();
}
}
@@ -360,7 +360,7 @@ void CfgAssureInt (void)
/* Make sure the next token is an integer */
{
if (CfgTok != CFGTOK_INTCON) {
CfgError ("Integer constant expected");
CfgError ("Integer constant expected");
}
}
@@ -370,7 +370,7 @@ void CfgAssureStr (void)
/* Make sure the next token is a string constant */
{
if (CfgTok != CFGTOK_STRCON) {
CfgError ("String constant expected");
CfgError ("String constant expected");
}
}
@@ -380,7 +380,7 @@ void CfgAssureIdent (void)
/* Make sure the next token is an identifier */
{
if (CfgTok != CFGTOK_IDENT) {
CfgError ("Identifier expected");
CfgError ("Identifier expected");
}
}
@@ -390,7 +390,7 @@ void CfgRangeCheck (unsigned long Lo, unsigned long Hi)
/* Check the range of CfgIVal */
{
if (CfgIVal < Lo || CfgIVal > Hi) {
CfgError ("Range error");
CfgError ("Range error");
}
}
@@ -404,20 +404,20 @@ void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name)
/* We need an identifier */
if (CfgTok == CFGTOK_IDENT) {
/* Make it upper case */
I = 0;
while (CfgSVal [I]) {
CfgSVal [I] = toupper (CfgSVal [I]);
++I;
}
/* Make it upper case */
I = 0;
while (CfgSVal [I]) {
CfgSVal [I] = toupper (CfgSVal [I]);
++I;
}
/* Linear search */
for (I = 0; I < Size; ++I) {
if (strcmp (CfgSVal, Table [I].Ident) == 0) {
CfgTok = Table [I].Tok;
return;
}
}
/* Linear search */
for (I = 0; I < Size; ++I) {
if (strcmp (CfgSVal, Table [I].Ident) == 0) {
CfgTok = Table [I].Tok;
return;
}
}
}
@@ -431,21 +431,21 @@ void CfgBoolToken (void)
/* Map an identifier or integer to a boolean token */
{
static const IdentTok Booleans [] = {
{ "YES", CFGTOK_TRUE },
{ "NO", CFGTOK_FALSE },
{ "YES", CFGTOK_TRUE },
{ "NO", CFGTOK_FALSE },
{ "TRUE", CFGTOK_TRUE },
{ "FALSE", CFGTOK_FALSE },
};
/* If we have an identifier, map it to a boolean token */
if (CfgTok == CFGTOK_IDENT) {
CfgSpecialToken (Booleans, ENTRY_COUNT (Booleans), "Boolean");
CfgSpecialToken (Booleans, ENTRY_COUNT (Booleans), "Boolean");
} else {
/* We expected an integer here */
if (CfgTok != CFGTOK_INTCON) {
CfgError ("Boolean value expected");
}
CfgTok = (CfgIVal == 0)? CFGTOK_FALSE : CFGTOK_TRUE;
/* We expected an integer here */
if (CfgTok != CFGTOK_INTCON) {
CfgError ("Boolean value expected");
}
CfgTok = (CfgIVal == 0)? CFGTOK_FALSE : CFGTOK_TRUE;
}
}
@@ -463,11 +463,11 @@ const char* CfgGetName (void)
/* Get the name of the config file */
{
if (CfgName) {
return CfgName;
return CfgName;
} else if (CfgBuf) {
return "[builtin config]";
return "[builtin config]";
} else {
return "";
return "";
}
}
@@ -497,11 +497,11 @@ void CfgOpenInput (void)
*/
if (!CfgBuf) {
/* Open the file */
InputFile = fopen (CfgName, "r");
if (InputFile == 0) {
Error ("Cannot open `%s': %s", CfgName, strerror (errno));
}
/* Open the file */
InputFile = fopen (CfgName, "r");
if (InputFile == 0) {
Error ("Cannot open `%s': %s", CfgName, strerror (errno));
}
}
@@ -522,7 +522,7 @@ void CfgCloseInput (void)
/* Close the input file if we had one */
if (InputFile) {
(void) fclose (InputFile);
InputFile = 0;
InputFile = 0;
}
}

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* scanner.h */
/* scanner.h */
/* */
/* Configuration file scanner for the sim65 6502 simulator */
/* */
@@ -45,7 +45,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -84,26 +84,26 @@ typedef enum {
/* Mapping table entry, special identifier --> token */
typedef struct IdentTok IdentTok;
struct IdentTok {
const char* Ident; /* Identifier */
cfgtok_t Tok; /* Token for identifier */
const char* Ident; /* Identifier */
cfgtok_t Tok; /* Token for identifier */
};
#define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
#define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
/* Current token and attributes */
extern cfgtok_t CfgTok;
extern StrBuf CfgSVal;
extern unsigned long CfgIVal;
extern cfgtok_t CfgTok;
extern StrBuf CfgSVal;
extern unsigned long CfgIVal;
/* Error location */
extern unsigned CfgErrorLine;
extern unsigned CfgErrorCol;
extern unsigned CfgErrorLine;
extern unsigned CfgErrorCol;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* simdata.h */
/* simdata.h */
/* */
/* Simulator data passed to the chip plugins */
/* Simulator data passed to the chip plugins */
/* */
/* */
/* */
@@ -47,8 +47,8 @@
/* SimData structure */
typedef struct SimData SimData;
struct SimData {
unsigned MajorVersion;
unsigned MinorVersion;
unsigned MajorVersion;
unsigned MinorVersion;
/* -- Callback functions -- */

View File

@@ -42,7 +42,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -70,7 +70,7 @@ extern System* System;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/