annotate src/timer/mint/SDL_systimer.c @ 4384:6800e2560310 SDL-1.2

Fixed bugs #882 and 865, re-opening bug #634 Ronald Lamprecht to SDL Hi, Sam Lantinga wrote: The problem with that fix is that it breaks IME events again. Maybe we can handle keyboard events differently to prevent this issue? Spending an hour reading MSDN, analysing SDL and another hour testing the reality on XP I am really wondering how patch r4990 could have ever worked in any situation. It's main effect is to break the unicode translation and causing spurious activation events! Why does TranslateMessage(&msg) nothing useful? Simply because it does not affect "msg" at all! All keyboard events are dispatched without the slightest change (see MSDN). TranslateMessage() just appends additional WM_CHAR, WM_DEADCHAR, WM_SYSCHAR, WM_SYSDEADCHAR event messages to the queue. But I could not find any SDL event handling routine that catches these events and transforms them to proper SDL keyevents while eliminating the corresponding WM_KEYDOWN, etc. events. Thus any IME input like the '@' generated by "Alt + 6(Numpad) + 4(Numpad)" is simply lost. But the situation is even worse! Up to r4990 the TranslateKey()/ToUnicode() calls did evaluate dead keys and did deliver proper key events for subsequent key strokes like '´' + 'e' resulting in 'é'. ToUnicode() needs proper key state informations to be able to handle these substitutions. But unfortunatly TranslateMessage() needs the same state information and eats it up while generating the WM_CHAR messages :-( Thus the current 1.2.14 breakes the partial IME support of previous releases, too. The key state race condition between ToUnicode() and TranslateMessage() requires to avoid any ToUnicode() usage for receiving proper WM_CHAR, etc. messages generated by TranslateMessage(). (Yes - the '@' and 'é' appear as WM_CHAR messages when unicode is switched off). The spurious SDL activation events are *not* caused by additional WM_ACTIVATE Windows messages! Besides DIB_HandleMessage() SDL_PrivateAppActive() is called by another source which I am not yet aware of - any hints? Thus I do strongly recommend the deletion of the TranslateMessage(&msg) call as a quick fix. A proper support of unicode and IME requires a clean SDL keyboard input concept first. Which SDL keyboards events should be transmitted to the app when the user presses '´' + 'e' ? Within the current unicode handling the first key stroke is hidden. Even though ToUnicode() delivers the proper key SDL does ignore it in TranslateKey(). Just the composed key event is transmitted to the app. That is what you expect for text input, but the app can no longer use keys like '^' as a key button because it will never receive a key event for it! With a given concept it seems to be necessary to regenerate SDL key events out of the WM_CHAR, etc. events and to drop all related direct WM_KEYDOWN, etc. events while the remaining basic WM_KEYDOWN, etc. events would still have to result in SDL key events. Anyway the source of the spurious WM_ACTIVATE should be located to avoid future trouble. Greets, Ronald
author Sam Lantinga <slouken@libsdl.org>
date Tue, 17 Nov 2009 04:59:13 +0000
parents a1b03ba2fcd0
children
rev   line source
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
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 3955
diff changeset
3 Copyright (C) 1997-2009 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
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1635
diff changeset
51 /* from audio/mint */
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1635
diff changeset
52 void SDL_MintAudio_CheckFpu(void);
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1635
diff changeset
53
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* The first ticks value of the application */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static Uint32 start;
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
56 static SDL_bool read_hz200_from_vbl = SDL_FALSE;
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
57 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
58
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 void SDL_StartTicks(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 {
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
61 void *old_stack;
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
62 unsigned long dummy;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* Set first ticks value */
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
65 old_stack = (void *)Super(0);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
66 start = *((volatile long *)_hz_200);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
67 Super(old_stack);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 start *= 5; /* One _hz_200 tic is 5ms */
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
70
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
71 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
72 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 Uint32 SDL_GetTicks (void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 {
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
76 Uint32 now = start;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
78 if (read_hz200_from_vbl) {
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
79 now = SDL_Atari_hz200;
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
80 } else {
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
81 void *old_stack = (void *)Super(0);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
82 now = *((volatile long *)_hz_200);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
83 Super(old_stack);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 return((now*5)-start);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 void SDL_Delay (Uint32 ms)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 Uint32 now;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 now = SDL_GetTicks();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 while ((SDL_GetTicks()-now)<ms){
1045
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
95 if (mint_present) {
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
96 Syield();
63b8e93a3a52 Release CPU when waiting
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
97 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 /* Data to handle a single periodic alarm */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 static SDL_bool timer_installed=SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /* This is only called if the event thread is not running */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 int SDL_SYS_TimerInit(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
107 void *old_stack;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1635
diff changeset
109 SDL_MintAudio_CheckFpu();
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1635
diff changeset
110
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 /* Install RunTimer in vbl vector */
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
112 old_stack = (void *)Super(0);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
113 timer_installed = !SDL_AtariVblInstall(SDL_ThreadedTimerCheck);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
114 Super(old_stack);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if (!timer_installed) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 return(-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
119
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
120 read_hz200_from_vbl = SDL_TRUE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 return(SDL_SetTimerThreaded(0));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 void SDL_SYS_TimerQuit(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 {
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
126 /* Uninstall RunTimer vbl vector */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 if (timer_installed) {
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
128 void *old_stack = (void *)Super(0);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
129 SDL_AtariVblUninstall(SDL_ThreadedTimerCheck);
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
130 Super(old_stack);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 timer_installed = SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3954
diff changeset
133 read_hz200_from_vbl = SDL_FALSE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 int SDL_SYS_StartTimer(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 SDL_SetError("Internal logic error: MiNT uses vbl timer");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 return(-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 void SDL_SYS_StopTimer(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 }
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
146
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
147 #endif /* SDL_TIMER_MINT */