Added Makefile and cleaned-up indent

This commit is contained in:
Tennessee Carmel-Veilleux 2014-07-23 14:57:21 -04:00
parent 2955bbb7ef
commit 984edd2187
2 changed files with 579 additions and 535 deletions

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
CC=gcc
CFLAGS=-O
dcc6502: dcc6502.c
$(CC) -o $@ $^ $(CFLAGS)
clean:
rm -f *.o dcc6502 dcc6502.exe
all: dcc6502

View File

@ -11,9 +11,10 @@
/**************************************************************/ /**************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#define VERSION_INFO "v1.5" #define VERSION_INFO "v1.6"
#define NUMBER_OPCODES 151 #define NUMBER_OPCODES 151
/* The 6502's 13 addressing modes */ /* The 6502's 13 addressing modes */
@ -311,7 +312,6 @@ void add_nes_str(char *instr, char *instr2) {
/* This function put NES-specific info in the comment block */ /* This function put NES-specific info in the comment block */
void append_nes(char *input, unsigned short arg) { void append_nes(char *input, unsigned short arg) {
switch(arg) { switch(arg) {
case 0x2000: add_nes_str(input,"PPU setup #1"); break; case 0x2000: add_nes_str(input,"PPU setup #1"); break;
case 0x2001: add_nes_str(input,"PPU setup #2"); break; case 0x2001: add_nes_str(input,"PPU setup #2"); break;
@ -581,7 +581,6 @@ void disassemble(char *output) {
break; break;
} }
} }
} }
void version(void) { void version(void) {
@ -680,27 +679,62 @@ int main(int argc, char *argv[]) {
exit(1); exit(1);
} }
switch (argv[i][1]) { switch (argv[i][1]) {
case '?': version(); usage(); license(); exit(0); break; case '?':
case 'n': nes_mode = 1; break; version();
case 'c': cycle_counting = 1; break; usage();
case 'h': hex_output = 1; break; license();
case 'v': version(); license(); exit(0); break; exit(0);
case 'o': set_org(argv[i]); break; break;
case 'm': set_max(argv[i]); break; case 'n':
nes_mode = 1;
default: version(); usage(); fprintf(stderr,"Unrecognized switch: %s\n",argv[i]); exit(1); break;
case 'c':
cycle_counting = 1;
break;
case 'h':
hex_output = 1;
break;
case 'v':
version();
license();
exit(0);
break;
case 'o':
set_org(argv[i]);
break;
case 'm':
set_max(argv[i]);
break;
default:
version();
usage();
fprintf(stderr, "Unrecognized switch: %s\n", argv[i]);
exit(1);
} }
} }
} else { } else {
if (argv[1][0] != '-') { if (argv[1][0] != '-') {
strncpy(filename,argv[1],511); strncpy(filename,argv[1],511);
} else } else {
switch (argv[1][1]) { switch (argv[1][1]) {
case '?': version(); usage(); license(); exit(0); break; case '?':
case 'v': version(); license(); exit(0); break; version();
default: version(); usage(); fprintf(stderr,"Unrecognized switch: %s\n",argv[1]); exit(1); usage();
license();
exit(0);
break;
case 'v':
version();
license();
exit(0);
break;
default:
version();
usage();
fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
exit(1);
}
} }
} }
@ -724,7 +758,7 @@ int main(int argc, char *argv[]) {
emit_header(filename, i, org); emit_header(filename, i, org);
PC = 0; PC = 0;
while(PC+org < 65535 && PC <= max && PC < i) { while(((PC + org) < 65535) && (PC <= max) && (PC < i)) {
disassemble(tmpstring); disassemble(tmpstring);
fprintf(stdout,"%s\n",tmpstring); fprintf(stdout,"%s\n",tmpstring);
PC++; PC++;