author | koda |
Tue, 30 Jun 2009 12:31:32 +0000 | |
changeset 2213 | bd51bbf06033 |
parent 2200 | 8192be6e3aef |
child 2240 | 7ce9e6b7be3b |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
unit SDLh; |
|
20 |
interface |
|
753 | 21 |
|
4 | 22 |
{$IFDEF LINUX} |
23 |
{$DEFINE UNIX} |
|
24 |
{$ENDIF} |
|
25 |
{$IFDEF FREEBSD} |
|
26 |
{$DEFINE UNIX} |
|
27 |
{$ENDIF} |
|
28 |
||
29 |
{$IFDEF UNIX} |
|
1903 | 30 |
{$IFNDEF DARWIN} |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
31 |
{$linklib c} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
32 |
{$ENDIF} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
33 |
{$linklib pthread} |
4 | 34 |
{$ENDIF} |
35 |
||
432 | 36 |
{$PACKRECORDS C} |
4 | 37 |
|
1819 | 38 |
{$IFDEF DARWIN} |
2200
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
39 |
{$PASCALMAINNAME SDL_main} |
2152 | 40 |
{$IFNDEF IPHONEOS} |
2200
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
41 |
{$linkframework Cocoa} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
42 |
{$linkframework SDL} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
43 |
{$linkframework SDL_net} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
44 |
{$linkframework SDL_image} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
45 |
{$linkframework SDL_ttf} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
46 |
{$linklib openalbridge} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
47 |
{$linklib SDLmain} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
48 |
{$linklib gcc} |
1819 | 49 |
{$ENDIF} |
1916 | 50 |
{$ENDIF} |
1819 | 51 |
|
1997 | 52 |
(* SDL *) |
4 | 53 |
const {$IFDEF WIN32} |
54 |
SDLLibName = 'SDL.dll'; |
|
55 |
{$ENDIF} |
|
56 |
{$IFDEF UNIX} |
|
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
57 |
{$IFDEF DARWIN} |
2152 | 58 |
SDLLibName = 'SDL'; |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
59 |
{$ELSE} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
60 |
SDLLibName = 'libSDL.so'; |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
61 |
{$ENDIF} |
4 | 62 |
{$ENDIF} |
63 |
SDL_SWSURFACE = $00000000; |
|
64 |
SDL_HWSURFACE = $00000001; |
|
65 |
SDL_ASYNCBLIT = $00000004; |
|
66 |
SDL_ANYFORMAT = $10000000; |
|
67 |
SDL_HWPALETTE = $20000000; |
|
358 | 68 |
SDL_DOUBLEBUF = $40000000; |
4 | 69 |
SDL_FULLSCREEN = $80000000; |
70 |
SDL_NOFRAME = $00000020; |
|
71 |
SDL_HWACCEL = $00000100; |
|
72 |
SDL_SRCCOLORKEY = $00001000; |
|
73 |
SDL_RLEACCEL = $00004000; |
|
2017 | 74 |
SDL_SRCALPHA = $00010000; |
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
75 |
|
4 | 76 |
SDL_NOEVENT = 0; |
308 | 77 |
SDL_ACTIVEEVENT = 1; |
4 | 78 |
SDL_KEYDOWN = 2; |
79 |
SDL_KEYUP = 3; |
|
80 |
SDL_QUITEV = 12; |
|
1120 | 81 |
SDL_VIDEORESIZE = 16; |
4 | 82 |
|
308 | 83 |
SDL_APPINPUTFOCUS = 2; |
84 |
||
4 | 85 |
SDL_INIT_VIDEO = $00000020; |
11 | 86 |
SDL_INIT_AUDIO = $00000010; |
753 | 87 |
|
88 |
SDL_GL_DOUBLEBUFFER = 5; |
|
89 |
SDL_OPENGL = 2; |
|
1120 | 90 |
SDL_RESIZABLE = $00000010; |
754 | 91 |
|
92 |
RMask = $FF; |
|
93 |
GMask = $FF00; |
|
94 |
BMask = $FF0000; |
|
95 |
AMask = $FF000000; |
|
96 |
||
4 | 97 |
type PSDL_Rect = ^TSDL_Rect; |
98 |
TSDL_Rect = record |
|
99 |
x, y: SmallInt; |
|
100 |
w, h: Word; |
|
101 |
end; |
|
102 |
||
103 |
TPoint = record |
|
105 | 104 |
X: LongInt; |
105 |
Y: LongInt; |
|
4 | 106 |
end; |
107 |
||
108 |
PSDL_PixelFormat = ^TSDL_PixelFormat; |
|
109 |
TSDL_PixelFormat = record |
|
110 |
palette: Pointer; |
|
111 |
BitsPerPixel : Byte; |
|
112 |
BytesPerPixel: Byte; |
|
113 |
Rloss : Byte; |
|
114 |
Gloss : Byte; |
|
115 |
Bloss : Byte; |
|
116 |
Aloss : Byte; |
|
117 |
Rshift: Byte; |
|
118 |
Gshift: Byte; |
|
119 |
Bshift: Byte; |
|
120 |
Ashift: Byte; |
|
121 |
RMask : Longword; |
|
122 |
GMask : Longword; |
|
123 |
BMask : Longword; |
|
124 |
AMask : Longword; |
|
125 |
colorkey: Longword; |
|
126 |
alpha : Byte; |
|
127 |
end; |
|
128 |
||
129 |
||
130 |
PSDL_Surface = ^TSDL_Surface; |
|
131 |
TSDL_Surface = record |
|
132 |
flags : Longword; |
|
133 |
format: PSDL_PixelFormat; |
|
432 | 134 |
w, h : LongInt; |
4 | 135 |
pitch : Word; |
136 |
pixels: Pointer; |
|
432 | 137 |
offset: LongInt; |
4 | 138 |
end; |
139 |
||
140 |
PSDL_Color = ^TSDL_Color; |
|
141 |
TSDL_Color = record |
|
206
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
142 |
case byte of |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
143 |
0: (r: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
144 |
g: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
145 |
b: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
146 |
unused: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
147 |
); |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
148 |
1: (value: Longword); |
4 | 149 |
end; |
150 |
||
151 |
PSDL_RWops = ^TSDL_RWops; |
|
105 | 152 |
TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; |
153 |
TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; |
|
154 |
TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; |
|
155 |
TClose = function( context: PSDL_RWops ): LongInt; cdecl; |
|
4 | 156 |
|
157 |
TStdio = record |
|
105 | 158 |
autoclose: LongInt; |
4 | 159 |
fp: pointer; |
160 |
end; |
|
161 |
||
162 |
TMem = record |
|
163 |
base: PByte; |
|
164 |
here: PByte; |
|
165 |
stop: PByte; |
|
166 |
end; |
|
167 |
||
168 |
TUnknown = record |
|
169 |
data1: Pointer; |
|
170 |
end; |
|
171 |
||
172 |
TSDL_RWops = record |
|
173 |
seek: TSeek; |
|
174 |
read: TRead; |
|
175 |
write: TWrite; |
|
176 |
close: TClose; |
|
177 |
type_: Longword; |
|
178 |
case Byte of |
|
179 |
0: (stdio: TStdio); |
|
180 |
1: (mem: TMem); |
|
181 |
2: (unknown: TUnknown); |
|
182 |
end; |
|
183 |
||
184 |
TSDL_KeySym = record |
|
185 |
scancode: Byte; |
|
106 | 186 |
sym: Longword; |
4 | 187 |
modifier: Longword; |
188 |
unicode: Word; |
|
189 |
end; |
|
190 |
||
308 | 191 |
TSDL_ActiveEvent = record |
192 |
type_: byte; |
|
1120 | 193 |
gain: byte; |
194 |
state: byte; |
|
195 |
end; |
|
308 | 196 |
|
4 | 197 |
TSDL_KeyboardEvent = record |
198 |
type_: Byte; |
|
199 |
which: Byte; |
|
200 |
state: Byte; |
|
201 |
keysym: TSDL_KeySym; |
|
202 |
end; |
|
203 |
||
204 |
TSDL_QuitEvent = record |
|
205 |
type_: Byte; |
|
206 |
end; |
|
1120 | 207 |
TSDL_ResizeEvent = record |
208 |
type_: Byte; |
|
209 |
w, h: LongInt; |
|
210 |
end; |
|
211 |
||
4 | 212 |
PSDL_Event = ^TSDL_Event; |
213 |
TSDL_Event = record |
|
214 |
case Byte of |
|
215 |
SDL_NOEVENT: (type_: byte); |
|
308 | 216 |
SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); |
4 | 217 |
SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent); |
218 |
SDL_QUITEV: (quit: TSDL_QuitEvent); |
|
1120 | 219 |
SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); |
4 | 220 |
end; |
221 |
||
222 |
PByteArray = ^TByteArray; |
|
316 | 223 |
TByteArray = array[0..65535] of Byte; |
224 |
PLongWordArray = ^TLongWordArray; |
|
225 |
TLongWordArray = array[0..16383] of LongWord; |
|
4 | 226 |
|
433 | 227 |
PSDL_Thread = Pointer; |
228 |
PSDL_mutex = Pointer; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
229 |
|
432 | 230 |
function SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName; |
4 | 231 |
procedure SDL_Quit; cdecl; external SDLLibName; |
432 | 232 |
function SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName; |
233 |
procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName; |
|
4 | 234 |
|
235 |
procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName; |
|
236 |
function SDL_GetTicks: Longword; cdecl; external SDLLibName; |
|
237 |
||
238 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
432 | 239 |
function SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 240 |
procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
241 |
||
242 |
function SDL_GetError: PChar; cdecl; external SDLLibName; |
|
243 |
||
432 | 244 |
function SDL_SetVideoMode(width, height, bpp: LongInt; flags: Longword): PSDL_Surface; cdecl; external SDLLibName; |
245 |
function SDL_CreateRGBSurface(flags: Longword; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
246 |
function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
4 | 247 |
procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
105 | 248 |
function SDL_SetColorKey(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName; |
2017 | 249 |
function SDL_SetAlpha(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName; |
4 | 250 |
|
105 | 251 |
function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName; |
252 |
function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: Longword): LongInt; cdecl; external SDLLibName; |
|
253 |
procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: Longword); cdecl; external SDLLibName; |
|
432 | 254 |
function SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 255 |
|
256 |
procedure SDL_GetRGB(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName; |
|
107 | 257 |
function SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): Longword; cdecl; external SDLLibName; |
4 | 258 |
|
259 |
function SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
|
35 | 260 |
function SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
4 | 261 |
|
262 |
function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName; |
|
432 | 263 |
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 264 |
|
2152 | 265 |
{$IFDEF SDL13} |
266 |
function SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName; |
|
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2152
diff
changeset
|
267 |
function SDL_GetMouseState(index: LongInt; x, y: PInteger): Byte; cdecl; external SDLLibName; |
2152 | 268 |
{$ELSE} |
105 | 269 |
function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName; |
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2152
diff
changeset
|
270 |
function SDL_GetMouseState(x, y: PInteger): Byte; cdecl; external SDLLibName; |
2152 | 271 |
{$ENDIF} |
4 | 272 |
function SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName; |
273 |
procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName; |
|
274 |
||
432 | 275 |
function SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName; |
4 | 276 |
|
432 | 277 |
function SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 278 |
|
279 |
procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName; |
|
280 |
||
433 | 281 |
function SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName; |
282 |
procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName; |
|
283 |
function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP'; |
|
284 |
function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV'; |
|
285 |
||
753 | 286 |
function SDL_GL_SetAttribute(attr: byte; value: LongInt): LongInt; cdecl; external SDLLibName; |
287 |
procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName; |
|
288 |
||
4 | 289 |
(* TTF *) |
290 |
||
291 |
const {$IFDEF WIN32} |
|
292 |
SDL_TTFLibName = 'SDL_ttf.dll'; |
|
293 |
{$ENDIF} |
|
294 |
{$IFDEF UNIX} |
|
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
295 |
{$IFDEF DARWIN} |
2152 | 296 |
SDL_TTFLibName = 'SDL_ttf'; |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
297 |
{$ELSE} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
298 |
SDL_TTFLibName = 'libSDL_ttf.so'; |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
299 |
{$ENDIF} |
4 | 300 |
{$ENDIF} |
202 | 301 |
TTF_STYLE_NORMAL = 0; |
302 |
TTF_STYLE_BOLD = 1; |
|
303 |
TTF_STYLE_ITALIC = 2; |
|
4 | 304 |
|
305 |
type PTTF_Font = ^TTTF_font; |
|
306 |
TTTF_Font = record |
|
307 |
end; |
|
308 |
||
432 | 309 |
function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
4 | 310 |
procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
311 |
||
312 |
||
432 | 313 |
function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName; |
206
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
314 |
(* TSDL_Color -> Longword conversion is workaround over freepascal bug. |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
315 |
See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
316 |
function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
317 |
function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
318 |
function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
206
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
319 |
|
432 | 320 |
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
321 |
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
4 | 322 |
|
323 |
||
1997 | 324 |
(* SDL_image *) |
4 | 325 |
|
326 |
const {$IFDEF WIN32} |
|
327 |
SDL_ImageLibName = 'SDL_image.dll'; |
|
328 |
{$ENDIF} |
|
329 |
{$IFDEF UNIX} |
|
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
330 |
{$IFDEF DARWIN} |
2152 | 331 |
SDL_ImageLibName = 'SDL_image'; |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
332 |
{$ELSE} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
333 |
SDL_ImageLibName = 'libSDL_image.so'; |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
334 |
{$ENDIF} |
4 | 335 |
{$ENDIF} |
336 |
||
337 |
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
338 |
||
1997 | 339 |
(* SDL_net *) |
4 | 340 |
|
341 |
const {$IFDEF WIN32} |
|
342 |
SDL_NetLibName = 'SDL_net.dll'; |
|
343 |
{$ENDIF} |
|
344 |
{$IFDEF UNIX} |
|
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
345 |
{$IFDEF DARWIN} |
2152 | 346 |
SDL_NetLibName = 'SDL_net'; |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
347 |
{$ELSE} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
348 |
SDL_NetLibName = 'libSDL_net.so'; |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
349 |
{$ENDIF} |
4 | 350 |
{$ENDIF} |
351 |
||
352 |
type TIPAddress = record |
|
353 |
host: Longword; |
|
354 |
port: Word; |
|
355 |
end; |
|
356 |
||
357 |
PTCPSocket = ^TTCPSocket; |
|
358 |
TTCPSocket = record |
|
106 | 359 |
ready: LongInt; |
105 | 360 |
channel: LongInt; |
106 | 361 |
remoteAddress: TIPaddress; |
4 | 362 |
localAddress: TIPaddress; |
105 | 363 |
sflag: LongInt; |
4 | 364 |
end; |
365 |
PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
366 |
TSDLNet_SocketSet = record |
|
367 |
numsockets, |
|
105 | 368 |
maxsockets: LongInt; |
4 | 369 |
sockets: PTCPSocket; |
370 |
end; |
|
371 |
||
105 | 372 |
function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
4 | 373 |
procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
374 |
||
105 | 375 |
function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
376 |
function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 377 |
function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
378 |
function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
105 | 379 |
function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
380 |
function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 381 |
procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
382 |
procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
105 | 383 |
function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
384 |
function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 385 |
|
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
386 |
procedure SDLNet_Write16(value: Word; buf: pointer); |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
387 |
procedure SDLNet_Write32(value: LongWord; buf: pointer); |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
388 |
function SDLNet_Read16(buf: pointer): Word; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
389 |
function SDLNet_Read32(buf: pointer): LongWord; |
4 | 390 |
|
391 |
implementation |
|
392 |
||
393 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
394 |
begin |
|
432 | 395 |
SDL_MustLock:= ( surface^.offset <> 0 ) |
4 | 396 |
or(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
397 |
end; |
|
398 |
||
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
399 |
procedure SDLNet_Write16(value: Word; buf: pointer); |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
400 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
401 |
PByteArray(buf)^[1]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
402 |
PByteArray(buf)^[0]:= value shr 8 |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
403 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
404 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
405 |
procedure SDLNet_Write32(value: LongWord; buf: pointer); |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
406 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
407 |
PByteArray(buf)^[3]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
408 |
PByteArray(buf)^[2]:= value shr 8; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
409 |
PByteArray(buf)^[1]:= value shr 16; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
410 |
PByteArray(buf)^[0]:= value shr 24 |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
411 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
412 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
413 |
function SDLNet_Read16(buf: pointer): Word; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
414 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
415 |
SDLNet_Read16:= PByteArray(buf)^[1] or |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
416 |
(PByteArray(buf)^[0] shl 8) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
417 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
418 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
419 |
function SDLNet_Read32(buf: pointer): LongWord; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
420 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
421 |
SDLNet_Read32:= PByteArray(buf)^[3] or |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
422 |
(PByteArray(buf)^[2] shl 8) or |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
423 |
(PByteArray(buf)^[1] shl 16) or |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
424 |
(PByteArray(buf)^[0] shl 24) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
425 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
426 |
|
4 | 427 |
end. |