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