|
1 /* |
|
2 SDL - Simple DirectMedia Layer |
|
3 Copyright (C) 1997-2006 Sam Lantinga |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Lesser General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2.1 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Lesser General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Lesser General Public |
|
16 License along with this library; if not, write to the Free Software |
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
|
19 Sam Lantinga |
|
20 slouken@libsdl.org |
|
21 */ |
|
22 |
|
23 /* |
|
24 * VBL queue routine |
|
25 * |
|
26 * Patrice Mandin |
|
27 */ |
|
28 |
|
29 #define _vbl_queue 0x456 |
|
30 #define _hz_200 0x4ba |
|
31 |
|
32 .text |
|
33 |
|
34 .globl _SDL_AtariVblInstall |
|
35 .globl _SDL_AtariVblUninstall |
|
36 |
|
37 .globl _SDL_MintAudio_hasfpu |
|
38 |
|
39 /*--- Vector installer ---*/ |
|
40 |
|
41 _SDL_AtariVblInstall: |
|
42 movel sp@(4),my_vector |
|
43 lea _my_vbl,a0 |
|
44 |
|
45 clrw vbl_mutex |
|
46 movel _hz_200.w, _SDL_Atari_hz200 |
|
47 |
|
48 /* Stop interrupts */ |
|
49 |
|
50 movew #0x2700,sr |
|
51 |
|
52 /* Read vbl_queue pointer */ |
|
53 movel _vbl_queue.w,a1 |
|
54 |
|
55 /* Search a free place */ |
|
56 moveq #7,d0 |
|
57 bcl_search_place: |
|
58 movel (a1),d1 |
|
59 beqs place_found |
|
60 addql #4,a1 |
|
61 dbra d0,bcl_search_place |
|
62 |
|
63 /* Not found */ |
|
64 moveq #1,d0 |
|
65 bras exit_vbl_queue |
|
66 |
|
67 /* Then install ourselves */ |
|
68 place_found: |
|
69 movel a0,(a1) |
|
70 moveq #0,d0 |
|
71 |
|
72 exit_vbl_queue: |
|
73 /* Restart interrupts */ |
|
74 movew #0x2300,sr |
|
75 |
|
76 rts |
|
77 |
|
78 /*--- Vector uninstaller ---*/ |
|
79 |
|
80 _SDL_AtariVblUninstall: |
|
81 movel sp@(4),d0 |
|
82 cmpl my_vector,d0 |
|
83 bnes badvector |
|
84 |
|
85 movel #_my_vbl,d0 |
|
86 |
|
87 /* Stop interrupts */ |
|
88 |
|
89 movew #0x2700,sr |
|
90 |
|
91 /* Read vbl_queue pointer */ |
|
92 movel _vbl_queue.w,a1 |
|
93 |
|
94 /* Search where we are */ |
|
95 moveq #7,d1 |
|
96 bcl2_search_place: |
|
97 cmpl (a1),d0 |
|
98 bnes next_place |
|
99 clrl (a1) |
|
100 moveq #0,d1 |
|
101 next_place: |
|
102 addql #4,a1 |
|
103 dbra d1,bcl2_search_place |
|
104 |
|
105 /* Restart interrupts */ |
|
106 movew #0x2300,sr |
|
107 badvector: |
|
108 rts |
|
109 |
|
110 /*--- Our vbl ---*/ |
|
111 |
|
112 _my_vbl: |
|
113 /* Update _hz_200 */ |
|
114 movel _hz_200.w, _SDL_Atari_hz200 |
|
115 |
|
116 /* Verify if this is not already running */ |
|
117 |
|
118 tstw vbl_mutex |
|
119 bnes vbl_end |
|
120 notw vbl_mutex |
|
121 |
|
122 moveml d0-d7/a0-a6,sp@- |
|
123 |
|
124 /* Save FPU if needed */ |
|
125 tstw _SDL_MintAudio_hasfpu |
|
126 beqs SDL_AtariVbl_nofpu1 |
|
127 .chip 68060 |
|
128 fsave sp@- |
|
129 fmoveml fpcr/fpsr/fpiar,sp@- |
|
130 fmovemx fp0-fp7,sp@- |
|
131 .chip 68000 |
|
132 SDL_AtariVbl_nofpu1: |
|
133 |
|
134 movel my_vector,a0 |
|
135 jsr a0@ |
|
136 |
|
137 /* Restore FPU if needed */ |
|
138 tstw _SDL_MintAudio_hasfpu |
|
139 beqs SDL_AtariVbl_Xbios_nofpu2 |
|
140 .chip 68060 |
|
141 fmovemx sp@+,fp0-fp7 |
|
142 fmoveml sp@+,fpcr/fpsr/fpiar |
|
143 frestore sp@+ |
|
144 .chip 68000 |
|
145 SDL_AtariVbl_Xbios_nofpu2: |
|
146 |
|
147 moveml sp@+,d0-d7/a0-a6 |
|
148 |
|
149 clrw vbl_mutex |
|
150 vbl_end: |
|
151 rts |
|
152 |
|
153 .data |
|
154 .even |
|
155 .comm _SDL_Atari_hz200,4*1 |
|
156 .even |
|
157 .comm vbl_mutex,2*1 |
|
158 .even |
|
159 .comm my_vector,4*1 |