static int plus60k_activate(void) { plus60k_ram = (BYTE *)lib_realloc((void *)plus60k_ram, (size_t)0xf000); log_message(plus60k_log, "PLUS60K expansion installed."); if (!util_check_null_string(plus60k_filename)) { if (util_file_load(plus60k_filename, plus60k_ram, (size_t)0xf000, UTIL_FILE_LOAD_RAW) < 0) { log_message(plus60k_log, "Reading PLUS60K image %s failed.", plus60k_filename); if (util_file_save(plus60k_filename, plus60k_ram, 0xf000) < 0) { log_message(plus60k_log, "Creating PLUS60K image %s failed.", plus60k_filename); return -1; } log_message(plus60k_log, "Creating PLUS60K image %s.", plus60k_filename); return 0; } log_message(plus60k_log, "Reading PLUS60K image %s.", plus60k_filename); } plus60k_reset(); return 0; }
static int ramcart_deactivate(void) { if (ramcart_ram == NULL) return 0; if (!util_check_null_string(ramcart_filename)) { if (util_file_save(ramcart_filename, ramcart_ram, ramcart_size) < 0) { #ifdef CELL_DEBUG printf("INFO: Writing RAMCART image %s failed.\n", ramcart_filename); #endif return -1; } #ifdef CELL_DEBUG printf("INFO: Writing RAMCART image %s.\n", ramcart_filename); #endif } lib_free(ramcart_ram); ramcart_ram = NULL; old_ramcart_ram_size = 0; return 0; }
int cbm2rom_load_chargen(const char *rom_name) { int i; if (!rom_loaded) return 0; /* init not far enough */ /* Load chargen ROM * we load 4k of 16-byte-per-char Charrom. * Then we generate the inverted chars */ if (!util_check_null_string(rom_name)) { memset(mem_chargen_rom, 0, CBM2_CHARGEN_ROM_SIZE); if (sysfile_load(rom_name, mem_chargen_rom, 4096, 4096) < 0) { log_error(cbm2rom_log, "Couldn't load character ROM '%s'.", rom_name); return -1; } if (machine_class != VICE_MACHINE_CBM5x0) { memmove(mem_chargen_rom + 4096, mem_chargen_rom + 2048, 2048); /* Inverted chargen into second half. This is a hardware feature.*/ for (i = 0; i < 2048; i++) { mem_chargen_rom[i + 2048] = mem_chargen_rom[i] ^ 0xff; mem_chargen_rom[i + 6144] = mem_chargen_rom[i + 4096] ^ 0xff; } } } /* FIXME: VIC-II config */ return 0; }
void tui_display_window(int x, int y, int width, int height, int foreground_color, int background_color, const char *title, tui_area_t *backing_store) { int i; if (backing_store != NULL) { /* 2 more chars on right, 1 more on bottom because of the "shadow". */ tui_area_get(backing_store, x, y, width + 2, height + 1); } tui_make_shadow(x + 2, y + 1, width, height); tui_set_attr(foreground_color, background_color, 0); tui_put_char(x, y, 0xc9); tui_hline(x + 1, y, 0xcd, width - 2); tui_put_char(x + width - 1, y, 0xbb); tui_put_char(x, y + height - 1, 0xc8); tui_hline(x + 1, y + height - 1, 0xcd, width - 2); tui_put_char(x + width - 1, y + height - 1, 0xbc); for (i = 0; i < height - 2; i++) { tui_put_char(x, y + i + 1, 0xba); tui_hline(x + 1, y + i + 1, ' ', width - 2); tui_put_char(x + width - 1, y + i + 1, 0xba); } if (!util_check_null_string(title)) { int title_x, title_length; title_length = strlen(title); title_x = x + (width - title_length - 4) / 2; tui_display(title_x, y, 0, "\x10 %s \x11", title); } }
int supercard_load(const char *name) { DBG(("supercard_load <%s>\n", name)); if (util_check_null_string(name)) { return 0; } if (util_file_load(name, supercard_rom, SUPERCARD_ROM_SIZE, UTIL_FILE_LOAD_SKIP_ADDRESS) < 0) { return -1; } return 0; }
static int plus60k_deactivate(void) { if (!util_check_null_string(plus60k_filename)) { if (util_file_save(plus60k_filename, plus60k_ram, 0xf000) < 0) { log_message(plus60k_log, "Writing PLUS60K image %s failed.", plus60k_filename); return -1; } log_message(plus60k_log, "Writing PLUS60K image %s.", plus60k_filename); } lib_free(plus60k_ram); plus60k_ram = NULL; return 0; }
int cbm2rom_load_cart_6(const char *rom_name) { if (!rom_loaded) return 0; /* init not far enough */ if (!util_check_null_string(rom_name)) { if ((sysfile_load(rom_name, mem_rom + 0x6000, 0x2000, 0x2000) < 0)) { log_error(cbm2rom_log, "Couldn't load ROM `%s'.", rom_name); } } else { memset(mem_rom + 0x6000, 0xff, 0x2000); } return 0; }
static int plus256k_deactivate(void) { if (!util_check_null_string(plus256k_filename)) { if (util_file_save(plus256k_filename, plus256k_ram, 0x40000) < 0) { log_message(plus256k_log, "Writing PLUS256K image %s failed.", plus256k_filename); return -1; } log_message(plus256k_log, "Writing PLUS256K image %s.", plus256k_filename); } vicii_set_ram_base(mem_ram); lib_free(plus256k_ram); plus256k_ram = NULL; remove_cpu_lines_lock(); return 0; }
static int functionrom_load_external(void) { if (external_function_rom_enabled) { if (util_check_null_string(external_function_rom_name)) return 0; if (util_file_load(external_function_rom_name, ext_function_rom, EXTERNAL_FUNCTION_ROM_SIZE, UTIL_FILE_LOAD_SKIP_ADDRESS | UTIL_FILE_LOAD_FILL) < 0) return -1; } else { memset(ext_function_rom, 0, sizeof(ext_function_rom)); } return 0; }
static int plus60k_deactivate(void) { if (!util_check_null_string(plus60k_filename)) { if (util_file_save(plus60k_filename, plus60k_ram, 0xf000) < 0) { printf("INFO: Writing PLUS60K image %s failed.\n", plus60k_filename); return -1; } printf("INFO: Writing PLUS60K image %s.\n", plus60k_filename); } lib_free(plus60k_ram); plus60k_ram = NULL; remove_cpu_lines_lock(); return 0; }
int cbm2rom_load_basic(const char *rom_name) { if (!rom_loaded) return 0; /* init not far enough */ /* Load BASIC ROM. */ if (!util_check_null_string(rom_name)) { if ((sysfile_load(rom_name, mem_rom + 0x8000, 0x4000, 0x4000) < 0)) { log_error(cbm2rom_log, "Couldn't load BASIC ROM `%s'.", rom_name); return -1; } } else { log_warning(cbm2rom_log, "Disabling BASIC by unloading ROM!"); memset(mem_rom + 0x8000, 0xff, 0x4000); } return 0; }
static int ramcart_activate(void) { if (!ramcart_size) return 0; ramcart_ram = lib_realloc((void *)ramcart_ram, (size_t)ramcart_size); /* Clear newly allocated RAM. */ if (ramcart_size > old_ramcart_ram_size) memset(ramcart_ram, 0, (size_t)(ramcart_size - old_ramcart_ram_size)); old_ramcart_ram_size = ramcart_size; #ifdef CELL_DEBUG printf("INFO: %dKB unit installed.\n", ramcart_size >> 10); #endif if (!util_check_null_string(ramcart_filename)) { if (util_file_load(ramcart_filename, ramcart_ram, (size_t)ramcart_size, UTIL_FILE_LOAD_RAW) < 0) { #ifdef CELL_DEBUG printf("INFO: Reading RAMCART image %s failed.\n", ramcart_filename); #endif if (util_file_save(ramcart_filename, ramcart_ram, ramcart_size) < 0) { #ifdef CELL_DEBUG printf("INFO: Creating RAMCART image %s failed.\n", ramcart_filename); #endif return -1; } #ifdef CELL_DEBUG printf("INFO: Creating RAMCART image %s.\n", ramcart_filename); #endif return 0; } #ifdef CELL_DEBUG printf("INFO: Reading RAMCART image %s.\n", ramcart_filename); #endif } ramcart_reset(); return 0; }
static int expert_deactivate(void) { if (expert_ram == NULL) { return 0; } if (!util_check_null_string(expert_filename)) { if (expert_write_image) { log_message(LOG_DEFAULT, "Writing Expert Cartridge image %s.", expert_filename); if (expert_flush_image() < 0) { log_error(LOG_DEFAULT, "Writing Expert Cartridge image %s failed.", expert_filename); } } } lib_free(expert_ram); expert_ram = NULL; return 0; }
int cbm2rom_load_kernal(const char *rom_name) { if (!rom_loaded) return 0; /* init not far enough */ /* De-initialize kbd-buf, autostart and tape stuff here before reloading the ROM the traps are installed in. */ kbdbuf_init(0, 0, 0, 0); autostart_init(0, 0, 0, 0, 0, 0); tape_init(&tapeinit); /* Load Kernal ROM. */ if (!util_check_null_string(rom_name)) { if (sysfile_load(rom_name, mem_rom + 0xe000, 0x2000, 0x2000) < 0) { log_error(cbm2rom_log, "Couldn't load ROM `%s'.", rom_name); return -1; } } return cbm2rom_checksum(); }
static int petdww_deactivate(void) { if (petdww_ram == NULL) { return 0; } if (!util_check_null_string(petdww_filename)) { if (util_file_save(petdww_filename, petdww_ram, PET_DWW_RAM_SIZE) < 0) { log_message(petdww_log, "Writing PET DWW image %s failed.", petdww_filename); return -1; } log_message(petdww_log, "Writing PET DWW image %s.", petdww_filename); } pia_reset(); lib_free(petdww_ram); petdww_ram = NULL; return 0; }
static int ramcart_deactivate(void) { if (ramcart_ram == NULL) { return 0; } if (!util_check_null_string(ramcart_filename)) { if (ramcart_write_image) { log_message(LOG_DEFAULT, "Writing RAMCART image %s.", ramcart_filename); if (ramcart_flush_image() < 0) { log_error(LOG_DEFAULT, "Writing RAMCART image %s failed.", ramcart_filename); } } } lib_free(ramcart_ram); ramcart_ram = NULL; old_ramcart_ram_size = 0; return 0; }
static int petdww_activate(void) { if (petres.IOSize < 2048) { log_message(petdww_log, "Cannot enable DWW: IOSize too small (%d but must be 2K)", petres.IOSize); return -1; } if (petres.superpet) { log_message(petdww_log, "Cannot enable DWW: not compatible with SuperPET"); return -1; } petdww_ram = lib_realloc((void *)petdww_ram, (size_t)PET_DWW_RAM_SIZE); /* Clear newly allocated RAM. */ memset(petdww_ram, 0, (size_t)PET_DWW_RAM_SIZE); log_message(petdww_log, "%dKB of hi-res RAM installed.", PET_DWW_RAM_SIZE >> 10); if (!util_check_null_string(petdww_filename)) { if (util_file_load(petdww_filename, petdww_ram, (size_t)PET_DWW_RAM_SIZE, UTIL_FILE_LOAD_RAW) < 0) { log_message(petdww_log, "Reading PET DWW image %s failed.", petdww_filename); if (util_file_save(petdww_filename, petdww_ram, PET_DWW_RAM_SIZE) < 0) { log_message(petdww_log, "Creating PET DWW image %s failed.", petdww_filename); return -1; } log_message(petdww_log, "Creating PET DWW image %s.", petdww_filename); return 0; } log_message(petdww_log, "Reading PET DWW image %s.", petdww_filename); } petdww_reset(); return 0; }
static int plus256k_activate(void) { plus256k_ram = lib_realloc((void *)plus256k_ram, (size_t)0x40000); log_message(plus256k_log, "PLUS256K hack installed."); if (!util_check_null_string(plus256k_filename)) { if (util_file_load(plus256k_filename, plus256k_ram, (size_t)0x40000, UTIL_FILE_LOAD_RAW) < 0) { log_message(plus256k_log, "Reading PLUS256K image %s failed.", plus256k_filename); if (util_file_save(plus256k_filename, plus256k_ram, 0x40000) < 0) { log_message(plus256k_log, "Creating PLUS256K image %s failed.", plus256k_filename); return -1; } log_message(plus256k_log, "Creating PLUS256K image %s.", plus256k_filename); return 0; } log_message(plus256k_log, "Reading PLUS256K image %s.", plus256k_filename); } plus256k_reset(); set_cpu_lines_lock(CPU_LINES_PLUS256K, "PLUS256K"); return 0; }
static int expert_activate(void) { if (expert_ram == NULL) { expert_ram = lib_malloc(EXPERT_RAM_SIZE); } if (!util_check_null_string(expert_filename)) { log_message(LOG_DEFAULT, "Reading Expert Cartridge image %s.", expert_filename); if (expert_load_image() < 0) { log_error(LOG_DEFAULT, "Reading Expert Cartridge image %s failed.", expert_filename); /* only create a new file if no file exists, so we dont accidently overwrite any files */ expert_filetype = CARTRIDGE_FILETYPE_BIN; if (!util_file_exists(expert_filename)) { if (expert_flush_image() < 0) { log_error(LOG_DEFAULT, "Creating Expert Cartridge image %s failed.", expert_filename); return -1; } } } } return 0; }
static int plus60k_activate(void) { plus60k_ram = lib_realloc((void *)plus60k_ram, (size_t)0xf000); #ifdef CELL_DEBUG printf("INFO: PLUS60K expansion installed.\n"); #endif if (!util_check_null_string(plus60k_filename)) { if (util_file_load(plus60k_filename, plus60k_ram, (size_t)0xf000, UTIL_FILE_LOAD_RAW) < 0) { #ifdef CELL_DEBUG printf("INFO: Reading PLUS60K image %s failed.\n", plus60k_filename); #endif if (util_file_save(plus60k_filename, plus60k_ram, 0xf000) < 0) { #ifdef CELL_DEBUG printf("INFO: Creating PLUS60K image %s failed.\n", plus60k_filename); #endif return -1; } #ifdef CELL_DEBUG printf("INFO: Creating PLUS60K image %s.\n", plus60k_filename); #endif return 0; } #ifdef CELL_DEBUG printf("INFO: Reading PLUS60K image %s.\n", plus60k_filename); #endif } plus60k_reset(); set_cpu_lines_lock(CPU_LINES_PLUS60K, "PLUS60K"); return 0; }
static int ramcart_activate(void) { if (!ramcart_size) { return 0; } ramcart_ram = lib_realloc((void *)ramcart_ram, (size_t)ramcart_size); /* Clear newly allocated RAM. */ if (ramcart_size > old_ramcart_ram_size) { memset(ramcart_ram, 0, (size_t)(ramcart_size - old_ramcart_ram_size)); } old_ramcart_ram_size = ramcart_size; log_message(ramcart_log, "%dKB unit installed.", ramcart_size >> 10); if (!util_check_null_string(ramcart_filename)) { if (util_file_load(ramcart_filename, ramcart_ram, (size_t)ramcart_size, UTIL_FILE_LOAD_RAW) < 0) { log_error(ramcart_log, "Reading RAMCART image %s failed.", ramcart_filename); /* only create a new file if no file exists, so we dont accidently overwrite any files */ if (!util_file_exists(ramcart_filename)) { if (util_file_save(ramcart_filename, ramcart_ram, ramcart_size) < 0) { log_error(ramcart_log, "Creating RAMCART image %s failed.", ramcart_filename); return -1; } log_message(ramcart_log, "Creating RAMCART image %s.", ramcart_filename); return 0; } } log_message(ramcart_log, "Reading RAMCART image %s.", ramcart_filename); } ramcart_reset(); return 0; }
void mon_command_print_help(const char *cmd) { const mon_cmds_t *c; int column; int len; int longest; int max_col; char *parameters; char *braces; int param_amount; if (cmd == NULL) { longest = 0; for (c = mon_cmd_array; c->str != NULL; c++) { len = (int)strlen(c->str); if (!util_check_null_string(c->abbrev)) len += 3 + (int)strlen(c->abbrev); /* 3 => " ()" */ if (len > longest) longest = len; } longest += 2; /* some space */ max_col = 80 / longest - 1; column = 0; for (c = mon_cmd_array; c->str != NULL; c++) { int tot = (int)strlen(c->str); /* "Empty" command, that's a head line */ if (tot == 0) { if (column != 0) { mon_out("\n"); column = 0; } mon_out("\n%s\n", GET_DESCRIPTION(c)); continue; } mon_out("%s", c->str); if (!util_check_null_string(c->abbrev)) { mon_out(" (%s)", c->abbrev); tot += 3 + (int)strlen(c->abbrev); } if (column >= max_col) { mon_out("\n"); column = 0; } else { for (; tot < longest; tot++) mon_out(" "); column++; } if (mon_stop_output != 0) break; } mon_out("\n\n"); } else { int cmd_num; cmd_num = mon_command_lookup_index(cmd); if (cmd_num == -1) mon_out(translate_text(IDGS_COMMAND_S_UNKNOWN), cmd); else if (mon_cmd_array[cmd_num].description == NULL && mon_cmd_array[cmd_num].description_id == IDGS_UNUSED) mon_out(translate_text(IDGS_NO_HELP_AVAILABLE_FOR_S), cmd); else { const mon_cmds_t *c; c = &mon_cmd_array[cmd_num]; if (c->use_param_names_id == USE_PARAM_ID) { braces = c->braces; param_amount = c->param_amount; switch (param_amount) { default: case 1: parameters = lib_msprintf(braces, translate_text(c->param_ids[0])); break; case 2: parameters = lib_msprintf(braces, translate_text(c->param_ids[0]), translate_text(c->param_ids[1])); break; case 3: parameters = lib_msprintf(braces, translate_text(c->param_ids[0]), translate_text(c->param_ids[1]), translate_text(c->param_ids[2])); break; case 4: parameters = lib_msprintf(braces, translate_text(c->param_ids[0]), translate_text(c->param_ids[1]), translate_text(c->param_ids[2]), translate_text(c->param_ids[3])); break; } } else { if (c->param_names == NULL) { parameters = NULL; } else { parameters = lib_stralloc(_(c->param_names)); } } mon_out(translate_text(IDGS_SYNTAX_S_S), c->str, parameters != NULL ? parameters : ""); lib_free(parameters); if (!util_check_null_string(c->abbrev)) mon_out(translate_text(IDGS_ABBREVIATION_S), c->abbrev); mon_out("\n%s\n\n", GET_DESCRIPTION(c)); } } }