Mostly working, but no sound yet
This commit is contained in:
parent
9a90e215b1
commit
930ffcfd18
39
doom.c
39
doom.c
@ -33,8 +33,6 @@
|
|||||||
#include "linuxdoom-1.10/info.c"
|
#include "linuxdoom-1.10/info.c"
|
||||||
#include "linuxdoom-1.10/i_main.c"
|
#include "linuxdoom-1.10/i_main.c"
|
||||||
#include "linuxdoom-1.10/i_sound.c"
|
#include "linuxdoom-1.10/i_sound.c"
|
||||||
#include "linuxdoom-1.10/i_system.c"
|
|
||||||
#include "linuxdoom-1.10/i_video.c"
|
|
||||||
#include "linuxdoom-1.10/m_argv.c"
|
#include "linuxdoom-1.10/m_argv.c"
|
||||||
#include "linuxdoom-1.10/m_bbox.c"
|
#include "linuxdoom-1.10/m_bbox.c"
|
||||||
#include "linuxdoom-1.10/m_cheat.c"
|
#include "linuxdoom-1.10/m_cheat.c"
|
||||||
@ -97,3 +95,40 @@
|
|||||||
#undef strupr
|
#undef strupr
|
||||||
|
|
||||||
#include "linuxdoom-1.10/i_net.c"
|
#include "linuxdoom-1.10/i_net.c"
|
||||||
|
|
||||||
|
#undef MAXCHAR
|
||||||
|
#undef MAXSHORT
|
||||||
|
#undef MAXINT
|
||||||
|
#undef MAXLONG
|
||||||
|
#undef MINCHAR
|
||||||
|
#undef MINSHORT
|
||||||
|
#undef MININT
|
||||||
|
#undef MINLONG
|
||||||
|
|
||||||
|
#define APP_WINDOWS
|
||||||
|
#define APP_LOG( ctx, level, message )
|
||||||
|
#define boolean HACK_TO_MAKE_BOOLEAN_NOT_BE_DEFINED
|
||||||
|
#define APP_IMPLEMENTATION
|
||||||
|
#include "libs_win32/app.h"
|
||||||
|
#undef APP_IMPLEMENTATION
|
||||||
|
|
||||||
|
#define FRAMETIMER_IMPLEMENTATION
|
||||||
|
#include "libs_win32/frametimer.h"
|
||||||
|
|
||||||
|
#define CRTEMU_IMPLEMENTATION
|
||||||
|
#include "libs_win32/crtemu.h"
|
||||||
|
|
||||||
|
#define THREAD_IMPLEMENTATION
|
||||||
|
#if defined( __TINYC__ )
|
||||||
|
typedef struct _RTL_CONDITION_VARIABLE { PVOID Ptr; } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
|
||||||
|
typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE;
|
||||||
|
static VOID (*InitializeConditionVariable)( PCONDITION_VARIABLE );
|
||||||
|
static VOID (*WakeConditionVariable)( PCONDITION_VARIABLE );
|
||||||
|
static BOOL (*SleepConditionVariableCS)( PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD );
|
||||||
|
#endif
|
||||||
|
#include "libs_win32/thread.h"
|
||||||
|
#undef THREAD_IMPLEMENTATION
|
||||||
|
#undef boolean
|
||||||
|
|
||||||
|
#include "linuxdoom-1.10/i_video.c"
|
||||||
|
#include "linuxdoom-1.10/i_system.c"
|
||||||
4816
libs_win32/app.h
Normal file
4816
libs_win32/app.h
Normal file
File diff suppressed because it is too large
Load Diff
1928
libs_win32/crtemu.h
Normal file
1928
libs_win32/crtemu.h
Normal file
File diff suppressed because it is too large
Load Diff
317
libs_win32/frametimer.h
Normal file
317
libs_win32/frametimer.h
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
/*
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licensing information can be found at the end of the file.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
frametimer.h - v0.1 - Framerate timer functionality.
|
||||||
|
|
||||||
|
Do this:
|
||||||
|
#define FRAMETIMER_IMPLEMENTATION
|
||||||
|
before you include this file in *one* C/C++ file to create the implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef frametimer_h
|
||||||
|
#define frametimer_h
|
||||||
|
|
||||||
|
typedef struct frametimer_t frametimer_t;
|
||||||
|
|
||||||
|
frametimer_t* frametimer_create( void* memxtx );
|
||||||
|
|
||||||
|
void frametimer_destroy( frametimer_t* frametimer );
|
||||||
|
|
||||||
|
void frametimer_lock_rate( frametimer_t* frametimer, int fps );
|
||||||
|
|
||||||
|
float frametimer_update( frametimer_t* frametimer );
|
||||||
|
|
||||||
|
float frametimer_delta_time( frametimer_t* frametimer );
|
||||||
|
|
||||||
|
int frametimer_frame_counter( frametimer_t* frametimer );
|
||||||
|
|
||||||
|
#endif /* frametimer_h */
|
||||||
|
|
||||||
|
/*
|
||||||
|
----------------------
|
||||||
|
IMPLEMENTATION
|
||||||
|
----------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef FRAMETIMER_IMPLEMENTATION
|
||||||
|
#undef FRAMETIMER_IMPLEMENTATION
|
||||||
|
|
||||||
|
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#if !defined( _WIN32_WINNT ) || _WIN32_WINNT < 0x0501
|
||||||
|
#undef _WIN32_WINNT
|
||||||
|
#define _WIN32_WINNT 0x0501 // requires Windows XP minimum
|
||||||
|
#endif
|
||||||
|
// 0x0400=Windows NT 4.0, 0x0500=Windows 2000, 0x0501=Windows XP, 0x0502=Windows Server 2003, 0x0600=Windows Vista,
|
||||||
|
// 0x0601=Windows 7, 0x0602=Windows 8, 0x0603=Windows 8.1, 0x0A00=Windows 10,
|
||||||
|
#define _WINSOCKAPI_
|
||||||
|
#pragma warning( push )
|
||||||
|
#pragma warning( disable: 4619 )
|
||||||
|
#pragma warning( disable: 4668 ) // 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
|
||||||
|
#pragma warning( disable: 4768 ) // __declspec attributes before linkage specification are ignored
|
||||||
|
#pragma warning( disable: 4255 ) // 'function' : no function prototype given: converting '()' to '(void)'
|
||||||
|
#include <windows.h>
|
||||||
|
#pragma warning( pop )
|
||||||
|
#ifndef __TINYC__
|
||||||
|
#pragma comment(lib, "winmm.lib")
|
||||||
|
#else
|
||||||
|
typedef struct timecaps_tag { UINT wPeriodMin; UINT wPeriodMax; } TIMECAPS, *PTIMECAPS, NEAR *NPTIMECAPS, FAR *LPTIMECAPS;
|
||||||
|
typedef UINT MMRESULT;
|
||||||
|
#define TIMERR_NOERROR (0)
|
||||||
|
static MMRESULT (*timeGetDevCaps)( LPTIMECAPS ptc, UINT cbtc );
|
||||||
|
static MMRESULT (*timeBeginPeriod)( UINT uPeriod );
|
||||||
|
static MMRESULT (*timeEndPeriod)( UINT uPeriod );
|
||||||
|
#endif
|
||||||
|
#elif defined( __APPLE__ )
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
#elif defined( __wasm__ )
|
||||||
|
#define WA_CORO_IMPLEMENT_NANOSLEEP
|
||||||
|
#include <wajic_coro.h>
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FRAMETIMER_MALLOC
|
||||||
|
#include <stdlib.h>
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define FRAMETIMER_MALLOC( ctx, size ) ( ::malloc( size ) )
|
||||||
|
#define FRAMETIMER_FREE( ctx, ptr ) ( ::free( ptr ) )
|
||||||
|
#else
|
||||||
|
#define FRAMETIMER_MALLOC( ctx, size ) ( malloc( size ) )
|
||||||
|
#define FRAMETIMER_FREE( ctx, ptr ) ( free( ptr ) )
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FRAMETIMER_U64
|
||||||
|
#define FRAMETIMER_U64 unsigned long long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct frametimer_t
|
||||||
|
{
|
||||||
|
FRAMETIMER_U64 clock_freq;
|
||||||
|
FRAMETIMER_U64 prev_clock;
|
||||||
|
void* memctx;
|
||||||
|
float delta_time;
|
||||||
|
int initialized;
|
||||||
|
int frame_counter;
|
||||||
|
int frame_rate_lock;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE waitable_timer;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
frametimer_t* frametimer_create( void* memctx )
|
||||||
|
{
|
||||||
|
frametimer_t* frametimer = (frametimer_t*) FRAMETIMER_MALLOC( memctx, sizeof( frametimer_t ) );
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef __TINYC__
|
||||||
|
HMODULE winmm = LoadLibrary( "winmm" );
|
||||||
|
timeGetDevCaps = GetProcAddress( winmm, "timeGetDevCaps");
|
||||||
|
timeBeginPeriod = GetProcAddress( winmm, "timeBeginPeriod");
|
||||||
|
timeEndPeriod = GetProcAddress( winmm, "timeEndPeriod");
|
||||||
|
#endif
|
||||||
|
TIMECAPS tc;
|
||||||
|
if( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == TIMERR_NOERROR )
|
||||||
|
timeBeginPeriod( tc.wPeriodMin );
|
||||||
|
frametimer->waitable_timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
frametimer->memctx = memctx;
|
||||||
|
frametimer->initialized = 0;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
LARGE_INTEGER f;
|
||||||
|
QueryPerformanceFrequency( &f );
|
||||||
|
frametimer->clock_freq = (FRAMETIMER_U64) f.QuadPart;
|
||||||
|
#else
|
||||||
|
frametimer->clock_freq = 1000000000ull;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
frametimer->prev_clock = 0;
|
||||||
|
frametimer->delta_time = 0.0f;
|
||||||
|
frametimer->frame_counter = 0;
|
||||||
|
frametimer->frame_rate_lock = 0;
|
||||||
|
return frametimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void frametimer_destroy( frametimer_t* frametimer )
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
CloseHandle( frametimer->waitable_timer );
|
||||||
|
TIMECAPS tc;
|
||||||
|
if( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == TIMERR_NOERROR )
|
||||||
|
timeEndPeriod( tc.wPeriodMin );
|
||||||
|
#endif
|
||||||
|
FRAMETIMER_FREE( frametimer->memctx, frametimer );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void frametimer_lock_rate( frametimer_t* frametimer, int fps )
|
||||||
|
{
|
||||||
|
frametimer->frame_rate_lock = ( fps > 0 && fps < 5 ) ? 5 : fps < 0 ? 0 : fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float frametimer_update( frametimer_t* frametimer )
|
||||||
|
{
|
||||||
|
if( !frametimer->initialized )
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
LARGE_INTEGER c;
|
||||||
|
QueryPerformanceCounter( &c );
|
||||||
|
frametimer->prev_clock = (FRAMETIMER_U64) c.QuadPart;
|
||||||
|
#elif defined( __APPLE__ )
|
||||||
|
frametimer->prev_clock = clock_gettime_nsec_np( CLOCK_UPTIME_RAW );
|
||||||
|
#else
|
||||||
|
struct timespec t;
|
||||||
|
clock_gettime( CLOCK_MONOTONIC_RAW, &t );
|
||||||
|
frametimer->prev_clock = (FRAMETIMER_U64)t.tv_sec;
|
||||||
|
frametimer->prev_clock *= 1000000000ull;
|
||||||
|
frametimer->prev_clock += (FRAMETIMER_U64)t.tv_nsec;
|
||||||
|
#endif
|
||||||
|
frametimer->initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
++frametimer->frame_counter;
|
||||||
|
|
||||||
|
|
||||||
|
FRAMETIMER_U64 curr_clock = 0ULL;
|
||||||
|
#ifdef _WIN32
|
||||||
|
LARGE_INTEGER c;
|
||||||
|
QueryPerformanceCounter( &c );
|
||||||
|
curr_clock = (FRAMETIMER_U64) c.QuadPart;
|
||||||
|
#elif defined( __APPLE__ )
|
||||||
|
curr_clock = (FRAMETIMER_U64) clock_gettime_nsec_np( CLOCK_UPTIME_RAW );
|
||||||
|
#else
|
||||||
|
struct timespec t;
|
||||||
|
clock_gettime( CLOCK_MONOTONIC_RAW, &t );
|
||||||
|
curr_clock = (FRAMETIMER_U64)t.tv_sec;
|
||||||
|
curr_clock *= 1000000000ull;
|
||||||
|
curr_clock += (FRAMETIMER_U64)t.tv_nsec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( frametimer->frame_rate_lock > 0 )
|
||||||
|
{
|
||||||
|
FRAMETIMER_U64 delta = 0ULL;
|
||||||
|
if( curr_clock > frametimer->prev_clock )
|
||||||
|
delta = curr_clock - frametimer->prev_clock - 1ULL;
|
||||||
|
if( delta < frametimer->clock_freq / frametimer->frame_rate_lock )
|
||||||
|
{
|
||||||
|
FRAMETIMER_U64 wait = ( frametimer->clock_freq / frametimer->frame_rate_lock ) - delta;
|
||||||
|
#ifdef _WIN32
|
||||||
|
if( wait > 0 )
|
||||||
|
{
|
||||||
|
LARGE_INTEGER due_time;
|
||||||
|
due_time.QuadPart = - (LONGLONG) ( ( 10000000ULL * wait ) / frametimer->clock_freq ) ;
|
||||||
|
|
||||||
|
SetWaitableTimer( frametimer->waitable_timer, &due_time, 0, 0, 0, FALSE );
|
||||||
|
WaitForSingleObject( frametimer->waitable_timer, 200 ); // wait long enough for timer to trigger ( 200ms == 5fps )
|
||||||
|
CancelWaitableTimer( frametimer->waitable_timer ); // in case we timed out
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct timespec t = { 0, 0 };
|
||||||
|
t.tv_nsec = wait;
|
||||||
|
while( t.tv_nsec > 0 )
|
||||||
|
{
|
||||||
|
struct timespec r = { 0, 0 };
|
||||||
|
if( nanosleep( &t, &r ) >= 0 ) break;
|
||||||
|
t = r;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
curr_clock += wait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FRAMETIMER_U64 delta_clock = 0ULL;
|
||||||
|
if( curr_clock > frametimer->prev_clock ) delta_clock = curr_clock - frametimer->prev_clock;
|
||||||
|
|
||||||
|
// Cap delta time if it is too high (running at less than 5 fps ) or things will jump
|
||||||
|
// like crazy on occasional long stalls.
|
||||||
|
if( delta_clock > frametimer->clock_freq / 5ULL ) delta_clock = frametimer->clock_freq / 5ULL; // Cap to 5 fps
|
||||||
|
|
||||||
|
float delta_time = (float) ( ( (double) delta_clock ) / ( (double) frametimer->clock_freq ) );
|
||||||
|
|
||||||
|
frametimer->delta_time = delta_time;
|
||||||
|
frametimer->prev_clock = curr_clock;
|
||||||
|
|
||||||
|
return delta_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float frametimer_delta_time( frametimer_t* frametimer )
|
||||||
|
{
|
||||||
|
return frametimer->delta_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int frametimer_frame_counter( frametimer_t* frametimer )
|
||||||
|
{
|
||||||
|
return frametimer->frame_counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FRAMETIMER_IMPLEMENTATION */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
This software is available under 2 licenses - you may choose the one you like.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ALTERNATIVE A - MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2015 Mattias Gustavsson
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
|
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
|
commercial or non-commercial, and by any means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
|
software dedicate any and all copyright interest in the software to the public
|
||||||
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
|
this software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
1478
libs_win32/thread.h
Normal file
1478
libs_win32/thread.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,18 +20,17 @@
|
|||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "d_ticcmd.h"
|
#include "d_ticcmd.h"
|
||||||
#include <time.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
|
|
||||||
void I_Init (void)
|
void I_Init (void)
|
||||||
{
|
{
|
||||||
I_InitSound();
|
I_InitSound();
|
||||||
I_InitGraphics();
|
// I_InitGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +51,12 @@ byte* I_ZoneBase (int *size)
|
|||||||
// returns current time in tics.
|
// returns current time in tics.
|
||||||
int I_GetTime (void)
|
int I_GetTime (void)
|
||||||
{
|
{
|
||||||
return clock()/(CLOCKS_PER_SEC/TICRATE);
|
LARGE_INTEGER large;
|
||||||
|
LARGE_INTEGER freq;
|
||||||
|
QueryPerformanceCounter( &large );
|
||||||
|
QueryPerformanceFrequency( &freq );
|
||||||
|
|
||||||
|
return large.QuadPart * TICRATE / freq.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,9 +79,9 @@ void I_StartFrame (void)
|
|||||||
// called before processing each tic in a frame.
|
// called before processing each tic in a frame.
|
||||||
// Quick syncronous operations are performed here.
|
// Quick syncronous operations are performed here.
|
||||||
// Can call D_PostEvent.
|
// Can call D_PostEvent.
|
||||||
void I_StartTic (void)
|
//void I_StartTic (void)
|
||||||
{
|
//{
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Asynchronous interrupt functions should maintain private queues
|
// Asynchronous interrupt functions should maintain private queues
|
||||||
// that are read by the synchronous functions
|
// that are read by the synchronous functions
|
||||||
@ -151,3 +155,191 @@ void I_Error (char *error, ...)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Emacs style mode select -*- C++ -*-
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// $Id:$
|
||||||
|
//
|
||||||
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
|
//
|
||||||
|
// This source is available for distribution and/or modification
|
||||||
|
// only under the terms of the DOOM Source Code License as
|
||||||
|
// published by id Software. All rights reserved.
|
||||||
|
//
|
||||||
|
// The source is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// $Log:$
|
||||||
|
//
|
||||||
|
// DESCRIPTION:
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static const char
|
||||||
|
rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "doomdef.h"
|
||||||
|
#include "m_misc.h"
|
||||||
|
#include "i_video.h"
|
||||||
|
#include "i_sound.h"
|
||||||
|
|
||||||
|
#include "d_net.h"
|
||||||
|
#include "g_game.h"
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "i_system.h"
|
||||||
|
#endif
|
||||||
|
#include "i_system.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int mb_used = 6;
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
I_Tactile
|
||||||
|
( int on,
|
||||||
|
int off,
|
||||||
|
int total )
|
||||||
|
{
|
||||||
|
// UNUSED.
|
||||||
|
on = off = total = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ticcmd_t emptycmd;
|
||||||
|
ticcmd_t* I_BaseTiccmd(void)
|
||||||
|
{
|
||||||
|
return &emptycmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int I_GetHeapSize (void)
|
||||||
|
{
|
||||||
|
return mb_used*1024*1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* I_ZoneBase (int* size)
|
||||||
|
{
|
||||||
|
*size = mb_used*1024*1024;
|
||||||
|
return (byte *) malloc (*size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_GetTime
|
||||||
|
// returns time in 1/70th second tics
|
||||||
|
//
|
||||||
|
int I_GetTime (void)
|
||||||
|
{
|
||||||
|
struct timeval tp;
|
||||||
|
struct timezone tzp;
|
||||||
|
int newtics;
|
||||||
|
static int basetime=0;
|
||||||
|
|
||||||
|
gettimeofday(&tp, &tzp);
|
||||||
|
if (!basetime)
|
||||||
|
basetime = tp.tv_sec;
|
||||||
|
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
|
||||||
|
return newtics;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_Init
|
||||||
|
//
|
||||||
|
void I_Init (void)
|
||||||
|
{
|
||||||
|
I_InitSound();
|
||||||
|
// I_InitGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_Quit
|
||||||
|
//
|
||||||
|
void I_Quit (void)
|
||||||
|
{
|
||||||
|
D_QuitNetGame ();
|
||||||
|
I_ShutdownSound();
|
||||||
|
I_ShutdownMusic();
|
||||||
|
M_SaveDefaults ();
|
||||||
|
I_ShutdownGraphics();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_WaitVBL(int count)
|
||||||
|
{
|
||||||
|
#ifdef SGI
|
||||||
|
sginap(1);
|
||||||
|
#else
|
||||||
|
#ifdef SUN
|
||||||
|
sleep(0);
|
||||||
|
#else
|
||||||
|
usleep (count * (1000000/70) );
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_BeginRead(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void I_EndRead(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* I_AllocLow(int length)
|
||||||
|
{
|
||||||
|
byte* mem;
|
||||||
|
|
||||||
|
mem = (byte *)malloc (length);
|
||||||
|
memset (mem,0,length);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// I_Error
|
||||||
|
//
|
||||||
|
extern boolean demorecording;
|
||||||
|
|
||||||
|
void I_Error (char *error, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
|
||||||
|
// Message first.
|
||||||
|
va_start (argptr,error);
|
||||||
|
fprintf (stderr, "Error: ");
|
||||||
|
vfprintf (stderr,error,argptr);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
va_end (argptr);
|
||||||
|
|
||||||
|
fflush( stderr );
|
||||||
|
|
||||||
|
// Shutdown. Here might be other errors.
|
||||||
|
if (demorecording)
|
||||||
|
G_CheckDemoStatus();
|
||||||
|
|
||||||
|
D_QuitNetGame ();
|
||||||
|
I_ShutdownGraphics();
|
||||||
|
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@ -237,6 +237,21 @@ default_t defaults[] =
|
|||||||
{"show_messages",&showMessages, 1},
|
{"show_messages",&showMessages, 1},
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
{"key_right",&key_right, KEY_RIGHTARROW},
|
||||||
|
{"key_left",&key_left, KEY_LEFTARROW},
|
||||||
|
{"key_up",&key_up, KEY_UPARROW},
|
||||||
|
{"key_down",&key_down, KEY_DOWNARROW},
|
||||||
|
{"key_strafeleft",&key_strafeleft, ','},
|
||||||
|
{"key_straferight",&key_straferight, '.'},
|
||||||
|
|
||||||
|
{"key_fire",&key_fire, KEY_RCTRL},
|
||||||
|
{"key_use",&key_use, ' '},
|
||||||
|
{"key_strafe",&key_strafe, KEY_RALT},
|
||||||
|
{"key_speed",&key_speed, KEY_RSHIFT},
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NORMALUNIX
|
#ifdef NORMALUNIX
|
||||||
{"key_right",&key_right, KEY_RIGHTARROW},
|
{"key_right",&key_right, KEY_RIGHTARROW},
|
||||||
{"key_left",&key_left, KEY_LEFTARROW},
|
{"key_left",&key_left, KEY_LEFTARROW},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user