static void setoutstr(const OEMCHAR *str) { #if defined(OSLANG_UCS2) oemtext_oemtosjis(np2sysp.outstr, sizeof(np2sysp.outstr), str, -1); #else milstr_ncpy(np2sysp.outstr, str, sizeof(np2sysp.outstr)); #endif np2sysp.outpos = 0; }
void create_about_dialog(void) { char work[256]; GtkWidget *about_dialog; GtkWidget *main_widget; GtkWidget *ver_label; GtkWidget *ok_button; GtkWidget *neko_image; GdkPixbuf *neko_pixbuf; uninstall_idle_process(); about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(about_dialog), "About Neko Project II"); gtk_window_set_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(about_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(about_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 10); g_signal_connect(GTK_OBJECT(about_dialog), "destroy", G_CALLBACK(about_destroy), NULL); main_widget = gtk_hbox_new(FALSE, 3); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(about_dialog), main_widget); neko_pixbuf = gdk_pixbuf_new_from_xpm_data(np2_icon); neko_image = gtk_image_new_from_pixbuf(neko_pixbuf); g_object_unref(neko_pixbuf); gtk_widget_show(neko_image); gtk_box_pack_start(GTK_BOX(main_widget), neko_image, FALSE, FALSE, 10); milstr_ncpy(work, "Neko Project II\n", sizeof(work)); milstr_ncat(work, NP2VER_CORE, sizeof(work)); #if defined(NP2VER_X11) milstr_ncat(work, NP2VER_X11, sizeof(work)); #endif ver_label = gtk_label_new(work); gtk_widget_show(ver_label); gtk_box_pack_start(GTK_BOX(main_widget), ver_label, FALSE, FALSE, 10); ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_box_pack_end(GTK_BOX(main_widget), ok_button, FALSE, TRUE, 0); g_signal_connect_swapped(GTK_OBJECT(ok_button), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(about_dialog)); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(ok_button, TRUE); gtk_widget_has_default(ok_button); #else GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT); #endif gtk_widget_grab_default(ok_button); gtk_widget_show_all(about_dialog); }
void initload(void) { OEMCHAR path[MAX_PATH]; icon.loadIcon(xmil_icon); //for dialog milstr_ncpy(path, file_getcd(inifile), NELEMENTS(path)); profile_iniread(path, ini_title, iniitem, NELEMENTS(iniitem), NULL); }
static void info_gdc2(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { OEMCHAR textstr[32]; OEMSPRINTF(textstr, str_dispclock, gdc.hclock / 1000, (gdc.hclock / 10) % 100, gdc.vclock / 10, gdc.vclock % 10); milstr_ncpy(str, textstr, maxlen); (void)ex; }
static void info_clock(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { UINT32 clock; OEMCHAR clockstr[16]; clock = (pccore.realclock + 50000) / 100000; OEMSPRINTF(clockstr, str_clockfmt, clock/10, clock % 10); milstr_ncpy(str, clockstr, maxlen); (void)ex; }
void SDL_WM_SetCaption(const char *title, const char *icon) { char caption[256]; milstr_ncpy(caption, "SDL", sizeof(caption)); if (title) { milstr_ncat(caption, " - ", sizeof(caption)); milstr_ncat(caption, title, sizeof(caption)); } SetWindowText(__sdl_hWnd, caption); }
static void SaveData_finalize(unsigned int id) { char path[16]; char long_desc[32] ; char short_desc[16]; unsigned char buf[MAX_VM_SIZE]; const char *save_title = "Select a VMU to save"; if (checked_vm < 0) return; sprintf(long_desc, "%s/Save File", ini_title); milstr_ncpy(short_desc, ini_title ,sizeof(short_desc)); loadSaveDatafromVmu(id); ZeroMemory(buf, sizeof(buf)); sprintf(path, "%x", id); int files = saveSaveData(id, buf); if (!files) return; int res = checked_vm; if (!res && !vmu_select(&res, save_title)) { checked_vm = -1; return; } for (;;) { display_message("Saving, do not power off or remove VMU!"); if (!save_to_vmu(res, path, long_desc, short_desc, buf, MAX_VM_SIZE, &icon)) { display_message("Failed!"); drawlcdstring(res, 0, 8, "FAILED!"); if (!vmu_select(&res, save_title)) { checked_vm = -1; return; } } else { display_message("Saved!"); drawlcdstring(res, 0, 8, "SAVED!"); checked_vm = res; return; } } }
static void info_cpu(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { UINT family; #if defined(CPU_FAMILY) family = min(CPU_FAMILY, 6); #else family = (CPU_TYPE & CPUTYPE_V30)?1:2; #endif milstr_ncpy(str, milstr_list(str_cpu, family), maxlen); (void)ex; }
void dialog_font(HWND hWnd) { TCHAR szPath[MAX_PATH]; file_cpyname(szPath, np2cfg.fontfile, NELEMENTS(szPath)); if ((dlgs_openfile(hWnd, &fpFont, szPath, NELEMENTS(szPath), NULL)) && (font_load(szPath, FALSE))) { gdcs.textdisp |= GDCSCRN_ALLDRAW2; milstr_ncpy(np2cfg.fontfile, szPath, NELEMENTS(np2cfg.fontfile)); sysmng_update(SYS_UPDATECFG); } }
static void iniwrsetarg8(char *work, int size, const BYTE *ptr, int arg) { int i; char tmp[8]; if (arg > 0) { SPRINTF(tmp, "%.2x", ptr[0]); milstr_ncpy(work, tmp, size); } for (i=1; i<arg; i++) { SPRINTF(tmp, " %.2x", ptr[i]); milstr_ncat(work, tmp, size); } }
void _handle_append(void *hdl, const OEMCHAR *name) { int i; if (hdl) { for (i=0; i<HDLTBLMAX; i++) { if (hdltbl[i].hdl == NULL) { hdltbl[i].hdl = hdl; milstr_ncpy(hdltbl[i].name, name, sizeof(hdltbl[0].name)); break; } } } }
static void binget(OEMCHAR *work, int size, const UINT8 *bin, UINT binlen) { UINT i; OEMCHAR tmp[8]; if (binlen) { OEMSPRINTF(tmp, OEMTEXT("%.2x"), bin[0]); milstr_ncpy(work, tmp, size); } for (i=1; i<binlen; i++) { OEMSPRINTF(tmp, OEMTEXT(" %.2x"), bin[i]); milstr_ncat(work, tmp, size); } }
static void info_text(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { const OEMCHAR *p; OEMCHAR textstr[64]; if (!(gdcs.textdisp & GDCSCRN_ENABLE)) { p = str_disable; } else { OEMSPRINTF(textstr, str_twidth, ((gdc.mode1 & 0x4)?40:80)); p = textstr; } milstr_ncpy(str, p, maxlen); (void)ex; }
/** * バイナリをシリアライズ * @param[out] lpString 文字列バッファ * @param[in] cchString 文字列バッファ長 * @param[in] lpBin バイナリ * @param[in] cbBin バイナリのサイズ */ static void binget(LPTSTR lpString, int cchString, const void* lpBin, UINT cbBin) { if (cbBin) { TCHAR tmp[8]; wsprintf(tmp, TEXT("%.2x"), (static_cast<const UINT8*>(lpBin))[0]); milstr_ncpy(lpString, tmp, cchString); } for (UINT i = 1; i < cbBin; i++) { TCHAR tmp[8]; wsprintf(tmp, TEXT(" %.2x"), (static_cast<const UINT8*>(lpBin))[i]); milstr_ncat(lpString, tmp, cchString); } }
static void readsuf(const char *path) { SYS_T *sys; SUF_T *suf; char subpath[MAX_PATH]; sys = &gamecore.sys; suf = &gamecore.suf; gamedef_loadsuf(path, suf, sys); if (archive_throwall(suf->scriptpath) != SUCCESS) { milstr_ncpy(subpath, suf->scriptpath, sizeof(subpath)); plusyen(subpath, sizeof(subpath)); milstr_ncat(subpath, suf->key, sizeof(subpath)); archive_throwall(subpath); } }
static void menusys_settxt(MENUID id, void *arg) { MENUSYS *sys; MENUHDL itm; int depth; int pos; int focus; sys = &menusys; itm = itemsea(sys, id); if (itm == NULL) { goto msst_end; } if (arg) { milstr_ncpy(itm->string, (OEMCHAR *)arg, NELEMENTS(itm->string)); } else { itm->string[0] = '\0'; } // リドローが必要? (ToDo: 再オープンすべし) depth = 0; while(depth < sys->depth) { itm = sys->wnd[depth].menu; pos = 0; while(itm) { if (itm->id == id) { if (!(itm->flag & (MENU_DISABLE | MENU_SEPARATOR))) { focus = 0; if (sys->wnd[depth].focus == pos) { focus = 2 - sys->opened; } itemdraw(sys, depth, pos, focus); menubase_draw(draw, sys); goto msst_end; } } pos++; itm = itm->next; } depth++; } msst_end: return; }
static void info_mem2(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { UINT memsize; OEMCHAR memstr[16]; memsize = np2cfg.memsw[2] & 7; if (memsize < 6) { memsize = (memsize + 1) * 128; } else { memsize = 640; } memsize += pccore.extmem * 1024; OEMSPRINTF(memstr, str_memfmt, memsize); milstr_ncpy(str, memstr, maxlen); (void)ex; }
static void info_sound(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { UINT type; type = 0; switch(usesound) { case 0x01: type = 1; break; case 0x02: type = 2; break; case 0x04: type = 3; break; case 0x06: type = 4; break; case 0x08: type = 5; break; case 0x14: type = 6; break; case 0x20: type = 7; break; case 0x40: type = 8; break; case 0x80: type = 9; break; } milstr_ncpy(str, milstr_list(str_fmboard, type), maxlen); (void)ex; }
static void *mvsndplay(const char *movie, BYTE *ptr, UINT size) { ONMEMSTMARG arg; char path[MAX_PATH]; UINT i; BOOL play; play = FALSE; if (!gamecore.gamecfg.bgm) { goto mvsp_exit; } if ((ptr) && (size)) { arg.ptr = ptr; arg.size = size; soundmix_load(SOUNDTRK_SOUND, onmem_ssopen, &arg); play = TRUE; } if (!play) { for (i=0; i<(sizeof(extnames)/sizeof(char *)); i++) { milstr_ncpy(path, movie, sizeof(path)); cutExtName(path); milstr_ncat(path, extnames[i], sizeof(path)); if (!soundmix_load(SOUNDTRK_SOUND, mp3_ssopen, path)) { play = TRUE; break; } } } if (play) { soundmix_play(SOUNDTRK_SOUND, 0, 0); #ifdef WAIT_SOUND { UINT32 base = GETTICK(); while((GETTICK() - base) < WAIT_SOUND) { if (!taskmng_sleep(1)) { break; } } } #endif } mvsp_exit: return((void *)(long)play); }
static void iniwrsetstr(char *work, int size, const char *ptr) { int i; char c; if (ptr[0] == ' ') { goto iwss_extend; } i = strlen(ptr); if ((i) && (ptr[i-1] == ' ')) { goto iwss_extend; } while(i > 0) { i--; if (ptr[i] == '\"') { goto iwss_extend; } } milstr_ncpy(work, ptr, size); return; iwss_extend: if (size > 3) { size -= 3; *work++ = '\"'; while(size > 0) { size--; c = *ptr++; if (c == '\"') { if (size > 0) { size--; work[0] = c; work[1] = c; work += 2; } } else { *work++ = c; } } work[0] = '\"'; work[1] = '\0'; } }
void *_memalloc(int size, const char *name) { void *ret; int i; ret = malloc(size); if (ret) { for (i=0; i<MEMTBLMAX; i++) { if (memtbl[i].hdl == NULL) { memtbl[i].hdl = ret; memtbl[i].size = size; milstr_ncpy(memtbl[i].name, name, sizeof(memtbl[0].name)); break; } } } return(ret); }
static void iniwrsetargh8(char *work, int size, INITBL *ini) { char tmp[8]; const UINT8 *ptr; UINT arg; UINT i; ptr = (UINT8 *)(ini->value); arg = ini->arg; if (arg > 0) { g_snprintf(tmp, sizeof(tmp), "%.2x ", ptr[0]); milstr_ncpy(work, tmp, size); } for (i = 1; i < arg; i++) { g_snprintf(tmp, sizeof(tmp), "%.2x ", ptr[i]); milstr_ncat(work, tmp, size); } }
void newdisk_fdd(const OEMCHAR *fname, REG8 type, const OEMCHAR *label) { _D88HEAD d88head; FILEH fh; ZeroMemory(&d88head, sizeof(d88head)); STOREINTELDWORD(d88head.fd_size, sizeof(d88head)); #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) oemtext_oemtosjis((char *)d88head.fd_name, NELEMENTS(d88head.fd_name), label, (UINT)-1); #else milstr_ncpy((char *)d88head.fd_name, label, NELEMENTS(d88head.fd_name)); #endif d88head.fd_type = type; fh = file_create(fname); if (fh != FILEH_INVALID) { file_write(fh, &d88head, sizeof(d88head)); file_close(fh); } }
void toolkit_initialize(void) { int i; if (NELEMENTS(toolkit) > 0) { for (i = 0; i < NELEMENTS(toolkit); i++) { gui_toolkit_t* p = toolkit[i].toolkit; if (strcasecmp(p->get_toolkit(), np2oscfg.toolkit) == 0) break; } if (i < NELEMENTS(toolkit)) { toolkitp = toolkit[i].toolkit; return; } sysmng_update(SYS_UPDATEOSCFG); milstr_ncpy(np2oscfg.toolkit, "gtk", sizeof(np2oscfg.toolkit)); } toolkitp = >k_toolkit; }
void moviemng_play(const char *fname, SCRN_T *scrn) { DAMEDEC prm; char path[MAX_PATH]; char *p; int r; menubase_close(); inputmng_resetmouse(0); milstr_ncpy(path, gamecore.suf.scriptpath, sizeof(path)); milstr_ncat(path, fname, sizeof(path)); cutExtName(path); milstr_ncat(path, ".MVD", sizeof(path)); p = getFileName(path); while(*p) { if ((((p[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) { if (p[1] != '\0') { p++; } } else if (((p[0] - 0x41) & 0xdf) < 26) { p[0] &= 0xdf; } p++; } prm.movie = path; prm.decproc = DAMEDEC_NOR; prm.draw = mvdraw; prm.task = mvtask; prm.sndplay = mvsndplay; prm.sndstop = mvsndstop; movieplaying = TRUE; r = damedec_play(&prm); if (r < 0) { TRACEOUT(("damelib error: %d [%s]", r, path)); } movieplaying = 0; (void)scrn; }
BRESULT menusys_create(const MSYSITEM *item, void (*cmd)(MENUID id), UINT16 icon, const OEMCHAR *title) { MENUSYS *ret; LISTARRAY r; MENUHDL hdl; ret = &menusys; ZeroMemory(ret, sizeof(MENUSYS)); ret->icon = icon; if (cmd == NULL) { cmd = defcmd; } ret->cmd = cmd; if (title) { milstr_ncpy(ret->title, title, NELEMENTS(ret->title)); } r = listarray_new(sizeof(_MENUHDL), 32); if (r == NULL) { goto mscre_err; } ret->res = r; hdl = appends(ret, s_root); if (hdl == NULL) { goto mscre_err; } ret->root = hdl; if (item) { while(hdl->next) { hdl = hdl->next; } hdl->next = appends(ret, item); } return(SUCCESS); mscre_err: return(FAILURE); }
FLISTH file_list1st(const char *dir, FLINFO *fli) { FLISTH ret; ret = (FLISTH)_MALLOC(sizeof(_FLISTH), "FLISTH"); if (ret == NULL) { return FLISTH_INVALID; } milstr_ncpy(ret->path, dir, sizeof(ret->path)); file_setseparator(ret->path, sizeof(ret->path)); ret->hdl = opendir(ret->path); if (ret->hdl == NULL) { _MFREE(ret); return FLISTH_INVALID; } if (file_listnext(ret, fli) == SUCCESS) { return ret; } closedir(ret->hdl); _MFREE(ret); return FLISTH_INVALID; }
static void ok_button_clicked(GtkButton *b, gpointer d) { const gchar *bufp = gtk_entry_get_text(GTK_ENTRY(buffer_entry)); const gchar *base = gtk_entry_get_text(GTK_ENTRY(baseclock_entry)); const gchar *multp = gtk_entry_get_text(GTK_ENTRY(clockmult_entry)); #if defined(SUPPORT_RESUME) gint resume = GTK_TOGGLE_BUTTON(resume_checkbutton)->active; #endif #if defined(GCC_CPU_ARCH_IA32) gint disablemmx = GTK_TOGGLE_BUTTON(disablemmx_checkbutton)->active; #endif guint bufsize; guint mult; UINT renewal = 0; int i; if (strcmp(base, "1.9968MHz") == 0) { if (np2cfg.baseclock != PCBASECLOCK20) { np2cfg.baseclock = PCBASECLOCK20; renewal |= SYS_UPDATECFG|SYS_UPDATECLOCK; } } else { if (np2cfg.baseclock != PCBASECLOCK25) { np2cfg.baseclock = PCBASECLOCK25; renewal |= SYS_UPDATECFG|SYS_UPDATECLOCK; } } mult = milstr_solveINT(multp); switch (mult) { case 1: case 2: case 4: case 5: case 6: case 8: case 10: case 12: case 16: case 20: if (mult != np2cfg.multiple) { np2cfg.multiple = mult; renewal |= SYS_UPDATECFG|SYS_UPDATECLOCK; } break; } for (i = 0; i < NELEMENTS(architecture); i++) { if (strcmp(arch, architecture[i].arch) == 0) { milstr_ncpy(np2cfg.model, arch, sizeof(np2cfg.model)); renewal |= SYS_UPDATECFG; break; } } if (i == NELEMENTS(architecture)) { milstr_ncpy(np2cfg.model, "VX", sizeof(np2cfg.model)); renewal |= SYS_UPDATECFG; } switch (rate) { case 11025: case 22050: case 44100: if (rate != np2cfg.samplingrate) { np2cfg.samplingrate = rate; renewal |= SYS_UPDATECFG|SYS_UPDATERATE; soundrenewal = 1; } break; } bufsize = milstr_solveINT(bufp); if (bufsize < 20) bufsize = 20; else if (bufsize > 1000) bufsize = 1000; if (np2cfg.delayms != bufsize) { np2cfg.delayms = bufsize; renewal |= SYS_UPDATECFG|SYS_UPDATESBUF; soundrenewal = 1; } #if defined(GCC_CPU_ARCH_IA32) if (!(mmxflag & MMXFLAG_NOTSUPPORT)) { disablemmx = disablemmx ? MMXFLAG_DISABLE : 0; if (np2oscfg.disablemmx != disablemmx) { np2oscfg.disablemmx = disablemmx; mmxflag &= ~MMXFLAG_DISABLE; mmxflag |= disablemmx; renewal |= SYS_UPDATEOSCFG; } } #endif #if defined(SUPPORT_RESUME) if (np2oscfg.resume != resume) { np2oscfg.resume = resume; renewal |= SYS_UPDATEOSCFG; } #endif if (renewal) { sysmng_update(renewal); } gtk_widget_destroy((GtkWidget *)d); }
void create_configure_dialog(void) { GtkWidget *config_dialog; GtkWidget *main_widget; GtkWidget *cpu_hbox; GtkWidget *cpu_frame; GtkWidget *cpuframe_vbox; GtkWidget *cpuclock_hbox; GtkWidget *baseclock_combo; GtkWidget *rate_combo; GtkWidget *times_label; GtkWidget *realclock_label; GtkWidget *confirm_widget; GtkWidget *ok_button; GtkWidget *cancel_button; GtkWidget *arch_frame; GtkWidget *arch_hbox; GtkWidget *arch_radiobutton[NELEMENTS(architecture)]; GtkWidget *sound_frame; GtkWidget *soundframe_vbox; GtkWidget *soundrate_hbox; GtkWidget *rate_label; GtkWidget *rate_radiobutton[NELEMENTS(samplingrate)]; GtkWidget *soundbuffer_hbox; GtkWidget *buffer_label; GtkWidget *ms_label; gchar buf[8]; int i; uninstall_idle_process(); config_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(config_dialog), "Configure"); gtk_window_set_position(GTK_WINDOW(config_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(config_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(config_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(config_dialog), 5); g_signal_connect(GTK_OBJECT(config_dialog), "destroy", G_CALLBACK(dialog_destroy), NULL); main_widget = gtk_vbox_new(FALSE, 0); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(config_dialog), main_widget); /* CPU column */ cpu_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(cpu_hbox); gtk_box_pack_start(GTK_BOX(main_widget), cpu_hbox, TRUE, TRUE, 0); /* * CPU frame */ cpu_frame = gtk_frame_new("CPU"); gtk_widget_show(cpu_frame); gtk_box_pack_start(GTK_BOX(cpu_hbox), cpu_frame, TRUE, TRUE, 0); cpuframe_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(cpuframe_vbox), 5); gtk_widget_show(cpuframe_vbox); gtk_container_add(GTK_CONTAINER(cpu_frame), cpuframe_vbox); /* cpu clock */ cpuclock_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(cpuclock_hbox); gtk_box_pack_start(GTK_BOX(cpuframe_vbox),cpuclock_hbox, TRUE, TRUE, 2); baseclock_combo = gtk_combo_box_entry_new_text(); gtk_widget_show(baseclock_combo); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), baseclock_combo, TRUE, FALSE, 0); gtk_widget_set_size_request(baseclock_combo, 96, -1); for (i = 0; i < NELEMENTS(baseclock_str); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(baseclock_combo), baseclock_str[i]); } baseclock_entry = GTK_BIN(baseclock_combo)->child; gtk_widget_show(baseclock_entry); gtk_editable_set_editable(GTK_EDITABLE(baseclock_entry), FALSE); switch (np2cfg.baseclock) { default: np2cfg.baseclock = PCBASECLOCK25; sysmng_update(SYS_UPDATECFG|SYS_UPDATECLOCK); /*FALLTHROUGH*/ case PCBASECLOCK25: gtk_entry_set_text(GTK_ENTRY(baseclock_entry),baseclock_str[1]); break; case PCBASECLOCK20: gtk_entry_set_text(GTK_ENTRY(baseclock_entry),baseclock_str[0]); break; } times_label = gtk_label_new("x"); gtk_widget_show(times_label); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), times_label, TRUE, FALSE, 0); gtk_misc_set_padding(GTK_MISC(times_label), 5, 0); rate_combo = gtk_combo_box_entry_new_text(); gtk_widget_show(rate_combo); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), rate_combo, TRUE, FALSE, 0); gtk_widget_set_size_request(rate_combo, 48, -1); for (i = 0; i < NELEMENTS(clockmult_str); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(rate_combo), clockmult_str[i]); } clockmult_entry = GTK_BIN(rate_combo)->child; gtk_widget_show(clockmult_entry); gtk_editable_set_editable(GTK_EDITABLE(clockmult_entry), FALSE); switch (np2cfg.multiple) { case 1: case 2: case 4: case 5: case 6: case 8: case 10: case 12: case 16: case 20: g_snprintf(buf, sizeof(buf), "%d", np2cfg.multiple); gtk_entry_set_text(GTK_ENTRY(clockmult_entry), buf); break; default: gtk_entry_set_text(GTK_ENTRY(clockmult_entry), "4"); break; } /* calculated cpu clock */ realclock_label = gtk_label_new("MHz"); gtk_widget_show(realclock_label); gtk_box_pack_start(GTK_BOX(cpuframe_vbox), realclock_label, FALSE, FALSE, 2); gtk_misc_set_alignment(GTK_MISC(realclock_label), 1.0, 0.5); g_signal_connect(GTK_OBJECT(baseclock_entry), "changed", G_CALLBACK(clock_changed), (gpointer)realclock_label); g_signal_connect(GTK_OBJECT(clockmult_entry), "changed", G_CALLBACK(clock_changed), (gpointer)realclock_label); clock_changed(NULL, realclock_label); /* OK, Cancel button base widget */ confirm_widget = gtk_vbutton_box_new(); gtk_widget_show(confirm_widget); gtk_box_pack_start(GTK_BOX(cpu_hbox), confirm_widget, TRUE, TRUE, 0); gtk_button_box_set_layout(GTK_BUTTON_BOX(confirm_widget), GTK_BUTTONBOX_END); //gtk_button_box_set_spacing(GTK_BUTTON_BOX(confirm_widget), 0); /* * Architecture frame */ arch_frame = gtk_frame_new("Architecture"); gtk_widget_show(arch_frame); gtk_box_pack_start(GTK_BOX(main_widget), arch_frame, TRUE, TRUE, 0); /* architecture */ arch_hbox = gtk_hbox_new(TRUE, 0); gtk_widget_show(arch_hbox); gtk_container_add(GTK_CONTAINER(arch_frame), arch_hbox); for (i = 0; i < NELEMENTS(architecture); i++) { arch_radiobutton[i] = gtk_radio_button_new_with_label_from_widget(i > 0 ? GTK_RADIO_BUTTON(arch_radiobutton[i-1]) : NULL, architecture[i].label); gtk_widget_show(arch_radiobutton[i]); gtk_box_pack_start(GTK_BOX(arch_hbox), arch_radiobutton[i], FALSE, FALSE, 0); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_focus(arch_radiobutton[i], FALSE); #else GTK_WIDGET_UNSET_FLAGS(rate_radiobutton[i], GTK_CAN_FOCUS); #endif g_signal_connect(GTK_OBJECT(arch_radiobutton[i]), "clicked", G_CALLBACK(arch_radiobutton_clicked), (gpointer)architecture[i].arch); } for (i = 0; i < NELEMENTS(architecture); i++) { if (strcmp(np2cfg.model, architecture[i].arch) == 0) { break; } } if (i == NELEMENTS(architecture)) { i = 1; milstr_ncpy(np2cfg.model, "VX", sizeof(np2cfg.model)); sysmng_update(SYS_UPDATECFG); } g_signal_emit_by_name(GTK_OBJECT(arch_radiobutton[i]), "clicked"); /* * Sound frame */ sound_frame = gtk_frame_new("Sound"); gtk_widget_show(sound_frame); gtk_box_pack_start(GTK_BOX(main_widget), sound_frame, TRUE, TRUE, 0); soundframe_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(soundframe_vbox), 5); gtk_widget_show(soundframe_vbox); gtk_container_add(GTK_CONTAINER(sound_frame), soundframe_vbox); /* sampling rate */ soundrate_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(soundrate_hbox); gtk_box_pack_start(GTK_BOX(soundframe_vbox), soundrate_hbox, TRUE, TRUE, 2); rate_label = gtk_label_new("Sampling Rate"); gtk_widget_show(rate_label); gtk_box_pack_start(GTK_BOX(soundrate_hbox), rate_label, FALSE, TRUE, 3); gtk_widget_set_size_request(rate_label, 96, -1); for (i = 0; i < NELEMENTS(samplingrate); i++) { rate_radiobutton[i] = gtk_radio_button_new_with_label_from_widget((i > 0) ? GTK_RADIO_BUTTON(rate_radiobutton[i-1]) : NULL, samplingrate[i].label); gtk_widget_show(rate_radiobutton[i]); gtk_box_pack_start(GTK_BOX(soundrate_hbox), rate_radiobutton[i], FALSE, FALSE, 0); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_focus(rate_radiobutton[i], FALSE); #else GTK_WIDGET_UNSET_FLAGS(rate_radiobutton[i], GTK_CAN_FOCUS); #endif g_signal_connect(GTK_OBJECT(rate_radiobutton[i]), "clicked", G_CALLBACK(rate_radiobutton_clicked), GINT_TO_POINTER(samplingrate[i].rate)); } if (np2cfg.samplingrate == 11025) { i = 0; } else if (np2cfg.samplingrate == 22050) { i = 1; } else if (np2cfg.samplingrate == 44100) { i = 2; } else { i = 1; np2cfg.samplingrate = 22050; sysmng_update(SYS_UPDATECFG|SYS_UPDATERATE); } g_signal_emit_by_name(GTK_OBJECT(rate_radiobutton[i]), "clicked"); soundbuffer_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(soundbuffer_hbox); gtk_box_pack_start(GTK_BOX(soundframe_vbox), soundbuffer_hbox, TRUE, TRUE, 2); /* buffer size */ buffer_label = gtk_label_new("Buffer"); gtk_widget_show(buffer_label); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox), buffer_label, FALSE, FALSE, 0); gtk_widget_set_size_request(buffer_label, 96, -1); buffer_entry = gtk_entry_new(); gtk_widget_show(buffer_entry); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox), buffer_entry, FALSE, FALSE, 0); gtk_widget_set_size_request(buffer_entry, 48, -1); if (np2cfg.delayms >= 20 && np2cfg.delayms <= 1000) { g_snprintf(buf, sizeof(buf), "%d", np2cfg.delayms); gtk_entry_set_text(GTK_ENTRY(buffer_entry), buf); } else { gtk_entry_set_text(GTK_ENTRY(buffer_entry), "500"); np2cfg.delayms = 500; sysmng_update(SYS_UPDATECFG|SYS_UPDATESBUF); soundrenewal = 1; } ms_label = gtk_label_new(" ms"); gtk_widget_show(ms_label); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox),ms_label, FALSE, FALSE, 0); #if defined(SUPPORT_RESUME) /* resume */ resume_checkbutton = gtk_check_button_new_with_label("Resume"); gtk_widget_show(resume_checkbutton); gtk_box_pack_start(GTK_BOX(main_widget), resume_checkbutton, FALSE, FALSE, 1); if (np2oscfg.resume) { g_signal_emit_by_name(GTK_OBJECT(resume_checkbutton), "clicked"); } #endif #if defined(GCC_CPU_ARCH_IA32) /* Disable MMX */ disablemmx_checkbutton = gtk_check_button_new_with_label("Disable MMX"); gtk_widget_show(disablemmx_checkbutton); gtk_box_pack_start(GTK_BOX(main_widget), disablemmx_checkbutton, FALSE, FALSE, 1); if (mmxflag & MMXFLAG_NOTSUPPORT) { gtk_widget_set_sensitive(disablemmx_checkbutton, FALSE); } else if (mmxflag & MMXFLAG_DISABLE) { g_signal_emit_by_name(GTK_OBJECT(disablemmx_checkbutton), "clicked"); } #endif /* * OK, Cancel button */ ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_container_add(GTK_CONTAINER(confirm_widget), ok_button); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(ok_button, TRUE); gtk_widget_has_default(ok_button); #else GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT); #endif g_signal_connect(GTK_OBJECT(ok_button), "clicked", G_CALLBACK(ok_button_clicked), (gpointer)config_dialog); gtk_widget_grab_default(ok_button); cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_widget_show(cancel_button); gtk_container_add(GTK_CONTAINER(confirm_widget), cancel_button); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(cancel_button, TRUE); #else GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT); #endif g_signal_connect_swapped(GTK_OBJECT(cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(config_dialog)); gtk_widget_show_all(config_dialog); }
void vramdraw_savebmp(int num, const char *dir, const char *name, int pos, const char *credit0, const char *credit1) { int i; char path[MAX_PATH]; char work[32]; BMPDATA inf; VRAMHDL vram; UINT tmp; UINT bmpsize; BMPFILE bf; BMPINFO bi; BYTE *dat; FILEH fh; if ((num < 0) || (num >= GAMECORE_MAXVRAM) || (name == NULL)) { goto vdsb_err1; } if (dir == NULL) { dir = ""; } for (i=0; i<100; i++) { milstr_ncpy(path, dir, sizeof(path)); milstr_ncat(path, name, sizeof(path)); sprintf(work, "%02u.bmp", i); milstr_ncat(path, work, sizeof(path)); if (file_attr(path) == -1) { break; } taskmng_rol(); } if (i >= 100) { goto vdsb_err1; } vram = vram_copy(gamecore.vram[num]); if (vram == NULL) { goto vdsb_err1; } creditmix(vram, pos, credit1, 0x000000); creditmix(vram, pos, credit0, 0xffffff); inf.width = vram->width; inf.height = vram->height; inf.bpp = 24; bmpdata_setinfo(&bi, &inf, TRUE); bmpsize = bmpdata_getdatasize(&bi); ZeroMemory(&bf, sizeof(bf)); bf.bfType[0] = 'B'; bf.bfType[1] = 'M'; tmp = sizeof(BMPFILE) + sizeof(BMPINFO); STOREINTELDWORD(bf.bfOffBits, tmp); tmp += bmpsize; STOREINTELDWORD(bf.bfSize, tmp); dat = bmpdata_bmp24cnv(&bi, vram); if (dat == NULL) { goto vdsb_err2; } fh = file_create(path); if (fh == FILEH_INVALID) { goto vdsb_err3; } file_write(fh, &bf, sizeof(bf)); file_write(fh, &bi, sizeof(bi)); file_write(fh, dat, bmpsize); file_close(fh); vdsb_err3: _MFREE(dat); vdsb_err2: vram_destroy(vram); vdsb_err1: return; }