-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcrater.c
More file actions
52 lines (44 loc) · 1.41 KB
/
Copy pathcrater.c
File metadata and controls
52 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Copyright (C) 2014-2016 Ben Kurtovic <ben.kurtovic@gmail.com>
Released under the terms of the MIT License. See LICENSE for details. */
#include <stdlib.h>
#include <stdio.h>
#include "src/assembler.h"
#include "src/config.h"
#include "src/disassembler.h"
#include "src/emulator.h"
#include "src/logging.h"
#include "src/rom.h"
/*
Main function.
*/
int main(int argc, char *argv[])
{
Config *config;
int retval = EXIT_SUCCESS;
retval = config_create(&config, argc, argv);
if (retval != CONFIG_OK)
return retval == CONFIG_EXIT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
SET_LOG_LEVEL(config->debug)
if (DEBUG_LEVEL)
config_dump_args(config);
if (config->assemble) {
retval = assemble_file(config->src_path, config->dst_path);
retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
} else if (config->disassemble) {
retval = disassemble_file(config->src_path, config->dst_path);
retval = retval ? EXIT_SUCCESS : EXIT_FAILURE;
} else {
ROM rom;
const char* errmsg;
if ((errmsg = rom_open(&rom, config->rom_path))) {
ERROR("couldn't load ROM image '%s': %s", config->rom_path, errmsg)
retval = EXIT_FAILURE;
} else {
printf("crater: emulating: %s\n", rom.name);
emulate(&rom, config);
rom_close(&rom);
}
}
config_destroy(config);
return retval;
}