forked from KolibriOS/kolibrios
Wolf3D:
- Fixed speed. - Fixed lags. - Returned --res parameter git-svn-id: svn://kolibrios.org@9097 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7f933eb487
commit
83d5b68cdf
@ -43,6 +43,7 @@ OBJECTS += mame/fmopl.o
|
||||
SDL_OBJ += SDL/SDL_wave.o
|
||||
SDL_OBJ += SDL/SDL_audiocvt.o
|
||||
SDL_OBJ += SDL/SDL_mixer.o
|
||||
SDL_OBJ += SDL/uSDL.o
|
||||
|
||||
SDL_MIX_OBJ += SDL_mixer/mixer.o
|
||||
SDL_MIX_OBJ += SDL_mixer/music.o
|
||||
|
29
contrib/games/wolf3d/SDL/uSDL.c
Normal file
29
contrib/games/wolf3d/SDL/uSDL.c
Normal file
@ -0,0 +1,29 @@
|
||||
static unsigned __starttime;
|
||||
|
||||
void uSDL_StartTicks(void){
|
||||
__asm__ __volatile__ (
|
||||
"int $0x40"
|
||||
:"=a"(__starttime)
|
||||
:"a"(26),"b"(9)
|
||||
:"memory"
|
||||
);
|
||||
}
|
||||
|
||||
unsigned uSDL_GetTicks(void){
|
||||
unsigned __curtime;
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=a"(__curtime)
|
||||
:"a"(26),"b"(9)
|
||||
:"memory"
|
||||
);
|
||||
return (__curtime-__starttime);
|
||||
}
|
||||
|
||||
void uSDL_Delay(unsigned time){
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
::"a"(5), "b"(time/3)
|
||||
:"memory"
|
||||
);
|
||||
}
|
@ -42,6 +42,14 @@
|
||||
#define __MIX_INTERNAL_EFFECT__
|
||||
#include "effects_internal.h"
|
||||
|
||||
#ifdef _KOLIBRI
|
||||
void uSDL_Delay(unsigned int time);
|
||||
unsigned uSDL_GetTicks();
|
||||
#else
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
#endif
|
||||
|
||||
/* Magic numbers for various audio file formats */
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
@ -300,7 +308,7 @@ static void mix_channels(void *udata, Uint8 *stream, int len)
|
||||
}
|
||||
|
||||
/* Mix any playing channels... */
|
||||
sdl_ticks = SDL_GetTicks();
|
||||
sdl_ticks = uSDL_GetTicks();
|
||||
for ( i=0; i<num_channels; ++i ) {
|
||||
if( ! mix_channel[i].paused ) {
|
||||
if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
|
||||
@ -857,7 +865,7 @@ int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
|
||||
|
||||
/* Queue up the audio data for this channel */
|
||||
if ( which >= 0 && which < num_channels ) {
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
if (Mix_Playing(which))
|
||||
_Mix_channel_done_playing(which);
|
||||
mix_channel[which].samples = chunk->abuf;
|
||||
@ -888,7 +896,7 @@ int Mix_ExpireChannel(int which, int ticks)
|
||||
}
|
||||
} else if ( which < num_channels ) {
|
||||
SDL_LockAudio();
|
||||
mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + ticks) : 0;
|
||||
mix_channel[which].expire = (ticks>0) ? ( uSDL_GetTicks() + ticks) : 0;
|
||||
SDL_UnlockAudio();
|
||||
++ status;
|
||||
}
|
||||
@ -927,7 +935,7 @@ int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int t
|
||||
|
||||
/* Queue up the audio data for this channel */
|
||||
if ( which >= 0 && which < num_channels ) {
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
if (Mix_Playing(which))
|
||||
_Mix_channel_done_playing(which);
|
||||
mix_channel[which].samples = chunk->abuf;
|
||||
@ -1046,7 +1054,7 @@ int Mix_FadeOutChannel(int which, int ms)
|
||||
mix_channel[which].fade_volume = mix_channel[which].volume;
|
||||
mix_channel[which].fading = MIX_FADING_OUT;
|
||||
mix_channel[which].fade_length = ms;
|
||||
mix_channel[which].ticks_fade = SDL_GetTicks();
|
||||
mix_channel[which].ticks_fade = uSDL_GetTicks();
|
||||
|
||||
/* only change fade_volume_reset if we're not fading. */
|
||||
if (mix_channel[which].fading == MIX_NO_FADING) {
|
||||
@ -1151,7 +1159,7 @@ void Mix_CloseAudio(void)
|
||||
/* Pause a particular channel (or all) */
|
||||
void Mix_Pause(int which)
|
||||
{
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
if ( which == -1 ) {
|
||||
int i;
|
||||
|
||||
@ -1170,7 +1178,7 @@ void Mix_Pause(int which)
|
||||
/* Resume a paused channel */
|
||||
void Mix_Resume(int which)
|
||||
{
|
||||
Uint32 sdl_ticks = SDL_GetTicks();
|
||||
Uint32 sdl_ticks = uSDL_GetTicks();
|
||||
|
||||
SDL_LockAudio();
|
||||
if ( which == -1 ) {
|
||||
@ -1260,7 +1268,7 @@ int Mix_GroupCount(int tag)
|
||||
int Mix_GroupOldest(int tag)
|
||||
{
|
||||
int chan = -1;
|
||||
Uint32 mintime = SDL_GetTicks();
|
||||
Uint32 mintime = uSDL_GetTicks();
|
||||
int i;
|
||||
for( i=0; i < num_channels; i ++ ) {
|
||||
if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
|
||||
|
@ -71,6 +71,13 @@
|
||||
static SDL_AudioSpec used_mixer;
|
||||
#endif
|
||||
|
||||
#ifdef _KOLIBRI
|
||||
extern void uSDL_Delay(unsigned int time);
|
||||
extern unsigned uSDL_GetTicks();
|
||||
#else
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
#endif
|
||||
|
||||
int volatile music_active = 1;
|
||||
static int volatile music_stopped = 0;
|
||||
@ -761,7 +768,7 @@ void Mix_FreeMusic(Mix_Music *music)
|
||||
/* Wait for any fade out to finish */
|
||||
while ( music->fading == MIX_FADING_OUT ) {
|
||||
SDL_UnlockAudio();
|
||||
SDL_Delay(100);
|
||||
uSDL_Delay(100);
|
||||
SDL_LockAudio();
|
||||
}
|
||||
if ( music == music_playing ) {
|
||||
@ -1013,7 +1020,7 @@ int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
|
||||
/* If the current music is fading out, wait for the fade to complete */
|
||||
while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) {
|
||||
SDL_UnlockAudio();
|
||||
SDL_Delay(100);
|
||||
uSDL_Delay(100);
|
||||
SDL_LockAudio();
|
||||
}
|
||||
music_active = 1;
|
||||
|
@ -22,7 +22,8 @@ compile_gcc{
|
||||
|
||||
-- SDL and SDL_mixer --
|
||||
compile_gcc{
|
||||
"SDL/SDL_wave.c", "SDL/SDL_audiocvt.c", "SDL/SDL_mixer.c", "SDL_mixer/mixer.c", "SDL_mixer/music.c", "SDL_mixer/load_aiff.c", "SDL_mixer/load_voc.c",
|
||||
"SDL/SDL_wave.c", "SDL/SDL_audiocvt.c", "SDL/SDL_mixer.c", "SDL_mixer/mixer.c", "SDL_mixer/music.c",
|
||||
"SDL_mixer/load_aiff.c", "SDL_mixer/load_voc.c", "SDL/uSDL.c",
|
||||
"SDL_mixer/effects_internal.c", "SDL_mixer/effect_position.c",
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ boolean IN_UserInput(longword delay)
|
||||
IN_ProcessEvents();
|
||||
if (IN_CheckAck())
|
||||
return true;
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
} while (GetTimeCount() - lasttime < delay);
|
||||
return(false);
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ SD_SetMusicMode(SMMode mode)
|
||||
|
||||
SD_FadeOutMusic();
|
||||
while (SD_MusicPlaying())
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -1284,7 +1284,7 @@ void
|
||||
SD_WaitSoundDone(void)
|
||||
{
|
||||
while (SD_SoundPlaying())
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -119,11 +119,17 @@ extern SMMode MusicMode;
|
||||
extern int DigiMap[];
|
||||
extern int DigiChannel[];
|
||||
|
||||
#define GetTimeCount() ((SDL_GetTicks()*7)/100)
|
||||
#ifdef _KOLIBRI
|
||||
extern void uSDL_Delay(unsigned time);
|
||||
#else
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#endif
|
||||
|
||||
#define GetTimeCount() (( uSDL_GetTicks()*7)/100)
|
||||
|
||||
inline void Delay(int wolfticks)
|
||||
{
|
||||
if(wolfticks>0) SDL_Delay(wolfticks * 100 / 7);
|
||||
if(wolfticks>0) uSDL_Delay(wolfticks * 100/ 7);
|
||||
}
|
||||
|
||||
// Function prototypes
|
||||
|
@ -741,7 +741,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
|
||||
|
||||
cursorvis ^= true;
|
||||
}
|
||||
else SDL_Delay(5);
|
||||
else uSDL_Delay(5);
|
||||
if (cursorvis)
|
||||
USL_XORICursor(x,y,s,cursor);
|
||||
|
||||
@ -772,7 +772,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
|
||||
void US_InitRndT(int randomize)
|
||||
{
|
||||
if(randomize)
|
||||
rndindex = (SDL_GetTicks() >> 4) & 0xff;
|
||||
rndindex = ( uSDL_GetTicks() >> 4) & 0xff;
|
||||
else
|
||||
rndindex = 0;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ extern SDL_Color gamepal[256];
|
||||
// VGA hardware routines
|
||||
//
|
||||
|
||||
#define VL_WaitVBL(a) SDL_Delay((a)*8)
|
||||
#define VL_WaitVBL(a) uSDL_Delay((a)*8)
|
||||
|
||||
void VL_SetVGAPlaneMode (void);
|
||||
void VL_SetTextMode (void);
|
||||
|
@ -208,3 +208,4 @@ void setcwd(char* path){
|
||||
::"a"(30), "b"(1), "c"(path)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,17 @@
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#ifdef _KOLIBRI
|
||||
extern "C"{
|
||||
extern void uSDL_Delay(unsigned int time);
|
||||
extern unsigned uSDL_GetTicks();
|
||||
}
|
||||
#else
|
||||
#define uSDL_Delay SDL_Delay
|
||||
#define uSDL_GetTicks SDL_GetTicks
|
||||
#endif
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#if defined(_arch_dreamcast)
|
||||
@ -1391,7 +1402,7 @@ static inline fixed FixedMul(fixed a, fixed b)
|
||||
#endif
|
||||
#define DEMOCOND_SDL (!DEMOCOND_ORIG)
|
||||
|
||||
#define GetTicks() ((SDL_GetTicks()*7)/100)
|
||||
#define GetTicks() (( uSDL_GetTicks()*7)/100)
|
||||
|
||||
#define ISPOINTER(x) ((((uintptr_t)(x)) & ~0xffff) != 0)
|
||||
|
||||
@ -1483,3 +1494,5 @@ static inline longword READLONGWORD(byte *&ptr)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// WL_DRAW.C
|
||||
|
||||
#include "wl_def.h"
|
||||
#include <cstdio>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "wl_cloudsky.h"
|
||||
@ -1073,12 +1074,12 @@ void CalcTics (void)
|
||||
if (lasttimecount > (int32_t) GetTimeCount())
|
||||
lasttimecount = GetTimeCount(); // if the game was paused a LONG time
|
||||
|
||||
uint32_t curtime = SDL_GetTicks();
|
||||
uint32_t curtime = uSDL_GetTicks();
|
||||
tics = (curtime * 7) / 100 - lasttimecount;
|
||||
if(!tics)
|
||||
{
|
||||
// wait until end of current tic
|
||||
SDL_Delay(((lasttimecount + 1) * 100) / 7 - curtime);
|
||||
uSDL_Delay(((lasttimecount + 1) * 100) / 7 - curtime);
|
||||
tics = 1;
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ BJ_Breathe (void)
|
||||
static int which = 0, max = 10;
|
||||
int pics[2] = { L_GUYPIC, L_GUY2PIC };
|
||||
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
|
||||
if ((int32_t) GetTimeCount () - lastBreathTime > max)
|
||||
{
|
||||
|
@ -27,6 +27,9 @@ extern byte signon[];
|
||||
extern void kolibri_set_win_center();
|
||||
extern char* dirname(char* path);
|
||||
extern void setcwd(char* path);
|
||||
extern "C"{
|
||||
extern void uSDL_StartTicks(void);
|
||||
}
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
@ -1126,7 +1129,7 @@ void DoJukebox(void)
|
||||
|
||||
#ifndef SPEAR
|
||||
#ifndef UPLOAD
|
||||
start = ((SDL_GetTicks()/10)%3)*6;
|
||||
start = (( uSDL_GetTicks()/10)%3)*6;
|
||||
#else
|
||||
start = 0;
|
||||
#endif
|
||||
@ -1217,6 +1220,9 @@ static void InitGame()
|
||||
printf("Unable to init SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _KOLIBRI
|
||||
uSDL_StartTicks();
|
||||
#endif
|
||||
SDL_AudioInit(NULL);
|
||||
atexit(SDL_Quit);
|
||||
|
||||
@ -1906,8 +1912,8 @@ void CheckParameters(int argc, char *argv[])
|
||||
" --nowait Skips intro screens\n"
|
||||
#ifndef _KOLIBRI
|
||||
" --windowed[-mouse] Starts the game in a window [and grabs mouse]\n"
|
||||
" --res <width> <height> Sets the screen resolution\n"
|
||||
#endif
|
||||
" --res <width> <height> Sets the screen resolution\n"
|
||||
" (must be multiple of 320x200 or 320x240)\n"
|
||||
" --resf <w> <h> Sets any screen resolution >= 320x200\n"
|
||||
" (which may result in graphic errors)\n"
|
||||
@ -1916,7 +1922,7 @@ void CheckParameters(int argc, char *argv[])
|
||||
" allowed: 8, 16, 24, 32, default: \"best\" depth)\n"
|
||||
" --nodblbuf Don't use SDL's double buffering\n"
|
||||
" --extravbls <vbls> Sets a delay after each frame, which may help to\n"
|
||||
" reduce flickering (unit is currently 8 ms, default: 0)\n"
|
||||
" reduce flickering (unit is currently 8 ms, default: 2)\n"
|
||||
#ifndef _KOLIBRI
|
||||
" --joystick <index> Use the index-th joystick if available\n"
|
||||
" (-1 to disable joystick, default: 0)\n"
|
||||
|
@ -1956,7 +1956,7 @@ MouseSensitivity (int)
|
||||
DrawMouseSens ();
|
||||
do
|
||||
{
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
switch (ci.dir)
|
||||
{
|
||||
@ -2228,7 +2228,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
redraw = 0;
|
||||
}
|
||||
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
|
||||
if (type == MOUSE || type == JOYSTICK)
|
||||
@ -2274,7 +2274,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
lastFlashTime = GetTimeCount();
|
||||
VW_UpdateScreen ();
|
||||
}
|
||||
else SDL_Delay(5);
|
||||
else uSDL_Delay(5);
|
||||
|
||||
//
|
||||
// WHICH TYPE OF INPUT DO WE PROCESS?
|
||||
@ -2397,7 +2397,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
while (!cust->allowed[which]);
|
||||
redraw = 1;
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) uSDL_Delay(5);
|
||||
IN_ClearKeysDown ();
|
||||
break;
|
||||
|
||||
@ -2411,7 +2411,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
|
||||
while (!cust->allowed[which]);
|
||||
redraw = 1;
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
|
||||
while (ReadAnyControl (&ci), ci.dir != dir_None) uSDL_Delay(5);
|
||||
IN_ClearKeysDown ();
|
||||
break;
|
||||
case dir_North:
|
||||
@ -2837,7 +2837,7 @@ CP_ChangeView (int)
|
||||
do
|
||||
{
|
||||
CheckPause ();
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
switch (ci.dir)
|
||||
{
|
||||
@ -3284,7 +3284,7 @@ HandleMenu (CP_iteminfo * item_i, CP_itemtype * items, void (*routine) (int w))
|
||||
routine (which);
|
||||
VW_UpdateScreen ();
|
||||
}
|
||||
else SDL_Delay(5);
|
||||
else uSDL_Delay(5);
|
||||
|
||||
CheckPause ();
|
||||
|
||||
@ -3484,7 +3484,7 @@ DrawHalfStep (int x, int y)
|
||||
VWB_DrawPic (x, y, C_CURSOR1PIC);
|
||||
VW_UpdateScreen ();
|
||||
SD_PlaySound (MOVEGUN1SND);
|
||||
SDL_Delay(1); //Fixed too long delay in the menu
|
||||
uSDL_Delay(1); //Fixed too long delay in the menu
|
||||
}
|
||||
|
||||
|
||||
@ -3526,7 +3526,7 @@ TicDelay (int count)
|
||||
int32_t startTime = GetTimeCount ();
|
||||
do
|
||||
{
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
ReadAnyControl (&ci);
|
||||
}
|
||||
while ((int32_t) GetTimeCount () - startTime < count && ci.dir != dir_None);
|
||||
@ -3732,7 +3732,7 @@ Confirm (const char *string)
|
||||
tick ^= 1;
|
||||
lastBlinkTime = GetTimeCount();
|
||||
}
|
||||
else SDL_Delay(5);
|
||||
else uSDL_Delay(5);
|
||||
|
||||
#ifdef SPANISH
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ int songs[] = {
|
||||
XFUNKIE_MUS,
|
||||
XDEATH_MUS,
|
||||
XGETYOU_MUS, // DON'T KNOW
|
||||
ULTIMATE_MUS, // Trans Gr”sse
|
||||
ULTIMATE_MUS, // Trans Gr<EFBFBD>sse
|
||||
|
||||
DUNGEON_MUS,
|
||||
GOINGAFT_MUS,
|
||||
@ -406,11 +406,11 @@ void PollControls (void)
|
||||
if (demoplayback || demorecord) // demo recording and playback needs to be constant
|
||||
{
|
||||
// wait up to DEMOTICS Wolf tics
|
||||
uint32_t curtime = SDL_GetTicks();
|
||||
uint32_t curtime = uSDL_GetTicks();
|
||||
lasttimecount += DEMOTICS;
|
||||
int32_t timediff = (lasttimecount * 100) / 7 - curtime;
|
||||
if(timediff > 0)
|
||||
SDL_Delay(timediff);
|
||||
uSDL_Delay(timediff);
|
||||
|
||||
if(timediff < -2 * DEMOTICS) // more than 2-times DEMOTICS behind?
|
||||
lasttimecount = (curtime * 7) / 100; // yes, set to current timecount
|
||||
|
@ -669,7 +669,7 @@ void ShowArticle (char *article)
|
||||
firstpage = false;
|
||||
}
|
||||
}
|
||||
SDL_Delay(5);
|
||||
uSDL_Delay(5);
|
||||
|
||||
LastScan = 0;
|
||||
ReadAnyControl(&ci);
|
||||
|
Loading…
Reference in New Issue
Block a user