author | unc0rr |
Wed, 18 Jun 2008 21:53:54 +0000 | |
changeset 1015 | 6f4a1890c60d |
parent 945 | 4ead9cde4e14 |
child 1066 | 1f1b3686a2b0 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
unit SDLh; |
|
20 |
interface |
|
753 | 21 |
|
4 | 22 |
{$IFDEF LINUX} |
23 |
{$DEFINE UNIX} |
|
24 |
{$ENDIF} |
|
25 |
{$IFDEF FREEBSD} |
|
26 |
{$DEFINE UNIX} |
|
27 |
{$ENDIF} |
|
28 |
||
29 |
{$IFDEF UNIX} |
|
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; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
54 |
|
4 | 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; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
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; |
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
279 |
function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
206
32fa6282efe2
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
unc0rr
parents:
202
diff
changeset
|
280 |
|
432 | 281 |
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
282 |
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
4 | 283 |
|
284 |
(* SDL_mixer *) |
|
285 |
||
286 |
const {$IFDEF WIN32} |
|
287 |
SDL_MixerLibName = 'SDL_mixer.dll'; |
|
288 |
{$ENDIF} |
|
289 |
{$IFDEF UNIX} |
|
290 |
SDL_MixerLibName = 'libSDL_mixer.so'; |
|
291 |
{$ENDIF} |
|
292 |
||
174 | 293 |
const MIX_MAX_VOLUME = 128; |
294 |
||
4 | 295 |
type PMixChunk = ^TMixChunk; |
296 |
TMixChunk = record |
|
297 |
allocated: Longword; |
|
298 |
abuf : PByte; |
|
299 |
alen : Longword; |
|
300 |
volume : PByte; |
|
106 | 301 |
end; |
4 | 302 |
TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
303 |
TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
304 |
||
305 |
TMidiSong = record |
|
105 | 306 |
samples : LongInt; |
4 | 307 |
events : pointer; |
308 |
end; |
|
309 |
||
310 |
TMusicUnion = record |
|
311 |
case Byte of |
|
312 |
0: ( midi : TMidiSong ); |
|
313 |
1: ( ogg : pointer); |
|
314 |
end; |
|
315 |
||
316 |
PMixMusic = ^TMixMusic; |
|
317 |
TMixMusic = record |
|
318 |
end; |
|
319 |
||
105 | 320 |
function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 321 |
procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
322 |
||
174 | 323 |
function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
324 |
function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
|
105 | 325 |
function Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 326 |
|
174 | 327 |
function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
4 | 328 |
procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName; |
329 |
procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName; |
|
330 |
||
105 | 331 |
function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: LongInt): PMixChunk; cdecl; external SDL_MixerLibName; |
4 | 332 |
function Mix_LoadMUS(const filename: PChar): PMixMusic; cdecl; external SDL_MixerLibName; |
333 |
||
105 | 334 |
function Mix_Playing(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
335 |
function Mix_PlayingMusic: LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 336 |
|
105 | 337 |
function Mix_PlayChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
338 |
function Mix_PlayMusic(music: PMixMusic; loops: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
339 |
function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
4 | 340 |
|
341 |
(* SDL_image *) |
|
342 |
||
343 |
const {$IFDEF WIN32} |
|
344 |
SDL_ImageLibName = 'SDL_image.dll'; |
|
345 |
{$ENDIF} |
|
346 |
{$IFDEF UNIX} |
|
347 |
SDL_ImageLibName = 'libSDL_image.so'; |
|
348 |
{$ENDIF} |
|
349 |
||
350 |
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
351 |
||
352 |
(* SDL_net *) |
|
353 |
||
354 |
const {$IFDEF WIN32} |
|
355 |
SDL_NetLibName = 'SDL_net.dll'; |
|
356 |
{$ENDIF} |
|
357 |
{$IFDEF UNIX} |
|
358 |
SDL_NetLibName = 'libSDL_net.so'; |
|
359 |
{$ENDIF} |
|
360 |
||
361 |
type TIPAddress = record |
|
362 |
host: Longword; |
|
363 |
port: Word; |
|
364 |
end; |
|
365 |
||
366 |
PTCPSocket = ^TTCPSocket; |
|
367 |
TTCPSocket = record |
|
106 | 368 |
ready: LongInt; |
105 | 369 |
channel: LongInt; |
106 | 370 |
remoteAddress: TIPaddress; |
4 | 371 |
localAddress: TIPaddress; |
105 | 372 |
sflag: LongInt; |
4 | 373 |
end; |
374 |
PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
375 |
TSDLNet_SocketSet = record |
|
376 |
numsockets, |
|
105 | 377 |
maxsockets: LongInt; |
4 | 378 |
sockets: PTCPSocket; |
379 |
end; |
|
380 |
||
105 | 381 |
function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
4 | 382 |
procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
383 |
||
105 | 384 |
function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
385 |
function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 386 |
function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
387 |
function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
105 | 388 |
function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
389 |
function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 390 |
procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
391 |
procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
105 | 392 |
function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
393 |
function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 394 |
|
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
function SDLNet_Read32(buf: pointer): LongWord; |
4 | 399 |
|
400 |
implementation |
|
401 |
||
402 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
403 |
begin |
|
432 | 404 |
SDL_MustLock:= ( surface^.offset <> 0 ) |
4 | 405 |
or(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
406 |
end; |
|
407 |
||
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
408 |
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
|
409 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
410 |
PByteArray(buf)^[1]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
411 |
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
|
412 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
413 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
414 |
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
|
415 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
416 |
PByteArray(buf)^[3]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
417 |
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
|
418 |
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
|
419 |
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
|
420 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
421 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
422 |
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
|
423 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
424 |
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
|
425 |
(PByteArray(buf)^[0] shl 8) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
426 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
427 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
428 |
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
|
429 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
430 |
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
|
431 |
(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
|
432 |
(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
|
433 |
(PByteArray(buf)^[0] shl 24) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
434 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
435 |
|
4 | 436 |
end. |