Subversion Repositories eduke32

Rev

Rev 8710 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8710 Rev 8716
Line 32... Line 32...
32
uint8_t g_keyAsciiPos;
32
uint8_t g_keyAsciiPos;
33
uint8_t g_keyAsciiEnd;
33
uint8_t g_keyAsciiEnd;
34
char    g_keyRemapTable[NUMKEYS];
34
char    g_keyRemapTable[NUMKEYS];
35
char    g_keyNameTable[NUMKEYS][24];
35
char    g_keyNameTable[NUMKEYS][24];
36
36
-
 
37
int32_t r_maxfps = -1;
-
 
38
int32_t r_maxfpsoffset;
-
 
39
uint64_t g_frameDelay;
-
 
40
37
void (*keypresscallback)(int32_t, int32_t);
41
void (*keypresscallback)(int32_t, int32_t);
38
42
39
void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
43
void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
40
44
41
int32_t keyGetState(int32_t key) { return keystatus[g_keyRemapTable[key]]; }
45
int32_t keyGetState(int32_t key) { return keystatus[g_keyRemapTable[key]]; }
Line 486... Line 490...
486
    if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
490
    if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
487
    {
491
    {
488
        videoSetPalette(GAMMA_CALC,0,0);
492
        videoSetPalette(GAMMA_CALC,0,0);
489
        return r;
493
        return r;
490
    }
494
    }
-
 
495
    else if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset"))
-
 
496
    {
-
 
497
        if (r_maxfps > 0) r_maxfps = clamp(r_maxfps, 30, 1000);
-
 
498
        g_frameDelay = calcFrameDelay(r_maxfps, r_maxfpsoffset);
491
499
    }
492
    return r;
500
    return r;
493
}
501
}
494
502
495
int32_t baselayer_init(void)
503
int32_t baselayer_init(void)
496
{
504
{
Line 510... Line 518...
510
        { "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",
518
        { "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",
511
          (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 },
519
          (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 },
512
        { "r_fpgrouscan","use floating-point numbers for slope rendering",(void *) &r_fpgrouscan, CVAR_BOOL, 0, 1 },
520
        { "r_fpgrouscan","use floating-point numbers for slope rendering",(void *) &r_fpgrouscan, CVAR_BOOL, 0, 1 },
513
        { "r_novoxmips","turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 },
521
        { "r_novoxmips","turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 },
514
        { "r_voxels","enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 },
522
        { "r_voxels","enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 },
-
 
523
        { "r_maxfps", "limit the frame rate", (void *)&r_maxfps, CVAR_INT | CVAR_FUNCPTR, -1, 1000 },
-
 
524
        { "r_maxfpsoffset", "menu-controlled offset for r_maxfps", (void *)&r_maxfpsoffset, CVAR_INT | CVAR_FUNCPTR, -10, 10 },
515
#ifdef YAX_ENABLE
525
#ifdef YAX_ENABLE
516
        { "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
526
        { "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
517
#endif
527
#endif
518
        { "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 },
528
        { "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 },
519
        { "vid_gamma","adjusts gamma component of gamma ramp",(void *) &g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
529
        { "vid_gamma","adjusts gamma component of gamma ramp",(void *) &g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
Line 576... Line 586...
576
        *stdout = *fp;
586
        *stdout = *fp;
577
        *stderr = *fp;
587
        *stderr = *fp;
578
    }
588
    }
579
#endif
589
#endif
580
}
590
}
-
 
591
-
 
592
int engineFPSLimit(void)
-
 
593
{
-
 
594
    if (!r_maxfps)
-
 
595
        return true;
-
 
596
-
 
597
    g_frameDelay = calcFrameDelay(r_maxfps, r_maxfpsoffset);
-
 
598
-
 
599
    uint64_t const  frameJitter = timerGetPerformanceFrequency() / 1000ull;
-
 
600
    uint64_t        frameTicks;
-
 
601
    static uint64_t nextFrameTicks;
-
 
602
    static uint64_t frameDelay;
-
 
603
-
 
604
    if (g_frameDelay != frameDelay)
-
 
605
    {
-
 
606
        nextFrameTicks = timerGetPerformanceCounter() + g_frameDelay;
-
 
607
        frameDelay = g_frameDelay;
-
 
608
    }
-
 
609
-
 
610
    do { handleevents(); } while (nextFrameTicks - (frameTicks = timerGetPerformanceCounter()) < frameJitter);
-
 
611
-
 
612
    if (nextFrameTicks - frameTicks > g_frameDelay)
-
 
613
    {
-
 
614
        while (nextFrameTicks - frameTicks > g_frameDelay)
-
 
615
            nextFrameTicks += g_frameDelay;
-
 
616
-
 
617
        return true;
-
 
618
    }
-
 
619
-
 
620
    return false;
-
 
621
}