initial commit
This commit is contained in:
146
libs/glfw/lib/dos/Makefile.dos.djgpp
Normal file
146
libs/glfw/lib/dos/Makefile.dos.djgpp
Normal file
@ -0,0 +1,146 @@
|
||||
##########################################################################
|
||||
# Makefile for GLFW on DOS using DJGPP.
|
||||
#-------------------------------------------------------------------------
|
||||
# To compile GLFW using this makefile, run:
|
||||
# make -f Makefile.dos.djgpp
|
||||
# NOTE: You need long filename support (e.g. compile under Windows9x or
|
||||
# use a LFN driver such as DOSLFN)
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# Default: Build static library version of GLFW
|
||||
##########################################################################
|
||||
default: libglfw.a
|
||||
|
||||
|
||||
##########################################################################
|
||||
# GLFW version
|
||||
##########################################################################
|
||||
VERMAJOR = 2
|
||||
VERMINOR = 4
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Compiler settings
|
||||
##########################################################################
|
||||
CC = gcc
|
||||
CFLAGS = -c -I. -I.. -Wall -Os
|
||||
|
||||
# Some modules should be optimized for speed (e.g. image decoding)
|
||||
CFLAGS_SPEED = -c -I. -I.. -Wall -O3 -ffast-math
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Library builder settings
|
||||
##########################################################################
|
||||
MKLIB = ar
|
||||
LIBFLAGS = -rcs
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Object files which are part of the GLFW library
|
||||
##########################################################################
|
||||
OBJS = \
|
||||
enable.o \
|
||||
fullscreen.o \
|
||||
glext.o \
|
||||
image.o \
|
||||
init.o \
|
||||
input.o \
|
||||
joystick.o \
|
||||
tga.o \
|
||||
thread.o \
|
||||
time.o \
|
||||
window.o \
|
||||
dos_enable.o \
|
||||
dos_events.o \
|
||||
dos_fullscreen.o \
|
||||
dos_glext.o \
|
||||
dos_init.o \
|
||||
dos_irq.o \
|
||||
dos_joystick.o \
|
||||
dos_keyboard.o \
|
||||
dos_mouse.o \
|
||||
dos_thread.o \
|
||||
dos_time.o \
|
||||
dos_window.o
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building library
|
||||
##########################################################################
|
||||
libglfw.a: $(OBJS)
|
||||
$(MKLIB) $(LIBFLAGS) $@ $(OBJS)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rules for building library object files
|
||||
##########################################################################
|
||||
enable.o: ..\\enable.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\enable.c
|
||||
|
||||
fullscreen.o: ..\\fullscreen.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\fullscreen.c
|
||||
|
||||
glext.o: ..\\glext.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\glext.c
|
||||
|
||||
image.o: ..\\image.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ..\\image.c
|
||||
|
||||
init.o: ..\\init.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\init.c
|
||||
|
||||
input.o: ..\\input.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\input.c
|
||||
|
||||
joystick.o: ..\\joystick.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\joystick.c
|
||||
|
||||
tga.o: ..\\tga.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ..\\tga.c
|
||||
|
||||
thread.o: ..\\thread.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\thread.c
|
||||
|
||||
time.o: ..\\time.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\time.c
|
||||
|
||||
window.o: ..\\window.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ..\\window.c
|
||||
|
||||
dos_enable.o: dos_enable.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_enable.c
|
||||
|
||||
dos_events.o: dos_events.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_events.c
|
||||
|
||||
dos_fullscreen.o: dos_fullscreen.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_fullscreen.c
|
||||
|
||||
dos_glext.o: dos_glext.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_glext.c
|
||||
|
||||
dos_init.o: dos_init.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_init.c
|
||||
|
||||
dos_irq.o: dos_irq.s ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ dos_irq.s
|
||||
|
||||
dos_joystick.o: dos_joystick.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_joystick.c
|
||||
|
||||
dos_keyboard.o: dos_keyboard.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_keyboard.c
|
||||
|
||||
dos_mouse.o: dos_mouse.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_mouse.c
|
||||
|
||||
dos_thread.o: dos_thread.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_thread.c
|
||||
|
||||
dos_time.o: dos_time.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_time.c
|
||||
|
||||
dos_window.o: dos_window.c ..\\internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ dos_window.c
|
51
libs/glfw/lib/dos/dos_enable.c
Normal file
51
libs/glfw/lib/dos/dos_enable.c
Normal file
@ -0,0 +1,51 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_enable.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformEnableSystemKeys() - Enable system keys
|
||||
// _glfwPlatformDisableSystemKeys() - Disable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformEnableSystemKeys( void )
|
||||
{
|
||||
// Not supported under DOS (yet)
|
||||
}
|
||||
|
||||
void _glfwPlatformDisableSystemKeys( void )
|
||||
{
|
||||
// Not supported under DOS (yet)
|
||||
}
|
173
libs/glfw/lib/dos/dos_events.c
Normal file
173
libs/glfw/lib/dos/dos_events.c
Normal file
@ -0,0 +1,173 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_events.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global variables
|
||||
//========================================================================
|
||||
|
||||
// Event buffer
|
||||
#define _GLFW_EVENT_BUFFER_SIZE 1024
|
||||
|
||||
static volatile struct {
|
||||
volatile int Start, End;
|
||||
volatile _GLFWdosevent *Event;
|
||||
} _glfwEventBuffer;
|
||||
|
||||
static int _glfwEventsInitialized = 0;
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwWaitNextEvent() - Wait for an event to appear in the event FIFO
|
||||
// NOTE: Must not be called from an interrupt routine
|
||||
//========================================================================
|
||||
|
||||
void _glfwWaitNextEvent( void )
|
||||
{
|
||||
int noevent = 1;
|
||||
|
||||
while( noevent )
|
||||
{
|
||||
DISABLE();
|
||||
noevent = ( _glfwEventBuffer.Start == _glfwEventBuffer.End );
|
||||
ENABLE();
|
||||
// Wait for an interrupt to happen?...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwGetNextEvent() - Get an event from the event FIFO
|
||||
// NOTE: Must not be called from an interrupt routine
|
||||
//========================================================================
|
||||
|
||||
int _glfwGetNextEvent( _GLFWdosevent *event )
|
||||
{
|
||||
DISABLE();
|
||||
|
||||
if( _glfwEventBuffer.Start == _glfwEventBuffer.End )
|
||||
{
|
||||
ENABLE();
|
||||
return 0;
|
||||
}
|
||||
|
||||
*event = _glfwEventBuffer.Event[ _glfwEventBuffer.Start ++ ];
|
||||
if( _glfwEventBuffer.Start >= _GLFW_EVENT_BUFFER_SIZE )
|
||||
{
|
||||
_glfwEventBuffer.Start = 0;
|
||||
}
|
||||
|
||||
ENABLE();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPostDOSEvent() - Put an event onto the event FIFO
|
||||
// NOTE: Must only be called from an interrupt routine
|
||||
//========================================================================
|
||||
|
||||
void _glfwPostDOSEvent( _GLFWdosevent *event )
|
||||
{
|
||||
// Add event
|
||||
_glfwEventBuffer.Event[ _glfwEventBuffer.End ++ ] = *event;
|
||||
|
||||
// End of FIFO buffer?
|
||||
if( _glfwEventBuffer.End >= _GLFW_EVENT_BUFFER_SIZE )
|
||||
_glfwEventBuffer.End = 0;
|
||||
|
||||
// If the buffer is full, drop the oldest event
|
||||
if( _glfwEventBuffer.End == _glfwEventBuffer.Start)
|
||||
{
|
||||
_glfwEventBuffer.Start ++;
|
||||
if( _glfwEventBuffer.Start >= _GLFW_EVENT_BUFFER_SIZE )
|
||||
_glfwEventBuffer.Start = 0;
|
||||
}
|
||||
} ENDOFUNC(_glfwPostDOSEvent)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitEvents() - Initialize event management functions and the FIFO
|
||||
//========================================================================
|
||||
|
||||
int _glfwInitEvents( void )
|
||||
{
|
||||
int fifosize;
|
||||
|
||||
// Allocate memory for the event FIFO buffer
|
||||
fifosize = _GLFW_EVENT_BUFFER_SIZE * sizeof(_GLFWdosevent);
|
||||
_glfwEventBuffer.Event = malloc( fifosize );
|
||||
if( !_glfwEventBuffer.Event )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Lock data & functions
|
||||
LOCKBUFF( _glfwEventBuffer.Event, fifosize );
|
||||
LOCKDATA( _glfwEventBuffer );
|
||||
LOCKFUNC( _glfwPostDOSEvent );
|
||||
|
||||
// Initialize event FIFO
|
||||
_glfwEventBuffer.Start = _glfwEventBuffer.End = 0;
|
||||
|
||||
_glfwEventsInitialized = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateEvents() - Terminate event management
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateEvents( void )
|
||||
{
|
||||
if( !_glfwEventsInitialized )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwEventsInitialized = 0;
|
||||
|
||||
// Free memory for the event FIFO buffer
|
||||
if( _glfwEventBuffer.Event )
|
||||
{
|
||||
free( (void *) _glfwEventBuffer.Event );
|
||||
_glfwEventBuffer.Event = NULL;
|
||||
}
|
||||
}
|
101
libs/glfw/lib/dos/dos_fullscreen.c
Normal file
101
libs/glfw/lib/dos/dos_fullscreen.c
Normal file
@ -0,0 +1,101 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_fullscreen.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwBPP2RGB() - Convert BPP to RGB bits (based on "best guess")
|
||||
//========================================================================
|
||||
|
||||
static void _glfwBPP2RGB( int bpp, int *r, int *g, int *b )
|
||||
{
|
||||
int delta;
|
||||
int bpp2;
|
||||
|
||||
// Special case: bpp = 32
|
||||
if( bpp == 32 ) bpp = 24;
|
||||
|
||||
// Convert "bits per pixel" to red, green & blue sizes
|
||||
*r = *g = *b = bpp / 3;
|
||||
delta = bpp - (*r * 3);
|
||||
if( delta >= 1 )
|
||||
{
|
||||
*g = *g + 1;
|
||||
}
|
||||
if( delta == 2 )
|
||||
{
|
||||
*r = *r + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetVideoModes() - List available video modes
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
|
||||
{
|
||||
if( maxcount <= 0 ) return 0;
|
||||
|
||||
// Dummy...
|
||||
list[0].Width = 640;
|
||||
list[0].Height = 480;
|
||||
list[0].RedBits = 5;
|
||||
list[0].GreenBits = 6;
|
||||
list[0].BlueBits = 5;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetDesktopMode() - Get the desktop video mode
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode )
|
||||
{
|
||||
// Dummy...
|
||||
mode->Width = 640;
|
||||
mode->Height = 480;
|
||||
mode->RedBits = 5;
|
||||
mode->GreenBits = 6;
|
||||
mode->BlueBits = 5;
|
||||
}
|
59
libs/glfw/lib/dos/dos_glext.c
Normal file
59
libs/glfw/lib/dos/dos_glext.c
Normal file
@ -0,0 +1,59 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_glext.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformExtensionSupported() - Check if an OpenGL extension is
|
||||
// available at runtime
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformExtensionSupported( const char *extension )
|
||||
{
|
||||
// TODO
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetProcAddress() - Get the function pointer to an OpenGL
|
||||
// function
|
||||
//========================================================================
|
||||
|
||||
void * _glfwPlatformGetProcAddress( const char *procname )
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
105
libs/glfw/lib/dos/dos_init.c
Normal file
105
libs/glfw/lib/dos/dos_init.c
Normal file
@ -0,0 +1,105 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_init.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminate_atexit() - Terminate GLFW when exiting application
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminate_atexit( void )
|
||||
{
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformInit() - Initialize various GLFW state
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformInit( void )
|
||||
{
|
||||
// Initialize thread package
|
||||
if( !_glfwInitThreads() )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Start the timer
|
||||
if( !_glfwInitTimer() )
|
||||
{
|
||||
_glfwTerminateThreads();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Initialize joysticks
|
||||
_glfwInitJoysticks();
|
||||
|
||||
// Install atexit() routine
|
||||
atexit( _glfwTerminate_atexit );
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformTerminate() - Close window and kill all threads
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformTerminate( void )
|
||||
{
|
||||
// Only the main thread is allowed to do this...
|
||||
// TODO
|
||||
|
||||
// Close OpenGL window
|
||||
glfwCloseWindow();
|
||||
|
||||
// Terminate joysticks
|
||||
_glfwTerminateJoysticks();
|
||||
|
||||
// Kill timer
|
||||
_glfwTerminateTimer();
|
||||
|
||||
// Kill thread package
|
||||
_glfwTerminateThreads();
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
246
libs/glfw/lib/dos/dos_irq.s
Normal file
246
libs/glfw/lib/dos/dos_irq.s
Normal file
@ -0,0 +1,246 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_irq.s
|
||||
// Platform: DOS
|
||||
// API version: 2.4
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2004 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
.file "dos_irq.S"
|
||||
|
||||
.text
|
||||
|
||||
|
||||
#define IRQ_STACK_SIZE 16384
|
||||
|
||||
#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
|
||||
#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
|
||||
#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
|
||||
#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// common
|
||||
//========================================================================
|
||||
|
||||
.balign 4
|
||||
common:
|
||||
movw $0x0400, %ax
|
||||
int $0x31
|
||||
|
||||
movl %ss:8(%ebp), %ebx
|
||||
cmpl $15, %ebx
|
||||
jbe 0f
|
||||
fail:
|
||||
orl $-1, %eax
|
||||
popl %edi
|
||||
popl %ebx
|
||||
leave
|
||||
ret
|
||||
|
||||
0:
|
||||
movl %ebx, %edi
|
||||
imull $IRQ_WRAPPER_LEN, %edi
|
||||
addl $__irq_wrapper_0, %edi
|
||||
|
||||
cmpb $7, %bl
|
||||
jbe 1f
|
||||
movb %dl, %dh
|
||||
subb $8, %dh
|
||||
1:
|
||||
addb %dh, %bl
|
||||
ret
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwInstallDOSIrq()
|
||||
//========================================================================
|
||||
|
||||
.balign 4
|
||||
.global __glfwInstallDOSIrq
|
||||
__glfwInstallDOSIrq:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl %ebx
|
||||
pushl %edi
|
||||
|
||||
call common
|
||||
|
||||
cmpl $0, IRQ_HOOK(%edi)
|
||||
jne fail
|
||||
|
||||
pushl $IRQ_WRAPPER_LEN
|
||||
pushl %edi
|
||||
call __go32_dpmi_lock_code
|
||||
addl $8, %esp
|
||||
testl %eax, %eax
|
||||
jnz fail
|
||||
|
||||
/* OLD >>
|
||||
pushl $IRQ_STACK_SIZE
|
||||
call _pc_malloc
|
||||
popl %edx
|
||||
testl %eax, %eax
|
||||
jz fail
|
||||
addl %edx, %eax
|
||||
movl %eax, IRQ_STACK(%edi)
|
||||
<< OLD */
|
||||
|
||||
/* MG: NEW >> */
|
||||
pushl $IRQ_STACK_SIZE
|
||||
call _malloc
|
||||
popl %edx
|
||||
testl %eax, %eax
|
||||
jz fail
|
||||
|
||||
pushl %edx
|
||||
pushl %eax
|
||||
call __go32_dpmi_lock_data
|
||||
addl $8, %esp
|
||||
testl %eax, %eax
|
||||
jnz fail
|
||||
subl $8, %esp
|
||||
popl %eax
|
||||
popl %edx
|
||||
|
||||
addl %edx, %eax
|
||||
movl %eax, IRQ_STACK(%edi)
|
||||
/* << NEW */
|
||||
|
||||
movl ___djgpp_ds_alias, %eax
|
||||
movl %eax, IRQ_STACK+4(%edi)
|
||||
|
||||
movl %ss:12(%ebp), %eax
|
||||
movl %eax, IRQ_HOOK(%edi)
|
||||
|
||||
movw $0x0204, %ax
|
||||
int $0x31
|
||||
movl %edx, IRQ_OLD(%edi)
|
||||
movw %cx, IRQ_OLD+4(%edi)
|
||||
movw $0x0205, %ax
|
||||
movl %edi, %edx
|
||||
movl %cs, %ecx
|
||||
int $0x31
|
||||
|
||||
done:
|
||||
xorl %eax, %eax
|
||||
popl %edi
|
||||
popl %ebx
|
||||
leave
|
||||
ret
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwRemoveDOSIrq()
|
||||
//========================================================================
|
||||
.balign 4
|
||||
.global __glfwRemoveDOSIrq
|
||||
__glfwRemoveDOSIrq:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl %ebx
|
||||
pushl %edi
|
||||
|
||||
call common
|
||||
|
||||
cmpl $0, IRQ_HOOK(%edi)
|
||||
je fail
|
||||
|
||||
movl $0, IRQ_HOOK(%edi)
|
||||
|
||||
movw $0x0205, %ax
|
||||
movl IRQ_OLD(%edi), %edx
|
||||
movl IRQ_OLD+4(%edi), %ecx
|
||||
int $0x31
|
||||
|
||||
movl IRQ_STACK(%edi), %eax
|
||||
subl $IRQ_STACK_SIZE, %eax
|
||||
pushl %eax
|
||||
call _free
|
||||
popl %eax
|
||||
|
||||
jmp done
|
||||
|
||||
|
||||
//========================================================================
|
||||
// IRQ wrapper code for all 16 different IRQs
|
||||
//========================================================================
|
||||
|
||||
#define WRAPPER(x) ; \
|
||||
.balign 4 ; \
|
||||
__irq_wrapper_##x: ; \
|
||||
pushal ; \
|
||||
pushl %ds ; \
|
||||
pushl %es ; \
|
||||
pushl %fs ; \
|
||||
pushl %gs ; \
|
||||
movl %ss, %ebx ; \
|
||||
movl %esp, %esi ; \
|
||||
lss %cs:__irq_stack_##x, %esp ; \
|
||||
pushl %ss ; \
|
||||
pushl %ss ; \
|
||||
popl %es ; \
|
||||
popl %ds ; \
|
||||
movl ___djgpp_dos_sel, %fs ; \
|
||||
pushl %fs ; \
|
||||
popl %gs ; \
|
||||
call *__irq_hook_##x ; \
|
||||
movl %ebx, %ss ; \
|
||||
movl %esi, %esp ; \
|
||||
testl %eax, %eax ; \
|
||||
popl %gs ; \
|
||||
popl %fs ; \
|
||||
popl %es ; \
|
||||
popl %ds ; \
|
||||
popal ; \
|
||||
jz __irq_ignore_##x ; \
|
||||
__irq_bypass_##x: ; \
|
||||
ljmp *%cs:__irq_old_##x ; \
|
||||
__irq_ignore_##x: ; \
|
||||
iret ; \
|
||||
.balign 4 ; \
|
||||
__irq_old_##x: ; \
|
||||
.long 0, 0 ; \
|
||||
__irq_hook_##x: ; \
|
||||
.long 0 ; \
|
||||
__irq_stack_##x: ; \
|
||||
.long 0, 0
|
||||
|
||||
WRAPPER(0);
|
||||
WRAPPER(1);
|
||||
WRAPPER(2);
|
||||
WRAPPER(3);
|
||||
WRAPPER(4);
|
||||
WRAPPER(5);
|
||||
WRAPPER(6);
|
||||
WRAPPER(7);
|
||||
WRAPPER(8);
|
||||
WRAPPER(9);
|
||||
WRAPPER(10);
|
||||
WRAPPER(11);
|
||||
WRAPPER(12);
|
||||
WRAPPER(13);
|
||||
WRAPPER(14);
|
||||
WRAPPER(15);
|
94
libs/glfw/lib/dos/dos_joystick.c
Normal file
94
libs/glfw/lib/dos/dos_joystick.c
Normal file
@ -0,0 +1,94 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_joystick.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitJoysticks() - Initialize joystick interface
|
||||
//========================================================================
|
||||
|
||||
void _glfwInitJoysticks( void )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateJoysticks() - Close all opened joystick handles
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateJoysticks( void )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetJoystickParam() - Determine joystick capabilities
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickParam( int joy, int param )
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetJoystickPos() - Get joystick axis positions
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetJoystickButtons() - Get joystick button states
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons,
|
||||
int numbuttons )
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
694
libs/glfw/lib/dos/dos_keyboard.c
Normal file
694
libs/glfw/lib/dos/dos_keyboard.c
Normal file
@ -0,0 +1,694 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_keyboard.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Most of the code in this source file is based on two sources of
|
||||
// information:
|
||||
// 1) The Allegro DOS keyboard driver (allegro\src\dos\dkeybd.c)
|
||||
// 2) The document "IBM PC KEYBOARD INFORMATION FOR SOFTWARE DEVELOPERS"
|
||||
// by Chris Giese.
|
||||
//========================================================================
|
||||
|
||||
//========================================================================
|
||||
// Unicode in GLFW for DOS
|
||||
// =======================
|
||||
//
|
||||
// Keyboard mapping tables in GLFW for DOS use Unicode encoding. The codes
|
||||
// are 16-bit unsigned integers, and thus do not cover the entire Unicode
|
||||
// standard (but a great deal is covered).
|
||||
//
|
||||
// Keys or characters that are not supported by GLFW (for instance the
|
||||
// PrtScr or Windows keys that are found on most PC keyboards) are coded
|
||||
// with 0xFFFF ("not a character" according to the Unicode standard).
|
||||
//
|
||||
// GLFW special keys, as defined in glfw.h (e.g. GLFW_KEY_LSHIFT) are
|
||||
// encoded in the private area of the Unicode standard (i.e. codes in the
|
||||
// range E000-F8FF). The encoding is as follows:
|
||||
//
|
||||
// unicode = 0xE000 + glfw_key - GLFW_KEY_SPECIAL;
|
||||
//
|
||||
// Every key in the keyboard matrix has a description consisting of four
|
||||
// entries: Normal, Shift, Caps, and AltGr.
|
||||
//========================================================================
|
||||
|
||||
//========================================================================
|
||||
// Definitions
|
||||
//========================================================================
|
||||
|
||||
// Keyboard interrupt number
|
||||
#define KEYB_IRQ 1
|
||||
|
||||
// Qualifier flags
|
||||
#define QUAL_SCROLOCK 0x0001 // Same bits as for controller cmd 0xED
|
||||
#define QUAL_NUMLOCK 0x0002 // (set leds)
|
||||
#define QUAL_CAPSLOCK 0x0004 // --"--
|
||||
#define QUAL_LSHIFT 0x0008
|
||||
#define QUAL_RSHIFT 0x0010
|
||||
#define QUAL_LALT 0x0020
|
||||
#define QUAL_RALT 0x0040
|
||||
#define QUAL_LCTRL 0x0080
|
||||
#define QUAL_RCTRL 0x0100
|
||||
|
||||
// Qualifier groups
|
||||
#define QUAL_MODIFIERS (QUAL_LSHIFT|QUAL_RSHIFT|QUAL_LALT|QUAL_RALT|\
|
||||
QUAL_LCTRL|QUAL_RCTRL)
|
||||
#define QUAL_LEDS (QUAL_SCROLOCK|QUAL_NUMLOCK|QUAL_CAPSLOCK)
|
||||
|
||||
|
||||
// Additional non-GLFW keys, defined here for internal processing only
|
||||
#define GLFW_KEY_CAPSLOCK (GLFW_KEY_SPECIAL+0x0200)
|
||||
#define GLFW_KEY_NUMLOCK (GLFW_KEY_SPECIAL+0x0201)
|
||||
#define GLFW_KEY_SCROLOCK (GLFW_KEY_SPECIAL+0x0202)
|
||||
#define GLFW_KEY_PAUSE (GLFW_KEY_SPECIAL+0x0203)
|
||||
|
||||
// Keymap entry definition
|
||||
struct key {
|
||||
unsigned short Normal, Caps, Shift, AltGr;
|
||||
};
|
||||
|
||||
// Keymap entry macros
|
||||
#define NOCHAR(x) {x+0xDF00,x+0xDF00,x+0xDF00,x+0xDF00}
|
||||
#define UNDEFINED {0xFFFF,0xFFFF,0xFFFF,0xFFFF}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global variables
|
||||
//========================================================================
|
||||
|
||||
static struct {
|
||||
int volatile KeyEnhanced, KeyPauseLoop, Qualifiers;
|
||||
int LedsOK;
|
||||
int Interrupt;
|
||||
} _glfwKeyDrv;
|
||||
|
||||
static int _glfwKeyboardInstalled = 0;
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// scancode_to_key_us[] - Mapping table for US keyboard layout (XT)
|
||||
//========================================================================
|
||||
|
||||
static struct key scancode_to_key_us[256] =
|
||||
{
|
||||
/* Standard hardware scancodes */
|
||||
/* 0x00 */ UNDEFINED, NOCHAR(GLFW_KEY_ESC),
|
||||
/* 0x02 */ {'1','1','!',0xFFFF}, {'2','2','@',0xFFFF},
|
||||
/* 0x04 */ {'3','3','#',0xFFFF}, {'4','4','$',0xFFFF},
|
||||
/* 0x06 */ {'5','5','%',0xFFFF}, {'6','6','^',0xFFFF},
|
||||
/* 0x08 */ {'7','7','&',0xFFFF}, {'8','8','*',0xFFFF},
|
||||
/* 0x0A */ {'9','9','(',0xFFFF}, {'0','0',')',0xFFFF},
|
||||
/* 0x0C */ {'-','-','_',0xFFFF}, {'=','=','+',0xFFFF},
|
||||
/* 0x0E */ NOCHAR(GLFW_KEY_BACKSPACE), NOCHAR(GLFW_KEY_TAB),
|
||||
/* 0x10 */ {'q','Q','Q',0xFFFF}, {'w','W','W',0xFFFF},
|
||||
/* 0x12 */ {'e','E','E',0xFFFF}, {'r','R','R',0xFFFF},
|
||||
/* 0x14 */ {'t','T','T',0xFFFF}, {'y','Y','Y',0xFFFF},
|
||||
/* 0x16 */ {'u','U','U',0xFFFF}, {'i','I','I',0xFFFF},
|
||||
/* 0x18 */ {'o','O','O',0xFFFF}, {'p','P','P',0xFFFF},
|
||||
/* 0x1A */ {'[','[','{',0xFFFF}, {']',']','}',0xFFFF},
|
||||
/* 0x1C */ NOCHAR(GLFW_KEY_ENTER), NOCHAR(GLFW_KEY_LCTRL),
|
||||
/* 0x1E */ {'a','A','A',0xFFFF}, {'s','S','S',0xFFFF},
|
||||
/* 0x20 */ {'d','D','D',0xFFFF}, {'f','F','F',0xFFFF},
|
||||
/* 0x22 */ {'g','G','G',0xFFFF}, {'h','H','H',0xFFFF},
|
||||
/* 0x24 */ {'j','J','J',0xFFFF}, {'k','K','K',0xFFFF},
|
||||
/* 0x26 */ {'l','L','L',0xFFFF}, {';',';',':',0xFFFF},
|
||||
/* 0x28 */ {'\'','\'','"',0xFFFF}, {'\\','\\','|',0xFFFF},
|
||||
/* 0x2A */ NOCHAR(GLFW_KEY_LSHIFT), {'\\','\\','|',0xFFFF},
|
||||
/* 0x2C */ {'z','Z','Z',0xFFFF}, {'x','X','X',0xFFFF},
|
||||
/* 0x2E */ {'c','C','C',0xFFFF}, {'v','V','V',0xFFFF},
|
||||
/* 0x30 */ {'b','B','B',0xFFFF}, {'n','N','N',0xFFFF},
|
||||
/* 0x32 */ {'m','M','M',0xFFFF}, {',',',','<',0xFFFF},
|
||||
/* 0x34 */ {'.','.','>',0xFFFF}, {'/','/','?',0xFFFF},
|
||||
/* 0x36 */ NOCHAR(GLFW_KEY_RSHIFT), NOCHAR(GLFW_KEY_KP_MULTIPLY),
|
||||
/* 0x38 */ NOCHAR(GLFW_KEY_LALT), {' ',' ',' ',0xFFFF},
|
||||
/* 0x3A */ NOCHAR(GLFW_KEY_CAPSLOCK), NOCHAR(GLFW_KEY_F1),
|
||||
/* 0x3C */ NOCHAR(GLFW_KEY_F2), NOCHAR(GLFW_KEY_F3),
|
||||
/* 0x3E */ NOCHAR(GLFW_KEY_F4), NOCHAR(GLFW_KEY_F5),
|
||||
/* 0x40 */ NOCHAR(GLFW_KEY_F6), NOCHAR(GLFW_KEY_F7),
|
||||
/* 0x42 */ NOCHAR(GLFW_KEY_F8), NOCHAR(GLFW_KEY_F9),
|
||||
/* 0x44 */ NOCHAR(GLFW_KEY_F10), NOCHAR(GLFW_KEY_NUMLOCK),
|
||||
/* 0x46 */ NOCHAR(GLFW_KEY_SCROLOCK), NOCHAR(GLFW_KEY_KP_7),
|
||||
/* 0x48 */ NOCHAR(GLFW_KEY_KP_8), NOCHAR(GLFW_KEY_KP_9),
|
||||
/* 0x4A */ NOCHAR(GLFW_KEY_KP_SUBTRACT), NOCHAR(GLFW_KEY_KP_4),
|
||||
/* 0x4C */ NOCHAR(GLFW_KEY_KP_5), NOCHAR(GLFW_KEY_KP_6),
|
||||
/* 0x4E */ NOCHAR(GLFW_KEY_KP_ADD), NOCHAR(GLFW_KEY_KP_1),
|
||||
/* 0x50 */ NOCHAR(GLFW_KEY_KP_2), NOCHAR(GLFW_KEY_KP_3),
|
||||
/* 0x52 */ NOCHAR(GLFW_KEY_KP_0), NOCHAR(GLFW_KEY_KP_DECIMAL),
|
||||
/* 0x54 */ UNDEFINED, /* PRTSCR */ UNDEFINED,
|
||||
/* 0x56 */ {'\\','\\','|',0xFFFF}, NOCHAR(GLFW_KEY_F11),
|
||||
/* 0x58 */ NOCHAR(GLFW_KEY_F12), UNDEFINED,
|
||||
/* 0x5A */ UNDEFINED, UNDEFINED, /* LWIN */
|
||||
/* 0x5C */ UNDEFINED, /* RWIN */ UNDEFINED, /* MENU */
|
||||
/* 0x5E */ UNDEFINED, UNDEFINED,
|
||||
/* 0x60 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x62 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x64 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x66 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x68 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x6A */ UNDEFINED, UNDEFINED,
|
||||
/* 0x6C */ UNDEFINED, UNDEFINED,
|
||||
/* 0x6E */ UNDEFINED, UNDEFINED,
|
||||
/* 0x70 */ UNDEFINED, /* KANA */ UNDEFINED,
|
||||
/* 0x72 */ UNDEFINED, UNDEFINED, /* ABNT_C1 */
|
||||
/* 0x74 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x76 */ UNDEFINED, UNDEFINED,
|
||||
/* 0x78 */ UNDEFINED, UNDEFINED, /* CONVERT */
|
||||
/* 0x7A */ UNDEFINED, UNDEFINED, /* NOCONVERT */
|
||||
/* 0x7C */ UNDEFINED, UNDEFINED, /* YEN */
|
||||
/* 0x7E */ UNDEFINED, UNDEFINED,
|
||||
|
||||
/* Extended hardware scancodes (index=scancode+0x80) */
|
||||
/* 0xE000 */ UNDEFINED, NOCHAR(GLFW_KEY_ESC),
|
||||
/* 0xE002 */ {'1','1','!',0xFFFF}, {'2','2','@',0xFFFF},
|
||||
/* 0xE004 */ {'3','3','#',0xFFFF}, {'4','4','$',0xFFFF},
|
||||
/* 0xE006 */ {'5','5','%',0xFFFF}, {'6','6','^',0xFFFF},
|
||||
/* 0xE008 */ {'7','7','&',0xFFFF}, {'8','8','*',0xFFFF},
|
||||
/* 0xE00A */ {'9','9','(',0xFFFF}, {'0','0',')',0xFFFF},
|
||||
/* 0xE00C */ {'-','-','_',0xFFFF}, {'=','=','+',0xFFFF},
|
||||
/* 0xE00E */ NOCHAR(GLFW_KEY_BACKSPACE), NOCHAR(GLFW_KEY_TAB),
|
||||
/* 0xE010 */ UNDEFINED, /* CIRCUMFLEX */ UNDEFINED, /* AT */
|
||||
/* 0xE012 */ UNDEFINED, /* COLON2 */ {'r','R','R',0xFFFF},
|
||||
/* 0xE014 */ UNDEFINED, /* KANJI */ {'y','Y','Y',0xFFFF},
|
||||
/* 0xE016 */ {'u','U','U',0xFFFF}, {'i','I','I',0xFFFF},
|
||||
/* 0xE018 */ {'o','O','O',0xFFFF}, {'p','P','P',0xFFFF},
|
||||
/* 0xE01A */ {'[','[','{',0xFFFF}, {']',']','}',0xFFFF},
|
||||
/* 0xE01C */ NOCHAR(GLFW_KEY_KP_ENTER), NOCHAR(GLFW_KEY_RCTRL),
|
||||
/* 0xE01E */ {'a','A','A',0xFFFF}, {'s','S','S',0xFFFF},
|
||||
/* 0xE020 */ {'d','D','D',0xFFFF}, {'f','F','F',0xFFFF},
|
||||
/* 0xE022 */ {'g','G','G',0xFFFF}, {'h','H','H',0xFFFF},
|
||||
/* 0xE024 */ {'j','J','J',0xFFFF}, {'k','K','K',0xFFFF},
|
||||
/* 0xE026 */ {'l','L','L',0xFFFF}, {';',';',':',0xFFFF},
|
||||
/* 0xE028 */ {'\'','\'','"',0xFFFF}, {'`','`','~',0xFFFF},
|
||||
/* 0xE02A */ UNDEFINED, {'\\','\\','|',0xFFFF},
|
||||
/* 0xE02C */ {'z','Z','Z',0xFFFF}, {'x','X','X',0xFFFF},
|
||||
/* 0xE02E */ {'c','C','C',0xFFFF}, {'v','V','V',0xFFFF},
|
||||
/* 0xE030 */ {'b','B','B',0xFFFF}, {'n','N','N',0xFFFF},
|
||||
/* 0xE032 */ {'m','M','M',0xFFFF}, {',',',','<',0xFFFF},
|
||||
/* 0xE034 */ {'.','.','>',0xFFFF}, NOCHAR(GLFW_KEY_KP_DIVIDE),
|
||||
/* 0xE036 */ UNDEFINED, UNDEFINED, /* PRTSCR */
|
||||
/* 0xE038 */ NOCHAR(GLFW_KEY_RALT), {' ',' ',' ',0xFFFF},
|
||||
/* 0xE03A */ NOCHAR(GLFW_KEY_CAPSLOCK), NOCHAR(GLFW_KEY_F1),
|
||||
/* 0xE03C */ NOCHAR(GLFW_KEY_F2), NOCHAR(GLFW_KEY_F3),
|
||||
/* 0xE03E */ NOCHAR(GLFW_KEY_F4), NOCHAR(GLFW_KEY_F5),
|
||||
/* 0xE040 */ NOCHAR(GLFW_KEY_F6), NOCHAR(GLFW_KEY_F7),
|
||||
/* 0xE042 */ NOCHAR(GLFW_KEY_F8), NOCHAR(GLFW_KEY_F9),
|
||||
/* 0xE044 */ NOCHAR(GLFW_KEY_F10), NOCHAR(GLFW_KEY_NUMLOCK),
|
||||
/* 0xE046 */ NOCHAR(GLFW_KEY_PAUSE), NOCHAR(GLFW_KEY_HOME),
|
||||
/* 0xE048 */ NOCHAR(GLFW_KEY_UP), NOCHAR(GLFW_KEY_PAGEUP),
|
||||
/* 0xE04A */ NOCHAR(GLFW_KEY_KP_SUBTRACT), NOCHAR(GLFW_KEY_LEFT),
|
||||
/* 0xE04C */ NOCHAR(GLFW_KEY_KP_5), NOCHAR(GLFW_KEY_RIGHT),
|
||||
/* 0xE04E */ NOCHAR(GLFW_KEY_KP_ADD), NOCHAR(GLFW_KEY_END),
|
||||
/* 0xE050 */ NOCHAR(GLFW_KEY_DOWN), NOCHAR(GLFW_KEY_PAGEDOWN),
|
||||
/* 0xE052 */ NOCHAR(GLFW_KEY_INSERT), NOCHAR(GLFW_KEY_DEL),
|
||||
/* 0xE054 */ UNDEFINED, /* PRTSCR */ UNDEFINED,
|
||||
/* 0xE056 */ {'\\','\\','|',0xFFFF}, NOCHAR(GLFW_KEY_F11),
|
||||
/* 0xE058 */ NOCHAR(GLFW_KEY_F12), UNDEFINED,
|
||||
/* 0xE05A */ UNDEFINED, UNDEFINED, /* LWIN */
|
||||
/* 0xE05C */ UNDEFINED, /* RWIN */ UNDEFINED, /* MENU */
|
||||
/* 0xE05E */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE060 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE062 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE064 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE066 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE068 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE06A */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE06C */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE06E */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE070 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE072 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE074 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE076 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE078 */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE07A */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE07C */ UNDEFINED, UNDEFINED,
|
||||
/* 0xE07E */ UNDEFINED, UNDEFINED
|
||||
};
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Keyboard Decoding *************************************************
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwMapRawKey() - Map a raw scancode to a Unicode character
|
||||
//========================================================================
|
||||
|
||||
static int _glfwMapRawKey( int scancode, int qualifiers )
|
||||
{
|
||||
struct key *keyvals;
|
||||
int keycode;
|
||||
|
||||
// Get possible key codings for this scancode
|
||||
keyvals = &scancode_to_key_us[ scancode ];
|
||||
|
||||
// Select Unicode code depending on qualifiers
|
||||
if( qualifiers & QUAL_RALT )
|
||||
{
|
||||
keycode = keyvals->AltGr;
|
||||
}
|
||||
else if( qualifiers & (QUAL_LSHIFT|QUAL_RSHIFT) )
|
||||
{
|
||||
if( (qualifiers & QUAL_CAPSLOCK) &&
|
||||
(keyvals->Normal != keyvals->Caps) )
|
||||
{
|
||||
keycode = keyvals->Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
keycode = keyvals->Shift;
|
||||
}
|
||||
}
|
||||
else if( qualifiers & QUAL_CAPSLOCK )
|
||||
{
|
||||
keycode = keyvals->Caps;
|
||||
}
|
||||
else
|
||||
{
|
||||
keycode = keyvals->Normal;
|
||||
}
|
||||
|
||||
// Special interpretations
|
||||
if( keycode >= 0xE000 && keycode <= 0xE8FF )
|
||||
{
|
||||
keycode = -(keycode - 0xE000 + GLFW_KEY_SPECIAL);
|
||||
}
|
||||
else if( keycode == 0xFFFF )
|
||||
{
|
||||
keycode = 0;
|
||||
}
|
||||
|
||||
return keycode;
|
||||
} ENDOFUNC(_glfwMapRawKey)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwCreateKeyEvent() - Add a keyboard event to the event FIFO
|
||||
//========================================================================
|
||||
|
||||
static void _glfwCreateKeyEvent( int scancode, int qualifiers, int action )
|
||||
{
|
||||
_GLFWdosevent event;
|
||||
struct key_event *key = &event.Key;
|
||||
|
||||
// Create event
|
||||
key->Type = _GLFW_DOS_KEY_EVENT;
|
||||
key->Key = _glfwMapRawKey( scancode, qualifiers );
|
||||
key->KeyNoMod = _glfwMapRawKey( scancode, QUAL_CAPSLOCK );
|
||||
key->Action = action;
|
||||
|
||||
// Post event
|
||||
_glfwPostDOSEvent( &event );
|
||||
} ENDOFUNC(_glfwCreateKeyEvent)
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Keyboard Communication ********************************************
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwWaitForReadReady() / _glfwWaitForWriteReady()
|
||||
// Wait for the keyboard controller to set the ready-for-read/write bit
|
||||
//========================================================================
|
||||
|
||||
static int _glfwWaitForReadReady( void )
|
||||
{
|
||||
int timeout = 16384;
|
||||
while( (timeout>0) && (!(inportb(0x64)&1)) ) timeout--;
|
||||
return timeout > 0;
|
||||
} ENDOFUNC(_glfwWaitForReadReady)
|
||||
|
||||
static int _glfwWaitForWriteReady( void )
|
||||
{
|
||||
int timeout = 4096;
|
||||
while( (timeout>0) && (inportb(0x64)&2) ) timeout--;
|
||||
return timeout > 0;
|
||||
} ENDOFUNC(_glfwWaitForWriteReady)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwSendKeyboardByte() - Send a byte to the keyboard controller
|
||||
//========================================================================
|
||||
|
||||
static int _glfwSendKeyboardByte( unsigned char data )
|
||||
{
|
||||
int resends = 4;
|
||||
int timeout, ret;
|
||||
|
||||
do
|
||||
{
|
||||
if( !_glfwWaitForWriteReady() ) return 0;
|
||||
|
||||
outportb( 0x60, data );
|
||||
|
||||
timeout = 4096;
|
||||
while( --timeout > 0 )
|
||||
{
|
||||
if( !_glfwWaitForReadReady() ) return 0;
|
||||
|
||||
ret = inportb( 0x60 );
|
||||
if( ret == 0xFA ) return 1;
|
||||
if( ret == 0xFE ) break;
|
||||
}
|
||||
}
|
||||
while( (resends-- > 0) && (timeout > 0) );
|
||||
|
||||
return 0;
|
||||
} ENDOFUNC(_glfwSendKeyboardByte)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwSendKeyboardCommand() - Send a command sequence to the keyboard
|
||||
//========================================================================
|
||||
|
||||
static int _glfwSendKeyboardCommand( unsigned char *cmd, int count )
|
||||
{
|
||||
int i, ok = 1;
|
||||
|
||||
// Force atomic keyboard communication session
|
||||
if( !_glfwKeyDrv.Interrupt ) DISABLE();
|
||||
|
||||
// Send command sequence
|
||||
for( i = 0; i < count; ++ i )
|
||||
{
|
||||
if( !_glfwSendKeyboardByte( cmd[i] ) )
|
||||
{
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send "clear output buffer, enable keyboard"
|
||||
_glfwSendKeyboardByte( 0xF4 );
|
||||
|
||||
if( !_glfwKeyDrv.Interrupt ) ENABLE();
|
||||
|
||||
return ok;
|
||||
} ENDOFUNC(_glfwSendKeyboardCommand)
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Miscellaneous Handling ********************************************
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwUpdateLeds() - Update keyboard leds
|
||||
//========================================================================
|
||||
|
||||
static void _glfwUpdateLeds( int qualifiers )
|
||||
{
|
||||
unsigned char cmd[2];
|
||||
cmd[0] = 0xED;
|
||||
cmd[1] = qualifiers & 7;
|
||||
_glfwSendKeyboardCommand( cmd, 2 );
|
||||
} ENDOFUNC(_glfwUpdateLeds)
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Keyboard Interrupt Handler ****************************************
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwHandleCode() - Handle new scancode event
|
||||
//========================================================================
|
||||
|
||||
static void _glfwHandleCode( int scancode, int keypress )
|
||||
{
|
||||
if( scancode == GLFW_KEY_PAUSE && keypress )
|
||||
{
|
||||
// Pause
|
||||
_glfwCreateKeyEvent( GLFW_KEY_PAUSE, 0, GLFW_PRESS );
|
||||
}
|
||||
else if( scancode )
|
||||
{
|
||||
int tmp, qualifier;
|
||||
|
||||
// Check if this is a qualifier key
|
||||
tmp = scancode_to_key_us[scancode].Normal;
|
||||
tmp += GLFW_KEY_SPECIAL - 0xE000;
|
||||
if( tmp == GLFW_KEY_LSHIFT ) qualifier = QUAL_LSHIFT;
|
||||
else if( tmp == GLFW_KEY_RSHIFT ) qualifier = QUAL_RSHIFT;
|
||||
else if( tmp == GLFW_KEY_LCTRL ) qualifier = QUAL_LCTRL;
|
||||
else if( tmp == GLFW_KEY_RCTRL ) qualifier = QUAL_RCTRL;
|
||||
else if( tmp == GLFW_KEY_LALT ) qualifier = QUAL_LALT;
|
||||
else if( tmp == GLFW_KEY_RALT ) qualifier = QUAL_RALT;
|
||||
else if( tmp == GLFW_KEY_NUMLOCK ) qualifier = QUAL_NUMLOCK;
|
||||
else if( tmp == GLFW_KEY_SCROLOCK ) qualifier = QUAL_SCROLOCK;
|
||||
else if( tmp == GLFW_KEY_CAPSLOCK ) qualifier = QUAL_CAPSLOCK;
|
||||
else qualifier = 0;
|
||||
|
||||
if( keypress )
|
||||
{
|
||||
// Key press
|
||||
if( qualifier & QUAL_MODIFIERS )
|
||||
{
|
||||
_glfwKeyDrv.Qualifiers |= qualifier;
|
||||
}
|
||||
if( !(qualifier & QUAL_LEDS) )
|
||||
{
|
||||
_glfwCreateKeyEvent( scancode, _glfwKeyDrv.Qualifiers,
|
||||
GLFW_PRESS );
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfwKeyDrv.Qualifiers ^= qualifier;
|
||||
_glfwUpdateLeds( _glfwKeyDrv.Qualifiers );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Key release
|
||||
if( qualifier & QUAL_MODIFIERS )
|
||||
{
|
||||
_glfwKeyDrv.Qualifiers &= ~qualifier;
|
||||
}
|
||||
if( !(qualifier & QUAL_LEDS) )
|
||||
{
|
||||
_glfwCreateKeyEvent( scancode, _glfwKeyDrv.Qualifiers,
|
||||
GLFW_RELEASE );
|
||||
}
|
||||
}
|
||||
}
|
||||
} ENDOFUNC(_glfwHandleCode)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwKeyInterrupt() - Keyboard interrupt routine
|
||||
//========================================================================
|
||||
|
||||
static int _glfwKeyInterrupt( void )
|
||||
{
|
||||
unsigned char keycode, scancode;
|
||||
|
||||
_glfwKeyDrv.Interrupt ++;
|
||||
|
||||
keycode = inportb( 0x60 );
|
||||
|
||||
if( keycode <= 0xE1 )
|
||||
{
|
||||
if( _glfwKeyDrv.KeyPauseLoop )
|
||||
{
|
||||
if( ! --_glfwKeyDrv.KeyPauseLoop )
|
||||
_glfwHandleCode( GLFW_KEY_PAUSE, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( keycode )
|
||||
{
|
||||
case 0xE0:
|
||||
_glfwKeyDrv.KeyEnhanced = 1;
|
||||
break;
|
||||
case 0xE1:
|
||||
_glfwKeyDrv.KeyPauseLoop = 5;
|
||||
break;
|
||||
default:
|
||||
scancode = keycode & 0x7F;
|
||||
if( _glfwKeyDrv.KeyEnhanced )
|
||||
{
|
||||
scancode |= 0x80;
|
||||
_glfwKeyDrv.KeyEnhanced = 0;
|
||||
}
|
||||
_glfwHandleCode( scancode, !(keycode & 0x80) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_glfwKeyDrv.Interrupt --;
|
||||
|
||||
if( ((keycode==0x4F) || (keycode==0x53)) &&
|
||||
(_glfwKeyDrv.Qualifiers & QUAL_LCTRL) &&
|
||||
(_glfwKeyDrv.Qualifiers & QUAL_RALT) )
|
||||
{
|
||||
// Hack alert:
|
||||
// Only SIGINT (but not Ctrl-Break) calls the destructors and will
|
||||
// safely clean up
|
||||
asm(
|
||||
"movb $0x79,%%al\n\t"
|
||||
"call ___djgpp_hw_exception\n\t"
|
||||
:
|
||||
:
|
||||
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
asm(
|
||||
"inb $0x61,%%al\n\t"
|
||||
"movb %%al,%%ah\n\t"
|
||||
"orb $0x80,%%al\n\t"
|
||||
"outb %%al,$0x61\n\t"
|
||||
"xchgb %%al,%%ah\n\t"
|
||||
"outb %%al,$0x61\n\t"
|
||||
"movb $0x20,%%al\n\t"
|
||||
"outb %%al,$0x20\n\t"
|
||||
:
|
||||
:
|
||||
: "%eax"
|
||||
);
|
||||
|
||||
return 0;
|
||||
} ENDOFUNC(_glfwKeyInterrupt)
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Keyboard driver interface functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitKeyboard() - Initialize keyboard driver
|
||||
//========================================================================
|
||||
|
||||
int _glfwInitKeyboard( void )
|
||||
{
|
||||
int s1, s2, s3;
|
||||
|
||||
if( _glfwKeyboardInstalled )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Init keyboard state
|
||||
_glfwKeyDrv.LedsOK = 1;
|
||||
_glfwKeyDrv.Interrupt = 0;
|
||||
_glfwKeyDrv.KeyEnhanced = 0;
|
||||
_glfwKeyDrv.KeyPauseLoop = 0;
|
||||
|
||||
// Lock data buffers
|
||||
LOCKDATA(_glfwKeyboardInstalled);
|
||||
LOCKDATA(_glfwKeyDrv);
|
||||
LOCKDATA(scancode_to_key_us);
|
||||
|
||||
// Lock functions
|
||||
LOCKFUNC(_glfwMapRawKey);
|
||||
LOCKFUNC(_glfwCreateKeyEvent);
|
||||
LOCKFUNC(_glfwWaitForReadReady);
|
||||
LOCKFUNC(_glfwWaitForWriteReady);
|
||||
LOCKFUNC(_glfwSendKeyboardByte);
|
||||
LOCKFUNC(_glfwSendKeyboardCommand);
|
||||
LOCKFUNC(_glfwUpdateLeds);
|
||||
LOCKFUNC(_glfwHandleCode);
|
||||
LOCKFUNC(_glfwKeyInterrupt);
|
||||
|
||||
_farsetsel( __djgpp_dos_sel );
|
||||
_farnspokew( 0x41c, _farnspeekw(0x41a) );
|
||||
|
||||
// Get current state of key qualifiers
|
||||
s1 = _farnspeekb( 0x417 );
|
||||
s2 = _farnspeekb( 0x418 );
|
||||
s3 = _farnspeekb( 0x496 );
|
||||
_glfwKeyDrv.Qualifiers = 0;
|
||||
if( s1 & 1 ) _glfwKeyDrv.Qualifiers |= QUAL_RSHIFT;
|
||||
if( s1 & 2 ) _glfwKeyDrv.Qualifiers |= QUAL_LSHIFT;
|
||||
if( s2 & 1 ) _glfwKeyDrv.Qualifiers |= QUAL_LCTRL;
|
||||
if( s2 & 2 ) _glfwKeyDrv.Qualifiers |= QUAL_LALT;
|
||||
if( s3 & 4 ) _glfwKeyDrv.Qualifiers |= QUAL_RCTRL;
|
||||
if( s3 & 8 ) _glfwKeyDrv.Qualifiers |= QUAL_RALT;
|
||||
if( s1 & 16 ) _glfwKeyDrv.Qualifiers |= QUAL_SCROLOCK;
|
||||
if( s1 & 32 ) _glfwKeyDrv.Qualifiers |= QUAL_NUMLOCK;
|
||||
if( s1 & 64 ) _glfwKeyDrv.Qualifiers |= QUAL_CAPSLOCK;
|
||||
_glfwUpdateLeds( _glfwKeyDrv.Qualifiers );
|
||||
|
||||
// Install keyboard interrupt handler
|
||||
if( _glfwInstallDOSIrq( KEYB_IRQ, _glfwKeyInterrupt ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
_glfwKeyboardInstalled = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateKeyboard() - Terminate keyboard driver
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateKeyboard( void )
|
||||
{
|
||||
int s1, s2, s3;
|
||||
|
||||
if( !_glfwKeyboardInstalled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwKeyboardInstalled = 0;
|
||||
|
||||
// Uninstall keyboard interrupt handler
|
||||
_glfwRemoveDOSIrq( KEYB_IRQ );
|
||||
|
||||
_farsetsel( __djgpp_dos_sel );
|
||||
_farnspokew( 0x41c, _farnspeekw(0x41a) );
|
||||
|
||||
// Set current state of key qualifiers
|
||||
s1 = _farnspeekb( 0x417 ) & 0x80;
|
||||
s2 = _farnspeekb( 0x418 ) & 0xFC;
|
||||
s3 = _farnspeekb( 0x496 ) & 0xF3;
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_RSHIFT) s1 |= 1;
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_LSHIFT) s1 |= 2;
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_LCTRL) {s2 |= 1; s1 |= 4;}
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_LALT) {s2 |= 2; s1 |= 8;}
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_RCTRL) {s3 |= 4; s1 |= 4;}
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_RALT) {s3 |= 8; s1 |= 8;}
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_SCROLOCK) s1 |= 16;
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_NUMLOCK) s1 |= 32;
|
||||
if(_glfwKeyDrv.Qualifiers & QUAL_CAPSLOCK) s1 |= 64;
|
||||
_farnspokeb( 0x417, s1 );
|
||||
_farnspokeb( 0x418, s2 );
|
||||
_farnspokeb( 0x496, s3 );
|
||||
_glfwUpdateLeds( _glfwKeyDrv.Qualifiers );
|
||||
}
|
337
libs/glfw/lib/dos/dos_mouse.c
Normal file
337
libs/glfw/lib/dos/dos_mouse.c
Normal file
@ -0,0 +1,337 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_mouse.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
//========================================================================
|
||||
// Most of the code in this source file is based on the mouse driver in
|
||||
// Daniel Borca's GLUT implementation for DOS/MESA.
|
||||
//========================================================================
|
||||
|
||||
//========================================================================
|
||||
// Definitions
|
||||
//========================================================================
|
||||
|
||||
#define _GLFW_MOUSE_STACK_SIZE 16384
|
||||
|
||||
|
||||
// Assembler function prototypes
|
||||
extern void _glfwMouseWrap( void );
|
||||
extern int _glfwMouseWrap_end[];
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global variables
|
||||
//========================================================================
|
||||
|
||||
static int _glfwMouseInstalled = 0;
|
||||
|
||||
static struct {
|
||||
long Callback;
|
||||
int Emulate3;
|
||||
int OldX, OldY, OldB;
|
||||
__dpmi_regs Regs;
|
||||
} _glfwMouseDrv;
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Mouse Interrupt ***************************************************
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwMouseInt() - Mouse interrupt handler
|
||||
//========================================================================
|
||||
|
||||
static void _glfwMouseInt( __dpmi_regs *r )
|
||||
{
|
||||
int newx, newy, dx, dy, dz, buttons;
|
||||
_GLFWdosevent event;
|
||||
struct mousemove_event *mousemove = &event.MouseMove;
|
||||
struct mousewheel_event *mousewheel = &event.MouseWheel;
|
||||
struct mousebutton_event *mousebutton = &event.MouseButton;
|
||||
|
||||
// Calculate mouse deltas
|
||||
newx = (signed short)r->x.si;
|
||||
newy = (signed short)r->x.di;
|
||||
dx = newx - _glfwMouseDrv.OldX;
|
||||
dy = newy - _glfwMouseDrv.OldY;
|
||||
dz = (signed char)r->h.bh;
|
||||
|
||||
// Get mouse buttons status
|
||||
buttons = r->h.bl;
|
||||
|
||||
// Emulate 3rd mouse button?
|
||||
if( _glfwMouseDrv.Emulate3 )
|
||||
{
|
||||
if( (buttons & 3) == 3 )
|
||||
{
|
||||
buttons = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moved?
|
||||
if( dx || dy )
|
||||
{
|
||||
mousemove->Type = _GLFW_DOS_MOUSE_MOVE_EVENT;
|
||||
mousemove->DeltaX = dx;
|
||||
mousemove->DeltaY = dy;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
|
||||
// Mouse wheel moved?
|
||||
if( dz )
|
||||
{
|
||||
mousewheel->Type = _GLFW_DOS_MOUSE_WHEEL_EVENT;
|
||||
mousewheel->WheelDelta = dz;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
|
||||
// Button state changed?
|
||||
if( buttons != _glfwMouseDrv.OldB )
|
||||
{
|
||||
mousebutton->Type = _GLFW_DOS_MOUSE_BUTTON_EVENT;
|
||||
|
||||
// Left mouse button changed?
|
||||
if( (_glfwMouseDrv.OldB & 1) && !(buttons & 1) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_LEFT;
|
||||
mousebutton->Action = GLFW_RELEASE;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
else if( !(_glfwMouseDrv.OldB & 1) && (buttons & 1) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_LEFT;
|
||||
mousebutton->Action = GLFW_PRESS;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
|
||||
// Right mouse button changed?
|
||||
if( (_glfwMouseDrv.OldB & 2) && !(buttons & 2) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
mousebutton->Action = GLFW_RELEASE;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
else if( !(_glfwMouseDrv.OldB & 2) && (buttons & 2) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
mousebutton->Action = GLFW_PRESS;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
|
||||
// Middle mouse button changed?
|
||||
if( (_glfwMouseDrv.OldB & 4) && !(buttons & 4) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
mousebutton->Action = GLFW_RELEASE;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
else if( !(_glfwMouseDrv.OldB & 4) && (buttons & 4) )
|
||||
{
|
||||
mousebutton->Button = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
mousebutton->Action = GLFW_PRESS;
|
||||
_glfwPostDOSEvent( &event );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Remember old mouse state
|
||||
_glfwMouseDrv.OldX = newx;
|
||||
_glfwMouseDrv.OldY = newy;
|
||||
_glfwMouseDrv.OldB = buttons;
|
||||
} ENDOFUNC(_glfwMouseInt)
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitMouse() - Initialize mouse driver
|
||||
//========================================================================
|
||||
|
||||
int _glfwInitMouse( void )
|
||||
{
|
||||
int buttons;
|
||||
|
||||
// Already installed?
|
||||
if( _glfwMouseInstalled )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Reset mouse and get status
|
||||
__asm("\n\
|
||||
xorl %%eax, %%eax \n\
|
||||
int $0x33 \n\
|
||||
andl %%ebx, %%eax \n\
|
||||
movl %%eax, %0 \n\
|
||||
":"=g" (buttons)::"%eax", "%ebx");
|
||||
if( !buttons )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Lock data and functions
|
||||
LOCKDATA( _glfwMouseDrv );
|
||||
LOCKBUFF( _glfwMouseWrap_end, 8 );
|
||||
LOCKFUNC( _glfwMouseInt );
|
||||
LOCKFUNC( _glfwMouseWrap );
|
||||
|
||||
_glfwMouseWrap_end[1] = __djgpp_ds_alias;
|
||||
|
||||
// Grab a locked stack
|
||||
_glfwMouseWrap_end[0] = (int)malloc( _GLFW_MOUSE_STACK_SIZE );
|
||||
if( _glfwMouseWrap_end[0] == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
LOCKBUFF( _glfwMouseWrap_end[0], _GLFW_MOUSE_STACK_SIZE );
|
||||
|
||||
// Try to hook a call-back
|
||||
__asm("\n\
|
||||
pushl %%ds \n\
|
||||
pushl %%es \n\
|
||||
movw $0x0303, %%ax \n\
|
||||
pushl %%ds \n\
|
||||
pushl %%cs \n\
|
||||
popl %%ds \n\
|
||||
popl %%es \n\
|
||||
int $0x31 \n\
|
||||
popl %%es \n\
|
||||
popl %%ds \n\
|
||||
jc 0f \n\
|
||||
shll $16, %%ecx \n\
|
||||
movw %%dx, %%cx \n\
|
||||
movl %%ecx, %0 \n\
|
||||
0: \n\
|
||||
":"=g"(_glfwMouseDrv.Callback)
|
||||
:"S" (_glfwMouseWrap), "D"(&_glfwMouseDrv.Regs)
|
||||
:"%eax", "%ecx", "%edx");
|
||||
if( !_glfwMouseDrv.Callback )
|
||||
{
|
||||
free( (void *)_glfwMouseWrap_end[0] );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Adjust stack
|
||||
_glfwMouseWrap_end[0] += _GLFW_MOUSE_STACK_SIZE;
|
||||
|
||||
// Install the handler
|
||||
_glfwMouseDrv.Regs.x.ax = 0x000c;
|
||||
_glfwMouseDrv.Regs.x.cx = 0x7f | 0x80;
|
||||
_glfwMouseDrv.Regs.x.dx = _glfwMouseDrv.Callback & 0xffff;
|
||||
_glfwMouseDrv.Regs.x.es = _glfwMouseDrv.Callback >> 16;
|
||||
__dpmi_int( 0x33, &_glfwMouseDrv.Regs );
|
||||
|
||||
// Clear mickeys
|
||||
__asm __volatile ("\n\
|
||||
movw $0xb, %%ax; \n\
|
||||
int $0x33 \n\
|
||||
":::"%eax", "%ecx", "%edx");
|
||||
|
||||
_glfwMouseDrv.OldX = 0;
|
||||
_glfwMouseDrv.OldY = 0;
|
||||
_glfwMouseDrv.OldB = 0;
|
||||
|
||||
// Emulate third mouse button?
|
||||
_glfwMouseDrv.Emulate3 = buttons < 3;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateMouse() - Terminate mouse driver
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateMouse( void )
|
||||
{
|
||||
if( !_glfwMouseInstalled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__asm("\n\
|
||||
movl %%edx, %%ecx \n\
|
||||
shrl $16, %%ecx \n\
|
||||
movw $0x0304, %%ax \n\
|
||||
int $0x31 \n\
|
||||
movw $0x000c, %%ax \n\
|
||||
xorl %%ecx, %%ecx \n\
|
||||
int $0x33 \n\
|
||||
"::"d"(_glfwMouseDrv.Callback):"%eax", "%ecx");
|
||||
_glfwMouseDrv.Callback = 0;
|
||||
|
||||
free( (void *)(_glfwMouseWrap_end[0] - _GLFW_MOUSE_STACK_SIZE) );
|
||||
|
||||
_glfwMouseInstalled = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwMouseWrap()
|
||||
//========================================================================
|
||||
|
||||
// Hack alert: `_glfwMouseWrap_end' actually holds the address of stack in
|
||||
// a safe data selector.
|
||||
|
||||
__asm("\n\
|
||||
.text \n\
|
||||
.p2align 5,,31 \n\
|
||||
.global __glfwMouseWrap \n\
|
||||
__glfwMouseWrap: \n\
|
||||
cld \n\
|
||||
lodsl \n\
|
||||
movl %eax, %es:42(%edi) \n\
|
||||
addw $4, %es:46(%edi) \n\
|
||||
pushl %es \n\
|
||||
movl %ss, %ebx \n\
|
||||
movl %esp, %esi \n\
|
||||
lss %cs:__glfwMouseWrap_end, %esp\n\
|
||||
pushl %ss \n\
|
||||
pushl %ss \n\
|
||||
popl %es \n\
|
||||
popl %ds \n\
|
||||
movl ___djgpp_dos_sel, %fs \n\
|
||||
pushl %fs \n\
|
||||
popl %gs \n\
|
||||
pushl %edi \n\
|
||||
call __glfwMouseInt \n\
|
||||
popl %edi \n\
|
||||
movl %ebx, %ss \n\
|
||||
movl %esi, %esp \n\
|
||||
popl %es \n\
|
||||
iret \n\
|
||||
.global __glfwMouseWrap_end \n\
|
||||
__glfwMouseWrap_end:.long 0, 0");
|
267
libs/glfw/lib/dos/dos_thread.c
Normal file
267
libs/glfw/lib/dos/dos_thread.c
Normal file
@ -0,0 +1,267 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_thread.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitThreads() - Initialize GLFW thread package
|
||||
//========================================================================
|
||||
|
||||
int _glfwInitThreads( void )
|
||||
{
|
||||
// TODO
|
||||
_glfwThrd.First.Previous = NULL;
|
||||
_glfwThrd.First.Next = NULL;
|
||||
_glfwThrd.First.ID = 0;
|
||||
_glfwThrd.NextID = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateThreads() - Terminate GLFW thread package
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateThreads( void )
|
||||
{
|
||||
_GLFWthread *t, *t_next;
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Kill all threads (NOTE: THE USER SHOULD WAIT FOR ALL THREADS TO
|
||||
// DIE, _BEFORE_ CALLING glfwTerminate()!!!)
|
||||
t = _glfwThrd.First.Next;
|
||||
while( t != NULL )
|
||||
{
|
||||
// Get pointer to next thread
|
||||
t_next = t->Next;
|
||||
|
||||
// Simply murder the process, no mercy!
|
||||
// TODO
|
||||
|
||||
// Free memory allocated for this thread
|
||||
free( (void *) t );
|
||||
|
||||
// Select next thread in list
|
||||
t = t_next;
|
||||
}
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateThread() - Create a new thread
|
||||
//========================================================================
|
||||
|
||||
GLFWthread _glfwPlatformCreateThread( GLFWthreadfun fun, void *arg )
|
||||
{
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyThread() - Kill a thread. NOTE: THIS IS A VERY
|
||||
// DANGEROUS OPERATION, AND SHOULD NOT BE USED EXCEPT IN EXTREME
|
||||
// SITUATIONS!
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyThread( GLFWthread ID )
|
||||
{
|
||||
_GLFWthread *t, *t_wait;
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Get thread information pointer
|
||||
t = _glfwGetThreadPointer( ID );
|
||||
if( t == NULL )
|
||||
{
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return;
|
||||
}
|
||||
|
||||
// Simply murder the process, no mercy!
|
||||
// TODO
|
||||
|
||||
// Remove thread from thread list
|
||||
_glfwRemoveThread( t );
|
||||
|
||||
// Signal any waiting threads that the thread has died
|
||||
// TODO
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformWaitThread() - Wait for a thread to die
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformWaitThread( GLFWthread ID, int waitmode )
|
||||
{
|
||||
// TODO
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetThreadID() - Return the thread ID for the current
|
||||
// thread
|
||||
//========================================================================
|
||||
|
||||
GLFWthread _glfwPlatformGetThreadID( void )
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateMutex() - Create a mutual exclusion object
|
||||
//========================================================================
|
||||
|
||||
GLFWmutex _glfwPlatformCreateMutex( void )
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyMutex() - Destroy a mutual exclusion object
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyMutex( GLFWmutex mutex )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformLockMutex() - Request access to a mutex
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformLockMutex( GLFWmutex mutex )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformUnlockMutex() - Release a mutex
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformUnlockMutex( GLFWmutex mutex )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateCond() - Create a new condition variable object
|
||||
//========================================================================
|
||||
|
||||
GLFWcond _glfwPlatformCreateCond( void )
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyCond() - Destroy a condition variable object
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyCond( GLFWcond cond )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformWaitCond() - Wait for a condition to be raised
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformWaitCond( GLFWcond cond, GLFWmutex mutex,
|
||||
double timeout )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSignalCond() - Signal a condition to one waiting thread
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSignalCond( GLFWcond cond )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformBroadcastCond() - Broadcast a condition to all waiting
|
||||
// threads
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformBroadcastCond( GLFWcond cond )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetNumberOfProcessors() - Return the number of processors
|
||||
// in the system.
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetNumberOfProcessors( void )
|
||||
{
|
||||
// Return number of processors online (DOS does not support multiple
|
||||
// CPUs...)
|
||||
return 1;
|
||||
}
|
309
libs/glfw/lib/dos/dos_time.c
Normal file
309
libs/glfw/lib/dos/dos_time.c
Normal file
@ -0,0 +1,309 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_time.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
// We use the __i386 define later in the code. Check if there are any
|
||||
// other defines that hint that we are compiling for 32-bit x86.
|
||||
#ifndef __i386
|
||||
#if defined(__i386__) || defined(i386) || defined(X86) || defined(_M_IX86)
|
||||
#define __i386
|
||||
#endif
|
||||
#endif // __i386
|
||||
|
||||
// Should we use inline x86 assembler?
|
||||
#if defined(__i386) && defined(__GNUC__)
|
||||
#define _USE_X86_ASM
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
// Functions for accessing upper and lower parts of 64-bit integers
|
||||
// (Note: These are endian dependent, but ONLY used on x86 platforms!)
|
||||
#define _HIGH(x) ((unsigned int*)&x)[1]
|
||||
#define _LOW(x) *((unsigned int*)&x)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwCPUID() - Execute x86 CPUID instruction
|
||||
//========================================================================
|
||||
|
||||
#ifdef _USE_X86_ASM
|
||||
|
||||
static int _glfwCPUID( unsigned int ID, unsigned int *a, unsigned int *b,
|
||||
unsigned int *c, unsigned int *d )
|
||||
{
|
||||
int has_cpuid;
|
||||
unsigned int local_a, local_b, local_c, local_d;
|
||||
|
||||
// Inline assembly - GCC version
|
||||
#if defined(__i386) && defined(__GNUC__)
|
||||
|
||||
// Detect CPUID support
|
||||
asm(
|
||||
"pushf\n\t"
|
||||
"pop %%eax\n\t"
|
||||
"movl %%eax,%%ebx\n\t"
|
||||
"xorl $0x00200000,%%eax\n\t"
|
||||
"push %%eax\n\t"
|
||||
"popf\n\t"
|
||||
"pushf\n\t"
|
||||
"pop %%eax\n\t"
|
||||
"xorl %%eax,%%ebx\n\t"
|
||||
"movl %%eax,%0\n\t"
|
||||
: "=m" (has_cpuid)
|
||||
:
|
||||
: "%eax", "%ebx"
|
||||
);
|
||||
if( !has_cpuid )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Execute CPUID
|
||||
asm(
|
||||
"movl %4,%%eax\n\t"
|
||||
"cpuid\n\t"
|
||||
"movl %%eax,%0\n\t"
|
||||
"movl %%ebx,%1\n\t"
|
||||
"movl %%ecx,%2\n\t"
|
||||
"movl %%edx,%3\n\t"
|
||||
: "=m" (local_a), "=m" (local_b), "=m" (local_c), "=m" (local_d)
|
||||
: "m" (ID)
|
||||
: "%eax", "%ebx", "%ecx", "%edx"
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
// Common code for all compilers
|
||||
*a = local_a;
|
||||
*b = local_b;
|
||||
*c = local_c;
|
||||
*d = local_d;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
#endif // _USE_X86_ASM
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwHasRDTSC() - Check for RDTSC availability AND usefulness
|
||||
//========================================================================
|
||||
|
||||
static int _glfwHasRDTSC( void )
|
||||
{
|
||||
#ifdef _USE_X86_ASM
|
||||
|
||||
unsigned int cpu_name1, cpu_name2, cpu_name3;
|
||||
unsigned int cpu_signature, cpu_brandID;
|
||||
unsigned int max_base, feature_flags;
|
||||
unsigned int dummy;
|
||||
|
||||
// Get processor vendor string (will return 0 if CPUID is not
|
||||
// supported)
|
||||
if( !_glfwCPUID( 0, &max_base, &cpu_name1, &cpu_name3, &cpu_name2 ) )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Does the processor support base CPUID function 1?
|
||||
if( max_base < 1 )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Get CPU capabilities, CPU Brand ID & CPU Signature
|
||||
_glfwCPUID( 1, &cpu_signature, &cpu_brandID, &dummy, &feature_flags );
|
||||
|
||||
// Is RDTSC supported?
|
||||
if( !(feature_flags & 0x00000010) )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
|
||||
#else
|
||||
|
||||
// Not a supported compiler
|
||||
return GL_FALSE;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// _RDTSC() - Get CPU cycle count using the RDTSC instruction
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if defined(__i386) && defined(__GNUC__)
|
||||
|
||||
// Read 64-bit processor Time Stamp Counter - GCC version
|
||||
#define _RDTSC( hi, lo ) \
|
||||
asm( \
|
||||
"rdtsc\n\t" \
|
||||
"movl %%edx,%0\n\t" \
|
||||
"movl %%eax,%1" \
|
||||
: "=m" (hi), "=m" (lo) \
|
||||
: \
|
||||
: "%edx", "%eax" \
|
||||
);
|
||||
|
||||
#else
|
||||
|
||||
#define _RDTSC( hi, lo ) {hi=lo=0;}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitTimer() - Initialize timer
|
||||
//========================================================================
|
||||
|
||||
int _glfwInitTimer( void )
|
||||
{
|
||||
clock_t t, t1, t2;
|
||||
long long c1, c2;
|
||||
|
||||
// Do we have RDTSC?
|
||||
_glfwTimer.HasRDTSC = _glfwHasRDTSC();
|
||||
if( _glfwTimer.HasRDTSC )
|
||||
{
|
||||
// Measure the CPU clock with the raw DOS clock (18.2 Hz)
|
||||
t = clock();
|
||||
while( (t1=clock()) == t );
|
||||
_RDTSC( _HIGH(c1), _LOW(c1) );
|
||||
t = t1+CLOCKS_PER_SEC/3;
|
||||
while( (t2=clock()) < t );
|
||||
_RDTSC( _HIGH(c2), _LOW(c2) );
|
||||
|
||||
// Calculate CPU clock period
|
||||
_glfwTimer.Period = (double)(t2-t1) /
|
||||
(CLOCKS_PER_SEC * (double)(c2-c1));
|
||||
_RDTSC( _HIGH(_glfwTimer.t0), _LOW(_glfwTimer.t0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the raw DOS clock (18.2 Hz)
|
||||
_glfwTimer.Period = 1.0 / CLOCKS_PER_SEC;
|
||||
_glfwTimer.t0 = clock();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTerminateTimer() - Terminate timer
|
||||
//========================================================================
|
||||
|
||||
void _glfwTerminateTimer( void )
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetTime() - Return timer value in seconds
|
||||
//========================================================================
|
||||
|
||||
double _glfwPlatformGetTime( void )
|
||||
{
|
||||
long long t_now;
|
||||
|
||||
// Get current clock count
|
||||
if( _glfwTimer.HasRDTSC )
|
||||
{
|
||||
_RDTSC( _HIGH(t_now), _LOW(t_now) );
|
||||
}
|
||||
else
|
||||
{
|
||||
t_now = (long long) clock();
|
||||
}
|
||||
|
||||
// Convert to seconds
|
||||
return (t_now-_glfwTimer.t0) * _glfwTimer.Period;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSetTime() - Set timer value in seconds
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetTime( double t )
|
||||
{
|
||||
long long t_now;
|
||||
|
||||
// Get current clock count
|
||||
if( _glfwTimer.HasRDTSC )
|
||||
{
|
||||
_RDTSC( _HIGH(t_now), _LOW(t_now) );
|
||||
}
|
||||
else
|
||||
{
|
||||
t_now = (long long) clock();
|
||||
}
|
||||
|
||||
// Set timer
|
||||
_glfwTimer.t0 = t_now - (long long)(t/_glfwTimer.Period);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSleep() - Put a thread to sleep for a specified amount of
|
||||
// time
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSleep( double time )
|
||||
{
|
||||
// TODO: Proper threaded version
|
||||
if( time > 0 )
|
||||
{
|
||||
if( time < 0.001 )
|
||||
{
|
||||
delay( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
delay( (unsigned int)(time*1000.0+0.5) );
|
||||
}
|
||||
}
|
||||
}
|
563
libs/glfw/lib/dos/dos_window.c
Normal file
563
libs/glfw/lib/dos/dos_window.c
Normal file
@ -0,0 +1,563 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: dos_window.c
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwRedirectOutput() - Standard output redirection
|
||||
//========================================================================
|
||||
|
||||
static void _glfwRedirectOutput( void )
|
||||
{
|
||||
// Generate temporary names
|
||||
tmpnam( _glfwWin.OutName );
|
||||
tmpnam( _glfwWin.ErrName );
|
||||
|
||||
// Open temporary output files
|
||||
_glfwWin.hOut = open( _glfwWin.OutName, O_WRONLY | O_CREAT | O_TEXT |
|
||||
O_TRUNC, S_IREAD | S_IWRITE );
|
||||
_glfwWin.hErr = open( _glfwWin.ErrName, O_WRONLY | O_CREAT | O_TEXT |
|
||||
O_TRUNC, S_IREAD | S_IWRITE );
|
||||
|
||||
// Redirect stdout
|
||||
if( _glfwWin.hOut > 0 )
|
||||
{
|
||||
_glfwWin.hOutOld = dup( STDOUT_FILENO );
|
||||
fflush( stdout );
|
||||
dup2( _glfwWin.hOut, STDOUT_FILENO );
|
||||
}
|
||||
|
||||
// Redirect stderr
|
||||
if( _glfwWin.hErr > 0 )
|
||||
{
|
||||
_glfwWin.hErrOld = dup( STDERR_FILENO );
|
||||
fflush( stderr );
|
||||
dup2( _glfwWin.hErr, STDERR_FILENO );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwRestoreOutput() - Standard output redirection
|
||||
//========================================================================
|
||||
|
||||
static void _glfwRestoreOutput( void )
|
||||
{
|
||||
FILE *f;
|
||||
char *str = alloca( 512 );
|
||||
|
||||
// Dump from temporary file to stdout
|
||||
if( _glfwWin.hOut > 0)
|
||||
{
|
||||
// Restore old stdout
|
||||
dup2( _glfwWin.hOutOld, STDOUT_FILENO );
|
||||
close( _glfwWin.hOut );
|
||||
close( _glfwWin.hOutOld );
|
||||
_glfwWin.hOut = 0;
|
||||
|
||||
// Dump file to stdout
|
||||
f = fopen( _glfwWin.OutName, "rt" );
|
||||
while( fgets( str, 512, f ) )
|
||||
{
|
||||
fputs( str, stdout );
|
||||
}
|
||||
fclose( f );
|
||||
|
||||
// Remove temporary file
|
||||
remove( _glfwWin.OutName );
|
||||
}
|
||||
|
||||
// Dump from temporary file to stderr
|
||||
if( _glfwWin.hOut > 0)
|
||||
{
|
||||
// Restore old stderr
|
||||
dup2( _glfwWin.hErrOld, STDERR_FILENO );
|
||||
close( _glfwWin.hErr );
|
||||
close( _glfwWin.hErrOld );
|
||||
_glfwWin.hErr = 0;
|
||||
|
||||
// Dump file to stderr
|
||||
f = fopen( _glfwWin.ErrName, "rt" );
|
||||
while( fgets( str, 512, f ) )
|
||||
{
|
||||
fputs( str, stderr );
|
||||
}
|
||||
fclose( f );
|
||||
|
||||
// Remove temporary file
|
||||
remove( _glfwWin.ErrName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTranslateChar() - Translates a DOS key code to Unicode
|
||||
//========================================================================
|
||||
|
||||
static int _glfwTranslateChar( int keycode )
|
||||
{
|
||||
// Unicode?
|
||||
if( (keycode >= 32 && keycode <= 126) || keycode >= 160 )
|
||||
{
|
||||
return keycode;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwTranslateKey() - Translates a DOS key code to GLFW coding
|
||||
//========================================================================
|
||||
|
||||
static int _glfwTranslateKey( int keycode )
|
||||
{
|
||||
// ISO 8859-1?
|
||||
if( ((keycode>=32) && (keycode<=126)) ||
|
||||
((keycode>=160) && (keycode<=254)) )
|
||||
{
|
||||
return keycode;
|
||||
}
|
||||
|
||||
// Special keys?
|
||||
if( keycode < 0 )
|
||||
{
|
||||
return -keycode;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformOpenWindow() - Here is where the window is created, and
|
||||
// the OpenGL rendering context is created
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformOpenWindow( int width, int height, int redbits,
|
||||
int greenbits, int bluebits, int alphabits, int depthbits,
|
||||
int stencilbits, int mode, int accumredbits, int accumgreenbits,
|
||||
int accumbluebits, int accumalphabits, int auxbuffers, int stereo,
|
||||
int refreshrate )
|
||||
{
|
||||
GLint params[2];
|
||||
|
||||
// Clear window resources
|
||||
_glfwWin.Visual = NULL;
|
||||
_glfwWin.Context = NULL;
|
||||
_glfwWin.Buffer = NULL;
|
||||
_glfwWin.hOut = 0;
|
||||
_glfwWin.hErr = 0;
|
||||
|
||||
// For now, we only support 640x480, 800x600 and 1024x768
|
||||
if( (width*height) < (700*500) )
|
||||
{
|
||||
width = 640;
|
||||
height = 480;
|
||||
}
|
||||
else if( (width*height) < (900*700) )
|
||||
{
|
||||
width = 800;
|
||||
height = 600;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 1024;
|
||||
height = 768;
|
||||
}
|
||||
|
||||
// For now, we only support 5,6,5 and 8,8,8 color formats
|
||||
if( (redbits+greenbits+bluebits) < 20 )
|
||||
{
|
||||
redbits = 5;
|
||||
greenbits = 6;
|
||||
bluebits = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
redbits = 8;
|
||||
greenbits = 8;
|
||||
bluebits = 8;
|
||||
}
|
||||
|
||||
// For now, we always set refresh rate = 0 (default)
|
||||
refreshrate = 0;
|
||||
|
||||
// stdout/stderr redirection
|
||||
_glfwRedirectOutput();
|
||||
|
||||
// Create visual
|
||||
_glfwWin.Visual = DMesaCreateVisual(
|
||||
width, height,
|
||||
redbits+greenbits+bluebits,
|
||||
refreshrate,
|
||||
GL_TRUE, // Double buffer
|
||||
GL_TRUE, // RGB mode
|
||||
alphabits?GL_TRUE:GL_FALSE, // Alpha buffer?
|
||||
depthbits,
|
||||
stencilbits,
|
||||
(accumredbits+accumgreenbits+
|
||||
accumbluebits+accumalphabits)>>2
|
||||
);
|
||||
if( _glfwWin.Visual == NULL )
|
||||
{
|
||||
printf("Unable to create visual\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Create context
|
||||
_glfwWin.Context = DMesaCreateContext( _glfwWin.Visual, NULL );
|
||||
if( _glfwWin.Context == NULL )
|
||||
{
|
||||
printf("Unable to create context\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Create buffer
|
||||
_glfwWin.Buffer = DMesaCreateBuffer( _glfwWin.Visual, 0, 0,
|
||||
width, height );
|
||||
if( _glfwWin.Buffer == NULL )
|
||||
{
|
||||
printf("Unable to create buffer\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Make current context
|
||||
if( !DMesaMakeCurrent( _glfwWin.Context, _glfwWin.Buffer ) )
|
||||
{
|
||||
printf("Unable to make current context\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Start DOS event handler
|
||||
if( !_glfwInitEvents() )
|
||||
{
|
||||
printf("Unable to start event handler\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Start keyboard handler
|
||||
if( !_glfwInitKeyboard() )
|
||||
{
|
||||
printf("Unable to start keyboard driver\n");
|
||||
_glfwPlatformCloseWindow();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Start mouse handler
|
||||
if( !_glfwInitMouse() )
|
||||
{
|
||||
printf("***Warning: Unable to start mouse driver\n");
|
||||
}
|
||||
|
||||
// Remember actual screen/window size
|
||||
_glfwWin.Width = width;
|
||||
_glfwWin.Height = height;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCloseWindow() - Properly kill the window/video display
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformCloseWindow( void )
|
||||
{
|
||||
// Terminate mouse handler
|
||||
_glfwTerminateMouse();
|
||||
|
||||
// Terminate keyboard handler
|
||||
_glfwTerminateKeyboard();
|
||||
|
||||
// Terminate event handler
|
||||
_glfwTerminateEvents();
|
||||
|
||||
// Destroy buffer
|
||||
if( _glfwWin.Buffer != NULL )
|
||||
{
|
||||
DMesaDestroyBuffer( _glfwWin.Buffer );
|
||||
_glfwWin.Buffer = NULL;
|
||||
}
|
||||
|
||||
// Destroy context
|
||||
if( _glfwWin.Context != NULL )
|
||||
{
|
||||
DMesaDestroyContext( _glfwWin.Context );
|
||||
_glfwWin.Context = NULL;
|
||||
}
|
||||
|
||||
// Destroy visual
|
||||
if( _glfwWin.Visual != NULL )
|
||||
{
|
||||
DMesaDestroyVisual( _glfwWin.Visual );
|
||||
_glfwWin.Visual = NULL;
|
||||
}
|
||||
|
||||
// stdout/stderr redirection
|
||||
_glfwRestoreOutput();
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSetWindowTitle() - Set the window title.
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowTitle( const char *title )
|
||||
{
|
||||
// Nothing to do here...
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSetWindowSize() - Set the window size.
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowSize( int width, int height )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSetWindowPos() - Set the window position.
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowPos( int x, int y )
|
||||
{
|
||||
// Nothing to do here...
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformIconfyWindow() - Window iconification
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformIconifyWindow( void )
|
||||
{
|
||||
// Nothing to do here...
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformRestoreWindow() - Window un-iconification
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformRestoreWindow( void )
|
||||
{
|
||||
// Nothing to do here...
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSwapBuffers() - Swap buffers (double-buffering) and poll
|
||||
// any new events.
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSwapBuffers( void )
|
||||
{
|
||||
DMesaSwapBuffers( _glfwWin.Buffer );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSwapInterval() - Set double buffering swap interval
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSwapInterval( int interval )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformRefreshWindowParams()
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformRefreshWindowParams( void )
|
||||
{
|
||||
GLint x;
|
||||
GLboolean b;
|
||||
|
||||
// Fill out information
|
||||
_glfwWin.Accelerated = GL_TRUE;
|
||||
glGetIntegerv( GL_RED_BITS, &x );
|
||||
_glfwWin.RedBits = x;
|
||||
glGetIntegerv( GL_GREEN_BITS, &x );
|
||||
_glfwWin.GreenBits = x;
|
||||
glGetIntegerv( GL_BLUE_BITS, &x );
|
||||
_glfwWin.BlueBits = x;
|
||||
glGetIntegerv( GL_ALPHA_BITS, &x );
|
||||
_glfwWin.AlphaBits = x;
|
||||
glGetIntegerv( GL_DEPTH_BITS, &x );
|
||||
_glfwWin.DepthBits = x;
|
||||
glGetIntegerv( GL_STENCIL_BITS, &x );
|
||||
_glfwWin.StencilBits = x;
|
||||
glGetIntegerv( GL_ACCUM_RED_BITS, &x );
|
||||
_glfwWin.AccumRedBits = x;
|
||||
glGetIntegerv( GL_ACCUM_GREEN_BITS, &x );
|
||||
_glfwWin.AccumGreenBits = x;
|
||||
glGetIntegerv( GL_ACCUM_BLUE_BITS, &x );
|
||||
_glfwWin.AccumBlueBits = x;
|
||||
glGetIntegerv( GL_ACCUM_ALPHA_BITS, &x );
|
||||
_glfwWin.AccumAlphaBits = x;
|
||||
glGetIntegerv( GL_AUX_BUFFERS, &x );
|
||||
_glfwWin.AuxBuffers = x;
|
||||
glGetBooleanv( GL_AUX_BUFFERS, &b );
|
||||
_glfwWin.Stereo = b ? GL_TRUE : GL_FALSE;
|
||||
_glfwWin.RefreshRate = 0;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformPollEvents() - Poll for new window and input events
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformPollEvents( void )
|
||||
{
|
||||
_GLFWdosevent event;
|
||||
struct key_event *key;
|
||||
struct mousemove_event *mousemove;
|
||||
struct mousewheel_event *mousewheel;
|
||||
struct mousebutton_event *mousebutton;
|
||||
|
||||
// Empty the event queue
|
||||
while( _glfwGetNextEvent( &event ) )
|
||||
{
|
||||
switch( event.Type )
|
||||
{
|
||||
// Keyboard event?
|
||||
case _GLFW_DOS_KEY_EVENT:
|
||||
key = &event.Key;
|
||||
_glfwInputKey( _glfwTranslateKey( key->KeyNoMod ),
|
||||
key->Action );
|
||||
_glfwInputChar( _glfwTranslateChar( key->Key ),
|
||||
key->Action );
|
||||
break;
|
||||
|
||||
// Mouse move event?
|
||||
case _GLFW_DOS_MOUSE_MOVE_EVENT:
|
||||
mousemove = &event.MouseMove;
|
||||
_glfwInput.MousePosX += mousemove->DeltaX;
|
||||
_glfwInput.MousePosY += mousemove->DeltaY;
|
||||
|
||||
// Call user callback function
|
||||
if( _glfwWin.MousePosCallback )
|
||||
{
|
||||
_glfwWin.MousePosCallback( _glfwInput.MousePosX,
|
||||
_glfwInput.MousePosY );
|
||||
}
|
||||
break;
|
||||
|
||||
// Mouse wheel event?
|
||||
case _GLFW_DOS_MOUSE_WHEEL_EVENT:
|
||||
mousewheel = &event.MouseWheel;
|
||||
_glfwInput.WheelPos += mousewheel->WheelDelta;
|
||||
|
||||
// Call user callback function
|
||||
if( _glfwWin.MouseWheelCallback )
|
||||
{
|
||||
_glfwWin.MouseWheelCallback( _glfwInput.WheelPos );
|
||||
}
|
||||
break;
|
||||
|
||||
// Mouse button event?
|
||||
case _GLFW_DOS_MOUSE_BUTTON_EVENT:
|
||||
mousebutton = &event.MouseButton;
|
||||
_glfwInputMouseClick( mousebutton->Button,
|
||||
mousebutton->Action );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformWaitEvents() - Wait for new window and input events
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformWaitEvents( void )
|
||||
{
|
||||
// Wait for new events
|
||||
_glfwWaitNextEvent;
|
||||
|
||||
// Poll new events
|
||||
_glfwPlatformPollEvents();
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformHideMouseCursor() - Hide mouse cursor (lock it)
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformHideMouseCursor( void )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformShowMouseCursor() - Show mouse cursor (unlock it)
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformShowMouseCursor( void )
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSetMouseCursorPos() - Set physical mouse cursor position
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetMouseCursorPos( int x, int y )
|
||||
{
|
||||
// TODO
|
||||
}
|
341
libs/glfw/lib/dos/platform.h
Normal file
341
libs/glfw/lib/dos/platform.h
Normal file
@ -0,0 +1,341 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: platform.h
|
||||
// Platform: DOS
|
||||
// API version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _platform_h_
|
||||
#define _platform_h_
|
||||
|
||||
|
||||
// This is the DOS version of GLFW
|
||||
#define _GLFW_DOS
|
||||
|
||||
|
||||
// Include files
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <dos.h>
|
||||
#include <dpmi.h>
|
||||
#include <fcntl.h>
|
||||
#include <pc.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/exceptn.h>
|
||||
#include <sys/farptr.h>
|
||||
#include <sys/segments.h>
|
||||
|
||||
// GLFW+GL+GLU defines
|
||||
#include "../../include/GL/glfw.h"
|
||||
|
||||
// DOS Mesa (include this AFTER gl.h!)
|
||||
#include <GL/dmesa.h>
|
||||
|
||||
|
||||
// Stack size for each thread (in bytes)
|
||||
#define _GLFW_TASK_STACK_SIZE 50000
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global variables (GLFW internals)
|
||||
//========================================================================
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Window structure
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct _GLFWwin_struct _GLFWwin;
|
||||
|
||||
struct _GLFWwin_struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// User callback functions
|
||||
GLFWwindowsizefun WindowSizeCallback;
|
||||
GLFWwindowclosefun WindowCloseCallback;
|
||||
GLFWwindowrefreshfun WindowRefreshCallback;
|
||||
GLFWmousebuttonfun MouseButtonCallback;
|
||||
GLFWmouseposfun MousePosCallback;
|
||||
GLFWmousewheelfun MouseWheelCallback;
|
||||
GLFWkeyfun KeyCallback;
|
||||
GLFWcharfun CharCallback;
|
||||
|
||||
// User selected window settings
|
||||
int Fullscreen; // Fullscreen flag
|
||||
int MouseLock; // Mouse-lock flag
|
||||
int AutoPollEvents; // Auto polling flag
|
||||
int SysKeysDisabled; // System keys disabled flag
|
||||
int WindowNoResize; // Resize- and maximize gadgets disabled flag
|
||||
|
||||
// Window status & parameters
|
||||
int Opened; // Flag telling if window is opened or not
|
||||
int Active; // Application active flag
|
||||
int Iconified; // Window iconified flag
|
||||
int Width, Height; // Window width and heigth
|
||||
int Accelerated; // GL_TRUE if window is HW accelerated
|
||||
int RedBits;
|
||||
int GreenBits;
|
||||
int BlueBits;
|
||||
int AlphaBits;
|
||||
int DepthBits;
|
||||
int StencilBits;
|
||||
int AccumRedBits;
|
||||
int AccumGreenBits;
|
||||
int AccumBlueBits;
|
||||
int AccumAlphaBits;
|
||||
int AuxBuffers;
|
||||
int Stereo;
|
||||
int RefreshRate; // Vertical monitor refresh rate
|
||||
|
||||
// Extensions & OpenGL version
|
||||
int Has_GL_SGIS_generate_mipmap;
|
||||
int Has_GL_ARB_texture_non_power_of_two;
|
||||
int GLVerMajor,GLVerMinor;
|
||||
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
// Platform specific window resources
|
||||
DMesaVisual Visual;
|
||||
DMesaContext Context;
|
||||
DMesaBuffer Buffer;
|
||||
|
||||
// Standard output redirection
|
||||
char OutName[L_tmpnam];
|
||||
char ErrName[L_tmpnam];
|
||||
int hOut,hOutOld,hErr,hErrOld;
|
||||
|
||||
// Platform specific extensions
|
||||
|
||||
// Various platform specific internal variables
|
||||
|
||||
};
|
||||
|
||||
GLFWGLOBAL _GLFWwin _glfwWin;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// User input status (most of this should go in _GLFWwin)
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// Mouse status
|
||||
int MousePosX, MousePosY;
|
||||
int WheelPos;
|
||||
char MouseButton[ GLFW_MOUSE_BUTTON_LAST+1 ];
|
||||
|
||||
// Keyboard status
|
||||
char Key[ GLFW_KEY_LAST+1 ];
|
||||
int LastChar;
|
||||
|
||||
// User selected settings
|
||||
int StickyKeys;
|
||||
int StickyMouseButtons;
|
||||
int KeyRepeat;
|
||||
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
// Platform specific internal variables
|
||||
|
||||
} _glfwInput;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Timer status
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
double Period;
|
||||
long long t0;
|
||||
int HasRDTSC;
|
||||
} _glfwTimer;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Thread record (one for each thread)
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct _GLFWthread_struct _GLFWthread;
|
||||
|
||||
struct _GLFWthread_struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// Pointer to previous and next threads in linked list
|
||||
_GLFWthread *Previous, *Next;
|
||||
|
||||
// GLFW user side thread information
|
||||
GLFWthread ID;
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
// System side thread information
|
||||
GLFWthreadfun Function;
|
||||
void *Arg;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// General thread information
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// Next thread ID to use (increments for every created thread)
|
||||
GLFWthread NextID;
|
||||
|
||||
// First thread in linked list (always the main thread)
|
||||
_GLFWthread First;
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
// Critical section lock
|
||||
|
||||
} _glfwThrd;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Joystick information & state
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
int dummy;
|
||||
} _glfwJoy;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Macros for encapsulating critical code sections (i.e. making parts
|
||||
// of GLFW thread safe)
|
||||
//========================================================================
|
||||
|
||||
// Thread list management
|
||||
#define ENTER_THREAD_CRITICAL_SECTION \
|
||||
;
|
||||
#define LEAVE_THREAD_CRITICAL_SECTION \
|
||||
;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// DOS events
|
||||
//========================================================================
|
||||
|
||||
// Valid event types
|
||||
#define _GLFW_DOS_KEY_EVENT 1
|
||||
#define _GLFW_DOS_MOUSE_MOVE_EVENT 2
|
||||
#define _GLFW_DOS_MOUSE_WHEEL_EVENT 3
|
||||
#define _GLFW_DOS_MOUSE_BUTTON_EVENT 4
|
||||
|
||||
// Keyboard event structure
|
||||
struct key_event {
|
||||
int Type;
|
||||
int Key;
|
||||
int KeyNoMod;
|
||||
int Action;
|
||||
};
|
||||
|
||||
// Mouse move event structure
|
||||
struct mousemove_event {
|
||||
int Type;
|
||||
int DeltaX, DeltaY;
|
||||
};
|
||||
|
||||
// Mouse wheel event structure
|
||||
struct mousewheel_event {
|
||||
int Type;
|
||||
int WheelDelta;
|
||||
};
|
||||
|
||||
// Mouse button event structure
|
||||
struct mousebutton_event {
|
||||
int Type;
|
||||
int Button;
|
||||
int Action;
|
||||
};
|
||||
|
||||
// DOS event structure
|
||||
typedef union {
|
||||
int Type;
|
||||
struct key_event Key;
|
||||
struct mousemove_event MouseMove;
|
||||
struct mousewheel_event MouseWheel;
|
||||
struct mousebutton_event MouseButton;
|
||||
} _GLFWdosevent;
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Prototypes for platform specific internal functions
|
||||
//========================================================================
|
||||
|
||||
// Time
|
||||
int _glfwInitTimer( void );
|
||||
void _glfwTerminateTimer( void );
|
||||
|
||||
// Fullscreen
|
||||
|
||||
// Events
|
||||
int _glfwInitEvents( void );
|
||||
void _glfwTerminateEvents( void );
|
||||
void _glfwWaitNextEvent( void );
|
||||
int _glfwGetNextEvent( _GLFWdosevent *event );
|
||||
void _glfwPostDOSEvent( _GLFWdosevent *event );
|
||||
|
||||
// Mouse
|
||||
int _glfwInitMouse( void );
|
||||
void _glfwTerminateMouse( void );
|
||||
|
||||
// Keyboard
|
||||
int _glfwInitKeyboard( void );
|
||||
void _glfwTerminateKeyboard( void );
|
||||
|
||||
// Joystick
|
||||
void _glfwInitJoysticks( void );
|
||||
void _glfwTerminateJoysticks( void );
|
||||
|
||||
// Threads
|
||||
int _glfwInitThreads( void );
|
||||
void _glfwTerminateThreads( void );
|
||||
|
||||
// Interrupt handling
|
||||
int _glfwInstallDOSIrq( int i, int (*handler) () );
|
||||
int _glfwRemoveDOSIrq( int i );
|
||||
|
||||
// Interrupt macros
|
||||
#define ENABLE() __asm __volatile("sti")
|
||||
#define DISABLE() __asm __volatile("cli")
|
||||
|
||||
// Memory macros (for locking memory)
|
||||
#define ENDOFUNC(x) static void x##_end() { }
|
||||
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
|
||||
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
|
||||
#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)
|
||||
|
||||
#endif // _platform_h_
|
Reference in New Issue
Block a user