int c64exp_cmdline_options_init(void) { unsigned int dnr, i; for (dnr = 0; dnr < DRIVE_NUM; dnr++) { cmd_drive[0].name = lib_msprintf("-parallel%i", dnr + 8); cmd_drive[0].resource_name = lib_msprintf("Drive%iParallelCable", dnr + 8); cmd_drive[1].name = lib_msprintf("-drive%iprofdos", dnr + 8); cmd_drive[1].resource_name = lib_msprintf("Drive%iProfDOS", dnr + 8); cmd_drive[2].name = lib_msprintf("+drive%iprofdos", dnr + 8); cmd_drive[2].resource_name = lib_msprintf("Drive%iProfDOS", dnr + 8); cmd_drive[3].name = lib_msprintf("-drive%isupercard", dnr + 8); cmd_drive[3].resource_name = lib_msprintf("Drive%iSuperCard", dnr + 8); cmd_drive[4].name = lib_msprintf("+drive%isupercard", dnr + 8); cmd_drive[4].resource_name = lib_msprintf("Drive%iSuperCard", dnr + 8); if (cmdline_register_options(cmd_drive) < 0) { return -1; } for (i = 0; i < 5; i++) { lib_free((char *)cmd_drive[i].name); lib_free((char *)cmd_drive[i].resource_name); } } return cmdline_register_options(cmdline_options); }
char *cmdline_options_string(void) { unsigned int i; char *cmdline_string, *new_cmdline_string; char *add_to_options1, *add_to_options2, *add_to_options3; cmdline_string = lib_stralloc("\n"); for (i = 0; i < num_options; i++) { add_to_options1 = lib_msprintf("%s", options[i].name); add_to_options3 = lib_msprintf("\n\t%s\n", cmdline_options_get_description(i)); if (options[i].need_arg && cmdline_options_get_param(i) != NULL) { if (options[i].need_arg == -1) { add_to_options2 = lib_msprintf(" <%s>", cmdline_options_get_param(i)); } else { add_to_options2 = lib_msprintf(" %s", cmdline_options_get_param(i)); } new_cmdline_string = util_concat(cmdline_string, add_to_options1, add_to_options2, add_to_options3, NULL); lib_free(add_to_options2); } else { new_cmdline_string = util_concat(cmdline_string, add_to_options1, add_to_options3, NULL); } lib_free(add_to_options1); lib_free(add_to_options3); lib_free(cmdline_string); cmdline_string = new_cmdline_string; } return cmdline_string; }
int c64exp_resources_init(void) { unsigned int dnr; drive_t *drive; for (dnr = 0; dnr < DRIVE_NUM; dnr++) { drive = drive_context[dnr]->drive; res_drive[0].name = lib_msprintf("Drive%iParallelCable", dnr + 8); res_drive[0].value_ptr = &(drive->parallel_cable); res_drive[0].param = uint_to_void_ptr(dnr); res_drive[1].name = lib_msprintf("Drive%iProfDOS", dnr + 8); res_drive[1].value_ptr = &(drive->profdos); res_drive[1].param = uint_to_void_ptr(dnr); res_drive[2].name = lib_msprintf("Drive%iSuperCard", dnr + 8); res_drive[2].value_ptr = &(drive->supercard); res_drive[2].param = uint_to_void_ptr(dnr); if (resources_register_int(res_drive) < 0) { return -1; } lib_free((char *)(res_drive[0].name)); lib_free((char *)(res_drive[1].name)); lib_free((char *)(res_drive[2].name)); } return resources_register_string(resources_string); }
int drive_resources_init(void) { unsigned int dnr; drive_t *drive; for (dnr = 0; dnr < DRIVE_NUM; dnr++) { drive = drive_context[dnr]->drive; res_drive[0].name = lib_msprintf("Drive%iExtendImagePolicy", dnr + 8); res_drive[0].value_ptr = (int *)&(drive->extend_image_policy); res_drive[0].param = uint_to_void_ptr(dnr); res_drive[1].name = lib_msprintf("Drive%iIdleMethod", dnr + 8); res_drive[1].value_ptr = &(drive->idling_method); res_drive[1].param = uint_to_void_ptr(dnr); if (resources_register_int(res_drive) < 0) { return -1; } lib_free((char *)(res_drive[0].name)); lib_free((char *)(res_drive[1].name)); } return machine_drive_resources_init() | resources_register_int(resources_int); }
char *mon_disassemble_with_label(MEMSPACE memspace, WORD loc, int hex, unsigned *opc_size_p, unsigned *label_p) { const char *p; if (*label_p == 0) { /* process a label, if available */ p = mon_symbol_table_lookup_name(memspace, loc); if (p) { *label_p = 1; *opc_size_p = 0; return lib_msprintf("%s:",p); } } else { *label_p = 0; } /* process the disassembly itself */ p = mon_disassemble_to_string_ex(memspace, loc, mon_get_mem_val(memspace, loc), mon_get_mem_val(memspace, (WORD)(loc + 1)), mon_get_mem_val(memspace, (WORD)(loc + 2)), mon_get_mem_val(memspace, (WORD)(loc + 3)), hex, opc_size_p); return lib_msprintf((hex ? "%04X: %s%10s" : "05u: %s%10s"), loc, p, ""); }
void ui_cmdline_show_help(unsigned int num_options, cmdline_option_ram_t *opt, void *arg) { int chars; // maximum area could be shown char format[13]; unsigned int i; HWND hwnd; // // calculate maximum width of text // size_t jmax = 0; for (i = 0; i < num_options; i++) { size_t j = strlen(opt[i].name) + 1; j += strlen((opt[i].need_arg && cmdline_options_get_param(i) != NULL) ? cmdline_options_get_param(i) : "") + 1; jmax = j > jmax ? j : jmax; j += strlen(cmdline_options_get_description(i)) + 1; chars = j > chars ? j : chars; } sprintf(format, "%%-%ds%%s", jmax); // // open dialog // hwnd = cmdopt_dialog((HWND)arg); if (!hwnd) { return; } // // fill dialog with text // for (i = 0; i < num_options; i++) { char *textopt = lib_msprintf("%s %s", opt[i].name, (opt[i].need_arg && cmdline_options_get_param(i) != NULL) ? cmdline_options_get_param(i) : ""); char *text = lib_msprintf(format, textopt, cmdline_options_get_description(i)); lib_free(textopt); WinSendMsg(hwnd, WM_INSERT, text, (void*)TRUE); lib_free(text); } // // MAINLOOP // WinProcessDlg(hwnd); // // WinProcessDlg() does NOT destroy the window on return! Do it here, // otherwise the window procedure won't ever get a WM_DESTROY, // which we may want :-) // WinDestroyWindow(hwnd); }
void ui_set_drive_menu(int drive, ui_menu_entry_t *flipmenu) { char *leftmenuname; int i; Widget w; int num_app_shells = get_num_shells(); if (drive < 0 || drive >= NUM_DRIVES) { return; } leftmenuname = lib_msprintf("leftDrive%iMenu", drive + 8); if (flipmenu != NULL) { w = ui_menu_create(leftmenuname, flipmenu, NULL); left_drive_menu[drive] = w; } if (!drive_menu_translations[drive]) { char *translation_table; char number[16]; char *rightmenuname; sprintf(number, "%d", drive); rightmenuname = lib_msprintf("rightDrive%iMenu", drive + 8); translation_table = util_concat( "<Btn1Down>: " "XawPositionSimpleMenu(", leftmenuname, ") " "XtMenuPopup(", leftmenuname, ")\n", "Meta Shift <KeyDown>z: " "FakeButton(1) " "XawPositionSimpleMenu(", leftmenuname, ") " "XtMenuPopup(", leftmenuname, ")\n", "<Btn3Down>: " "RebuildDiskMenu(", number, ",", rightmenuname, ") " "XawPositionSimpleMenu(", rightmenuname, ") " "XtMenuPopup(", rightmenuname, ")\n", "Meta Shift <KeyDown>x: " "RebuildDiskMenu(", number, ",", rightmenuname, ") " "FakeButton(3) " "XawPositionSimpleMenu(", rightmenuname, ") " "XtMenuPopup(", rightmenuname, ")\n", NULL); drive_menu_translations[drive] = XtParseTranslationTable(translation_table); lib_free(translation_table); lib_free(rightmenuname); } for (i = 0; i < num_app_shells; i++) { XtOverrideTranslations(app_shells[i]. drive_widgets[drive].track_label, drive_menu_translations[drive]); } lib_free(leftmenuname); }
void drivecpu_setup_context(struct drive_context_s *drv, int i) { monitor_interface_t *mi; drivecpu_context_t *cpu; if (i) { drv->cpu = lib_calloc(1, sizeof(drivecpu_context_t)); } cpu = drv->cpu; if (i) { drv->cpud = lib_calloc(1, sizeof(drivecpud_context_t)); drv->func = lib_malloc(sizeof(drivefunc_context_t)); cpu->int_status = interrupt_cpu_status_new(); interrupt_cpu_status_init(cpu->int_status, &(cpu->last_opcode_info)); } drivecpu_int_status_ptr[drv->mynumber] = cpu->int_status; cpu->rmw_flag = 0; cpu->d_bank_limit = 0; cpu->d_bank_start = 0; cpu->pageone = NULL; if (i) { cpu->snap_module_name = lib_msprintf("DRIVECPU%d", drv->mynumber); cpu->identification_string = lib_msprintf("DRIVE#%d", drv->mynumber + 8); cpu->monitor_interface = monitor_interface_new(); } mi = cpu->monitor_interface; mi->context = (void *)drv; mi->cpu_regs = &(cpu->cpu_regs); mi->cpu_R65C02_regs = NULL; mi->cpu_65816_regs = NULL; mi->dtv_cpu_regs = NULL; mi->z80_cpu_regs = NULL; mi->h6809_cpu_regs = NULL; mi->int_status = cpu->int_status; mi->clk = &(drive_clk[drv->mynumber]); mi->current_bank = 0; mi->mem_bank_list = NULL; mi->mem_bank_from_name = NULL; mi->get_line_cycle = NULL; mi->mem_bank_read = drivemem_bank_read; mi->mem_bank_peek = drivemem_bank_peek; mi->mem_bank_write = drivemem_bank_store; mi->mem_ioreg_list_get = drivemem_ioreg_list_get; mi->toggle_watchpoints_func = drivemem_toggle_watchpoints; mi->set_bank_base = drivecpu_set_bank_base; cpu->monspace = monitor_diskspace_mem(drv->mynumber); if (i) { drv->cpu->clk_guard = clk_guard_new(drv->clk_ptr, CLOCK_MAX - CLKGUARD_SUB_MIN); drv->cpu->alarm_context = alarm_context_new(drv->cpu->identification_string); } }
void via1d2031_setup_context(drive_context_t *ctxptr) { drivevia1_context_t *via1p; via_context_t *via; /* Clear struct as snapshot code may write uninitialized values. */ ctxptr->via1d2031 = lib_calloc(1, sizeof(via_context_t)); via = ctxptr->via1d2031; via->prv = lib_malloc(sizeof(drivevia1_context_t)); via1p = (drivevia1_context_t *)(via->prv); via1p->number = ctxptr->mynumber; via->context = (void *)ctxptr; via->rmw_flag = &(ctxptr->cpu->rmw_flag); via->clk_ptr = ctxptr->clk_ptr; via->myname = lib_msprintf("2031Drive%dVia1", ctxptr->mynumber); via->my_module_name = lib_msprintf("2031VIA1D%d", ctxptr->mynumber); viacore_setup_context(via); via->my_module_name_alt1 = lib_msprintf("VIA1D%d", ctxptr->mynumber); via->irq_line = IK_IRQ; via1p->drive = ctxptr->drive; via1p->v_parieee_is_out = 1; if (via1p->number == 0) { via1p->parallel_id = PARALLEL_DRV0; } else { via1p->parallel_id = PARALLEL_DRV1; } via->undump_pra = undump_pra; via->undump_prb = undump_prb; via->undump_pcr = undump_pcr; via->undump_acr = undump_acr; via->store_pra = store_pra; via->store_prb = store_prb; via->store_pcr = store_pcr; via->store_acr = store_acr; via->store_sr = store_sr; via->store_t2l = store_t2l; via->read_pra = read_pra; via->read_prb = read_prb; via->set_int = set_int; via->restore_int = restore_int; via->set_ca2 = set_ca2; via->set_cb2 = set_cb2; via->reset = reset; }
int drive_resources_init(void) { unsigned int dnr; drive_t *drive; int has_iec; switch (machine_class) { case VICE_MACHINE_NONE: case VICE_MACHINE_PET: case VICE_MACHINE_CBM5x0: case VICE_MACHINE_CBM6x0: case VICE_MACHINE_VSID: has_iec = 0; break; default: has_iec = 1; } for (dnr = 0; dnr < DRIVE_NUM; dnr++) { drive = drive_context[dnr]->drive; res_drive[0].name = lib_msprintf("Drive%iExtendImagePolicy", dnr + 8); res_drive[0].value_ptr = (int *)&(drive->extend_image_policy); res_drive[0].param = uint_to_void_ptr(dnr); res_drive[1].name = lib_msprintf("Drive%iIdleMethod", dnr + 8); res_drive[1].value_ptr = &(drive->idling_method); res_drive[1].param = uint_to_void_ptr(dnr); if (has_iec) { res_drive_rtc[0].name = lib_msprintf("Drive%iRTCSave", dnr + 8); res_drive_rtc[0].value_ptr = &(drive->rtc_save); res_drive_rtc[0].param = uint_to_void_ptr(dnr); if (resources_register_int(res_drive_rtc) < 0) { return -1; } } if (resources_register_int(res_drive) < 0) { return -1; } lib_free((char *)(res_drive[0].name)); lib_free((char *)(res_drive[1].name)); if (has_iec) { lib_free((char *)(res_drive_rtc[0].name)); } } return machine_drive_resources_init() | resources_register_int(resources_int); }
static int log_helper(log_t log, unsigned int level, const char *format, va_list ap) { static const char *level_strings[3] = { "", "Warning - ", "Error - " }; const signed int logi = (signed int)log; int rc = 0; char *logtxt = NULL; if (!log_enabled) { return 0; } if ((logi != LOG_DEFAULT) && (logi != LOG_ERR)) { if ((logs == NULL) || (logi < 0)|| (logi >= num_logs) || (logs[logi] == NULL)) { #ifdef DEBUG log_archdep("log_helper: internal error (invalid id or closed log), messages follows:\n", format, ap); #endif return -1; } } if ((logi != LOG_DEFAULT) && (logi != LOG_ERR) && (*logs[logi] != '\0')) { logtxt = lib_msprintf("%s: %s", logs[logi], level_strings[level]); } else { logtxt = lib_msprintf("%s", level_strings[level]); } if (log_file == NULL) { rc = log_archdep(logtxt, format, ap); } else { #ifdef ARCHDEP_EXTRA_LOG_CALL log_archdep(logtxt, format, ap); #endif if (fputs(logtxt, log_file) == EOF || vfprintf(log_file, format, ap) < 0 || fputc ('\n', log_file) == EOF) { rc = -1; } } lib_free(logtxt); return rc; }
static void ResSetKeyVal(int num, USHORT id, int val) { char *res = lib_msprintf("KeySet%d%s", num ? 1 : 2, GetDirection(id)); resources_set_int(res, val); lib_free (res); }
static void debug_open_new_file(void) { char *filename, *st; const char *directory; if (debug_file != NULL) { fclose(debug_file); } resources_get_string("EventSnapshotDir", &directory); st = lib_msprintf("debug%06d", debug_file_current); filename = util_concat(directory, st, FSDEV_EXT_SEP_STR, "log", NULL); lib_free(st); debug_file = fopen(filename, MODE_READ_TEXT); if (debug_file != NULL) { debug_buffer_size = fread(debug_buffer, sizeof(char), DEBUG_HISTORY_MAXFILESIZE, debug_file); debug_buffer_ptr = 0; debug_file_current++; } else { debug_buffer_size = 0; } debug_file_line = 0; lib_free(filename); }
static void uiattach_autostart_dialog(HWND hwnd) { TCHAR *st_name; int autostart_index = 0; char *resource; resource = lib_msprintf("AttachDevice%dReadonly", 8); if ((st_name = uilib_select_file_autostart(hwnd, translate_text(IDS_AUTOSTART_IMAGE), UILIB_FILTER_CBM | UILIB_FILTER_DISK | UILIB_FILTER_TAPE | #ifdef HAVE_ZLIB UILIB_FILTER_ZIP | #endif UILIB_FILTER_PRGP00 | UILIB_FILTER_ALL, UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DISK_AND_TAPE, &autostart_index, resource)) != NULL) { char *name; name = system_wcstombs_alloc(st_name); if (autostart_autodetect(name, NULL, autostart_index, AUTOSTART_MODE_RUN) < 0) { ui_error(translate_text(IDS_CANNOT_AUTOSTART_FILE)); } system_wcstombs_free(name); lib_free(st_name); } lib_free(resource); }
int drive_resources_type_init(unsigned int default_type) { unsigned int dnr, type; drive_t *drive; for (dnr = 0; dnr < DRIVE_NUM; dnr++) { drive = drive_context[dnr]->drive; if (dnr == 0) { type = default_type; } else { type = DRIVE_TYPE_NONE; } res_drive_type[0].name = lib_msprintf("Drive%iType", dnr + 8); res_drive_type[0].factory_value = (int)type; res_drive_type[0].value_ptr = (int *)&(drive->type); res_drive_type[0].param = uint_to_void_ptr(dnr); if (resources_register_int(res_drive_type) < 0) { return -1; } lib_free((char *)(res_drive_type[0].name)); } return 0; }
void riot1_setup_context(drive_context_t *ctxptr) { riot_context_t *riot; ctxptr->riot1 = lib_malloc(sizeof(riot_context_t)); riot = ctxptr->riot1; riot->prv = NULL; riot->context = (void *)ctxptr; riot->rmw_flag = &(ctxptr->cpu->rmw_flag); riot->clk_ptr = ctxptr->clk_ptr; riotcore_setup_context(riot); riot->myname = lib_msprintf("RIOT1D%d", ctxptr->mynumber); riot->undump_pra = undump_pra; riot->undump_prb = undump_prb; riot->store_pra = store_pra; riot->store_prb = store_prb; riot->read_pra = read_pra; riot->read_prb = read_prb; riot->reset = reset; riot->set_irq = set_irq; riot->restore_irq = restore_irq; }
void tpi_setup_context(machine_context_t *machine_context) { tpi_context_t *tpi_context; machine_context->tpi1 = lib_malloc(sizeof(tpi_context_t)); tpi_context = machine_context->tpi1; tpi_context->prv = NULL; tpi_context->context = (void *)machine_context; tpi_context->rmw_flag = &maincpu_rmw_flag; tpi_context->clk_ptr = &maincpu_clk; tpi_context->myname = lib_msprintf("TPI"); tpicore_setup_context(tpi_context); tpi_context->store_pa = store_pa; tpi_context->store_pb = store_pb; tpi_context->store_pc = store_pc; tpi_context->read_pa = read_pa; tpi_context->read_pb = read_pb; tpi_context->read_pc = read_pc; tpi_context->undump_pa = undump_pa; tpi_context->undump_pb = undump_pb; tpi_context->undump_pc = undump_pc; tpi_context->reset = reset; tpi_context->set_ca = set_ca; tpi_context->set_cb = set_cb; tpi_context->set_int = set_int; tpi_context->restore_int = restore_int; }
void vidmode_menu_create(struct ui_menu_entry_s *menu) { unsigned int i, amodes; ui_menu_entry_t *resolutions_submenu; amodes = vidmode_available_modes(); resolutions_submenu = lib_calloc((size_t)(amodes + 1), sizeof(ui_menu_entry_t)); for (i = 0; i < amodes ; i++) { resolutions_submenu[i].string = (ui_callback_data_t)lib_msprintf("%s", vm_bestmodes[i].name); resolutions_submenu[i].type = UI_MENU_TYPE_TICK; resolutions_submenu[i].callback = (ui_callback_t)mode_callback; resolutions_submenu[i].callback_data = (ui_callback_data_t)(unsigned long)i; } for (i = 0; menu[i].string; i++) { if (strncmp(menu[i].string, "VidMode", 7) == 0) { if (amodes > 0) { menu[i].sub_menu = resolutions_submenu; } break; } } }
/* FIXME: hack, because 0x4000 is only ok for 1001/8050/8250. fdc.c:fdc_do_job() adds an offset for 2040/3040/4040 by itself :-( Why donlly get a table for that...! */ void fdc_init(drive_context_t *drv) { unsigned int fnum = drv->mynumber; BYTE *buffermem = drv->cpud->drive_ram + 0x100; BYTE *ipromp = &(drv->drive->rom[0x4000]); char *buffer; fdc[fnum].buffer = buffermem; fdc[fnum].iprom = ipromp; if (fdc_log == LOG_ERR) fdc_log = log_open("fdc"); #ifdef FDC_DEBUG log_message(fdc_log, "fdc_init(drive %d)", fnum); #endif buffer = lib_msprintf("fdc%i", drv->mynumber); fdc[fnum].fdc_alarm = alarm_new(drv->cpu->alarm_context, buffer, int_fdc, drv); lib_free(buffer); clk_guard_add_callback(drv->cpu->clk_guard, clk_overflow_callback, uint_to_void_ptr(drv->mynumber)); }
int fdc_snapshot_write_module(snapshot_t *p, int fnum) { snapshot_module_t *m; char *name; if (fdc[fnum].fdc_state == FDC_UNUSED) { return 0; } name = lib_msprintf("FDC%i", fnum); m = snapshot_module_create(p, name, FDC_DUMP_VER_MAJOR, FDC_DUMP_VER_MINOR); lib_free(name); if (m == NULL) return -1; SMW_B(m, (BYTE)(fdc[fnum].fdc_state)); /* clk till next invocation */ SMW_DW(m, (DWORD)(fdc[fnum].alarm_clk - drive_clk[fnum])); /* number of drives - so far 1 only */ SMW_B(m, 1); /* last accessed track/sector */ SMW_B(m, ((BYTE)(fdc[fnum].last_track))); SMW_B(m, ((BYTE)(fdc[fnum].last_sector))); snapshot_module_close(m); return 0; }
static void debug_int(interrupt_cpu_status_t *cs, const char *name, unsigned int type, CLOCK iclk) { unsigned int i; char *textout, *texttmp; textout = lib_stralloc(name); for (i = 0; i < cs->num_ints; i++) { if (cs->pending_int[i] & type) { texttmp = util_concat(textout, " ", cs->int_name[i], NULL); lib_free(textout); textout = texttmp; } } texttmp = lib_msprintf("%s %ld", textout, iclk); lib_free(textout); textout = texttmp; if (debug.trace_mode == DEBUG_HISTORY || debug.trace_mode == DEBUG_AUTOPLAY) { debug_history_step(textout); } else { log_debug("%s", textout); } lib_free(textout); }
/* Show the speed index to the user. */ void ui_display_speed(float percent, float framerate, int warp_flag) { int i; int percent_int = (int)(percent + 0.5); int framerate_int = (int)(framerate + 0.5); char *str = NULL; int num_app_shells = get_num_shells(); if (percent) { str = lib_msprintf("%d%%, %dfps %s", percent_int, framerate_int, warp_flag ? _("(warp)") : ""); } for (i = 0; i < num_app_shells; i++) { if (!percent) { XtVaSetValues(app_shells[i].speed_label, XtNlabel, warp_flag ? _("(warp)") : "", NULL); } else { XtVaSetValues(app_shells[i].speed_label, XtNlabel, str, NULL); } } lib_free(str); if (statustext_display_time > 0) { statustext_display_time--; if (statustext_display_time == 0) { statusbar_setstatustext(""); } } if (!screenshot_is_recording()) { #if !DEBUG_LAYOUT XtUnmanageChild(rec_button); #endif /* DEBUG_LAYOUT */ } }
int fdc_snapshot_read_module(snapshot_t *p, int fnum) { BYTE vmajor, vminor; BYTE byte, ndrv; DWORD dword; snapshot_module_t *m; char *name; name = lib_msprintf("FDC%d", fnum); m = snapshot_module_open(p, name, &vmajor, &vminor); lib_free(name); if (m == NULL) { log_message(fdc_log, "Could not find snapshot module %s", name); return -1; } if (vmajor != FDC_DUMP_VER_MAJOR) { log_error(fdc_log, "Snapshot module version (%d.%d) newer than %d.%d.", vmajor, vminor, FDC_DUMP_VER_MAJOR, FDC_DUMP_VER_MINOR); snapshot_module_close(m); return -1; } SMR_B(m, &byte); if (byte > FDC_LAST_STATE) { snapshot_module_close(m); return -1; } fdc[fnum].fdc_state = byte; /* clk till next invocation */ SMR_DW(m, &dword); fdc[fnum].alarm_clk = drive_clk[fnum] + dword; alarm_set(fdc[fnum].fdc_alarm, fdc[fnum].alarm_clk); /* number of drives - so far 1 only */ SMR_B(m, &ndrv); /* last accessed track/sector */ SMR_B(m, &byte); fdc[fnum].last_track = byte; SMR_B(m, &byte); fdc[fnum].last_sector = byte; if (ndrv > 1) { /* ignore drv 0 values */ SMR_B(m, &byte); SMR_B(m, &byte); } if (snapshot_module_close(m) < 0) return -1; return 0; }
static char* append_char_to_input_buffer(char *old_input_buffer, char new_char) { char* new_input_buffer = lib_msprintf("%s%c", old_input_buffer ? old_input_buffer : "", new_char); lib_free(old_input_buffer); return new_input_buffer; }
static void sdl_poll_print_timeout(int x, int y, int time) { char *timestr = NULL; timestr = lib_msprintf("Timeout in %i...", time); sdl_ui_print(timestr, x, y); sdl_ui_refresh(); lib_free(timestr); }
static int log_helper(log_t log, unsigned int level, const char *format, va_list ap) { static const char *level_strings[3] = { "", "Warning - ", "Error - " }; const signed int logi = (signed int)log; int rc = 0; char *logtxt = NULL; if (!log_enabled) { return 0; } if ((logi != LOG_DEFAULT) && (logi != LOG_ERR) && (logs == NULL || logs[logi] == NULL)) { return -1; } if ((logi != LOG_DEFAULT) && (logi != LOG_ERR) && (*logs[logi] != '\0')) { logtxt = lib_msprintf("%s: %s", logs[logi], level_strings[level]); } else { logtxt = lib_msprintf("%s", level_strings[level]); } if (log_file == NULL) { rc = log_archdep(logtxt, format, ap); } else { #ifdef WIN32 log_archdep(logtxt, format, ap); #endif /* #ifdef WIN32 */ if (fputs(logtxt, log_file) == EOF || vfprintf(log_file, format, ap) < 0 || fputc ('\n', log_file) == EOF) rc = -1; } lib_free(logtxt); return rc; }
char *image_contents_to_string(image_contents_t * contents, char convert_to_ascii) { char *string = lib_msprintf("0 \"%s\" %s", contents->name, contents->id); if (convert_to_ascii) { charset_petconvstring((unsigned char *)string, 1); } return string; }
char *mon_dump_with_label(MEMSPACE memspace, WORD loc, int hex, unsigned *label_p) { const char *p; BYTE val; if (*label_p == 0) { /* process a label, if available */ p = mon_symbol_table_lookup_name(memspace, loc); if (p) { *label_p = 1; return lib_msprintf("%s:",p); } } else { *label_p = 0; } val = mon_get_mem_val(memspace, loc); return lib_msprintf((hex ? "%04X: $%02X %03u '%c'" : "%05u: $%02X %03u '%c'"), loc, val, val, isprint(val)?val:' '); }
static int ResGetKeyVal(int num, USHORT id) { int val; char *res = lib_msprintf("KeySet%d%s", num ? 1 : 2, GetDirection(id)); resources_get_int(res, &val); lib_free (res); return val; }
void iec_drive_idling_method(unsigned int dnr) { char *tmp; tmp = lib_msprintf("Drive%iIdleMethod", dnr + 8); resources_touch(tmp); lib_free(tmp); }