author | unc0rr |
Fri, 25 Jan 2008 20:47:50 +0000 | |
changeset 753 | 40fc0deb388f |
parent 500 | d9b140e9d2c2 |
child 754 | 94ac14829085 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
316 | 3 |
* Copyright (c) 2004-2007 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} |
|
30 |
{$linklib c} |
|
105 | 31 |
{$linklib pthread} |
4 | 32 |
{$ENDIF} |
33 |
||
432 | 34 |
{$PACKRECORDS C} |
4 | 35 |
|
36 |
(* SDL *) |
|
37 |
const {$IFDEF WIN32} |
|
38 |
SDLLibName = 'SDL.dll'; |
|
39 |
{$ENDIF} |
|
40 |
{$IFDEF UNIX} |
|
41 |
SDLLibName = 'libSDL.so'; |
|
42 |
{$ENDIF} |
|
43 |
SDL_SWSURFACE = $00000000; |
|
44 |
SDL_HWSURFACE = $00000001; |
|
45 |
SDL_ASYNCBLIT = $00000004; |
|
46 |
SDL_ANYFORMAT = $10000000; |
|
47 |
SDL_HWPALETTE = $20000000; |
|
358 | 48 |
SDL_DOUBLEBUF = $40000000; |
4 | 49 |
SDL_FULLSCREEN = $80000000; |
50 |
SDL_NOFRAME = $00000020; |
|
51 |
SDL_HWACCEL = $00000100; |
|
52 |
SDL_SRCCOLORKEY = $00001000; |
|
53 |
SDL_RLEACCEL = $00004000; |
|
54 |
||
55 |
SDL_NOEVENT = 0; |
|
308 | 56 |
SDL_ACTIVEEVENT = 1; |
4 | 57 |
SDL_KEYDOWN = 2; |
58 |
SDL_KEYUP = 3; |
|
59 |
SDL_QUITEV = 12; |
|
60 |
||
308 | 61 |
SDL_APPINPUTFOCUS = 2; |
62 |
||
4 | 63 |
SDL_INIT_VIDEO = $00000020; |
11 | 64 |
SDL_INIT_AUDIO = $00000010; |
753 | 65 |
|
66 |
SDL_GL_DOUBLEBUFFER = 5; |
|
67 |
SDL_OPENGL = 2; |
|
11 | 68 |
|
4 | 69 |
type PSDL_Rect = ^TSDL_Rect; |
70 |
TSDL_Rect = record |
|
71 |
x, y: SmallInt; |
|
72 |
w, h: Word; |
|
73 |
end; |
|
74 |
||
75 |
TPoint = record |
|
105 | 76 |
X: LongInt; |
77 |
Y: LongInt; |
|
4 | 78 |
end; |
79 |
||
80 |
PSDL_PixelFormat = ^TSDL_PixelFormat; |
|
81 |
TSDL_PixelFormat = record |
|
82 |
palette: Pointer; |
|
83 |
BitsPerPixel : Byte; |
|
84 |
BytesPerPixel: Byte; |
|
85 |
Rloss : Byte; |
|
86 |
Gloss : Byte; |
|
87 |
Bloss : Byte; |
|
88 |
Aloss : Byte; |
|
89 |
Rshift: Byte; |
|
90 |
Gshift: Byte; |
|
91 |
Bshift: Byte; |
|
92 |
Ashift: Byte; |
|
93 |
RMask : Longword; |
|
94 |
GMask : Longword; |
|
95 |
BMask : Longword; |
|
96 |
AMask : Longword; |
|
97 |
colorkey: Longword; |
|
98 |
alpha : Byte; |
|
99 |
end; |
|
100 |
||
101 |
||
102 |
PSDL_Surface = ^TSDL_Surface; |
|
103 |
TSDL_Surface = record |
|
104 |
flags : Longword; |
|
105 |
format: PSDL_PixelFormat; |
|
432 | 106 |
w, h : LongInt; |
4 | 107 |
pitch : Word; |
108 |
pixels: Pointer; |
|
432 | 109 |
offset: LongInt; |
4 | 110 |
end; |
111 |
||
112 |
PSDL_Color = ^TSDL_Color; |
|
113 |
TSDL_Color = record |
|
206
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
114 |
case byte of |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
115 |
0: (r: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
116 |
g: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
117 |
b: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
118 |
unused: Byte; |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
119 |
); |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
120 |
(* workaround over freepascal bug. |
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
121 |
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
|
122 |
1: (value: Longword); |
4 | 123 |
end; |
124 |
||
125 |
PSDL_RWops = ^TSDL_RWops; |
|
105 | 126 |
TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; |
127 |
TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; |
|
128 |
TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; |
|
129 |
TClose = function( context: PSDL_RWops ): LongInt; cdecl; |
|
4 | 130 |
|
131 |
TStdio = record |
|
105 | 132 |
autoclose: LongInt; |
4 | 133 |
fp: pointer; |
134 |
end; |
|
135 |
||
136 |
TMem = record |
|
137 |
base: PByte; |
|
138 |
here: PByte; |
|
139 |
stop: PByte; |
|
140 |
end; |
|
141 |
||
142 |
TUnknown = record |
|
143 |
data1: Pointer; |
|
144 |
end; |
|
145 |
||
146 |
TSDL_RWops = record |
|
147 |
seek: TSeek; |
|
148 |
read: TRead; |
|
149 |
write: TWrite; |
|
150 |
close: TClose; |
|
151 |
type_: Longword; |
|
152 |
case Byte of |
|
153 |
0: (stdio: TStdio); |
|
154 |
1: (mem: TMem); |
|
155 |
2: (unknown: TUnknown); |
|
156 |
end; |
|
157 |
||
158 |
TSDL_KeySym = record |
|
159 |
scancode: Byte; |
|
106 | 160 |
sym: Longword; |
4 | 161 |
modifier: Longword; |
162 |
unicode: Word; |
|
163 |
end; |
|
164 |
||
308 | 165 |
TSDL_ActiveEvent = record |
166 |
type_: byte; |
|
167 |
gain: byte; |
|
168 |
state: byte; |
|
169 |
end; |
|
170 |
||
4 | 171 |
TSDL_KeyboardEvent = record |
172 |
type_: Byte; |
|
173 |
which: Byte; |
|
174 |
state: Byte; |
|
175 |
keysym: TSDL_KeySym; |
|
176 |
end; |
|
177 |
||
178 |
TSDL_QuitEvent = record |
|
179 |
type_: Byte; |
|
180 |
end; |
|
181 |
PSDL_Event = ^TSDL_Event; |
|
182 |
TSDL_Event = record |
|
183 |
case Byte of |
|
184 |
SDL_NOEVENT: (type_: byte); |
|
308 | 185 |
SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); |
4 | 186 |
SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent); |
187 |
SDL_QUITEV: (quit: TSDL_QuitEvent); |
|
188 |
end; |
|
189 |
||
190 |
PByteArray = ^TByteArray; |
|
316 | 191 |
TByteArray = array[0..65535] of Byte; |
192 |
PLongWordArray = ^TLongWordArray; |
|
193 |
TLongWordArray = array[0..16383] of LongWord; |
|
4 | 194 |
|
433 | 195 |
PSDL_Thread = Pointer; |
196 |
PSDL_mutex = Pointer; |
|
197 |
||
432 | 198 |
function SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName; |
4 | 199 |
procedure SDL_Quit; cdecl; external SDLLibName; |
432 | 200 |
function SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName; |
201 |
procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName; |
|
4 | 202 |
|
203 |
procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName; |
|
204 |
function SDL_GetTicks: Longword; cdecl; external SDLLibName; |
|
205 |
||
206 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
432 | 207 |
function SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 208 |
procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
209 |
||
210 |
function SDL_GetError: PChar; cdecl; external SDLLibName; |
|
211 |
||
432 | 212 |
function SDL_SetVideoMode(width, height, bpp: LongInt; flags: Longword): PSDL_Surface; cdecl; external SDLLibName; |
213 |
function SDL_CreateRGBSurface(flags: Longword; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
214 |
function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
4 | 215 |
procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
105 | 216 |
function SDL_SetColorKey(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName; |
4 | 217 |
|
105 | 218 |
function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName; |
219 |
function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: Longword): LongInt; cdecl; external SDLLibName; |
|
220 |
procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: Longword); cdecl; external SDLLibName; |
|
432 | 221 |
function SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 222 |
|
223 |
procedure SDL_GetRGB(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName; |
|
107 | 224 |
function SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): Longword; cdecl; external SDLLibName; |
4 | 225 |
|
226 |
function SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
|
35 | 227 |
function SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
4 | 228 |
|
229 |
function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName; |
|
432 | 230 |
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 231 |
|
105 | 232 |
function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName; |
107 | 233 |
function SDL_GetMouseState(x, y: PInteger): Byte; cdecl; external SDLLibName; |
4 | 234 |
function SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName; |
235 |
procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName; |
|
236 |
||
432 | 237 |
function SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName; |
4 | 238 |
|
432 | 239 |
function SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 240 |
|
241 |
procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName; |
|
242 |
||
433 | 243 |
function SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName; |
244 |
procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName; |
|
245 |
function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP'; |
|
246 |
function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV'; |
|
247 |
||
753 | 248 |
function SDL_GL_SetAttribute(attr: byte; value: LongInt): LongInt; cdecl; external SDLLibName; |
249 |
procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName; |
|
250 |
||
4 | 251 |
(* TTF *) |
252 |
||
253 |
const {$IFDEF WIN32} |
|
254 |
SDL_TTFLibName = 'SDL_ttf.dll'; |
|
255 |
{$ENDIF} |
|
256 |
{$IFDEF UNIX} |
|
257 |
SDL_TTFLibName = 'libSDL_ttf.so'; |
|
258 |
{$ENDIF} |
|
202 | 259 |
TTF_STYLE_NORMAL = 0; |
260 |
TTF_STYLE_BOLD = 1; |
|
261 |
TTF_STYLE_ITALIC = 2; |
|
4 | 262 |
|
263 |
type PTTF_Font = ^TTTF_font; |
|
264 |
TTTF_Font = record |
|
265 |
end; |
|
266 |
||
432 | 267 |
function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
4 | 268 |
procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
269 |
||
270 |
||
432 | 271 |
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
|
272 |
(* 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
|
273 |
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
|
274 |
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
|
275 |
function TTF_RenderUTF8_Blended(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
|
276 |
|
432 | 277 |
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
278 |
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
4 | 279 |
|
280 |
(* SDL_mixer *) |
|
281 |
||
282 |
const {$IFDEF WIN32} |
|
283 |
SDL_MixerLibName = 'SDL_mixer.dll'; |
|
284 |
{$ENDIF} |
|
285 |
{$IFDEF UNIX} |
|
286 |
SDL_MixerLibName = 'libSDL_mixer.so'; |
|
287 |
{$ENDIF} |
|
288 |
||
174 | 289 |
const MIX_MAX_VOLUME = 128; |
290 |
||
4 | 291 |
type PMixChunk = ^TMixChunk; |
292 |
TMixChunk = record |
|
293 |
allocated: Longword; |
|
294 |
abuf : PByte; |
|
295 |
alen : Longword; |
|
296 |
volume : PByte; |
|
106 | 297 |
end; |
4 | 298 |
TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
299 |
TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
300 |
||
301 |
TMidiSong = record |
|
105 | 302 |
samples : LongInt; |
4 | 303 |
events : pointer; |
304 |
end; |
|
305 |
||
306 |
TMusicUnion = record |
|
307 |
case Byte of |
|
308 |
0: ( midi : TMidiSong ); |
|
309 |
1: ( ogg : pointer); |
|
310 |
end; |
|
311 |
||
312 |
PMixMusic = ^TMixMusic; |
|
313 |
TMixMusic = record |
|
314 |
end; |
|
315 |
||
105 | 316 |
function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 317 |
procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
318 |
||
174 | 319 |
function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
320 |
function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
|
105 | 321 |
function Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 322 |
|
174 | 323 |
function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 324 |
procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName; |
325 |
procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName; |
|
326 |
||
105 | 327 |
function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: LongInt): PMixChunk; cdecl; external SDL_MixerLibName; |
4 | 328 |
function Mix_LoadMUS(const filename: PChar): PMixMusic; cdecl; external SDL_MixerLibName; |
329 |
||
105 | 330 |
function Mix_Playing(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
331 |
function Mix_PlayingMusic: LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 332 |
|
105 | 333 |
function Mix_PlayChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
334 |
function Mix_PlayMusic(music: PMixMusic; loops: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
335 |
function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 336 |
|
337 |
(* SDL_image *) |
|
338 |
||
339 |
const {$IFDEF WIN32} |
|
340 |
SDL_ImageLibName = 'SDL_image.dll'; |
|
341 |
{$ENDIF} |
|
342 |
{$IFDEF UNIX} |
|
343 |
SDL_ImageLibName = 'libSDL_image.so'; |
|
344 |
{$ENDIF} |
|
345 |
||
346 |
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
347 |
||
348 |
(* SDL_net *) |
|
349 |
||
350 |
const {$IFDEF WIN32} |
|
351 |
SDL_NetLibName = 'SDL_net.dll'; |
|
352 |
{$ENDIF} |
|
353 |
{$IFDEF UNIX} |
|
354 |
SDL_NetLibName = 'libSDL_net.so'; |
|
355 |
{$ENDIF} |
|
356 |
||
357 |
type TIPAddress = record |
|
358 |
host: Longword; |
|
359 |
port: Word; |
|
360 |
end; |
|
361 |
||
362 |
PTCPSocket = ^TTCPSocket; |
|
363 |
TTCPSocket = record |
|
106 | 364 |
ready: LongInt; |
105 | 365 |
channel: LongInt; |
106 | 366 |
remoteAddress: TIPaddress; |
4 | 367 |
localAddress: TIPaddress; |
105 | 368 |
sflag: LongInt; |
4 | 369 |
end; |
370 |
PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
371 |
TSDLNet_SocketSet = record |
|
372 |
numsockets, |
|
105 | 373 |
maxsockets: LongInt; |
4 | 374 |
sockets: PTCPSocket; |
375 |
end; |
|
376 |
||
105 | 377 |
function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
4 | 378 |
procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
379 |
||
105 | 380 |
function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
381 |
function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 382 |
function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
383 |
function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
105 | 384 |
function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
385 |
function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 386 |
procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
387 |
procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
105 | 388 |
function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
389 |
function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 390 |
|
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
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
|
394 |
function SDLNet_Read32(buf: pointer): LongWord; |
4 | 395 |
|
396 |
implementation |
|
397 |
||
398 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
399 |
begin |
|
432 | 400 |
SDL_MustLock:= ( surface^.offset <> 0 ) |
4 | 401 |
or(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
402 |
end; |
|
403 |
||
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
404 |
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
|
405 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
406 |
PByteArray(buf)^[1]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
407 |
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
|
408 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
409 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
410 |
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
|
411 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
412 |
PByteArray(buf)^[3]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
417 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
418 |
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
|
419 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
420 |
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
|
421 |
(PByteArray(buf)^[0] shl 8) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
422 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
423 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
424 |
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
|
425 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
426 |
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
|
427 |
(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
|
428 |
(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
|
429 |
(PByteArray(buf)^[0] shl 24) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
430 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
431 |
|
4 | 432 |
end. |