Example #1
0
static
CLUST get_cluster (		/* 0,>=2: successful, 1: failed */
	CLUST clust			/* Cluster# to get the link information */
)
{
   WORD wc, bc;
   DWORD fatsect;
  FATFS *fs = FatFs;


	if (clust >= 2 && clust < fs->max_clust) {		/* Valid cluster# */
		fatsect = fs->fatbase;
		switch (fs->fs_type) {
		case FS_FAT12 :
			bc = (WORD)clust * 3 / 2;
			if (!move_window(fatsect + bc / 512)) break;
			wc = fs->win[bc % 512]; bc++;
			if (!move_window(fatsect + bc / 512)) break;
			wc |= (WORD)fs->win[bc % 512] << 8;
			return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);

		case FS_FAT16 :
			if (!move_window(fatsect + clust / 256)) break;
			return LD_WORD(&fs->win[((WORD)clust * 2) % 512]);
#if _FAT32
		case FS_FAT32 :
			if (!move_window(fatsect + clust / 128)) break;
			return LD_DWORD(&fs->win[((WORD)clust * 4) % 512]) & 0x0FFFFFFF;
#endif
		}
	}
Example #2
0
File: ff.c Project: optixx/lm32
static
DWORD get_cluster (
	DWORD clust			/* Cluster# to get the link information */
)
{
	WORD wc, bc;
	DWORD fatsect;
	FATFS *fs = FatFs;


	if ((clust >= 2) && (clust < fs->max_clust)) {		/* Valid cluster# */
		fatsect = fs->fatbase;
		switch (fs->fs_type) {
		case FS_FAT12 :
			bc = (WORD)clust * 3 / 2;
			if (!move_window(fatsect + bc / 512)) break;
			wc = fs->win[bc % 512]; bc++;
			if (!move_window(fatsect + bc / 512)) break;
			wc |= (WORD)fs->win[bc % 512] << 8;
			return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);

		case FS_FAT16 :
			if (!move_window(fatsect + clust / 256)) break;
			return LD_WORD(&(fs->win[((WORD)clust * 2) % 512]));

		case FS_FAT32 :
			if (!move_window(fatsect + clust / 128)) break;
			return LD_DWORD(&(fs->win[((WORD)clust * 4) % 512]));
		}
	}
Example #3
0
static int ui_scale_misc_handler(window_info *win)
{
	int y_len = 0;
	analog_clock_size = (int)(0.5 + win->current_scale * 64);
	compass_size = (int)(0.5 + win->current_scale * 64);
	knowledge_bar_height = win->small_font_len_y + 6;
	side_stats_bar_height = win->small_font_len_y;
	digital_clock_height = win->default_font_len_y;
	ui_scale_timer(win);
	y_len = compass_size;
	if (view_hud_timer)
		y_len += get_height_of_timer();
	if (view_analog_clock)
		y_len += analog_clock_size;
	if (view_digital_clock)
		y_len += digital_clock_height;
	if (view_knowledge_bar)
		y_len += knowledge_bar_height;
	if (show_stats_in_hud && have_stats)
		y_len += num_disp_stat * side_stats_bar_height;
	resize_window(win->window_id, HUD_MARGIN_X, y_len);
	move_window(win->window_id, -1, 0, window_width-HUD_MARGIN_X, window_height-y_len);
	reset_cm_regions();
	return 1;
}
Example #4
0
static
FRESULT sync (void)		/* FR_OK: successful, FR_RW_ERROR: failed */
{
	FATFS *fs = FatFs;


	fs->winflag = 1;
	if (!move_window(0)) return FR_RW_ERROR;
#if _USE_FSINFO
	/* Update FSInfo sector if needed */
	if (fs->fs_type == FS_FAT32 && fs->fsi_flag) {
		fs->winsect = 0;
		memset(fs->win, 0, 512);
		ST_WORD(&fs->win[BS_55AA], 0xAA55);
		ST_DWORD(&fs->win[FSI_LeadSig], 0x41615252);
		ST_DWORD(&fs->win[FSI_StrucSig], 0x61417272);
		ST_DWORD(&fs->win[FSI_Free_Count], fs->free_clust);
		ST_DWORD(&fs->win[FSI_Nxt_Free], fs->last_clust);
		disk_write(0, fs->win, fs->fsi_sector, 1);
		fs->fsi_flag = 0;
	}
#endif
	/* Make sure that no pending write process in the physical drive */
	if (disk_ioctl(0, CTRL_SYNC, NULL) != RES_OK) return FR_RW_ERROR;
	return FR_OK;
}
int do_logical_MoveCloseBox(int xmv,int ymv, int idwindow)
{

if(window_focus_id==idwindow)
{
  if(mouse_y>ymv-15 && mouse_y<ymv+15 && mouse_y>hauteur_ChannelMenu)
  {
  if(mouse_x>xmv-15 && mouse_x<xmv+15)
  {
  if(mouse_button==1 && mouse_released==0 &&  im_moving_a_window==0 && original_posx==mouse_x && original_posy==mouse_y)
  {
  substract_a_window(idwindow);
  mouse_released=1;
  }
  }
  else if(((mouse_x>xmv+40-15 && mouse_x<xmv+40+15)|| im_moving_a_window==1)&& (original_posx==mouse_x && original_posy==mouse_y))
  {
  move_window(idwindow);
  }

  }
  }

 return(0);
}
Example #6
0
void window_key_move(char dumb, char *dumber)
{
    in_window_command = 1;
    message_from(NULL, LOG_CURRENT);
    move_window(curr_scr_win, 1);
    update_all_windows();
    in_window_command = 0;
    message_from(NULL, LOG_CRAP);
}
Example #7
0
static void
cmd_ctrl_wK(key_info_t key_info, keys_info_t *keys_info)
{
	if(is_right_or_bottom())
	{
		view_switch_views();
	}
	move_window(get_active_view(), 1, 1);
}
Example #8
0
static void
cmd_ctrl_wL(key_info_t key_info, keys_info_t *keys_info)
{
	if(is_top_or_left())
	{
		view_switch_views();
	}
	move_window(get_active_view(), 0, 0);
}
Example #9
0
void display_popup_win (INPUT_POPUP *ipu, const char* label)
{
	widget_list *wok;
	widget_list *wno;

	if(ipu->popup_win < 0)
	{
		Uint32 flags = ELW_WIN_DEFAULT & ~ELW_CLOSE_BOX;
		ipu->popup_win = create_window (win_prompt, ipu->parent, 0, ipu->x, ipu->y, ipu->popup_x_len, ipu->popup_y_len, flags);

		// clear the buffer
		init_text_message (&ipu->popup_text, ipu->maxlen);
		set_text_message_color (&ipu->popup_text, 0.77f, 0.57f, 0.39f);

		// Label
		ipu->popup_label = label_add (ipu->popup_win, NULL, label, 5, 5);
		widget_set_color (ipu->popup_win, ipu->popup_label, 0.77f, 0.57f, 0.39f);

		// Input
		ipu->popup_field = text_field_add_extended (ipu->popup_win, 101, NULL, 5, 28, ipu->popup_x_len - 10, 28*ipu->rows, ipu->text_flags, 1.0f, 0.77f, 0.57f, 0.39f, &ipu->popup_text, 1, FILTER_ALL, 5, 5);
		widget_set_color (ipu->popup_win, ipu->popup_field, 0.77f, 0.57f, 0.39f);

		// Accept
		ipu->popup_ok = button_add (ipu->popup_win, NULL, button_okay, 0, 0);
		widget_set_OnClick (ipu->popup_win, ipu->popup_ok, popup_ok_button_handler);
		widget_set_color (ipu->popup_win, ipu->popup_ok, 0.77f, 0.57f, 0.39f);

		// Reject
		ipu->popup_no = button_add (ipu->popup_win, NULL, button_cancel, 0, 0);
		widget_set_OnClick (ipu->popup_win, ipu->popup_no, popup_cancel_button_handler);
		widget_set_color (ipu->popup_win, ipu->popup_no, 0.77f, 0.57f, 0.39f);

		// align the buttons
		wok = widget_find(ipu->popup_win, ipu->popup_ok);
		wno = widget_find(ipu->popup_win, ipu->popup_no);
		widget_move(ipu->popup_win, ipu->popup_ok, (ipu->popup_x_len - wok->len_x - wno->len_x)/3, ipu->popup_y_len - (wok->len_y + 5));
		widget_move(ipu->popup_win, ipu->popup_no, wok->len_x + 2*(ipu->popup_x_len - wok->len_x - wno->len_x)/3, ipu->popup_y_len - (wno->len_y + 5));

		set_window_handler (ipu->popup_win, ELW_HANDLER_KEYPRESS, popup_keypress_handler);

		if ((ipu->popup_win > -1) && (ipu->popup_win < windows_list.num_windows))
			windows_list.window[ipu->popup_win].data = ipu;
	}
	else
	{
		if ((ipu->parent > -1) && (ipu->parent < windows_list.num_windows))
		{
			window_info *win = &windows_list.window[ipu->parent];
			move_window(ipu->popup_win, ipu->parent, 0, win->pos_x+ipu->x, win->pos_y+ipu->y);
		}
		text_field_clear(ipu->popup_win, ipu->popup_field);
		label_set_text (ipu->popup_win, ipu->popup_label, label);
		show_window (ipu->popup_win);
		select_window (ipu->popup_win);
	}
}
Example #10
0
void TEST_move_window() {
    char *routine = "TEST_move_window";
    printf(testing, routine);
    //First with a valid window
    Window win = active_window();
    int before_x = window_x(win);
    int before_y = window_y(win);
    assert(move_window(win, before_x + 10, before_y + 10, -1));
    int after_x = window_x(win);
    int after_y = window_y(win);

    //"Snap to grid" makes this a bit hard to test.
    //What if the grid isn't "10"?  If it's e.g. 12,
    //then we'll be off by 2 pixels.
    assert(before_x != after_x);
    assert(before_y != after_y);
    move_window(win, before_x, before_y, -1);
    activate_window(win);

    //Now with an invalid window
    assert(move_window(20, 0, 0, -1) == FALSE);
    printf(done, routine);
}
Example #11
0
int	init_window(int win_id, int pos_id, Uint32 pos_loc, int pos_x, int pos_y, int size_x, int size_y)
{
	if(win_id <=0 || win_id >= windows_list.num_windows)	return -1;
	if(windows_list.window[win_id].window_id != win_id)	return -1;

	move_window(win_id, pos_id, pos_loc, pos_x, pos_y);
	windows_list.window[win_id].len_x= size_x;
	windows_list.window[win_id].len_y= size_y;

	if(windows_list.window[win_id].init_handler)
		{
			return((*windows_list.window[win_id].init_handler)(&windows_list.window[win_id]));
		}
	return 1;
}
Example #12
0
	//	Move the window back to the default poistion
	//
	void List_Window::reset_position(void)
	{
		if ((win_id>=0) && (win_id<windows_list.num_windows))
		{
			window_info *list_win = &windows_list.window[win_id];
			if (list_win && (list_win->pos_id>=0) && (list_win->pos_id<windows_list.num_windows))
			{
				window_info *parent_win = &windows_list.window[list_win->pos_id];
				if (parent_win)
				{
					int pos_x = get_window_pos_x(parent_win);
					move_window(win_id, list_win->pos_id, list_win->pos_loc, parent_win->pos_x + pos_x, parent_win->pos_y);
				}
			}
		}
	}
Example #13
0
/**************************************************************************
  Move Window Group.  The Trick is simple.  We move only last member of
  group: the window , and then set new position to all members of group.

  Function return 1 when group was moved.
**************************************************************************/
bool move_window_group_dialog(struct widget *pBeginGroupWidgetList,
			     struct widget *pEndGroupWidgetList)
{
  bool ret = FALSE;
  Sint16 oldX = pEndGroupWidgetList->size.x,
      oldY = pEndGroupWidgetList->size.y;

  if (move_window(pEndGroupWidgetList)) {
    set_new_group_start_pos(pBeginGroupWidgetList,
			    pEndGroupWidgetList->prev,
			    pEndGroupWidgetList->size.x - oldX,
			    pEndGroupWidgetList->size.y - oldY);
    ret = TRUE;
  }

  return ret;
}
Example #14
0
void setup() {
    Serial.begin(9600);
    Serial.println("Starting...");
    delay(500);
    Serial.flush();    // There can be nasty leftover bits.

    initialize_screen();

    initialize_sd_card();

    initialize_joystick();

    initialize_map();

    // Want to start viewing window in the center of the map
    move_window(
        (map_box[current_map_num].W + map_box[current_map_num].E) / 2,
        (map_box[current_map_num].N + map_box[current_map_num].S) / 2);

    // with cursor in the middle of the window
    move_cursor_to(
        screen_map_x + display_window_width / 2, 
        screen_map_y + display_window_height / 2);

    // Draw the initial screen and cursor
    first_time = 1;

    // Now initialize and enable the zoom buttons.
    pinMode(zoom_out_pin, INPUT);    // Zoom out.
    digitalWrite(zoom_out_pin, HIGH);

    pinMode(zoom_in_pin, INPUT);    // Zoom in.
    digitalWrite(zoom_in_pin, HIGH);

    // Initialize interrupt routines attached to zoom buttons.
    attachInterrupt(zoom_in_interrupt, handle_zoom_in, FALLING);
    attachInterrupt(zoom_out_interrupt, handle_zoom_out, FALLING);

    #ifdef DEBUG_MEMORY
        Serial.print("Available mem:");
        Serial.println(AVAIL_MEM);
    #endif
}
Example #15
0
void display_small_text_window()
{
	int x=mouse_x-(small_text_win_x_len>>1);
	int y=mouse_y-(small_text_win_y_len>>1);

	if(x<0)x=200;
	if(y<0)y=200;
	if(x>window_width-small_text_win_x_len)x=200;
	if(y>window_height-small_text_win_y_len)y=200;

	if(small_text_win < 0){
		small_text_win= create_window("Small text window", 0, 0, x, y, small_text_win_x_len, small_text_win_y_len, ELW_CLOSE_BOX|ELW_DRAGGABLE|ELW_USE_BACKGROUND|ELW_USE_BORDER|ELW_SHOW);
		set_window_handler(small_text_win, ELW_HANDLER_DISPLAY, &display_small_text_window_handler );
	} else {
		move_window(small_text_win, 0, 0, x, y);
		show_window(small_text_win);
		select_window(small_text_win);
	}
}
Example #16
0
//	When the mouse is over an achievement, create a window to display the details.
//
void Achievements_Window::open_child(void)
{
	window_info *parent = &windows_list.window[main_win_id];
	if (child_win_id < 0)
	{
		child_win_id = create_window("child", parent->window_id, 0, 0, 0, 0, 0,
			ELW_USE_BACKGROUND|ELW_USE_BORDER|ELW_SHOW|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE);
		set_window_handler(child_win_id, ELW_HANDLER_DISPLAY, (int (*)())&achievements_child_display_handler );
	}
	else
		show_window(child_win_id);

	Achievements_System *as = Achievements_System::get_instance();
	window_info *win = &windows_list.window[child_win_id];
	win->data = reinterpret_cast<void *>(&last_over);
	win->opaque = parent->opaque;
	resize_window(win->window_id, as->get_child_win_x(), as->get_child_win_y());
	move_window(win->window_id, parent->window_id, 0,
		parent->pos_x + (parent->len_x - as->get_child_win_x()) / 2, parent->pos_y  + parent->len_y + as->get_y_win_offset());
}
Example #17
0
static long apply_delta(off_t len, struct line_buffer *input,
			const char *old_data, uint32_t old_mode)
{
	long ret;
	struct sliding_view preimage = SLIDING_VIEW_INIT(&report_buffer, 0);
	FILE *out;

	if (init_postimage() || !(out = buffer_tmpfile_rewind(&postimage)))
		die("cannot open temporary file for blob retrieval");
	if (old_data) {
		const char *response;
		printf("cat-blob %s\n", old_data);
		fflush(stdout);
		response = get_response_line();
		if (parse_cat_response_line(response, &preimage.max_off))
			die("invalid cat-blob response: %s", response);
		check_preimage_overflow(preimage.max_off, 1);
	}
	if (old_mode == REPO_MODE_LNK) {
		strbuf_addstr(&preimage.buf, "link ");
		check_preimage_overflow(preimage.max_off, strlen("link "));
		preimage.max_off += strlen("link ");
		check_preimage_overflow(preimage.max_off, 1);
	}
	if (svndiff0_apply(input, len, &preimage, out))
		die("cannot apply delta");
	if (old_data) {
		/* Read the remainder of preimage and trailing newline. */
		assert(!signed_add_overflows(preimage.max_off, 1));
		preimage.max_off++;	/* room for newline */
		if (move_window(&preimage, preimage.max_off - 1, 1))
			die("cannot seek to end of input");
		if (preimage.buf.buf[0] != '\n')
			die("missing newline after cat-blob response");
	}
	ret = buffer_tmpfile_prepare_to_read(&postimage);
	if (ret < 0)
		die("cannot read temporary file for blob retrieval");
	strbuf_release(&preimage.buf);
	return ret;
}
Example #18
0
//	Called when UI scaling changed
static int ui_scale_manufacture_handler(window_info *win)
{
	int mbw = (int)(0.5 + 43 * win->current_scale);
	int cbw = (int)(0.5 + 70 * win->current_scale);
	int space = (int)(0.5 + 7 * win->current_scale);
	int free_x = 0;

	SLOT_SIZE = (int)(0.5 + 33 * win->current_scale);
	PIPE_CONTROL_X = (int)(0.5 + 5 * win->current_scale) * 2 + win->small_font_len_x;
	recipe_win_width = SLOT_SIZE * NUM_MIX_SLOTS + win->box_size + 2;
	manufacture_menu_x_len = GRID_COLS * SLOT_SIZE + win->box_size;
	manufacture_menu_y_len = (GRID_ROWS+1) * SLOT_SIZE + (4+1) * win->small_font_len_y;
	text_y_offset = SLOT_SIZE + 4 + 4.5 * win->small_font_len_y;
	recipe_y_offset = SLOT_SIZE + 4;
	control_elem_size = (int)(0.5 + 5 * win->current_scale);

	free_x = manufacture_menu_x_len - (cbw + 2*mbw + 3*space);
	pipeline_x = space + cbw + free_x/2 - (SLOT_SIZE*NUM_MIX_SLOTS + PIPE_CONTROL_X)/2;

	resize_window(win->window_id, manufacture_menu_x_len, manufacture_menu_y_len);

	button_resize(win->window_id, mixone_button_id, mbw, 0,  win->current_scale);
	button_resize(win->window_id, mixall_button_id, mbw, 0,  win->current_scale);
	button_resize(win->window_id, clear_button_id, cbw, 0,  win->current_scale);

	widget_move(win->window_id, mixone_button_id, manufacture_menu_x_len-2*(mbw+space), manufacture_menu_y_len - recipe_y_offset);
	widget_move(win->window_id, mixall_button_id, manufacture_menu_x_len-(mbw+space), manufacture_menu_y_len - recipe_y_offset);
	widget_move(win->window_id, clear_button_id, space, manufacture_menu_y_len - recipe_y_offset);

	if ((recipe_win > -1) && (recipe_win < windows_list.num_windows))
	{
		set_window_min_size(recipe_win, recipe_win_width, 4*SLOT_SIZE);
		move_window(recipe_win, win->window_id, 0, win->pos_x + pipeline_x, win->pos_y + manufacture_menu_y_len - 2);
		resize_window(recipe_win, recipe_win_width, num_displayed_recipes*SLOT_SIZE);
	}

	last_items_string_id = (size_t)-1;

	return 1;
}
Example #19
0
void analyzer(int argc, char *argv[])  
{  
    char input[BUF_SIZE] = { 0, };
    int length = 0;
    int threshold = 0;
    int range = 0;
//    FILE *output dd= NULL;

    char org_chr[8] = { 0, };
    char prev_chr[8] = { 0, };
    int  org_pos;
    int  prev_pos = 1;
    int  is_new_pos = 0;  // HERE
    char fnd_chr[8] = { 0, };
    int  fnd_pos;
    char base;
    uint32_t  flag;
    int  qual;
    int  ret;
    char *ARGV[ARGC_MAX];
    int ARGC = 0;
    int i = 0;

    if( argc == 0 ) // HADOOP
    {
        ARGV[0] = getenv("mapred_job_arg0"); // e.g. 50
        ARGV[1] = "analyzer";
        ARGV[2] = getenv("mapred_job_arg2"); // e.g. 50
        ARGV[3] = getenv("mapred_job_arg3"); // e.g. -e
        ARGV[4] = getenv("mapred_job_arg4"); // e.g. 0.02
        ARGV[5] = getenv("mapred_job_arg5"); // e.g. -q
        ARGV[6] = getenv("mapred_job_arg6"); // e.g. A
        ARGV[7] = getenv("mapred_job_arg7"); // e.g. -r
        ARGV[8] = getenv("mapred_job_arg8"); // e.g. 200
        ARGV[9] = getenv("mapred_job_arg9"); // e.g. -t
        ARGV[10] = getenv("mapred_job_arg10"); // e.g. 20
        ARGV[11] = getenv("mapred_job_arg11"); // e.g. -f
        ARGV[12] = getenv("mapred_job_arg12"); 
        ARGV[13] = getenv("mapred_job_arg13"); 
        ARGV[14] = getenv("mapred_job_arg14"); 
        ARGV[15] = getenv("mapred_job_arg15"); 
        ARGV[16] = getenv("mapred_job_arg16"); 
        ARGV[17] = getenv("mapred_job_arg17"); 
        ARGV[18] = getenv("mapred_job_arg18"); 
        ARGV[19] = getenv("mapred_job_arg19"); 
        ARGV[20] = getenv("mapred_job_arg20"); 
        ARGV[21] = getenv("mapred_job_arg21"); 
        ARGV[22] = getenv("mapred_job_arg22"); 
        ARGV[23] = getenv("mapred_job_arg23"); 

        fprintf( stderr, "0. %s\n", ARGV[0] );
        fprintf( stderr, "1. %s\n", ARGV[1] );
        fprintf( stderr, "2. %s\n", ARGV[2] );
        fprintf( stderr, "3. %s\n", ARGV[3] );
        fprintf( stderr, "4. %s\n", ARGV[4] );
        fprintf( stderr, "5. %s\n", ARGV[5] );
        fprintf( stderr, "6. %s\n", ARGV[6] );
        fprintf( stderr, "7. %s\n", ARGV[7] );
        fprintf( stderr, "8. %s\n", ARGV[8] );
        fprintf( stderr, "9. %s\n", ARGV[9] );
        fprintf( stderr, "10. %s\n", ARGV[10] );
        fprintf( stderr, "11. %s\n", ARGV[11] );
        fprintf( stderr, "12. %s\n", ARGV[12] );
        fprintf( stderr, "13. %s\n", ARGV[13] );
        fprintf( stderr, "14. %s\n", ARGV[14] );
        fprintf( stderr, "15. %s\n", ARGV[15] );
        fprintf( stderr, "16. %s\n", ARGV[16] );
        fprintf( stderr, "17. %s\n", ARGV[17] );
        fprintf( stderr, "18. %s\n", ARGV[18] );
        fprintf( stderr, "19. %s\n", ARGV[19] );
        fprintf( stderr, "20. %s\n", ARGV[20] );
        fprintf( stderr, "21. %s\n", ARGV[21] );
        fprintf( stderr, "22. %s\n", ARGV[22] );
        fprintf( stderr, "23. %s\n", ARGV[23] );

        ARGC = atoi( ARGV[0] );
 
        parse_args( ARGC, ARGV, &length, &threshold, &range );
    }
    else
    {
        parse_args( argc, argv, &length, &threshold, &range );
    }

    fprintf( stderr, "==================================================\n" );
    fprintf( stderr, "length : %d\n", length );
    fprintf( stderr, "threshold : %d\n", threshold );
    fprintf( stderr, "library distance : %d\n", range );
    fprintf( stderr, "==================================================\n" );

    fprintf( stdout, "#chr\tpos\t\tbase\tmaq\ttotal = >= + <(um)\tGMS\n");


    init_prob_window( length );
//    output = fopen( "sort.gma", "w+" );

    while( fgets( input, BUF_SIZE-1, stdin ) )
    {
        get_info( input, org_chr, &org_pos, 
                         fnd_chr, &fnd_pos, &base, &flag, &qual, &ret ); 
/*
        fprintf( stderr, "%s", input );
*/
/*
        fprintf( stderr, "%s:", org_chr );
        fprintf( stderr, "%d-", org_pos );
        fprintf( stderr, "%s:", fnd_chr );
        fprintf( stderr, "%d\t", fnd_pos );

        fprintf( stderr, "%c:", base );
        fprintf( stderr, "%d(0x%x):", flag, flag );
        fprintf( stderr, "%d:", qual );
        fprintf( stderr, "%d\n", ret );
*/

        if( strcmp( prev_chr, "" ) == 0 )
        {
            //fprintf( stderr, "none -> %s +\n", org_chr );
            strcpy( prev_chr, org_chr );
        }
        else if( strcmp( prev_chr, org_chr ) == 0 )
        {
            //  in the same chromosome
            // fprintf( stderr, "org_pos: %d, prev_pos: %d\n", org_pos, prev_pos );

            if( prev_pos != org_pos )
            {
                for( i = 1; i < ( org_pos - prev_pos ) ; i++ )
                {
                    //fprintf( stdout, "prev_pos + i : %d\n", prev_pos + i );
                    move_window( NULL,
                                 0, // range
                                 org_chr, 
                                 prev_pos+i, //org_pos,
                                 '*', //base,
                                 0,   //flag,
                                 -1,  //qual, 
                                 threshold );

                }
 
                prev_pos = org_pos;
                is_new_pos = 1;
            }
            else
            {
                is_new_pos = 0;
            }
        }
        else // new chromosome
        {
            fprintf( stderr, "clear windows: prv_chr(%s), prv_pos(%d+1)\n", prev_chr, prev_pos );
            fprintf( stderr, "clear windows: org_chr(%s), org_pos(%d)\n", org_chr, org_pos );

            clean_windows( NULL, prev_chr, prev_pos, length, threshold); 
            destroy_prob_window();
            init_prob_window( length );

            fprintf( stderr, "%s -> %s *\n", prev_chr, org_chr );
            is_new_pos = 0;
            strcpy( prev_chr, org_chr );
        }

        // prg_chr starts with "chr", e.g. chrX, chr1
        // fnd_chr depends on how BWA and SAM tools work

        if( org_pos == fnd_pos )
        {
            //fprintf( stderr, "%9d:%9d:%d\n", org_pos, fnd_pos, qual );
        }
        else
        {
            qual = 0;
        }

        //fprintf( stdout, "%9d:%09d:%09d:%d\n", prev_pos, org_pos, fnd_pos, qual );

        if( ( strcmp( &org_chr[3],  fnd_chr )    == 0 ) ||
            ( strcmp( &org_chr[3], &fnd_chr[3] ) == 0 ) ||
            ( strcmp(  org_chr   ,  fnd_chr    ) == 0 ) ||
            ( strcmp(  org_chr   , &fnd_chr[3] ) == 0 ) )
        {
            //fprintf( stderr, "same %s == %s\n", org_chr, fnd_chr );

            if( is_new_pos == 0 )
            {
                

                fill_window( NULL,
                             range,
                             org_chr, 
                             org_pos,
                             base,
                             flag,
                             qual, 
                             threshold );
            }
            else
            {
//               fprintf( stderr, "\n" );
                move_window( NULL,
                             range,
                             org_chr, 
                             org_pos,
                             base,
                             flag,
                             qual, 
                             threshold );
            }
        }
        else
        {
            //fprintf( stderr, "diff %s != %s\n", org_chr, fnd_chr );
            if( is_new_pos == 0 )
            {
                fill_window( NULL,
                             range,
                             org_chr, 
                             org_pos,
                             base,
                             flag,
                             -1, 
                             threshold );
            }
            else
            {
//                fprintf( stderr, "\n" );
                move_window( NULL,
                             range,
                             org_chr, 
                             org_pos,
                             base,
                             flag,
                             -1, 
                             threshold );
            }
        }
    } // while

    //clean_windows( NULL, org_chr, org_pos+1, length); 
    clean_windows( NULL, org_chr, org_pos, length, threshold); 
    destroy_prob_window();
}
Example #20
0
/// \brief      Tries to fill the input window (mf->buffer)
///
/// If we are the last encoder in the chain, our input data is in in[].
/// Otherwise we call the next filter in the chain to process in[] and
/// write its output to mf->buffer.
///
/// This function must not be called once it has returned LZMA_STREAM_END.
///
static lzma_ret
fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
		size_t *in_pos, size_t in_size, lzma_action action)
{
	size_t write_pos;
	lzma_ret ret;

	assert(coder->mf.read_pos <= coder->mf.write_pos);

	// Move the sliding window if needed.
	if (coder->mf.read_pos >= coder->mf.size - coder->mf.keep_size_after)
		move_window(&coder->mf);

	// Maybe this is ugly, but lzma_mf uses uint32_t for most things
	// (which I find cleanest), but we need size_t here when filling
	// the history window.
	write_pos = coder->mf.write_pos;
	if (coder->next.code == NULL) {
		// Not using a filter, simply memcpy() as much as possible.
		lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer,
				&write_pos, coder->mf.size);

		ret = action != LZMA_RUN && *in_pos == in_size
				? LZMA_STREAM_END : LZMA_OK;

	} else {
		ret = coder->next.code(coder->next.coder, allocator,
				in, in_pos, in_size,
				coder->mf.buffer, &write_pos,
				coder->mf.size, action);
	}

	coder->mf.write_pos = write_pos;

	// If end of stream has been reached or flushing completed, we allow
	// the encoder to process all the input (that is, read_pos is allowed
	// to reach write_pos). Otherwise we keep keep_size_after bytes
	// available as prebuffer.
	if (ret == LZMA_STREAM_END) {
		assert(*in_pos == in_size);
		ret = LZMA_OK;
		coder->mf.action = action;
		coder->mf.read_limit = coder->mf.write_pos;

	} else if (coder->mf.write_pos > coder->mf.keep_size_after) {
		// This needs to be done conditionally, because if we got
		// only little new input, there may be too little input
		// to do any encoding yet.
		coder->mf.read_limit = coder->mf.write_pos
				- coder->mf.keep_size_after;
	}

	// Restart the match finder after finished LZMA_SYNC_FLUSH.
	if (coder->mf.pending > 0
			&& coder->mf.read_pos < coder->mf.read_limit) {
		// Match finder may update coder->pending and expects it to
		// start from zero, so use a temporary variable.
		const size_t pending = coder->mf.pending;
		coder->mf.pending = 0;

		// Rewind read_pos so that the match finder can hash
		// the pending bytes.
		assert(coder->mf.read_pos >= pending);
		coder->mf.read_pos -= pending;

		// Call the skip function directly instead of using
		// mf_skip(), since we don't want to touch mf->read_ahead.
		coder->mf.skip(&coder->mf, pending);
	}

	return ret;
}
Example #21
0
	inline void move_window(window wd, const rectangle& r)
	{
		move_window(wd, r.x, r.y, r.width, r.height);
	}
Example #22
0
int display_minimap_handler(window_info *win)
{
	float zoom_multip;
	float size_x = float_minimap_size / (tile_map_size_x * 6);
	float size_y = float_minimap_size / (tile_map_size_y * 6);
	float px = 0.0f, py = 0.0f;
	actor *me;
	float x,y;
	int i;

	if(win->pos_x > window_width - 50)
		move_window(minimap_win,win->pos_id,win->pos_loc,window_width-minimap_size,win->pos_y);
	if(win->pos_y > window_height - 50)
		move_window(minimap_win,win->pos_id,win->pos_loc,win->pos_x,window_height-minimap_size);

	if (enable_controls)
	{
		draw_minimap_title_bar(win);
		enable_controls = 0;
	}
	
	zoom_multip = minimap_get_zoom();

	if(!minimap_texture) 
	{
		//there's no minimap for this map :( draw a X
		glTranslatef(0.0f, 16.0f, 0.0f);
		glPushMatrix(); 
		glDisable(GL_TEXTURE_2D);
		//draw black background
		glColor3f(0.0f,0.0f,0.0f);
		glBegin(GL_POLYGON);
		for (i=0; i<=360; i +=10) 
		{
			x = sin((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2;
			y = cos((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2;
			glVertex2f(x, y);	
		}
		glEnd();

		glPopMatrix();
		draw_compass();
		return 0;
	}
	//draw minimap

	//get player position in window coordinates
	if( (me = get_our_actor ()) == NULL)
	{
		//Don't know who we are? can't draw then
		return 0;
	}
	px = me->x_tile_pos * size_x;
	py = float_minimap_size - (me->y_tile_pos * size_y);

	glTranslatef(0.0f, 16.0f, 0.0f);

	glDisable(GL_TEXTURE_2D);
	//draw black background
	glColor3f(0.0f,0.0f,0.0f);
	glBegin(GL_POLYGON);
	for (i=0; i<=360; i +=10) 
	{
		x = sin((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2;
		y = cos((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2;
		glVertex2f(x, y);	
	}
	glEnd();

	draw_map(win,zoom_multip, px, py);
	draw_actor_points(zoom_multip, px, py);


#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE

	return 0;
}
Example #23
0
void handle_msg(int *msg)
{
	WINDOWP	window;

	wake_mouse();
	window= get_window(msg[3]);			/* Zugeh�riges Fenster */

	switch (msg[0])							/* Art der Nachricht */
	{
		case MN_SELECTED:
			if (makro_rec)						/* Makro wird Tastendruck vorgegaukelt */
			{
				int	kstate, kreturn;
				char	str[50];
				
				get_string(menu, msg[4], str);
				if (str_to_key(str, &kstate, &kreturn))
				{
					kstate |= (kstate & 3);
					to_makro(kstate, kreturn);
				}
			}
			handle_menu(msg[3], msg[4], menu_ctrl);
			menu_ctrl = FALSE;
			break;
		case WM_REDRAW  :
			if (msg[3] == akt_handle)
				redraw_aktion();
			else
				redraw_window (window, (GRECT*)(msg+4));
			break;
		case WM_CLOSED  :
			do_icon(window->handle, DO_DELETE);
			break;
		case WM_FULLED  :
			full_window (window);
			break;
		case WM_ARROWED :
			arrow_window (window, msg[4], 1);
			break;
		case WM_HSLID	 :
			h_slider (window, msg[4]);
			break;
		case WM_VSLID	 :
			v_slider (window, msg[4]);
			break;
		case WM_SIZED	 :
			size_window (window, (GRECT*)(msg+4), TRUE);
			break;
		case WM_MOVED	 :
			move_window (window, (GRECT*)(msg+4));
			break;
		case WM_NEWTOP	 : /* Fenster von qed ist irgendwie nach oben gekommen */
		case WM_ONTOP	 :
			ontop_window(window);
			break;
		case WM_TOPPED  :
			top_window (window);
			break;
		case WM_UNTOPPED: /* qed hat jetzt nicht mehr das Top-Fenster */
			untop_window (window);
			break;
		case WM_BOTTOMED: 	/* AES 4.00 MagiC 3 : Fenster nach hinten */
		case WM_M_BDROPPED :	/* Magic 2 */
			bottom_window (window, msg[0]);
			break;
		case WM_ICONIFY:
			iconify_window(window, (GRECT*)(msg+4));
			break;
		case WM_ALLICONIFY:
			all_iconify(window, (GRECT*)(msg+4));
			break;
		case WM_UNICONIFY:
			if (all_iconified)
				all_uniconify(NULL, (GRECT*)(msg+4));
			else
				uniconify_window(window, (GRECT*)(msg+4));
			break;
		case WM_SHADED :
		case WM_UNSHADED :
			shade_window(window, msg[0]);
			break;

		case AP_TERM:
			if (all_iconified)
				all_uniconify(NULL, NULL);
			quick_close = TRUE;
			if (prepare_quit())
				do_quit();
			break;
		case AP_DRAGDROP :
			if (all_iconified)
				Bconout(2, 7);
			else
				handle_dd(msg);
			break;

		case SC_CHANGED :
			/*
			 * Ignorieren, da wir vor dem Paste sowieso neu laden.
			*/
			break;

		case VA_START :
		case VA_PROTOSTATUS :
		case VA_DRAG_COMPLETE :
		case VA_DRAGACCWIND :
		case AV_SENDKEY :
			handle_av(msg);
			break;

		case SE_INIT:
		case SE_OK:
		case SE_ACK:
		case SE_OPEN:
		case SE_ERROR:
		case SE_ERRFILE:
		case SE_PROJECT:
		case SE_QUIT:
		case SE_TERMINATE:
		case SE_CLOSE :
		case SE_MENU :
			if (all_iconified)
				all_uniconify(NULL, NULL);
		   handle_se(msg);
		   break;

		case OLGA_INIT :
		case OLE_NEW :
		case OLGA_ACK :
		case OLE_EXIT :
			handle_olga(msg);
			break;

		case SH_WDRAW:				/* schickt Freedom st�ndig */
		case DHST_ACK:				/* SMU antwortet */
			/* ignore */
			break;

		case FONT_CHANGED :
			if (msg[4] != 0)
				font_id = msg[4];
			if (msg[5] != 0)
				font_pts = msg[5];
			font_change();	
			break;
			
		default:
			if (debug_level)
			{
				char	str[12];
				int	d, i, id;
	
				if ((appl_xgetinfo(4, &d, &d, &i, &d)) && (i == 1))	/* gibts appl_search? */
				{
					i = appl_search(0, str, &d, &id);
					while (i != 0)
					{
						if (id == msg[1])
							break;
						i = appl_search( 1, str, &d, &id);
					}
				}
				else
				{
					strcpy(str, "");
					id = msg[1];
				}
				debug("Unbekannte Msg %d (0x%X) von %s (%d)\n", msg[0], msg[0], str, id);
			}
			break;
	}
}
Example #24
0
void raise_window(void) {
  move_window(true);
}
Example #25
0
void lower_window(void) {
  move_window(false);
}
Example #26
0
int	drag_windows(int _x, int _y, int dx, int dy)
{
	int	next_id;
	int	id, i;
	int	drag_id= 0;

	// check each window in the proper order for which one might be getting dragged
	if(windows_list.display_level > 0)
		{
			id= 9999;
			while(drag_id <= 0)
				{
					next_id= 0;
					for(i=1; i<windows_list.num_windows; i++){
						// only look at displayed windows
						if(windows_list.window[i].displayed > 0 && (windows_list.window[i].flags&ELW_DRAGGABLE)){
							// at this level?
							if(windows_list.window[i].order == id){
								// check for being actively dragging or on the top bar
								if(windows_list.window[i].dragged || (mouse_in_window(i, _x, _y) && _y<windows_list.window[i].cur_y) ){
									drag_id= i;
									break;
								} else if(mouse_in_window(i, _x, _y)){
									// stop processing if we are inside of another window
									return 0;
								}
							} else if(windows_list.window[i].order < id && windows_list.window[i].order > next_id){
								// try to find the next level
								next_id= windows_list.window[i].order;
							}
						}
					}
					if(next_id <= 0)
						{
							break;
						}
					else
						{
							id= next_id;
						}
				}
		}

	// this section probably won't be needed, included to be complete
	// now check the background windows in the proper order for which one might be getting dragged
	id= -9999;
	while(drag_id <= 0)
		{
			next_id= 0;
			for(i=1; i<windows_list.num_windows; i++){
				// only look at displayed windows
				if(windows_list.window[i].displayed > 0 && (windows_list.window[i].flags&ELW_DRAGGABLE)){
					// at this level?
					if(windows_list.window[i].order == id){
						// check for being actively dragging or on the top bar
						if(windows_list.window[i].dragged || (mouse_in_window(i, _x, _y) && _y<windows_list.window[i].cur_y) ){
							drag_id= i;
							break;
						} else if(mouse_in_window(i, _x, _y)){
							// stop processing if we are inside of another window
							return 0;
						}
					} else if(windows_list.window[i].order > id && windows_list.window[i].order < next_id){
						// try to find the next level
						next_id= windows_list.window[i].order;
					}
				}
			}
			if(next_id >= 0)
				{
					break;
				}
			else
				{
					id= next_id;
				}
		}

	// are we dragging a window?
	if(drag_id <= 0)	return 0;

	// dragged window is always on top
	select_window(drag_id);
	// flag we are dragging
	windows_list.window[drag_id].dragged= 1;
	if(left_click>1 && (dx != 0 || dy != 0))	// TODO: avoid globals?
		{
			// move to new location
			move_window(drag_id, windows_list.window[drag_id].pos_id, windows_list.window[drag_id].pos_loc,
					windows_list.window[drag_id].pos_x+dx, windows_list.window[drag_id].pos_y+dy);
		}

	return 1;
}