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