Skip to content

Commit e6b52e0

Browse files
committed
Add --joy CLI argument
Closes #15
1 parent 2cf85f8 commit e6b52e0

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/args.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const char* app_releases_address = "https://github.com/X65/emu/releases";
1111
#define FULL_NAME "X65 microcomputer emulator"
1212
const char full_name[] = FULL_NAME;
1313

14-
struct arguments arguments = { NULL, 0, 0, "-" };
14+
struct arguments arguments = {
15+
NULL, 0, 0, "-", false, false, NULL,
16+
};
1517
static char args_doc[] = "[ROM.xex]";
1618

1719
#ifdef USE_ARGP
@@ -21,6 +23,7 @@ static struct argp_option options[] = {
2123
{ "silent", 's', 0, OPTION_ALIAS },
2224
{ "output", 'o', "FILE", 0, "Output to FILE instead of standard output" },
2325
{ "labels", 'l', "LABELS_FILE", 0, "Load VICE compatible global labels file" },
26+
{ "joy", 'j', 0, 0, "Enable Joystick 0 emulation" },
2427
{ "dap", 'd', 0, 0, "Enable Debug Adapter Protocol over stdin/stdout" },
2528
{ "dap-port", 'p', "PORT", 0, "Enable Debug Adapter Protocol over TCP port" },
2629
{ 0 }
@@ -34,6 +37,7 @@ static error_t parse_opt(int key, char* arg, struct argp_state* argp_state) {
3437
case 's': args->silent = 1; break;
3538
case 'v': args->verbose = 1; break;
3639
case 'o': args->output_file = arg; break;
40+
case 'j': args->joy = 1; break;
3741
case 'd': args->dap = 1; break;
3842
case 'p': args->dap_port = arg; break;
3943

src/args.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extern struct arguments {
1313
const char* rom;
1414
int silent, verbose;
1515
const char* output_file;
16+
bool joy;
1617
bool dap;
1718
const char* dap_port;
1819
} arguments;

src/x65.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void app_init(void) {
148148
saudio_setup(&(saudio_desc){
149149
.logger.func = slog_func,
150150
});
151-
x65_joystick_type_t joy_type = X65_JOYSTICKTYPE_NONE;
151+
x65_joystick_type_t joy_type = arguments.joy ? X65_JOYSTICKTYPE_DIGITAL_1 : X65_JOYSTICKTYPE_NONE;
152152
if (sargs_exists("joystick")) {
153153
if (sargs_equals("joystick", "digital_1")) {
154154
joy_type = X65_JOYSTICKTYPE_DIGITAL_1;
@@ -281,10 +281,11 @@ void app_init(void) {
281281
}
282282
if (sargs_exists("break")) {
283283
int opcode;
284-
if (sscanf(sargs_value("break"),"%x",&opcode) == 1) {
285-
ui_dbg_control_opcode_break(&state.ui.dbg,true,opcode);
286-
} else {
287-
fprintf(stderr,"Bad breakpoint opcode %s\n",sargs_value("break"));
284+
if (sscanf(sargs_value("break"), "%x", &opcode) == 1) {
285+
ui_dbg_control_opcode_break(&state.ui.dbg, true, opcode);
286+
}
287+
else {
288+
fprintf(stderr, "Bad breakpoint opcode %s\n", sargs_value("break"));
288289
}
289290
}
290291
}

0 commit comments

Comments
 (0)