void sim_coil_init (void) { int devno; int sol; /* Initialize everything to zero first */ for (sol = 0; sol < PINIO_NUM_SOLS; sol++) { char item_name[32]; struct sim_coil_state *c = coil_states + sol; memset (c, 0, sizeof (struct sim_coil_state)); if (MACHINE_SOL_FLASHERP (sol)) c->type = &flasher_type_coil; else c->type = &generic_type_coil; c->master = c; snprintf (item_name, sizeof (item_name), "coil.%d.disabled", sol); conf_add (item_name, &c->disabled); } /* Note coils which are attached to ball devices */ for (devno = 0; devno < NUM_DEVICES; devno++) { const device_properties_t *props = &device_properties_table[devno]; device_coil_init (props->sol, &device_nodes[devno]); } /* Initialize Fliptronic coils */ #if (MACHINE_FLIPTRONIC == 1) fliptronic_coil_init (SOL_LL_FLIP_POWER); fliptronic_coil_init (SOL_LR_FLIP_POWER); #ifdef SOL_UL_FLIP_POWER fliptronic_coil_init (SOL_UL_FLIP_POWER); #endif #ifdef SOL_UR_FLIP_POWER fliptronic_coil_init (SOL_UR_FLIP_POWER); #endif #endif /* Initialize machine specific coils */ #ifdef CONFIG_MACHINE_SIM mach_coil_init (); #endif }
int conf_loadfile() { FILE* conf; char buf[512], *action, param[128]; int line = 0, success; if (!(conf = fopen(set_get_string("config_file"), "r"))) { log(LOG_ERROR, "Unable to open config file \"%s\" for reading", set_get_string("config_file")); return -1; } while (fgets(buf, sizeof(buf), conf) > 0 && ++line) { if (!*buf || *buf=='#') continue; action = strtok(buf, " \t\r\n"); if (action != NULL) { if (strcasecmp(action, "set") == 0) { sprintf(param, "%s", strtok(NULL, " =\r\n")); success = conf_set(param, strtok(NULL, "\r\n")); } else if (strcasecmp(action, "add") == 0) { sprintf(param, "%s", strtok(NULL, " \r\n")); success = conf_add(param, strtok(NULL, "\r\n")); } else if (strcasecmp(action, "echo") == 0) { success = conf_echo(strtok(NULL, "\r\n"), NULL); } else if (strcasecmp(action, "load") == 0) { sprintf(param, "%s", strtok(NULL, " =\r\n")); success = conf_load(param, strtok(NULL, "\r\n")); } else { log(LOG_ERROR, "configuration file: Unknown command \"%s\"", action); success = -1; } if (success == -1) { log(LOG_WARNING, "Loading of configuration file failed " "(error in %s, line %i)", set_get_string("config_file"), line); fclose(conf); return -1; } } } fclose(conf); return 0; }
/** * Initialize the WPC I/O. Map WPC I/O addresses to functions that will * simulate them. */ void io_wpc_init (void) { /* TODO: Continue breaking this up into multiple adds below */ io_add (MIN_IO_ADDR, MAX_IO_ADDR, wpc_read, wpc_write, NULL); /* Install miscellaneous I/O handlers */ io_add_rw (WPC_ZEROCROSS_IRQ_CLEAR, wpc_misc_read, wpc_misc_write, NULL); /* Install switch handlers */ io_add_direct_switches (WPC_SW_CABINET_INPUT, SW_LEFT_COIN); /* Install lamp handlers */ io_add_lamp_matrix (WPC_LAMP_COL_STROBE, WPC_LAMP_ROW_OUTPUT, 0); /* Install solenoid I/O handlers */ io_add_sol_bank (WPC_SOL_HIGHPOWER_OUTPUT, SOL_BASE_HIGH); io_add_sol_bank (WPC_SOL_LOWPOWER_OUTPUT, SOL_BASE_LOW); io_add_sol_bank (WPC_SOL_FLASHER_OUTPUT, SOL_BASE_GENERAL); io_add_sol_bank (WPC_SOL_GEN_OUTPUT, SOL_BASE_AUXILIARY); #if (MACHINE_WPC95 == 1) io_add_sol_bank (WPC95_FLIPPER_COIL_OUTPUT, 32); #endif #if (MACHINE_FLIPTRONIC == 1) io_add_sol_bank (WPC_FLIPTRONIC_PORT_A, 32); #endif #ifdef MACHINE_SOL_EXTBOARD1 io_add_sol_bank (WPC_EXTBOARD1, SOL_BASE_EXTENDED); #endif /* Install dot matrix register handlers */ #if (MACHINE_DMD == 1) io_add_dmd_visible_reg (WPC_DMD_ACTIVE_PAGE); io_add_dmd_mapping_reg (WPC_DMD_LOW_PAGE, 0); io_add_dmd_mapping_reg (WPC_DMD_HIGH_PAGE, 1); #if (MACHINE_WPC95 == 1) io_add_dmd_mapping_reg (WPC95_DMD_3000_PAGE, 2); io_add_dmd_mapping_reg (WPC95_DMD_3200_PAGE, 3); io_add_dmd_mapping_reg (WPC95_DMD_3400_PAGE, 4); io_add_dmd_mapping_reg (WPC95_DMD_3600_PAGE, 5); #endif /* WPC_DMD_FIRQ_ROW_VALUE is not handled in simulation */ #endif /* Install parallel/serial port handlers */ wpc_io_debug_init (&wpc_debug_port); io_add_wo (WPC_PARALLEL_DATA_PORT, wpc_write_debug, &wpc_debug_port); io_add_rw (WPC_DEBUG_DATA_PORT, wpc_read_debug, wpc_write_debug, &wpc_debug_port); io_add_rw (WPC_DEBUG_CONTROL_PORT, wpc_read_debug_status, io_null_writer, &wpc_debug_port); /* Install diagnostic LED handler */ io_add_wo (WPC_LEDS, wpc_write_led, NULL); /* Install jumper/DIP switch handler */ sim_jumpers = LC_USA_CANADA << 2; conf_add ("jumpers", &sim_jumpers); io_add_ro (WPC_SW_JUMPER_INPUT, io_conf_reader, &sim_jumpers); /* TODO - install hwtimer read/write */ /* Install sound board read/write */ io_add (WPCS_DATA, 2, sound_ext_read, sound_ext_write, NULL); /* Install clock handler. Since clock time comes from the native OS, it cannot be changed and so these are read-only registers */ io_add (WPC_CLK_HOURS_DAYS, 2, wpc_clock_reader, wpc_clock_writer, NULL); /* Install the internal timer handler */ io_add_ro (WPC_PERIPHERAL_TIMER_FIRQ_CLEAR, wpc_timer_reader, NULL); /* TODO : If a ribbon cable is disconnected, then that I/O will not work. */ }
int CONF_ReadFile(const char *file, conf_add_f *conf_add) { FILE *in; char *line; int linenum = 0; in = fopen(file, "r"); if (in == NULL) { perror(file); return(-1); } line = (char *) malloc(BUFSIZ); if (line == NULL) return ENOMEM; while (conf_get_line(line, in) != -1) { char orig[BUFSIZ]; linenum++; char *comment = strchr(line, '#'); if (comment != NULL) *comment = '\0'; if (strlen(line) == 0) continue; char *ptr = line + strlen(line) - 1; while (ptr != line && isspace(*ptr)) --ptr; ptr[isspace(*ptr) ? 0 : 1] = '\0'; if (strlen(line) == 0) continue; ptr = line; while (isspace(*ptr) && *++ptr) ; strncpy(orig, ptr, BUFSIZ); char *lval, *rval; if (conf_ParseLine(ptr, &lval, &rval) != 0) { fprintf(stderr, "Cannot parse %s line %d: '%s'\n", file, linenum, orig); return(-1); } int ret; if ((ret = conf_add((const char *) lval, (const char *) rval)) != 0) { fprintf(stderr, "Error in %s line %d (%s): '%s'\n", file, linenum, strerror(ret), orig); return(-1); } } int ret = 0; if (ferror(in)) { fprintf(stderr, "Error reading file %s (errno %d: %s)\n", file, errno, strerror(errno)); ret = -1; } errno = 0; if (fclose(in) != 0) { fprintf(stderr, "Error closing file %s: %s)\n", file, strerror(errno)); ret = -1; } free(line); return(ret); }