src/timer/mint/SDL_systimer.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
permissions -rw-r--r--
more tweaking indent options
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
    13
    Lesser General Public License for more details.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
    16
    License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1045
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1396
diff changeset
    22
#include "SDL_config.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    24
#ifdef SDL_TIMER_MINT
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    25
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
/*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
 *	TOS/MiNT timer driver
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
 *	based on vbl vector
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
 *
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
 *	Patrice Mandin
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#include <stdio.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include <sys/time.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#include <signal.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#include <unistd.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#include <string.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#include <errno.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
    40
#include <mint/cookie.h>
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
    41
#include <mint/sysvars.h>
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
#include <mint/osbind.h>
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
    43
#include <mint/mintbind.h>
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
#include "SDL_timer.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    46
#include "../SDL_timer_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
#include "SDL_thread.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
1396
428c8690cf73 Add missing include directories
Patrice Mandin <patmandin@gmail.com>
parents: 1361
diff changeset
    49
#include "SDL_vbltimer_s.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
/* The first ticks value of the application */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
static Uint32 start;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
static SDL_bool supervisor;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    54
static int mint_present;        /* can we use Syield() ? */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    56
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    57
SDL_StartTicks(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    59
    void *oldpile;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    60
    unsigned long dummy;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    62
    /* Set first ticks value */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    63
    oldpile = (void *) Super(0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    64
    start = *((volatile long *) _hz_200);
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    65
    Super(oldpile);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    67
    start *= 5;                 /* One _hz_200 tic is 5ms */
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
    68
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    69
    mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    72
Uint32
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    73
SDL_GetTicks(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    75
    Uint32 now;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    76
    void *oldpile = NULL;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    78
    /* Check if we are in supervisor mode 
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    79
       (this is the case when called from SDL_ThreadedTimerCheck,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    80
       which is called from RunTimer, running in the vbl vector)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    81
     */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    82
    if (!supervisor) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    83
        oldpile = (void *) Super(0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    84
    }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    86
    now = *((volatile long *) _hz_200);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    88
    if (!supervisor) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    89
        Super(oldpile);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    90
    }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    92
    return ((now * 5) - start);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    95
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
    96
SDL_Delay(Uint32 ms)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
    98
    Uint32 now;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   100
    now = SDL_GetTicks();
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   101
    while ((SDL_GetTicks() - now) < ms) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   102
        if (mint_present) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   103
            Syield();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   104
        }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   105
    }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
/* Data to handle a single periodic alarm */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   109
static SDL_bool timer_installed = SDL_FALSE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   111
static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   112
RunTimer(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   114
    supervisor = SDL_TRUE;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   115
    SDL_ThreadedTimerCheck();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   116
    supervisor = SDL_FALSE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
/* This is only called if the event thread is not running */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   120
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   121
SDL_SYS_TimerInit(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   123
    void *oldpile;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   125
    supervisor = SDL_FALSE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   127
    /* Install RunTimer in vbl vector */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   128
    oldpile = (void *) Super(0);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   129
    timer_installed = !SDL_AtariVblInstall(RunTimer);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   130
    Super(oldpile);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   132
    if (!timer_installed) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   133
        return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   134
    }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   135
    return (SDL_SetTimerThreaded(0));
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   138
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   139
SDL_SYS_TimerQuit(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   141
    void *oldpile;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   143
    if (timer_installed) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   144
        /* Uninstall RunTimer vbl vector */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   145
        oldpile = (void *) Super(0);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   146
        SDL_AtariVblUninstall(RunTimer);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   147
        Super(oldpile);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   148
        timer_installed = SDL_FALSE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   149
    }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   152
int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   153
SDL_SYS_StartTimer(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
{
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   155
    SDL_SetError("Internal logic error: MiNT uses vbl timer");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   156
    return (-1);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   159
void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
   160
SDL_SYS_StopTimer(void)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
{
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   162
    return;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
}
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   164
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   165
#endif /* SDL_TIMER_MINT */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
   166
/* vi: set ts=4 sw=4 expandtab: */