mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-10 11:59:58 -05:00
Quack 2
This commit is contained in:
committed by
GitHub
parent
b585e51a81
commit
e8bd66b89c
40
irix/cd_irix.c
Normal file
40
irix/cd_irix.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <sys/types.h>
|
||||
#include <cdaudio.h>
|
||||
|
||||
#include "../client/client.h"
|
||||
|
||||
void CDAudio_Play(int track, qboolean looping)
|
||||
{
|
||||
Com_Printf("XXX - CDAudio_Play %i (%i)\n", track, looping);
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Stop(void)
|
||||
{
|
||||
Com_Printf("XXX - CDAudio_Stop\n");
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Resume(void)
|
||||
{
|
||||
Com_Printf("XXX - CDAudio_Resume\n");
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Update(void)
|
||||
{
|
||||
/* Com_Printf("XXX - CDAudio_Update\n"); */
|
||||
}
|
||||
|
||||
|
||||
int CDAudio_Init(void)
|
||||
{
|
||||
Com_Printf("XXX - CDAudio_Init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Shutdown(void)
|
||||
{
|
||||
Com_Printf("XXX - CDAudio_Shutdown\n");
|
||||
}
|
927
irix/glw_imp.c
Normal file
927
irix/glw_imp.c
Normal file
@ -0,0 +1,927 @@
|
||||
/*
|
||||
** GLW_IMP.C
|
||||
**
|
||||
** This file contains ALL Linux specific stuff having to do with the
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
** must be implemented by the port:
|
||||
**
|
||||
** GLimp_EndFrame
|
||||
** GLimp_Init
|
||||
** GLimp_Shutdown
|
||||
** GLimp_SwitchFullscreen
|
||||
**
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include "../ref_gl/gl_local.h"
|
||||
#include "../client/keys.h"
|
||||
#include "../linux/rw_linux.h"
|
||||
|
||||
GLXContext gl_cx;
|
||||
|
||||
static qboolean doShm;
|
||||
static Display *x_disp;
|
||||
static Colormap x_cmap;
|
||||
static Window x_win;
|
||||
static GC x_gc;
|
||||
static Visual *x_vis;
|
||||
static XVisualInfo *x_visinfo;
|
||||
|
||||
static int StudlyRGBattributes[] =
|
||||
{
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 4,
|
||||
GLX_GREEN_SIZE, 4,
|
||||
GLX_BLUE_SIZE, 4,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
GLX_SAMPLES_SGIS, 4, /* for better AA */
|
||||
None,
|
||||
};
|
||||
|
||||
static int RGBattributes[] =
|
||||
{
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 4,
|
||||
GLX_GREEN_SIZE, 4,
|
||||
GLX_BLUE_SIZE, 4,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
None,
|
||||
};
|
||||
|
||||
#define STD_EVENT_MASK (StructureNotifyMask | KeyPressMask \
|
||||
| KeyReleaseMask | ExposureMask | PointerMotionMask | \
|
||||
ButtonPressMask | ButtonReleaseMask)
|
||||
|
||||
int current_framebuffer;
|
||||
static int x_shmeventtype;
|
||||
//static XShmSegmentInfo x_shminfo;
|
||||
|
||||
static qboolean oktodraw = false;
|
||||
static qboolean X11_active = false;
|
||||
|
||||
struct
|
||||
{
|
||||
int key;
|
||||
int down;
|
||||
} keyq[64];
|
||||
int keyq_head=0;
|
||||
int keyq_tail=0;
|
||||
|
||||
static int mx, my;
|
||||
static int p_mouse_x, p_mouse_y;
|
||||
static cvar_t *_windowed_mouse;
|
||||
|
||||
static cvar_t *sensitivity;
|
||||
static cvar_t *lookstrafe;
|
||||
static cvar_t *m_side;
|
||||
static cvar_t *m_yaw;
|
||||
static cvar_t *m_pitch;
|
||||
static cvar_t *m_forward;
|
||||
static cvar_t *freelook;
|
||||
|
||||
int config_notify=0;
|
||||
int config_notify_width;
|
||||
int config_notify_height;
|
||||
|
||||
typedef unsigned short PIXEL;
|
||||
|
||||
// Console variables that we need to access from this module
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MOUSE */
|
||||
/*****************************************************************************/
|
||||
|
||||
// this is inside the renderer shared lib, so these are called from vid_so
|
||||
|
||||
static qboolean mouse_avail;
|
||||
static int mouse_buttonstate;
|
||||
static int mouse_oldbuttonstate;
|
||||
static int mouse_x, mouse_y;
|
||||
static int old_mouse_x, old_mouse_y;
|
||||
static float old_windowed_mouse;
|
||||
static int p_mouse_x, p_mouse_y;
|
||||
|
||||
static cvar_t *_windowed_mouse;
|
||||
static cvar_t *m_filter;
|
||||
static cvar_t *in_mouse;
|
||||
|
||||
static qboolean mlooking;
|
||||
|
||||
// state struct passed in Init
|
||||
static in_state_t *in_state;
|
||||
|
||||
int XShmQueryExtension(Display *);
|
||||
int XShmGetEventBase(Display *);
|
||||
|
||||
static void signal_handler(int sig)
|
||||
{
|
||||
fprintf(stderr, "Received signal %d, exiting...\n", sig);
|
||||
GLimp_Shutdown();
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
static void InitSig(void)
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigaction(SIGINT, 0, &sa);
|
||||
sa.sa_handler = signal_handler;
|
||||
sigaction(SIGINT, &sa, 0);
|
||||
sigaction(SIGTERM, &sa, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_SetMode
|
||||
*/
|
||||
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
||||
{
|
||||
int width, height;
|
||||
GLint attribs[32];
|
||||
|
||||
fprintf(stderr, "GLimp_SetMode\n");
|
||||
|
||||
ri.Con_Printf( PRINT_ALL, "Initializing OpenGL display\n");
|
||||
|
||||
ri.Con_Printf (PRINT_ALL, "...setting mode %d:", mode );
|
||||
|
||||
if ( !ri.Vid_GetModeInfo( &width, &height, mode ) )
|
||||
{
|
||||
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
ri.Con_Printf( PRINT_ALL, " %d %d\n", width, height );
|
||||
|
||||
// destroy the existing window
|
||||
GLimp_Shutdown ();
|
||||
|
||||
*pwidth = width;
|
||||
*pheight = height;
|
||||
|
||||
if ( !GLimp_InitGraphics( fullscreen ) ) {
|
||||
// failed to set a valid mode in windowed mode
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
/* gl_cx = glXCreateContext( x_disp, x_visinfo, 0, True ); */
|
||||
|
||||
// let the sound and input subsystems know about the new window
|
||||
ri.Vid_NewWindow (width, height);
|
||||
|
||||
return rserr_ok;
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_Shutdown
|
||||
**
|
||||
** This routine does all OS specific shutdown procedures for the OpenGL
|
||||
** subsystem. Under OpenGL this means NULLing out the current DC and
|
||||
** HGLRC, deleting the rendering context, and releasing the DC acquired
|
||||
** for the window. The state structure is also nulled out.
|
||||
**
|
||||
*/
|
||||
void GLimp_Shutdown( void )
|
||||
{
|
||||
fprintf(stderr, "GLimp_Shutdown\n");
|
||||
|
||||
if (!x_disp)
|
||||
return;
|
||||
|
||||
XSynchronize( x_disp, True );
|
||||
XAutoRepeatOn(x_disp);
|
||||
XCloseDisplay(x_disp);
|
||||
x_disp = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_Init
|
||||
**
|
||||
** This routine is responsible for initializing the OS specific portions
|
||||
** of OpenGL.
|
||||
*/
|
||||
int GLimp_Init( void *hinstance, void *wndproc )
|
||||
{
|
||||
// catch signals so i can turn on auto-repeat and stuff
|
||||
InitSig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_BeginFrame
|
||||
*/
|
||||
void GLimp_BeginFrame( float camera_seperation )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_EndFrame
|
||||
**
|
||||
** Responsible for doing a swapbuffers and possibly for other stuff
|
||||
** as yet to be determined. Probably better not to make this a GLimp
|
||||
** function and instead do a call to GLimp_SwapBuffers.
|
||||
*/
|
||||
void GLimp_EndFrame (void)
|
||||
{
|
||||
glFlush();
|
||||
glXSwapBuffers( x_disp, x_win );
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_AppActivate
|
||||
*/
|
||||
void GLimp_AppActivate( qboolean active )
|
||||
{
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// makes a null cursor
|
||||
// ========================================================================
|
||||
|
||||
static Cursor CreateNullCursor(Display *display, Window root)
|
||||
{
|
||||
Pixmap cursormask;
|
||||
XGCValues xgc;
|
||||
GC gc;
|
||||
XColor dummycolour;
|
||||
Cursor cursor;
|
||||
|
||||
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
|
||||
xgc.function = GXclear;
|
||||
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
||||
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
||||
dummycolour.pixel = 0;
|
||||
dummycolour.red = 0;
|
||||
dummycolour.flags = 04;
|
||||
cursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
||||
&dummycolour,&dummycolour, 0,0);
|
||||
XFreePixmap(display,cursormask);
|
||||
XFreeGC(display,gc);
|
||||
return cursor;
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_InitGraphics
|
||||
**
|
||||
** This initializes the GL implementation specific
|
||||
** graphics subsystem.
|
||||
**
|
||||
** The necessary width and height parameters are grabbed from
|
||||
** vid.width and vid.height.
|
||||
*/
|
||||
qboolean GLimp_InitGraphics( qboolean fullscreen )
|
||||
{
|
||||
int pnum, i;
|
||||
XVisualInfo template;
|
||||
int num_visuals;
|
||||
int template_mask;
|
||||
|
||||
fprintf(stderr, "GLimp_InitGraphics\n");
|
||||
|
||||
srandom(getpid());
|
||||
|
||||
// let the sound and input subsystems know about the new window
|
||||
ri.Vid_NewWindow (vid.width, vid.height);
|
||||
|
||||
// open the display
|
||||
x_disp = XOpenDisplay(NULL);
|
||||
if (!x_disp)
|
||||
{
|
||||
if (getenv("DISPLAY"))
|
||||
Sys_Error("VID: Could not open display [%s]\n",
|
||||
getenv("DISPLAY"));
|
||||
else
|
||||
Sys_Error("VID: Could not open local display\n");
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "VID: Opened display %s\n", getenv("DISPLAY"));
|
||||
|
||||
XAutoRepeatOff(x_disp);
|
||||
|
||||
// for debugging only
|
||||
XSynchronize(x_disp, True);
|
||||
|
||||
// check for command-line window size
|
||||
template_mask = 0;
|
||||
|
||||
#if 0
|
||||
// specify a visual id
|
||||
if ((pnum=COM_CheckParm("-visualid")))
|
||||
{
|
||||
if (pnum >= com_argc-1)
|
||||
Sys_Error("VID: -visualid <id#>\n");
|
||||
template.visualid = Q_atoi(com_argv[pnum+1]);
|
||||
template_mask = VisualIDMask;
|
||||
}
|
||||
|
||||
// If not specified, use default visual
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int screen;
|
||||
screen = XDefaultScreen(x_disp);
|
||||
template.visualid =
|
||||
XVisualIDFromVisual(XDefaultVisual(x_disp, screen));
|
||||
template_mask = VisualIDMask;
|
||||
}
|
||||
|
||||
// pick a visual- warn if more than one was available
|
||||
|
||||
x_visinfo = glXChooseVisual( x_disp, DefaultScreen( x_disp ),
|
||||
StudlyRGBattributes );
|
||||
if (!x_visinfo)
|
||||
{
|
||||
fprintf(stderr, "Using non studly RGB attributes\n");
|
||||
x_visinfo = glXChooseVisual( x_disp, DefaultScreen( x_disp ),
|
||||
RGBattributes );
|
||||
if (!x_visinfo) Sys_Error( "No matching visual available!\n" );
|
||||
}
|
||||
|
||||
ri.Con_Printf(PRINT_ALL, "Using visualid 0x%x:\n",
|
||||
(int)(x_visinfo->visualid));
|
||||
#if 0
|
||||
if (verbose)
|
||||
{
|
||||
printf("Using visualid %d:\n", (int)(x_visinfo->visualid));
|
||||
printf(" screen %d\n", x_visinfo->screen);
|
||||
printf(" red_mask 0x%x\n", (int)(x_visinfo->red_mask));
|
||||
printf(" green_mask 0x%x\n", (int)(x_visinfo->green_mask));
|
||||
printf(" blue_mask 0x%x\n", (int)(x_visinfo->blue_mask));
|
||||
printf(" colormap_size %d\n", x_visinfo->colormap_size);
|
||||
printf(" bits_per_rgb %d\n", x_visinfo->bits_per_rgb);
|
||||
}
|
||||
#endif
|
||||
|
||||
x_vis = x_visinfo->visual;
|
||||
|
||||
// setup attributes for main window
|
||||
{
|
||||
int attribmask = CWEventMask | CWColormap | CWBorderPixel;
|
||||
XSetWindowAttributes attribs;
|
||||
Colormap tmpcmap;
|
||||
|
||||
Window root_win = XRootWindow(x_disp, x_visinfo->screen);
|
||||
|
||||
tmpcmap = XCreateColormap(x_disp, root_win, x_vis, AllocNone);
|
||||
|
||||
|
||||
attribs.event_mask = STD_EVENT_MASK;
|
||||
attribs.border_pixel = 0;
|
||||
attribs.colormap = tmpcmap;
|
||||
|
||||
// create the main window
|
||||
x_win = XCreateWindow( x_disp,
|
||||
root_win,
|
||||
0, 0, // x, y
|
||||
vid.width, vid.height,
|
||||
0, // borderwidth
|
||||
x_visinfo->depth,
|
||||
InputOutput,
|
||||
x_vis,
|
||||
attribmask,
|
||||
&attribs );
|
||||
XStoreName(x_disp, x_win, "Quake II");
|
||||
|
||||
if (x_visinfo->class != TrueColor)
|
||||
XFreeColormap(x_disp, tmpcmap);
|
||||
}
|
||||
|
||||
if (x_visinfo->depth == 8)
|
||||
{
|
||||
// create and upload the palette
|
||||
if (x_visinfo->class == PseudoColor)
|
||||
{
|
||||
x_cmap = XCreateColormap(x_disp, x_win, x_vis, AllocAll);
|
||||
XSetWindowColormap(x_disp, x_win, x_cmap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// inviso cursor
|
||||
XDefineCursor(x_disp, x_win, CreateNullCursor(x_disp, x_win));
|
||||
|
||||
// create the GC
|
||||
{
|
||||
XGCValues xgcvalues;
|
||||
int valuemask = GCGraphicsExposures;
|
||||
xgcvalues.graphics_exposures = False;
|
||||
x_gc = XCreateGC(x_disp, x_win, valuemask, &xgcvalues );
|
||||
}
|
||||
|
||||
// set window properties for full screen
|
||||
if (fullscreen) {
|
||||
MotifWmHints wmhints;
|
||||
Atom aHints;
|
||||
XSizeHints sizehints;
|
||||
XWindowChanges changes;
|
||||
|
||||
aHints = XInternAtom( x_disp, "_MOTIF_WM_HINTS", 0 );
|
||||
if (aHints == None)
|
||||
{
|
||||
ri.Con_Printf( PRINT_ALL, "Could not intern X atom for _MOTIF_WM_HINTS." );
|
||||
/* return( false ); */
|
||||
}
|
||||
else {
|
||||
wmhints.flags = MWM_HINTS_DECORATIONS;
|
||||
wmhints.decorations = 0; // Absolutely no decorations.
|
||||
XChangeProperty(x_disp, x_win, aHints, aHints, 32,
|
||||
PropModeReplace, (unsigned char *)&wmhints,
|
||||
4 );
|
||||
|
||||
sizehints.flags = USPosition | USSize;
|
||||
sizehints.x = 0;
|
||||
sizehints.y = 0;
|
||||
sizehints.width = vid.width;
|
||||
sizehints.height = vid.height;
|
||||
XSetWMNormalHints( x_disp, x_win, &sizehints );
|
||||
|
||||
changes.x = 0;
|
||||
changes.y = 0;
|
||||
changes.width = vid.width;
|
||||
changes.height = vid.height;
|
||||
changes.stack_mode = TopIf;
|
||||
XConfigureWindow(x_disp, x_win,
|
||||
CWX | CWY | CWWidth | CWHeight | CWStackMode,
|
||||
&changes);
|
||||
}
|
||||
}
|
||||
|
||||
// map the window
|
||||
XMapWindow(x_disp, x_win);
|
||||
|
||||
// wait for first exposure event
|
||||
{
|
||||
XEvent event;
|
||||
do
|
||||
{
|
||||
XNextEvent(x_disp, &event);
|
||||
if (event.type == Expose && !event.xexpose.count)
|
||||
oktodraw = true;
|
||||
} while (!oktodraw);
|
||||
}
|
||||
// now safe to draw
|
||||
|
||||
gl_cx = glXCreateContext( x_disp, x_visinfo, 0, True );
|
||||
if (!glXMakeCurrent( x_disp, x_win, gl_cx ))
|
||||
Sys_Error( "Can't make window current to context\n" );
|
||||
|
||||
// even if MITSHM is available, make sure it's a local connection
|
||||
#if 0
|
||||
// This is messing up the DISPLAY environment variable so can't close and
|
||||
// reopen the window (it lops off the :0.0)...
|
||||
if (XShmQueryExtension(x_disp))
|
||||
{
|
||||
char *displayname;
|
||||
doShm = true;
|
||||
displayname = (char *) getenv("DISPLAY");
|
||||
if (displayname)
|
||||
{
|
||||
char *d = displayname;
|
||||
while (*d && (*d != ':')) d++;
|
||||
if (*d) *d = 0;
|
||||
if (!(!strcasecmp(displayname, "unix") || !*displayname))
|
||||
doShm = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (doShm)
|
||||
{
|
||||
x_shmeventtype = XShmGetEventBase(x_disp) + ShmCompletion;
|
||||
ResetSharedFrameBuffers();
|
||||
}
|
||||
else
|
||||
ResetFrameBuffer();
|
||||
#endif
|
||||
|
||||
current_framebuffer = 0;
|
||||
/* vid.rowbytes = x_framebuffer[0]->bytes_per_line; */
|
||||
/* vid.buffer = x_framebuffer[0]->data; */
|
||||
|
||||
// XSynchronize(x_disp, False);
|
||||
|
||||
X11_active = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int XLateKey(XKeyEvent *ev)
|
||||
{
|
||||
|
||||
int key;
|
||||
char buf[64];
|
||||
KeySym keysym;
|
||||
|
||||
key = 0;
|
||||
|
||||
XLookupString(ev, buf, sizeof buf, &keysym, 0);
|
||||
|
||||
switch(keysym)
|
||||
{
|
||||
case XK_KP_Page_Up: key = K_KP_PGUP; break;
|
||||
case XK_Page_Up: key = K_PGUP; break;
|
||||
|
||||
case XK_KP_Page_Down: key = K_KP_PGDN; break;
|
||||
case XK_Page_Down: key = K_PGDN; break;
|
||||
|
||||
case XK_KP_Home: key = K_KP_HOME; break;
|
||||
case XK_Home: key = K_HOME; break;
|
||||
|
||||
case XK_KP_End: key = K_KP_END; break;
|
||||
case XK_End: key = K_END; break;
|
||||
|
||||
case XK_KP_Left: key = K_KP_LEFTARROW; break;
|
||||
case XK_Left: key = K_LEFTARROW; break;
|
||||
|
||||
case XK_KP_Right: key = K_KP_RIGHTARROW; break;
|
||||
case XK_Right: key = K_RIGHTARROW; break;
|
||||
|
||||
case XK_KP_Down: key = K_KP_DOWNARROW; break;
|
||||
case XK_Down: key = K_DOWNARROW; break;
|
||||
|
||||
case XK_KP_Up: key = K_KP_UPARROW; break;
|
||||
case XK_Up: key = K_UPARROW; break;
|
||||
|
||||
case XK_Escape: key = K_ESCAPE; break;
|
||||
|
||||
case XK_KP_Enter: key = K_KP_ENTER; break;
|
||||
case XK_Return: key = K_ENTER; break;
|
||||
|
||||
case XK_Tab: key = K_TAB; break;
|
||||
|
||||
case XK_F1: key = K_F1; break;
|
||||
|
||||
case XK_F2: key = K_F2; break;
|
||||
|
||||
case XK_F3: key = K_F3; break;
|
||||
|
||||
case XK_F4: key = K_F4; break;
|
||||
|
||||
case XK_F5: key = K_F5; break;
|
||||
|
||||
case XK_F6: key = K_F6; break;
|
||||
|
||||
case XK_F7: key = K_F7; break;
|
||||
|
||||
case XK_F8: key = K_F8; break;
|
||||
|
||||
case XK_F9: key = K_F9; break;
|
||||
|
||||
case XK_F10: key = K_F10; break;
|
||||
|
||||
case XK_F11: key = K_F11; break;
|
||||
|
||||
case XK_F12: key = K_F12; break;
|
||||
|
||||
case XK_BackSpace: key = K_BACKSPACE; break;
|
||||
|
||||
case XK_KP_Delete: key = K_KP_DEL; break;
|
||||
case XK_Delete: key = K_DEL; break;
|
||||
|
||||
case XK_Pause: key = K_PAUSE; break;
|
||||
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R: key = K_SHIFT; break;
|
||||
|
||||
case XK_Execute:
|
||||
case XK_Control_L:
|
||||
case XK_Control_R: key = K_CTRL; break;
|
||||
|
||||
case XK_Alt_L:
|
||||
case XK_Meta_L:
|
||||
case XK_Alt_R:
|
||||
case XK_Meta_R: key = K_ALT; break;
|
||||
|
||||
case XK_KP_Begin: key = K_KP_5; break;
|
||||
|
||||
case XK_Insert:key = K_INS; break;
|
||||
case XK_KP_Insert: key = K_KP_INS; break;
|
||||
|
||||
case XK_KP_Multiply: key = '*'; break;
|
||||
case XK_KP_Add: key = K_KP_PLUS; break;
|
||||
case XK_KP_Subtract: key = K_KP_MINUS; break;
|
||||
case XK_KP_Divide: key = K_KP_SLASH; break;
|
||||
|
||||
#if 0
|
||||
case 0x021: key = '1';break;/* [!] */
|
||||
case 0x040: key = '2';break;/* [@] */
|
||||
case 0x023: key = '3';break;/* [#] */
|
||||
case 0x024: key = '4';break;/* [$] */
|
||||
case 0x025: key = '5';break;/* [%] */
|
||||
case 0x05e: key = '6';break;/* [^] */
|
||||
case 0x026: key = '7';break;/* [&] */
|
||||
case 0x02a: key = '8';break;/* [*] */
|
||||
case 0x028: key = '9';;break;/* [(] */
|
||||
case 0x029: key = '0';break;/* [)] */
|
||||
case 0x05f: key = '-';break;/* [_] */
|
||||
case 0x02b: key = '=';break;/* [+] */
|
||||
case 0x07c: key = '\'';break;/* [|] */
|
||||
case 0x07d: key = '[';break;/* [}] */
|
||||
case 0x07b: key = ']';break;/* [{] */
|
||||
case 0x022: key = '\'';break;/* ["] */
|
||||
case 0x03a: key = ';';break;/* [:] */
|
||||
case 0x03f: key = '/';break;/* [?] */
|
||||
case 0x03e: key = '.';break;/* [>] */
|
||||
case 0x03c: key = ',';break;/* [<] */
|
||||
#endif
|
||||
|
||||
default:
|
||||
key = *(unsigned char*)buf;
|
||||
if (key >= 'A' && key <= 'Z')
|
||||
key = key - 'A' + 'a';
|
||||
break;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void GetEvent(void)
|
||||
{
|
||||
XEvent x_event;
|
||||
int b;
|
||||
|
||||
XNextEvent(x_disp, &x_event);
|
||||
switch(x_event.type) {
|
||||
case KeyPress:
|
||||
keyq[keyq_head].key = XLateKey(&x_event.xkey);
|
||||
keyq[keyq_head].down = true;
|
||||
keyq_head = (keyq_head + 1) & 63;
|
||||
break;
|
||||
case KeyRelease:
|
||||
keyq[keyq_head].key = XLateKey(&x_event.xkey);
|
||||
keyq[keyq_head].down = false;
|
||||
keyq_head = (keyq_head + 1) & 63;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (_windowed_mouse->value) {
|
||||
mx += ((int)x_event.xmotion.x - (int)(vid.width/2));
|
||||
my += ((int)x_event.xmotion.y - (int)(vid.height/2));
|
||||
|
||||
/* move the mouse to the window center again */
|
||||
XSelectInput(x_disp,x_win, STD_EVENT_MASK & ~PointerMotionMask);
|
||||
XWarpPointer(x_disp,None,x_win,0,0,0,0,
|
||||
(vid.width/2),(vid.height/2));
|
||||
XSelectInput(x_disp,x_win, STD_EVENT_MASK);
|
||||
} else {
|
||||
mx = ((int)x_event.xmotion.x - (int)p_mouse_x);
|
||||
my = ((int)x_event.xmotion.y - (int)p_mouse_y);
|
||||
p_mouse_x=x_event.xmotion.x;
|
||||
p_mouse_y=x_event.xmotion.y;
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
b=-1;
|
||||
if (x_event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (x_event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (x_event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
mouse_buttonstate |= 1<<b;
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
b=-1;
|
||||
if (x_event.xbutton.button == 1)
|
||||
b = 0;
|
||||
else if (x_event.xbutton.button == 2)
|
||||
b = 2;
|
||||
else if (x_event.xbutton.button == 3)
|
||||
b = 1;
|
||||
if (b>=0)
|
||||
mouse_buttonstate &= ~(1<<b);
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
config_notify_width = x_event.xconfigure.width;
|
||||
config_notify_height = x_event.xconfigure.height;
|
||||
config_notify = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (doShm && x_event.type == x_shmeventtype)
|
||||
oktodraw = true;
|
||||
}
|
||||
|
||||
if (old_windowed_mouse != _windowed_mouse->value) {
|
||||
old_windowed_mouse = _windowed_mouse->value;
|
||||
|
||||
if (!_windowed_mouse->value) {
|
||||
/* ungrab the pointer */
|
||||
XUngrabPointer(x_disp,CurrentTime);
|
||||
} else {
|
||||
/* grab the pointer */
|
||||
XGrabPointer(x_disp,x_win,True,0,GrabModeAsync,
|
||||
GrabModeAsync,x_win,None,CurrentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* KEYBOARD */
|
||||
/*****************************************************************************/
|
||||
|
||||
Key_Event_fp_t Key_Event_fp;
|
||||
|
||||
void KBD_Init(Key_Event_fp_t fp)
|
||||
{
|
||||
_windowed_mouse = ri.Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE);
|
||||
Key_Event_fp = fp;
|
||||
}
|
||||
|
||||
void KBD_Update(void)
|
||||
{
|
||||
// get events from x server
|
||||
if (x_disp)
|
||||
{
|
||||
while (XPending(x_disp))
|
||||
GetEvent();
|
||||
while (keyq_head != keyq_tail)
|
||||
{
|
||||
Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down);
|
||||
keyq_tail = (keyq_tail + 1) & 63;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KBD_Close(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void Force_CenterView_f (void)
|
||||
{
|
||||
in_state->viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
static void RW_IN_MLookDown (void)
|
||||
{
|
||||
mlooking = true;
|
||||
}
|
||||
|
||||
static void RW_IN_MLookUp (void)
|
||||
{
|
||||
mlooking = false;
|
||||
in_state->IN_CenterView_fp ();
|
||||
}
|
||||
|
||||
void RW_IN_Init(in_state_t *in_state_p)
|
||||
{
|
||||
int mtype;
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "GL RW_IN_Init\n");
|
||||
|
||||
in_state = in_state_p;
|
||||
|
||||
// mouse variables
|
||||
_windowed_mouse = ri.Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE);
|
||||
m_filter = ri.Cvar_Get ("m_filter", "0", 0);
|
||||
in_mouse = ri.Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
||||
freelook = ri.Cvar_Get( "freelook", "0", 0 );
|
||||
lookstrafe = ri.Cvar_Get ("lookstrafe", "0", 0);
|
||||
sensitivity = ri.Cvar_Get ("sensitivity", "3", 0);
|
||||
m_pitch = ri.Cvar_Get ("m_pitch", "0.022", 0);
|
||||
m_yaw = ri.Cvar_Get ("m_yaw", "0.022", 0);
|
||||
m_forward = ri.Cvar_Get ("m_forward", "1", 0);
|
||||
m_side = ri.Cvar_Get ("m_side", "0.8", 0);
|
||||
|
||||
ri.Cmd_AddCommand ("+mlook", RW_IN_MLookDown);
|
||||
ri.Cmd_AddCommand ("-mlook", RW_IN_MLookUp);
|
||||
|
||||
ri.Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
||||
|
||||
mouse_x = mouse_y = 0.0;
|
||||
mouse_avail = true;
|
||||
}
|
||||
|
||||
void RW_IN_Shutdown(void)
|
||||
{
|
||||
mouse_avail = false;
|
||||
|
||||
ri.Cmd_RemoveCommand ("force_centerview");
|
||||
ri.Cmd_RemoveCommand ("+mlook");
|
||||
ri.Cmd_RemoveCommand ("-mlook");
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Commands
|
||||
===========
|
||||
*/
|
||||
void RW_IN_Commands (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!mouse_avail)
|
||||
return;
|
||||
|
||||
for (i=0 ; i<3 ; i++) {
|
||||
if ( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) )
|
||||
in_state->Key_Event_fp (K_MOUSE1 + i, true);
|
||||
|
||||
if ( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) )
|
||||
in_state->Key_Event_fp (K_MOUSE1 + i, false);
|
||||
}
|
||||
mouse_oldbuttonstate = mouse_buttonstate;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void RW_IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
if (!mouse_avail)
|
||||
return;
|
||||
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
} else {
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
|
||||
if (!mouse_x && !mouse_y)
|
||||
return;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (*in_state->in_strafe_state & 1) ||
|
||||
(lookstrafe->value && mlooking ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
in_state->viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if ( (mlooking || freelook->value) &&
|
||||
!(*in_state->in_strafe_state & 1))
|
||||
{
|
||||
in_state->viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
mx = my = 0;
|
||||
}
|
||||
|
||||
void RW_IN_Frame (void)
|
||||
{
|
||||
}
|
||||
|
||||
void RW_IN_Activate(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//===============================================================================
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_MakeCodeWriteable
|
||||
================
|
||||
*/
|
||||
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
||||
{
|
||||
|
||||
int r;
|
||||
unsigned long addr;
|
||||
int psize = getpagesize();
|
||||
|
||||
addr = (startaddr & ~(psize-1)) - psize;
|
||||
|
||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
||||
// addr, startaddr+length, length);
|
||||
|
||||
r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
|
||||
|
||||
if (r < 0)
|
||||
Sys_Error("Protection change failed\n");
|
||||
|
||||
}
|
200
irix/q_shirix.c
Normal file
200
irix/q_shirix.c
Normal file
@ -0,0 +1,200 @@
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "../linux/glob.h"
|
||||
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
//===============================================================================
|
||||
|
||||
byte *membase;
|
||||
int maxhunksize;
|
||||
int curhunksize;
|
||||
|
||||
void *Hunk_Begin (int maxsize)
|
||||
{
|
||||
maxhunksize = maxsize + sizeof(int);
|
||||
curhunksize = 0;
|
||||
/* membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, */
|
||||
/* MAP_PRIVATE, -1, 0); */
|
||||
/* if ((membase == NULL) || (membase == MAP_FAILED)) */
|
||||
membase = malloc(maxhunksize);
|
||||
if (membase == NULL)
|
||||
Com_Error(ERR_FATAL, "unable to virtual allocate %d bytes", maxsize);
|
||||
|
||||
*((int *)membase) = curhunksize;
|
||||
|
||||
return membase + sizeof(int);
|
||||
}
|
||||
|
||||
void *Hunk_Alloc (int size)
|
||||
{
|
||||
byte *buf;
|
||||
|
||||
// round to cacheline
|
||||
size = (size+31)&~31;
|
||||
if (curhunksize + size > maxhunksize)
|
||||
Com_Error(ERR_FATAL, "Hunk_Alloc overflow");
|
||||
buf = membase + sizeof(int) + curhunksize;
|
||||
curhunksize += size;
|
||||
return buf;
|
||||
}
|
||||
|
||||
int Hunk_End (void)
|
||||
{
|
||||
return curhunksize;
|
||||
}
|
||||
|
||||
void Hunk_Free (void *base)
|
||||
{
|
||||
byte *m;
|
||||
|
||||
if (base) {
|
||||
m = ((byte *)base) - sizeof(int);
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_Milliseconds
|
||||
================
|
||||
*/
|
||||
int curtime;
|
||||
int Sys_Milliseconds (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec/1000;
|
||||
}
|
||||
|
||||
curtime = (tp.tv_sec - secbase)*1000 + tp.tv_usec/1000;
|
||||
|
||||
return curtime;
|
||||
}
|
||||
|
||||
void Sys_Mkdir (char *path)
|
||||
{
|
||||
mkdir (path, 0777);
|
||||
}
|
||||
|
||||
char *strlwr (char *s)
|
||||
{
|
||||
char *origs = s;
|
||||
while (*s) {
|
||||
*s = tolower(*s);
|
||||
s++;
|
||||
}
|
||||
return origs;
|
||||
}
|
||||
|
||||
//============================================
|
||||
|
||||
static char findbase[MAX_OSPATH];
|
||||
static char findpath[MAX_OSPATH];
|
||||
static char findpattern[MAX_OSPATH];
|
||||
static DIR *fdir;
|
||||
|
||||
static qboolean CompareAttributes(char *path, char *name,
|
||||
unsigned musthave, unsigned canthave )
|
||||
{
|
||||
struct stat st;
|
||||
char fn[MAX_OSPATH];
|
||||
|
||||
// . and .. never match
|
||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
|
||||
return false;
|
||||
|
||||
sprintf(fn, "%s/%s", path, name);
|
||||
if (stat(fn, &st) == -1)
|
||||
return false; // shouldn't happen
|
||||
|
||||
if ( ( st.st_mode & S_IFDIR ) && ( canthave & SFF_SUBDIR ) )
|
||||
return false;
|
||||
|
||||
if ( ( musthave & SFF_SUBDIR ) && !( st.st_mode & S_IFDIR ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char *Sys_FindFirst (char *path, unsigned musthave, unsigned canhave)
|
||||
{
|
||||
struct dirent *d;
|
||||
char *p;
|
||||
|
||||
if (fdir)
|
||||
Sys_Error ("Sys_BeginFind without close");
|
||||
|
||||
// COM_FilePath (path, findbase);
|
||||
strcpy(findbase, path);
|
||||
|
||||
if ((p = strrchr(findbase, '/')) != NULL) {
|
||||
*p = 0;
|
||||
strcpy(findpattern, p + 1);
|
||||
} else
|
||||
strcpy(findpattern, "*");
|
||||
|
||||
if (strcmp(findpattern, "*.*") == 0)
|
||||
strcpy(findpattern, "*");
|
||||
|
||||
if ((fdir = opendir(findbase)) == NULL)
|
||||
return NULL;
|
||||
while ((d = readdir(fdir)) != NULL) {
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name)) {
|
||||
// if (*findpattern)
|
||||
// printf("%s matched %s\n", findpattern, d->d_name);
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave)) {
|
||||
sprintf (findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *Sys_FindNext (unsigned musthave, unsigned canhave)
|
||||
{
|
||||
struct dirent *d;
|
||||
|
||||
if (fdir == NULL)
|
||||
return NULL;
|
||||
while ((d = readdir(fdir)) != NULL) {
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name)) {
|
||||
// if (*findpattern)
|
||||
// printf("%s matched %s\n", findpattern, d->d_name);
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave)) {
|
||||
sprintf (findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Sys_FindClose (void)
|
||||
{
|
||||
if (fdir != NULL)
|
||||
closedir(fdir);
|
||||
fdir = NULL;
|
||||
}
|
||||
|
||||
|
||||
//============================================
|
||||
|
3997
irix/qgl_irix.c
Normal file
3997
irix/qgl_irix.c
Normal file
File diff suppressed because it is too large
Load Diff
222
irix/snd_irix.c
Normal file
222
irix/snd_irix.c
Normal file
@ -0,0 +1,222 @@
|
||||
#include <dmedia/dmedia.h>
|
||||
#include <dmedia/audio.h>
|
||||
|
||||
#include "../client/client.h"
|
||||
#include "../client/snd_loc.h"
|
||||
|
||||
/*
|
||||
==================
|
||||
SNDDM_Init
|
||||
|
||||
Try to find a sound device to mix for.
|
||||
Returns false if nothing is found.
|
||||
Returns true and fills in the "dma" structure with information for the mixer.
|
||||
==================
|
||||
*/
|
||||
|
||||
// must be power of two!
|
||||
#define QSND_SKID 2
|
||||
#define QSND_BUFFER_FRAMES 8192
|
||||
#define QSND_BUFFER_SIZE (QSND_BUFFER_FRAMES*2)
|
||||
|
||||
#define UST_TO_BUFFPOS(ust) ((int)((ust) & (QSND_BUFFER_FRAMES - 1)) << 1)
|
||||
|
||||
cvar_t *s_loadas8bit;
|
||||
cvar_t *s_khz;
|
||||
cvar_t *sndchannels;
|
||||
|
||||
short int dma_buffer[QSND_BUFFER_SIZE];
|
||||
ALport sgisnd_aport = NULL;
|
||||
long long sgisnd_startframe;
|
||||
double sgisnd_frames_per_ns;
|
||||
long long sgisnd_lastframewritten = 0;
|
||||
|
||||
qboolean SNDDMA_Init(void)
|
||||
{
|
||||
ALconfig ac = NULL;
|
||||
ALpv pvbuf[2];
|
||||
|
||||
s_loadas8bit = Cvar_Get("s_loadas8bit", "16", CVAR_ARCHIVE);
|
||||
if ((int)s_loadas8bit->value)
|
||||
dma.samplebits = 8;
|
||||
else
|
||||
dma.samplebits = 16;
|
||||
|
||||
if (dma.samplebits != 16) {
|
||||
Com_Printf("Don't currently support %i-bit data. Forcing 16-bit.\n",
|
||||
dma.samplebits);
|
||||
dma.samplebits = 16;
|
||||
Cvar_SetValue( "s_loadas8bit", false );
|
||||
}
|
||||
|
||||
s_khz = Cvar_Get("s_khz", "0", CVAR_ARCHIVE);
|
||||
switch ((int)s_khz->value) {
|
||||
case 48:
|
||||
dma.speed = AL_RATE_48000;
|
||||
break;
|
||||
case 44:
|
||||
dma.speed = AL_RATE_44100;
|
||||
break;
|
||||
case 32:
|
||||
dma.speed = AL_RATE_32000;
|
||||
break;
|
||||
case 22:
|
||||
dma.speed = AL_RATE_22050;
|
||||
break;
|
||||
case 16:
|
||||
dma.speed = AL_RATE_16000;
|
||||
break;
|
||||
case 11:
|
||||
dma.speed = AL_RATE_11025;
|
||||
break;
|
||||
case 8:
|
||||
dma.speed = AL_RATE_8000;
|
||||
break;
|
||||
default:
|
||||
dma.speed = AL_RATE_22050;
|
||||
Com_Printf("Don't currently support %i kHz sample rate. Using %i.\n",
|
||||
(int)s_khz->value, (int)(dma.speed/1000));
|
||||
}
|
||||
|
||||
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
|
||||
dma.channels = (int)sndchannels->value;
|
||||
if (dma.channels != 2)
|
||||
Com_Printf("Don't currently support %i sound channels. Try 2.\n",
|
||||
sndchannels);
|
||||
|
||||
/***********************/
|
||||
|
||||
ac = alNewConfig();
|
||||
alSetChannels( ac, AL_STEREO );
|
||||
alSetSampFmt( ac, AL_SAMPFMT_TWOSCOMP );
|
||||
alSetQueueSize( ac, QSND_BUFFER_FRAMES );
|
||||
if (dma.samplebits == 8)
|
||||
alSetWidth( ac, AL_SAMPLE_8 );
|
||||
else
|
||||
alSetWidth( ac, AL_SAMPLE_16 );
|
||||
|
||||
sgisnd_aport = alOpenPort( "Quake", "w", ac );
|
||||
if (!sgisnd_aport)
|
||||
{
|
||||
printf( "failed to open audio port!\n" );
|
||||
}
|
||||
|
||||
// set desired sample rate
|
||||
pvbuf[0].param = AL_MASTER_CLOCK;
|
||||
pvbuf[0].value.i = AL_CRYSTAL_MCLK_TYPE;
|
||||
pvbuf[1].param = AL_RATE;
|
||||
pvbuf[1].value.ll = alIntToFixed( dma.speed );
|
||||
alSetParams( alGetResource( sgisnd_aport ), pvbuf, 2 );
|
||||
if (pvbuf[1].sizeOut < 0)
|
||||
printf( "illegal sample rate %d\n", dma.speed );
|
||||
|
||||
sgisnd_frames_per_ns = dma.speed * 1.0e-9;
|
||||
|
||||
dma.samples = sizeof(dma_buffer)/(dma.samplebits/8);
|
||||
dma.submission_chunk = 1;
|
||||
|
||||
dma.buffer = (unsigned char *)dma_buffer;
|
||||
|
||||
dma.samplepos = 0;
|
||||
|
||||
alFreeConfig( ac );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SNDDMA_GetDMAPos
|
||||
|
||||
return the current sample position (in mono samples, not stereo)
|
||||
inside the recirculating dma buffer, so the mixing code will know
|
||||
how many sample are required to fill it up.
|
||||
===============
|
||||
*/
|
||||
int SNDDMA_GetDMAPos(void)
|
||||
{
|
||||
long long ustFuture, ustNow;
|
||||
if (!sgisnd_aport) return( 0 );
|
||||
alGetFrameTime( sgisnd_aport, &sgisnd_startframe, &ustFuture );
|
||||
dmGetUST( (unsigned long long *)&ustNow );
|
||||
sgisnd_startframe -= (long long)((ustFuture - ustNow) * sgisnd_frames_per_ns);
|
||||
sgisnd_startframe += 100;
|
||||
//printf( "frame %ld pos %d\n", frame, UST_TO_BUFFPOS( sgisnd_startframe ) );
|
||||
return( UST_TO_BUFFPOS( sgisnd_startframe ) );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SNDDMA_Shutdown
|
||||
|
||||
Reset the sound device for exiting
|
||||
===============
|
||||
*/
|
||||
void SNDDMA_Shutdown(void)
|
||||
{
|
||||
if (sgisnd_aport) alClosePort( sgisnd_aport ), sgisnd_aport = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SNDDMA_Submit
|
||||
|
||||
Send sound to device if buffer isn't really the dma buffer
|
||||
===============
|
||||
*/
|
||||
|
||||
extern int soundtime;
|
||||
|
||||
void SNDDMA_Submit(void)
|
||||
{
|
||||
int nFillable, nFilled, nPos;
|
||||
int nFrames, nFramesLeft;
|
||||
unsigned endtime;
|
||||
|
||||
if (!sgisnd_aport) return;
|
||||
|
||||
nFillable = alGetFillable( sgisnd_aport );
|
||||
nFilled = QSND_BUFFER_FRAMES - nFillable;
|
||||
|
||||
nFrames = dma.samples >> (dma.channels - 1);
|
||||
|
||||
if (paintedtime - soundtime < nFrames)
|
||||
nFrames = paintedtime - soundtime;
|
||||
|
||||
if (nFrames <= QSND_SKID) return;
|
||||
|
||||
nPos = UST_TO_BUFFPOS( sgisnd_startframe );
|
||||
|
||||
// dump re-written contents of the buffer
|
||||
if (sgisnd_lastframewritten > sgisnd_startframe)
|
||||
{
|
||||
alDiscardFrames( sgisnd_aport, sgisnd_lastframewritten - sgisnd_startframe );
|
||||
}
|
||||
else if ((int)(sgisnd_startframe - sgisnd_lastframewritten) >= QSND_BUFFER_FRAMES)
|
||||
{
|
||||
// blow away everything if we've underflowed
|
||||
alDiscardFrames( sgisnd_aport, QSND_BUFFER_FRAMES );
|
||||
}
|
||||
|
||||
// don't block
|
||||
if (nFrames > nFillable) nFrames = nFillable;
|
||||
|
||||
// account for stereo
|
||||
nFramesLeft = nFrames;
|
||||
if (nPos + nFrames * dma.channels > QSND_BUFFER_SIZE)
|
||||
{
|
||||
int nFramesAtEnd = (QSND_BUFFER_SIZE - nPos) >> (dma.channels - 1);
|
||||
|
||||
alWriteFrames( sgisnd_aport, &dma_buffer[nPos], nFramesAtEnd );
|
||||
nPos = 0;
|
||||
nFramesLeft -= nFramesAtEnd;
|
||||
}
|
||||
alWriteFrames( sgisnd_aport, &dma_buffer[nPos], nFramesLeft );
|
||||
|
||||
sgisnd_lastframewritten = sgisnd_startframe + nFrames;
|
||||
}
|
||||
|
||||
void SNDDMA_BeginPainting (void)
|
||||
{
|
||||
}
|
383
irix/sys_irix.c
Normal file
383
irix/sys_irix.c
Normal file
@ -0,0 +1,383 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <mntent.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#include "../linux/rw_linux.h"
|
||||
|
||||
cvar_t *nostdout;
|
||||
|
||||
unsigned sys_frame_time;
|
||||
|
||||
uid_t saved_euid;
|
||||
qboolean stdin_active = true;
|
||||
|
||||
// =======================================================================
|
||||
// General routines
|
||||
// =======================================================================
|
||||
|
||||
void Sys_ConsoleOutput (char *string)
|
||||
{
|
||||
if (nostdout && nostdout->value)
|
||||
return;
|
||||
|
||||
fputs(string, stdout);
|
||||
}
|
||||
|
||||
void Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
unsigned char *p;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vsprintf (text,fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
if (strlen(text) > sizeof(text))
|
||||
Sys_Error("memory overwrite in Sys_Printf");
|
||||
|
||||
if (nostdout && nostdout->value)
|
||||
return;
|
||||
|
||||
for (p = (unsigned char *)text; *p; p++) {
|
||||
*p &= 0x7f;
|
||||
if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
|
||||
printf("[%02x]", *p);
|
||||
else
|
||||
putc(*p, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
void Sys_Quit (void)
|
||||
{
|
||||
CL_Shutdown ();
|
||||
Qcommon_Shutdown ();
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
void Sys_Init(void)
|
||||
{
|
||||
#if id386
|
||||
// Sys_SetFPCW();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Sys_Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
// change stdin to non blocking
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||
|
||||
va_start (argptr,error);
|
||||
vsprintf (string,error,argptr);
|
||||
va_end (argptr);
|
||||
fprintf(stderr, "Error: %s\n", string);
|
||||
|
||||
CL_Shutdown ();
|
||||
Qcommon_Shutdown ();
|
||||
_exit (1);
|
||||
|
||||
}
|
||||
|
||||
void Sys_Warn (char *warning, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
va_start (argptr,warning);
|
||||
vsprintf (string,warning,argptr);
|
||||
va_end (argptr);
|
||||
fprintf(stderr, "Warning: %s", string);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Sys_FileTime
|
||||
|
||||
returns -1 if not present
|
||||
============
|
||||
*/
|
||||
int Sys_FileTime (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (stat (path,&buf) == -1)
|
||||
return -1;
|
||||
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
void floating_point_exception_handler(int whatever)
|
||||
{
|
||||
// Sys_Warn("floating point exception\n");
|
||||
signal(SIGFPE, floating_point_exception_handler);
|
||||
}
|
||||
|
||||
char *Sys_ConsoleInput(void)
|
||||
{
|
||||
static char text[256];
|
||||
int len;
|
||||
fd_set fdset;
|
||||
struct timeval timeout;
|
||||
|
||||
if (!dedicated || !dedicated->value)
|
||||
return NULL;
|
||||
|
||||
if (!stdin_active)
|
||||
return NULL;
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(0, &fdset); // stdin
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))
|
||||
return NULL;
|
||||
|
||||
len = read (0, text, sizeof(text));
|
||||
if (len == 0) { // eof!
|
||||
stdin_active = false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (len < 1)
|
||||
return NULL;
|
||||
text[len-1] = 0; // rip off the /n and terminate
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void *game_library;
|
||||
|
||||
/*
|
||||
=================
|
||||
Sys_UnloadGame
|
||||
=================
|
||||
*/
|
||||
void Sys_UnloadGame (void)
|
||||
{
|
||||
if (game_library)
|
||||
dlclose (game_library);
|
||||
game_library = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Sys_GetGameAPI
|
||||
|
||||
Loads the game dll
|
||||
=================
|
||||
*/
|
||||
void *Sys_GetGameAPI (void *parms)
|
||||
{
|
||||
#ifndef REF_HARD_LINKED
|
||||
void *(*GetGameAPI) (void *);
|
||||
|
||||
char name[MAX_OSPATH];
|
||||
char curpath[MAX_OSPATH];
|
||||
char *path;
|
||||
#ifdef __sgi
|
||||
const char *gamename = "gamemips.so";
|
||||
#else
|
||||
#error Unknown arch
|
||||
#endif
|
||||
|
||||
setreuid(getuid(), getuid());
|
||||
setegid(getgid());
|
||||
|
||||
if (game_library)
|
||||
Com_Error (ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame");
|
||||
|
||||
getcwd(curpath, sizeof(curpath));
|
||||
|
||||
Com_Printf("------- Loading %s -------", gamename);
|
||||
|
||||
// now run through the search paths
|
||||
path = NULL;
|
||||
while (1)
|
||||
{
|
||||
path = FS_NextPath (path);
|
||||
if (!path)
|
||||
return NULL; // couldn't find one anywhere
|
||||
sprintf (name, "%s/%s/%s", curpath, path, gamename);
|
||||
Com_Printf ("Trying to load library (%s)\n",name);
|
||||
game_library = dlopen (name, RTLD_NOW );
|
||||
if (game_library)
|
||||
{
|
||||
Com_DPrintf ("LoadLibrary (%s)\n",name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GetGameAPI = (void *)dlsym (game_library, "GetGameAPI");
|
||||
if (!GetGameAPI)
|
||||
{
|
||||
Sys_UnloadGame ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GetGameAPI (parms);
|
||||
#else
|
||||
return (void *)GetGameAPI (parms);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Sys_AppActivate (void)
|
||||
{
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents (void)
|
||||
{
|
||||
if (KBD_Update_fp)
|
||||
KBD_Update_fp();
|
||||
|
||||
// grab frame time
|
||||
sys_frame_time = Sys_Milliseconds();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *Sys_GetClipboardData(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int time, oldtime, newtime;
|
||||
|
||||
// go back to real user for config loads
|
||||
saved_euid = geteuid();
|
||||
seteuid(getuid());
|
||||
|
||||
Qcommon_Init(argc, argv);
|
||||
|
||||
/* fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); */
|
||||
|
||||
nostdout = Cvar_Get("nostdout", "0", 0);
|
||||
if (!nostdout->value) {
|
||||
/* fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); */
|
||||
// printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION);
|
||||
}
|
||||
|
||||
oldtime = Sys_Milliseconds ();
|
||||
while (1)
|
||||
{
|
||||
// find time spent rendering last frame
|
||||
do {
|
||||
newtime = Sys_Milliseconds ();
|
||||
time = newtime - oldtime;
|
||||
} while (time < 1);
|
||||
Qcommon_Frame (time);
|
||||
oldtime = newtime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sys_CopyProtect(void)
|
||||
{
|
||||
FILE *mnt;
|
||||
struct mntent *ent;
|
||||
char path[MAX_OSPATH];
|
||||
struct stat st;
|
||||
qboolean found_cd = false;
|
||||
|
||||
static qboolean checked = false;
|
||||
|
||||
if (checked)
|
||||
return;
|
||||
|
||||
Com_Printf("XXX - Sys_CopyProtect disabled\n");
|
||||
checked = true;
|
||||
return;
|
||||
|
||||
if ((mnt = setmntent("/etc/mtab", "r")) == NULL)
|
||||
Com_Error(ERR_FATAL, "Can't read mount table to determine mounted cd location.");
|
||||
|
||||
while ((ent = getmntent(mnt)) != NULL) {
|
||||
if (strcmp(ent->mnt_type, "iso9660") == 0) {
|
||||
// found a cd file system
|
||||
found_cd = true;
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
endmntent(mnt);
|
||||
return;
|
||||
}
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
endmntent(mnt);
|
||||
return;
|
||||
}
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
endmntent(mnt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
endmntent(mnt);
|
||||
|
||||
if (found_cd)
|
||||
Com_Error (ERR_FATAL, "Could not find a Quake2 CD in your CD drive.");
|
||||
Com_Error (ERR_FATAL, "Unable to find a mounted iso9660 file system.\n"
|
||||
"You must mount the Quake2 CD in a cdrom drive in order to play.");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
================
|
||||
Sys_MakeCodeWriteable
|
||||
================
|
||||
*/
|
||||
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
||||
{
|
||||
|
||||
int r;
|
||||
unsigned long addr;
|
||||
int psize = getpagesize();
|
||||
|
||||
addr = (startaddr & ~(psize-1)) - psize;
|
||||
|
||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
||||
// addr, startaddr+length, length);
|
||||
|
||||
r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
|
||||
|
||||
if (r < 0)
|
||||
Sys_Error("Protection change failed\n");
|
||||
|
||||
}
|
||||
|
||||
#endif
|
426
irix/vid_menu.c
Normal file
426
irix/vid_menu.c
Normal file
@ -0,0 +1,426 @@
|
||||
#include "../client/client.h"
|
||||
#include "../client/qmenu.h"
|
||||
|
||||
#define REF_SOFT 0
|
||||
#define REF_OPENGL 1
|
||||
|
||||
extern cvar_t *vid_ref;
|
||||
extern cvar_t *vid_fullscreen;
|
||||
extern cvar_t *vid_gamma;
|
||||
extern cvar_t *scr_viewsize;
|
||||
|
||||
static cvar_t *gl_mode;
|
||||
static cvar_t *gl_driver;
|
||||
static cvar_t *gl_picmip;
|
||||
static cvar_t *gl_ext_palettedtexture;
|
||||
|
||||
static cvar_t *sw_mode;
|
||||
static cvar_t *sw_stipplealpha;
|
||||
|
||||
static cvar_t *_windowed_mouse;
|
||||
|
||||
extern void M_ForceMenuOff( void );
|
||||
|
||||
/*
|
||||
====================================================================
|
||||
|
||||
MENU INTERACTION
|
||||
|
||||
====================================================================
|
||||
*/
|
||||
#define SOFTWARE_MENU 0
|
||||
#define OPENGL_MENU 1
|
||||
|
||||
static menuframework_s s_software_menu;
|
||||
static menuframework_s s_opengl_menu;
|
||||
static menuframework_s *s_current_menu;
|
||||
static int s_current_menu_index;
|
||||
|
||||
static menulist_s s_mode_list[2];
|
||||
static menulist_s s_ref_list[2];
|
||||
static menuslider_s s_tq_slider;
|
||||
static menuslider_s s_screensize_slider[2];
|
||||
static menuslider_s s_brightness_slider[2];
|
||||
static menulist_s s_fs_box[2];
|
||||
static menulist_s s_stipple_box;
|
||||
static menulist_s s_paletted_texture_box;
|
||||
static menulist_s s_windowed_mouse;
|
||||
static menuaction_s s_apply_action[2];
|
||||
static menuaction_s s_defaults_action[2];
|
||||
|
||||
static void DriverCallback( void *unused )
|
||||
{
|
||||
s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue;
|
||||
|
||||
if ( s_ref_list[s_current_menu_index].curvalue < 1 )
|
||||
{
|
||||
s_current_menu = &s_software_menu;
|
||||
s_current_menu_index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_current_menu = &s_opengl_menu;
|
||||
s_current_menu_index = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ScreenSizeCallback( void *s )
|
||||
{
|
||||
menuslider_s *slider = ( menuslider_s * ) s;
|
||||
|
||||
Cvar_SetValue( "viewsize", slider->curvalue * 10 );
|
||||
}
|
||||
|
||||
static void BrightnessCallback( void *s )
|
||||
{
|
||||
menuslider_s *slider = ( menuslider_s * ) s;
|
||||
|
||||
if ( s_current_menu_index == 0)
|
||||
s_brightness_slider[1].curvalue = s_brightness_slider[0].curvalue;
|
||||
else
|
||||
s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue;
|
||||
|
||||
if ( Q_stricmp( vid_ref->string, "soft" ) == 0 )
|
||||
{
|
||||
float gamma = ( 0.8 - ( slider->curvalue/10.0 - 0.5 ) ) + 0.5;
|
||||
|
||||
Cvar_SetValue( "vid_gamma", gamma );
|
||||
}
|
||||
}
|
||||
|
||||
static void ResetDefaults( void *unused )
|
||||
{
|
||||
VID_MenuInit();
|
||||
}
|
||||
|
||||
static void ApplyChanges( void *unused )
|
||||
{
|
||||
float gamma;
|
||||
|
||||
/*
|
||||
** make values consistent
|
||||
*/
|
||||
s_fs_box[!s_current_menu_index].curvalue = s_fs_box[s_current_menu_index].curvalue;
|
||||
s_brightness_slider[!s_current_menu_index].curvalue = s_brightness_slider[s_current_menu_index].curvalue;
|
||||
s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue;
|
||||
|
||||
/*
|
||||
** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3
|
||||
*/
|
||||
gamma = ( 0.8 - ( s_brightness_slider[s_current_menu_index].curvalue/10.0 - 0.5 ) ) + 0.5;
|
||||
|
||||
Cvar_SetValue( "vid_gamma", gamma );
|
||||
Cvar_SetValue( "sw_stipplealpha", s_stipple_box.curvalue );
|
||||
Cvar_SetValue( "gl_picmip", 3 - s_tq_slider.curvalue );
|
||||
Cvar_SetValue( "vid_fullscreen", s_fs_box[s_current_menu_index].curvalue );
|
||||
Cvar_SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue );
|
||||
Cvar_SetValue( "sw_mode", s_mode_list[SOFTWARE_MENU].curvalue );
|
||||
Cvar_SetValue( "gl_mode", s_mode_list[OPENGL_MENU].curvalue );
|
||||
Cvar_SetValue( "_windowed_mouse", s_windowed_mouse.curvalue);
|
||||
|
||||
switch ( s_ref_list[s_current_menu_index].curvalue )
|
||||
{
|
||||
case REF_SOFT:
|
||||
Cvar_Set( "vid_ref", "soft" );
|
||||
break;
|
||||
case REF_OPENGL:
|
||||
Cvar_Set( "vid_ref", "gl" );
|
||||
Cvar_Set( "gl_driver", "opengl32" );
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
** update appropriate stuff if we're running OpenGL and gamma
|
||||
** has been modified
|
||||
*/
|
||||
if ( Q_stricmp( vid_ref->string, "gl" ) == 0 )
|
||||
{
|
||||
if ( vid_gamma->modified )
|
||||
{
|
||||
vid_ref->modified = true;
|
||||
if ( Q_stricmp( gl_driver->string, "3dfxgl" ) == 0 )
|
||||
{
|
||||
char envbuffer[1024];
|
||||
float g;
|
||||
|
||||
vid_ref->modified = true;
|
||||
|
||||
g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
|
||||
Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
|
||||
putenv( envbuffer );
|
||||
|
||||
vid_gamma->modified = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
M_ForceMenuOff();
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_MenuInit
|
||||
*/
|
||||
void VID_MenuInit( void )
|
||||
{
|
||||
static const char *resolutions[] =
|
||||
{
|
||||
"[320 240 ]",
|
||||
"[400 300 ]",
|
||||
"[512 384 ]",
|
||||
"[640 480 ]",
|
||||
"[800 600 ]",
|
||||
"[960 720 ]",
|
||||
"[1024 768 ]",
|
||||
"[1152 864 ]",
|
||||
"[1280 1024]",
|
||||
"[1600 1200]",
|
||||
0
|
||||
};
|
||||
static const char *refs[] =
|
||||
{
|
||||
"[software ]",
|
||||
"[default OpenGL]",
|
||||
0
|
||||
};
|
||||
static const char *yesno_names[] =
|
||||
{
|
||||
"no",
|
||||
"yes",
|
||||
0
|
||||
};
|
||||
int i;
|
||||
|
||||
if ( !gl_driver )
|
||||
gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 );
|
||||
if ( !gl_picmip )
|
||||
gl_picmip = Cvar_Get( "gl_picmip", "0", 0 );
|
||||
if ( !gl_mode )
|
||||
gl_mode = Cvar_Get( "gl_mode", "3", 0 );
|
||||
if ( !sw_mode )
|
||||
sw_mode = Cvar_Get( "sw_mode", "0", 0 );
|
||||
if ( !gl_ext_palettedtexture )
|
||||
gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE );
|
||||
|
||||
if ( !sw_stipplealpha )
|
||||
sw_stipplealpha = Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE );
|
||||
|
||||
if ( !_windowed_mouse)
|
||||
_windowed_mouse = Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
|
||||
|
||||
s_mode_list[SOFTWARE_MENU].curvalue = sw_mode->value;
|
||||
s_mode_list[OPENGL_MENU].curvalue = gl_mode->value;
|
||||
|
||||
if ( !scr_viewsize )
|
||||
scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE);
|
||||
|
||||
s_screensize_slider[SOFTWARE_MENU].curvalue = scr_viewsize->value/10;
|
||||
s_screensize_slider[OPENGL_MENU].curvalue = scr_viewsize->value/10;
|
||||
|
||||
if (strcmp( vid_ref->string, "soft" ) == 0 )
|
||||
{
|
||||
s_current_menu_index = SOFTWARE_MENU;
|
||||
s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFT;
|
||||
}
|
||||
else if ( strcmp( vid_ref->string, "gl" ) == 0 )
|
||||
{
|
||||
s_current_menu_index = OPENGL_MENU;
|
||||
s_ref_list[s_current_menu_index].curvalue = REF_OPENGL;
|
||||
#if 0
|
||||
if ( strcmp( gl_driver->string, "3dfxgl" ) == 0 )
|
||||
s_ref_list[s_current_menu_index].curvalue = REF_3DFX;
|
||||
else if ( strcmp( gl_driver->string, "pvrgl" ) == 0 )
|
||||
s_ref_list[s_current_menu_index].curvalue = REF_POWERVR;
|
||||
else if ( strcmp( gl_driver->string, "opengl32" ) == 0 )
|
||||
s_ref_list[s_current_menu_index].curvalue = REF_OPENGL;
|
||||
else
|
||||
s_ref_list[s_current_menu_index].curvalue = REF_VERITE;
|
||||
#endif
|
||||
}
|
||||
|
||||
s_software_menu.x = viddef.width * 0.50;
|
||||
s_software_menu.nitems = 0;
|
||||
s_opengl_menu.x = viddef.width * 0.50;
|
||||
s_opengl_menu.nitems = 0;
|
||||
|
||||
for ( i = 0; i < 2; i++ )
|
||||
{
|
||||
s_ref_list[i].generic.type = MTYPE_SPINCONTROL;
|
||||
s_ref_list[i].generic.name = "driver";
|
||||
s_ref_list[i].generic.x = 0;
|
||||
s_ref_list[i].generic.y = 0;
|
||||
s_ref_list[i].generic.callback = DriverCallback;
|
||||
s_ref_list[i].itemnames = refs;
|
||||
|
||||
s_mode_list[i].generic.type = MTYPE_SPINCONTROL;
|
||||
s_mode_list[i].generic.name = "video mode";
|
||||
s_mode_list[i].generic.x = 0;
|
||||
s_mode_list[i].generic.y = 10;
|
||||
s_mode_list[i].itemnames = resolutions;
|
||||
|
||||
s_screensize_slider[i].generic.type = MTYPE_SLIDER;
|
||||
s_screensize_slider[i].generic.x = 0;
|
||||
s_screensize_slider[i].generic.y = 20;
|
||||
s_screensize_slider[i].generic.name = "screen size";
|
||||
s_screensize_slider[i].minvalue = 3;
|
||||
s_screensize_slider[i].maxvalue = 12;
|
||||
s_screensize_slider[i].generic.callback = ScreenSizeCallback;
|
||||
|
||||
s_brightness_slider[i].generic.type = MTYPE_SLIDER;
|
||||
s_brightness_slider[i].generic.x = 0;
|
||||
s_brightness_slider[i].generic.y = 30;
|
||||
s_brightness_slider[i].generic.name = "brightness";
|
||||
s_brightness_slider[i].generic.callback = BrightnessCallback;
|
||||
s_brightness_slider[i].minvalue = 5;
|
||||
s_brightness_slider[i].maxvalue = 13;
|
||||
s_brightness_slider[i].curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10;
|
||||
|
||||
s_fs_box[i].generic.type = MTYPE_SPINCONTROL;
|
||||
s_fs_box[i].generic.x = 0;
|
||||
s_fs_box[i].generic.y = 40;
|
||||
s_fs_box[i].generic.name = "fullscreen";
|
||||
s_fs_box[i].itemnames = yesno_names;
|
||||
s_fs_box[i].curvalue = vid_fullscreen->value;
|
||||
|
||||
s_defaults_action[i].generic.type = MTYPE_ACTION;
|
||||
s_defaults_action[i].generic.name = "reset to default";
|
||||
s_defaults_action[i].generic.x = 0;
|
||||
s_defaults_action[i].generic.y = 90;
|
||||
s_defaults_action[i].generic.callback = ResetDefaults;
|
||||
|
||||
s_apply_action[i].generic.type = MTYPE_ACTION;
|
||||
s_apply_action[i].generic.name = "apply";
|
||||
s_apply_action[i].generic.x = 0;
|
||||
s_apply_action[i].generic.y = 100;
|
||||
s_apply_action[i].generic.callback = ApplyChanges;
|
||||
}
|
||||
|
||||
s_stipple_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_stipple_box.generic.x = 0;
|
||||
s_stipple_box.generic.y = 60;
|
||||
s_stipple_box.generic.name = "stipple alpha";
|
||||
s_stipple_box.curvalue = sw_stipplealpha->value;
|
||||
s_stipple_box.itemnames = yesno_names;
|
||||
|
||||
s_windowed_mouse.generic.type = MTYPE_SPINCONTROL;
|
||||
s_windowed_mouse.generic.x = 0;
|
||||
s_windowed_mouse.generic.y = 72;
|
||||
s_windowed_mouse.generic.name = "windowed mouse";
|
||||
s_windowed_mouse.curvalue = _windowed_mouse->value;
|
||||
s_windowed_mouse.itemnames = yesno_names;
|
||||
|
||||
s_tq_slider.generic.type = MTYPE_SLIDER;
|
||||
s_tq_slider.generic.x = 0;
|
||||
s_tq_slider.generic.y = 60;
|
||||
s_tq_slider.generic.name = "texture quality";
|
||||
s_tq_slider.minvalue = 0;
|
||||
s_tq_slider.maxvalue = 3;
|
||||
s_tq_slider.curvalue = 3-gl_picmip->value;
|
||||
|
||||
s_paletted_texture_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_paletted_texture_box.generic.x = 0;
|
||||
s_paletted_texture_box.generic.y = 70;
|
||||
s_paletted_texture_box.generic.name = "8-bit textures";
|
||||
s_paletted_texture_box.itemnames = yesno_names;
|
||||
s_paletted_texture_box.curvalue = gl_ext_palettedtexture->value;
|
||||
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_ref_list[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_mode_list[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_screensize_slider[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_brightness_slider[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_fs_box[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_stipple_box );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_windowed_mouse );
|
||||
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_ref_list[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_mode_list[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_screensize_slider[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_brightness_slider[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_fs_box[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_tq_slider );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_paletted_texture_box );
|
||||
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_defaults_action[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_software_menu, ( void * ) &s_apply_action[SOFTWARE_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_defaults_action[OPENGL_MENU] );
|
||||
Menu_AddItem( &s_opengl_menu, ( void * ) &s_apply_action[OPENGL_MENU] );
|
||||
|
||||
Menu_Center( &s_software_menu );
|
||||
Menu_Center( &s_opengl_menu );
|
||||
s_opengl_menu.x -= 8;
|
||||
s_software_menu.x -= 8;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
VID_MenuDraw
|
||||
================
|
||||
*/
|
||||
void VID_MenuDraw (void)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if ( s_current_menu_index == 0 )
|
||||
s_current_menu = &s_software_menu;
|
||||
else
|
||||
s_current_menu = &s_opengl_menu;
|
||||
|
||||
/*
|
||||
** draw the banner
|
||||
*/
|
||||
re.DrawGetPicSize( &w, &h, "m_banner_video" );
|
||||
re.DrawPic( viddef.width / 2 - w / 2, viddef.height /2 - 110, "m_banner_video" );
|
||||
|
||||
/*
|
||||
** move cursor to a reasonable starting position
|
||||
*/
|
||||
Menu_AdjustCursor( s_current_menu, 1 );
|
||||
|
||||
/*
|
||||
** draw the menu
|
||||
*/
|
||||
Menu_Draw( s_current_menu );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
VID_MenuKey
|
||||
================
|
||||
*/
|
||||
const char *VID_MenuKey( int key )
|
||||
{
|
||||
extern void M_PopMenu( void );
|
||||
|
||||
menuframework_s *m = s_current_menu;
|
||||
static const char *sound = "misc/menu1.wav";
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case K_ESCAPE:
|
||||
M_PopMenu();
|
||||
return NULL;
|
||||
case K_UPARROW:
|
||||
m->cursor--;
|
||||
Menu_AdjustCursor( m, -1 );
|
||||
break;
|
||||
case K_DOWNARROW:
|
||||
m->cursor++;
|
||||
Menu_AdjustCursor( m, 1 );
|
||||
break;
|
||||
case K_LEFTARROW:
|
||||
Menu_SlideItem( m, -1 );
|
||||
break;
|
||||
case K_RIGHTARROW:
|
||||
Menu_SlideItem( m, 1 );
|
||||
break;
|
||||
case K_ENTER:
|
||||
Menu_SelectItem( m );
|
||||
break;
|
||||
}
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
|
492
irix/vid_so.c
Normal file
492
irix/vid_so.c
Normal file
@ -0,0 +1,492 @@
|
||||
// Main windowed and fullscreen graphics interface module. This module
|
||||
// is used for both the software and OpenGL rendering versions of the
|
||||
// Quake refresh engine.
|
||||
|
||||
#define SO_FILE "/etc/quake2.conf"
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h> // ELF dl loader
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../client/client.h"
|
||||
|
||||
#include "../linux/rw_linux.h"
|
||||
|
||||
// Structure containing functions exported from refresh DLL
|
||||
refexport_t re;
|
||||
|
||||
#ifdef REF_HARD_LINKED
|
||||
refexport_t GetRefAPI (refimport_t rimp);
|
||||
#endif
|
||||
|
||||
// Console variables that we need to access from this module
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *vid_ref; // Name of Refresh DLL loaded
|
||||
cvar_t *vid_xpos; // X coordinate of window position
|
||||
cvar_t *vid_ypos; // Y coordinate of window position
|
||||
cvar_t *vid_fullscreen;
|
||||
|
||||
// Global variables used internally by this module
|
||||
viddef_t viddef; // global video state; used by other modules
|
||||
void *reflib_library; // Handle to refresh DLL
|
||||
qboolean reflib_active = 0;
|
||||
|
||||
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
|
||||
|
||||
/** KEYBOARD **************************************************************/
|
||||
|
||||
void Do_Key_Event(int key, qboolean down);
|
||||
|
||||
void (*KBD_Update_fp)(void);
|
||||
void (*KBD_Init_fp)(Key_Event_fp_t fp);
|
||||
void (*KBD_Close_fp)(void);
|
||||
|
||||
/** MOUSE *****************************************************************/
|
||||
|
||||
in_state_t in_state;
|
||||
|
||||
void (*RW_IN_Init_fp)(in_state_t *in_state_p);
|
||||
void (*RW_IN_Shutdown_fp)(void);
|
||||
void (*RW_IN_Activate_fp)(qboolean active);
|
||||
void (*RW_IN_Commands_fp)(void);
|
||||
void (*RW_IN_Move_fp)(usercmd_t *cmd);
|
||||
void (*RW_IN_Frame_fp)(void);
|
||||
|
||||
void Real_IN_Init (void);
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
|
||||
DLL GLUE
|
||||
|
||||
==========================================================================
|
||||
*/
|
||||
|
||||
#define MAXPRINTMSG 4096
|
||||
void VID_Printf (int print_level, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
static qboolean inupdate;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vsprintf (msg,fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
if (print_level == PRINT_ALL)
|
||||
Com_Printf ("%s", msg);
|
||||
else
|
||||
Com_DPrintf ("%s", msg);
|
||||
}
|
||||
|
||||
void VID_Error (int err_level, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
static qboolean inupdate;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vsprintf (msg,fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
Com_Error (err_level,"%s", msg);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
============
|
||||
VID_Restart_f
|
||||
|
||||
Console command to re-start the video mode and refresh DLL. We do this
|
||||
simply by setting the modified flag for the vid_ref variable, which will
|
||||
cause the entire video mode and refresh DLL to be reset on the next frame.
|
||||
============
|
||||
*/
|
||||
void VID_Restart_f (void)
|
||||
{
|
||||
vid_ref->modified = true;
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_GetModeInfo
|
||||
*/
|
||||
typedef struct vidmode_s
|
||||
{
|
||||
const char *description;
|
||||
int width, height;
|
||||
int mode;
|
||||
} vidmode_t;
|
||||
|
||||
vidmode_t vid_modes[] =
|
||||
{
|
||||
{ "Mode 0: 320x240", 320, 240, 0 },
|
||||
{ "Mode 1: 400x300", 400, 300, 1 },
|
||||
{ "Mode 2: 512x384", 512, 384, 2 },
|
||||
{ "Mode 3: 640x480", 640, 480, 3 },
|
||||
{ "Mode 4: 800x600", 800, 600, 4 },
|
||||
{ "Mode 5: 960x720", 960, 720, 5 },
|
||||
{ "Mode 6: 1024x768", 1024, 768, 6 },
|
||||
{ "Mode 7: 1152x864", 1152, 864, 7 },
|
||||
{ "Mode 8: 1280x1024", 1280, 1024, 8 },
|
||||
{ "Mode 9: 1600x1200", 1600, 1200, 9 }
|
||||
};
|
||||
|
||||
qboolean VID_GetModeInfo( int *width, int *height, int mode )
|
||||
{
|
||||
if ( mode < 0 || mode >= VID_NUM_MODES )
|
||||
return false;
|
||||
|
||||
*width = vid_modes[mode].width;
|
||||
*height = vid_modes[mode].height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_NewWindow
|
||||
*/
|
||||
void VID_NewWindow ( int width, int height)
|
||||
{
|
||||
viddef.width = width;
|
||||
viddef.height = height;
|
||||
}
|
||||
|
||||
void VID_FreeReflib (void)
|
||||
{
|
||||
if (reflib_library) {
|
||||
if (KBD_Close_fp)
|
||||
KBD_Close_fp();
|
||||
if (RW_IN_Shutdown_fp)
|
||||
RW_IN_Shutdown_fp();
|
||||
#ifndef REF_HARD_LINKED
|
||||
dlclose(reflib_library);
|
||||
#endif
|
||||
}
|
||||
|
||||
KBD_Init_fp = NULL;
|
||||
KBD_Update_fp = NULL;
|
||||
KBD_Close_fp = NULL;
|
||||
RW_IN_Init_fp = NULL;
|
||||
RW_IN_Shutdown_fp = NULL;
|
||||
RW_IN_Activate_fp = NULL;
|
||||
RW_IN_Commands_fp = NULL;
|
||||
RW_IN_Move_fp = NULL;
|
||||
RW_IN_Frame_fp = NULL;
|
||||
|
||||
memset (&re, 0, sizeof(re));
|
||||
reflib_library = NULL;
|
||||
reflib_active = false;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
VID_LoadRefresh
|
||||
==============
|
||||
*/
|
||||
qboolean VID_LoadRefresh( char *name )
|
||||
{
|
||||
refimport_t ri;
|
||||
#ifndef REF_HARD_LINKED
|
||||
GetRefAPI_t GetRefAPI;
|
||||
#endif
|
||||
char fn[MAX_OSPATH];
|
||||
struct stat st;
|
||||
extern uid_t saved_euid;
|
||||
FILE *fp;
|
||||
char *path;
|
||||
char curpath[MAX_OSPATH];
|
||||
|
||||
if ( reflib_active )
|
||||
{
|
||||
if (KBD_Close_fp)
|
||||
KBD_Close_fp();
|
||||
if (RW_IN_Shutdown_fp)
|
||||
RW_IN_Shutdown_fp();
|
||||
KBD_Close_fp = NULL;
|
||||
RW_IN_Shutdown_fp = NULL;
|
||||
re.Shutdown();
|
||||
VID_FreeReflib ();
|
||||
}
|
||||
|
||||
#ifndef REF_HARD_LINKED
|
||||
getcwd(curpath, sizeof(curpath));
|
||||
|
||||
Com_Printf( "------- Loading %s -------\n", name );
|
||||
|
||||
// now run through the search paths
|
||||
path = NULL;
|
||||
while (1)
|
||||
{
|
||||
path = FS_NextPath (path);
|
||||
if (!path)
|
||||
return NULL; // couldn't find one anywhere
|
||||
sprintf (fn, "%s/%s/%s", curpath, path, name);
|
||||
Com_Printf ("Trying to load library (%s)\n", fn);
|
||||
|
||||
reflib_library = dlopen( fn, RTLD_NOW );
|
||||
if (reflib_library)
|
||||
{
|
||||
Com_DPrintf ("LoadLibrary (%s)\n",name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ri.Cmd_AddCommand = Cmd_AddCommand;
|
||||
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
||||
ri.Cmd_Argc = Cmd_Argc;
|
||||
ri.Cmd_Argv = Cmd_Argv;
|
||||
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
|
||||
ri.Con_Printf = VID_Printf;
|
||||
ri.Sys_Error = VID_Error;
|
||||
ri.FS_LoadFile = FS_LoadFile;
|
||||
ri.FS_FreeFile = FS_FreeFile;
|
||||
ri.FS_Gamedir = FS_Gamedir;
|
||||
ri.Cvar_Get = Cvar_Get;
|
||||
ri.Cvar_Set = Cvar_Set;
|
||||
ri.Cvar_SetValue = Cvar_SetValue;
|
||||
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
||||
ri.Vid_MenuInit = VID_MenuInit;
|
||||
ri.Vid_NewWindow = VID_NewWindow;
|
||||
|
||||
#ifndef REF_HARD_LINKED
|
||||
if ( ( GetRefAPI = (void *) dlsym( reflib_library, "GetRefAPI" ) ) == 0 )
|
||||
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
|
||||
#endif
|
||||
re = GetRefAPI( ri );
|
||||
|
||||
if (re.api_version != API_VERSION)
|
||||
{
|
||||
VID_FreeReflib ();
|
||||
Com_Error (ERR_FATAL, "%s has incompatible api_version", name);
|
||||
}
|
||||
|
||||
/* Init IN (Mouse) */
|
||||
in_state.IN_CenterView_fp = IN_CenterView;
|
||||
in_state.Key_Event_fp = Do_Key_Event;
|
||||
in_state.viewangles = cl.viewangles;
|
||||
in_state.in_strafe_state = &in_strafe.state;
|
||||
|
||||
#ifndef REF_HARD_LINKED
|
||||
if ((RW_IN_Init_fp = dlsym(reflib_library, "RW_IN_Init")) == NULL ||
|
||||
(RW_IN_Shutdown_fp = dlsym(reflib_library, "RW_IN_Shutdown")) == NULL ||
|
||||
(RW_IN_Activate_fp = dlsym(reflib_library, "RW_IN_Activate")) == NULL ||
|
||||
(RW_IN_Commands_fp = dlsym(reflib_library, "RW_IN_Commands")) == NULL ||
|
||||
(RW_IN_Move_fp = dlsym(reflib_library, "RW_IN_Move")) == NULL ||
|
||||
(RW_IN_Frame_fp = dlsym(reflib_library, "RW_IN_Frame")) == NULL)
|
||||
Sys_Error("No RW_IN functions in REF.\n");
|
||||
#else
|
||||
{
|
||||
void RW_IN_Init(in_state_t *in_state_p);
|
||||
void RW_IN_Shutdown(void);
|
||||
void RW_IN_Commands (void);
|
||||
void RW_IN_Move (usercmd_t *cmd);
|
||||
void RW_IN_Frame (void);
|
||||
void RW_IN_Activate(void);
|
||||
|
||||
RW_IN_Init_fp = RW_IN_Init;
|
||||
RW_IN_Shutdown_fp = RW_IN_Shutdown;
|
||||
RW_IN_Activate_fp = RW_IN_Activate;
|
||||
RW_IN_Commands_fp = RW_IN_Commands;
|
||||
RW_IN_Move_fp = RW_IN_Move;
|
||||
RW_IN_Frame_fp = RW_IN_Frame;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( re.Init( 0, 0 ) == -1 )
|
||||
{
|
||||
re.Shutdown();
|
||||
VID_FreeReflib ();
|
||||
return false;
|
||||
}
|
||||
|
||||
// give up root now
|
||||
setreuid(getuid(), getuid());
|
||||
setegid(getgid());
|
||||
|
||||
/* Init KBD */
|
||||
#ifndef REF_HARD_LINKED
|
||||
if ((KBD_Init_fp = dlsym(reflib_library, "KBD_Init")) == NULL ||
|
||||
(KBD_Update_fp = dlsym(reflib_library, "KBD_Update")) == NULL ||
|
||||
(KBD_Close_fp = dlsym(reflib_library, "KBD_Close")) == NULL)
|
||||
Sys_Error("No KBD functions in REF.\n");
|
||||
#else
|
||||
{
|
||||
void KBD_Init(void);
|
||||
void KBD_Update(void);
|
||||
void KBD_Close(void);
|
||||
|
||||
KBD_Init_fp = KBD_Init;
|
||||
KBD_Update_fp = KBD_Update;
|
||||
KBD_Close_fp = KBD_Close;
|
||||
}
|
||||
#endif
|
||||
KBD_Init_fp(Do_Key_Event);
|
||||
Real_IN_Init();
|
||||
|
||||
Com_Printf( "------------------------------------\n");
|
||||
reflib_active = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_CheckChanges
|
||||
|
||||
This function gets called once just before drawing each frame, and it's sole purpose in life
|
||||
is to check to see if any of the video mode parameters have changed, and if they have to
|
||||
update the rendering DLL and/or video mode to match.
|
||||
============
|
||||
*/
|
||||
void VID_CheckChanges (void)
|
||||
{
|
||||
char name[100];
|
||||
cvar_t *sw_mode;
|
||||
|
||||
if ( vid_ref->modified )
|
||||
{
|
||||
S_StopAllSounds();
|
||||
}
|
||||
|
||||
while (vid_ref->modified)
|
||||
{
|
||||
/*
|
||||
** refresh has changed
|
||||
*/
|
||||
vid_ref->modified = false;
|
||||
vid_fullscreen->modified = true;
|
||||
cl.refresh_prepped = false;
|
||||
cls.disable_screen = true;
|
||||
|
||||
sprintf( name, "ref_%s.so", vid_ref->string );
|
||||
if ( !VID_LoadRefresh( name ) )
|
||||
{
|
||||
if ( strcmp (vid_ref->string, "soft") == 0 ) {
|
||||
Com_Printf("Refresh failed\n");
|
||||
sw_mode = Cvar_Get( "sw_mode", "0", 0 );
|
||||
if (sw_mode->value != 0) {
|
||||
Com_Printf("Trying mode 0\n");
|
||||
Cvar_SetValue("sw_mode", 0);
|
||||
if ( !VID_LoadRefresh( name ) )
|
||||
Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
|
||||
} else
|
||||
Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
|
||||
}
|
||||
|
||||
Cvar_Set( "vid_ref", "soft" );
|
||||
|
||||
/*
|
||||
** drop the console if we fail to load a refresh
|
||||
*/
|
||||
if ( cls.key_dest != key_console )
|
||||
{
|
||||
Con_ToggleConsole_f();
|
||||
}
|
||||
}
|
||||
cls.disable_screen = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_Init
|
||||
============
|
||||
*/
|
||||
void VID_Init (void)
|
||||
{
|
||||
/* Create the video variables so we know how to start the graphics drivers */
|
||||
vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE);
|
||||
vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
|
||||
vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
|
||||
|
||||
/* Add some console commands that we want to handle */
|
||||
Cmd_AddCommand ("vid_restart", VID_Restart_f);
|
||||
|
||||
/* Disable the 3Dfx splash screen */
|
||||
putenv("FX_GLIDE_NO_SPLASH=0");
|
||||
|
||||
/* Start the graphics mode and load refresh DLL */
|
||||
VID_CheckChanges();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_Shutdown
|
||||
============
|
||||
*/
|
||||
void VID_Shutdown (void)
|
||||
{
|
||||
if ( reflib_active )
|
||||
{
|
||||
if (KBD_Close_fp)
|
||||
KBD_Close_fp();
|
||||
if (RW_IN_Shutdown_fp)
|
||||
RW_IN_Shutdown_fp();
|
||||
KBD_Close_fp = NULL;
|
||||
RW_IN_Shutdown_fp = NULL;
|
||||
re.Shutdown ();
|
||||
VID_FreeReflib ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* INPUT */
|
||||
/*****************************************************************************/
|
||||
|
||||
cvar_t *in_joystick;
|
||||
|
||||
// This if fake, it's acutally done by the Refresh load
|
||||
void IN_Init (void)
|
||||
{
|
||||
in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE);
|
||||
}
|
||||
|
||||
void Real_IN_Init (void)
|
||||
{
|
||||
if (RW_IN_Init_fp)
|
||||
RW_IN_Init_fp(&in_state);
|
||||
}
|
||||
|
||||
void IN_Shutdown (void)
|
||||
{
|
||||
if (RW_IN_Shutdown_fp)
|
||||
RW_IN_Shutdown_fp();
|
||||
}
|
||||
|
||||
void IN_Commands (void)
|
||||
{
|
||||
if (RW_IN_Commands_fp)
|
||||
RW_IN_Commands_fp();
|
||||
}
|
||||
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
if (RW_IN_Move_fp)
|
||||
RW_IN_Move_fp(cmd);
|
||||
}
|
||||
|
||||
void IN_Frame (void)
|
||||
{
|
||||
if (RW_IN_Frame_fp)
|
||||
RW_IN_Frame_fp();
|
||||
}
|
||||
|
||||
void IN_Activate (qboolean active)
|
||||
{
|
||||
if (RW_IN_Activate_fp)
|
||||
RW_IN_Activate_fp(active);
|
||||
}
|
||||
|
||||
void Do_Key_Event(int key, qboolean down)
|
||||
{
|
||||
Key_Event(key, down, Sys_Milliseconds());
|
||||
}
|
||||
|
Reference in New Issue
Block a user