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