Exemplo n.º 1
0
static void draw_text_info(int x, int y, int dx, int dy, int pos)
{
	char buffer[3][256];

	adv_crtc* crtc = menu_pos(pos);

	if (crtc) {
		format_info(buffer[0], buffer[1], buffer[2], 256, crtc);
	} else {
		sncpy(buffer[0], sizeof(buffer[0]), "");
		sncpy(buffer[1], sizeof(buffer[1]), "");
		sncpy(buffer[2], sizeof(buffer[2]), "");
	}

	draw_text_left(x, y+0, dx, buffer[0], COLOR_INFO_TITLE);
	draw_text_left(x, y+1, dx, buffer[1], COLOR_INFO_NORMAL);
	draw_text_left(x, y+2, dx, buffer[2], COLOR_INFO_NORMAL);

	if (crtc) {
		if (crtc_is_fake(crtc)) {
			draw_text_left(x+dx-8, y, 8, " SYSTEM ", COLOR_INFO_NORMAL);
		} else if (!crtc_clock_check(&the_monitor, crtc)) {
			draw_text_left(x+dx-14, y, 14, " OUT OF RANGE ", COLOR_ERROR);
		} else {
			draw_text_left(x+dx-14, y, 14, " PROGRAMMABLE ", COLOR_INFO_NORMAL);
		}
	} else {
		draw_text_fillrect(x, y, ' ', dx, dy, COLOR_INFO_NORMAL);
	}
}
Exemplo n.º 2
0
static adv_error cmd_onvideo_calib(void)
{
	adv_mode mode;
	adv_crtc* crtc;
	unsigned speed;
	char buffer[128];

	mode_reset(&mode);

	if (the_mode_index == MODE_FLAGS_INDEX_TEXT) {
		error_set("Command supported only in graphics mode");
		return -1;
	}

	crtc = menu_current();
	if (!crtc)
		return -1;

	if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc))
		return -1;

	if (video_mode_generate(&mode, crtc, the_mode_index)!=0) {
		return -1;
	}

	if (text_mode_set(&mode) != 0) {
		text_reset();
		return -1;
	}

	video_write_lock();

	draw_graphics_palette();
	/* draw_graphics_out_of_screen(0); */
	draw_graphics_clear();

	speed = draw_graphics_speed(0, 0, video_size_x(), video_size_y());
	draw_graphics_calib(0, 0, video_size_x(), video_size_y());

	snprintf(buffer, sizeof(buffer), " %.2f MB/s", speed / (double)(1024*1024));
	draw_string(0, 0, buffer, DRAW_COLOR_WHITE);

	video_write_unlock(0, 0, 0, 0, 0);

	video_wait_vsync();

	do {
		target_idle();
		os_poll();
	} while (inputb_get()==INPUTB_NONE);

	return 0;
}
Exemplo n.º 3
0
adv_error fb_mode_generate(fb_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{
	assert(fb_is_active());

	if (crtc_is_fake(crtc)) {
		error_nolog_set("Not programmable modes are not supported.\n");
		return -1;
	}

	if (video_mode_generate_check("fb", fb_flags(), 8, 2048, crtc, flags)!=0)
		return -1;

	mode->crtc = *crtc;
	mode->index = flags & MODE_FLAGS_INDEX_MASK;

	return 0;
}
Exemplo n.º 4
0
adv_error vgaline_mode_generate(vgaline_video_mode* mode, const adv_crtc* crtc, unsigned flags)
{
	unsigned pixelclock;

	assert(vgaline_is_active());

	if (crtc_is_fake(crtc)) {
		error_nolog_set("Not programmable modes are not supported.\n");
		return -1;
	}

	switch (flags & MODE_FLAGS_INDEX_MASK) {
	case MODE_FLAGS_INDEX_PALETTE8 :
		if (vgaline_mode_generate_graphics(mode, crtc, flags) != 0)
			return -1;
		break;
	case MODE_FLAGS_INDEX_TEXT :
		if (vgaline_mode_generate_text(mode, crtc, flags) != 0)
			return -1;
		break;
	default :
		return -1;
	}

	pixelclock = crtc->pixelclock;

	/* get the real pixelclock */
	pixelclock = vga_pixelclock_nearest_get(pixelclock, mode->is_text);

	if (vgaline_acceptable_pixelclock(crtc->pixelclock, pixelclock)!=0) {
		error_nolog_set("Pixel clock not supported. Nearest supported value is %d Hz.\n", pixelclock);
		return -1;
	}

	return 0;
}
Exemplo n.º 5
0
static void menu_item_draw(int x, int y, int dx, int pos, adv_bool selected)
{
	char buffer[256];

	adv_crtc* crtc = menu_pos(pos);

	if (crtc) {
		char tag;
		unsigned pos;
		unsigned color;
		unsigned color_n;
		unsigned color_clock;
		char pfreq_buffer[8];
		char vfreq_buffer[8];
		char hfreq_buffer[8];

		if (selected) {
			if (crtc->user_flags & MODE_FLAGS_USER_BIT0) {
				tag = 'þ';
				color = COLOR_SELECTED_MARK;
				color_n = color;
			} else {
				tag = ' ';
				color = COLOR_SELECTED;
				color_n = color;
			}
		} else {
			if (crtc->user_flags & MODE_FLAGS_USER_BIT0) {
				tag = 'þ';
				if (crtc_is_fake(crtc) || crtc_clock_check(&the_monitor, crtc)) {
					color = COLOR_MARK;
					color_n = color;
				} else {
					color = COLOR_MARK;
					color_n = COLOR_MARK_BAD;
				}
			} else {
				tag = ' ';
				if (crtc_is_fake(crtc) || crtc_clock_check(&the_monitor, crtc)) {
					color = COLOR_NORMAL;
					color_n = color;
				} else {
					color = COLOR_NORMAL;
					color_n = COLOR_BAD;
				}
			}
		}

		snprintf(vfreq_buffer, sizeof(vfreq_buffer), "%7.2f", (double)crtc_vclock_get(crtc));

		snprintf(hfreq_buffer, sizeof(hfreq_buffer), "%7.2f", (double)crtc_hclock_get(crtc) / 1E3);

		snprintf(pfreq_buffer, sizeof(pfreq_buffer), "%7.2f", (double)crtc_pclock_get(crtc) / 1E6);

		snprintf(buffer, sizeof(buffer), " %c %4d %4d", tag, crtc->hde, crtc->vde);

		pos = 0;

		pos += draw_text_string(x + pos, y, buffer, color_n);

		pos += draw_text_string(x + pos, y, pfreq_buffer, color_n);
		pos += draw_text_string(x + pos, y, hfreq_buffer, color_n);
		pos += draw_text_string(x + pos, y, vfreq_buffer, color_n);

		snprintf(buffer, sizeof(buffer), " %s", crtc->name);

		draw_text_left(x + pos, y, dx - pos, buffer, color_n);
	} else {
		draw_text_fill(x, y, ' ', dx, COLOR_NORMAL);
	}
}
Exemplo n.º 6
0
static adv_error cmd_onvideo_animate(void)
{
	adv_mode mode;
	adv_crtc* crtc;
	unsigned i;
	int counter;

	mode_reset(&mode);

	if (the_mode_index == MODE_FLAGS_INDEX_TEXT) {
		error_set("Command supported only in graphics mode");
		return -1;
	}

	crtc = menu_current();
	if (!crtc)
		return -1;

	if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc))
		return -1;

	if (video_mode_generate(&mode, crtc, the_mode_index)!=0) {
		return -1;
	}

	if (text_mode_set(&mode) != 0) {
		text_reset();
		return -1;
	}

	update_init(2);

	draw_graphics_palette();

	for(i=0;i<3;++i) {
		update_start();
		video_clear(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 0);
		update_stop(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 1);
	}

	counter = update_page_max_get();
	
	while (!inputb_hit()) {
		os_poll();
		
		update_start();
		draw_graphics_animate(update_x_get(), update_y_get(), video_size_x(), video_size_y(), counter - update_page_max_get() + 1, 1);
		++counter;
		draw_graphics_animate(update_x_get(), update_y_get(), video_size_x(), video_size_y(), counter, 0);
		update_stop(update_x_get(), update_y_get(), video_size_x(), video_size_y(), 1);
	}

	update_done();

	do {
		target_idle();
		os_poll();
	} while (inputb_get()==INPUTB_NONE);

	return 0;
}
Exemplo n.º 7
0
static adv_error cmd_onvideo_test(void)
{
	adv_crtc* crtc;
	adv_mode mode;
	adv_bool done;
	adv_crtc crtc_save;
	adv_bool dirty = 1;
	adv_bool crtc_save_modified;

	mode_reset(&mode);

	crtc = menu_current();
	if (!crtc)
		return -1;

	if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc))
		return -1;

	if (video_mode_generate(&mode, crtc, the_mode_index)!=0) {
		return -1;
	}

	if (text_mode_set(&mode) != 0) {
		text_reset();
		return -1;
	}

	crtc_save = *crtc;
	crtc_save_modified = the_modes_modified;

	done = 0;
	while (!done) {
		int userkey;
		adv_bool modify = 0;

		adv_crtc last_crtc = *crtc;
		adv_mode last_mode = mode;
		adv_bool vm_last_modified = the_modes_modified;

		if (dirty) {
			video_write_lock();
			test_draw(1, 1, &mode);
			video_write_unlock(0, 0, 0, 0, 0);
			dirty = 0;
		}

		video_wait_vsync();

		target_idle();
		os_poll();

		userkey = inputb_get();

		switch (userkey) {
			case INPUTB_ESC :
				done = 1;
				/* restore */
				*crtc = crtc_save;
				the_modes_modified = crtc_save_modified;
				break;
			case INPUTB_ENTER :
				done = 1;
				break;
		}

		if (!done) {
			modify = test_exe_crtc(userkey, crtc);

			if (modify) {
				the_modes_modified = 1;
				dirty = 1;

				if ((crtc_is_fake(crtc) || crtc_clock_check(&the_monitor, crtc))
					&& video_mode_generate(&mode, crtc, the_mode_index)==0) {
					if (text_mode_set(&mode) != 0) {
						text_reset();
						/* abort */
						*crtc = crtc_save;
						the_modes_modified = crtc_save_modified;
						return -1;
					}
				} else {
					/* restore */
					mode = last_mode;
					*crtc = last_crtc;
					the_modes_modified = vm_last_modified;

					dirty = 1;
					sound_error();
				}
			} else {
				sound_warn();
			}
		}
	}

	return 0;
}