Esempio n. 1
0
void	VID_Init (unsigned char *palette)
{
	// Configurating vita2d environment
	vita2d_set_vblank_wait(0);
	
	tex_buffer = vita2d_create_empty_texture_format(widths[3], heights[3], SCE_GXM_TEXTURE_BASE_FORMAT_P8);
	vid.maxwarpwidth = vid.width = vid.conwidth = widths[3];
	vid.maxwarpheight = vid.height = vid.conheight = heights[3];
	vid.rowbytes = vid.conrowbytes = widths[3];
	
	vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
	vid.numpages = 2;
	vid.colormap = host_colormap;
	vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
	vid.buffer = vid.conbuffer = vid.direct = vita2d_texture_get_datap(tex_buffer);
	
	// Set correct palette for the texture
	VID_SetPalette(palette);
		
	// Init Quake Cache
	d_pzbuffer = zbuffer;
	surfcache = malloc(SURFCACHE_SIZE);
	D_InitCaches (surfcache, SURFCACHE_SIZE);
	
	sprintf(res_string,"Current Resolution: %ld x %ld", widths[3], heights[3]);
	Cvar_RegisterVariable (&res_val);
	Cvar_RegisterVariable(&vid_vsync);
	
}
Esempio n. 2
0
static int VID_SetMode (int modenum, unsigned char *palette)
{
	Uint32 flags;
	int	is_fullscreen;

	in_mode_set = true;

	if (screen)
		SDL_FreeSurface(screen);

	flags = (SDL_SWSURFACE|SDL_HWPALETTE);
	if (vid_config_fscr.integer)
		flags |= SDL_FULLSCREEN;

	// Set the mode
	screen = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags);
	if (!screen)
		return false;

	// initial success. adjust vid vars.
	vid.height = vid.conheight = modelist[modenum].height;
	vid.width = vid.conwidth = modelist[modenum].width;
	vid.buffer = vid.conbuffer = vid.direct = (pixel_t *) screen->pixels;
	vid.rowbytes = vid.conrowbytes = screen->pitch;
	vid.numpages = 1;
	vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);

	if (!VID_AllocBuffers (vid.width, vid.height))
		return false;

	D_InitCaches (vid_surfcache, vid_surfcachesize);

	// real success. set vid_modenum properly.
	vid_modenum = modenum;
	is_fullscreen = (screen->flags & SDL_FULLSCREEN) ? 1 : 0;
	modestate = (is_fullscreen) ? MS_FULLDIB : MS_WINDOWED;
	Cvar_SetValue ("vid_config_swx", modelist[vid_modenum].width);
	Cvar_SetValue ("vid_config_swy", modelist[vid_modenum].height);
	Cvar_SetValue ("vid_config_fscr", is_fullscreen);

	IN_HideMouse ();

	ClearAllStates();

	VID_SetPalette (palette);

	// setup the window manager stuff
	VID_SetIcon();
	SDL_WM_SetCaption(WM_TITLEBAR_TEXT, WM_ICON_TEXT);

	Con_SafePrintf ("Video Mode: %ux%ux%d\n", vid.width, vid.height, modelist[modenum].bpp);

	in_mode_set = false;
	vid.recalc_refdef = 1;

	return true;
}
Esempio n. 3
0
void VID_Init (unsigned char *palette)
{
	vid.width = BASEWIDTH;
	vid.height = BASEHEIGHT;
	vid.pixelaspect = 1.0;
	vid.numpages = 1;
	vid.buffer = vid_buffer;
	vid.rowbytes = BASEWIDTH;
	
	d_pzbuffer = zbuffer;
	D_InitCaches (surfcache, sizeof(surfcache));
}
Esempio n. 4
0
void
VID_Init(unsigned char *palette)
{
    vid.maxwarpwidth = vid.width = vid.conwidth = BASEWIDTH;
    vid.maxwarpheight = vid.height = vid.conheight = BASEHEIGHT;
    vid.aspect = 1.0;
    vid.numpages = 1;
    vid.colormap = host_colormap;
    vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048));
    vid.buffer = vid.conbuffer = vid_buffer;
    vid.rowbytes = vid.conrowbytes = BASEWIDTH;

    d_pzbuffer = zbuffer;
    D_InitCaches(surfcache, sizeof(surfcache));
}
Esempio n. 5
0
void VID_Init(unsigned char *palette)
{
   /* TODO */
    vid.width = BASEWIDTH;
    vid.height = BASEHEIGHT;
    vid.maxwarpwidth = WARP_WIDTH;
    vid.maxwarpheight = WARP_HEIGHT;
    vid.conwidth = vid.width;
    vid.conheight = vid.height;
    vid.numpages = 1;
    vid.colormap = host_colormap;
    vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048));
    vid.buffer = vid.conbuffer = vid_buffer;
    vid.rowbytes = BASEWIDTH;
    vid.conrowbytes = vid.rowbytes;
    vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);

    d_pzbuffer = zbuffer;
    D_InitCaches(surfcache, sizeof(surfcache));
}
Esempio n. 6
0
void	VID_Init (unsigned char *palette)
{

	vid_buffer = malloc(sizeof(byte) * basewidth * baseheight);
	zbuffer = malloc(sizeof(short) * basewidth * baseheight);

	vid.maxwarpwidth = vid.width = vid.conwidth = basewidth;
	vid.maxwarpheight = vid.height = vid.conheight = baseheight;
	vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
	vid.numpages = 2;
	vid.colormap = host_colormap;
	vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
	vid.buffer = vid.conbuffer = vid.direct = vid_buffer;
	vid.rowbytes = vid.conrowbytes = basewidth;
	VID_SetPalette(palette);
	d_pzbuffer = zbuffer;
	surfcache = malloc(D_SurfaceCacheForRes(basewidth,baseheight));
	D_InitCaches (surfcache, D_SurfaceCacheForRes(basewidth,baseheight));
	fb = (u16*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
	globalcolormap = malloc(sizeof(byte)*(VID_GRADES*256));
}
Esempio n. 7
0
static int VID_SW_AllocBuffers(int width, int height)
{
	unsigned int surfcachesize;

	surfcachesize = D_SurfaceCacheForRes(width, height);

	d_pzbuffer = malloc(width * height * sizeof(*d_pzbuffer));
	if (d_pzbuffer)
	{
		vid_surfcache = malloc(surfcachesize);
		if (vid_surfcache)
		{
			D_InitCaches(vid_surfcache, surfcachesize);

			return 1;
		}

		free(d_pzbuffer);
	}

	return 0;
}
Esempio n. 8
0
/*
================
VID_ExtraInitMode
================
*/
int VID_ExtraInitMode (viddef_t *lvid, vmode_t *pcurrentmode)
{
	vesa_extra_t	*pextra;
	int				pageoffset;

	pextra = pcurrentmode->pextradata;

	if (vid_nopageflip.value)
		lvid->numpages = 1;
	else
		lvid->numpages = pcurrentmode->numpages;

// clean up any old vid buffer lying around, alloc new if needed
	if (!VGA_FreeAndAllocVidbuffer (lvid, lvid->numpages == 1))
		return -1;	// memory alloc failed

// clear the screen and wait for the next frame. VGA_pcurmode, which
// VGA_ClearVideoMem relies on, is guaranteed to be set because mode 0 is
// always the first mode set in a session
	if (VGA_pcurmode)
		VGA_ClearVideoMem (VGA_pcurmode->planar);

// set the mode
	regs.x.ax = 0x4f02;
	regs.x.bx = pextra->vesamode;
	dos_int86(0x10);

	if (regs.x.ax != 0x4f)
		return 0;

	VID_banked = !(pextra->vesamode & LINEAR_MODE);
	VID_membase = pextra->plinearmem;
	VGA_width = lvid->width;
	VGA_height = lvid->height;
	VGA_rowbytes = lvid->rowbytes;

	lvid->colormap = host_colormap;

	VID_pagelist = &pextra->pages[0];

// wait for display enable by default only when triple-buffering on a VGA-
// compatible machine that actually has a functioning display enable status
	vsync_exists = VID_ExtraStateFound (0x08);
	de_exists = VID_ExtraStateFound (0x01);

	if (!pextra->vga_incompatible  &&
		(lvid->numpages == 3)      &&
		de_exists                  &&
		(_vid_wait_override.value == 0.0))
	{
		Cvar_SetValue ("vid_wait", (float)VID_WAIT_DISPLAY_ENABLE);

		VID_displayedpage = 0;
		VID_currentpage = 1;
	}
	else
	{
		if ((lvid->numpages == 1) && (_vid_wait_override.value == 0.0))
		{
			Cvar_SetValue ("vid_wait", (float)VID_WAIT_NONE);
			VID_displayedpage = VID_currentpage = 0;
		}
		else
		{
			Cvar_SetValue ("vid_wait", (float)VID_WAIT_VSYNC);

			VID_displayedpage = 0;

			if (lvid->numpages > 1)
				VID_currentpage = 1;
			else
				VID_currentpage = 0;
		}
	}

// TODO: really should be a call to a function
	pageoffset = VID_pagelist[VID_displayedpage];

	regs.x.ax = 0x4f07;
	regs.x.bx = 0x80;	// wait for vsync so we know page 0 is visible
	regs.x.cx = pageoffset % VGA_rowbytes;
	regs.x.dx = pageoffset / VGA_rowbytes;
	dos_int86(0x10);

	if (VID_banked)
	{
		regs.x.ax = 0x4f05;
		regs.x.bx = 0;
		regs.x.dx = VID_currentpage;
		dos_int86(0x10);

		VGA_pagebase = VID_membase;
	}
	else
	{
		VGA_pagebase = VID_membase + VID_pagelist[VID_currentpage];
	}

	if (lvid->numpages > 1)
	{
		lvid->buffer = VGA_pagebase;
		lvid->conbuffer = lvid->buffer;
	}
	else
	{
		lvid->rowbytes = lvid->width;
	}

	lvid->direct = VGA_pagebase;
	lvid->conrowbytes = lvid->rowbytes;
	lvid->conwidth = lvid->width;
	lvid->conheight = lvid->height;

	lvid->maxwarpwidth = WARP_WIDTH;
	lvid->maxwarpheight = WARP_HEIGHT;

	VGA_pcurmode = pcurrentmode;

	D_InitCaches (vid_surfcache, vid_surfcachesize);

	return 1;
}
Esempio n. 9
0
void VID_Init (unsigned char *palette)
{
	DWORD		WindowStyle, ExWindowStyle;
	WNDCLASS		wc;
//	HDC				hdc;

	Cvar_Register (&vid_ref);

	vid.width = BASEWIDTH;
	vid.height = BASEHEIGHT;
	vid.aspect = ((float)vid.height / (float)vid.width) *
				(320.0 / 240.0);


//	vid.numpages = 1;
	vid.numpages = 2;	// TESTING

	vid.colormap = host_colormap;
	vid.buffer = vid_buffer;
	vid.rowbytes = BASEWIDTH;
	
	d_pzbuffer = zbuffer;

	D_InitCaches (surfcache, sizeof(surfcache));


	if (hwnd_dialog)
		DestroyWindow (hwnd_dialog);


//create window class
	hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_APPICON));

	/* Register the frame class */
	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC)MainWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = global_hInstance;
	wc.hIcon         = 0;
	wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName  = 0;
	wc.lpszClassName = "WinQuake";

	if (!RegisterClass (&wc) )
		Sys_Error ("Couldn't register window class");


//create main window
	WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
/*
	WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
				  WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS |
				  WS_CLIPCHILDREN;*/
	ExWindowStyle = 0;
	mainwindow = CreateWindowEx (
		ExWindowStyle,
		"WinQuake",
		PROGRAM,
		WindowStyle,
		0, 0,
		320,
		200,
		NULL,
		NULL,
		global_hInstance,
		NULL);
	
	if (!mainwindow)
		Sys_Error ("Couldn't create DIB window");

	ShowWindow (mainwindow, SW_SHOWDEFAULT);
	UpdateWindow (mainwindow);

	setcurrentpalette (palette);

	DDraw_Init ();

	window_width = vid.width;
	window_height = vid.height;

	VID_UpdateWindowStatus ();

	vid_initialized = true;
}