author | unc0rr |
Thu, 10 Sep 2009 18:50:53 +0000 | |
changeset 2379 | d62b1f224982 |
parent 2376 | ece7b87f1334 |
child 2390 | 57fb33ab04a4 |
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 |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
22 |
{$IFDEF LINUX or FREEBSD} |
4 | 23 |
{$DEFINE UNIX} |
24 |
{$ENDIF} |
|
25 |
||
26 |
{$IFDEF UNIX} |
|
1903 | 27 |
{$IFNDEF DARWIN} |
1556
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
28 |
{$linklib c} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
29 |
{$ENDIF} |
3369f016b79d
Patch for engine to successfully build on Mac OS X by Michael Schindler
unc0rr
parents:
1225
diff
changeset
|
30 |
{$linklib pthread} |
4 | 31 |
{$ENDIF} |
32 |
||
432 | 33 |
{$PACKRECORDS C} |
4 | 34 |
|
1819 | 35 |
{$IFDEF DARWIN} |
2200
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
36 |
{$PASCALMAINNAME SDL_main} |
2152 | 37 |
{$IFNDEF IPHONEOS} |
2200
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
38 |
{$linkframework Cocoa} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
39 |
{$linkframework SDL} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
40 |
{$linkframework SDL_net} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
41 |
{$linkframework SDL_image} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
42 |
{$linkframework SDL_ttf} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
43 |
{$linklib openalbridge} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
44 |
{$linklib SDLmain} |
8192be6e3aef
koda/Smaxx changes to openal for crossplatform building
nemo
parents:
2191
diff
changeset
|
45 |
{$linklib gcc} |
1819 | 46 |
{$ENDIF} |
1916 | 47 |
{$ENDIF} |
1819 | 48 |
|
1997 | 49 |
(* SDL *) |
4 | 50 |
const {$IFDEF WIN32} |
2379 | 51 |
SDLLibName = 'SDL.dll'; |
52 |
{$ENDIF} |
|
53 |
{$IFDEF UNIX} |
|
54 |
{$IFDEF DARWIN} |
|
55 |
SDLLibName = 'SDL'; |
|
56 |
{$ELSE} |
|
57 |
SDLLibName = 'libSDL.so'; |
|
58 |
{$ENDIF} |
|
59 |
{$ENDIF} |
|
60 |
SDL_SWSURFACE = $00000000; |
|
61 |
SDL_HWSURFACE = $00000001; |
|
62 |
SDL_SRCALPHA = $00010000; |
|
63 |
SDL_INIT_VIDEO = $00000020; |
|
64 |
SDL_INIT_AUDIO = $00000010; |
|
2240
7ce9e6b7be3b
-Removal of older WAV files, now useless thanks to OpenAL
koda
parents:
2200
diff
changeset
|
65 |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
66 |
{$IFDEF SDL13} |
2379 | 67 |
SDL_ASYNCBLIT = $08000000; |
68 |
SDL_ANYFORMAT = $10000000; |
|
69 |
SDL_HWPALETTE = $00200000; |
|
70 |
SDL_DOUBLEBUF = $00400000; |
|
71 |
SDL_FULLSCREEN = $00800000; |
|
72 |
SDL_HWACCEL = $08000000; |
|
73 |
SDL_SRCCOLORKEY = $00020000; |
|
74 |
SDL_RLEACCEL = $08000000; |
|
75 |
SDL_NOFRAME = $02000000; |
|
76 |
SDL_OPENGL = $04000000; |
|
77 |
SDL_RESIZABLE = $01000000; |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
78 |
{$ELSE} |
2379 | 79 |
SDL_ASYNCBLIT = $00000004; |
80 |
SDL_ANYFORMAT = $00100000; |
|
81 |
SDL_HWPALETTE = $20000000; |
|
82 |
SDL_DOUBLEBUF = $40000000; |
|
83 |
SDL_FULLSCREEN = $80000000; |
|
84 |
SDL_HWACCEL = $00000100; |
|
85 |
SDL_SRCCOLORKEY = $00001000; |
|
86 |
SDL_RLEACCEL = $00004000; |
|
87 |
SDL_NOFRAME = $00000020; |
|
88 |
SDL_OPENGL = $00000002; |
|
89 |
SDL_RESIZABLE = $00000010; |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
90 |
{$ENDIF} |
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
91 |
|
2379 | 92 |
SDL_NOEVENT = 0; |
93 |
SDL_ACTIVEEVENT = 1; |
|
94 |
SDL_KEYDOWN = 2; |
|
95 |
SDL_KEYUP = 3; |
|
96 |
SDL_MOUSEBUTTONDOWN = 5; |
|
97 |
SDL_MOUSEBUTTONUP = 6; |
|
98 |
SDL_QUITEV = 12; |
|
99 |
SDL_VIDEORESIZE = 16; |
|
4 | 100 |
|
2242 | 101 |
{$IFDEF SDL13} |
2379 | 102 |
SDL_MOUSEMOTION = 5; |
2242 | 103 |
{$ENDIF} |
104 |
||
2379 | 105 |
SDL_APPINPUTFOCUS = 2; |
106 |
SDL_BUTTON_WHEELDUP = 4; |
|
107 |
SDL_BUTTON_WHEELDOWN = 5; |
|
753 | 108 |
|
2379 | 109 |
RMask = $000000FF; |
110 |
GMask = $0000FF00; |
|
111 |
BMask = $00FF0000; |
|
112 |
AMask = $FF000000; |
|
754 | 113 |
|
4 | 114 |
type PSDL_Rect = ^TSDL_Rect; |
2379 | 115 |
TSDL_Rect = record |
116 |
{$IFDEF SDL13} |
|
117 |
x, y, w, h: LongInt; |
|
118 |
{$ELSE} |
|
119 |
x, y: SmallInt; |
|
120 |
w, h: Word; |
|
121 |
{$ENDIF} |
|
122 |
end; |
|
4 | 123 |
|
2379 | 124 |
TPoint = record |
125 |
X: LongInt; |
|
126 |
Y: LongInt; |
|
127 |
end; |
|
4 | 128 |
|
2379 | 129 |
PSDL_PixelFormat = ^TSDL_PixelFormat; |
130 |
TSDL_PixelFormat = record |
|
131 |
palette: Pointer; |
|
132 |
BitsPerPixel : Byte; |
|
133 |
BytesPerPixel: Byte; |
|
134 |
Rloss : Byte; |
|
135 |
Gloss : Byte; |
|
136 |
Bloss : Byte; |
|
137 |
Aloss : Byte; |
|
138 |
Rshift: Byte; |
|
139 |
Gshift: Byte; |
|
140 |
Bshift: Byte; |
|
141 |
Ashift: Byte; |
|
142 |
RMask : Longword; |
|
143 |
GMask : Longword; |
|
144 |
BMask : Longword; |
|
145 |
AMask : Longword; |
|
146 |
colorkey: Longword; |
|
147 |
alpha : Byte; |
|
148 |
end; |
|
4 | 149 |
|
150 |
||
2379 | 151 |
PSDL_Surface = ^TSDL_Surface; |
152 |
TSDL_Surface = record |
|
153 |
flags : Longword; |
|
154 |
format: PSDL_PixelFormat; |
|
155 |
w, h : LongInt; |
|
156 |
pitch : Word; |
|
157 |
pixels: Pointer; |
|
158 |
offset: LongInt; |
|
159 |
end; |
|
4 | 160 |
|
2248
26e11cb27c61
real fix for iphone color (reverting previous commit)
koda
parents:
2242
diff
changeset
|
161 |
|
2379 | 162 |
PSDL_Color = ^TSDL_Color; |
163 |
TSDL_Color = record |
|
164 |
case byte of |
|
165 |
0: (r: Byte; |
|
166 |
g: Byte; |
|
167 |
b: Byte; |
|
168 |
unused: Byte; |
|
169 |
); |
|
170 |
1: (value: Longword); |
|
171 |
end; |
|
4 | 172 |
|
2248
26e11cb27c61
real fix for iphone color (reverting previous commit)
koda
parents:
2242
diff
changeset
|
173 |
|
2379 | 174 |
PSDL_RWops = ^TSDL_RWops; |
175 |
TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; |
|
176 |
TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; |
|
177 |
TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; |
|
178 |
TClose = function( context: PSDL_RWops ): LongInt; cdecl; |
|
4 | 179 |
|
2379 | 180 |
TStdio = record |
181 |
autoclose: LongInt; |
|
182 |
fp: pointer; |
|
183 |
end; |
|
184 |
||
185 |
TMem = record |
|
186 |
base: PByte; |
|
187 |
here: PByte; |
|
188 |
stop: PByte; |
|
189 |
end; |
|
4 | 190 |
|
2379 | 191 |
TUnknown = record |
192 |
data1: Pointer; |
|
193 |
end; |
|
4 | 194 |
|
2379 | 195 |
TSDL_RWops = record |
196 |
seek: TSeek; |
|
197 |
read: TRead; |
|
198 |
write: TWrite; |
|
199 |
close: TClose; |
|
200 |
type_: Longword; |
|
201 |
case Byte of |
|
202 |
0: (stdio: TStdio); |
|
203 |
1: (mem: TMem); |
|
204 |
2: (unknown: TUnknown); |
|
205 |
end; |
|
206 |
||
207 |
TSDL_KeySym = record |
|
208 |
scancode: Byte; |
|
209 |
sym: Longword; |
|
210 |
modifier: Longword; |
|
211 |
unicode: Word; |
|
212 |
end; |
|
4 | 213 |
|
2379 | 214 |
TSDL_ActiveEvent = record |
215 |
type_: byte; |
|
216 |
gain: byte; |
|
217 |
state: byte; |
|
218 |
end; |
|
4 | 219 |
|
2379 | 220 |
TSDL_KeyboardEvent = record |
221 |
type_: Byte; |
|
222 |
which: Byte; |
|
223 |
state: Byte; |
|
224 |
keysym: TSDL_KeySym; |
|
225 |
end; |
|
308 | 226 |
|
2379 | 227 |
TSDL_MouseButtonEvent = record |
228 |
_type, |
|
229 |
which, |
|
230 |
button, |
|
231 |
state: byte; |
|
232 |
x, y: word; |
|
233 |
end; |
|
2376 | 234 |
|
2379 | 235 |
TSDL_GLattr = ( |
236 |
SDL_GL_RED_SIZE, |
|
237 |
SDL_GL_GREEN_SIZE, |
|
238 |
SDL_GL_BLUE_SIZE, |
|
239 |
SDL_GL_ALPHA_SIZE, |
|
240 |
SDL_GL_BUFFER_SIZE, |
|
241 |
SDL_GL_DOUBLEBUFFER, |
|
242 |
SDL_GL_DEPTH_SIZE, |
|
243 |
SDL_GL_STENCIL_SIZE, |
|
244 |
SDL_GL_ACCUM_RED_SIZE, |
|
245 |
SDL_GL_ACCUM_GREEN_SIZE, |
|
246 |
SDL_GL_ACCUM_BLUE_SIZE, |
|
247 |
SDL_GL_ACCUM_ALPHA_SIZE, |
|
248 |
SDL_GL_STEREO, |
|
249 |
SDL_GL_MULTISAMPLEBUFFERS, |
|
250 |
SDL_GL_MULTISAMPLESAMPLES, |
|
251 |
SDL_GL_ACCELERATED_VISUAL, |
|
252 |
SDL_GL_RETAINED_BACKING, |
|
253 |
SDL_GL_CONTEXT_MAJOR_VERSION, |
|
254 |
SDL_GL_CONTEXT_MINOR_VERSION |
|
255 |
); |
|
2376 | 256 |
|
2252 | 257 |
{$IFDEF SDL13} |
258 |
TSDL_MouseMotionEvent = record |
|
259 |
type_: byte; |
|
260 |
which: byte; |
|
261 |
state: byte; |
|
262 |
x : LongInt; |
|
263 |
y : LongInt; |
|
264 |
xrel : LongInt; |
|
265 |
yrel : LongInt; |
|
266 |
end; |
|
267 |
{$ENDIF} |
|
4 | 268 |
|
269 |
TSDL_QuitEvent = record |
|
270 |
type_: Byte; |
|
271 |
end; |
|
2252 | 272 |
TSDL_ResizeEvent = record |
1120 | 273 |
type_: Byte; |
274 |
w, h: LongInt; |
|
275 |
end; |
|
276 |
||
4 | 277 |
PSDL_Event = ^TSDL_Event; |
278 |
TSDL_Event = record |
|
279 |
case Byte of |
|
280 |
SDL_NOEVENT: (type_: byte); |
|
308 | 281 |
SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); |
4 | 282 |
SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent); |
283 |
SDL_QUITEV: (quit: TSDL_QuitEvent); |
|
1120 | 284 |
SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); |
2379 | 285 |
SDL_MOUSEBUTTONDOWN, |
286 |
SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); |
|
2252 | 287 |
{$IFDEF SDL13} |
288 |
SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); |
|
289 |
{$ENDIF} |
|
290 |
end; |
|
4 | 291 |
|
292 |
PByteArray = ^TByteArray; |
|
316 | 293 |
TByteArray = array[0..65535] of Byte; |
294 |
PLongWordArray = ^TLongWordArray; |
|
295 |
TLongWordArray = array[0..16383] of LongWord; |
|
4 | 296 |
|
433 | 297 |
PSDL_Thread = Pointer; |
298 |
PSDL_mutex = Pointer; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
883
diff
changeset
|
299 |
|
432 | 300 |
function SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName; |
4 | 301 |
procedure SDL_Quit; cdecl; external SDLLibName; |
432 | 302 |
function SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName; |
303 |
procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName; |
|
4 | 304 |
|
305 |
procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName; |
|
306 |
function SDL_GetTicks: Longword; cdecl; external SDLLibName; |
|
307 |
||
308 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
432 | 309 |
function SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 310 |
procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
311 |
||
312 |
function SDL_GetError: PChar; cdecl; external SDLLibName; |
|
313 |
||
432 | 314 |
function SDL_SetVideoMode(width, height, bpp: LongInt; flags: Longword): PSDL_Surface; cdecl; external SDLLibName; |
315 |
function SDL_CreateRGBSurface(flags: Longword; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
316 |
function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName; |
|
4 | 317 |
procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; |
105 | 318 |
function SDL_SetColorKey(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName; |
2017 | 319 |
function SDL_SetAlpha(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName; |
2248
26e11cb27c61
real fix for iphone color (reverting previous commit)
koda
parents:
2242
diff
changeset
|
320 |
function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongInt): PSDL_Surface; cdecl; external SDLLibName; |
4 | 321 |
|
105 | 322 |
function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName; |
323 |
function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: Longword): LongInt; cdecl; external SDLLibName; |
|
324 |
procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: Longword); cdecl; external SDLLibName; |
|
432 | 325 |
function SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName; |
4 | 326 |
|
327 |
procedure SDL_GetRGB(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName; |
|
107 | 328 |
function SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): Longword; cdecl; external SDLLibName; |
4 | 329 |
|
330 |
function SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
|
35 | 331 |
function SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName; |
4 | 332 |
|
333 |
function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName; |
|
432 | 334 |
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 335 |
|
2152 | 336 |
{$IFDEF SDL13} |
337 |
function SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName; |
|
2242 | 338 |
function SDL_GetMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName; |
339 |
function SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName; |
|
340 |
function SDL_GetRelativeMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName; |
|
341 |
function SDL_GetNumMice : LongInt; cdecl; external SDLLibName; |
|
2152 | 342 |
{$ELSE} |
105 | 343 |
function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName; |
2242 | 344 |
function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName; |
2152 | 345 |
{$ENDIF} |
4 | 346 |
function SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName; |
347 |
procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName; |
|
348 |
||
432 | 349 |
function SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName; |
4 | 350 |
|
432 | 351 |
function SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName; |
4 | 352 |
|
353 |
procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName; |
|
354 |
||
433 | 355 |
function SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName; |
356 |
procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName; |
|
357 |
function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP'; |
|
358 |
function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV'; |
|
359 |
||
2252 | 360 |
function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName; |
753 | 361 |
procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName; |
362 |
||
2254 | 363 |
{$IFDEF SDL13} |
364 |
{$IFDEF IPHONEOS} |
|
365 |
function SDL_iPhoneKeyboardShow(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
|
366 |
function SDL_iPhoneKeyboardHide(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
|
367 |
function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName; |
|
368 |
function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
|
369 |
{$ENDIF} |
|
370 |
{$ENDIF} |
|
371 |
||
4 | 372 |
(* TTF *) |
373 |
||
374 |
const {$IFDEF WIN32} |
|
375 |
SDL_TTFLibName = 'SDL_ttf.dll'; |
|
376 |
{$ENDIF} |
|
377 |
{$IFDEF UNIX} |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
378 |
{$IFDEF DARWIN} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
379 |
SDL_TTFLibName = 'SDL_ttf'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
380 |
{$ELSE} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
381 |
SDL_TTFLibName = 'libSDL_ttf.so'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
382 |
{$ENDIF} |
4 | 383 |
{$ENDIF} |
202 | 384 |
TTF_STYLE_NORMAL = 0; |
385 |
TTF_STYLE_BOLD = 1; |
|
386 |
TTF_STYLE_ITALIC = 2; |
|
4 | 387 |
|
388 |
type PTTF_Font = ^TTTF_font; |
|
389 |
TTTF_Font = record |
|
390 |
end; |
|
391 |
||
2254 | 392 |
function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
4 | 393 |
procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
394 |
||
395 |
||
2254 | 396 |
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
|
397 |
(* 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
|
398 |
See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
2254 | 399 |
function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
400 |
function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
401 |
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
|
402 |
|
2254 | 403 |
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
432 | 404 |
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
4 | 405 |
|
406 |
||
1997 | 407 |
(* SDL_image *) |
4 | 408 |
|
409 |
const {$IFDEF WIN32} |
|
410 |
SDL_ImageLibName = 'SDL_image.dll'; |
|
411 |
{$ENDIF} |
|
412 |
{$IFDEF UNIX} |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
413 |
{$IFDEF DARWIN} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
414 |
SDL_ImageLibName = 'SDL_image'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
415 |
{$ELSE} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
416 |
SDL_ImageLibName = 'libSDL_image.so'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
417 |
{$ENDIF} |
4 | 418 |
{$ENDIF} |
419 |
||
420 |
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
421 |
||
1997 | 422 |
(* SDL_net *) |
4 | 423 |
|
424 |
const {$IFDEF WIN32} |
|
425 |
SDL_NetLibName = 'SDL_net.dll'; |
|
426 |
{$ENDIF} |
|
427 |
{$IFDEF UNIX} |
|
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
428 |
{$IFDEF DARWIN} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
429 |
SDL_NetLibName = 'SDL_net'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
430 |
{$ELSE} |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
431 |
SDL_NetLibName = 'libSDL_net.so'; |
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
432 |
{$ENDIF} |
4 | 433 |
{$ENDIF} |
434 |
||
435 |
type TIPAddress = record |
|
436 |
host: Longword; |
|
437 |
port: Word; |
|
438 |
end; |
|
439 |
||
440 |
PTCPSocket = ^TTCPSocket; |
|
441 |
TTCPSocket = record |
|
106 | 442 |
ready: LongInt; |
105 | 443 |
channel: LongInt; |
106 | 444 |
remoteAddress: TIPaddress; |
4 | 445 |
localAddress: TIPaddress; |
105 | 446 |
sflag: LongInt; |
4 | 447 |
end; |
448 |
PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
449 |
TSDLNet_SocketSet = record |
|
450 |
numsockets, |
|
105 | 451 |
maxsockets: LongInt; |
4 | 452 |
sockets: PTCPSocket; |
453 |
end; |
|
454 |
||
2254 | 455 |
function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
4 | 456 |
procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
457 |
||
2254 | 458 |
function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
459 |
function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
460 |
function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
|
461 |
function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
462 |
function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
463 |
function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 464 |
procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
465 |
procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
2254 | 466 |
function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
467 |
function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
4 | 468 |
|
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
469 |
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
|
470 |
procedure SDLNet_Write32(value: LongWord; buf: pointer); |
2254 | 471 |
function SDLNet_Read16(buf: pointer): Word; |
472 |
function SDLNet_Read32(buf: pointer): LongWord; |
|
4 | 473 |
|
474 |
implementation |
|
475 |
||
476 |
function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
|
477 |
begin |
|
432 | 478 |
SDL_MustLock:= ( surface^.offset <> 0 ) |
4 | 479 |
or(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
480 |
end; |
|
481 |
||
459
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
482 |
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
|
483 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
484 |
PByteArray(buf)^[1]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
485 |
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
|
486 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
487 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
488 |
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
|
489 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
490 |
PByteArray(buf)^[3]:= value; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
495 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
496 |
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
|
497 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
498 |
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
|
499 |
(PByteArray(buf)^[0] shl 8) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
500 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
501 |
|
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
502 |
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
|
503 |
begin |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
504 |
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
|
505 |
(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
|
506 |
(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
|
507 |
(PByteArray(buf)^[0] shl 24) |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
508 |
end; |
95163c6efa69
Do not use SDL_Net's to/from network byte order conversion functions
unc0rr
parents:
433
diff
changeset
|
509 |
|
4 | 510 |
end. |
2241
7992f7ba388d
completes removal of wav files, updates SDLh and adds DEBUGFILE to hwengine when compiled in Debug mode
koda
parents:
2240
diff
changeset
|
511 |