author | displacer |
Wed, 21 Feb 2007 23:16:54 +0000 | |
changeset 480 | 09434d6c3865 |
parent 467 | 20d36f976b25 |
child 500 | d9b140e9d2c2 |
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_CreateThread(fn: pointer; data: pointer): PSDL_Thread; cdecl; external SDLLibName; |
240 |
procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName; |
|
241 |
function SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName; |
|
242 |
procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName; |
|
243 |
function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP'; |
|
244 |
function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV'; |
|
245 |
||
4 | 246 |
(* TTF *) |
247 |
||
248 |
const {$IFDEF WIN32} |
|
249 |
SDL_TTFLibName = 'SDL_ttf.dll'; |
|
250 |
{$ENDIF} |
|
251 |
{$IFDEF UNIX} |
|
252 |
SDL_TTFLibName = 'libSDL_ttf.so'; |
|
253 |
{$ENDIF} |
|
202 | 254 |
TTF_STYLE_NORMAL = 0; |
255 |
TTF_STYLE_BOLD = 1; |
|
256 |
TTF_STYLE_ITALIC = 2; |
|
4 | 257 |
|
258 |
type PTTF_Font = ^TTTF_font; |
|
259 |
TTTF_Font = record |
|
260 |
end; |
|
261 |
||
432 | 262 |
function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
4 | 263 |
procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
264 |
||
265 |
||
432 | 266 |
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
|
267 |
(* 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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
|
432 | 272 |
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
273 |
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
4 | 274 |
|
275 |
(* SDL_mixer *) |
|
276 |
||
277 |
const {$IFDEF WIN32} |
|
278 |
SDL_MixerLibName = 'SDL_mixer.dll'; |
|
279 |
{$ENDIF} |
|
280 |
{$IFDEF UNIX} |
|
281 |
SDL_MixerLibName = 'libSDL_mixer.so'; |
|
282 |
{$ENDIF} |
|
283 |
||
174 | 284 |
const MIX_MAX_VOLUME = 128; |
285 |
||
4 | 286 |
type PMixChunk = ^TMixChunk; |
287 |
TMixChunk = record |
|
288 |
allocated: Longword; |
|
289 |
abuf : PByte; |
|
290 |
alen : Longword; |
|
291 |
volume : PByte; |
|
106 | 292 |
end; |
4 | 293 |
TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
294 |
TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
295 |
||
296 |
TMidiSong = record |
|
105 | 297 |
samples : LongInt; |
4 | 298 |
events : pointer; |
299 |
end; |
|
300 |
||
301 |
TMusicUnion = record |
|
302 |
case Byte of |
|
303 |
0: ( midi : TMidiSong ); |
|
304 |
1: ( ogg : pointer); |
|
305 |
end; |
|
306 |
||
307 |
PMixMusic = ^TMixMusic; |
|
308 |
TMixMusic = record |
|
309 |
end; |
|
310 |
||
105 | 311 |
function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 312 |
procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
313 |
||
174 | 314 |
function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
315 |
function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
|
105 | 316 |
function Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 317 |
|
174 | 318 |
function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 319 |
procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName; |
320 |
procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName; |
|
321 |
||
105 | 322 |
function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: LongInt): PMixChunk; cdecl; external SDL_MixerLibName; |
4 | 323 |
function Mix_LoadMUS(const filename: PChar): PMixMusic; cdecl; external SDL_MixerLibName; |
324 |
||
105 | 325 |
function Mix_Playing(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
326 |
function Mix_PlayingMusic: LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 327 |
|
105 | 328 |
function Mix_PlayChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
329 |
function Mix_PlayMusic(music: PMixMusic; loops: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
330 |
function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 331 |
|
332 |
(* SDL_image *) |
|
333 |
||
334 |
const {$IFDEF WIN32} |
|
335 |
SDL_ImageLibName = 'SDL_image.dll'; |
|
336 |
{$ENDIF} |
|
337 |
{$IFDEF UNIX} |
|
338 |
SDL_ImageLibName = 'libSDL_image.so'; |
|
339 |
{$ENDIF} |
|
340 |
||
341 |
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
342 |
||
343 |
(* SDL_net *) |
|
344 |
||
345 |
const {$IFDEF WIN32} |
|
346 |
SDL_NetLibName = 'SDL_net.dll'; |
|
347 |
{$ENDIF} |
|
348 |
{$IFDEF UNIX} |
|
349 |
SDL_NetLibName = 'libSDL_net.so'; |
|
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. |