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