1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-10 14:29:30 +00:00

Remove option flags; remove unnecessary --flash option

This commit is contained in:
Peter Evans 2018-03-21 15:26:58 -05:00
parent a461194a63
commit 2870bc03bc
4 changed files with 3 additions and 37 deletions

View File

@ -5,8 +5,7 @@
#include <stdio.h> #include <stdio.h>
enum option_flags { enum option_flags {
OPTION_FLASH = 1, OPTION_DISASSEMBLE = 1,
OPTION_DISASSEMBLE = 2,
}; };
/* /*

View File

@ -337,10 +337,9 @@ apple2_free(apple2 *mach)
void void
apple2_run_loop(apple2 *mach) apple2_run_loop(apple2 *mach)
{ {
FILE *dlog = NULL; FILE *dlog = (FILE *)vm_di_get(VM_DISASM_LOG);
if (option_flag(OPTION_DISASSEMBLE)) { if (dlog != NULL) {
dlog = (FILE *)vm_di_get(VM_DISASM_LOG);
vm_reflect_disasm(NULL); vm_reflect_disasm(NULL);
} }

View File

@ -44,8 +44,6 @@ static char error_buffer[ERRBUF_SIZE] = "";
static int width = 840; static int width = 840;
static int height = 576; static int height = 576;
static int flags = 0;
/* /*
* These are all of the options we allow in our long-form options. It's * These are all of the options we allow in our long-form options. It's
* a bit faster to identify them by integer symbols than to do string * a bit faster to identify them by integer symbols than to do string
@ -55,7 +53,6 @@ enum options {
DISK1, DISK1,
DISK2, DISK2,
HELP, HELP,
FLASH,
DISASSEMBLE, DISASSEMBLE,
}; };
@ -66,7 +63,6 @@ static struct option long_options[] = {
{ "disassemble", 1, NULL, DISASSEMBLE }, { "disassemble", 1, NULL, DISASSEMBLE },
{ "disk1", 1, NULL, DISK1 }, { "disk1", 1, NULL, DISK1 },
{ "disk2", 1, NULL, DISK2 }, { "disk2", 1, NULL, DISK2 },
{ "flash", 0, NULL, FLASH },
{ "help", 0, NULL, HELP }, { "help", 0, NULL, HELP },
}; };
@ -120,7 +116,6 @@ option_parse(int argc, char **argv)
switch (opt) { switch (opt) {
case DISASSEMBLE: case DISASSEMBLE:
flags |= OPTION_DISASSEMBLE;
if (!option_open_file(&disasm_log, optarg, "w")) { if (!option_open_file(&disasm_log, optarg, "w")) {
return 0; return 0;
} }
@ -144,10 +139,6 @@ option_parse(int argc, char **argv)
vm_di_set(VM_DISK2, input2); vm_di_set(VM_DISK2, input2);
break; break;
case FLASH:
flags |= OPTION_FLASH;
break;
case HELP: case HELP:
option_print_help(); option_print_help();
@ -200,17 +191,7 @@ option_print_help()
--disassemble=FILE Write assembly notation into FILE\n\ --disassemble=FILE Write assembly notation into FILE\n\
--disk1=FILE Load FILE into disk drive 1\n\ --disk1=FILE Load FILE into disk drive 1\n\
--disk2=FILE Load FILE into disk drive 2\n\ --disk2=FILE Load FILE into disk drive 2\n\
--flash Flash CPU memory with contents of drive 1\n\
--help Print this help message\n\ --help Print this help message\n\
--size=WIDTHxHEIGHT Use WIDTH and HEIGHT for window size\n\ --size=WIDTHxHEIGHT Use WIDTH and HEIGHT for window size\n\
(only 700x480 and 875x600 are supported)\n"); (only 700x480 and 875x600 are supported)\n");
} }
/*
* Return true if the given option flag is set.
*/
bool
option_flag(int flag)
{
return flags & flag;
}

View File

@ -75,16 +75,3 @@ Test(option, parse)
cr_assert_eq(option_parse(argc, argv), 0); cr_assert_eq(option_parse(argc, argv), 0);
} }
Test(option, flag)
{
int argc = 2;
char *argv[] = {
"prog_name",
"--flash",
};
cr_assert_eq(option_flag(OPTION_FLASH), false);
cr_assert_eq(option_parse(argc, argv), 1);
cr_assert_eq(option_flag(OPTION_FLASH), true);
}