Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
4380:66aea42c3541 | 4381:5425a6fbacf8 |
---|---|
34 .globl _SDL_AtariVblInstall | 34 .globl _SDL_AtariVblInstall |
35 .globl _SDL_AtariVblUninstall | 35 .globl _SDL_AtariVblUninstall |
36 | 36 |
37 .globl _SDL_MintAudio_hasfpu | 37 .globl _SDL_MintAudio_hasfpu |
38 | 38 |
39 /*--- Save/restore FPU context ---*/ | |
40 | |
41 #if defined(__mcoldfire__) | |
42 | |
43 #define SAVE_FPU_CONTEXT \ | |
44 lea sp@(-216),sp; \ | |
45 fsave sp@; \ | |
46 fmovel fpiar,sp@-; \ | |
47 lea sp@(-64),sp; \ | |
48 fmovemd fp0-fp7,sp@ | |
49 | |
50 #define RESTORE_FPU_CONTEXT \ | |
51 fmovemd sp@,fp0-fp7; \ | |
52 lea sp@(64),sp; \ | |
53 fmovel sp@+,fpiar; \ | |
54 frestore sp@; \ | |
55 lea sp@(216),sp | |
56 | |
57 #else | |
58 | |
59 #define SAVE_FPU_CONTEXT \ | |
60 .chip 68k/68881; \ | |
61 fsave sp@-; \ | |
62 fmoveml fpcr/fpsr/fpiar,sp@-; \ | |
63 fmovemx fp0-fp7,sp@-; \ | |
64 .chip 68k | |
65 | |
66 #define RESTORE_FPU_CONTEXT \ | |
67 .chip 68k/68881; \ | |
68 fmovemx sp@+,fp0-fp7; \ | |
69 fmoveml sp@+,fpcr/fpsr/fpiar; \ | |
70 frestore sp@+; \ | |
71 .chip 68k | |
72 | |
73 #endif | |
74 | |
39 /*--- Vector installer ---*/ | 75 /*--- Vector installer ---*/ |
40 | 76 |
41 _SDL_AtariVblInstall: | 77 _SDL_AtariVblInstall: |
78 #if defined(__mcoldfire__) | |
79 movel sp@(4),d0 | |
80 movel d0,my_vector | |
81 #else | |
42 movel sp@(4),my_vector | 82 movel sp@(4),my_vector |
83 #endif | |
84 | |
43 lea _my_vbl,a0 | 85 lea _my_vbl,a0 |
44 | 86 |
45 clrw vbl_mutex | 87 clrw vbl_mutex |
88 #if defined(__mcoldfire__) | |
89 movel _hz_200.w,d0 | |
90 movel d0, _SDL_Atari_hz200 | |
91 #else | |
46 movel _hz_200.w, _SDL_Atari_hz200 | 92 movel _hz_200.w, _SDL_Atari_hz200 |
93 #endif | |
47 | 94 |
48 /* Stop interrupts */ | 95 /* Stop interrupts */ |
49 | 96 |
50 movew #0x2700,sr | 97 movew #0x2700,sr |
51 | 98 |
56 moveq #7,d0 | 103 moveq #7,d0 |
57 bcl_search_place: | 104 bcl_search_place: |
58 movel (a1),d1 | 105 movel (a1),d1 |
59 beqs place_found | 106 beqs place_found |
60 addql #4,a1 | 107 addql #4,a1 |
108 #if defined(__mcoldfire__) | |
109 subql #1,d0 | |
110 bpls bcl_search_place | |
111 #else | |
61 dbra d0,bcl_search_place | 112 dbra d0,bcl_search_place |
113 #endif | |
62 | 114 |
63 /* Not found */ | 115 /* Not found */ |
64 moveq #1,d0 | 116 moveq #1,d0 |
65 bras exit_vbl_queue | 117 bras exit_vbl_queue |
66 | 118 |
98 bnes next_place | 150 bnes next_place |
99 clrl (a1) | 151 clrl (a1) |
100 moveq #0,d1 | 152 moveq #0,d1 |
101 next_place: | 153 next_place: |
102 addql #4,a1 | 154 addql #4,a1 |
155 #if defined(__mcoldfire__) | |
156 subql #1,d1 | |
157 bpls bcl_search_place | |
158 #else | |
103 dbra d1,bcl2_search_place | 159 dbra d1,bcl2_search_place |
160 #endif | |
104 | 161 |
105 /* Restart interrupts */ | 162 /* Restart interrupts */ |
106 movew #0x2300,sr | 163 movew #0x2300,sr |
107 badvector: | 164 badvector: |
108 rts | 165 rts |
109 | 166 |
110 /*--- Our vbl ---*/ | 167 /*--- Our vbl ---*/ |
111 | 168 |
112 _my_vbl: | 169 _my_vbl: |
170 #if defined(__mcoldfire__) | |
171 lea sp@(-60),sp | |
172 moveml d0-d7/a0-a6,sp@ | |
173 #else | |
174 moveml d0-d7/a0-a6,sp@- | |
175 #endif | |
176 | |
113 /* Update _hz_200 */ | 177 /* Update _hz_200 */ |
178 #if defined(__mcoldfire__) | |
179 movel _hz_200.w,d0 | |
180 movel d0, _SDL_Atari_hz200 | |
181 #else | |
114 movel _hz_200.w, _SDL_Atari_hz200 | 182 movel _hz_200.w, _SDL_Atari_hz200 |
183 #endif | |
115 | 184 |
116 /* Verify if this is not already running */ | 185 /* Verify if this is not already running */ |
117 | 186 |
118 tstw vbl_mutex | 187 tstw vbl_mutex |
119 bnes vbl_end | 188 bnes vbl_end |
189 #if defined(__mcoldfire__) | |
190 movew vbl_mutex,d0 | |
191 notl d0 | |
192 movew d0,vbl_mutex | |
193 #else | |
120 notw vbl_mutex | 194 notw vbl_mutex |
121 | 195 #endif |
122 moveml d0-d7/a0-a6,sp@- | |
123 | 196 |
124 /* Save FPU if needed */ | 197 /* Save FPU if needed */ |
125 tstw _SDL_MintAudio_hasfpu | 198 tstw _SDL_MintAudio_hasfpu |
126 beqs SDL_AtariVbl_nofpu1 | 199 beqs SDL_AtariVbl_nofpu1 |
127 .chip 68060 | 200 SAVE_FPU_CONTEXT |
128 fsave sp@- | |
129 fmoveml fpcr/fpsr/fpiar,sp@- | |
130 fmovemx fp0-fp7,sp@- | |
131 .chip 68000 | |
132 SDL_AtariVbl_nofpu1: | 201 SDL_AtariVbl_nofpu1: |
133 | 202 |
134 movel my_vector,a0 | 203 movel my_vector,a0 |
135 jsr a0@ | 204 jsr a0@ |
136 | 205 |
137 /* Restore FPU if needed */ | 206 /* Restore FPU if needed */ |
138 tstw _SDL_MintAudio_hasfpu | 207 tstw _SDL_MintAudio_hasfpu |
139 beqs SDL_AtariVbl_Xbios_nofpu2 | 208 beqs SDL_AtariVbl_Xbios_nofpu2 |
140 .chip 68060 | 209 RESTORE_FPU_CONTEXT |
141 fmovemx sp@+,fp0-fp7 | |
142 fmoveml sp@+,fpcr/fpsr/fpiar | |
143 frestore sp@+ | |
144 .chip 68000 | |
145 SDL_AtariVbl_Xbios_nofpu2: | 210 SDL_AtariVbl_Xbios_nofpu2: |
146 | |
147 moveml sp@+,d0-d7/a0-a6 | |
148 | 211 |
149 clrw vbl_mutex | 212 clrw vbl_mutex |
150 vbl_end: | 213 vbl_end: |
214 #if defined(__mcoldfire__) | |
215 moveml sp@,d0-d7/a0-a6 | |
216 lea sp@(60),sp | |
217 #else | |
218 moveml sp@+,d0-d7/a0-a6 | |
219 #endif | |
151 rts | 220 rts |
152 | 221 |
153 .data | 222 .data |
154 .even | 223 .even |
155 .comm _SDL_Atari_hz200,4*1 | 224 .comm _SDL_Atari_hz200,4*1 |