void input_menu(void) { NOPH_List_t input_menu_list; NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get()); NOPH_Displayable_t cur = NOPH_Display_getCurrent(display); NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance(); mm_args_t args; int i; const char *list[] = { "F1", "F3", "F5", "F7", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z" }; input_menu_list = NOPH_List_new("Choose option", NOPH_Choice_IMPLICIT); NOPH_Display_setCurrent(display, input_menu_list); for (i = 0; i < sizeof(list) / sizeof(const char *); i++) NOPH_List_append(input_menu_list, list[i], 0); /* Setup the callback args */ args.selected = 0; args.menu_list = input_menu_list; NOPH_CommandMgr_setList(cm, input_menu_list, input_menu_callback, &args); while(args.selected == 0) { NOPH_Thread_sleep(250); } NOPH_Display_setCurrent(display, cur); NOPH_delete(input_menu_list); }
int roadmap_tile_load (int fips, int tile_index, void **base, size_t *size) { if (tile_index == -1) return load_index(fips, base, size); if (!TS) { if (TS_fail) return -1; TS = NOPH_TileStorage_new(); if (NOPH_TileStorage_initialize(TS) != 0) { NOPH_delete(TS); TS = 0; TS_fail = 1; return -1; } } int store_id = NOPH_TileStorage_findTile(TS, fips, tile_index, (int *)size); if (store_id == -1) return -1; *base = malloc (*size); int res = NOPH_TileStorage_loadTile(TS, fips, tile_index, store_id, *base); if (res == -1) { free (*base); return -1; } return 0; }
char *cibyl_select_game(char *base_dir) { NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get()); NOPH_Displayable_t cur = NOPH_Display_getCurrent(display); NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance(); char **p; all_games = read_directory(get_current_directory()); if (!all_games) return NULL; game_list = NOPH_List_new("Select game", NOPH_Choice_IMPLICIT); for (p = all_games; *p; p++) { NOPH_List_append(game_list, *p, 0); } NOPH_Display_setCurrent(display, game_list); printf("Setting list\n"); NOPH_CommandMgr_setList(cm, game_list, select_game_callback, NULL); while(selected_game == NULL) { NOPH_Thread_sleep(250); } free(all_games); NOPH_Display_setCurrent(display, cur); NOPH_delete(game_list); game_list = 0; return get_game_directory(selected_game); }
void roadmap_main_remove_periodic (RoadMapCallback callback) { int index; for (index = 0; index < ROADMAP_MAX_TIMER; ++index) { if (RoadMapMainPeriodicTimer[index].callback == callback) { int task = RoadMapMainPeriodicTimer[index].task; RoadMapMainPeriodicTimer[index].callback = NULL; RoadMapMainPeriodicTimer[index].task = -1; RoadMapMainPeriodicTimer[index].uid = 0; NOPH_TimerTask_cancel(task); NOPH_delete(task); return; } if (RoadMapSecondTimers[index].callback == callback){ RoadMapSecondTimers[index].callback = NULL; RoadMapSecondTimers[index].how_many_seconds_left = -1; RoadMapSecondTimers[index].interval_in_seconds = -1; return; } } roadmap_log (ROADMAP_ERROR, "timer 0x%08x not found", callback); }
static void dummy_handler(NOPH_Exception_t exception, void *arg) { if (arg) { RoadMapImage i = (RoadMapImage) arg; roadmap_log(ROADMAP_ERROR, "Error drawing image: %s\n", i->file_name); } NOPH_delete(exception); }
const char *cibyl_select_fs_root(void) { NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get()); NOPH_Displayable_t cur = NOPH_Display_getCurrent(display); NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance(); NOPH_Enumeration_t en = NOPH_FileSystemRegistry_listRoots(); FILE *conf; int i = 0; fs_root = NULL; fs_list = NOPH_List_new("Select fs root", NOPH_Choice_IMPLICIT); while (NOPH_Enumeration_hasMoreElements(en)) { NOPH_Object_t o = NOPH_Enumeration_nextElement(en); NOPH_String_toCharPtr(o, roots[i], 40); NOPH_List_append(fs_list, roots[i], 0); NOPH_delete(o); i++; } NOPH_delete(en); NOPH_Display_setCurrent(display, fs_list); NOPH_CommandMgr_setList(cm, fs_list, select_fs_callback, NULL); while(fs_root == NULL) { NOPH_Thread_sleep(250); } #if 0 conf = fopen("recordstore://sarien-conf:1", "w"); if (conf) { char buf[40]; strncpy(buf, fs_root, 40); fwrite(buf, 1, 40, conf); fclose(conf); } #endif NOPH_Display_setCurrent(display, cur); NOPH_delete(fs_list); return fs_root; }
void exit_handler(NOPH_Exception_t exception, void *arg){ char msg[512]; NOPH_String_toCharPtr(NOPH_Throwable_toString(exception), msg, sizeof(msg)); roadmap_log(ROADMAP_ERROR,"Exception in main_exit!! Exception mesage :%s", msg); NOPH_Throwable_printStackTrace(exception); NOPH_delete(exception); exit(0); }
void exception_handler(NOPH_Exception_t exception, void *arg) { char msg[512]; NOPH_String_toCharPtr(NOPH_Throwable_toString(exception), msg, sizeof(msg)); roadmap_messagebox("Error", msg); NOPH_Throwable_printStackTrace(exception); NOPH_delete(exception); }
BOOL roadmap_internet_open_browser( const char* url){ #ifdef RIMAPI NOPH_FreemapMainScreen_t RimScreen = NOPH_FreemapMainScreen_get(); NOPH_FreemapMainScreen_openBrowser(RimScreen,url); NOPH_delete(RimScreen); #else NOPH_MIDlet_platformRequest(NOPH_MIDlet_get(),url); #endif }
NOPH_try(exit_handler,NULL){ int index; roadmap_log(ROADMAP_ERROR, "INFO : in roadmap_main_exit!"); NOPH_FreemapMainScreen_revertToInitialLocale(RimScreen); roadmap_log(ROADMAP_DEBUG, "b4 roadmap_start_Exit...\n"); roadmap_start_exit (); roadmap_log(ROADMAP_DEBUG, "after roadmap_start_Exit...\n"); should_exit = 1; /* remove all timers */ #ifdef RIMAPI NOPH_RimTimerMgr_cancelTimer(); for (index = 0; index < ROADMAP_MAX_TIMER; ++index) { if (RoadMapMainPeriodicTimer[index].callback != NULL) { NOPH_TimerTask_cancel(RoadMapMainPeriodicTimer[index].task); RoadMapMainPeriodicTimer[index].callback = NULL; NOPH_delete(RoadMapMainPeriodicTimer[index].task); RoadMapMainPeriodicTimer[index].task = 0; } } #else for (index = 0; index < ROADMAP_MAX_TIMER; ++index) { if (RoadMapMainPeriodicTimer[index].callback != NULL) { RoadMapMainPeriodicTimer[index].callback = NULL; NOPH_TimerMgr_remove (timer_mgr, index); } } #endif roadmap_log_shutdown(); #ifdef RIMAPI exit(0); #endif }NOPH_catch();
void cibyl_main_menu(void) { NOPH_List_t main_menu_list; NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get()); NOPH_Displayable_t cur = NOPH_Display_getCurrent(display); NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance(); mm_args_t args; char buf[80]; main_menu_list = NOPH_List_new("Choose option", NOPH_Choice_IMPLICIT); snprintf(buf, 80, "Swap joysticks (now port %d)", ThePrefs.JoystickSwap ? 1 : 2); NOPH_List_append(main_menu_list, buf, 0); NOPH_List_append(main_menu_list, "Bind space to GAME_B", 0); NOPH_List_append(main_menu_list, "Bind RunStop to GAME_B", 0); NOPH_List_append(main_menu_list, "Bind Return to GAME_B", 0); NOPH_List_append(main_menu_list, "Bind other to GAME_B", 0); NOPH_List_append(main_menu_list, "Load from disk", 0); NOPH_List_append(main_menu_list, "Load from tape", 0); NOPH_Display_setCurrent(display, main_menu_list); /* Setup the callback args */ args.selected = 0; args.menu_list = main_menu_list; NOPH_CommandMgr_setList(cm, main_menu_list, main_menu_callback, &args); while(args.selected == 0) { NOPH_Thread_sleep(250); } if (args.selected == 2) input_menu(); NOPH_Display_setCurrent(display, cur); NOPH_delete(main_menu_list); }