annotate src/timer/mint/SDL_vbltimer.S @ 4381:5425a6fbacf8 SDL-1.2

Adapt timer code for Coldfire
author Patrice Mandin <patmandin@gmail.com>
date Sat, 07 Nov 2009 20:56:09 +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: 297
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: 297
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: 297
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: 297
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: 297
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: 297
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 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 * VBL queue routine
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 *
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 * Patrice Mandin
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #define _vbl_queue 0x456
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
30 #define _hz_200 0x4ba
281
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 .text
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 .globl _SDL_AtariVblInstall
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 .globl _SDL_AtariVblUninstall
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
37 .globl _SDL_MintAudio_hasfpu
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
38
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
39 /*--- Save/restore FPU context ---*/
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
40
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
41 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
42
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
43 #define SAVE_FPU_CONTEXT \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
44 lea sp@(-216),sp; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
45 fsave sp@; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
46 fmovel fpiar,sp@-; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
47 lea sp@(-64),sp; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
48 fmovemd fp0-fp7,sp@
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
49
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
50 #define RESTORE_FPU_CONTEXT \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
51 fmovemd sp@,fp0-fp7; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
52 lea sp@(64),sp; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
53 fmovel sp@+,fpiar; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
54 frestore sp@; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
55 lea sp@(216),sp
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
56
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
57 #else
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
58
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
59 #define SAVE_FPU_CONTEXT \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
60 .chip 68k/68881; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
61 fsave sp@-; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
62 fmoveml fpcr/fpsr/fpiar,sp@-; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
63 fmovemx fp0-fp7,sp@-; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
64 .chip 68k
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
65
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
66 #define RESTORE_FPU_CONTEXT \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
67 .chip 68k/68881; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
68 fmovemx sp@+,fp0-fp7; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
69 fmoveml sp@+,fpcr/fpsr/fpiar; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
70 frestore sp@+; \
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
71 .chip 68k
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
72
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
73 #endif
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
74
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 /*--- Vector installer ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 _SDL_AtariVblInstall:
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
78 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
79 movel sp@(4),d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
80 movel d0,my_vector
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
81 #else
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 movel sp@(4),my_vector
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
83 #endif
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
84
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 lea _my_vbl,a0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 clrw vbl_mutex
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
88 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
89 movel _hz_200.w,d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
90 movel d0, _SDL_Atari_hz200
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
91 #else
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
92 movel _hz_200.w, _SDL_Atari_hz200
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
93 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 /* Stop interrupts */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 movew #0x2700,sr
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 /* Read vbl_queue pointer */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 movel _vbl_queue.w,a1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 /* Search a free place */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 moveq #7,d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 bcl_search_place:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 movel (a1),d1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 beqs place_found
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 addql #4,a1
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
108 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
109 subql #1,d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
110 bpls bcl_search_place
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
111 #else
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 dbra d0,bcl_search_place
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
113 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 /* Not found */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 moveq #1,d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 bras exit_vbl_queue
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 /* Then install ourselves */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 place_found:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 movel a0,(a1)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 moveq #0,d0
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 exit_vbl_queue:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 /* Restart interrupts */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 movew #0x2300,sr
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 rts
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 /*--- Vector uninstaller ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 _SDL_AtariVblUninstall:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 movel sp@(4),d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 cmpl my_vector,d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 bnes badvector
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 movel #_my_vbl,d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 /* Stop interrupts */
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 movew #0x2700,sr
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 /* Read vbl_queue pointer */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 movel _vbl_queue.w,a1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 /* Search where we are */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 moveq #7,d1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 bcl2_search_place:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 cmpl (a1),d0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 bnes next_place
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 clrl (a1)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 moveq #0,d1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 next_place:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 addql #4,a1
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
155 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
156 subql #1,d1
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
157 bpls bcl_search_place
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
158 #else
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 dbra d1,bcl2_search_place
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
160 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 /* Restart interrupts */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 movew #0x2300,sr
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 badvector:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 rts
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 /*--- Our vbl ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 _my_vbl:
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
170 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
171 lea sp@(-60),sp
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
172 moveml d0-d7/a0-a6,sp@
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
173 #else
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
174 moveml d0-d7/a0-a6,sp@-
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
175 #endif
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
176
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
177 /* Update _hz_200 */
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
178 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
179 movel _hz_200.w,d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
180 movel d0, _SDL_Atari_hz200
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
181 #else
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
182 movel _hz_200.w, _SDL_Atari_hz200
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
183 #endif
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
184
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 /* Verify if this is not already running */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 tstw vbl_mutex
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 bnes vbl_end
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
189 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
190 movew vbl_mutex,d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
191 notl d0
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
192 movew d0,vbl_mutex
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
193 #else
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 notw vbl_mutex
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
195 #endif
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
196
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
197 /* Save FPU if needed */
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
198 tstw _SDL_MintAudio_hasfpu
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
199 beqs SDL_AtariVbl_nofpu1
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
200 SAVE_FPU_CONTEXT
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
201 SDL_AtariVbl_nofpu1:
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
202
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 movel my_vector,a0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 jsr a0@
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
205
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
206 /* Restore FPU if needed */
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
207 tstw _SDL_MintAudio_hasfpu
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
208 beqs SDL_AtariVbl_Xbios_nofpu2
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
209 RESTORE_FPU_CONTEXT
3883
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
210 SDL_AtariVbl_Xbios_nofpu2:
cfe850b334e7 Also save/restore fpu register in vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 1312
diff changeset
211
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 clrw vbl_mutex
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 vbl_end:
4381
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
214 #if defined(__mcoldfire__)
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
215 moveml sp@,d0-d7/a0-a6
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
216 lea sp@(60),sp
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
217 #else
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
218 moveml sp@+,d0-d7/a0-a6
5425a6fbacf8 Adapt timer code for Coldfire
Patrice Mandin <patmandin@gmail.com>
parents: 4159
diff changeset
219 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 rts
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 .data
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 .even
3955
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
224 .comm _SDL_Atari_hz200,4*1
40b6b5744e05 Avoid switch to supervisor mode in SDL_GetTicks, by updating system counter from vbl interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 3883
diff changeset
225 .even
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 .comm vbl_mutex,2*1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 .even
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 .comm my_vector,4*1