static void finalize_load(const char *fn) { char *name; /* Calculate the checksums of the game */ rom_adler = rom_adler32(cart_rom, cart_len); rom_crc = rom_crc32(cart_rom, cart_len); #ifdef DEBUG printf("Checksums: Adler-32: 0x%08" PRIX32 " CRC32: 0x%08" PRIX32 "\n", (uint32_t)rom_adler, (uint32_t)rom_crc); #endif /* Copy the rom and font into the memory space. */ memcpy(memory + 0x200, cart_rom, cart_len); memcpy(memory, font, 80); chip8_mem_clear_fb(NULL); name = strrchr(fn, '/'); if(name != NULL) { /* we have a filename, but the first char is /, so skip that */ gui_set_title(name + 1); } else { gui_set_title("CrabEmu"); } }
static void gs_button_4() { /* enter */ char chr; if (get_string_data.row == GS_MAX_ROWS) { /* Edit function row */ if (get_string_data.col == 0) /* back */ { get_string_data.ready = true; get_string_data.escape = true; } else if (get_string_data.col == 1) /* delete */ { gs_idx--; if (gs_idx < 0) gs_idx = 0; getstring[gs_idx] = 0; gui_set_title(getstring, 1); } else if (get_string_data.col == 2) /* accept */ { get_string_data.ready = true; get_string_data.escape = false; } } else { /* add current char */ chr = char_array[get_string_data.row][get_string_data.col]; getstring[gs_idx] = chr; gs_idx++; if (gs_idx > sizeof getstring) { gs_idx = sizeof getstring; } getstring[gs_idx] = 0; } #if BOARD == EVK1100 dip204_set_cursor_position(1,1); /* col,line */ dip204_write_string(getstring); dip204_set_cursor_position(get_string_data.col + 1 - get_string_data.colstart, get_string_data.row + 2 - get_string_data.rowstart); /* col,line */ #else gui_set_title(getstring, 1); #endif mod = true; }
void open_uri(AppData *appdata, const char *uri) { char *dirname; char *cover; /* close old stream */ if (appdata->stream) decoder_close_stream(appdata->decoder); /* open new stream */ appdata->stream = stream_new_from_uri(uri); if (! decoder_open_stream(appdata->decoder, appdata->stream)) { appdata->stream = NULL; gui_show_error(appdata->gui, "Could not open file"); } else { decoder_play(appdata->decoder); } /* look for cover art */ dirname = g_path_get_dirname(uri); cover = lookup_cover(dirname); gui_load_cover(appdata->gui, cover); g_free(dirname); g_free(cover); /* set song label */ gui_set_title(appdata->gui, appdata->decoder->tag_title, appdata->decoder->tag_artist, appdata->decoder->tag_album); }
void gui_mode(int argc, char *argv[]) { osso_context_t *osso_context; char *versionstring; AppData *appdata = g_new(AppData, 1); appdata->runmode = GUI; gtk_init(&argc, &argv); /* register OSSO service */ osso_context = osso_initialize(NAME, VERSION, TRUE, NULL); if (! osso_context) fprintf(stderr, "Could not initialize OSSO."); appdata->playlist = playlist_new(); appdata->decoder = decoder_new(); appdata->stream = NULL; appdata->gui = gui_new(appdata->playlist); versionstring = g_strconcat(FULLNAME, " ", VERSION, NULL); gui_set_title(appdata->gui, "", versionstring, ""); g_free(versionstring); /* setup callbacks */ playlist_set_play_cb(appdata->playlist, play_cb, (void *) appdata); /* setup GUI callbacks */ gui_set_open_cb(appdata->gui, open_cb, (void *) appdata); gui_set_volume_cb(appdata->gui, volume_cb, (void *) appdata); gui_set_seek_cb(appdata->gui, seek_cb, (void *) appdata); gui_set_control_cb(appdata->gui, control_cb, (void *) appdata); g_timeout_add(500, (GSourceFunc) status_cb, appdata); gui_run(); }
void gui_getstring(getstring_cb cb, void *ctx) { static enum { IDLE, INIT, POLLING, FINISH } state = IDLE; static getstring_cb saved_cb; static void *cb_ctx; switch (state) { case IDLE: if (cb) { saved_cb = cb; cb_ctx = ctx; state = INIT; } else { return; } // Fallthrough case INIT: { gui_save_buttons(); #if BOARD == EVK1100 dip204_clear_display(); redisplay = true; #endif gui_set_title("Enter preshared key", 0); gui_set_title(getstring, 1); gui_set_button(0, "Left", sizeof "Left",gs_button_0); gui_set_button(1, "Right", sizeof "Right", gs_button_1); gui_set_button(2, "Up", sizeof "Up", gs_button_2); gui_set_button(3, "Down", sizeof "Down", gs_button_3); gui_set_button(4, "Enter", sizeof "Enter", gs_button_4); get_string_data.col = 0; get_string_data.row = 0; get_string_data.colstart = 0; get_string_data.rowstart = 0; get_string_data.ready = false; get_string_data.escape = false; gui_getstring_onoff(true); state = POLLING; break; } case POLLING: if (get_string_data.ready) { state = FINISH; } break; case FINISH: gui_getstring_onoff(false); gui_restore_buttons(); if (get_string_data.escape) saved_cb(NULL, 0, cb_ctx); else saved_cb(getstring, strlen(getstring), cb_ctx); saved_cb = NULL; cb_ctx = NULL; state = IDLE; break; } return; }