Mercurial > sdl-ios-xcode
annotate src/video/SDL_memops.h @ 330:5fed858d551c
Date: 03 Apr 2002 15:28:09 +0200
From: Alexander Pipelka <pipelka@bms-austria.com>
Subject: SDL patches
This one adds 2 new videomodes for the fbconsole.
720x576, 720x480
These are used by the NSC settopbox we are using for MPEG2 decoding.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 03 Apr 2002 21:45:25 +0000 |
parents | f6ffac90895c |
children | b8d311d90021 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 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 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
1
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #ifndef _SDL_memops_h | |
29 #define _SDL_memops_h | |
30 | |
31 /* System dependent optimized memory manipulation routines: | |
32 */ | |
33 #include <string.h> | |
34 | |
35 #if defined(__GNUC__) && defined(i386) | |
36 /* Thanks to Brennan "Bas" Underwood, for the inspiration. :) | |
37 */ | |
38 #define SDL_memcpy(dst, src, len) \ | |
39 do { \ | |
40 int u0, u1, u2; \ | |
41 __asm__ __volatile__ ( \ | |
42 "cld\n\t" \ | |
43 "rep ; movsl\n\t" \ | |
44 "testb $2,%b4\n\t" \ | |
45 "je 1f\n\t" \ | |
46 "movsw\n" \ | |
47 "1:\ttestb $1,%b4\n\t" \ | |
48 "je 2f\n\t" \ | |
49 "movsb\n" \ | |
50 "2:" \ | |
51 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ | |
52 : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ | |
53 : "memory" ); \ | |
54 } while(0) | |
55 | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
56 #define SDL_memcpy4(dst, src, len) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
57 do { \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
58 int ecx, edi, esi; \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
59 __asm__ __volatile__ ( \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
60 "cld\n\t" \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
61 "rep ; movsl" \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
62 : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
63 : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
64 : "memory" ); \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
65 } while(0) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
66 |
0 | 67 #define SDL_revcpy(dst, src, len) \ |
68 do { \ | |
69 int u0, u1, u2; \ | |
70 char *dstp = (char *)(dst); \ | |
71 char *srcp = (char *)(src); \ | |
72 int n = (len); \ | |
73 if ( n >= 4 ) { \ | |
74 __asm__ __volatile__ ( \ | |
75 "std\n\t" \ | |
76 "rep ; movsl\n\t" \ | |
77 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ | |
78 : "0" (n >> 2), \ | |
79 "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ | |
80 : "memory" ); \ | |
81 } \ | |
82 switch (n & 3) { \ | |
83 case 3: dstp[2] = srcp[2]; \ | |
84 case 2: dstp[1] = srcp[1]; \ | |
85 case 1: dstp[0] = srcp[0]; \ | |
86 break; \ | |
87 default: \ | |
88 break; \ | |
89 } \ | |
90 } while(0) | |
91 | |
92 #define SDL_memmove(dst, src, len) \ | |
93 do { \ | |
94 if ( (dst) < (src) ) { \ | |
95 SDL_memcpy((dst), (src), (len)); \ | |
96 } else { \ | |
97 SDL_revcpy((dst), (src), (len)); \ | |
98 } \ | |
99 } while(0) | |
100 | |
101 #define SDL_memset4(dst, val, len) \ | |
102 do { \ | |
103 int u0, u1, u2; \ | |
104 __asm__ __volatile__ ( \ | |
105 "cld\n\t" \ | |
106 "rep ; stosl\n\t" \ | |
107 : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ | |
108 : "0" (dst), "1" (val), "2" ((Uint32)(len)) \ | |
109 : "memory" ); \ | |
110 } while(0) | |
111 | |
112 #endif /* GNU C and x86 */ | |
113 | |
114 /* If there are no optimized versions, define the normal versions */ | |
115 #ifndef SDL_memcpy | |
116 #define SDL_memcpy(dst, src, len) memcpy(dst, src, len) | |
117 #endif | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
118 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
119 #ifndef SDL_memcpy4 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
120 #define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len) << 2) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
121 #endif |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
122 |
0 | 123 #ifndef SDL_revcpy |
124 #define SDL_revcpy(dst, src, len) memmove(dst, src, len) | |
125 #endif | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
126 |
0 | 127 #ifndef SDL_memset4 |
128 #define SDL_memset4(dst, val, len) \ | |
129 do { \ | |
130 unsigned _count = (len); \ | |
131 unsigned _n = (_count + 3) / 4; \ | |
132 Uint32 *_p = (Uint32 *)(dst); \ | |
133 Uint32 _val = (val); \ | |
134 switch (_count % 4) { \ | |
135 case 0: do { *_p++ = _val; \ | |
136 case 3: *_p++ = _val; \ | |
137 case 2: *_p++ = _val; \ | |
138 case 1: *_p++ = _val; \ | |
139 } while ( --_n ); \ | |
140 } \ | |
141 } while(0) | |
142 #endif | |
143 | |
144 #endif /* _SDL_memops_h */ |